/* ============================================================
   SIMBA LOGISTICS — shared control-room stylesheet
   Brand: Simba Red as a single loud signal on a calm
   charcoal-and-white base. Stolzl (Archivo/Inter fallback).
   ============================================================ */

:root {
  /* Brand */
  --red:        #ee202e;   /* PRIMARY — action / in-transit / alert only */
  --red-press:  #c8121e;
  --red-tint:   #fdecec;   /* red at low alpha for chip fills */
  --charcoal:   #242728;   /* app chrome */
  --charcoal-2: #2e3132;   /* raised chrome surface */
  --charcoal-3: #3a3d3e;   /* chrome borders / hover */
  --black:      #000000;
  --white:      #ffffff;
  --sand:       #dac1a4;   /* warm secondary — idle */
  --sand-tint:  #f6efe6;
  --gray:       #e5e5e5;   /* borders / dividers */
  --green:      #2e9e5b;   /* delivered — functional */
  --green-tint: #e7f4ec;

  /* Neutral text ramp */
  --ink:        #1a1c1d;
  --ink-2:      #55595b;
  --ink-3:      #8a8f91;

  /* Surfaces */
  --bg:         #f4f5f5;   /* content canvas */
  --surface:    #ffffff;
  --surface-2:  #fafafb;

  /* System */
  --radius:     8px;
  --radius-sm:  6px;
  --shadow:     0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.05);
  --shadow-lg:  0 12px 34px rgba(0,0,0,.14);
  --rail:       64px;
  --topbar:     60px;

  --font: "Stolzl", "Archivo", "Inter", -apple-system, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== Simba lion emblem =====================================
   Real brand PNG (lion in red disc) CSS-cropped to just the
   circular emblem — the "Finely Crafted SIMBA" beer wordmark in
   the source file is framed out. .emblem fills its parent; set
   size on the parent. */
.emblem { display: block; width: 100%; height: 100%; position: relative; overflow: hidden; border-radius: 50%; }
.emblem img { position: absolute; width: 380%; max-width: none; height: auto; left: -20%; top: -48%; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* Headings — Stolzl Bold, uppercase, tight tracking */
.h-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3);
}
.h-title {
  font-weight: 800; letter-spacing: -.01em; text-transform: uppercase;
}
.num { font-variant-numeric: tabular-nums; }

/* ===== App shell ============================================ */
.app { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar); grid-column: 1 / -1;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px 0 20px;
  background: var(--charcoal); color: var(--white);
  border-bottom: 1px solid var(--black);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand__mark { width: 34px; height: 34px; flex: none; }
