/* ============================================================
   سامانه مدیریت سرویس مدارس - استایل اصلی (RTL)
   ============================================================ */
@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --teal: #0d9488;
  --teal-light: #ccfbf1;
  --purple: #7c3aed;
  --amber: #f59e0b;
  --rose: #e11d48;
  --green: #10b981;
  --red: #ef4444;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.12);
  --grad: linear-gradient(135deg,#2563eb 0%,#0d9488 100%);
  --grad-purple: linear-gradient(135deg,#7c3aed 0%,#2563eb 100%);
  --grad-amber: linear-gradient(135deg,#f59e0b 0%,#e11d48 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.7;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--sidebar);
  color: #cbd5e1;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform .3s;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #1e293b;
}
.brand .logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.brand .t { font-weight: 800; color: #fff; font-size: 15px; line-height: 1.3; }
.brand .s { font-size: 11px; color: #64748b; }

.nav { padding: 14px 12px; flex: 1; }
.nav-group { font-size: 11px; color: #475569; padding: 14px 12px 6px; font-weight: 700; letter-spacing: .5px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 13.5px;
  margin-bottom: 3px;
  transition: .2s;
  font-weight: 500;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.active { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(37,99,235,.35); }
.nav a .ic { font-size: 17px; width: 22px; text-align: center; }
.nav a .badge { margin-right: auto; }

.main { flex: 1; margin-right: 260px; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar .page-title { font-size: 18px; font-weight: 800; }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--bg);
  border-radius: 40px;
  font-size: 13px;
}
.topbar .user-chip .av {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.menu-toggle { display: none; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text); }

.content { padding: 26px; flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
  border: 1px solid rgba(226,232,240,.6);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 16px; font-weight: 800; }
.card-head .spacer { flex: 1; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit,minmax(210px,1fr)); gap: 18px; margin-bottom: 22px; }
.stat {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(226,232,240,.6);
  transition: .25s;
}
.stat:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat::before {
  content: ''; position: absolute; top: 0; right: 0; width: 5px; height: 100%;
  background: var(--grad);
}
.stat.teal::before { background: linear-gradient(135deg,#0d9488,#10b981); }
.stat.purple::before { background: var(--grad-purple); }
.stat.amber::before { background: var(--grad-amber); }
.stat .ic {
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: 12px;
}
.stat.teal .ic { background: var(--teal-light); color: var(--teal); }
.stat.purple .ic { background: #ede9fe; color: var(--purple); }
.stat.amber .ic { background: #fef3c7; color: var(--amber); }
.stat .val { font-size: 26px; font-weight: 800; line-height: 1.2; }
.stat .lbl { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.stat .trend { font-size: 12px; margin-top: 8px; font-weight: 600; }
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--grad);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: .2s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(37,99,235,.35); color: #fff; }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-outline { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: var(--bg); color: var(--text); }
.btn-ghost:hover { background: var(--border); color: var(--text); box-shadow: none; }
.btn-danger { background: linear-gradient(135deg,#ef4444,#e11d48); }
.btn-danger:hover { box-shadow: 0 8px 20px rgba(239,68,68,.35); }
.btn-success { background: linear-gradient(135deg,#10b981,#0d9488); }
.btn-success:hover { box-shadow: 0 8px 20px rgba(16,185,129,.35); }
.btn-warning { background: linear-gradient(135deg,#f59e0b,#f97316); }
.btn-purple { background: var(--grad-purple); }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: 10px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; color: #334155; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=tel], input[type=time], input[type=url], select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  transition: .2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.1);
}
textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 0 16px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
.check input { width: auto; margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: right;
  padding: 13px 14px;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 12.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: .15s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px;
  border-radius: 40px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-green { background: #d1fae5; color: #047857; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-teal { background: var(--teal-light); color: #0f766e; }

/* ---------- Alerts ---------- */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13.5px; font-weight: 500; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.6);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { font-size: 17px; font-weight: 800; }
.modal-head .close { margin-right: auto; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-start; }

/* ---------- Map ---------- */
#map, .map-box { height: 480px; border-radius: var(--radius); overflow: hidden; z-index: 1; }
.map-box.sm { height: 320px; }
.leaflet-container { font-family: Vazirmatn, Tahoma, sans-serif; }

/* ---------- Misc ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit,minmax(300px,1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-sm { font-size: 12.5px; }
.text-lg { font-size: 17px; }
.fw-bold { font-weight: 800; }
.empty { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty .ic { font-size: 52px; margin-bottom: 12px; opacity: .5; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--primary); }
.avatar-lg { width: 72px; height: 72px; font-size: 26px; }
.progress { height: 8px; background: var(--border); border-radius: 10px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--grad); border-radius: 10px; transition: width .4s; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--bg); border-radius: 40px; font-size: 12.5px; font-weight: 600; }
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 11px 18px; font-weight: 700; font-size: 13.5px; color: var(--text-muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg,#1e3a8a 0%,#0f766e 100%);
  position: relative;
  overflow: hidden;
}
.auth-wrap::before {
  content: ''; position: absolute; width: 500px; height: 500px;
  background: rgba(255,255,255,.06); border-radius: 50%;
  top: -200px; left: -150px;
}
.auth-wrap::after {
  content: ''; position: absolute; width: 400px; height: 400px;
  background: rgba(255,255,255,.05); border-radius: 50%;
  bottom: -180px; right: -120px;
}
.auth-card {
  background: #fff; border-radius: 24px;
  box-shadow: 0 30px 70px rgba(0,0,0,.35);
  width: 100%; max-width: 440px;
  padding: 38px 34px;
  position: relative; z-index: 2;
}
.auth-card.wide { max-width: 620px; }
.auth-logo {
  width: 70px; height: 70px; border-radius: 20px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; margin: 0 auto 18px;
  box-shadow: 0 12px 30px rgba(37,99,235,.4);
}
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; font-weight: 800; }
.auth-card .sub { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 26px; }
.auth-foot { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.role-pills { display: flex; gap: 8px; margin-bottom: 20px; }
.role-pills a {
  flex: 1; text-align: center; padding: 10px; border-radius: var(--radius-sm);
  background: var(--bg); font-size: 13px; font-weight: 700; color: var(--text-muted);
}
.role-pills a.active { background: var(--grad); color: #fff; }

/* ---------- PWA bottom nav (mobile) ---------- */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid var(--border);
  z-index: 200; padding: 6px 0;
  box-shadow: 0 -4px 20px rgba(15,23,42,.08);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10.5px; color: var(--text-muted); padding: 6px 2px; font-weight: 600;
}
.bottom-nav a .ic { font-size: 20px; }
.bottom-nav a.active { color: var(--primary); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-right: 26px; }
.timeline::before { content: ''; position: absolute; right: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item::before {
  content: ''; position: absolute; right: -22px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--primary-light);
}
.tl-item.green::before { background: var(--green); box-shadow: 0 0 0 2px #d1fae5; }
.tl-item.amber::before { background: var(--amber); box-shadow: 0 0 0 2px #fef3c7; }
.tl-item .t { font-weight: 700; font-size: 13.5px; }
.tl-item .d { font-size: 12px; color: var(--text-muted); }

/* ---------- Notification list ---------- */
.notif-item { display: flex; gap: 14px; padding: 15px; border-radius: var(--radius-sm); transition: .2s; border: 1px solid transparent; }
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eff6ff; border-color: #bfdbfe; }
.notif-item .ic { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; background: var(--primary-light); color: var(--primary); }
.notif-item.warning .ic { background: #fef3c7; color: var(--amber); }
.notif-item.success .ic { background: #d1fae5; color: var(--green); }
.notif-item.danger .ic { background: #fee2e2; color: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-right: 0; }
  .menu-toggle { display: block; }
  .content { padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .bottom-nav { display: flex; }
  .content { padding-bottom: 80px; }
  .topbar { padding: 12px 16px; }
  .topbar .page-title { font-size: 15px; }
  .stat .val { font-size: 22px; }
}
@media (max-width: 480px) {
  .auth-card { padding: 28px 22px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 15px; }
  .stat .ic { width: 40px; height: 40px; font-size: 20px; }
  .stat .val { font-size: 19px; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .bottom-nav, .btn, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}

/* ---------- Animations ---------- */
.fade-in { animation: fadeIn .4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form fields (new) ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field input, .field select, .field textarea { width: 100%; }
.sep { border: none; border-top: 1px dashed var(--border); margin: 18px 0; }
.gap-2 { gap: 12px; }
.contract-box { font-family: 'Vazirmatn', Tahoma, sans-serif; font-size: 13px; line-height: 2; background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }

/* ---------- Mini stats ---------- */
.mini-stat { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; background: #f8fafc; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.mini-stat .lbl { font-size: 12px; color: var(--text-muted); }
.mini-stat .val { font-size: 14.5px; font-weight: 700; }

/* ---------- Extra badges ---------- */
.badge-success { background: #d1fae5; color: #047857; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-muted { background: #f1f5f9; color: #64748b; }

/* ---------- Timeline dots (numbered) ---------- */
.tl-dot { position: absolute; right: -30px; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px #fff; }
.tl-body { padding-right: 4px; }

/* ---------- Map markers ---------- */
.car-marker { font-size: 26px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
.school-marker { font-size: 24px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }

/* ---------- Attendance list ---------- */
.att-list { display: flex; flex-direction: column; gap: 10px; }
.att-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); flex-wrap: wrap; }
.att-info { flex: 1; min-width: 160px; }
.att-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.att-btn { border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 8px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: .18s; font-family: inherit; }
.att-btn:hover { border-color: var(--primary); }
.att-btn.boarded.on { background: #dbeafe; border-color: #3b82f6; color: #1d4ed8; }
.att-btn.dropped.on { background: #d1fae5; border-color: #10b981; color: #047857; }
.att-btn.absent.on { background: #f1f5f9; border-color: #94a3b8; color: #475569; }
.att-btn.noshow.on { background: #fee2e2; border-color: #ef4444; color: #b91c1c; }

/* ---------- Active trip card ---------- */
.trip-active { border: 2px solid #10b981; box-shadow: 0 0 0 4px #d1fae5; }

/* ---------- Profile modal (floating card) ---------- */
.profile-modal { max-width: 560px; }
.prof-head { display: flex; align-items: center; gap: 16px; padding: 4px 0 18px; border-bottom: 2px solid var(--primary-light); margin-bottom: 16px; }
.prof-avatar { width: 66px; height: 66px; border-radius: 50%; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; flex-shrink: 0; box-shadow: 0 6px 18px rgba(37,99,235,.35); }
.prof-name { font-size: 20px; font-weight: 800; color: var(--text); }
.prof-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.prof-table td { padding: 9px 13px; border: 1px solid var(--border); font-size: 13px; }
.prof-table td:first-child { background: #f8fafc; font-weight: 700; width: 42%; color: var(--text-muted); }
.prof-section { margin-top: 14px; }
.prof-section h4 { margin: 0 0 8px; color: var(--primary); font-size: 14px; }

/* ---------- Inline entity creator (service_new) ---------- */
.entity-box { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 14px; margin-top: 8px; background: #f8fafc; }
.entity-box h4 { font-size: 13px; margin-bottom: 10px; color: var(--primary); }
.pick-row { display: flex; gap: 8px; align-items: flex-end; }
.pick-row .form-group { flex: 1; margin-bottom: 0; }
.switch-link { font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--primary); }
.switch-link:hover { text-decoration: underline; }
.step-badge { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 12px; font-weight: 800; margin-left: 8px; }

/* ---------- Report print header ---------- */
.report-head { text-align: center; margin-bottom: 18px; }
.report-head h2 { font-size: 20px; margin-bottom: 4px; }
.report-head .sub { font-size: 12.5px; color: var(--text-muted); }
.report-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
@media print {
  .report-head { margin-bottom: 12px; }
  .tabs { display: none !important; }
}

/* ---------- Multi-month payment (accounting) ---------- */
.mm-months { display: grid; grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); gap: 10px; }
.mm-month { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: #f8fafc; }
.mm-check { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; cursor: pointer; margin-bottom: 6px; }
.mm-check input { width: auto; margin: 0; }
.mm-month input[type="number"] { padding: 6px 8px; font-size: 12.5px; }
.mm-month input[type="number"]:disabled { background: #eef2f7; opacity: .6; }

/* ============================================================
   انتخابگر تاریخ شمسی (Jalali Date Picker)
   ============================================================ */
.jd-host { position: relative; }
.jd-input-wrap { position: relative; }
.jd-input-wrap .jd-display { width: 100%; padding-left: 38px; cursor: pointer; background: #fff; }
.jd-cal-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; font-size: 16px; opacity: .7; }
.jd-pop {
  position: absolute; z-index: 300; top: calc(100% + 6px); right: 0;
  width: 290px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 12px;
}
.jd-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.jd-title { font-weight: 800; font-size: 14px; }
.jd-nav { background: var(--bg); border: none; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 18px; line-height: 1; color: var(--text); }
.jd-nav:hover { background: var(--primary-light); color: var(--primary); }
.jd-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.jd-wd { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 4px 0; }
.jd-day { border: none; background: transparent; border-radius: 8px; padding: 7px 0; font-size: 12.5px; cursor: pointer; font-family: inherit; color: var(--text); }
.jd-day:hover { background: var(--primary-light); }
.jd-day.today { box-shadow: inset 0 0 0 1px var(--primary); }
.jd-day.sel { background: var(--primary); color: #fff; font-weight: 700; }
.jd-empty { visibility: hidden; }
.jd-foot { display: flex; gap: 8px; margin-top: 10px; }
.jd-foot button { flex: 1; border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 7px; font-size: 12px; cursor: pointer; font-family: inherit; font-weight: 600; }
.jd-foot .jd-today { color: var(--primary); border-color: var(--primary-light); }
.jd-foot .jd-clear { color: var(--red); }

/* ============================================================
   انتخاب موقعیت از روی نقشه (Map Picker)
   ============================================================ */
.mp-host { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.mp-toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #f8fafc; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mp-hint { font-size: 11.5px; color: var(--text-muted); }
.mp-map { height: 260px; width: 100%; z-index: 1; }
.mp-coords { display: flex; gap: 18px; padding: 8px 12px; font-size: 12px; color: var(--text-muted); background: #f8fafc; border-top: 1px solid var(--border); }
.mp-coords b { color: var(--text); font-variant-numeric: tabular-nums; }
.mp-error { padding: 18px 16px; background: #fef2f2; color: #b91c1c; font-size: 13px; font-weight: 600; text-align: center; }
.leaflet-container { font-family: Vazirmatn, Tahoma, sans-serif; }

/* ============================================================
   بهبود ریسپانسیو (Responsive Enhancements)
   ============================================================ */
img, table, .mp-map { max-width: 100%; }
.card-head { flex-wrap: wrap; gap: 10px; }
.card-head input[type="text"] { min-width: 140px; }

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); }
}

@media (max-width: 900px) {
  .sidebar { width: 280px; box-shadow: var(--shadow-lg); }
  .topbar { gap: 10px; }
  .topbar .user-chip span:not(.av) { display: none; }
  .card { padding: 16px; }
  .card-head h3 { font-size: 15px; }
  .modal { max-width: 100%; margin: 0; border-radius: 16px 16px 0 0; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; }
  .modal-body { padding: 18px; max-height: 70vh; overflow-y: auto; }
  .modal-head, .modal-foot { padding: 14px 18px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }
  .mp-map { height: 220px; }
  .jd-pop { width: 100%; right: 0; left: 0; }
}

@media (max-width: 640px) {
  body { font-size: 13.5px; }
  .content { padding: 12px; padding-bottom: 84px; }
  .topbar { padding: 10px 12px; }
  .topbar .page-title { font-size: 14px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 13px; }
  .stat .val { font-size: 18px; }
  .stat .ic { width: 38px; height: 38px; font-size: 18px; }
  .btn { padding: 9px 13px; font-size: 12.5px; }
  .btn-lg { padding: 12px 18px; font-size: 14px; }
  .card-head { flex-direction: column; align-items: stretch; }
  .card-head input[type="text"] { max-width: 100% !important; }
  .card-head .btn { width: 100%; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal-foot { flex-direction: column; }
  .modal-foot .btn { width: 100%; }
  .att-row { flex-direction: column; align-items: stretch; }
  .att-actions { justify-content: stretch; }
  .att-btn { flex: 1; }
  .mm-months { grid-template-columns: 1fr 1fr; }
  .prof-table td { padding: 7px 9px; font-size: 12px; }
  .prof-avatar { width: 52px; height: 52px; font-size: 22px; }
  .prof-name { font-size: 17px; }
  .mp-map { height: 200px; }
  .mp-coords { flex-direction: column; gap: 2px; }
}

@media (max-width: 400px) {
  .stats { grid-template-columns: 1fr; }
  .mm-months { grid-template-columns: 1fr; }
  .bottom-nav a { font-size: 9.5px; }
}

/* اطمینان از اسکرول افقی جداول در موبایل */
.table-wrap { overflow-x: auto; }

/* ============================================================
   مشخصات طراح (Designer credit)
   ============================================================ */
.designer-credit {
  margin-top: 8px; margin-bottom: 20px;
  background: linear-gradient(135deg,#0f172a 0%,#1e293b 100%);
  border-radius: var(--radius); padding: 20px 24px; color: #e2e8f0;
  box-shadow: var(--shadow);
}
.designer-credit .dc-inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.designer-credit .dc-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(37,99,235,.4);
}
.designer-credit .dc-title { font-size: 12px; color: #94a3b8; font-weight: 600; }
.designer-credit .dc-name { font-size: 18px; font-weight: 800; color: #fff; }
.designer-credit .dc-links { font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.designer-credit .dc-links a { color: #93c5fd; font-weight: 600; }
.designer-credit .dc-links a:hover { color: #bfdbfe; }
.designer-credit .dc-sep { color: #475569; }

/* ============================================================
   بارگذاری مدارک راننده (Driver documents)
   ============================================================ */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 14px; }
.doc-item {
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 12px; background: #f8fafc;
}
.doc-item > label { font-size: 12.5px; font-weight: 700; margin-bottom: 8px; }
.doc-item input[type=file] {
  width: 100%; font-size: 12px; padding: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; font-family: inherit;
}
.doc-preview { margin-top: 10px; min-height: 90px; display: flex; align-items: center; justify-content: center; }
.doc-preview img {
  max-width: 100%; max-height: 150px; border-radius: 8px;
  border: 1px solid var(--border); object-fit: cover; background: #fff;
}
.doc-preview .doc-empty { font-size: 12px; color: var(--text-muted); }
.doc-remove { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--red); cursor: pointer; }
.doc-remove input { width: auto; margin: 0; }

/* نمایش مدارک در مودال پروفایل */
.prof-docs { display: grid; grid-template-columns: repeat(auto-fit,minmax(120px,1fr)); gap: 12px; }
.prof-doc {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px; background: #fff; text-align: center; color: var(--text);
}
.prof-doc:hover { border-color: var(--primary); color: var(--text); }
.prof-doc img { width: 100%; height: 90px; object-fit: cover; border-radius: 8px; }
.prof-doc span { font-size: 11.5px; font-weight: 700; }
.prof-doc small { font-size: 10.5px; color: var(--text-muted); }
.prof-doc.empty { background: #f8fafc; }
.prof-doc.empty .ph {
  width: 100%; height: 90px; border-radius: 8px; background: #eef2f7;
  display: flex; align-items: center; justify-content: center; font-size: 30px; opacity: .6;
}

@media (max-width: 640px) {
  .doc-grid { grid-template-columns: 1fr; }
  .designer-credit { padding: 16px; }
  .designer-credit .dc-name { font-size: 16px; }
}
