/* ============================================================================
   FleetLog - depot instrumentation.

   The visual language is workshop hardware, not web app: a graphite or bone
   ground ruled like graph paper, amber used only as a signal, hairlines in
   place of cards, near-zero radius, and figures set in tabular mono so columns
   of kilometres line up the way they do on a gauge.

   Light and dark are both first class. Every colour is a token; nothing below
   this block hardcodes one, so the two themes cannot drift apart.
   ==========================================================================*/

:root {
  color-scheme: light dark;

  /* Signal colours. These are lamps, not decoration, and they hold their
     meaning in both themes: go / caution / stop. */
  --signal:      #e3a008;
  --go:          #128a5f;
  --stop:        #cf3239;
  --info:        #2b7cd3;

  /* Login brand panel photo. Placeholder: swap for a real depot or fleet shot
     by dropping the file in public/img/ and pointing this at it, e.g.
     url("/img/login.jpg"). The panel keeps its amber wash if this fails to
     load, so there is no broken-image state. */
  --login-photo: url("https://picsum.photos/seed/fleetlog-depot-yard/1400/1800");

  --radius: 2px;
  --hair: 1px;

  --font-display: 'Archivo', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;

  --ease: cubic-bezier(.2, 0, 0, 1);   /* mechanical, no overshoot */
  --tick: 130ms;
}

/* ---- light: bone paper and ink, the colour of a printed job card ---- */
:root, :root[data-theme="light"] {
  --bg:          #e8e6e0;
  --grid:        rgba(24, 27, 32, .050);
  --panel:       #f6f5f2;
  --panel-2:     #e3e0d9;
  --line:        #c7c3b9;
  --line-hard:   #9b968a;
  --text:        #181b20;
  --muted:       #5c6069;
  --signal-text: #7d5800;
  --go-text:     #0c6644;
  --stop-text:   #9c2229;
  --info-text:   #1c5c9e;
  --go-fill:     #e4f4ec;
  --caution-fill:#fbf0d5;
  --stop-fill:   #fbe6e7;
  --info-fill:   #e6eff9;
  --shadow:      0 1px 0 rgba(24, 27, 32, .06);
  --shadow-lift: 0 2px 0 rgba(24, 27, 32, .10), 0 8px 24px rgba(24, 27, 32, .10);
  --plate-ink:   #181b20;
  --plate-bg:    #f2f0ea;
}

/* ---- dark: graphite, the colour of the machine it manages ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #131519;
    --grid:        rgba(255, 255, 255, .042);
    --panel:       #1b1e23;
    --panel-2:     #23272e;
    --line:        #333942;
    --line-hard:   #4d545f;
    --text:        #e9e7e2;
    --muted:       #989ea8;
    --signal-text: #f0b429;
    --go-text:     #3fc794;
    --stop-text:   #ff7a80;
    --info-text:   #6fb2f0;
    --go-fill:     #10241d;
    --caution-fill:#2a2113;
    --stop-fill:   #2b1618;
    --info-fill:   #12212f;
    --shadow:      0 1px 0 rgba(0, 0, 0, .35);
    --shadow-lift: 0 2px 0 rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .45);
    --plate-ink:   #e9e7e2;
    --plate-bg:    #14171b;
  }
}
:root[data-theme="dark"] {
  --bg:          #131519;
  --grid:        rgba(255, 255, 255, .042);
  --panel:       #1b1e23;
  --panel-2:     #23272e;
  --line:        #333942;
  --line-hard:   #4d545f;
  --text:        #e9e7e2;
  --muted:       #989ea8;
  --signal-text: #f0b429;
  --go-text:     #3fc794;
  --stop-text:   #ff7a80;
  --info-text:   #6fb2f0;
  --go-fill:     #10241d;
  --caution-fill:#2a2113;
  --stop-fill:   #2b1618;
  --info-fill:   #12212f;
  --shadow:      0 1px 0 rgba(0, 0, 0, .35);
  --shadow-lift: 0 2px 0 rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .45);
  --plate-ink:   #e9e7e2;
  --plate-bg:    #14171b;
}

/* legacy aliases so nothing that still names a colour breaks */
:root { --amber: var(--signal); --amber-text: var(--signal-text); --green: var(--go); --red: var(--stop); --blue: var(--info); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background-color: var(--bg);
  /* ruled ground: 8px graph paper, the surface a job card is written on */
  background-image:
    repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 8px);
  color: var(--text);
  font: 13.5px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-stretch: 112%;             /* Archivo's width axis: signage, not text */
  letter-spacing: -.005em;
  line-height: 1.08;
}
h1, h2 { text-transform: uppercase; letter-spacing: .01em; }

