/* Excel Executive Appeals */
:root {
  --ink: #0E1A2B;
  --ink-2: #1A2940;
  --paper: #F3F5F8;
  --surface: #FFFFFF;
  --line: #DEE3EA;
  --line-strong: #C9D1DC;
  --text: #16202E;
  --muted: #5B6677;
  --blue: #1D5DB5;
  --blue-dark: #154A93;
  --sky: #3E9BE0;
  --blue-wash: #EAF2FC;
  --green: #1D7A4C;
  --green-wash: #E6F4EC;
  --amber: #B8710A;
  --amber-wash: #FDF3E1;
  --red: #B3261E;
  --red-wash: #FBEAE9;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow-panel: 0 18px 50px rgba(14, 26, 43, .18), 0 2px 6px rgba(14, 26, 43, .08);
  --font: "Schibsted Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--paper); border-color: #AEB8C6; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(29, 93, 181, .08); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: 12.5px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface);
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.55; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 93, 181, .15); }
.row { display: grid; gap: 14px; align-items: start; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; accent-color: var(--blue); width: 16px; height: 16px; }

/* ---------- Login ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 5fr) 7fr;
}
.auth-side {
  background: var(--ink); color: #fff; padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-side::after {
  /* the logo's X, drawn as two sweeping blades */
  content: ""; position: absolute; right: -120px; bottom: -80px; width: 460px; height: 460px;
  background:
    linear-gradient(135deg, transparent 47%, var(--sky) 47.5%, var(--blue) 52%, transparent 52.5%),
    linear-gradient(45deg, transparent 48%, rgba(255,255,255,.14) 48.5%, rgba(255,255,255,.14) 51.5%, transparent 52%);
  opacity: .9; pointer-events: none;
}
.logo-plate {
  background: #fff; border-radius: var(--radius-s); padding: 10px 14px;
  display: inline-flex; align-items: center; width: fit-content;
}
.logo-plate img { height: 44px; display: block; }
.auth-side h1 { font-size: 40px; line-height: 1.1; letter-spacing: -.02em; margin: 0 0 14px; max-width: 12ch; }
.auth-side p { color: #B8C4D6; max-width: 38ch; margin: 0; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-form { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.auth-form h2 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
.auth-form p.lead { margin: -8px 0 4px; color: var(--muted); }
.demo-note {
  font-size: 13px; background: var(--blue-wash); color: var(--blue-dark);
  padding: 10px 12px; border-radius: var(--radius-s);
}
.form-error { color: var(--red); font-size: 14px; min-height: 1em; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--ink); color: #D8E1EE; display: flex; flex-direction: column;
  padding: 20px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo-plate { margin: 0 6px 6px; }
.sidebar .logo-plate img { height: 36px; }
.app-name { font-weight: 700; color: #fff; font-size: 15px; margin: 10px 8px 22px; letter-spacing: -.01em; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-s);
  color: #C5D0DF; text-decoration: none; font-weight: 500; font-size: 14.5px;
}
.nav a svg { width: 18px; height: 18px; opacity: .8; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a[aria-current="page"] { background: var(--blue); color: #fff; }
.nav a[aria-current="page"] svg { opacity: 1; }
.nav .count {
  margin-left: auto; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 20px;
  background: rgba(255,255,255,.12); color: #fff;
}
.nav a[aria-current="page"] .count { background: rgba(255,255,255,.22); }
.nav-group { margin-top: 20px; padding: 0 10px 6px; font-size: 12.5px; color: #7F8DA3; }
.me {
  margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--ink-2);
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.me .name { color: #fff; font-weight: 600; font-size: 14px; line-height: 1.2; }
.me .role { font-size: 12.5px; color: #8FA0B8; }
.me button { background: none; border: 0; color: #8FA0B8; cursor: pointer; padding: 6px; border-radius: 6px; }
.me button:hover { color: #fff; background: var(--ink-2); }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 28px 36px 18px;
}
.topbar h1 { font-size: 28px; line-height: 1.15; margin: 0; letter-spacing: -.02em; }
.topbar .sub { color: var(--muted); margin: 4px 0 0; font-size: 14.5px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 0 36px 48px; }
.demo-banner {
  margin: 0 36px 16px; padding: 10px 14px; border-radius: var(--radius-s);
  background: var(--amber-wash); color: #7A4A05; font-size: 13.5px;
}

/* Summary strip */
.pulse {
  display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 18px;
  border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface);
}
.pulse div { padding: 14px 20px; flex: 1 1 150px; border-right: 1px solid var(--line); }
.pulse div:last-child { border-right: 0; }
.pulse b { display: block; font-size: 22px; letter-spacing: -.01em; }
.pulse span { color: var(--muted); font-size: 13px; }
.pulse .warn b { color: var(--red); }

/* Filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters .input { width: auto; min-height: 36px; }
.filters .search { flex: 1 1 240px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 12px; min-height: 34px; font-size: 13.5px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- Appeal list ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.list-head, .item {
  display: grid; align-items: center; gap: 16px;
  grid-template-columns: 118px 118px minmax(150px, 1.3fr) minmax(120px, 1fr) 105px 125px 185px 115px;
  padding: 0 20px;
}
.list-head { min-height: 40px; font-size: 12.5px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); background: #FAFBFC; }
.item {
  min-height: 70px; border-bottom: 1px solid var(--line); cursor: pointer; width: 100%;
  text-align: left; background: none; border-left: 3px solid transparent; border-top: 0; border-right: 0;
}
.item:last-child { border-bottom: 0; }
.item:hover { background: #F7F9FC; }
.item[aria-selected="true"] { background: var(--blue-wash); border-left-color: var(--blue); }
.item .when b { display: block; font-size: 14px; }
.item .when span, .item .muted { font-size: 13px; color: var(--muted); }
.item .who b { display: block; font-weight: 600; }
.item .reason { font-size: 14px; }
.cell-trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* Strike meter: the signature element. Three bars, like licence points filling up. */
.strikes { display: inline-flex; align-items: center; gap: 10px; }
.strikes .bars { display: inline-grid; grid-template-columns: repeat(3, 14px); gap: 3px; }
.strikes .bars i { height: 18px; border-radius: 2px; background: var(--line); transform: skewX(-18deg); }
.strikes[data-level="1"] .bars i:nth-child(-n+1) { background: var(--sky); }
.strikes[data-level="2"] .bars i:nth-child(-n+2) { background: var(--amber); }
.strikes[data-level="3"] .bars i { background: var(--red); }
.strikes span { font-size: 13px; font-weight: 600; }
.strikes[data-level="2"] span { color: var(--amber); }
.strikes[data-level="3"] span { color: var(--red); }
.strikes.large .bars { grid-template-columns: repeat(3, 26px); gap: 5px; }
.strikes.large .bars i { height: 30px; }
.strikes.large span { font-size: 15px; }

/* Tags */
.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 4px; background: var(--paper); color: var(--muted); white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.new { background: var(--blue-wash); color: var(--blue); }
.tag.in_review, .tag.awaiting_driver { background: var(--amber-wash); color: var(--amber); }
.tag.reinstate, .tag.reinstate_warning, .tag.active { background: var(--green-wash); color: var(--green); }
.tag.suspend, .tag.manual_review, .tag.suspended { background: var(--amber-wash); color: var(--amber); }
.tag.permanent_ban, .tag.banned, .tag.failed { background: var(--red-wash); color: var(--red); }
.tag.plain::before { display: none; }

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(14, 26, 43, .32); z-index: 30; animation: fade .18s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%); z-index: 31;
  background: var(--surface); box-shadow: var(--shadow-panel);
  display: flex; flex-direction: column; animation: slide .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.drawer-head { padding: 22px 28px 18px; border-bottom: 1px solid var(--line); }
.drawer-head .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.drawer-head .ref { font-size: 13px; color: var(--muted); font-weight: 600; }
.drawer-head h2 { margin: 6px 0 12px; font-size: 26px; letter-spacing: -.02em; line-height: 1.15; }
.drawer-head .meta { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 14px; }
.drawer-body { overflow-y: auto; padding: 8px 28px 28px; flex: 1; }
.sect { padding: 20px 0; border-bottom: 1px solid var(--line); }
.sect:last-child { border-bottom: 0; }
.sect h3 { margin: 0 0 12px; font-size: 16px; letter-spacing: -.01em; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px 20px; margin: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.statement { white-space: pre-wrap; max-width: 68ch; margin: 0; line-height: 1.6; }
.files { display: flex; gap: 8px; flex-wrap: wrap; }
.files a {
  display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px; font-size: 13.5px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); text-decoration: none; color: var(--text);
}
.files a:hover { border-color: var(--blue); color: var(--blue); }

.recommend {
  border-left: 4px solid var(--blue); background: var(--blue-wash);
  padding: 14px 18px; border-radius: 0 var(--radius-s) var(--radius-s) 0;
}
.recommend.lvl-2 { border-color: var(--amber); background: var(--amber-wash); }
.recommend.lvl-3 { border-color: var(--red); background: var(--red-wash); }
.recommend .rule { font-weight: 700; }
.recommend .out { font-size: 14px; color: var(--muted); margin-top: 2px; }
.recommend ol { margin: 10px 0 0; padding-left: 20px; font-size: 14px; }
.recommend ol li { margin: 3px 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before {
  content: ""; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--line-strong);
}
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.current::before { background: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
.timeline .t-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 600; font-size: 14px; }
.timeline .t-sub { color: var(--muted); font-size: 13.5px; }

.decision { display: grid; gap: 14px; }
.outcomes { display: grid; grid-template-columns: repeat(auto-fit, minmax(116px, 1fr)); gap: 8px; }
.outcomes label {
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 10px 12px;
  cursor: pointer; font-weight: 600; font-size: 14px; display: flex; gap: 8px; align-items: center;
}
.outcomes input { accent-color: var(--blue); }
.outcomes label:has(input:checked) { border-color: var(--blue); background: var(--blue-wash); color: var(--blue-dark); }
.decided { background: var(--paper); border-radius: var(--radius-s); padding: 14px 16px; }

.comms { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.comms li { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 14px; }
.comms .c-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.comms .c-top b { text-transform: capitalize; }
.comms .c-body { font-size: 13.5px; color: var(--muted); margin-top: 4px; white-space: pre-wrap; max-height: 3.2em; overflow: hidden; }
.drawer-foot {
  border-top: 1px solid var(--line); padding: 14px 28px; display: flex; gap: 8px; flex-wrap: wrap; background: #FAFBFC;
}

/* ---------- Modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(14,26,43,.4); animation: fade .15s; }
.modal {
  width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface); border-radius: var(--radius-m); box-shadow: var(--shadow-panel);
}
.modal-head { padding: 20px 24px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.modal-body { padding: 18px 24px; display: grid; gap: 16px; }
.modal-foot { padding: 14px 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px dashed var(--line-strong); background: var(--paper); border-radius: 4px; padding: 2px 8px; font-size: 12.5px; cursor: pointer; }
.chips button:hover { border-color: var(--blue); color: var(--blue); }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px 16px; display: grid; gap: 14px; }
.fieldset legend { padding: 0 6px; font-weight: 700; font-size: 14px; }
.multi { display: flex; flex-wrap: wrap; gap: 6px; }
.multi label { border: 1px solid var(--line-strong); border-radius: 20px; padding: 4px 12px; font-size: 13.5px; cursor: pointer; }
.multi input { position: absolute; opacity: 0; pointer-events: none; }
.multi label:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }
.multi label:has(input:focus-visible) { outline: 2px solid var(--sky); outline-offset: 2px; }

/* ---------- Rules / templates / staff ---------- */
.rules { display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.rule-row {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 18px; align-items: start;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.rule-row:last-child { border-bottom: 0; }
.rule-row.off { opacity: .55; }
.prio { font-size: 13px; font-weight: 700; color: var(--muted); padding-top: 3px; }
.rule-row h3 { margin: 0; font-size: 16px; }
.rule-row .when { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.rule-row .then { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rule-row .acts { display: flex; gap: 6px; }
.explain { color: var(--muted); font-size: 14px; max-width: 72ch; margin: 0 0 16px; }

table.tbl { width: 100%; border-collapse: collapse; background: var(--surface); }
.tbl-wrap { border: 1px solid var(--line); border-radius: var(--radius-m); overflow-x: auto; }
.tbl th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 16px; background: #FAFBFC; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .input { min-height: 34px; padding: 4px 8px; width: auto; }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: var(--radius-s);
  font-size: 14px; box-shadow: var(--shadow-panel); animation: fade .2s;
}
.toast.err { background: var(--red); }

/* ---------- Driver appeal form (public) ---------- */
.public { background: var(--paper); }
.pub-head { background: var(--ink); color: #fff; position: relative; overflow: hidden; }
.pub-head::after {
  content: ""; position: absolute; right: -60px; top: -120px; width: 380px; height: 380px;
  background: linear-gradient(135deg, transparent 47%, var(--sky) 47.5%, var(--blue) 52%, transparent 52.5%);
  pointer-events: none;
}
.pub-head .inner { max-width: 760px; margin: 0 auto; padding: 28px 24px 40px; position: relative; z-index: 1; }
.pub-head h1 { font-size: 34px; letter-spacing: -.02em; line-height: 1.1; margin: 26px 0 10px; }
.pub-head p { color: #B8C4D6; margin: 0; max-width: 56ch; }
.pub-form { max-width: 760px; margin: -18px auto 60px; padding: 0 24px; position: relative; z-index: 2; }
.pub-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 28px; display: grid; gap: 28px; }
.step { display: grid; grid-template-columns: 36px 1fr; gap: 16px; }
.step-n {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--blue); color: var(--blue);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.step h2 { margin: 3px 0 14px; font-size: 18px; }
.step .body { display: grid; gap: 14px; }
.reasons { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.reasons label {
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 11px 14px; cursor: pointer;
  font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 10px;
}
.reasons input { accent-color: var(--blue); }
.reasons label:has(input:checked) { border-color: var(--blue); background: var(--blue-wash); color: var(--blue-dark); }
.drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-s); padding: 22px; text-align: center;
  cursor: pointer; color: var(--muted);
}
.drop:hover, .drop.over { border-color: var(--blue); background: var(--blue-wash); }
.drop b { color: var(--blue); }
.file-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.file-list li { display: flex; justify-content: space-between; padding: 6px 10px; background: var(--paper); border-radius: 4px; }
.done { text-align: center; padding: 20px 0; display: grid; gap: 12px; justify-items: center; }
.done .refbox { font-size: 28px; font-weight: 700; letter-spacing: .02em; padding: 10px 20px; border: 2px solid var(--blue); border-radius: var(--radius-s); color: var(--blue); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .list-head { display: none; }
  .item { grid-template-columns: 1fr auto; padding: 14px 18px; gap: 6px 12px; }
  .item .when { order: 2; text-align: right; }
  .item .who { order: 1; }
  .item .reason, .item .strikes-cell, .item .rec, .item .status { grid-column: 1 / -1; order: 3; }
  .item .reason { order: 3; } .item .strikes-cell { order: 4; } .item .rec { order: 5; } .item .status { order: 6; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .main, .sidebar, .nav { min-width: 0; }
  .pulse div { flex-basis: 45%; border-bottom: 1px solid var(--line); }
  .filters .seg { flex: 1 1 auto; }
  .filters .seg button { flex: 1; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .demo-banner { margin: 0 16px 12px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 24px; min-height: 220px; }
  .auth-side h1 { font-size: 30px; }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 18px; padding-right: 18px; }
  .pub-card { padding: 20px; }
  .step { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Two-step sign-in */
.mfa-qr { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-m); }
.mfa-qr img { display: block; background: #fff; border-radius: 4px; }
.mfa-qr-demo { width: 150px; height: 150px; display: grid; place-items: center; text-align: center; font-size: 12.5px; color: var(--muted); background: repeating-linear-gradient(45deg, var(--paper) 0 8px, #fff 8px 16px); border-radius: 4px; }
.mfa-qr code { display: block; margin-top: 6px; font-size: 14px; font-weight: 600; word-break: break-all; letter-spacing: .06em; }
.mfa-code { font-size: 24px; letter-spacing: .4em; text-align: center; font-weight: 600; min-height: 54px; }
@media (max-width: 480px) { .mfa-qr { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

/* Typeset wordmark (replaces the low-quality logo image) */
.wordmark { display: inline-grid; line-height: 1; width: fit-content; user-select: none; }
.wm-top { font-weight: 800; font-size: 34px; letter-spacing: -.045em; color: #fff; }
.wm-bottom { justify-self: end; font-weight: 700; font-size: 13px; letter-spacing: .01em; color: var(--sky); margin-top: 1px; }
.sidebar .wordmark { margin: 4px 8px 0; }
.sidebar .wm-top { font-size: 30px; }
.sidebar .app-name { margin-top: 14px; }
@media (max-width: 860px) { .sidebar .wm-top { font-size: 24px; } .sidebar .wm-bottom { font-size: 11px; } }
.auth-side > * { position: relative; z-index: 1; }

/* Brand logo (white-lettering version on dark backgrounds) */
.brand-logo { display: block; height: auto; width: 180px; max-width: 100%; }
.sidebar .brand-logo { width: 150px; margin: 6px 8px 0; }
.pub-head .brand-logo { width: 170px; }
@media (max-width: 860px) { .auth-side .brand-logo { width: 140px; } }

/* Email appeals */
.tag.src-email { background: #EEF0FF; color: #3C3FA8; }
.tag.needs { background: var(--amber-wash); color: var(--amber); }
.needs-box { background: var(--amber-wash); border-radius: var(--radius-s); padding: 14px 16px; display: grid; gap: 12px; margin-bottom: 18px; }
.needs-box p { margin: 2px 0 0; font-size: 14px; color: #6B4A08; }
.mail-item { grid-template-columns: 112px minmax(170px, 1fr) minmax(200px, 2fr) 130px !important; }
.mail-body { max-height: 320px; overflow: auto; background: var(--paper); padding: 12px 14px; border-radius: var(--radius-s); font-size: 14px; }
@media (max-width: 1100px) { .mail-item { grid-template-columns: 1fr auto !important; } }

/* Staged messaging */
.preview-box { border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 14px 16px; display: grid; gap: 12px; background: #FAFBFC; }
.preview-head { display: grid; gap: 2px; }
.preview-head span { font-size: 13px; color: var(--muted); }
.waiting { background: var(--blue-wash); border-radius: var(--radius-s); padding: 12px 14px; display: grid; gap: 8px; margin-bottom: 14px; }
.w-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; }
.seg button:disabled { cursor: not-allowed; opacity: .6; }

/* Who's online */
.online { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 20px; }
.online-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.online-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.online-person { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22A35A; margin-right: 7px; box-shadow: 0 0 0 3px rgba(34,163,90,.18); vertical-align: 1px; }

/* Activity timeline */
.act-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 4px 0 8px; }
.act-list.compact { border: 0; padding: 0; background: none; }
.act-day { position: sticky; top: 0; z-index: 1; background: #FAFBFC; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); padding: 8px 20px; font-size: 13px; font-weight: 700; color: var(--muted); }
.act-day:first-child { border-top: 0; border-radius: var(--radius-m) var(--radius-m) 0 0; }
.act-row { display: grid; grid-template-columns: 78px 18px 1fr; gap: 12px; padding: 11px 20px; position: relative; }
.act-list.compact .act-row { padding: 8px 0; grid-template-columns: 70px 18px 1fr; }
.act-row + .act-row { border-top: 1px solid #F0F2F5; }
.act-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; line-height: 1.35; }
.act-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--line-strong); box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--line); }
.cat-appeal .act-dot { background: var(--blue); }
.cat-decision .act-dot { background: var(--green); }
.cat-message .act-dot { background: var(--sky); }
.cat-email .act-dot { background: #6B6FD6; }
.cat-outbox .act-dot { background: #9AA6B8; }
.cat-alert .act-dot { background: var(--red); }
.cat-staff .act-dot, .cat-session .act-dot { background: var(--ink); }
.cat-setup .act-dot { background: var(--amber); }
.cat-driver .act-dot { background: #4B8B6E; }
.act-text { font-weight: 600; font-size: 14.5px; line-height: 1.4; }
.act-meta { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.act-ref { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 4px; padding: 0 6px; font-size: 12.5px; font-weight: 600; color: var(--blue); cursor: pointer; }
.act-ref:hover { border-color: var(--blue); }
.act-main details { margin-top: 6px; }
.act-main summary { font-size: 13px; color: var(--blue); cursor: pointer; width: fit-content; }
table.chg { margin-top: 8px; border-collapse: collapse; font-size: 13px; width: auto; max-width: 100%; }
table.chg th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 12px 5px 0; vertical-align: top; white-space: nowrap; width: 1%; }
table.chg td { padding: 5px 8px 5px 0; vertical-align: top; word-break: break-word; white-space: pre-wrap; max-width: 320px; }
table.chg td.arrow { color: var(--muted); width: 1%; white-space: nowrap; }
table.chg tr + tr { border-top: 1px solid #F0F2F5; }
@media (max-width: 860px) { .act-row { grid-template-columns: 64px 14px 1fr; padding: 10px 14px; } .act-day { padding: 8px 14px; } }
.tbl td.nowrap { white-space: nowrap; }

/* Word-level differences */
.diff { white-space: pre-wrap; line-height: 1.6; font-size: 13.5px; background: #FAFBFC; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; max-height: 360px; overflow: auto; }
.diff del { background: #FDE2E0; color: #9A1B14; text-decoration: line-through; border-radius: 2px; padding: 0 1px; }
.diff ins { background: #DDF3E4; color: #125C33; text-decoration: none; border-radius: 2px; padding: 0 1px; font-weight: 600; }
.diff-gap { color: var(--muted); }
.diff del + ins, .diff ins + del { margin-left: 3px; }

/* Staff activity */
.staff-today { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; margin-bottom: 16px; }
.st-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.st-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.st-card { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; text-align: left; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); cursor: pointer; }
.st-card:hover { border-color: var(--blue); background: var(--blue-wash); }
.st-name { display: grid; line-height: 1.25; min-width: 0; }
.st-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.st-name span { font-size: 12.5px; color: var(--muted); }
.st-count { display: grid; text-align: right; line-height: 1.1; }
.st-count b { font-size: 18px; }
.st-count span { font-size: 11.5px; color: var(--muted); }
.act-person, .link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--blue); cursor: pointer; }
.act-person { font-weight: 500; }
.act-person:hover, .link-btn:hover { text-decoration: underline; }
.person-head { display: flex; gap: 14px; align-items: center; }
.day-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.day-nav .input { width: auto; min-height: 38px; }
.day-title { margin-left: 8px; font-size: 16px; }
.pstats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 18px; overflow: hidden; }
.pstats div { padding: 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.pstats span { display: block; font-size: 12.5px; color: var(--muted); }
.pstats b { font-size: 17px; }
.reorder { display: grid; gap: 4px; } .reason-row .acts { flex-wrap: wrap; justify-content: flex-end; }
.reason-row.off { opacity: 1; } .reason-row.off h3, .reason-row.off .when { opacity: .5; }

/* Dealing with it */
.avatar.mini { width: 22px; height: 22px; font-size: 10px; display: inline-grid; margin-right: 6px; vertical-align: middle; }
.who-tag { display: inline-flex; align-items: center; font-size: 13.5px; font-weight: 600; }
.who-tag.me { color: var(--blue); }
.handling { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 28px; font-size: 14px; border-bottom: 1px solid var(--line); }
.handling.free { background: var(--blue-wash); }
.handling.mine { background: var(--green-wash); color: #125C33; }
.handling.other { background: var(--amber-wash); color: #6B4A08; }
.handling .h-acts { display: flex; gap: 6px; }
.locked-box { background: var(--amber-wash); border-radius: var(--radius-s); padding: 14px 16px; }
.locked-box p { margin: 4px 0 0; font-size: 14px; color: #6B4A08; }

/* Repeat appeals */
.item.repeat-2 { background: #FFFBF2; }
.item.repeat-3 { background: #FFF6F5; }
.item.repeat-2:hover { background: #FDF3E1; } .item.repeat-3:hover { background: #FBEAE9; }
.hist-banner { margin: 16px 0 0; padding: 11px 14px; border-radius: var(--radius-s); font-size: 14px; line-height: 1.8; }
.hist-banner.first { background: var(--blue-wash); color: var(--blue-dark); }
.hist-banner.lvl-2 { background: var(--amber-wash); color: #6B4A08; }
.hist-banner.lvl-3 { background: var(--red-wash); color: #8A1C15; }
.hist-chip { border: 1px solid currentColor; background: #fff; color: inherit; border-radius: 4px; font-size: 12.5px; padding: 1px 7px; cursor: pointer; font-weight: 600; }
.h2link { font-size: inherit; font-weight: inherit; color: var(--text); letter-spacing: inherit; }
.h2link:hover { color: var(--blue); }

/* Drivers */
.click-row { cursor: pointer; } .click-row:hover td { background: #F7F9FC; }
.drivers-tbl .strikes .bars { grid-template-columns: repeat(3, 10px); } .drivers-tbl .strikes .bars i { height: 14px; }
.incidents { display: grid; gap: 8px; }
.incident { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--sky); border-radius: var(--radius-s); cursor: pointer; font-size: 14px; }
.incident:hover { background: #F7F9FC; }
.incident.lvl-2 { border-left-color: var(--amber); } .incident.lvl-3 { border-left-color: var(--red); }
.inc-n { font-weight: 700; font-size: 15px; color: var(--muted); }
.dfile { display: grid; gap: 12px; }

/* Customisation */
.tpl-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.wording { display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px; }
.wording-save { display: flex; gap: 8px; }
.sender-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; display: grid; gap: 12px; margin-bottom: 8px; }
.strikes > span:last-child { white-space: nowrap; }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; display: grid; gap: 2px; cursor: default; font: inherit; color: inherit; }
.kpi[data-go] { cursor: pointer; } .kpi[data-go]:hover { border-color: var(--blue); }
.kpi span { font-size: 13px; color: var(--muted); } .kpi b { font-size: 26px; letter-spacing: -.02em; line-height: 1.2; } .kpi small { font-size: 12.5px; color: var(--muted); }
.kpi.warn { border-left: 4px solid var(--amber); } .kpi.bad { border-left: 4px solid var(--red); } .kpi.bad b { color: var(--red); } .kpi.good { border-left: 4px solid var(--green); }
.dgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.chart { display: grid; grid-template-columns: repeat(30, 1fr); gap: 3px; height: 150px; align-items: end; }
.chart .col { display: flex; gap: 1px; align-items: end; height: 100%; }
.chart .b { flex: 1; border-radius: 2px 2px 0 0; min-height: 1px; }
.chart .rec { background: var(--blue); } .chart .dec { background: #7CC5A0; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend i.rec { background: var(--blue); } .legend i.dec { background: #7CC5A0; }
.hbar { display: grid; grid-template-columns: 150px 1fr 36px; gap: 10px; align-items: center; font-size: 13.5px; margin: 7px 0; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 10px; background: var(--paper); border-radius: 5px; overflow: hidden; }
.hb-fill { display: block; height: 100%; background: var(--blue); border-radius: 5px; }
.hb-fill.reinstate, .hb-fill.reinstate_warning, .hb-fill.ok, .hb-fill.lvl1 { background: var(--green); }
.hb-fill.suspend, .hb-fill.warn, .hb-fill.lvl2 { background: var(--amber); }
.hb-fill.permanent_ban, .hb-fill.bad, .hb-fill.lvl3 { background: var(--red); }
.hb-fill.manual_review { background: #9AA6B8; }
.hbar b { text-align: right; }
.tbl.mini td, .tbl.mini th { padding: 8px 12px; }

/* Timeline */
.live-badge { display: inline-flex; align-items: center; font-size: 13px; font-weight: 700; color: #1D7A4C; background: var(--green-wash); border-radius: 20px; padding: 3px 10px 3px 8px; vertical-align: middle; margin-left: 8px; letter-spacing: 0; }
.live-badge .live-dot { animation: pulse 1.6s infinite; }
.live-badge.paused { color: var(--muted); background: var(--paper); } .live-badge.paused .live-dot { background: #9AA6B8; animation: none; box-shadow: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(34,163,90,0); } }
.tl-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.tl-row { display: grid; grid-template-columns: 70px 84px minmax(0, 1fr) 150px 130px; gap: 12px; align-items: center; padding: 8px 18px; font-size: 13.5px; border-top: 1px solid #F0F2F5; }
.tl-row.fresh { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: #EAF2FC; } to { background: transparent; } }
.tl-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-cat { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--paper); color: var(--muted); text-align: center; white-space: nowrap; }
.cat-message .tl-cat, .cat-delivery .tl-cat { background: #E4F2FB; color: #1B6FA8; }
.cat-email .tl-cat { background: #EEF0FF; color: #3C3FA8; }
.cat-decision .tl-cat { background: var(--green-wash); color: var(--green); }
.cat-appeal .tl-cat, .cat-driver .tl-cat { background: var(--blue-wash); color: var(--blue); }
.cat-alert .tl-cat { background: var(--red-wash); color: var(--red); }
.cat-setup .tl-cat, .cat-outbox .tl-cat { background: var(--amber-wash); color: var(--amber); }
.cat-staff .tl-cat, .cat-session .tl-cat { background: #E9ECF1; color: var(--ink); }
.cat-view .tl-text, .cat-click .tl-text { color: var(--muted); }
.cat-delivery .act-dot { background: var(--sky); } .cat-view .act-dot, .cat-click .act-dot { background: #C9D1DC; }
.tl-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.tl-list .act-day { position: static; }
@media (max-width: 1000px) { .tl-row { grid-template-columns: 64px 1fr; } .tl-cat { justify-self: start; } .tl-text { grid-column: 1 / -1; white-space: normal; } .tl-who, .tl-ref { grid-column: auto; } }
.act-ref { white-space: nowrap; }

/* Export recipients */
.chip-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 6px; background: var(--surface); }
.chip-input .input { border: 0; min-height: 30px; flex: 1 1 200px; padding: 4px 6px; box-shadow: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--blue-wash); color: var(--blue-dark); border-radius: 14px; padding: 3px 4px 3px 10px; font-size: 13.5px; font-weight: 600; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; padding: 2px; display: grid; }
.chip button svg { width: 14px; height: 14px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 600; font-size: 14.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--blue); border-bottom-color: var(--blue); }
.tabs button:hover { color: var(--text); }
.dlv { list-style: none; margin: 0; padding: 0; font-size: 13.5px; display: grid; gap: 4px; }


/* ============================================================
   Mobile
   ============================================================ */
.mtop, .nav-scrim { display: none; }
@media (max-width: 860px) {
  html { -webkit-text-size-adjust: 100%; }
  body { padding-bottom: env(safe-area-inset-bottom, 0px); }
  /* top bar with menu button */
  .mtop { display: flex; position: sticky; top: 0; z-index: 25; align-items: center; gap: 12px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: var(--ink); color: #fff; }
  .mtop .brand-logo { width: 92px; }
  .mtop .mtitle { font-weight: 700; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menu-btn { border: 0; background: rgba(255,255,255,.1); color: #fff; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; flex: none; position: relative; }
  .menu-btn svg { width: 22px; height: 22px; }
  .menu-btn .dot { position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 2px var(--ink); }
  /* sliding menu */
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 84vw); height: 100%; z-index: 40; overflow-y: auto;
    transform: translateX(-102%); transition: transform .22s ease; padding-top: calc(20px + env(safe-area-inset-top, 0px)); padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .shell.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(14,26,43,.45); }
  .sidebar .brand-logo { width: 130px; }
  .nav a { padding: 12px 12px; font-size: 15.5px; }
  .me { margin-top: 18px; }
  /* page layout */
  .topbar { padding-top: 18px; }
  .topbar h1 { font-size: 23px; }
  .topbar .actions { width: 100%; }
  .topbar .actions .btn { flex: 1 1 auto; }
  .demo-banner { margin-top: 10px; }
  /* bigger touch targets, no iPhone zoom on inputs */
  .btn { min-height: 44px; }
  .btn.small { min-height: 38px; padding: 0 12px; }
  .input, select.input, textarea.input { font-size: 16px; min-height: 44px; }
  .filters { gap: 8px; }
  .filters .input, .filters .search { width: 100%; flex: 1 1 100%; }
  .filters .seg { width: 100%; overflow-x: auto; }
  .seg button { min-height: 40px; white-space: nowrap; }
  .tabs { overflow-x: auto; }
  .tabs a, .tabs button { white-space: nowrap; }
  /* lists */
  .item { padding: 14px 16px; }
  .list-head { display: none; }
  .mail-item { grid-template-columns: 1fr !important; }
  .mail-item .when { text-align: left; }
  /* appeal / driver panels: full screen */
  .drawer { width: 100%; }
  .drawer-head { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
  .drawer-head h2 { font-size: 22px; }
  .drawer-head .meta { gap: 8px 12px; }
  .strikes.large .bars { grid-template-columns: repeat(3, 20px); } .strikes.large .bars i { height: 24px; }
  .handling { padding: 10px 18px; }
  .handling .h-acts { width: 100%; } .handling .h-acts .btn { flex: 1; }
  .drawer-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .drawer-foot .btn { flex: 1 1 auto; }
  .facts { grid-template-columns: 1fr 1fr; }
  .outcomes { grid-template-columns: 1fr 1fr; }
  /* pop-up windows become bottom sheets */
  .modal-wrap { padding: 0; place-items: end stretch; }
  .modal { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
  .modal-foot { flex-wrap: wrap; } .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot .btn[style*="margin-right:auto"] { flex-basis: 100%; margin-right: 0 !important; order: 3; }
  /* dashboard */
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px; } .kpi b { font-size: 22px; }
  .dgrid { grid-template-columns: minmax(0, 1fr); }
  .hbar { grid-template-columns: 104px 1fr 30px; }
  .chart { height: 120px; gap: 2px; }
  .card { padding: 14px; overflow-x: auto; }
  /* timeline / activity */
  .tl-row { grid-template-columns: 64px 1fr; padding: 10px 14px; row-gap: 4px; }
  .tl-text { grid-column: 1 / -1; white-space: normal; }
  .tl-who { grid-column: 1; } .tl-ref { grid-column: 2; justify-self: end; }
  .staff-today .st-list, .online-list { grid-template-columns: 1fr; }
  .pstats { grid-template-columns: 1fr 1fr; }
  .day-nav .btn { flex: 1; } .day-nav .input { flex: 1 1 100%; order: -1; }
  .person-head h1 { font-size: 22px; }
  /* tables scroll sideways inside their box */
  .tbl-wrap { -webkit-overflow-scrolling: touch; }
  .tbl th, .tbl td { padding: 10px 12px; }
  .rule-row { grid-template-columns: 1fr !important; }
  .rule-row .acts { justify-content: flex-start; }
  .reason-row .reorder { grid-auto-flow: column; justify-content: start; }
  .toasts { left: 12px; right: 12px; transform: none; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 380px) { .kpis { grid-template-columns: 1fr; } .facts { grid-template-columns: 1fr; } }

/* Date boxes: make iPhone/Safari match the other boxes exactly */
.field { min-width: 0; }
input.input[type="date"] {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; min-width: 0; max-width: 100%;
  height: 44px; min-height: 44px; line-height: 1.2; padding: 0 12px;
  background: var(--surface); color: var(--text); text-align: left;
}
input.input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input.input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; }
input.input[type="date"]:not(:focus):invalid, input.input[type="date"][value=""] { color: var(--muted); }
.row > .field { min-width: 0; }
@media (max-width: 860px) { .row { grid-template-columns: 1fr; } }

/* Pre-filled driver form */
.prefill-note { background: var(--blue-wash); color: var(--blue-dark); border-radius: var(--radius-s); padding: 11px 14px; font-size: 14.5px; line-height: 1.6; }
.linkish { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--blue); text-decoration: underline; cursor: pointer; }
.input.locked { background: #F3F6FA; color: var(--text); border-style: dashed; }
@media (max-width: 600px) { .pub-head::after { right: -230px; top: -170px; opacity: .55; } .pub-head h1 { font-size: 28px; } }

/* My tasks */
.sec-h { font-size: 16px; margin: 24px 0 10px; }
.mine-item { grid-template-columns: 130px minmax(160px, 1fr) 150px minmax(200px, 1.4fr) !important; }
.mine-flags { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 1100px) { .mine-item { grid-template-columns: 1fr auto !important; } .mine-item .mine-flags { grid-column: 1 / -1; } }

/* Welcome message */
.welcome { position: fixed; top: calc(20px + env(safe-area-inset-top, 0px)); right: 24px; z-index: 90; pointer-events: none; }
.welcome-card { display: flex; align-items: center; gap: 16px; background: var(--ink); color: #fff; padding: 20px 28px 20px 20px; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(14,26,43,.35); opacity: 0; transform: translateX(24px); transition: opacity .45s ease, transform .45s cubic-bezier(.2,.8,.2,1); pointer-events: auto; }
.welcome.show .welcome-card { opacity: 1; transform: none; }
.welcome-card .avatar { width: 48px; height: 48px; font-size: 17px; background: linear-gradient(135deg, var(--sky), var(--blue)); }
.welcome-card b { display: block; font-size: 22px; letter-spacing: -.01em; }
.welcome-card span:not(.avatar) { display: block; color: #9FB0C6; font-size: 14px; margin-top: 2px; }

@media (max-width: 860px) { .welcome { top: calc(70px + env(safe-area-inset-top, 0px)); right: 12px; left: 12px; } .welcome-card { padding: 14px 18px 14px 14px; } .welcome-card b { font-size: 18px; } }

/* ============ Staff messaging ============ */
.nav .count.alert { background: #E5484D; color: #fff; }
.nav .count[hidden] { display: none; }
.chat { display: grid; grid-template-columns: 330px minmax(0, 1fr); height: calc(100vh - 32px); margin: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 10px; }
.chat-list-head h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.chat-list > .input { margin: 0 16px 10px; width: auto; }
#convList { overflow-y: auto; flex: 1; }
.conv { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 10px 16px; border: 0; background: none; cursor: pointer; font: inherit; color: inherit; border-left: 3px solid transparent; }
.conv:hover { background: #F7F9FC; }
.conv.active { background: var(--blue-wash); border-left-color: var(--blue); }
.conv .avatar { width: 42px; height: 42px; font-size: 14px; position: relative; }
.conv .avatar svg, .thread-head .avatar svg { width: 20px; height: 20px; }
.avatar.grp { background: var(--ink); }
.avatar .on { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: #22A35A; border: 2px solid #fff; }
.conv-main { display: grid; min-width: 0; line-height: 1.3; }
.conv-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-main span { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .conv-main b { font-weight: 800; } .conv.unread .conv-main span { color: var(--text); font-weight: 600; }
.conv-side { display: grid; justify-items: end; gap: 4px; font-size: 12px; color: var(--muted); }
.ubadge { background: #E5484D; color: #fff; border-radius: 10px; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; font-size: 12px; }
.chat-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-empty { margin: auto; display: grid; justify-items: center; gap: 6px; color: var(--muted); text-align: center; padding: 20px; }
.chat-empty svg { width: 44px; height: 44px; opacity: .4; } .chat-empty b { color: var(--text); font-size: 17px; }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.thread-head .avatar { width: 40px; height: 40px; font-size: 14px; flex: none; }
.th-title { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.th-title b { font-size: 16px; } .th-title span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.back-btn { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 20px 8px; background: #F7F9FC; display: flex; flex-direction: column; }
.chat-day { align-self: center; font-size: 12px; font-weight: 600; color: var(--muted); background: #E9EDF3; border-radius: 10px; padding: 3px 10px; margin: 14px 0 8px; }
.msg { display: grid; justify-items: start; max-width: min(72%, 560px); margin-top: 10px; }
.msg.cont { margin-top: 3px; }
.msg.mine { align-self: flex-end; justify-items: end; }
.msg-who { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 3px 10px; }
.bubble { background: #fff; border: 1px solid var(--line); padding: 9px 13px; border-radius: 16px 16px 16px 4px; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; line-height: 1.45; }
.msg.mine .bubble { background: var(--blue); border-color: var(--blue); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg.mine .bubble .act-ref { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.4); }
.msg-time { font-size: 11px; color: var(--muted); margin: 3px 8px 0; }
.seen { align-self: flex-end; font-size: 12px; color: var(--muted); margin: 2px 8px 0; }
.typing { font-size: 13px; color: var(--muted); margin: 10px 0 4px; display: flex; align-items: center; gap: 6px; }
.dots { display: inline-flex; gap: 3px; } .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.composer .input { resize: none; min-height: 44px; max-height: 160px; line-height: 1.4; padding: 11px 14px; border-radius: 22px; }
.composer .btn { border-radius: 22px; min-height: 44px; }
.picker { display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; }
.pick { display: grid; grid-template-columns: auto 30px 1fr; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; }
.pick:has(input:checked) { border-color: var(--blue); background: var(--blue-wash); }
.pick input { accent-color: var(--blue); width: 17px; height: 17px; }
.pick b { display: block; font-size: 14px; } .pick small { color: var(--muted); font-size: 12.5px; }
/* new-message pop-ups */
#chatPops { position: fixed; right: 20px; bottom: 20px; z-index: 85; display: grid; gap: 8px; }
.chat-pop { display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center; width: 330px; max-width: calc(100vw - 32px); text-align: left; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid #E5484D; border-radius: var(--radius-m); padding: 12px 14px; box-shadow: var(--shadow-panel); cursor: pointer; font: inherit; color: inherit;
  opacity: 0; transform: translateY(12px); transition: opacity .3s, transform .3s; }
.chat-pop.show { opacity: 1; transform: none; }
.chat-pop .avatar { width: 38px; height: 38px; font-size: 13px; }
.chat-pop b { display: block; font-size: 14px; } .chat-pop span span { display: block; font-size: 13.5px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (max-width: 860px) {
  .chat { grid-template-columns: 1fr; margin: 0; border: 0; border-radius: 0; height: calc(100vh - 62px - env(safe-area-inset-top, 0px)); }
  .chat .chat-thread { display: none; } .chat.has-active .chat-list { display: none; } .chat.has-active .chat-thread { display: flex; }
  .back-btn { display: inline-flex; } .th-acts { display: none; }
  .msg { max-width: 85%; }
  .composer { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  #chatPops { right: 12px; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); } .chat-pop { width: auto; }
}

/* Form field editor */
.ff-tbl .input { min-width: 150px; width: 100%; }
.ff-tbl tr.ff-off td:first-child b, .ff-tbl tr.ff-off .input { opacity: .45; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: #CBD3DE; border-radius: 12px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: .45; }
.switch input:focus-visible + span { outline: 2px solid var(--sky); outline-offset: 2px; }

/* Case categories */
.cat-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; margin-bottom: 18px; }
.cat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.cat-list { display: grid; }
.cat { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #F0F2F5; flex-wrap: wrap; }
.cat.off .cat-name b { opacity: .5; }
.cat-name { display: grid; } .cat-name small { color: var(--muted); font-size: 12.5px; }
.cat-acts { display: flex; gap: 4px; flex-wrap: wrap; }
.cat-pick { min-height: 34px; padding: 4px 8px; font-weight: 600; }
/* Completed date range */
.daterange { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.daterange label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }
.daterange .input { width: auto; min-height: 36px; }
.chat-thread > .typing { margin: 0; padding: 6px 20px; background: #F7F9FC; border-top: 1px solid var(--line); min-height: 30px; }
.typing-inline { color: var(--blue); font-style: normal; font-weight: 600; }

/* Severity (staff only) */
.sev { display: inline-flex; align-items: center; gap: 10px; }
.sev .bars { display: inline-grid; grid-template-columns: repeat(3, 14px); gap: 3px; }
.sev .bars i { height: 18px; border-radius: 2px; background: var(--line); transform: skewX(-18deg); }
.sev span:last-child { font-size: 13px; font-weight: 600; white-space: nowrap; }
.sev[data-sev="none"] span:last-child { color: var(--muted); font-weight: 500; }
.sev[data-sev="low"] .bars i:nth-child(1) { background: #22A35A; } .sev[data-sev="low"] span:last-child { color: #1D7A4C; }
.sev[data-sev="medium"] .bars i:nth-child(-n+2) { background: var(--amber); } .sev[data-sev="medium"] span:last-child { color: var(--amber); }
.sev[data-sev="high"] .bars i { background: var(--red); } .sev[data-sev="high"] span:last-child { color: var(--red); }
.sev.large .bars { grid-template-columns: repeat(3, 26px); gap: 5px; } .sev.large .bars i { height: 30px; } .sev.large span:last-child { font-size: 15px; }
.sev-pick { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.sev-lbl { font-size: 13px; font-weight: 600; color: var(--muted); margin-right: 4px; }
.sev-btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; padding: 5px 12px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.sev-btn.sev-low[aria-pressed="true"] { background: #22A35A; border-color: #22A35A; color: #fff; }
.sev-btn.sev-medium[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); color: #fff; }
.sev-btn.sev-high[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.sev-btn:hover { border-color: #8C98AA; }
.inc-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 1100px) { .item .sev-cell { grid-column: 1 / -1; order: 4; } }

/* Case notes + editing completed cases */
.notes { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.notes li { background: #FFFBEB; border: 1px solid #F3E3B5; border-radius: var(--radius-s); padding: 10px 14px; }
.n-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.n-body { margin-top: 4px; white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.note-add { display: flex; gap: 8px; align-items: flex-end; }
.note-add .input { min-height: 44px; resize: vertical; }
.decided-acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.review-banner { background: var(--amber-wash); color: #6B4A08; border-radius: var(--radius-s); padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.tag.resolved { background: var(--green-wash); color: var(--green); }
.hb-fill.resolved { background: #22A35A; }

.jobdate { display: grid; line-height: 1.3; } .jobdate b { font-size: 14px; } .jobdate span { font-size: 12.5px; color: var(--muted); }
.sortby { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }
.sortby .input { width: auto; min-height: 36px; }

.item .when b, .jobdate b { white-space: nowrap; }
.inc-jd { font-weight: 600; }

/* Clickable driver boxes */
.pulse-btns button { text-align: left; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; display: grid; gap: 2px; padding: 16px 20px; border-right: 1px solid var(--line); }
.pulse-btns button:last-child { border-right: 0; }
.pulse-btns button:hover { background: #F7F9FC; }
.pulse-btns button[aria-pressed="true"] { background: var(--blue-wash); box-shadow: inset 0 -3px 0 var(--blue); }
.pulse-btns button b { font-size: 26px; } .pulse-btns button span { font-size: 13.5px; color: var(--muted); }
.pulse-btns button.warn b { color: var(--red); }
/* Driver look-up in Log a case */
.ac-wrap { position: relative; }
.ac-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-s); box-shadow: var(--shadow-panel); max-height: 300px; overflow-y: auto; }
.ac-item { display: grid; grid-template-columns: 80px 1fr; column-gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; font: inherit; cursor: pointer; border-top: 1px solid #F0F2F5; }
.ac-item:first-child { border-top: 0; }
.ac-item small { grid-column: 2; color: var(--muted); font-size: 12.5px; }
.ac-item:hover, .ac-item.on { background: var(--blue-wash); }
.ac-empty { padding: 10px 12px; font-size: 13.5px; color: var(--muted); }
.ac-note { background: var(--green-wash); color: #125C33; border-radius: var(--radius-s); padding: 9px 12px; font-size: 13.5px; }

/* Outbox: select several */
.bulkbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 8px 14px; margin-bottom: 8px; }
.sel-row { display: grid; grid-template-columns: auto 1fr; align-items: stretch; border-top: 1px solid var(--line); }
.list .sel-row:first-child { border-top: 0; }
.sel-row .item { border-top: 0; }
.sel-row.on { background: var(--blue-wash); } .sel-row.on .item { background: transparent; }
.sel-box { display: grid; place-items: center; padding: 0 4px 0 16px; cursor: pointer; }
.sel-box input { width: 18px; height: 18px; accent-color: var(--blue); cursor: pointer; }
