/* Stowline — application shell. Built on industry.css tokens.
   Adapted from the Stowline design (claude.ai/design); the mockup's D3 map is
   replaced with a real Leaflet + CARTO/OSM map. */

:root {
  --warn: oklch(0.50 0.145 32);
  --warn-500: oklch(0.62 0.145 32);
  --warn-300: oklch(0.84 0.075 32);
  --warn-100: oklch(0.945 0.028 32);
  --ok-500: oklch(0.62 0.11 155);
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --rail: 348px;
  --drawer: 392px;
}
html, body { height: 100%; }
body { overflow: hidden; }

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; }
.kick {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 48%, transparent);
}
.dim { color: color-mix(in srgb, var(--color-text) 52%, transparent); }

/* ── app shell ─────────────────────────────────────────────────── */
.app {
  height: 100vh; display: grid; grid-template-rows: auto 1fr;
}
.topbar {
  display: flex; align-items: center; gap: var(--space-6);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--color-divider);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: var(--space-4); flex: none; }
.brand .mk { width: 22px; height: 22px; border: 1px solid var(--color-accent); position: relative; }
.brand .mk::after { content: ""; position: absolute; inset: 5px; background: var(--color-accent); }
.brand b { font-family: var(--font-heading); font-weight: 700; font-size: 19px; letter-spacing: 0.02em; }

.tabs { display: flex; align-items: stretch; gap: 0; margin-right: auto; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  font-family: var(--font-heading); font-weight: 600; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
  padding: 8px 14px; display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
.tab:hover { color: var(--color-text); background: color-mix(in srgb, var(--color-text) 5%, transparent); }
.tab[aria-selected="true"] { color: var(--color-accent-800); border-bottom-color: var(--color-accent); }
.tab-ic { display: none; } /* shown only in the mobile bottom nav */
.pill {
  font-family: var(--mono); font-size: 10px; padding: 1px 5px;
  border: 1px solid var(--color-divider); color: var(--color-accent-800);
  background: var(--color-accent-100);
}
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; white-space: nowrap; flex: none; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--color-neutral-500); }
.status-dot.live::before { background: var(--ok-500); }
.status-dot.stale::before { background: var(--warn-500); }

/* ── workspace ─────────────────────────────────────────────────── */
.workspace { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 0; }
.rail {
  border-right: 1px solid var(--color-divider);
  display: grid; grid-template-rows: auto auto 1fr auto; min-height: 0;
}
.rail-head { padding: var(--space-4) var(--space-4) var(--space-3); }
.searchwrap { position: relative; }
.searchwrap svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%); pointer-events: none;
  color: color-mix(in srgb, var(--color-text) 45%, transparent);
}
.searchwrap .input { padding-left: 30px; }
.filters { display: flex; gap: var(--space-2); padding: 0 var(--space-4) var(--space-3); flex-wrap: wrap; }
.chip {
  appearance: none; cursor: pointer; font-family: var(--font-heading); font-weight: 600; font-size: 12px;
  letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 9px; background: transparent;
  border: 1px solid var(--color-divider); color: color-mix(in srgb, var(--color-text) 65%, transparent);
}
.chip:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); color: var(--color-text); }
.chip[aria-pressed="true"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg); }
.rail-list { overflow: auto; padding: 8px var(--space-4) var(--space-6); display: flex; flex-direction: column; gap: 12px; }
.rail-foot {
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-divider);
  display: flex; align-items: center; gap: var(--space-3);
}
.rail-empty { font-size: 13px; padding: var(--space-6) var(--space-2); color: color-mix(in srgb, var(--color-text) 60%, transparent); line-height: 1.6; }
.rail-handle { display: none; } /* shown only as the mobile bottom-sheet grip */

