/* Shoprite FR-VLM-001 · Stage 12 — the lifecycle dashboard.
 *
 * Tokens are the existing Simply Fleet dashboard palette (simplyfleetsc / kishugu / roadlab-fleet),
 * unchanged on purpose: same portal, same people, nothing to relearn. The drawer rules are copied
 * from `widgets/roadlab-fleet/index.html` by way of `widgets/kishugu/index.html`, which is where
 * the pattern has been in production for months (CORE.md: copy a production pattern first).
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:#0F1626; --teal:#009AA4; --teal-dark:#007a82; --teal-light:#e6f5f6;
  --slate:#2C5C72; --bg:#F3F5F9; --card:#FFFFFF; --text:#0F1626;
  --muted:#8E99A2; --border:#E2E4E8;
  --green:#27AE60; --green-light:#eaf7ef;
  --amber:#F2994A; --amber-light:#fef5eb;
  --red:#EB5757;   --red-light:#fdeaea;
  --blue:#2F80ED;  --blue-light:#e8f1fd;
  --purple:#8B5CF6; --purple-light:#f1ecfe;
  --shadow:0 2px 8px rgba(15,22,38,.07), 0 1px 2px rgba(15,22,38,.04);
  --r:10px; --rs:6px;
}

body {
  font-family:'Rubik',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  background:var(--bg); color:var(--text);
  font-size:14px; line-height:1.5;
  padding:16px;                       /* the 16px gutter the portal iframe needs on a phone */
  -webkit-font-smoothing:antialiased;
}