.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* every figure in the app lines up in a column */
td, .card .v, .score-cell .n, .alert-item .l, .matchcount, .pager { font-variant-numeric: tabular-nums; }

.error {
  color: var(--stop-text); background: var(--stop-fill);
  border: var(--hair) solid var(--stop); border-left-width: 3px;
  padding: 8px 10px; border-radius: var(--radius); margin: 8px 0; font-size: 13px;
}

/* a registration plate reads as a plate, not as a string in a cell */
.plate {
  font-family: var(--font-mono); font-weight: 600; font-size: 12.5px;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--plate-ink); background: var(--plate-bg);
  border: var(--hair) solid var(--line-hard); border-radius: var(--radius);
  padding: 1px 6px; display: inline-block; white-space: nowrap;
}

/* --------------------- motion: mechanical, brief --------------------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
/* a stop lamp with something behind it draws the eye, once every two seconds */
@keyframes lamp { 0%, 100% { box-shadow: inset 0 0 0 1px var(--stop); } 50% { box-shadow: inset 0 0 0 1px var(--stop), 0 0 0 3px var(--stop-fill); } }

.page > * { animation: fadeUp .24s var(--ease) both; }
.page > *:nth-child(2) { animation-delay: .03s; }
.page > *:nth-child(3) { animation-delay: .06s; }
.page > *:nth-child(4) { animation-delay: .09s; }
.page > *:nth-child(5) { animation-delay: .12s; }
.page > *:nth-child(n+6) { animation-delay: .15s; }
.card, .panel { transition: border-color var(--tick) var(--ease); }
.card:hover, .panel:hover { border-color: var(--line-hard); }
tbody tr { transition: background 90ms var(--ease); }
.btn { transition: background var(--tick) var(--ease), border-color var(--tick) var(--ease), transform 80ms var(--ease); }
.btn:active { transform: translateY(1px); }
.modal { animation: popIn .14s var(--ease); }
.modal-back { animation: fadeUp .14s var(--ease); }
.toast { animation: slideIn .2s var(--ease); }

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--signal); outline-offset: 2px; border-radius: var(--radius);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------ login ------------------------------ */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 768px) { .login-wrap { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--panel); }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 14px; animation: fadeUp .3s var(--ease) both; }
.login-brand {
  font-family: var(--font-display); font-size: 14px; font-weight: 700; font-stretch: 118%;
  letter-spacing: .16em; text-transform: uppercase; color: var(--signal-text);
}
.login-card h1 { font-size: 38px; color: var(--text); }
.login-card label { display: grid; gap: 5px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.login-card input, .login-card .btn, .login-card .error { border-radius: var(--radius); }
.login-card input { padding: 10px 11px; font-size: 14px; }
.login-card .btn { padding: 11px 14px; font-size: 13px; margin-top: 4px; }
.login-card .error { margin: 0; }

.login-aside {
  display: none; align-items: flex-end; padding: 40px;
  background-color: #14171b;
  background-image:
    linear-gradient(to top, rgba(12, 14, 17, .92) 0%, rgba(12, 14, 17, .58) 60%, rgba(12, 14, 17, .48) 100%),
    linear-gradient(140deg, rgba(227, 160, 8, .42), rgba(19, 21, 25, .35)),
    var(--login-photo);
  background-size: cover; background-position: center; background-repeat: no-repeat;
}
@media (min-width: 768px) { .login-aside { display: flex; } }
.login-aside p {
  font-family: var(--font-display); font-size: 30px; font-weight: 600; font-stretch: 108%;
  line-height: 1.2; color: #fff; max-width: 20ch; text-wrap: balance;
  animation: fadeUp .42s .06s var(--ease) both;
}

/* --------------------------- app shell ----------------------------- */
:root { --nav-w: 232px; --nav-w-min: 60px; }
.app { min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--nav-w);
  display: flex; flex-direction: column; gap: 1px;
  background: var(--panel); border-right: var(--hair) solid var(--line);
  padding: 0 8px 14px; overflow-x: hidden; overflow-y: auto; z-index: 45;
  transition: width .16s var(--ease);
}
body.nav-collapsed .sidebar { width: var(--nav-w-min); }
body.nav-collapsed .sidebar:hover { width: var(--nav-w); box-shadow: var(--shadow-lift); }

