:root {
  --navy: #0b1f3a; --navy-2: #13305a; --accent: #f5a524; --bg: #f3f5f9; --card: #fff;
  --line: #e3e8ef; --text: #172235; --muted: #66738a;
  --moving: #16a34a; --idle: #d97706; --stopped: #dc2626; --offline: #94a3b8;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.07);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
button, input, select { font: inherit; color: inherit; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* buttons & inputs */
.btn { border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; background: #e9eef5; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--navy-2); }
.btn.ghost { background: #fff; border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { border-color: #c5cfdd; }
.btn.danger { background: #fff; border-color: #f2c2c2; color: #b42318; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; padding: 11px; }
.icon-btn { background: transparent; border: 0; color: #fff; font-size: 19px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: rgba(255,255,255,.1); }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #8aa4c8; box-shadow: 0 0 0 3px rgba(19,48,90,.1); }
label { display: block; font-weight: 600; font-size: 13px; color: #34425a; }
label input, label select, label textarea { display: block; width: 100%; margin-top: 5px; font-weight: 400; }
.form-msg { color: #b42318; font-size: 13px; min-height: 1em; margin: 8px 0 0; }
.form-msg.ok { color: var(--moving); }

/* auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% 0%, #1a3d6e 0%, var(--navy) 60%); }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 30px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-card h2 { margin: 22px 0 14px; font-size: 19px; }
.auth-card label { margin-bottom: 13px; }
.brand-lg { display: flex; align-items: center; gap: 12px; }
.brand-lg img { width: 44px; height: 44px; }
.brand-lg b { display: block; font-size: 18px; }
.brand-lg span { color: var(--muted); }

/* layout */
.app { height: 100%; display: flex; flex-direction: column; }
.top { height: 56px; flex: none; display: flex; align-items: center; gap: 18px; padding: 0 16px; background: var(--navy); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand img { width: 30px; height: 30px; }
.brand span { color: #9fb3cf; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs button { background: none; border: 0; color: #b7c6da; padding: 0 14px; cursor: pointer; font-weight: 600; border-bottom: 3px solid transparent; }
.tabs button:hover { color: #fff; }
.tabs button.active { color: #fff; border-bottom-color: var(--accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.sync { font-size: 12.5px; color: #9fb3cf; }
.who { font-size: 13px; color: #d6e0ee; }
.top .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.25); }
.view { flex: 1; min-height: 0; }
.view-map { display: flex; }

/* sidebar */
.side { width: 350px; flex: none; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; z-index: 500; }
.counts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 12px 12px 4px; }
.count { border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; text-align: center; cursor: pointer; background: #fff; }
.count b { display: block; font-size: 18px; line-height: 1.2; }
.count span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.count.on { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.count .dot { margin-right: 3px; }
.filters { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); }
.filters input[type=search] { width: 100%; }
.filter-row { display: flex; gap: 6px; margin-top: 7px; }
.filter-row select { flex: 1; min-width: 0; padding: 6px; font-size: 13px; }
.vlist { overflow-y: auto; flex: 1; }
.vitem { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #eef1f5; cursor: pointer; align-items: flex-start; }
.vitem:hover { background: #f6f8fb; }
.vitem.sel { background: #eaf1fb; box-shadow: inset 3px 0 0 var(--navy); }
.vitem .ico { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex: none; color: #fff; }
.vitem .ico svg { width: 20px; height: 20px; }
.vitem .main { flex: 1; min-width: 0; }
.vitem .reg { font-weight: 700; letter-spacing: .02em; }
.vitem .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vitem .right { text-align: right; font-size: 12.5px; white-space: nowrap; }
.vitem .spd { font-weight: 700; }
.badge { display: inline-block; white-space: nowrap; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; color: #fff; vertical-align: 1px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: #f1f4f8; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.st-moving { --c: var(--moving); } .st-idle { --c: var(--idle); } .st-stopped { --c: var(--stopped); } .st-offline { --c: var(--offline); }
.dot.st-moving, .dot.st-idle, .dot.st-stopped, .dot.st-offline { background: var(--c); }
.ico.st-moving, .ico.st-idle, .ico.st-stopped, .ico.st-offline { background: var(--c); }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }

/* map */
.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #e5e9ef; }
.map-opt { position: absolute; left: 60px; top: 10px; z-index: 600; background: #fff; padding: 5px 10px; border-radius: 6px; box-shadow: var(--shadow); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.map-opt input { width: auto; margin: 0; display: inline; }
.mk { position: relative; }
.mk .pin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 2px 6px rgba(0,0,0,.35); display: grid; place-items: center; color: #fff; }
.mk .pin svg { width: 15px; height: 15px; }
.mk .lbl { position: absolute; left: 32px; top: 4px; background: #fff; border-radius: 4px; padding: 1px 6px; font-size: 11.5px; font-weight: 700; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.nolabels .mk .lbl { display: none; }
.mk.sel .pin { transform: scale(1.25); box-shadow: 0 0 0 4px rgba(11,31,58,.35), 0 2px 6px rgba(0,0,0,.35); }

/* detail card */
.detail { position: absolute; right: 12px; top: 12px; width: 330px; max-height: calc(100% - 24px); overflow-y: auto; z-index: 700; background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(16,24,40,.18); }
.detail .head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); position: relative; }
.detail .head h2 { margin: 0; font-size: 19px; letter-spacing: .02em; }
.detail .close { position: absolute; right: 8px; top: 8px; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.detail .kv { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.detail .kv div { background: #fff; padding: 8px 16px; }
.detail .kv small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.detail .kv b { font-size: 14.5px; }
.detail .sec { padding: 12px 16px; border-top: 1px solid var(--line); }
.detail .addr { font-size: 13px; }
.detail .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.detail .row input[type=date] { flex: 1; min-width: 0; padding: 5px 8px; }
.trip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; text-align: center; }
.trip div { background: #f4f7fb; border-radius: 8px; padding: 6px; }
.trip b { display: block; font-size: 15px; }
.trip small { color: var(--muted); font-size: 11px; }
.playback { position: absolute; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 700; background: #fff; border-radius: 12px; padding: 8px 12px; box-shadow: 0 10px 30px rgba(16,24,40,.2); display: flex; gap: 10px; align-items: center; width: min(640px, calc(100% - 24px)); }
.playback input[type=range] { flex: 1; padding: 0; border: 0; box-shadow: none; }
.playback #pbInfo { font-size: 12.5px; white-space: nowrap; min-width: 150px; }

/* pages */
.page { overflow-y: auto; padding: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 0 auto 16px; max-width: 1200px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; }
.page-head p { margin: 0; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; max-width: 1200px; margin: 0 auto 16px; }
.card h3 { margin: 0 0 12px; font-size: 15.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 1200px; margin: 0 auto; }
.grid2 .card { margin: 0; }
.table-search { width: 280px; max-width: 100%; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfd; }
.tbl th.sortable { cursor: pointer; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
.tbl tr:hover td { background: #fafcff; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.inactive td { color: #98a2b3; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.report-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.report-bar label input { width: auto; }
.quick { display: flex; gap: 4px; flex-wrap: wrap; }
.prov { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid #eef1f5; }
.prov:last-of-type { border-bottom: 0; margin-bottom: 10px; }
.prov .nm { font-weight: 700; }
.prov .err { color: #b42318; font-size: 12.5px; }
.stack label { margin-bottom: 10px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.inline-form input, .inline-form select { flex: 1 1 140px; }
.ulist .u { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid #eef1f5; gap: 8px; }

/* modal & toast */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(11,31,58,.45); display: grid; place-items: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 14px; width: 100%; max-width: 460px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.3); max-height: 92vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 14px; font-size: 18px; }
.modal-card label { margin-bottom: 12px; }
.modal-card .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal-card .actions .left { margin-right: auto; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; margin: 0; display: inline; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 3000; box-shadow: var(--shadow); }
.toast.err { background: #b42318; }

.only-mobile { display: none; }
@media (max-width: 1100px) { .sync { display: none; } .brand span { display: none; } }
@media (max-width: 860px) {
  .only-mobile { display: inline-block; }
  .top { gap: 8px; padding: 0 8px; }
  .brand b { display: none; }
  .who { display: none; }
  .tabs button { padding: 0 8px; font-size: 13px; }
  .side { position: absolute; top: 56px; bottom: 0; left: 0; width: min(350px, 88vw); transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.25); }
  .side.open { transform: none; }
  .detail { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; max-height: 60%; }
  .grid2 { grid-template-columns: 1fr; }
  .page { padding: 14px; }
  .playback #pbInfo { min-width: 0; }
}
@media (max-width: 560px) { .top-right .btn { display: none; } .tabs button { padding: 0 6px; } }