/* ── vessel card ───────────────────────────────────────────────── */
.vcard {
  cursor: pointer; padding: var(--space-3); display: grid; gap: var(--space-2); background: transparent;
  text-align: left; font: inherit; color: inherit; border: 1px solid var(--color-divider); width: 100%;
}
.vcard:hover { background: color-mix(in srgb, var(--color-accent) 7%, transparent); }
.vcard[aria-current="true"] { border-color: var(--color-accent); box-shadow: inset 0 0 0 1px var(--color-accent); }
.vcard .top { display: flex; align-items: flex-start; gap: var(--space-2); }
.vcard .nm { font-family: var(--font-heading); font-weight: 600; font-size: 17px; line-height: 1.1; flex: 1; }
.vcard .row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.leg { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.leg .arrow { flex: none; color: color-mix(in srgb, var(--color-text) 40%, transparent); }
.meter { height: 3px; background: color-mix(in srgb, var(--color-text) 12%, transparent); position: relative; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--color-accent); }
.navchip {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.04em; padding: 2px 6px; border: 1px solid var(--color-divider); white-space: nowrap;
}
.navchip.nopos { border-color: var(--warn-300); background: var(--warn-100); color: var(--warn); }
.wxchip {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.04em; padding: 2px 6px; border: 1px solid var(--color-divider); white-space: nowrap;
}
.wxchip svg { flex: none; }
.wxchip.wet { border-color: var(--warn-300); background: var(--warn-100); color: var(--warn); }
.flagbar {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; font-size: 12px; margin-top: 8px;
  border: 1px solid var(--warn-300); background: var(--warn-100); color: var(--warn);
}
.flagbar svg { flex: none; }
.flagbar b { font-family: var(--font-heading); letter-spacing: 0.03em; }

/* ── stage / map ───────────────────────────────────────────────── */
.stage { position: relative; min-width: 0; overflow: hidden; }
.view { position: absolute; inset: 0; display: none; }
.view[data-on] { display: block; }
.view.scroll { overflow: auto; }
#map { position: absolute; inset: 0; background: var(--color-bg); }

/* Mute the basemap so vessels/routes read on top. */
/* Push the OSM basemap towards a muted, blueprint-ish grey so vessels read. */
.leaflet-tile-pane { filter: saturate(0.32) brightness(1.06) contrast(0.92); }
.leaflet-container { background: #dfe3e6; font: inherit; }
.leaflet-bar a { border-radius: 0 !important; color: var(--color-text); }
.leaflet-control-attribution { font-size: 9px; background: color-mix(in srgb, var(--color-bg) 82%, transparent) !important; }

.marker-vessel { }
.marker-vessel svg { display: block; overflow: visible; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.marker-vessel .hull { fill: var(--color-accent-800); stroke: var(--color-bg); stroke-width: 1; }
.marker-vessel.moored .hull { fill: var(--color-neutral-600); }
.marker-vessel.on .hull { fill: var(--color-accent); }
.marker-port {
  width: 9px; height: 9px; background: var(--color-bg); border: 1.5px solid var(--color-text);
}
.marker-port.load { border-color: var(--color-accent-700); }
.marker-port.discharge { border-color: var(--color-accent-700); background: var(--color-accent-700); }
.marker-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--color-text); background: color-mix(in srgb, var(--color-bg) 80%, transparent);
  padding: 1px 4px; white-space: nowrap; transform: translateX(8px);
}

.overlay {
  position: absolute; z-index: 500;
  background: color-mix(in srgb, var(--color-bg) 90%, transparent);
  backdrop-filter: blur(2px); border: 1px solid var(--color-divider);
}
.mapctl { top: var(--space-4); left: var(--space-4); padding: var(--space-3); display: grid; gap: 9px; width: 190px; }
.tog { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; cursor: pointer; }
.tog input { position: absolute; opacity: 0; pointer-events: none; }
.tog .sw { width: 26px; height: 14px; border: 1px solid var(--color-divider); position: relative; flex: none; }
.tog .sw::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 8px; height: 8px;
  background: color-mix(in srgb, var(--color-text) 45%, transparent); transition: .14s;
}
.tog input:checked + .sw { border-color: var(--color-accent); }
.tog input:checked + .sw::after { left: 14px; background: var(--color-accent); }
.legend { bottom: var(--space-6); left: var(--space-4); padding: var(--space-3); display: grid; gap: 7px; }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend .sw-line { width: 22px; height: 0; border-top: 2px solid var(--color-accent-700); }
.legend .sw-line.future { border-top-style: dashed; }
.legend .sw-dot { width: 10px; height: 10px; background: var(--color-accent-800); }
.legend .sw-sq { width: 10px; height: 10px; border: 1.5px solid var(--color-text); }
.legend .sw-ring { width: 12px; height: 12px; border-radius: 50%; border: 1.5px dashed var(--warn-500); }