.brand__word {
  font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  font-size: 15px; line-height: 1;
}
.brand__word small {
  display: block; font-size: 9px; letter-spacing: .22em;
  color: var(--sand); font-weight: 600; margin-top: 2px;
}
.topnav { display: flex; gap: 4px; margin-left: 8px; }
.topnav a {
  position: relative; padding: 0 14px; height: var(--topbar);
  display: inline-flex; align-items: center;
  font-size: 12.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: #b9bdbe;
  transition: color .15s;
}
.topnav a:hover { color: var(--white); }
.topnav a.is-active { color: var(--white); }
.topnav a.is-active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 0;
  height: 3px; background: var(--red); border-radius: 3px 3px 0 0;
}
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.top-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--charcoal-2); border: 1px solid var(--charcoal-3);
  border-radius: 7px; padding: 7px 12px; width: 288px; color: #b9bdbe;
}
.top-search svg { width: 16px; height: 16px; flex: none; }
.top-search input {
  background: none; border: 0; color: var(--white); font-family: inherit;
  font-size: 13px; width: 100%; outline: none;
}
.top-search input::placeholder { color: #7d8183; }
.user {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 5px 6px 5px 5px; border-radius: 8px; transition: background .15s;
}
.user:hover { background: var(--charcoal-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--sand); color: var(--charcoal);
  display: grid; place-items: center; font-weight: 800; font-size: 12px;
}
.user__meta { line-height: 1.25; }
.user__meta b { font-size: 12.5px; font-weight: 700; }
.user__meta span { display: block; font-size: 10.5px; color: #8a8f91; }

/* Icon rail */
.rail {
  position: sticky; top: var(--topbar); align-self: start;
  height: calc(100vh - var(--topbar));
  background: var(--charcoal); border-right: 1px solid var(--black);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 4px;
}
.rail a {
  width: 44px; height: 44px; border-radius: 10px; position: relative;
  display: grid; place-items: center; color: #8a8f91; transition: .15s;
}
.rail a:hover { color: var(--white); background: var(--charcoal-2); }
.rail a.is-active { color: var(--white); }
.rail a.is-active::before {
  content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px;
  width: 3px; border-radius: 3px; background: var(--red);
}
.rail a svg { width: 21px; height: 21px; }
.rail__tip {
  position: absolute; left: 54px; white-space: nowrap;
  background: var(--black); color: var(--white); font-size: 11px;
  padding: 5px 9px; border-radius: 6px; opacity: 0; pointer-events: none;
  transform: translateX(-4px); transition: .12s; z-index: 60; font-weight: 600;
  letter-spacing: .03em;
}
.rail a:hover .rail__tip { opacity: 1; transform: translateX(0); }
.rail__sep { flex: 1; }

/* Main */
.main { padding: 24px 28px 40px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-head h1 { font-size: 23px; font-weight: 800; text-transform: uppercase; letter-spacing: -.01em; }
.page-head p { color: var(--ink-2); font-size: 13px; margin-top: 3px; }

/* ===== Buttons ============================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--radius);
  font-weight: 700; font-size: 13px; letter-spacing: .03em;
  border: 1px solid transparent; background: var(--white); color: var(--ink);
  border-color: var(--gray); transition: .13s;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { border-color: #cfcfcf; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--red); color: var(--white); border-color: var(--red); }
.btn--primary:hover { background: var(--red-press); border-color: var(--red-press); }
.btn--dark { background: var(--charcoal); color: var(--white); border-color: var(--charcoal); }
.btn--dark:hover { background: #34383a; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: #ededed; color: var(--ink); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn--block { width: 100%; }
.btn--lg { height: 48px; padding: 0 26px; font-size: 14px; }

/* ===== Cards ================================================ */
.card {
  background: var(--surface); border: 1px solid var(--gray);
  border-radius: 5px; box-shadow: none;   /* flat instrument, not a floating SaaS card */
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--gray);
}
.card__head h2 { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.card__body { padding: 18px; }

/* ===== KPI strip — one connected instrument panel, not floating tiles ===
   De-slopped: no pastel icon chips, no drop shadows, no gaps. Four metrics
   share one hairline-bordered strip divided by rules, each led by a thin
   top status-accent. Reads like a dispatch console readout. */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  border: 1px solid var(--gray); border-radius: 5px; overflow: hidden;
  background: var(--surface); margin-bottom: 22px; }
.kpi {
  background: transparent; border: 0; border-left: 1px solid var(--gray);
  border-radius: 0; box-shadow: none; padding: 16px 20px 18px;
  position: relative; transition: background .12s;
}
.kpi:first-child { border-left: 0; }
.kpi:hover { background: #fbfbfb; }
.kpi::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ink-3); }
.kpi__ico { display: none; }   /* removed the AI-tile icon chip */
.kpi__label { font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.kpi__val { font-size: 38px; font-weight: 800; line-height: 1; margin-top: 12px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi__val small { font-size: 13px; font-weight: 600; color: var(--ink-3); letter-spacing: 0; }
.kpi__foot { font-size: 11.5px; color: var(--ink-2); margin-top: 9px; display: flex; align-items: center; gap: 5px; }
.kpi--road::before  { background: var(--red); }
.kpi--road .kpi__val { color: var(--red); }
.kpi--idle::before  { background: var(--sand); }
.kpi--done::before  { background: var(--green); }
.kpi--alert::before { background: var(--red); }
.delta-up { color: var(--green); font-weight: 700; }
.delta-flat { color: var(--ink-3); font-weight: 700; }

/* ===== Chips =============================================== */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px 4px 8px; border-radius: 999px; white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
/* In-transit chip stays calm (charcoal on neutral) so a whole column of
   them doesn't flood; the pulsing RED dot is the single movement signal. */
.chip--transit { background: #eceeef; color: var(--ink); border: 1px solid #e0e2e3; }
.chip--transit .dot { background: var(--red); animation: pulse 1.6s infinite; }
.chip--idle { background: var(--sand-tint); color: #916a35; }
.chip--idle .dot { background: var(--sand); }
.chip--done { background: var(--green-tint); color: #1f7a44; }
.chip--done .dot { background: var(--green); }
.chip--alert { background: var(--red); color: #fff; }
.chip--alert .dot { background: #fff; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(238,32,46,.5); } 70% { box-shadow: 0 0 0 5px rgba(238,32,46,0); } }

/* Doc badges */
.badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 5px;
}
.badge--danger { background: var(--red-tint); color: var(--red-press); }
.badge--warn { background: var(--sand-tint); color: #916a35; }
.badge--ok { background: var(--green-tint); color: #1f7a44; }

/* ===== Tables ============================================== */
.table-wrap { overflow: auto; border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 5; background: var(--charcoal);
  text-align: left; font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: #a7abac;
  padding: 11px 16px; border-bottom: 1px solid #000; white-space: nowrap;
}
table.grid tbody td { padding: 10px 16px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
table.grid tbody tr { transition: background .1s, box-shadow .1s; }
table.grid tbody tr:focus-within { background: #f7f7f8; box-shadow: inset 3px 0 0 var(--red); }
table.grid tbody tr:hover { background: #fafafa; }
table.grid tbody tr:last-child td { border-bottom: 0; }
/* Reg plates in monospace — they're the operator's primary identifier;
   telemetry-grade type is the detail that reads as a real dispatch console. */
.cell-veh { font-family: var(--mono); font-weight: 700; font-size: 12.5px; letter-spacing: 0; }
.cell-veh small { display: block; font-family: var(--font); font-weight: 500; color: var(--ink-3); font-size: 11px; letter-spacing: 0; margin-top: 1px; }
.cell-sub { color: var(--ink-3); font-size: 12px; }
.t-right { text-align: right; }

/* Mini person */
.person { display: flex; align-items: center; gap: 9px; }
.person .avatar { width: 28px; height: 28px; font-size: 10px; }
.person b { font-weight: 600; }

/* ===== Modal / dialog ====================================== */
.modal-scrim {
  position: fixed; inset: 0; z-index: 200; display: none;
  background: rgba(20,22,23,.55); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-scrim.open { display: flex; animation: scrimIn .15s ease; }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 440px; background: var(--surface);
  border: 1px solid var(--gray); border-radius: 8px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: modalIn .18s var(--ease-standard, ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: flex-start; gap: 13px; padding: 20px 20px 0; }
.modal__ico { width: 40px; height: 40px; flex: none; border-radius: 8px; display: grid; place-items: center; background: var(--red-tint); color: var(--red); }
.modal__ico svg { width: 21px; height: 21px; }
.modal__head h3 { font-size: 16px; font-weight: 800; text-transform: uppercase; letter-spacing: .01em; }
.modal__head p { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.modal__meta { margin: 16px 20px 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--gray); border-radius: 6px; font-size: 12.5px; }
.modal__meta .row-kv { display: flex; justify-content: space-between; padding: 3px 0; }
.modal__meta .row-kv span { color: var(--ink-3); } .modal__meta .row-kv b { font-family: var(--mono); }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 20px 20px; }

/* ===== System error / feed banner ========================== */
.banner {
  display: flex; align-items: center; gap: 13px;
  border: 1px solid var(--gray); border-radius: 5px;
  padding: 12px 14px; margin-bottom: 16px; background: var(--surface);
}
.banner__ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 5px; }
.banner__ico svg { width: 19px; height: 19px; }
.banner__body { flex: 1; min-width: 0; }
.banner__body b { display: block; font-size: 13px; font-weight: 800; letter-spacing: .01em; }
.banner__body span { font-size: 12px; color: var(--ink-2); }
.banner__body span .num { font-family: var(--mono); }
.banner__act { display: flex; align-items: center; gap: 8px; }
.banner__x { width: 30px; height: 30px; border: 0; background: transparent; color: var(--ink-3); border-radius: 5px; font-size: 16px; }
.banner__x:hover { background: #ededed; color: var(--ink); }
/* error severity — red is the alert signal (no flood: just the rail + icon) */
.banner--error { border-left: 3px solid var(--red); }
.banner--error .banner__ico { background: var(--red-tint); color: var(--red); }
.banner--warn { border-left: 3px solid var(--sand); }
.banner--warn .banner__ico { background: var(--sand-tint); color: #a9834f; }

/* ===== Loading skeleton ==================================== */
.sk { background: linear-gradient(90deg,#eee 25%,#f5f5f5 37%,#eee 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 5px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ===== Empty state ========================================= */
.empty { text-align: center; padding: 54px 20px; position: relative; }
.empty__lion { width: 96px; height: 96px; margin: 0 auto 14px; opacity: .18; }
.empty h3 { font-size: 17px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.empty p { color: var(--ink-2); margin: 6px 0 18px; }

/* Lion watermark helper */
.watermark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: .05; }
.watermark .emblem { width: 320px; height: 320px; }

/* Utility */
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.muted { color: var(--ink-2); }
.pill-count { background: var(--charcoal); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }

/* ===== Mobile bottom tab bar (injected by shell.js) ========= */
.botnav { display: none; }
@media (max-width: 760px) {
  .botnav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    background: var(--charcoal); border-top: 1px solid #000;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .botnav a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; color: #8a8f91; font-size: 10px; font-weight: 700;
    letter-spacing: .02em; text-transform: uppercase; position: relative;
  }
  .botnav a svg { width: 22px; height: 22px; }
  .botnav a.is-active { color: #fff; }
  .botnav a.is-active::before { content:""; position:absolute; top:0; left:26%; right:26%; height:2px; background:var(--red); border-radius:2px; }
}

/* ===== Tablet ( ≤1024px ) ================================== */
@media (max-width: 1024px) {
  .topnav { display: none; }
  .top-search { width: 170px; }
  .main { padding: 18px 18px 40px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi { border-left: 1px solid var(--gray); }
  .kpi:nth-child(-n+2) { border-top: 0; }        /* divider tidy on 2-col */
  .kpi:nth-child(odd) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--gray); }
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  /* keep dense tables usable: horizontal scroll rather than crushing */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.grid { min-width: 720px; }
}

/* ===== Mobile ( ≤760px ) ================================== */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .main { padding: 16px 14px 84px; }             /* room for bottom nav */
  .topbar { gap: 12px; padding: 0 14px; }
  .top-search { display: none; }                  /* search moves to page controls */
  .user__meta { display: none; }                  /* avatar only */
  .brand__word small { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi__val { font-size: 30px; }
  .page-head h1 { font-size: 20px; }
  .btn { height: 42px; }                           /* 44px-ish touch targets */
  .btn--sm { height: 36px; }
  .modal { max-width: 100%; }
  .banner { flex-wrap: wrap; }
  .banner__act { width: 100%; justify-content: flex-end; }
}
@media (max-width: 400px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi { border-left: 0 !important; border-top: 1px solid var(--gray); }
  .kpi:first-child { border-top: 0; }
}
