/* TrackHarvest - field-first UI.
   One bold element: the lot code "bag tag". Everything else stays quiet. */

:root {
  --bg: #e9eee6;
  --surface: #ffffff;
  --surface-2: #f4f7f2;
  --ink: #22291f;
  --ink-2: #55604f;
  --line: #cfd8ca;
  --leaf: #2f5d3a;
  --leaf-ink: #ffffff;
  --leaf-soft: #dce8dd;
  --kraft: #c8a46a;
  --kraft-ink: #2b2112;
  --maize: #e3a812;
  --maize-soft: #fbefcc;
  --rust: #a7432c;
  --rust-soft: #f6dfd8;
  --muted-soft: #e3e6e1;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  --font-code: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;

  --r-sm: 6px;
  --r-md: 10px;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131912;
    --surface: #1c241b;
    --surface-2: #222c21;
    --ink: #e6ece2;
    --ink-2: #a3ae9d;
    --line: #34402f;
    --leaf: #7dba88;
    --leaf-ink: #10200f;
    --leaf-soft: #233826;
    --kraft: #c8a46a;
    --maize: #f0bd3c;
    --maize-soft: #3b3115;
    --rust: #e58a72;
    --rust-soft: #3d221b;
    --muted-soft: #2a3128;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
a { color: var(--leaf); }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--maize); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- Chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--leaf); color: var(--leaf-ink);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand img { border-radius: 7px; box-shadow: 0 0 0 1.5px rgba(255,255,255,.35); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  background: rgba(255,255,255,.16); color: inherit; text-decoration: none;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok::before { background: #9fe0a8; }
.pill.wait { background: var(--maize); color: #2b2112; }
.pill.bad { background: var(--rust); color: #fff; }
.banner { background: var(--maize-soft); color: var(--ink); padding: 8px 16px; font-size: .9rem; border-bottom: 1px solid var(--line); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface); border-top: 1px solid var(--line);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-2); text-decoration: none; font-size: .75rem; font-weight: 600;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--leaf); }
.nav a.primary span.icon {
  display: grid; place-items: center; width: 44px; height: 32px; border-radius: 16px;
  background: var(--leaf); color: var(--leaf-ink);
}

main { max-width: 960px; margin: 0 auto; padding: 20px 16px 32px; outline: none; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .nav {
    top: 52px; right: auto; bottom: 0; width: 200px; height: auto;
    grid-auto-flow: row; grid-auto-rows: 52px; align-content: start;
    padding: 16px 10px; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; border-radius: var(--r-md); font-size: .95rem; }
  .nav a[aria-current="page"] { background: var(--leaf-soft); }
  .nav a.primary span.icon { width: 24px; height: 24px; border-radius: 6px; }
  .nav a.primary span.icon svg { width: 18px; height: 18px; }
  main { margin-left: 200px; margin-right: 0; padding: 28px 32px 48px; max-width: 1000px; }
}

/* ---------- Page structure ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { color: var(--ink-2); margin-top: 4px; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 10px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.panel-pad { padding: 16px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* ---------- The bag tag (signature element) ---------- */
.tag {
  --hole: 7px;
  position: relative; display: inline-flex; align-items: center;
  padding: 3px 10px 3px calc(var(--hole) * 2 + 10px);
  background: var(--kraft); color: var(--kraft-ink);
  font: 700 1rem/1.25 var(--font-code); letter-spacing: .04em; font-variant-numeric: tabular-nums;
  border-radius: 4px 4px 4px 4px;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 10px 100%, 0 50%);
  text-decoration: none; white-space: nowrap;
}
.tag::before {
  content: ""; position: absolute; left: 11px; top: 50%;
  width: var(--hole); height: var(--hole); margin-top: calc(var(--hole) / -2);
  border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1.5px rgba(43,33,18,.45);
}
.tag-lg { --hole: 12px; font-size: clamp(1.6rem, 6vw, 2.4rem); padding: 8px 18px 8px 48px; clip-path: polygon(22px 0, 100% 0, 100% 100%, 22px 100%, 0 50%); }
.tag-lg::before { left: 20px; }
.tag.closed { filter: saturate(.25); opacity: .8; }