/* ── header ─────────────────────────────────────────────────────────────────────────────────── */
.top {
  display:flex; align-items:flex-start; gap:16px; flex-wrap:wrap;
  padding-bottom:14px; margin-bottom:16px; border-bottom:1px solid var(--border);
}
.brand-t { font-size:19px; font-weight:700; letter-spacing:-.2px; }
/* BUILD-PLAN §12 trap: "State the data window on screen." This is that line; it is never empty. */
.brand-s { font-size:12px; color:var(--muted); margin-top:3px; }
.top-actions { margin-left:auto; display:flex; align-items:center; gap:10px; }
.src { font-size:11px; color:var(--muted); }
.src b { font-weight:600; color:var(--slate); }
.btn {
  font:inherit; font-size:13px; font-weight:500; padding:6px 14px; border-radius:var(--rs);
  border:1px solid var(--border); background:var(--card); color:var(--slate); cursor:pointer;
}
.btn:hover { border-color:var(--teal); color:var(--teal-dark); }
.btn:disabled { opacity:.55; cursor:progress; }
.btn.primary { background:var(--teal); border-color:var(--teal); color:#fff; }
.btn.primary:hover { background:var(--teal-dark); color:#fff; }

/* ── boot / error ───────────────────────────────────────────────────────────────────────────── */
.boot { display:flex; flex-direction:column; align-items:center; gap:14px; padding:64px 0; color:var(--muted); }
.spin { width:30px; height:30px; border:3px solid var(--border); border-top-color:var(--teal); border-radius:50%; animation:sp .8s linear infinite; }
@keyframes sp { to { transform:rotate(360deg); } }
.fail { background:var(--red-light); border:1px solid #f6c9c9; border-radius:var(--r); padding:16px 18px; }
.fail h3 { font-size:14px; color:var(--red); margin-bottom:6px; }
.fail p  { font-size:13px; color:var(--slate); }
.fail pre { font-size:11px; background:#fff; border-radius:var(--rs); padding:8px 10px; margin-top:8px; overflow-x:auto; }

/* ── tabs ───────────────────────────────────────────────────────────────────────────────────
 * Same shape as every other dashboard in the estate (`widgets/roadlab-fleet/index.html`: a sticky
 * nav of `.tab-btn`s over `.page` panels, `.active` on both, `.badge-count` for the number that
 * wants attention). Copied rather than reinvented so this reads as the same product.
 *
 * Why tabs at all: the six sections stacked ran to ~3,200px. Billing and Operations — the two a
 * fleet manager opens the dashboard FOR — sat below anything anyone scrolls to. */
nav.tabs {
  display:flex; gap:2px; overflow-x:auto; -webkit-overflow-scrolling:touch;
  background:var(--card); border-radius:var(--r) var(--r) 0 0;
  border-bottom:1px solid var(--border); box-shadow:var(--shadow);
  position:sticky; top:0; z-index:199; margin-bottom:16px; padding:0 6px;
}
.tab-btn {
  padding:12px 15px; border:0; background:none; cursor:pointer; font:inherit;
  font-size:13px; font-weight:500; color:var(--muted);
  border-bottom:3px solid transparent; margin-bottom:-1px; white-space:nowrap;
  display:inline-flex; align-items:center; gap:7px; transition:color .15s, border-color .15s;
}
.tab-btn:hover { color:var(--teal-dark); }
.tab-btn.active { color:var(--teal-dark); border-bottom-color:var(--teal); font-weight:600; }
.tab-btn:focus-visible { outline:2px solid var(--teal-dark); outline-offset:-2px; }
.badge-count {
  background:var(--red); color:#fff; font-size:10px; font-weight:700;
  border-radius:10px; padding:1px 6px; line-height:1.5;
}
.badge-count.calm { background:var(--muted); }
.page { display:none; }
.page.active { display:block; animation:fade .18s ease-out; }
@keyframes fade { from { opacity:0; transform:translateY(3px); } to { opacity:1; transform:none; } }

/* ── layout ─────────────────────────────────────────────────────────────────────────────────── */
section.blk { margin-bottom:22px; }
.blk-h { display:flex; align-items:baseline; gap:10px; margin-bottom:10px; flex-wrap:wrap; }
.blk-h h2 { font-size:13px; font-weight:700; text-transform:uppercase; letter-spacing:.7px; color:var(--slate); }
.blk-h .ref { font-size:11px; color:var(--muted); }
.blk-h .tools { margin-left:auto; display:flex; align-items:center; gap:8px; }

.card { background:var(--card); border-radius:var(--r); box-shadow:var(--shadow); padding:14px 16px; }
.grid { display:grid; gap:12px; grid-template-columns:repeat(auto-fit, minmax(190px, 1fr)); }
.grid.wide { grid-template-columns:repeat(auto-fit, minmax(290px, 1fr)); }
.cols2 { display:grid; gap:12px; grid-template-columns:repeat(auto-fit, minmax(340px, 1fr)); }
/* The three lifecycle DIMENSIONS — custody, COO and exception — side by side, because they are
 * three parallel state machines over the same vehicle and the demo reads them together. */
.cols3 { display:grid; gap:12px; grid-template-columns:repeat(auto-fit, minmax(290px, 1fr)); }

/* ── stat tiles ─────────────────────────────────────────────────────────────────────────────── */
.stat {
  background:var(--card); border-radius:var(--r); box-shadow:var(--shadow);
  padding:13px 15px; text-align:left; display:block; width:100%;
  border:0; border-left:3px solid var(--border); position:relative; font:inherit; color:inherit;
  transition:box-shadow .12s, transform .12s;
}
.stat .lab { font-size:11px; text-transform:uppercase; letter-spacing:.6px; color:var(--muted); font-weight:600; }
.stat .val { font-size:26px; font-weight:700; line-height:1.15; margin-top:4px; letter-spacing:-.5px; }
.stat .note { font-size:11px; color:var(--muted); margin-top:3px; }
.stat.good { border-left-color:var(--green); } .stat.good .val { color:var(--green); }
.stat.warn { border-left-color:var(--amber); } .stat.warn .val { color:#b26a1d; }
.stat.bad  { border-left-color:var(--red);   } .stat.bad  .val { color:var(--red); }
.stat.info { border-left-color:var(--blue);  } .stat.info .val { color:var(--blue); }
.stat.calm { border-left-color:var(--teal);  } .stat.calm .val { color:var(--teal-dark); }

button.stat.click { cursor:pointer; }
button.stat.click:hover { box-shadow:0 2px 10px rgba(0,154,164,.22); transform:translateY(-1px); }
button.stat.click::after { content:'\22EF'; position:absolute; top:6px; right:10px; font-size:13px; color:var(--muted); }
button.stat.click:hover::after { color:var(--teal); }
button.stat.click:focus-visible { outline:2px solid var(--teal-dark); outline-offset:2px; }
/* A figure with NO record list behind it must SAY so rather than open an empty drawer
 * (STAGE12-CONTRACT §6: "a figure with no per-record list must say that is what it is showing"). */
.stat.inert::after { content:none; }

/* ── bars ───────────────────────────────────────────────────────────────────────────────────── */
.bars { display:flex; flex-direction:column; gap:7px; }
.bar { display:grid; grid-template-columns:minmax(96px,34%) 1fr auto; gap:9px; align-items:center;
       background:none; border:0; padding:2px 0; font:inherit; color:inherit; width:100%; text-align:left; }
.bar.click { cursor:pointer; }
.bar.click:hover .bar-k { color:var(--teal-dark); }
.bar.click:hover .bar-f { filter:brightness(.93); }
.bar.click:focus-visible { outline:2px solid var(--teal-dark); outline-offset:2px; border-radius:var(--rs); }
.bar-k { font-size:12px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
/* 🔴 BOTH OF THESE MUST BE `display:block`, AND THE FILL IS THE ONE THAT BITES.
 * `.bar-t` is a direct child of `.bar`, which is `display:grid`, so it gets blockified for free and
 * its `height:16px` applies. `.bar-f` is nested INSIDE it, is not a grid item, and therefore stays
 * `display:inline` — where `height:100%` is silently ignored and the fill renders at ZERO height.
 * The result is every bar looking like an identical empty grey pill whatever its value.
 * ⚠ It survived review because the obvious check passes: computed `width` and `background-color`
 * are both exactly right (22%, rgb(39,174,96)). Only `height` is wrong, and nothing prints it
 * unless you ask. The regression test asserts the rendered HEIGHT, not the colour. */
.bar-t { display:block; background:var(--bg); border-radius:99px; height:16px; overflow:hidden; }
.bar-f { display:block; height:100%; border-radius:99px; min-width:3px; transition:width .3s; background:var(--teal); }
.bar-f.good { background:var(--green); } .bar-f.warn { background:var(--amber); }
.bar-f.bad { background:var(--red); } .bar-f.info { background:var(--blue); }
.bar-f.calm { background:var(--teal); } .bar-f.mute { background:#cdd3da; }
.bar-v { font-size:12px; font-weight:700; min-width:34px; text-align:right; font-variant-numeric:tabular-nums; }

/* ── tables ─────────────────────────────────────────────────────────────────────────────────── */
.tw { overflow-x:auto; -webkit-overflow-scrolling:touch; }
table { width:100%; border-collapse:collapse; font-size:13px; }
th, td { padding:7px 10px; text-align:left; border-bottom:1px solid var(--border); white-space:nowrap; }
th { font-size:10px; text-transform:uppercase; letter-spacing:.6px; color:var(--muted); font-weight:600; background:var(--bg); position:sticky; top:0; }
td.r, th.r { text-align:right; font-variant-numeric:tabular-nums; }
tbody tr:last-child td { border-bottom:none; }
tbody tr:hover { background:var(--teal-light); }

.pill { display:inline-block; font-size:12px; font-weight:600; padding:1px 8px; border-radius:99px; }
.pill.good { background:var(--green-light); color:var(--green); }
.pill.warn { background:var(--amber-light); color:#b26a1d; }
.pill.bad  { background:var(--red-light);   color:var(--red); }
.pill.info { background:var(--blue-light);  color:var(--blue); }
.pill.calm { background:var(--teal-light);  color:var(--teal-dark); }
.pill.mute { background:var(--bg);          color:var(--muted); }

/* a count in a table that opens the same drawer */
.cnt { background:none; border:0; padding:0; cursor:pointer; font:inherit; }
.cnt .pill { cursor:pointer; border:1px solid transparent; }
.cnt:hover .pill { border-color:currentColor; }
.cnt:focus-visible { outline:2px solid var(--teal-dark); outline-offset:2px; border-radius:99px; }

/* ── notes / callouts ───────────────────────────────────────────────────────────────────────── */
.none { color:var(--muted); font-size:13px; font-style:italic; }
.caveat {
  font-size:12px; color:var(--slate); background:var(--amber-light);
  border-left:3px solid var(--amber); border-radius:0 var(--rs) var(--rs) 0;
  padding:8px 11px; margin-top:10px;
}
.caveat b { font-weight:600; }
.hint { font-size:11px; color:var(--muted); margin-top:8px; }

/* ── date-window controls ───────────────────────────────────────────────────────────────────── */
.win { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.win label { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.5px; font-weight:600; }
.win input[type=date] { font:inherit; font-size:12px; padding:4px 7px; border:1px solid var(--border); border-radius:var(--rs); background:var(--card); color:var(--text); }
input.search {
  font:inherit; font-size:12px; padding:5px 10px; min-width:240px;
  border:1px solid var(--border); border-radius:var(--rs); background:var(--card); color:var(--text);
}
input.search:focus { outline:none; border-color:var(--teal); box-shadow:0 0 0 2px var(--teal-light); }
.chip { font:inherit; font-size:12px; padding:4px 10px; border-radius:99px; border:1px solid var(--border); background:var(--card); color:var(--slate); cursor:pointer; }
.chip:hover { border-color:var(--teal); color:var(--teal-dark); }
.chip[aria-pressed="true"] { background:var(--teal); border-color:var(--teal); color:#fff; }

/* ── facets (the fleet finder) ──────────────────────────────────────────────────────────────── */
.facet { display:grid; grid-template-columns:minmax(120px,150px) 1fr; gap:10px;
         align-items:start; padding:7px 0; border-top:1px solid var(--border); }
.facet:first-of-type { border-top:0; }
.facet-l { font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted);
           font-weight:600; padding-top:5px; display:flex; flex-direction:column; }
.facet-h { text-transform:none; letter-spacing:0; font-weight:400; font-size:10px; }
.facet-v { display:flex; flex-wrap:wrap; gap:6px; }
.chip.on { background:var(--teal); border-color:var(--teal); color:#fff; }
.chip.preset { background:var(--teal-light); border-color:var(--teal-light); color:var(--teal-dark); font-weight:500; }
.chip.preset:hover { border-color:var(--teal); }
@media (max-width:560px) { .facet { grid-template-columns:1fr; } }

/* ── the drill-down drawer (pattern copied from widgets/roadlab-fleet) ──────────────────────── */
.dv-overlay { position:fixed; inset:0; background:rgba(15,22,38,.38); z-index:400;
              opacity:0; pointer-events:none; transition:opacity .22s; }
.dv-overlay.on { opacity:1; pointer-events:auto; }
.dv {
  position:fixed; top:0; right:0; bottom:0; width:520px; max-width:94vw; z-index:401;
  background:var(--card); box-shadow:-8px 0 32px rgba(15,22,38,.18);
  transform:translateX(100%); transition:transform .28s cubic-bezier(.4,0,.2,1);
  display:flex; flex-direction:column; overflow:hidden;
}
.dv.on { transform:translateX(0); }
.dv-h { display:flex; align-items:flex-start; gap:12px; flex-shrink:0;
        padding:16px 18px; border-bottom:1px solid var(--border); background:var(--bg); }
.dv-title { font-size:15px; font-weight:600; }
.dv-sub { font-size:12px; color:var(--muted); margin-top:2px; }
.dv-x { margin-left:auto; flex-shrink:0; width:28px; height:28px; border:0; border-radius:50%;
        background:var(--border); color:var(--slate); font-size:14px; cursor:pointer; }
.dv-x:hover { background:var(--red-light); color:var(--red); }
.dv-back { font:inherit; font-size:12px; color:var(--teal-dark); background:none; border:0;
           cursor:pointer; padding:9px 18px 0; text-align:left; }
.dv-back:hover { text-decoration:underline; }
.dv-act { padding:10px 18px 0; }
.dv-open-all {
  display:inline-block; font-size:12px; font-weight:500; text-decoration:none;
  color:var(--teal-dark); background:var(--teal-light); border:1px solid var(--teal-light);
  border-radius:var(--rs); padding:5px 11px;
}
.dv-open-all:hover { border-color:var(--teal); }
.dv-open-none { display:block; font-size:11px; color:var(--muted); line-height:1.45; }
.dv-body { flex:1; overflow-y:auto; padding:16px 18px 22px; display:flex; flex-direction:column; gap:12px; }
.dv-sort { display:flex; align-items:center; gap:8px; padding-bottom:4px; }
.dv-sort label { font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); font-weight:600; }
.dv-sort-sel { font:inherit; font-size:12px; padding:4px 8px; border:1px solid var(--border);
               border-radius:var(--rs); background:var(--card); color:var(--text); cursor:pointer; }
.dv-sort-sel:hover { border-color:var(--teal); }
.dv-list { list-style:none; display:flex; flex-direction:column; }
.dv-list li { padding:9px 0; border-bottom:1px solid var(--border); }
.dv-list li:last-child { border-bottom:0; }
.dv-r { display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; }
.dv-r-n { font-weight:600; font-size:14px; }
.dv-r-m { font-size:12px; color:var(--muted); margin-top:2px; }
.dv-states { display:flex; flex-wrap:wrap; gap:5px; margin-top:6px; }
.dv-states .pill { font-size:11px; font-weight:500; }
.dv-r-a { margin-left:auto; display:flex; gap:8px; align-items:center; }
/* The link OUT is a SECONDARY per-row action. STAGE12-CONTRACT §6: the pop-up is the primary
 * gesture, the button out is "for 'edit this one', not for 'show me the rows'". */
.dv-open { font-size:11px; color:var(--teal-dark); text-decoration:none; border:1px solid var(--border);
           border-radius:var(--rs); padding:2px 8px; white-space:nowrap; }
.dv-open:hover { border-color:var(--teal); background:var(--teal-light); }
.dv-more { font-size:12px; color:var(--muted); padding-top:8px; }
@media (max-width:560px) { .dv { width:100%; max-width:100%; } }

@media print {
  .page { display:block !important; }
  nav.tabs, .top-actions, .dv, .dv-overlay, .tools, button.stat.click::after { display:none !important; }
  body { padding:0; background:#fff; }
  .card, .stat { box-shadow:none; border:1px solid var(--border); }
  section.blk { break-inside:avoid; }
}
