:root {
  --ink: #0E1726; --ink-2: #334155; --muted: #4A5568; --line: #DCE1E7; --line-2: #EEF1F4;
  --ground: #F3F5F7; --panel: #FFFFFF; --panel-2: #F7F9FB; --nav: #0E1726; --nav-2: #22324A; --nav-text: #D5DCE6; --nav-muted: #A9B4C4;
  --accent: #C2410C; --accent-ink: #FFFFFF; --link: #175CD3;
  --red: #B42318; --red-bg: #FEE4E2; --red-ink: #912018;
  --amber: #93370D; --amber-bg: #FEF0C7; --amber-ink: #7A2E0E;
  --blue: #175CD3; --blue-bg: #D1E9FF; --blue-ink: #194185;
  --green: #067647; --green-bg: #DCFAE6; --green-ink: #085D3A;
  --radius: 12px;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); font-size: 15px; }
a { color: var(--link); }
h1 { margin: 0; font-size: 28px; font-weight: 700; }
h2 { margin: 0; font-size: 18px; font-weight: 700; }
h3 { margin: 0; font-size: 15px; font-weight: 700; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.nav { flex: 1 1 232px; max-width: 100%; background: var(--nav); color: #E6EAF0; padding: 20px 14px; display: flex; flex-direction: column; gap: 3px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; text-decoration: none; color: inherit; }
.brand-logo { width: 68px; height: 46px; border-radius: 8px; background: #fff; padding: 4px; display: flex; align-items: center; justify-content: center; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand b { display: block; font-size: 16px; }
.brand span { font-size: 12px; color: var(--nav-muted); }
.nav a.item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--nav-text); text-decoration: none; font-size: 14px; }
.nav a.item:hover { background: #18253A; }
.nav a.item.active { background: var(--nav-2); color: #fff; font-weight: 600; }
.nav .section { margin: 18px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: 1px; color: #8D9AAE; text-transform: uppercase; }
.nav .user { margin-top: auto; padding: 18px 12px 0; display: flex; flex-direction: column; gap: 2px; }
.nav .user b { font-size: 13px; }
.nav .user span { font-size: 12px; color: var(--nav-muted); }
.nav .user button { margin-top: 8px; align-self: flex-start; }
.main { flex: 999 1 560px; min-width: 0; padding: 26px 30px 40px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.page-head .sub { font-size: 14px; color: var(--muted); margin-top: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- components ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid #CBD2DC; background: #fff; color: var(--ink); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #9AA6B6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.ghost-nav { background: transparent; border-color: #3A4A63; color: var(--nav-text); }
.btn:disabled { opacity: .5; cursor: default; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 16px 18px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid3 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .grid4 { grid-template-columns: 1fr 1fr; gap: 10px; } .main { padding: 18px 14px 90px; } }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi b { font-family: var(--mono); font-size: 28px; font-weight: 600; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.st-overdue { background: var(--red-bg); color: var(--red-ink); }
.st-tolerance, .st-due { background: var(--amber-bg); color: var(--amber-ink); }
.st-upcoming { background: var(--blue-bg); color: var(--blue-ink); }
.st-ok { background: var(--green-bg); color: var(--green-ink); }
.st-unknown { background: var(--line-2); color: var(--ink-2); }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 13px 18px; border-radius: var(--radius) var(--radius) 0 0; }
.col-head.overdue { background: var(--red-bg); color: var(--red-ink); }
.col-head.due { background: var(--amber-bg); color: var(--amber-ink); }
.col-head.upcoming { background: var(--blue-bg); color: var(--blue-ink); }
.task { padding: 13px 18px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 5px; }
.task .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.task .meta b { color: var(--ink); }
.task .title { font-size: 14px; font-weight: 600; }
.task .when { font-family: var(--mono); font-size: 13px; }
.when.overdue { color: var(--red); } .when.due, .when.tolerance { color: var(--amber); } .when.upcoming { color: var(--blue); }
.empty { padding: 16px 18px; color: var(--muted); font-size: 14px; }

.fleet-card { display: flex; flex-direction: column; overflow: hidden; text-decoration: none; color: var(--ink); }
.fleet-card img, .fleet-card .noimg { width: 100%; height: 150px; object-fit: cover; display: block; background: #E9EDF2; }
.fleet-card .body { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.fleet-card .reg { font-size: 22px; font-weight: 700; letter-spacing: .5px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.kv div { display: flex; flex-direction: column; gap: 2px; }
.kv span { font-size: 11px; color: var(--muted); }
.kv b { font-family: var(--mono); font-size: 15px; font-weight: 600; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { min-height: 44px; padding: 0 16px; border: 0; border-bottom: 3px solid transparent; background: transparent; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
.acpick { display: flex; flex-wrap: wrap; gap: 8px; }
.acpick a { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px 0 6px; border-radius: 10px; border: 1px solid #CBD2DC; background: #fff; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.acpick a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.acpick img { width: 66px; height: 40px; border-radius: 6px; object-fit: cover; }
.ac-head { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.ac-head img { width: 200px; height: 130px; border-radius: 12px; object-fit: cover; }
.timebox { display: flex; flex-direction: column; gap: 8px; }
.timebox .l { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.timebox .l b { font-family: var(--mono); font-size: 16px; color: var(--ink); font-weight: 600; }
.timebox.darkbox { background: var(--ink); color: #E6EAF0; border-color: var(--ink); }
.timebox.darkbox .l { color: var(--nav-muted); } .timebox.darkbox .l b { color: #fff; }

.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { background: var(--panel-2); text-align: left; padding: 11px 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
table.data td { padding: 11px 14px; border-top: 1px solid var(--line-2); vertical-align: top; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.void td { color: #9AA6B6; text-decoration: line-through; }

.form { display: grid; gap: 14px; }
.form.cols { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
label.f input, label.f select, label.f textarea { min-height: 44px; border: 1px solid #CBD2DC; border-radius: 8px; padding: 0 12px; font: inherit; font-size: 15px; font-weight: 400; background: #fff; color: var(--ink); }
label.f textarea { padding: 10px 12px; min-height: 80px; }
label.f input.big { font-family: var(--mono); font-size: 20px; font-weight: 600; min-height: 52px; }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
label.check input { width: 22px; height: 22px; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; }
.seg button { min-height: 44px; border-radius: 10px; border: 1px solid #CBD2DC; background: #fff; font: inherit; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--ink); color: #fff; border: 2px solid var(--ink); font-weight: 700; }
.note { font-size: 12px; color: var(--muted); }
.msg { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.msg.err { background: var(--red-bg); color: var(--red-ink); }
.msg.ok { background: var(--green-bg); color: var(--green-ink); }
.msg.info { background: var(--blue-bg); color: var(--blue-ink); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--nav); }
.auth .card { width: 100%; max-width: 420px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth .logo { width: 170px; align-self: center; }

/* ---------- offline bar, toast, dialog ---------- */
.offline { background: var(--amber-bg); color: var(--amber-ink); font-size: 13px; padding: 8px 14px; border-radius: 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100% - 24px)); max-height: calc(100vh - 32px); overflow: auto; }
dialog::backdrop { background: rgba(14, 23, 38, .55); }
dialog .dhead { padding: 18px 20px 0; }
dialog .dbody { padding: 16px 20px; display: grid; gap: 14px; }
dialog .dfoot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ---------- mobile ---------- */
.mobilebar { display: none; }
@media (max-width: 760px) {
  .nav { display: none; }
  .mobilebar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .mobilebar a { min-height: 60px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--ink-2); text-decoration: none; }
  .mobilebar a.active { color: var(--accent); font-weight: 700; }
  .ac-head img { width: 100%; height: 180px; }
}