.sidebar .brand {
  display: flex; align-items: center; gap: 10px; height: 54px; flex: none; padding: 0 8px;
  color: var(--text); font-family: var(--font-display); font-weight: 700; font-stretch: 118%;
  font-size: 20px; letter-spacing: .1em; text-transform: uppercase; text-decoration: none; white-space: nowrap;
}
.sidebar .brand i { font-size: 21px; flex: none; color: var(--signal); }

.nav-group {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .18em;
  color: var(--muted); padding: 15px 10px 5px; white-space: nowrap;
}
.navlink {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px;
  color: var(--text); text-decoration: none; font-size: 13px; white-space: nowrap;
  border-left: 2px solid transparent; border-radius: 0;
  transition: background var(--tick) var(--ease), color var(--tick) var(--ease);
}
.navlink i { font-size: 18px; flex: none; width: 22px; text-align: center; color: var(--muted); }
.navlink:hover { background: var(--panel-2); }
.navlink.active { background: var(--panel-2); border-left-color: var(--signal); font-weight: 600; }
.navlink.active i { color: var(--signal); }

body.nav-collapsed .sidebar:not(:hover) .navlabel,
body.nav-collapsed .sidebar:not(:hover) .brandname { opacity: 0; width: 0; overflow: hidden; }
body.nav-collapsed .sidebar:not(:hover) .nav-group { height: 1px; padding: 9px 0 0; color: transparent; overflow: hidden; }

.shell { margin-left: var(--nav-w); transition: margin-left .16s var(--ease); min-width: 0; }
body.nav-collapsed .shell { margin-left: var(--nav-w-min); }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 6px 22px;
  background: var(--panel); border-bottom: var(--hair) solid var(--line-hard);
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none;
  background: none; border: var(--hair) solid transparent; border-radius: var(--radius);
  color: var(--muted); font-size: 18px; cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }

.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--signal-text); }
.crumb i { font-size: 10px; opacity: .55; }
.crumb .crumb-current { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 12px; }
.nav-scrim { display: none; }

.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 22px 4px; flex-wrap: wrap; }
.pagehead h2 { font-size: 30px; }
.pagehead-right { display: flex; align-items: center; gap: 10px; }
.page { padding: 16px 22px 44px; display: grid; gap: 16px; align-content: start; }