/* ---------- Status ---------- */
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 650; white-space: nowrap; }
.status.active { background: var(--leaf-soft); color: var(--leaf); }
.status.in_transit { background: var(--maize-soft); color: var(--ink); box-shadow: inset 3px 0 0 var(--maize); }
.status.closed { background: var(--muted-soft); color: var(--ink-2); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 1rem var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
.btn-primary:hover { background: var(--leaf); filter: brightness(1.08); }
.btn-danger { color: var(--rust); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: progress; }

.form { display: grid; gap: 16px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .95rem; }
.field > small { color: var(--ink-2); font-size: .85rem; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 1rem var(--font);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--leaf); outline-offset: 0; border-color: var(--leaf); }
.input-row { display: flex; gap: 8px; }
.input-row > input { flex: 1; }
.code-input { font: 700 1.15rem var(--font-code); letter-spacing: .05em; text-transform: uppercase; }
.form-error { background: var(--rust-soft); color: var(--rust); padding: 10px 12px; border-radius: var(--r-sm); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 .9rem var(--font); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Dashboard ---------- */
.counts { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
@media (min-width: 640px) { .counts { grid-template-columns: repeat(4, 1fr); } }
.counts a { padding: 14px 16px; color: inherit; text-decoration: none; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.counts a:hover { background: var(--surface-2); }
.counts b { display: block; font: 700 1.9rem/1.1 var(--font-code); font-variant-numeric: tabular-nums; }
.counts span { color: var(--ink-2); font-size: .9rem; }
.counts a.transit b { color: var(--maize); }

.stock-loc + .stock-loc { border-top: 1px solid var(--line); }
.stock-loc { padding: 12px 16px; }
.stock-loc h3 { margin-bottom: 6px; }
.stock-line { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.qty { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.lot-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 14px;
  padding: 12px 16px; color: inherit; text-decoration: none;
}
.lot-row:hover { background: var(--surface-2); }
.lot-row .meta { min-width: 0; }
.lot-row .meta div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) {
  .lot-row { grid-template-columns: 1fr auto; }
  .lot-row .meta { grid-column: 1 / -1; grid-row: 2; }
}
.activity { padding: 10px 16px; display: grid; gap: 2px; }
.activity .when { color: var(--ink-2); font-size: .85rem; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-2); }
.empty .btn { margin-top: 12px; }

/* ---------- Lot detail ---------- */
.lot-hero { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .lot-hero { grid-template-columns: 1fr 180px; } }
.lot-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; margin-top: 18px; }
.lot-facts dt { color: var(--ink-2); font-size: .85rem; }
.lot-facts dd { margin: 0; font-weight: 600; }
.lot-qty { font: 700 2rem/1.1 var(--font-code); font-variant-numeric: tabular-nums; margin-top: 14px; }
.lot-qty small { font: 600 1rem var(--font); color: var(--ink-2); margin-left: 6px; }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px; display: grid; gap: 8px; justify-items: center; align-self: start; }
.qr-box img { width: 150px; height: 150px; image-rendering: pixelated; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 22px 28px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: -6px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--leaf); }
.timeline li.e-dispatch::after { border-color: var(--maize); }
.timeline li.e-close::after { border-color: var(--ink-2); background: var(--ink-2); }
.timeline .t-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.timeline .t-body { color: var(--ink-2); font-size: .92rem; margin-top: 4px; display: grid; gap: 2px; }
.timeline .t-body strong { color: var(--ink); font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 650; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Settings ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 10px 14px; color: var(--ink-2); text-decoration: none; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--leaf); }
.ref-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px; }
.ref-row.inactive .ref-name { text-decoration: line-through; color: var(--ink-2); }
.ref-row .ref-main { flex: 1; min-width: 180px; }
.ref-edit { padding: 16px; background: var(--surface-2); }

