/* FleetPro — dark graphite UI. No external dependencies. */
:root {
  --bg: #0d0f13;
  --bg-2: #111318;
  --panel: #15181e;
  --panel-2: #1a1e25;
  --panel-3: #20252d;
  --line: #262b34;
  --line-2: #313744;
  --text: #e7e9ee;
  --text-2: #b4bac6;
  --muted: #7d8595;
  --blue: #3b82f6;
  --blue-2: #2563eb;
  --blue-soft: rgba(59,130,246,.14);
  --green: #22c55e;
  --green-soft: rgba(34,197,94,.13);
  --amber: #f59e0b;
  --amber-soft: rgba(245,158,11,.14);
  --red: #ef4444;
  --red-soft: rgba(239,68,68,.14);
  --violet: #a78bfa;
  --teal: #2dd4bf;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: #8fb4ff; text-decoration: none; }
a:hover { color: #b9d0ff; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
small, .muted { color: var(--muted); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; font-size: 15px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--blue), #1d4ed8); display: grid; place-items: center; color: #fff; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.nav { padding: 6px 10px 18px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--blue-soft); color: #cfe0ff; }
.nav a.active svg.i { color: var(--blue); }
.nav .count { margin-left: auto; background: var(--blue); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; line-height: 18px; font-weight: 600; }
.nav .count.warn { background: var(--amber); color: #1a1205; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: rgba(13,15,19,.86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search input { width: 100%; padding-left: 36px; background: var(--panel); }
.topbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .spacer { flex: 1; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; color: var(--text-2); border: 1px solid var(--line); background: var(--panel); }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 99px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; border: 2px solid var(--bg); }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.menu-pop a, .menu-pop button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--panel-3); color: var(--text); }
.menu-pop .head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.avatar { width: 28px; height: 28px; border-radius: 8px; background: var(--panel-3); display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #cfe0ff; }
.burger { display: none; }

.content { padding: 24px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card-b { padding: 16px; }
.card-b.flush { padding: 0; }
.stack > * + * { margin-top: 16px; }

.kpi { padding: 16px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi .sub b { color: var(--text-2); font-weight: 600; }
.kpi.alert { border-color: rgba(245,158,11,.35); }
.kpi.danger { border-color: rgba(239,68,68,.35); }
.kpi a.stretch::after { content: ""; position: absolute; inset: 0; }
.kpi .ico { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.kpi .ico.green { background: var(--green-soft); color: var(--green); }
.kpi .ico.amber { background: var(--amber-soft); color: var(--amber); }
.kpi .ico.red { background: var(--red-soft); color: var(--red); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
table.t th a { color: var(--muted); }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: rgba(255,255,255,.015); }
table.t td.actions { white-space: nowrap; text-align: right; }
table.t .strong { font-weight: 600; color: var(--text); }
.plate { display: inline-block; font-family: var(--mono); font-weight: 700; font-size: 12.5px; padding: 2px 7px; border-radius: 5px; background: #e9edf3; color: #111; letter-spacing: .04em; border-left: 6px solid #9e1b32; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge-green { background: var(--green-soft); color: #4ade80; }
.badge-blue { background: var(--blue-soft); color: #93c5fd; }
.badge-amber { background: var(--amber-soft); color: #fbbf24; }
.badge-red { background: var(--red-soft); color: #f87171; }
.badge-gray { background: rgba(148,163,184,.12); color: #a5afbf; }
.badge-violet { background: rgba(167,139,250,.14); color: #c4b5fd; }
.badge-teal { background: rgba(45,212,191,.13); color: #5eead4; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--panel-3); color: var(--text-2); }
.pos { color: #f87171; }
.neg { color: #4ade80; }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--blue); }
input[type=file] { padding: 8px; }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field-error { font-size: 12px; color: #f87171; margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-2); }
.inline-form { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters input, .filters select { width: auto; min-width: 140px; padding: 7px 10px; }
.filters .grow { flex: 1; min-width: 180px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--panel-3); color: var(--text); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-2); color: #fff; }
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-danger { background: transparent; border-color: rgba(239,68,68,.45); color: #f87171; }
.btn-danger:hover { background: var(--red-soft); color: #fca5a5; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 14px 18px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; border: 1px solid; margin-bottom: 14px; font-size: 13.5px; }
.alert-ok { background: var(--green-soft); border-color: rgba(34,197,94,.3); color: #bbf7d0; }
.alert-error { background: var(--red-soft); border-color: rgba(239,68,68,.35); color: #fecaca; }
.alert-warn { background: var(--amber-soft); border-color: rgba(245,158,11,.35); color: #fde68a; }
.alert-info { background: var(--blue-soft); border-color: rgba(59,130,246,.35); color: #dbeafe; }
.copy-box { display: flex; gap: 8px; align-items: center; background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 9px; padding: 8px 10px; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs a { padding: 11px 12px; color: var(--muted); font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--blue); }
.pill-tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.pill-tabs a { padding: 6px 12px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.pill-tabs a.on { background: var(--panel-3); color: var(--text); }

/* ---------- definition list ---------- */
.dl { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 9px 14px; margin: 0; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--text); }

/* ---------- vehicle cards ---------- */
.vcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.vcard { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.vcard .top { display: flex; justify-content: space-between; align-items: center; }
.vcard .model { font-weight: 650; }
.vcard .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 12px; color: var(--muted); }
.vcard .meta b { color: var(--text-2); font-weight: 600; display: block; }

/* ---------- charts ---------- */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .zero { stroke: var(--line-2); stroke-width: 1.5; }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.s1 { fill: #3b82f6; background: #3b82f6; }
.s2 { fill: #64748b; background: #64748b; }
.s3 { fill: #22c55e; background: #22c55e; }
.s4 { fill: #f59e0b; background: #f59e0b; }
.s5 { fill: #ef4444; background: #ef4444; }
.s6 { fill: #a78bfa; background: #a78bfa; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: 96px 1fr 72px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.hbar-track { height: 8px; background: var(--panel-3); border-radius: 99px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 99px; }
.hbar-val { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .meta { font-size: 12px; color: var(--muted); }
.list li.unread { background: rgba(59,130,246,.05); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 14px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--panel-3); border: 2px solid var(--blue); }

/* ---------- dialogs (CSS-only via <details>) ---------- */
details.dialog > summary { list-style: none; display: inline-flex; }
details.dialog > summary::-webkit-details-marker { display: none; }
details.dialog[open] > .dialog-body { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0,0,0,.6); padding: 16px; }
.dialog-card { width: 100%; max-width: 480px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.5); text-align: left; }
.dialog-card .card-h { border-bottom: 1px solid var(--line); }
.dialog-card .card-b { padding: 16px; }
.dialog-card .foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }

/* ---------- auth / public ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, rgba(59,130,246,.16), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 28px; }
.auth-card.wide { max-width: 720px; }
.auth-card .brand { padding: 0 0 18px; }

/* ---------- driver (mobile-first) ---------- */
.d-shell { min-height: 100vh; padding-bottom: 86px; }
.d-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: rgba(13,15,19,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.d-content { padding: 16px; max-width: 640px; margin: 0 auto; }
.d-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--bg-2); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.d-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 10px; }
.d-nav a.on { color: #cfe0ff; background: var(--blue-soft); }
.d-nav svg.i { width: 22px; height: 22px; }
.bigbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bigbtn { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-weight: 650; font-size: 15px; min-height: 104px; }
.bigbtn svg.i { width: 26px; height: 26px; color: var(--blue); }
.bigbtn small { font-weight: 500; }
.bigbtn.primary { background: linear-gradient(135deg, #1d4ed8, #3b82f6); border-color: transparent; }
.bigbtn.primary svg.i, .bigbtn.primary small { color: #dbeafe; }
.carcard { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.bignum input { font-size: 26px; font-weight: 700; padding: 14px; text-align: center; letter-spacing: .04em; font-family: var(--mono); }
.photo-input { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px; border: 2px dashed var(--line-2); border-radius: 14px; color: var(--text-2); font-weight: 600; cursor: pointer; text-align: center; }
.photo-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-input.has-file { border-color: var(--green); color: #bbf7d0; }

/* ---------- utilities ---------- */
.flex { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt0 { margin-top: 0; } .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb0 { margin-bottom: 0; } .mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
.w100 { width: 100%; }
.small { font-size: 12px; }
.warn-text { color: #fbbf24; }
.err-text { color: #f87171; }
.ok-text { color: #4ade80; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
  .burger { display: inline-grid; }
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar .search { display: none; }
  table.t.responsive thead { display: none; }
  table.t.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.t.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 14px; text-align: right; }
  table.t.responsive td::before { content: attr(data-l); color: var(--muted); font-size: 12px; text-align: left; }
  table.t.responsive td.actions { justify-content: flex-end; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 20px; }
  .kpi .ico { display: none; }
}
@media print {
  .sidebar, .topbar, .actions, .filters, form, .d-nav { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; box-shadow: none; background: #fff; }
}