/* ── drawer ────────────────────────────────────────────────────── */
.drawer {
  position: absolute; z-index: 600; top: 0; right: 0; bottom: 0; width: var(--drawer);
  background: var(--color-bg); border-left: 1px solid var(--color-divider);
  display: grid; grid-template-rows: auto 1fr auto; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .18s ease; overflow: hidden;
}
.drawer[data-open] { transform: none; }
.dhead { padding: var(--space-4); border-bottom: 1px solid var(--color-divider); display: grid; gap: var(--space-2); }
.dbody { overflow: auto; padding: var(--space-4); display: grid; gap: var(--space-6); align-content: start; }
.dfoot { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-divider); display: flex; gap: var(--space-2); }
.xbtn {
  appearance: none; background: none; border: 1px solid var(--color-divider); width: 28px; height: 28px;
  cursor: pointer; display: grid; place-items: center; flex: none;
}
.xbtn:hover { background: color-mix(in srgb, var(--color-text) 8%, transparent); }
.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--color-divider); border: 1px solid var(--color-divider); }
.specs > div { background: var(--color-bg); padding: 9px 10px; }
.specs .v { font-family: var(--font-heading); font-size: 17px; line-height: 1.15; }
.section-t {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding-bottom: 6px; border-bottom: 1px solid var(--color-divider); margin-bottom: var(--space-3);
}
.kv { display: grid; grid-template-columns: 116px 1fr; gap: 7px var(--space-3); font-size: 13.5px; }
.kv dt {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 50%, transparent); padding-top: 3px;
}
.kv dd { margin: 0; }
.note { font-size: 13px; padding: var(--space-3); border: 1px solid var(--color-divider); background: color-mix(in srgb, var(--color-text) 3%, transparent); }
.wxnow { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.wxnow svg { flex: none; }
.wxnow b { font-family: var(--font-heading); font-weight: 600; }
.wxnow.wet { color: var(--warn); }

/* weather day strip */
.strip { display: flex; gap: 4px; flex-wrap: wrap; }
.day {
  width: 46px; border: 1px solid var(--color-divider); display: grid; gap: 2px;
  justify-items: center; padding: 5px 2px 6px;
}
.day .dw {
  font-family: var(--mono); font-size: 9px; letter-spacing: .06em;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.day .dn { font-family: var(--font-heading); font-size: 16px; line-height: 1; }
.day .mm { font-family: var(--mono); font-size: 8.5px; color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.day.wet { border-color: var(--warn); background: var(--warn-100); color: var(--warn); }
.day.wet .dw, .day.wet .mm { color: var(--warn); }
.day.past { opacity: .45; }
.day.blank { opacity: .4; border-style: dashed; }
/* a day past the declared window while the op is still running */
.day.overrun { border-top: 2px solid var(--warn); opacity: 1; }
.day.overrun.past { opacity: .7; }
.risk { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; }
.risk i { width: 26px; height: 4px; background: color-mix(in srgb, var(--color-text) 14%, transparent); position: relative; }
.risk i::after { content: ""; position: absolute; inset: 0 auto 0 0; background: var(--color-accent); }
.risk.hi i::after { width: 100%; background: var(--warn-500); }
.risk.mid i::after { width: 55%; }
.risk.low i::after { width: 22%; }

/* ── table view ────────────────────────────────────────────────── */
.viewpad { padding: var(--space-6); }
.viewhead { display: flex; align-items: flex-end; gap: var(--space-4); margin-bottom: var(--space-4); }
.viewhead h2 { margin: 0; }
.table td, .table th { white-space: nowrap; }
.table tbody tr { cursor: pointer; }
.table .num { font-family: var(--mono); font-size: 12px; }
.table .group-row td {
  cursor: default; padding-top: var(--space-6); padding-bottom: 4px;
  border-bottom: 1px solid var(--color-divider);
}
.table .group-row:first-child td { padding-top: var(--space-2); }
.table .group-row:hover td { background: none; }
.table tr.hist td { color: color-mix(in srgb, var(--color-text) 60%, transparent); }
.table tr.hist:hover td { color: var(--color-text); }
.tag-ok { background: color-mix(in srgb, var(--ok-500) 16%, transparent); color: var(--ok-500); }

/* ── schedule / gantt ──────────────────────────────────────────── */
.gantt { border: 1px solid var(--color-divider); overflow-x: auto; }
.grow {
  display: grid; grid-template-columns: 220px 1fr; min-width: 900px;
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}
.grow:last-child { border-bottom: 0; }
.grow[data-ref] { cursor: pointer; }
.grow[data-ref]:hover .gtrack { background: color-mix(in srgb, var(--color-text) 3%, transparent); }
.grow[aria-current="true"] { box-shadow: inset 2px 0 0 var(--color-accent); }
.glabel { padding: 10px var(--space-3); border-right: 1px solid var(--color-divider); display: grid; gap: 2px; align-content: center; }
.glabel .p { font-family: var(--font-heading); font-size: 15px; line-height: 1.1; }
.gtrack {
  position: relative; display: grid; align-items: center; min-height: 52px;
  background-image: linear-gradient(to right,
    color-mix(in srgb, var(--color-text) 8%, transparent) 0 1px, transparent 1px 100%);
}
.ghead { position: sticky; top: 0; z-index: 3; background: var(--color-bg); border-bottom: 1px solid var(--color-divider); }
.ghead .gtrack { min-height: 34px; background-image: none; }
.gd {
  grid-row: 1; display: grid; place-items: center; font-family: var(--mono); font-size: 9.5px;
  color: color-mix(in srgb, var(--color-text) 52%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}
.gd.we { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.gbar {
  grid-row: 1; height: 24px; display: flex; align-items: center; gap: 5px; padding: 0 7px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .05em; overflow: hidden;
  position: relative; z-index: 1; white-space: nowrap; border: 1px solid var(--color-accent-700);
}
.gbar.load { background: var(--color-accent-800); color: var(--color-bg); border-color: var(--color-accent-800); }
.gbar.disch {
  background: transparent; color: var(--color-accent-800);
  background-image: repeating-linear-gradient(45deg,
    color-mix(in srgb, var(--color-accent) 22%, transparent) 0 3px, transparent 3px 6px);
}
.gbar.flag { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.gnow { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--warn-500); z-index: 2; }
.gnow::after {
  content: "NOW"; position: absolute; top: -1px; left: 3px; font-family: var(--mono); font-size: 8.5px;
  letter-spacing: .1em; color: var(--warn);
}
.gnow.mute::after { content: none; }
.gflag {
  grid-row: 1; justify-self: center; z-index: 2; pointer-events: none; color: var(--warn);
  display: grid; place-items: center;
}
.gempty { grid-column: 1 / -1; padding: var(--space-4); font-size: 13px; }

/* ── alerts ────────────────────────────────────────────────────── */
.alist { display: grid; gap: var(--space-3); max-width: 860px; }
.alist-empty { font-size: 13px; color: color-mix(in srgb, var(--color-text) 55%, transparent); padding: var(--space-4) 0; }
.alerts-group + .alerts-group { margin-top: var(--space-6); }
.alerts-head {
  font-family: var(--font-heading); font-weight: 600; font-size: 14px; letter-spacing: 0.03em;
  text-transform: uppercase; padding-bottom: var(--space-2); margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-divider); max-width: 860px;
}
.alerts-head .dim { font-family: var(--mono); font-weight: 400; font-size: 11px; }
.alert {
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); padding: var(--space-3);
  border: 1px solid var(--color-divider); align-items: start; cursor: pointer; text-align: left;
  background: transparent; font: inherit; color: inherit; width: 100%;
}
.alert:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.alert .ic { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--color-divider); }
.alert.hi .ic { border-color: var(--warn-300); background: var(--warn-100); color: var(--warn); }
.alert h4 { margin: 0 0 3px; }
.alert .ab { font-family: var(--mono); font-size: 11px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }

/* ── dialog ────────────────────────────────────────────────────── */
.dialog-backdrop { display: none; z-index: 900; }
.dialog-backdrop[data-open] { display: grid; }
/* industry.css makes .dialog transparent for the blueprint sheet; over a live
   scrim it needs a solid ground so the fields don't float. */
.dialog {
  width: min(680px, 100%); max-height: 88vh; overflow: auto;
  background: var(--color-bg); box-shadow: var(--shadow-lg);
}
.dialog .input { background: var(--color-surface); }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4); }
.formgrid .wide { grid-column: 1 / -1; }
.formgrid .sub { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.form-errors { grid-column: 1 / -1; border: 1px solid var(--warn-300); background: var(--warn-100); color: var(--warn); padding: var(--space-2) var(--space-3); font-size: 13px; }
.btn-danger { border-color: var(--warn-300); color: var(--warn); }
.btn-danger:hover { background: var(--warn-100); }

/* vessel name typeahead */
.field.combo { position: relative; }
.combo-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 30;
  background: var(--color-bg); border: 1px solid var(--color-accent);
  max-height: 244px; overflow: auto; box-shadow: var(--shadow-md);
}
.combo-opt {
  display: grid; gap: 1px; width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: none; border: 0; padding: 7px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}
