/* ============================================================
   HK Logistics OS — design system v2 (light, committed)
   Tokens first; every component styles through them.
   ============================================================ */
:root {
  /* ground + surfaces */
  --bg: #edf1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eef2f7;
  /* ink */
  --ink: #101c2b;
  --ink-2: #42546b;
  --muted: #6e7f95;
  --line: #e3e9f0;
  --line-2: #c9d4e0;
  /* brand */
  --navy-900: #0b1e37;
  --navy-800: #102a4d;
  --brand: #1a4d8f;
  --brand-600: #143e75;
  --brand-050: #e9f0f9;
  --accent: #2fb2e8;          /* cyan — live / highlight only */
  --accent-ink: #0f6d96;
  --ai: #6250d6;              /* violet — AI features only */
  --ai-bg: #edebfb;
  /* semantic */
  --ok: #158741;   --ok-bg: #e3f3e9;   --ok-text: #0e6330;
  --warn: #b97a05; --warn-bg: #fdf3da; --warn-text: #7d5303;
  --serious: #c65a1e; --serious-bg: #fcece1; --serious-text: #96430f;
  --crit: #c22f2f; --crit-bg: #fae5e5; --crit-text: #9b2222;
  --info: #1c66c9; --info-bg: #e6effb; --info-text: #16509d;
  --progress: #b35a11; --progress-bg: #fdf0e3;
  /* data-viz series (validated) */
  --series-1: #2a78d6; --series-2: #eb6834;
  --teal: #0e9d84; --teal-bg: #e2f5f1;
  --violet: #5b4bc4; --violet-bg: #ecebfa;
  --amber: #c97e06; --amber-bg: #fdf1dd;
  --rose: #c2417c;  --rose-bg: #fbe9f2;
  --blue-bg: #e7f0fb;
  --seq-200: #9ec5f4; --seq-300: #6da7ec; --seq-450: #2a78d6; --seq-600: #184f95;
  /* shape + depth */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(13, 28, 50, .05), 0 3px 10px rgba(13, 28, 50, .05);
  --shadow-lg: 0 10px 36px rgba(10, 24, 46, .20);
  --sidebar-w: 232px;
  --topbar-h: 54px;
  /* type */
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono, .ref { font-family: var(--mono); font-size: .92em; font-weight: 600; letter-spacing: -.02em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------------- layout shell */
#app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--navy-900) 0%, #091a30 100%);
  color: #cfe0f4;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 12px;
  color: #fff; font-weight: 700; font-size: 17px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.side-brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent);
  color: #143054; font-size: 15px; font-weight: 700;
  display: grid; place-items: center;
}
.side-brand small { display: block; font-weight: 500; font-size: 10px; color: #7f9abd; letter-spacing: 1.6px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 10px; scrollbar-width: thin; }
.nav-section {
  margin: 15px 8px 5px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.6px;
  color: #7690b5; display: flex; align-items: center; gap: 7px; font-weight: 600;
}
.nav-section::before { content: ""; width: 7px; height: 7px; border-radius: 2.5px; background: var(--sec-c, #2a78d6); }
.nav-section[data-sec="Operations"] { --sec-c: #4d9fff; }
.nav-section[data-sec="Fleet & People"] { --sec-c: #23c9a7; }
.nav-section[data-sec="Commercial"] { --sec-c: #ffb648; }
.nav-section[data-sec="Intelligence"] { --sec-c: #a78bfa; }
.nav-section[data-sec="Resources"] { --sec-c: #23c9a7; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7.5px 10px; margin: 1px 0;
  border-radius: 8px; color: #bfd2e9; font-size: 13.5px; font-weight: 500;
  text-decoration: none; position: relative;
}
.nav a svg { width: 17px; height: 17px; opacity: .78; flex: none; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav a.active {
  background: linear-gradient(90deg, rgba(47,178,232,.16), rgba(47,178,232,.05));
  color: #fff; font-weight: 600;
}
.nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav a.active svg { opacity: 1; color: var(--accent); }
.nav a .count {
  margin-left: auto; background: rgba(255,255,255,.13); border-radius: 9px;
  font-size: 10.5px; padding: 1px 7px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.nav a.active .count { background: var(--accent); color: #0b2438; }
.side-foot { padding: 11px 16px; font-size: 10.5px; color: #62799b; border-top: 1px solid rgba(255,255,255,.07); line-height: 1.5; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 40;
}
.searchbox { position: relative; flex: 1; max-width: 440px; }
.searchbox input {
  width: 100%; padding: 7px 12px 7px 32px;
  border: 1px solid var(--line); border-radius: 9px;
  font-size: 13px; background: var(--surface-2);
  transition: background .12s ease, border-color .12s ease;
}
.searchbox input:focus { background: var(--surface); border-color: var(--line-2); }
.searchbox svg { position: absolute; left: 10px; top: 8px; width: 15px; height: 15px; color: var(--muted); }
.search-results {
  position: absolute; top: 40px; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); z-index: 90; max-height: 420px; overflow: auto;
}
.search-results .sr-item { padding: 9px 14px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.search-results .sr-item:hover { background: var(--surface-2); }
.search-results .sr-type { font-size: 9.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); width: 52px; letter-spacing: .5px; }
.topbar .spacer { flex: 1; }
.iconbtn {
  position: relative; border: none; background: none; cursor: pointer;
  width: 34px; height: 34px; border-radius: 9px; color: var(--ink-2);
  display: grid; place-items: center;
}
.iconbtn:hover { background: var(--surface-3); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn .dot {
  position: absolute; top: 4px; right: 4px; min-width: 15px; height: 15px;
  background: var(--crit); color: #fff; font-size: 9.5px; font-weight: 700;
  border-radius: 8px; display: grid; place-items: center; padding: 0 3px;
}
.user-chip { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 8px; border-radius: 9px; }
.user-chip:hover { background: var(--surface-3); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 600;
  display: grid; place-items: center; flex: none;
}
.avatar.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }
.avatar.hue-0 { background: #1c4e89; } .avatar.hue-1 { background: #0e9d84; }
.avatar.hue-2 { background: #5b4bc4; } .avatar.hue-3 { background: #c97e06; }
.avatar.hue-4 { background: #c2417c; } .avatar.hue-5 { background: #2a78d6; }
.avatar.hue-6 { background: #b3541e; } .avatar.hue-7 { background: #3f7d20; }
.user-chip .uc-name { font-size: 13px; font-weight: 600; line-height: 1.15; }
.user-chip .uc-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }

.content { padding: 20px 22px 60px; max-width: 1560px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 12.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .card-head {
  padding: 11px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 13.5px;
}
.card .card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card .card-body { padding: 16px; }
.card.pad { padding: 16px; }
.card.acc-blue .card-head { box-shadow: inset 0 2px 0 var(--series-1); }
.card.acc-teal .card-head { box-shadow: inset 0 2px 0 var(--teal); }
.card.acc-violet .card-head { box-shadow: inset 0 2px 0 var(--violet); }
.card.acc-amber .card-head { box-shadow: inset 0 2px 0 var(--amber); }
.card.acc-rose .card-head { box-shadow: inset 0 2px 0 var(--rose); }

.grid { display: grid; gap: 13px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: 1fr 1fr; } .grid.cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------------- KPI / stat cards */
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow); cursor: pointer; position: relative;
  transition: transform .07s ease, box-shadow .07s ease;
}
.stat:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(13,28,50,.08), 0 6px 20px rgba(13,28,50,.07); }
.stat .s-label { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .3px; text-transform: uppercase; }
.stat .s-value { font-size: 25px; font-weight: 700; margin-top: 3px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .s-note { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.stat .s-delta { font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; margin-left: 7px; vertical-align: 3px; }
.stat .s-delta.up { color: var(--ok-text); } .stat .s-delta.down { color: var(--crit-text); }
.stat .s-delta.up.bad { color: var(--crit-text); } .stat .s-delta.down.good { color: var(--ok-text); }
.stat .s-spark { position: absolute; right: 12px; bottom: 10px; opacity: .9; }
.stat.tint-blue { background: linear-gradient(135deg, var(--blue-bg), var(--surface) 60%); }
.stat.tint-teal { background: linear-gradient(135deg, var(--teal-bg), var(--surface) 60%); }
.stat.tint-amber { background: linear-gradient(135deg, var(--amber-bg), var(--surface) 60%); }
.stat.tint-violet { background: linear-gradient(135deg, var(--violet-bg), var(--surface) 60%); }
.stat.tint-rose { background: linear-gradient(135deg, var(--rose-bg), var(--surface) 60%); }
.stat.alert-crit { box-shadow: inset 3px 0 0 var(--crit), var(--shadow); }
.stat.alert-warn { box-shadow: inset 3px 0 0 var(--warn), var(--shadow); }
.stat.good { box-shadow: inset 3px 0 0 var(--ok), var(--shadow); }

/* ---------------- tables v2 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); font-weight: 600; padding: 8px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable:hover { color: var(--ink-2); }
table.tbl th .sort-ind { font-size: 9px; margin-left: 3px; }
table.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { cursor: pointer; }
table.tbl tbody tr:hover { background: #f3f7fc; }
table.tbl tr.no-link { cursor: default; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl.dense td { padding: 5.5px 12px; }
table.tbl.dense { font-size: 12.5px; }
.tbl-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
.tbl-foot {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.tbl-foot .pages { margin-left: auto; display: flex; gap: 4px; }
.money { font-variant-numeric: tabular-nums; }
.money.neg { color: var(--crit); }
.cell-main { font-weight: 600; font-size: 13px; line-height: 1.25; }
.cell-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.cell-pair { display: flex; align-items: center; gap: 9px; min-width: 0; }
.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .1s ease; justify-content: flex-end; }
tr:hover .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

/* ---------------- badges & chips */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 2.5px 9px; border-radius: 20px;
  white-space: nowrap; line-height: 1.5;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.neutral { background: #ecf0f4; color: #5b6b7c; }
.badge.info { background: var(--info-bg); color: var(--info-text); }
.badge.progress { background: var(--progress-bg); color: var(--progress); }
.badge.good { background: var(--ok-bg); color: var(--ok-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.serious { background: var(--serious-bg); color: var(--serious-text); }
.badge.crit { background: var(--crit-bg); color: var(--crit-text); }
.badge.brand { background: var(--brand-050); color: var(--brand-600); }
.badge.ai { background: var(--ai-bg); color: var(--ai); }
.badge.plain::before { display: none; }
.badge.live::before { animation: pulse 1.6s ease infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.chip { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.plate {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .3px;
  background: #fbd649; color: #1c1c1c; border: 1px solid #d9b93a; border-radius: 5px;
  padding: 1.5px 7px; display: inline-block; white-space: nowrap;
}

/* ---------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; text-decoration: none; line-height: 1.3;
  transition: background .1s ease, border-color .1s ease;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(20,62,117,.3); }
.btn.primary:hover { background: var(--brand-600); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #0b2438; }
.btn.ai { background: var(--ai-bg); border-color: #d5cff5; color: var(--ai); }
.btn.ai:hover { background: #e4e0f9; }
.btn.danger { background: #fff; border-color: #eec7c7; color: var(--crit); }
.btn.danger:hover { background: #fdf4f4; }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px; padding: 2.5px; gap: 2px; }
.seg button {
  border: none; background: none; font-family: inherit; cursor: pointer;
  padding: 5px 13px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  border-radius: 7.5px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(13,28,50,.12); }
.seg button svg { width: 14px; height: 14px; }

/* toolbar (filters row) */
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 13px;
}
.toolbar input[type="search"], .toolbar input[type="text"] { width: 220px; }
.toolbar select { width: auto; }
.toolbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------------- forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 11px; color: var(--muted); }
input, select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 10px;
  background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b7d4ee; border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  border: none; background: none; font-family: inherit;
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs button .count { background: #ecf0f4; border-radius: 9px; padding: 1px 7px; font-size: 11px; margin-left: 5px; font-variant-numeric: tabular-nums; }
.tabs button.active .count { background: var(--brand-050); color: var(--brand-600); }

.pillbar { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 20px;
  padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-2);
  font-family: inherit;
}
.pill.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* legacy tabbar (pill link row) */
.tabbar { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabbar .tab { padding: 7px 15px; border-radius: 9px; font-size: 13px; font-weight: 600;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
.tabbar .tab:hover { border-color: var(--line-2); text-decoration: none; }
.tabbar .tab.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }

/* ---------------- hero header (360° profiles) */
.hero {
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); margin-bottom: 14px;
}
.hero .hero-band {
  background: linear-gradient(100deg, var(--navy-900), #14355e 55%, #1a4d8f);
  padding: 16px 20px 14px; color: #fff;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
}
.hero .hero-band .avatar.lg { box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.hero .h-id { min-width: 0; }
.hero .h-name { font-size: 19px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero .h-sub { font-size: 12.5px; color: #a9c1de; margin-top: 2px; display: flex; gap: 12px; flex-wrap: wrap; }
.hero .h-sub a { color: #cfe4f8; }
.hero .h-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.hero .hero-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  border-top: 1px solid var(--line); background: var(--surface);
}
.hero .hs {
  padding: 10px 16px; border-right: 1px solid var(--line); cursor: default;
}
.hero .hs:last-child { border-right: none; }
.hero .hs.click { cursor: pointer; } .hero .hs.click:hover { background: var(--surface-2); }
.hero .hs .hs-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.hero .hs .hs-value { font-size: 16.5px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 7px; }
.hero .hs .hs-value .badge { font-size: 10.5px; }
.hero .hs .hs-note { font-size: 10.5px; color: var(--muted); }

/* profile sub-navigation rail */
.subnav {
  display: flex; gap: 2px; margin-bottom: 15px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px;
  scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav button {
  border: none; background: none; font-family: inherit; cursor: pointer;
  padding: 7px 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  border-radius: 8px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.subnav button:hover { color: var(--ink); background: var(--surface-2); }
.subnav button.active { background: var(--navy-800); color: #fff; }
.subnav button .count { font-size: 10.5px; background: #ecf0f4; padding: 0 6px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.subnav button.active .count { background: rgba(255,255,255,.2); color: #fff; }

/* ---------------- drawer (right side panel) */
.drawer-overlay { position: fixed; inset: 0; background: rgba(12, 25, 44, .35); z-index: 100; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 94vw); z-index: 101;
  background: var(--surface); box-shadow: -12px 0 40px rgba(10,24,46,.25);
  display: flex; flex-direction: column; animation: drawerin .18s ease;
}
.drawer.wide { width: min(680px, 96vw); }
@keyframes drawerin { from { transform: translateX(30px); opacity: .4; } }
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-head h3 { font-size: 15px; }
.drawer-head .x { margin-left: auto; }
.drawer-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------- modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(12, 25, 44, .5); z-index: 100;
  display: grid; place-items: center; padding: 24px;
}
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column;
  animation: modalin .16s ease;
}
@keyframes modalin { from { transform: translateY(8px) scale(.985); opacity: .5; } }
.modal.wide { max-width: 900px; }
.modal-head { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------- toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--navy-900); color: #fff; border-radius: 11px; padding: 11px 16px;
  font-size: 13px; box-shadow: var(--shadow-lg); max-width: 380px;
  display: flex; gap: 9px; align-items: center; animation: slidein .18s ease;
}
.toast.err { background: #7c1f1f; }
.toast.ok { background: #14532d; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

/* ---------------- timeline */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 13px; font-size: 12.5px; }
.tl-item::before {
  content: ""; position: absolute; left: -19px; top: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--line-2); border: 2px solid var(--surface);
}
.tl-item.hl::before { background: var(--brand); }
.tl-item .tl-when { color: var(--muted); font-size: 11px; }
.tl-item .tl-what { font-weight: 600; }
.tl-item .tl-note { color: var(--ink-2); margin-top: 1px; }

/* job lifecycle progress */
.jprogress { display: flex; align-items: center; gap: 4px; }
.jprogress .bar { height: 6px; border-radius: 3px; background: var(--line); flex: 1; overflow: hidden; }
.jprogress .bar i { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }
.jprogress .pct { font-size: 11px; color: var(--muted); font-weight: 700; width: 34px; text-align: right; }

/* ---------------- alerts + event feed */
.alert-row { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.alert-row:last-child { border-bottom: none; }
.alert-row .sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; }
.alert-row .sev.critical { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-bg); }
.alert-row .sev.warning { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.alert-row .sev.info { background: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }
.alert-row .a-title { font-size: 13px; font-weight: 600; }
.alert-row .a-detail { font-size: 12px; color: var(--ink-2); }
.alert-row .a-when { font-size: 11px; color: var(--muted); }
.alert-row .actions { margin-left: auto; display: flex; gap: 6px; flex: none; }

.feed-item { display: flex; gap: 11px; padding: 9px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.feed-item:last-child { border-bottom: none; }
.feed-item .f-ico {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-size: 13px;
  background: var(--tone-bg, var(--surface-3)); color: var(--tone-c, var(--ink-2));
}
.feed-item .f-ico svg { width: 15px; height: 15px; }
.feed-item .f-title { font-size: 12.5px; font-weight: 600; }
.feed-item .f-sub { font-size: 11.5px; color: var(--ink-2); }
.feed-item .f-when { font-size: 10.5px; color: var(--muted); margin-left: auto; flex: none; padding-top: 2px; }

/* ---------------- empty / loading / skeleton */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13.5px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.empty .btn { margin-top: 12px; }

.spinner {
  width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-3) 25%, #f7f9fc 40%, var(--surface-3) 55%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { to { background-position: -140% 0; } }
.skel-row { height: 15px; margin: 13px 14px; }
.skel-stat { height: 78px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }

.route-line { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.route-line .arrow { color: var(--muted); }

/* ---------------- charts */
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--navy-900); color: #fff;
  font-size: 11.5px; padding: 6px 9px; border-radius: 7px; box-shadow: var(--shadow-lg);
  transform: translate(-50%, -110%); white-space: nowrap; z-index: 30; display: none;
}
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--ink-2); flex-wrap: wrap; }
.legend .li { display: flex; gap: 5px; align-items: center; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }

/* score ring */
.ring-wrap { display: flex; align-items: center; gap: 12px; }
.ring-wrap .ring-info .ri-big { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.ring-wrap .ring-info .ri-sub { font-size: 11.5px; color: var(--muted); }

/* ---------------- pipeline board (jobs kanban) */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.board-col { min-width: 252px; width: 252px; flex: none; background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--radius); }
.board-col .bc-head {
  padding: 9px 12px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--ink-2); display: flex; align-items: center; gap: 7px; position: sticky; top: 0;
}
.board-col .bc-head::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--col-c, var(--muted)); }
.board-col .bc-head .count { margin-left: auto; background: var(--surface); border-radius: 8px; padding: 0 7px; font-size: 10.5px; }
.board-col .bc-body { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 7px; max-height: 62vh; overflow-y: auto; }
.board-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; cursor: pointer; box-shadow: 0 1px 2px rgba(13,28,50,.05);
}
.board-card:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.board-card .b-ref { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--brand); }
.board-card .b-route { font-size: 12px; font-weight: 600; margin: 3px 0 2px; }
.board-card .b-meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }

/* job card grid view */
.jcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.jcard { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow); }
.jcard:hover { border-color: var(--line-2); transform: translateY(-1px); }
.jcard .j-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

/* ---------------- stepper (AI import etc.) */
.stepper { display: flex; gap: 0; margin-bottom: 18px; overflow-x: auto; }
.step { display: flex; align-items: center; gap: 8px; padding: 0 14px 0 0; flex: none; }
.step .s-dot {
  width: 24px; height: 24px; border-radius: 50%; font-size: 11.5px; font-weight: 700;
  display: grid; place-items: center; background: var(--surface-3); color: var(--muted);
  border: 1.5px solid var(--line-2);
}
.step.done .s-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.active .s-dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.step .s-lbl { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.step.active .s-lbl { color: var(--ink); }
.step.done .s-lbl { color: var(--ink-2); }
.step::after { content: ""; width: 26px; height: 2px; background: var(--line-2); border-radius: 1px; margin-left: 6px; }
.step:last-child::after { display: none; }
.step.done::after { background: var(--ok); }

/* ---------------- maps */
.tower-map { background: #0f2440; border-radius: var(--radius); position: relative; overflow: hidden; }
.tower-map svg text { font-family: inherit; }

/* ---------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1000px 500px at 80% -10%, #1c4e89 0%, transparent 60%), var(--navy-900); }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 34px 34px 28px; width: 380px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 19px; color: #143054; }
.login-brand h1 { font-size: 20px; }
.login-brand small { color: var(--muted); font-size: 12px; }

/* ---------------- notifications panel */
.notif-panel {
  position: fixed; top: var(--topbar-h); right: 12px; width: 400px; max-height: 70vh;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  box-shadow: var(--shadow-lg); z-index: 95; overflow: hidden; display: flex; flex-direction: column;
}
.notif-panel .np-head { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.notif-panel .np-list { overflow-y: auto; }
.notif-item { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.notif-item.unread { background: #f2f7fd; box-shadow: inset 2.5px 0 0 var(--accent); }
.notif-item .n-title { font-weight: 600; }
.notif-item .n-when { font-size: 11px; color: var(--muted); }

.issue { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; display: inline-block; margin: 1px 2px 1px 0; }
.issue.error { background: var(--crit-bg); color: var(--crit-text); }
.issue.warning { background: var(--warn-bg); color: var(--warn-text); }

.conf { font-size: 11px; font-weight: 700; }
.conf.high { color: var(--ok-text); }
.conf.mid { color: var(--warn-text); }
.conf.low { color: var(--crit); }

/* ---------------- reputation / verification (v2) */
.stars { display: inline-flex; gap: 2px; font-size: 15px; letter-spacing: 1px; color: var(--amber); }
.stars .off { color: var(--line-2); }
.rating-hero { display: flex; align-items: baseline; gap: 10px; }
.rating-hero .num { font-size: 34px; font-weight: 700; letter-spacing: -.03em; }
.rating-hero .sub { font-size: 12px; color: var(--muted); font-weight: 600; }
.qbar { display: flex; align-items: center; gap: 10px; margin: 7px 0; font-size: 12.5px; }
.qbar .lbl { width: 130px; color: var(--ink-2); font-weight: 600; }
.qbar .track { flex: 1; height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; }
.qbar .fill { height: 100%; border-radius: 4px; background: var(--series-1); }
.qbar .val { width: 44px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.verify-banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 10px; font-weight: 600; font-size: 13.5px; }
.verify-banner.v-verified { background: var(--teal-bg); color: #0a6e5c; }
.verify-banner.v-unverified { background: #ecf0f4; color: #5b6b7c; }
.verify-banner.v-in_progress, .verify-banner.v-partially_verified { background: var(--amber-bg); color: #8a5a04; }
.verify-banner.v-expired, .verify-banner.v-rejected { background: var(--crit-bg); color: var(--crit-text); }
.verify-banner.v-suspended, .verify-banner.v-under_investigation { background: var(--violet-bg); color: #46389e; }
.verify-banner .big { font-size: 22px; }

.review-item { padding: 11px 16px; border-bottom: 1px solid var(--line); }
.review-item:last-child { border-bottom: none; }
.review-item .rmeta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.review-item .rcomment { font-size: 13px; margin-top: 4px; }
.review-item .rnote { font-size: 12px; margin-top: 4px; background: var(--violet-bg); color: #46389e; border-radius: 7px; padding: 5px 9px; }

.doc-thumb { width: 44px; height: 34px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; font-size: 16px; }
kbd.kbd { background: var(--surface-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font-size: 11px; font-family: inherit; color: var(--ink-2); }

/* ---------------- forms area (QR) */
.form-col { display: flex; flex-direction: column; gap: 10px; min-width: min(420px, 80vw); }
.form-col input, .form-col select { width: 100%; }

/* ---------------- Communication Centre */
.msg-layout { display: grid; grid-template-columns: 330px 1fr; gap: 13px; min-height: 60vh; }
.msg-list { min-width: 0; }
.msg-row { display: block; padding: 10px 12px; text-decoration: none; color: var(--ink); border-left: 2.5px solid transparent; }
.msg-row:hover { background: var(--surface-2); text-decoration: none; }
.msg-row.active { background: var(--brand-050); border-left-color: var(--brand); }
.msg-unread { background: var(--accent); color: #0b2438; border-radius: 9px; font-size: 10.5px;
  font-weight: 700; padding: 1px 7px; }
.msg-chat { display: flex; flex-direction: column; min-width: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.msg-chat-head { display: flex; gap: 6px; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--surface-2); }
.msg-feed { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column;
  gap: 9px; max-height: 52vh; background: #fafcfe; }
.msg-bubble { max-width: 78%; padding: 8px 13px; border-radius: 13px; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 1.5px rgba(13,28,50,.05); }
.msg-bubble.mine { align-self: flex-end; background: #e0f0fb; border-color: #c2e0f3; }
.msg-bubble.internal_note { background: #fdf6df; border-color: #efdfa8; }
.msg-bubble.system { background: var(--surface-3); font-size: 12.5px; color: var(--ink-2); box-shadow: none; }
.msg-bubble.quick_action { border-left: 4px solid var(--accent); }
.msg-assist { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 14px 0; }
.msg-compose { display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line);
  align-items: flex-end; }
.msg-compose textarea { flex: 1; resize: none; }
@media (max-width: 900px) {
  .msg-layout { grid-template-columns: 1fr; }
  .msg-layout.chat-open .msg-list { display: none; }
}

/* ---------------- Live Fleet */
.fleet-layout { display: grid; grid-template-columns: 1fr 330px; gap: 13px; }
.fleet-map { height: 62vh; min-height: 380px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2); z-index: 0; }
.fleet-side { overflow-y: auto; max-height: 62vh; display: flex; flex-direction: column; gap: 8px; }
.fleet-row { padding: 9px 12px; cursor: pointer; }
.fleet-tip { font-size: 10px; font-weight: 700; padding: 1px 5px; }
@media (max-width: 900px) {
  .fleet-layout { grid-template-columns: 1fr; }
  .fleet-map { height: 44vh; min-height: 280px; }
  .fleet-side { max-height: none; }
}

/* ---------------- command centre (tower) */
.tower-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 13px; }
.tower-main { min-width: 0; display: flex; flex-direction: column; gap: 13px; }
.tower-side { display: flex; flex-direction: column; gap: 13px; min-width: 0; }
@media (max-width: 1150px) { .tower-layout { grid-template-columns: 1fr; } }

/* ---------------- AI assistant workspace */
.ai-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 13px; }
@media (max-width: 1000px) { .ai-layout { grid-template-columns: 1fr; } }
.ai-msg { display: flex; gap: 10px; margin-bottom: 13px; }
.ai-msg .who {
  width: 28px; height: 28px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.ai-msg.user .who { background: var(--surface-3); color: var(--ink-2); }
.ai-msg.bot .who { background: var(--ai-bg); color: var(--ai); }
.ai-msg .bubble { font-size: 13.5px; line-height: 1.55; min-width: 0; }
.ai-suggest { display: inline-block; margin: 3px 6px 3px 0; padding: 6px 12px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line-2); font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); cursor: pointer; font-family: inherit; }
.ai-suggest:hover { border-color: var(--ai); color: var(--ai); }

/* ---------------- responsive: tablet & mobile */
.menu-btn { display: none; }
.nav-backdrop { display: none; }
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 130;
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.35); height: 100dvh;
  }
  body.nav-open .sidebar { transform: none; }
  .nav-backdrop {
    position: fixed; inset: 0; background: rgba(10, 20, 35, .45); z-index: 120;
  }
  body.nav-open .nav-backdrop { display: block; }
  .menu-btn {
    display: grid; place-items: center; width: 38px; height: 38px; flex: none;
    border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface);
    cursor: pointer; color: var(--ink-2);
  }
  .content { padding: 14px 12px 70px; }
  .page-head h1 { font-size: 18px; }
  .user-chip .uc-name, .user-chip .uc-role { display: none; }
  .searchbox { max-width: none; }
  .grid, .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr !important; }
  .grid.cols-1-sm, .grid.wide-cards { grid-template-columns: 1fr !important; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 120px 1fr; }
  .modal { max-width: none; }
  table.tbl { font-size: 12.5px; }
  table.tbl th, table.tbl td { padding: 8px 8px; }
  .stat .s-value { font-size: 21px; }
  .hero .hero-band { padding: 13px 14px; }
  .hero .h-actions { margin-left: 0; width: 100%; }
  .hero .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero .hs { border-bottom: 1px solid var(--line); }
  .toolbar input[type="search"], .toolbar input[type="text"] { width: 100%; }
  .drawer { width: 100vw; }
  th.hide-sm, td.hide-sm { display: none; }
}
@media (max-width: 560px) {
  .grid, .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr !important; }
}

/* mobile: allow a table to collapse into cards */
@media (max-width: 700px) {
  table.tbl.collapse, table.tbl.collapse tbody, table.tbl.collapse tr, table.tbl.collapse td { display: block; }
  table.tbl.collapse thead { display: none; }
  table.tbl.collapse tr {
    border: 1px solid var(--line); border-radius: 10px; margin: 8px 10px;
    background: var(--surface); padding: 6px 4px; box-shadow: 0 1px 2px rgba(13,28,50,.05);
  }
  table.tbl.collapse td { border: none; padding: 4px 10px; }
  table.tbl.collapse td.num { text-align: left; }
  table.tbl.collapse td[data-th]::before {
    content: attr(data-th); display: block; font-size: 9.5px; text-transform: uppercase;
    letter-spacing: .6px; color: var(--muted); font-weight: 700; margin-bottom: 1px;
  }
  table.tbl.collapse td:empty { display: none; }
}

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

@media print {
  .sidebar, .topbar { display: none; }
  #app { grid-template-columns: 1fr; }
}

/* ---- Email Centre */
.email-layout { display: grid; grid-template-columns: 215px 340px minmax(0, 1fr); gap: 13px; min-height: 68vh; }
.em-rail { display: flex; flex-direction: column; gap: 4px; }
.em-rail .rail-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; border: none;
  background: none; font-family: inherit; text-align: left; width: 100%;
}
.em-rail .rail-item:hover { background: var(--surface-3); }
.em-rail .rail-item.active { background: var(--navy-800); color: #fff; }
.em-rail .rail-item .count { margin-left: auto; font-size: 10.5px; font-weight: 700;
  background: var(--accent); color: #0b2438; border-radius: 9px; padding: 1px 7px; }
.em-rail .rail-sec { margin: 10px 4px 3px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--muted); }
.em-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; }
.em-list .em-search { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.em-rows { overflow-y: auto; flex: 1; }
.em-row { padding: 10px 13px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.em-row:hover { background: var(--surface-2); }
.em-row.active { background: var(--brand-050); box-shadow: inset 2.5px 0 0 var(--brand); }
.em-row.unread .em-from, .em-row.unread .em-subj { font-weight: 700; }
.em-row .em-top { display: flex; gap: 7px; align-items: center; }
.em-row .em-from { font-size: 12.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-row .em-when { font-size: 10.5px; color: var(--muted); flex: none; }
.em-row .em-subj { font-size: 12.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-row .em-snip { font-size: 11.5px; color: var(--muted); margin-top: 1px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.em-row .acc-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.em-star { cursor: pointer; color: var(--line-2); font-size: 14px; flex: none; border: none;
  background: none; padding: 0 2px; }
.em-star.on { color: var(--amber); }
.em-read { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.em-read-head { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.em-read-body { flex: 1; overflow-y: auto; min-height: 300px; }
.em-read-body iframe { width: 100%; border: none; min-height: 380px; background: #fff; }
.em-thread-item { padding: 7px 16px; border-bottom: 1px solid var(--line); font-size: 12px;
  cursor: pointer; display: flex; gap: 8px; color: var(--ink-2); }
.em-thread-item:hover { background: var(--surface-2); }
.em-thread-item.current { background: var(--brand-050); font-weight: 600; color: var(--ink); }
.em-attach { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; margin: 3px 6px 3px 0; color: var(--brand);
  text-decoration: none; }
.em-attach:hover { background: var(--surface-2); text-decoration: none; }
.em-compose-editor { min-height: 180px; border: 1px solid var(--line-2); border-radius: 9px;
  padding: 10px 12px; font-size: 13.5px; line-height: 1.55; overflow-y: auto; max-height: 40vh; background: var(--surface); }
.em-compose-editor:focus { outline: 2px solid #b7d4ee; }
.em-fmt { display: flex; gap: 2px; margin-bottom: 6px; }
.em-fmt button { border: 1px solid var(--line); background: var(--surface); border-radius: 7px;
  width: 30px; height: 28px; font-size: 12.5px; cursor: pointer; font-family: inherit; color: var(--ink-2); }
.em-fmt button:hover { background: var(--surface-2); }
@media (max-width: 1150px) {
  .email-layout { grid-template-columns: 190px minmax(0, 1fr); }
  .email-layout .em-read { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .email-layout { grid-template-columns: 1fr; }
}

/* ---- Driver approval queue (top of the Drivers list) ------------------- */
.approval-q { border: 1px solid #f0d9a8; border-radius: 12px; background: var(--amber-bg);
  margin-bottom: 16px; overflow: hidden; }
.approval-q > .aq-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; font-weight: 700; font-size: 13.5px; color: #8a5a04;
  border-bottom: 1px solid #f0d9a8; }
.approval-q .aq-head .aq-why { font-weight: 500; font-size: 12.5px; opacity: .85; }
.approval-q .aq-row { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap;
  padding: 13px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.approval-q .aq-row:last-child { border-bottom: 0; }
.approval-q .aq-who { min-width: 190px; }
.approval-q .aq-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.approval-q .aq-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.approval-q .aq-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px 20px; flex: 1 1 340px; }
.approval-q .aq-fact { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.approval-q .aq-fact b { display: block; font-size: 10.5px; letter-spacing: .5px;
  text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 1px; }
.approval-q .aq-fact a { color: var(--brand); text-decoration: underline; }
.approval-q .aq-flag { color: var(--crit-text); font-weight: 600; }
.approval-q .aq-okflag { color: #0a6e5c; font-weight: 600; }
.approval-q .aq-act { display: inline-flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }


/* Flex/grid children must be allowed to shrink below their content width, or a
   two-column card forces the whole page to scroll sideways on a phone. This was
   the one route in the app that did it (#/clients/<id> at 390px). */
.grid > *, .form-grid > *, .cols-2 > *, .cols-3 > * { min-width: 0; }
.grid, .form-grid { min-width: 0; }