/* ------------------------------ controls --------------------------- */
.btn {
  background: var(--panel); color: var(--text); border: var(--hair) solid var(--line-hard);
  padding: 7px 14px; border-radius: var(--radius); cursor: pointer;
  font: 600 11.5px/1.5 var(--font-body); text-transform: uppercase; letter-spacing: .09em;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: #181b20; }
.btn.primary:hover { background: #f0ae12; }
.btn.danger { background: transparent; border-color: var(--stop); color: var(--stop-text); }
.btn.danger:hover { background: var(--stop-fill); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { border-color: var(--line); }
.btn.slim { padding: 4px 10px; font-size: 10.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }

input, select, textarea {
  background: var(--bg); color: var(--text); border: var(--hair) solid var(--line-hard);
  border-radius: var(--radius); padding: 7px 10px; font: 13px var(--font-body); width: 100%;
}
select { font-family: var(--font-body); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--signal); outline-offset: 0; border-color: var(--signal); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input[type="number"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
label.f { display: grid; gap: 4px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters input, .filters select { width: auto; min-width: 140px; }
.filters .grow { flex: 1; min-width: 220px; }
.matchcount { font-size: 11px; color: var(--muted); padding-bottom: 9px; white-space: nowrap; font-family: var(--font-mono); }

/* ------------------------------ widgets ---------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: var(--hair) solid var(--line);
  border-top: 2px solid var(--line-hard);
  border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 3px;
}
.card .k { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .13em; display: flex; align-items: center; gap: 7px; }
.card .v { font-family: var(--font-mono); font-size: 29px; font-weight: 600; line-height: 1.05; letter-spacing: -.02em; }
.card .s { color: var(--muted); font-size: 11px; }
.card.warn { border-top-color: var(--signal); }
.card.warn .v { color: var(--signal-text); }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: var(--hair) solid var(--line); border-radius: var(--radius); padding: 15px 16px; }
.panel > h3, .panel .ptitle {
  font-family: var(--font-body); font-weight: 700; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .15em; color: var(--muted);
  padding-bottom: 9px; margin-bottom: 13px; border-bottom: var(--hair) solid var(--line);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.chart-wrap { position: relative; height: 230px; }

.alert-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.alert-list { display: grid; gap: 0; max-height: 260px; overflow: auto; }
/* hairlines between rows, not a stack of little boxes */
.alert-item {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 8px 2px; border-bottom: var(--hair) solid var(--line);
}
.alert-item:last-child { border-bottom: none; }
.alert-item .l { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; }
.alert-item .s { color: var(--muted); font-size: 11px; }

/* ---------------------- fleet status scorecard --------------------- */
.scorecard { display: grid; gap: 0; }
.score-row { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); align-items: stretch; border-top: var(--hair) solid var(--line); }
.score-row:first-of-type { border-top: none; }
.score-head { display: grid; align-content: center; gap: 2px; padding: 12px 8px 12px 0; min-width: 0; }
.score-head .l { font-weight: 600; font-size: 12.5px; }
.score-head .s { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }
/* each cell is a signal lamp: solid block, mono figure, hard edge */
.score-cell {
  display: grid; gap: 2px; align-content: center; justify-items: center;
  padding: 10px 6px; margin: 6px 0 6px 6px;
  background: var(--panel-2); border: var(--hair) solid transparent; border-radius: var(--radius);
  font-family: var(--font-body); cursor: pointer; text-align: center; color: var(--muted);
  transition: border-color var(--tick) var(--ease), transform 80ms var(--ease);
}
.score-cell .n { font-family: var(--font-mono); font-size: 23px; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.score-cell .k { font-size: 9px; text-transform: uppercase; letter-spacing: .14em; }
.score-cell:hover { border-color: currentColor; }
.score-cell:active { transform: translateY(1px); }
.score-cell:disabled { cursor: default; opacity: .4; }
.score-cell:disabled:hover { border-color: transparent; }
.score-cell.green { color: var(--go-text); background: var(--go-fill); }
.score-cell.amber { color: var(--signal-text); background: var(--caution-fill); }
.score-cell.red   { color: var(--stop-text); background: var(--stop-fill); }
/* a stop lamp with something behind it pulses; an empty one stays dark */
.score-cell.red:not(:disabled) { animation: lamp 2.4s var(--ease) infinite; }

/* hazard tape: reserved for the one state that means stop work */
.flagbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; border: var(--hair) solid var(--line-hard);
  border-left: 6px solid transparent;
  border-image: repeating-linear-gradient(45deg, var(--signal) 0 6px, var(--line-hard) 6px 12px) 6;
  background: var(--caution-fill); color: var(--signal-text);
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
}
.flagbar .btn { margin-left: auto; }

/* ------------------------------ badges ------------------------------ */
.badge {
  padding: 2px 8px; border-radius: var(--radius); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  border: var(--hair) solid var(--line); display: inline-block; background: var(--panel-2); color: var(--muted);
}
.badge.ok   { color: var(--go-text); border-color: var(--go); background: var(--go-fill); }
.badge.warn { color: var(--signal-text); border-color: var(--signal); background: var(--caution-fill); }
.badge.bad  { color: var(--stop-text); border-color: var(--stop); background: var(--stop-fill); }
.badge.info { color: var(--info-text); border-color: var(--info); background: var(--info-fill); }

/* ------------------------------ table ------------------------------ */
.table-wrap { background: var(--panel); border: var(--hair) solid var(--line); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: var(--hair) solid var(--line); white-space: nowrap; vertical-align: top; }
th {
  color: var(--muted); font-weight: 700; font-size: 9.5px; text-transform: uppercase; letter-spacing: .14em;
  position: sticky; top: 0; background: var(--panel-2); cursor: pointer; user-select: none;
  border-bottom: 2px solid var(--line-hard);
}
th:hover { color: var(--text); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
.cell-wrap { white-space: normal !important; word-break: break-word; min-width: 180px; max-width: 460px; }
td.actions { text-align: right; white-space: nowrap; }
td .link {
  color: var(--muted); cursor: pointer; background: none; border: none;
  font: 600 10px/1.5 var(--font-body); text-transform: uppercase; letter-spacing: .1em; padding: 0 5px;
}
td .link:hover { color: var(--signal-text); }
td .link.del:hover { color: var(--stop-text); }
.plines { white-space: normal; min-width: 220px; }
.plines .pline { display: flex; gap: 6px; align-items: baseline; }
.plines .pqty, .plines .pcost { color: var(--muted); font-size: 11.5px; font-family: var(--font-mono); }

/* ------------------------------ modal ------------------------------ */
.modal-back {
  position: fixed; inset: 0; background: rgba(10, 12, 15, .62); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 34px 16px; overflow: auto;
}
.modal {
  background: var(--panel); border: var(--hair) solid var(--line-hard); border-top: 3px solid var(--signal);
  border-radius: var(--radius); width: 620px; max-width: 100%; padding: 20px 22px;
  display: grid; gap: 12px; box-shadow: var(--shadow-lift);
}
.modal.wide { width: 840px; }
.modal h3 { font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; align-items: center; }
.modal .foot .total { margin-right: auto; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }
.modal .foot .total b { font-family: var(--font-mono); color: var(--text); font-size: 14px; }
.foot { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

.parts-box { border: var(--hair) solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; background: var(--panel-2); }
.parts-box .boxhead { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .13em; color: var(--muted); }
.parts-line { display: grid; grid-template-columns: 92px 1.3fr 1fr 1fr 56px 90px 84px 26px; gap: 6px; align-items: center; }
.parts-line input, .parts-line select { padding: 5px 7px; font-size: 12.5px; }
.parts-line .unit { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.parts-head { color: var(--muted); }
.parts-total { display: flex; justify-content: flex-end; gap: 8px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; align-items: baseline; }
.parts-total b { font-family: var(--font-mono); color: var(--text); font-size: 14px; letter-spacing: 0; }
.xbtn { background: transparent; border: var(--hair) solid var(--stop); color: var(--stop-text); border-radius: var(--radius); cursor: pointer; height: 26px; }
.xbtn:hover { background: var(--stop-fill); }

.checklist-sec { border: var(--hair) solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--panel-2); }
.checklist-sec h4 { font-family: var(--font-body); font-size: 10px; color: var(--signal-text); margin-bottom: 9px; text-transform: uppercase; letter-spacing: .14em; font-weight: 700; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.checklist .item { display: grid; grid-template-columns: 1fr 120px; gap: 8px; align-items: center; }
.checklist .item .cl-label { font-size: 12.5px; }
.checklist .item .cl-label small { display: block; color: var(--muted); font-size: 10.5px; }
.checklist select { padding: 4px 6px; font-size: 12px; }
.checklist-standalone { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.checklist-standalone .item { display: grid; grid-template-columns: 1fr 110px 1fr; gap: 8px; align-items: center; }

.diff { display: grid; gap: 8px; }
.diff pre {
  background: var(--bg); border: var(--hair) solid var(--line); border-radius: var(--radius);
  padding: 10px; font: 11.5px var(--font-mono); overflow: auto; max-height: 220px; color: var(--muted);
}

/* ------------------------------ toast ------------------------------ */
#toastRoot { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 99; }
.toast {
  background: var(--panel); border: var(--hair) solid var(--line-hard); border-left: 4px solid var(--go);
  padding: 10px 14px; border-radius: var(--radius); font-size: 12.5px; max-width: 380px;
  box-shadow: var(--shadow-lift); color: var(--text);
}
.toast.ok { border-left-color: var(--go); }
.toast.err { border-left-color: var(--stop); }
.toast.info { border-left-color: var(--info); }

.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }
.exportwrap { position: relative; }
.exportmenu {
  position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel);
  border: var(--hair) solid var(--line-hard); border-radius: var(--radius);
  display: grid; min-width: 160px; z-index: 30; overflow: hidden; box-shadow: var(--shadow-lift);
}
.exportmenu button {
  background: none; border: none; color: var(--text); text-align: left; padding: 9px 13px;
  font: 600 10.5px/1.5 var(--font-body); text-transform: uppercase; letter-spacing: .1em; cursor: pointer;
  border-bottom: var(--hair) solid var(--line);
}
.exportmenu button:last-child { border-bottom: none; }
.exportmenu button:hover { background: var(--panel-2); color: var(--signal-text); }

/* ------------------------- mobile responsiveness ------------------------- */
@media (max-width: 900px) {
  .sidebar { width: var(--nav-w); transform: translateX(-100%); transition: transform .18s var(--ease); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lift); }
  body.nav-collapsed .sidebar, body.nav-collapsed .sidebar:hover { width: var(--nav-w); box-shadow: none; }
  body.nav-collapsed .sidebar:not(:hover) .navlabel,
  body.nav-collapsed .sidebar:not(:hover) .brandname { opacity: 1; width: auto; }
  body.nav-collapsed .sidebar:not(:hover) .nav-group { height: auto; padding: 15px 10px 5px; color: var(--muted); }
  .shell, body.nav-collapsed .shell { margin-left: 0; }
  .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(10, 12, 15, .55); z-index: 44; }
  .nav-scrim[hidden] { display: none; }
  .topbar { padding: 6px 14px; }
}

@media (max-width: 760px) {
  body { font-size: 13px; }
  .page { padding: 14px 14px 32px; gap: 12px; }
  .pagehead { padding: 14px 14px 0; }
  .pagehead h2 { font-size: 24px; }
  .pagehead-right { width: 100%; flex-direction: column; align-items: stretch; gap: 8px; }
  .pagehead-right select { width: 100% !important; }

  .filters { flex-direction: column; align-items: stretch; gap: 10px; }
  .filters label.f, .filters input, .filters select, .filters .btn { width: 100%; min-width: 0; }
  .filters .grow { min-width: 0; }
  .filters > div[style] { display: none; }
  .matchcount { padding-bottom: 0; }
  .exportwrap { display: grid; }

  .form-grid, .checklist, .checklist-standalone { grid-template-columns: 1fr; }
  .parts-line { grid-template-columns: 1fr 1fr; }
  .modal { padding: 16px; }

  input, select, textarea { font-size: 16px; }
  .parts-line input, .parts-line select, .checklist select, .checklist input { font-size: 13px; }

  .foot { flex-wrap: wrap; }

  .score-row { grid-template-columns: repeat(3, 1fr); }
  .score-head { grid-column: 1 / -1; padding: 12px 0 2px; }
  .score-cell { margin: 0 0 6px; }
  .score-cell:first-of-type { margin-left: 0; }
}

@media (max-width: 560px) {
  .topbar-right .muted { display: none; }
}

/* --------------------- vehicle detail + new atoms -------------------- */
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.detail-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.detail-id > i { font-size: 30px; color: var(--signal); flex: none; }
.detail-plate { font-size: 19px; padding: 3px 10px; letter-spacing: .06em; }

/* tab strip: a ruled row of switches, not pills */
.tabs { display: flex; gap: 0; flex-wrap: wrap; border-bottom: var(--hair) solid var(--line); }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 10px 15px; margin-bottom: -1px; cursor: pointer; color: var(--muted);
  font: 700 10.5px/1.5 var(--font-body); text-transform: uppercase; letter-spacing: .12em;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--signal-text); border-bottom-color: var(--signal); }

.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 20px; }
.overview-grid .k { color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: .14em; margin-bottom: 3px; }
.overview-grid .ov { font-size: 13.5px; }

/* empty state: says why it is empty and what to do next */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); display: grid; gap: 5px; justify-items: center; }
.empty i { font-size: 30px; opacity: .5; margin-bottom: 4px; }
.empty .l { color: var(--text); font-weight: 600; font-size: 14px; }
.empty .s { font-size: 12.5px; max-width: 42ch; }