.combo-opt:last-child { border-bottom: 0; }
.combo-opt:hover, .combo-opt.active { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.combo-nm { font-family: var(--font-heading); font-size: 14px; line-height: 1.1; }
.combo-sub { font-family: var(--mono); font-size: 10px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.combo-empty { padding: 9px 10px; font-size: 12px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.combo-hint { font-family: var(--mono); font-size: 10px; margin-top: 4px; min-height: 13px; color: var(--color-accent-700); }
.combo-hint.cleared { color: color-mix(in srgb, var(--color-text) 45%, transparent); }

.hidden { display: none !important; }

/* ── topbar user menu ──────────────────────────────────────────── */
.usermenu { display: flex; align-items: center; gap: var(--space-3); flex: none; }
.usermenu .who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; white-space: nowrap; }
.usermenu a.who { color: var(--color-text); text-decoration: none; }
.usermenu a.who:hover b { color: var(--color-accent-700); }
.usermenu .who b { font-family: var(--font-heading); font-weight: 600; font-size: 13px; }
.usermenu form { margin: 0; }

/* ── flash messages ────────────────────────────────────────────── */
.flash-stack {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  pointer-events: none;
}
.flash {
  pointer-events: auto; max-width: min(720px, 92vw);
  padding: var(--space-2) var(--space-4); font-size: 13px;
  border: 1px solid var(--color-divider); border-top: 0;
  background: var(--color-surface); color: var(--color-text);
}
.flash-notice { border-color: var(--ok-500); background: color-mix(in srgb, var(--ok-500) 12%, var(--color-surface)); }
.flash-alert { border-color: var(--warn-500); background: var(--warn-100); color: var(--warn); }

/* ── standalone auth pages (login, signup, password reset) ─────── */
html:has(.auth) body,
html:has(.adminwrap) body { overflow: auto; }

/* ── admin screens ─────────────────────────────────────────────── */
.adminwrap { max-width: 960px; margin: 0 auto; padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); }
.adminwrap h1 { font-size: 22px; margin: 0; }
.adminwrap h2 { font-size: 15px; margin: 0 0 var(--space-2); }
.admin-panel { border: 1px solid var(--color-divider); padding: var(--space-4); }
.admin-panel form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); margin: 0; }
.admin-panel .field { flex: 1 1 200px; display: flex; flex-direction: column; }
.admin-panel .field > label { font-size: 12px; margin-bottom: 5px; color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.admin-code { font-family: var(--mono); font-size: 11px; word-break: break-all; }
.tag-used { color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.tag-live { color: var(--ok-500); }
.adminwrap .table td .btn { padding-block: 2px; }

/* ── settings ──────────────────────────────────────────────────── */
.admin-panel form.stacked-form {
  display: flex; flex-direction: column; align-items: stretch;
  gap: var(--space-3); max-width: 360px;
}
.admin-panel form.stacked-form .field { flex: none; }
.admin-panel form.stacked-form .btn { align-self: flex-start; }
.settings-list { margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.settings-list > div { display: flex; gap: var(--space-4); }
.settings-list dt { flex: none; width: 96px; font-size: 12px; color: color-mix(in srgb, var(--color-text) 60%, transparent); }
.settings-list dd { margin: 0; font-size: 14px; }
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: var(--space-6);
  background:
    repeating-linear-gradient(0deg, transparent 0 39px, color-mix(in srgb, var(--color-text) 4%, transparent) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, color-mix(in srgb, var(--color-text) 4%, transparent) 39px 40px),
    var(--color-bg);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--color-surface);
  border: 1px solid var(--color-divider); padding: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand .mk { width: 22px; height: 22px; border: 1px solid var(--color-accent); position: relative; }
.auth-brand .mk::after { content: ""; position: absolute; inset: 5px; background: var(--color-accent); }
.auth-brand b { font-family: var(--font-heading); font-weight: 700; font-size: 19px; letter-spacing: 0.02em; }
.auth-card h1 { font-size: 20px; margin: 0; }
.auth-card p.sub { margin: 0; font-size: 13px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.auth-card form { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; }
.auth-card .field { display: flex; flex-direction: column; }
.auth-card .field > label { font-size: 12px; margin-bottom: 5px; color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.auth-foot { font-size: 12px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
[hidden] { display: none !important; }

/* ══════════════════════════════════════════════════════════════════
   Mobile — narrow viewports only. Desktop rules above are untouched;
   this turns the fleet rail into a bottom sheet, the tabs into a
   bottom nav, and the drawer/dialog into full-screen sheets.
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 860px) {
  :root {
    --bottomnav-h: 56px;
    --rail-peek-h: 160px;
    --safe-b: env(safe-area-inset-bottom, 0px);
  }

  .app { height: 100dvh; }

  /* ── topbar (shared with the admin/settings chrome layout) ───── */
  .topbar { flex-wrap: wrap; row-gap: var(--space-2); padding: var(--space-2) var(--space-3); }
  .brand b { font-size: 16px; }
  .usermenu { gap: var(--space-2); margin-left: auto; }
  .usermenu .who .kick { display: none; }
  .usermenu .who b { font-size: 12px; }
  .usermenu .btn, .usermenu form .btn { padding-inline: 8px; font-size: 12px; }

  /* ── tracking shell only ──────────────────────────────────────── */
  .app .workspace { grid-template-columns: 1fr; }

  /* clock shrinks to just the live/stale dot — the label and the
     "updated …" line take too much space on a phone-width topbar */
  .app .clock { flex-direction: row; align-items: center; }
  .app .clock .kick { display: none; }
  .app .status-dot { font-size: 0; }

  /* "New parcel" becomes a floating action button */
  .app .new-parcel-btn {
    position: fixed; z-index: 620; right: var(--space-3);
    bottom: calc(var(--bottomnav-h) + var(--space-3) + var(--safe-b));
    width: 48px; height: 48px; padding: 0; display: grid; place-items: center;
    box-shadow: var(--shadow-lg); transition: bottom .18s ease;
  }
  .app .new-parcel-btn .btn-label { display: none; }
  .app:has(#view-map[data-on]) .new-parcel-btn {
    bottom: calc(var(--bottomnav-h) + var(--rail-peek-h) + var(--space-3) + var(--safe-b));
  }
  .app:has(.drawer[data-open]) .new-parcel-btn,
  .app:has(.rail[data-sheet]) .new-parcel-btn { display: none; }

  /* tabs relocate to a fixed bottom nav */
  .app .tabs-primary {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 700; margin: 0;
    height: calc(var(--bottomnav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--color-bg); border-top: 1px solid var(--color-divider);
  }
  .app .tabs-primary .tab {
    flex: 1; flex-direction: column; justify-content: center; gap: 3px;
    padding: 5px 2px; border-bottom: 0; text-transform: none;
    font-size: 10px; letter-spacing: 0.02em; font-weight: 500;
  }
  .app .tabs-primary .tab .tab-ic { display: block; }
  .app .tabs-primary .tab .tab-label { display: flex; align-items: center; gap: 3px; }
  .app .tabs-primary .tab .pill { font-size: 8px; padding: 0 4px; }

  /* fleet rail becomes a bottom sheet over the map, peeking by default */
  .app .rail {
    display: none; position: fixed; left: 0; right: 0; z-index: 550;
    bottom: calc(var(--bottomnav-h) + var(--safe-b));
    border-right: 0; border-top: 1px solid var(--color-divider);
    background: var(--color-bg); box-shadow: var(--shadow-lg);
    grid-template-rows: auto auto auto auto;
    max-height: var(--rail-peek-h); transition: max-height .18s ease;
  }
  .app .workspace:has(#view-map[data-on]) .rail { display: grid; }
  .app .rail[data-sheet] { max-height: 78vh; grid-template-rows: auto auto auto 1fr auto; }
  .app .rail-handle {
    appearance: none; font: inherit; display: flex; justify-content: center;
    padding: 8px 0 4px; background: none; border: 0; cursor: pointer;
  }
  .app .rail-handle .grip { width: 36px; height: 4px; background: var(--color-divider); }
  .app .rail-list { display: none; }
  .app .rail[data-sheet] .rail-list { display: flex; }

  /* map overlays: decluttered for a small screen */
  .app .mapctl { width: 152px; padding: var(--space-2); font-size: 12px; }
  .app .legend { display: none; }

  /* vessel/parcel drawer becomes a full-width sheet from the bottom */
  .app .drawer {
    left: 0; right: 0; top: auto; bottom: calc(var(--bottomnav-h) + var(--safe-b)); width: auto; height: 86vh;
    border-left: 0; border-top: 1px solid var(--color-divider);
    transform: translateY(100%); padding-bottom: var(--safe-b);
  }
  .app .drawer[data-open] { transform: none; }

  /* parcel dialog fills the screen */
  .dialog-backdrop { padding: 0; place-items: stretch; }
  .dialog { width: 100%; height: 100%; max-height: 100%; border: 0; }
  .formgrid { grid-template-columns: 1fr; }
  .formgrid .sub { grid-template-columns: 1fr 1fr; }

  /* tables / schedule / detail panels */
  .viewpad { padding: var(--space-4); padding-bottom: calc(var(--bottomnav-h) + var(--space-4) + var(--safe-b)); }
  .viewhead { flex-wrap: wrap; }
  .grow { grid-template-columns: 150px 1fr; min-width: 640px; }
  .kv { grid-template-columns: 96px 1fr; }

  /* admin / settings chrome */
  .adminwrap { padding: var(--space-4); gap: var(--space-4); }
  .admin-panel { overflow-x: auto; }
  .settings-list dt { width: 80px; }
  .auth { padding: var(--space-4); }
  .auth-card { padding: var(--space-5); }
}
