:root {
  --ink: #1a2027; --muted: #5b6874; --line: #dde2e7; --bg: #eef0f2; --panel: #fff;
  --asphalt: #1e242b; --asphalt-2: #2b333c; --sign: #f2b203; --blue: #1d6fb8; --danger: #b3302f; --ok: #138a5b;
  --font: "Vazirmatn", "Vazir", "Samim", "IRANSans", Tahoma, "Segoe UI", system-ui, sans-serif;
}
.st-moving { --c: #138a5b; } .st-idle { --c: #c98a00; } .st-stopped { --c: #5b6a79; }
.st-offline { --c: #a33b3b; } .st-nodata { --c: #9aa6b2; }
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
a { color: var(--blue); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #f2b203; outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: plaintext; text-align: end; }

/* ---------- ورود ---------- */
.login { min-height: 100%; display: grid; place-items: center; background: var(--asphalt); padding: 16px;
  background-image: repeating-linear-gradient(90deg, transparent 0 46px, rgba(242,178,3,.07) 46px 50px); }
.login-card { width: min(380px, 100%); background: var(--panel); border-radius: 10px; padding: 28px; display: grid; gap: 14px; border-top: 6px solid var(--sign); }
.login-card h1 { font-size: 22px; }
.login-card .sub { margin: -8px 0 4px; color: var(--muted); }
label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
input, select { border: 1px solid #c4ccd4; border-radius: 6px; padding: 8px 10px; background: #fff; min-height: 38px; width: 100%; }
input[type=checkbox] { width: auto; min-height: 0; }
input[type=range] { padding: 0; min-height: 28px; direction: ltr; }
.err { color: var(--danger); min-height: 1.4em; margin: 0; font-weight: 600; }

/* ---------- دکمه‌ها ---------- */
.btn { border: 1px solid #b6c0ca; background: #fff; border-radius: 6px; padding: 7px 14px; cursor: pointer; min-height: 36px; font-weight: 600; }
.btn:hover { background: #f3f5f7; }
.btn.primary { background: var(--asphalt); border-color: var(--asphalt); color: #fff; }
.btn.primary:hover { background: var(--asphalt-2); }
.btn.danger { color: var(--danger); border-color: #e0b4b3; }
.btn.small { padding: 3px 10px; min-height: 28px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 2px 0; color: #aeb8c2; cursor: pointer; text-align: start; }
.link:hover { color: #fff; text-decoration: underline; }

/* ---------- چیدمان ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; height: 100%; }
.nav { background: var(--asphalt); color: #d6dbe0; display: flex; flex-direction: column; padding: 14px 0; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; padding: 4px 18px 16px; color: #fff; }
.mark { width: 22px; height: 22px; background: var(--sign); clip-path: polygon(50% 0, 100% 100%, 50% 78%, 0 100%); }
.nav ul { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.nav li a { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; color: #c9d0d7; text-decoration: none; border-inline-start: 4px solid transparent; }
.nav li a:hover { background: var(--asphalt-2); color: #fff; }
.nav li a[aria-current=page] { background: var(--asphalt-2); color: #fff; border-inline-start-color: var(--sign); font-weight: 700; }
.badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; min-width: 22px; text-align: center; }
.nav-foot { padding: 12px 18px 0; border-top: 1px solid #38424d; display: grid; gap: 4px; }
.who { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; }
.who small { color: #93a0ad; font-weight: 400; margin-inline-start: auto; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, #9aa6b2); flex: none; }
#conn { background: #a33b3b; } #conn.on { background: #2fbf80; }
.view { overflow: auto; min-width: 0; min-height: 0; outline: none; }
.page { padding: 20px 24px 40px; display: grid; gap: 16px; align-content: start; }
.page-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.pad { padding: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.toolbar label { min-width: 150px; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- جدول ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f6f7f8; font-size: 12.5px; color: var(--muted); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 220px; }
td.actions .btn + .btn { margin-inline-start: 6px; }
tr.row-click { cursor: pointer; } tr.row-click:hover td { background: #f6f9fc; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--c, var(--ink)); }
.sev-warning { color: #9a5b00; } .sev-info { color: var(--blue); } .sev-critical { color: var(--danger); }
tr.unacked td { background: #fffaf0; }

/* ---------- نقشه زنده ---------- */
.live { display: grid; grid-template-columns: 340px 1fr; height: 100%; }
.vpanel { background: var(--panel); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.strip { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.bar { display: flex; height: 12px; border-radius: 3px; overflow: hidden; gap: 2px; background: #e4e8ec; }
.seg { background: var(--c); min-width: 3px; }
.legend { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.legend b { color: var(--ink); }
.vsearch { padding: 10px 14px 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 14px 10px; border-bottom: 1px solid var(--line); }
.chip { border: 1px solid #c4ccd4; background: #fff; border-radius: 14px; padding: 2px 11px; cursor: pointer; font-size: 12.5px; }
.chip[aria-pressed=true] { background: var(--asphalt); color: #fff; border-color: var(--asphalt); }
.vlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.vitem { display: grid; grid-template-columns: 14px 1fr auto; gap: 2px 10px; align-items: center; width: 100%; text-align: start; border: 0; background: none; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #edf0f2; }
.vitem:hover { background: #f4f7fa; }
.vitem.sel { background: #fff7dd; box-shadow: inset 4px 0 0 var(--sign); }
.vname { font-weight: 700; } .vplate, .vmeta { color: var(--muted); font-size: 12.5px; }
.vmeta { grid-column: 2 / 4; }
.map { width: 100%; height: 100%; min-height: 320px; direction: ltr; background: #dfe5ea; }
.leaflet-container { font-family: var(--font); }
.veh-wrap { background: none; border: 0; }
.veh { width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.45); display: grid; place-items: center; }
.veh i { width: 0; height: 0; border-inline: 5px solid transparent; border-bottom: 11px solid #fff; display: block; }
.veh.st-offline, .veh.st-nodata { opacity: .75; }
.pop { direction: rtl; min-width: 190px; font-family: var(--font); }
.pop h3 { font-size: 15px; margin-bottom: 2px; }
.pop dl { margin: 8px 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; }
.pop dt { color: var(--muted); } .pop dd { margin: 0; font-weight: 600; }

/* ---------- تاریخچه / محدوده ---------- */
.split { display: grid; grid-template-columns: 1fr 360px; height: 100%; }
.side { background: var(--panel); border-inline-start: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.side section { padding: 14px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.side h3 { font-size: 14px; }
.hist { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.hbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 12px 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat b { display: block; font-size: 17px; } .stat span { color: var(--muted); font-size: 12px; }
.trip { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #fff; cursor: pointer; text-align: start; display: grid; gap: 2px; width: 100%; }
.trip:hover { background: #f4f7fa; }
.player { display: grid; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: middle; }

/* ---------- پنجره و پیام ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(20,26,32,.55); display: grid; place-items: center; padding: 16px; z-index: 1000; }
.modal { background: #fff; border-radius: 10px; width: min(520px, 100%); max-height: 92vh; overflow: auto; border-top: 5px solid var(--sign); }
.modal header { padding: 14px 18px 0; } .modal header h3 { font-size: 17px; }
.modal .body { padding: 14px 18px; display: grid; gap: 12px; }
.modal footer { padding: 0 18px 16px; display: flex; gap: 8px; justify-content: flex-end; }
.kv { background: #f4f6f8; border-radius: 6px; padding: 8px 10px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; word-break: break-all; direction: ltr; text-align: left; user-select: all; }
.checks { max-height: 160px; overflow: auto; border: 1px solid #c4ccd4; border-radius: 6px; padding: 6px 10px; display: grid; gap: 4px; }
.checks label { font-weight: 400; display: flex; align-items: center; gap: 8px; }
#toasts { position: fixed; inset-block-end: 16px; inset-inline-start: 16px; display: grid; gap: 8px; z-index: 2000; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--asphalt); color: #fff; border-radius: 8px; padding: 10px 14px; border-inline-start: 5px solid var(--sign); box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.toast.error { border-inline-start-color: #e0554f; } .toast.warn { border-inline-start-color: #f2b203; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .nav { flex-direction: row; align-items: center; padding: 0; overflow-x: auto; }
  .brand { padding: 8px 14px; white-space: nowrap; }
  .nav ul { display: flex; overflow: visible; flex: none; }
  .nav li a { padding: 12px 12px; border-inline-start: 0; border-bottom: 4px solid transparent; white-space: nowrap; }
  .nav li a[aria-current=page] { border-bottom-color: var(--sign); }
  .nav-foot { flex-direction: row; display: flex; border: 0; padding: 0 12px; align-items: center; white-space: nowrap; }
  .who small { display: none; }
  .live, .split { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; }
  .live .map { order: -1; } .split .side { border-inline-start: 0; border-top: 1px solid var(--line); }
  .page { padding: 14px 12px 32px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

@media print {
  .nav, .toolbar, .chips, .page-head .row, .btn { display: none !important; }
  .shell { display: block; height: auto; } .view { overflow: visible; } body { background: #fff; font-size: 12px; }
  .card { border: 0; } th, td { padding: 4px 6px; } a { color: inherit; text-decoration: none; }
}

.picker { position: relative; display: grid; gap: 4px; }
.picker > .lbl { font-weight: 600; font-size: 13px; }
.ppanel { position: absolute; z-index: 50; top: 100%; inset-inline-start: 0; width: 330px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 10px; display: grid; gap: 8px; margin-top: 4px; }
.ppanel .checks { max-height: 250px; }

textarea { border: 1px solid #c4ccd4; border-radius: 6px; padding: 8px 10px; width: 100%; font: inherit; background: #fff; resize: vertical; }

/* ---------- تاریخ شمسی ---------- */
.jd-wrap { display: flex; gap: 6px; }
.jd-text { text-align: center; min-width: 118px; }
.jd-time { width: 96px; flex: none; }
.jd-cal { position: absolute; z-index: 3000; width: 262px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.22); padding: 8px; direction: rtl; font-family: var(--font); }
.jd-head { display: flex; align-items: center; justify-content: space-between; gap: 2px; margin-bottom: 6px; }
.jd-head b { flex: 1; text-align: center; font-size: 13.5px; }
.jd-head button, .jd-foot button { border: 0; background: #f1f3f5; border-radius: 6px; min-width: 30px; height: 28px; cursor: pointer; font: inherit; }
.jd-head button:hover, .jd-foot button:hover { background: #e3e7eb; }
.jd-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.jd-grid i { font-style: normal; color: var(--muted); font-size: 12px; padding: 4px 0; }
.jd-day { border: 0; background: none; height: 32px; border-radius: 6px; cursor: pointer; font: inherit; }
.jd-day:hover { background: #eef1f4; }
.jd-day.today { outline: 2px solid var(--sign); outline-offset: -2px; }
.jd-day.sel { background: var(--asphalt); color: #fff; }
.jd-foot { display: flex; justify-content: space-between; margin-top: 6px; }

.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
fieldset legend { padding: 0 6px; }

#offbar { position: fixed; top: 0; inset-inline: 0; z-index: 4000; background: #c98a00; color: #fff; text-align: center; padding: 6px 12px; font-size: 13px; font-weight: 700; }

/* ---------- داشبورد ---------- */
.dash-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dash-tools input[type=search] { min-width: 170px; }
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { text-align: start; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer; display: grid; gap: 4px; font: inherit; color: inherit; border-top: 4px solid var(--blue); }
.kpi:hover { background: #f7f9fb; }
.kpi.warn { border-top-color: var(--sign); } .kpi.danger { border-top-color: var(--danger); }
.kpi-l { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi-v { font-size: 30px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.card-h { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 14px 6px; }
.card-h h3 { font-size: 15.5px; }
.note { margin: 0; padding: 6px 14px 12px; font-size: 12.5px; line-height: 1.7; }
.small { font-size: 12.5px; }
.empty.ok { color: var(--ok); }
.cl-warning { --c: #c98a00; } .cl-critical { --c: #b3302f; } .cl-severe { --c: #7a1f1f; }
.dash-rank { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.chart { padding: 4px 10px 0; } .chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e3e8ed; stroke-width: 1; } .chart .grid.v { stroke-dasharray: 2 4; }
.chart .ax { fill: #5b6874; font-size: 11px; }
.chart .ln { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .ref { stroke: #9aa6b2; stroke-dasharray: 5 5; }
.chart .hov { stroke: var(--asphalt); stroke-width: 1; display: none; }
.dash details summary { cursor: pointer; }
.dash table.mini { margin-top: 6px; font-size: 12px; width: 100%; } .dash table.mini td { padding: 2px 6px; border: 0; } .dash table.mini tr.off { color: var(--muted); }
@media (max-width: 900px) { .dash-rank { grid-template-columns: 1fr; } .kpi-v { font-size: 26px; } }

/* انتخاب‌گر سبک نقشه */
.map-style { background: #fff; padding: 3px; border-radius: 4px; }
.map-style select { font-size: 13px; min-height: 28px; border: 0; background: #fff; cursor: pointer; font-family: inherit; }