/* a plate with its vehicle-type mark alongside */
.plate-cell { display: inline-flex; align-items: center; gap: 8px; }
.plate-cell > i { font-size: 15px; color: var(--muted); flex: none; }

/* the "reset to role default" control sits with its label */
.permhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }

@media (max-width: 760px) {
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .tab { padding: 9px 11px; }
}

/* ------------------- live figures under a form ---------------------- */
/* The arithmetic the form is doing as you type: consumption, variance, what
   the card will be left with. Reads as an instrument panel, not a card. */
.readout {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 1px; margin-top: 4px;
  background: var(--line); border: var(--hair) solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.readout-item { background: var(--panel-2); padding: 9px 11px; display: grid; gap: 2px; }
.readout-item .k {
  font-size: 9px; text-transform: uppercase; letter-spacing: .13em; color: var(--muted);
}
.readout-item .v {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 14px; font-weight: 500;
}
.readout-item.good .v { color: var(--go-text); }
.readout-item.bad .v { color: var(--stop-text); }

/* ------------------ clickable alerts + stacked cells ----------------- */
/* An alert row is a way in to the record it is about. */
a.alert-item { text-decoration: none; color: inherit; cursor: pointer; }
a.alert-item:hover { background: var(--panel-2); }
a.alert-item:hover .l { color: var(--signal-text); }
.alert-item.linked .l { text-decoration: underline; text-decoration-color: var(--line-hard); text-underline-offset: 2px; }
.ptitle .seeall {
  margin-left: auto; color: var(--signal-text); text-decoration: none;
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; white-space: nowrap;
}
.ptitle .seeall:hover { text-decoration: underline; }

/* two lines in one cell: the thing, then what qualifies it */
.stackcell { display: grid; gap: 3px; justify-items: start; }
.stackcell .small { font-size: 11px; }

/* --------------------------- report header --------------------------- */
/* What the export prints at its head, shown on screen so the two agree. */
.rephead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}
.rephead h3 {
  font-family: var(--font-display); font-size: 21px; font-weight: 700;
  font-stretch: 108%; text-transform: uppercase; letter-spacing: .01em;
}
.rephead p { max-width: 68ch; margin-top: 3px; }
.repmeta { display: flex; gap: 26px; flex-wrap: wrap; }
.repmeta > div { display: grid; gap: 2px; }
.repmeta .k {
  font-size: 9px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted);
}
.repmeta .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; }

/* figures line up on the decimal, headings included */
td.numcol, th.numcol { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td {
  border-top: 2px solid var(--line-hard); border-bottom: none;
  background: var(--panel-2); font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  .rephead { flex-direction: column; gap: 12px; }
  .repmeta { gap: 16px; }
}