/* ---------- Scanner ---------- */
.scanner { position: relative; background: #000; border-radius: var(--r-md); overflow: hidden; aspect-ratio: 1 / 1; max-width: 420px; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner::after { content: ""; position: absolute; inset: 18%; border: 3px solid var(--kraft); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--r-md);
  font-weight: 600; max-width: min(92vw, 480px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--rust); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ---------- Login ---------- */
.login { min-height: 70vh; display: grid; place-items: center; }
.login .panel { width: min(100%, 400px); padding: 28px 24px; }
.login h1 { margin-bottom: 4px; }

/* ---------- Print label ---------- */
.label-sheet { background: #fff; color: #000; width: 100mm; padding: 6mm; border: 1px dashed #999; display: grid; grid-template-columns: 34mm 1fr; gap: 5mm; align-items: center; }
.label-sheet img { width: 34mm; height: 34mm; image-rendering: pixelated; }
.label-sheet .l-code { font: 700 18pt/1.1 var(--font-code); letter-spacing: .03em; }
.label-sheet .l-line { font-size: 10pt; margin-top: 1.5mm; }

@media print {
  body { background: #fff; padding: 0; }
  .topbar, .nav, .banner, .toast, .no-print { display: none !important; }
  main { margin: 0; padding: 0; max-width: none; }
  .label-sheet { border: 0; }
}

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

/* Fixes after visual review */
main:focus, main:focus-visible { outline: none; }
.lot-row > .tag { justify-self: start; }
.code-input::placeholder { text-transform: none; letter-spacing: normal; font-weight: 400; }
.filters-selects { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) { .filters-selects { width: 100%; } .filters-selects select { flex: 1; min-width: 0; } }
.ref-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Shipments ---------- */
/* Truck registration rendered as a number plate: the physical thing people look for at the gate. */
.plate {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px; min-width: 96px;
  background: #fff; color: #000; border: 2px solid #000; border-radius: 5px;
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px rgba(0,0,0,.25);
  font: 700 .95rem/1.2 var(--font-code); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
.plate-lg { font-size: 1.5rem; padding: 6px 16px; border-width: 3px; }

.ship-row { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 14px; align-items: center; padding: 12px 16px; color: inherit; text-decoration: none; }
.ship-row:hover { background: var(--surface-2); }
.ship-row .meta { min-width: 0; }
@media (max-width: 520px) {
  .ship-row { grid-template-columns: auto 1fr; }
  .ship-row .ship-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .ship-row .meta { grid-column: 1 / -1; }
  .ship-row > .plate { justify-self: start; }
}

.status.on_road { background: var(--maize-soft); color: var(--ink); box-shadow: inset 3px 0 0 var(--maize); }
.status.stopped { background: var(--maize); color: #2b2112; }
.status.overdue { background: var(--rust); color: #fff; }
.status.disc { background: var(--rust-soft); color: var(--rust); box-shadow: inset 3px 0 0 var(--rust); }
.status.resolved { background: var(--muted-soft); color: var(--ink-2); }
.status.arrived { background: var(--leaf-soft); color: var(--leaf); }

.counts a.bad b { color: var(--rust); }
.text-ok { color: var(--leaf); font-weight: 650; }
.text-bad { color: var(--rust); font-weight: 650; }

.alert { padding: 14px 16px; border-radius: var(--r-md); border-left: 5px solid; }
.alert-ok { background: var(--leaf-soft); border-color: var(--leaf); }
.alert-bad { background: var(--rust-soft); border-color: var(--rust); }
.alert-muted { background: var(--muted-soft); border-color: var(--ink-2); }

.timeline li.j-depart::after { background: var(--leaf); }
.timeline li.j-stop::after { border-color: var(--maize); width: 12px; height: 12px; left: 2px; top: 5px; }
.timeline li.j-stop.flag::after { border-color: var(--rust); }
.timeline li.j-stop.ongoing::after { background: var(--maize); }
.timeline li.j-arrive::after { background: var(--leaf); border-color: var(--leaf); }
.timeline li.j-pending::after { border-style: dashed; border-color: var(--ink-2); }

.load-line { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
@media (min-width: 640px) { .load-line { grid-template-columns: 1fr 180px auto; align-items: end; } .load-line .line-hint { grid-column: 1 / -1; } }

.choice-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chips label { position: relative; }
.choice-chips input { position: absolute; opacity: 0; inset: 0; }
.choice-chips span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600; cursor: pointer; }
.choice-chips input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.choice-chips input:focus-visible + span { outline: 3px solid var(--maize); outline-offset: 2px; }

.all-arrived { min-height: 56px; font-size: 1.1rem; border: 2px solid var(--leaf); color: var(--leaf); background: var(--surface); }
.arr-item { display: grid; gap: 12px; }
.arr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.arr-diff { font-size: 1.05rem; min-height: 1.5em; }
.arr-summary { font-size: 1.05rem; margin: 4px 0; }

/* Six nav items on phones */
@media (max-width: 899px) { .nav a { font-size: .7rem; } }
/* Load table stacks into label/value rows on phones */
@media (max-width: 640px) {
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
  .stack-table tr { padding: 10px 4px; border-bottom: 1px solid var(--line); }
  .stack-table td { border: 0; padding: 4px 12px; text-align: left; }
  .stack-table td[data-label] { display: flex; justify-content: space-between; gap: 12px; }
  .stack-table td[data-label]::before { content: attr(data-label); color: var(--ink-2); font-weight: 400; }
}
.status.disc { box-shadow: none; border: 1px solid var(--rust); }
@media (max-width: 640px) { .stack-table .reason-cell { text-align: right; max-width: 65%; } }

/* ---------- TrackHarvest additions ---------- */
.map { height: 340px; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); z-index: 0; }
@media (min-width: 900px) { .map { height: 420px; } }
.leaflet-container { font: inherit; }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-top: 8px; }
.map-legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.map-legend .lg-route { background: #2f5d3a; border-radius: 2px; height: 4px; width: 16px; vertical-align: 3px; }
.map-legend .lg-planned { border-top: 2px dashed #7a8574; border-radius: 0; height: 0; width: 16px; vertical-align: 3px; }
.map-legend .lg-truck { background: #e3a812; }
.map-legend .lg-alert { background: #a7432c; }

/* The handover code: the one thing the driver must be able to read out at the gate. */
.handover { border: 2px dashed var(--kraft); border-radius: var(--r-md); padding: 12px 16px; background: var(--surface); }
.handover-code { font: 700 2.4rem/1.1 var(--font-code); letter-spacing: .12em; font-variant-numeric: tabular-nums; margin: 4px 0; }

.alert-row { display: grid; gap: 10px; padding: 14px 16px; border-left: 4px solid var(--line); }
.alert-row.sev-high { border-left-color: var(--rust); }
.alert-row.sev-medium { border-left-color: var(--maize); }
.alert-row p { margin: 4px 0 0; }
.alert-row .plate { font-size: .8rem; min-width: 0; padding: 1px 8px; }

.metrics { display: grid; grid-template-columns: 1fr; margin: 0; }
@media (min-width: 640px) { .metrics { grid-template-columns: repeat(4, 1fr); } }
.metrics > div { padding: 14px 16px; border-bottom: 1px solid var(--line); }
@media (min-width: 640px) { .metrics > div { border-bottom: 0; border-right: 1px solid var(--line); } .metrics > div:last-child { border-right: 0; } }
.metrics dt { color: var(--ink-2); font-size: .9rem; }
.metrics dd { margin: 2px 0; font: 700 1.7rem/1.15 var(--font-code); font-variant-numeric: tabular-nums; }
.metrics p { color: var(--ink-2); font-size: .82rem; }

.tracker-panel strong { font-size: 1.05rem; }
.trip-card h2 { font-size: 1.25rem; }
.row-bad td { background: var(--rust-soft); }
.audit-data { white-space: pre-wrap; word-break: break-word; font-size: .78rem; color: var(--ink-2); }

/* ---------- Activity ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.health { list-style: none; margin: 0; padding: 4px 0; }
.health li { display: grid; grid-template-columns: 22px 1fr; align-items: baseline; gap: 4px; padding: 8px 16px; }
.health .h-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--leaf); }
.health .h-warn .h-dot { background: var(--maize); }
.health .h-bad .h-dot { background: var(--rust); }
.health .h-bad { color: var(--rust); font-weight: 600; }

/* One colour per kind of activity, shared by the chart, legend and log. */
:root { --c-batches: var(--leaf); --c-shipments: var(--maize); --c-alerts: var(--rust); --c-sms: var(--kraft); --c-settings: var(--ink-2); --c-signins: #6f8796; }
.bar-batches { fill: var(--c-batches); background: var(--c-batches); }
.bar-shipments { fill: var(--c-shipments); background: var(--c-shipments); }
.bar-alerts { fill: var(--c-alerts); background: var(--c-alerts); }
.bar-sms { fill: var(--c-sms); background: var(--c-sms); }
.bar-settings { fill: var(--c-settings); background: var(--c-settings); }
.bar-signins { fill: var(--c-signins); background: var(--c-signins); }
.activity-chart { width: 100%; overflow: hidden; }
.activity-chart svg { display: block; }
.activity-chart .grid { stroke: var(--line); stroke-width: 1; }
.activity-chart .axis { fill: var(--ink-2); font-size: 11px; font-family: var(--font); }
.activity-chart .hit { fill: transparent; }
.activity-chart .hit:hover { fill: var(--ink); fill-opacity: .06; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .88rem; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.activity-cols { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .activity-cols { grid-template-columns: 1fr 1fr; } }
.activity-cols h2 { margin-bottom: 10px; }
.people li { padding: 10px 16px; }
.pbar { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.pbar span { display: block; height: 100%; background: var(--leaf); border-radius: 3px; }
.signin-failed strong { color: var(--rust); }

.log-filters { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 10px 0 12px; align-items: end; }
.log-filters input[type=search] { grid-column: 1 / -1; order: -1; }
.log-filters label { display: grid; gap: 4px; min-width: 0; }
@media (min-width: 900px) { .log-filters { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.log-day { padding: 14px 16px 6px; font-weight: 650; border-top: 1px solid var(--line); background: var(--surface-2); }
.log-day:first-child { border-top: 0; border-radius: var(--r-md) var(--r-md) 0 0; }
.log-row { display: grid; grid-template-columns: 74px 1fr auto; gap: 2px 12px; padding: 10px 16px 10px 13px; border-top: 1px solid var(--line); border-left: 3px solid var(--c-settings); align-items: baseline; }
.log-row time { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: .88rem; }
.log-row .log-cat { grid-column: 2; grid-row: 2; color: var(--ink-2); font-size: .8rem; }
.log-row .log-open { grid-column: 3; grid-row: 1 / span 2; align-self: center; font-size: .9rem; }
.log-row.cat-batches { border-left-color: var(--c-batches); }
.log-row.cat-shipments { border-left-color: var(--c-shipments); }
.log-row.cat-alerts { border-left-color: var(--c-alerts); }
.log-row.cat-sms { border-left-color: var(--c-sms); }
.log-row.cat-signins { border-left-color: var(--c-signins); }
.log-row.signin-failed { background: var(--rust-soft); }
