/* Self-hosted so the dashboard works on the jetty LAN without internet. */
@font-face { font-family: "Schibsted Grotesk"; src: url(vendor/fonts/schibsted-grotesk.woff2) format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Martian Mono"; src: url(vendor/fonts/martian-mono.woff2) format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #0b0b0c;
  --app: #111113;
  --panel: #161618;
  --card: #1b1b1e;
  --hover: #222226;
  --line: #26262b;
  --line-2: #303036;
  --ink: #ededf0;
  --ink-2: #b5b5bd;
  --muted: #7d7d87;
  --primary: #3d6ff5;
  --on-primary: #ffffff;
  --green: #2fbf71;
  --blue: #4c8dff;
  --orange: #f2762e;
  --amber: #e9a23b;
  --red: #ef5350;
  --purple: #8b6cf6;
  --teal: #2bb7a6;
  --pink: #e05d9c;
  --in: var(--green);
  --out: var(--blue);
  --stale: #6b6b75;
  --unserviced: var(--amber);
  /* map */
  --water: #0f161e;
  --land: #18181b;
  --land-edge: #2b3540;
  --building: #1f1f23;
  --road: #232328;
  --breakwater: #2d2d33;
  --harbour: #d9dde3;
  --entrance: var(--amber);
  /* surfaces and details that differ between the dark and the light theme */
  --glass: rgba(20,20,22,.88);
  --glass-2: rgba(20,20,22,.9);
  --tip: rgba(22,22,24,.94);
  --attrib: rgba(17,17,19,.8);
  --row-hover: rgba(255,255,255,.015);
  --avatar: #26303a;
  --gate-bg: #14352a; --gate-ink: #6ee7a8; --gate-line: #1f5a43;
  --building-edge: #26262b;
  --hull-edge: rgba(11,11,12,.85);
  --dot-edge: #0b0b0c;
  --bar-off: #2a2a30; --bar-mid: #3a4a6a;
  --sh-1: rgba(0,0,0,.35); --sh-2: rgba(0,0,0,.5); --sh-3: rgba(0,0,0,.6);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Schibsted Grotesk", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, monospace;
  color-scheme: dark;
}

/* Light theme: same layout, type and accents; light surfaces, a light chart and slightly deeper accents
   so coloured text keeps its contrast on white. */
:root[data-theme="light"] {
  --bg: #f3f3f1;
  --app: #f8f8f7;
  --panel: #ffffff;
  --card: #f4f4f5;
  --hover: #ececee;
  --line: #e4e4e8;
  --line-2: #d4d4db;
  --ink: #17171a;
  --ink-2: #484851;
  --muted: #7a7a84;
  --primary: #3461e8;
  --green: #1a9a5a;
  --blue: #2f6fe6;
  --orange: #de6418;
  --amber: #c27c12;
  --red: #d93a37;
  --purple: #6f4ee0;
  --teal: #16958a;
  --pink: #cc4585;
  --stale: #9b9ba4;
  --water: #dce8f1;
  --land: #f1f0ec;
  --land-edge: #c6cdd4;
  --building: #e2e1dc;
  --road: #ffffff;
  --breakwater: #c9ced5;
  --harbour: #39424d;
  --glass: rgba(255,255,255,.9);
  --glass-2: rgba(255,255,255,.94);
  --tip: rgba(255,255,255,.97);
  --attrib: rgba(255,255,255,.85);
  --row-hover: rgba(0,0,0,.025);
  --avatar: #e3e7ec;
  --gate-bg: #e2f4ea; --gate-ink: #16754a; --gate-line: #a9dbc0;
  --building-edge: #cfcec8;
  --hull-edge: rgba(23,23,26,.55);
  --dot-edge: #ffffff;
  --bar-off: #e2e2e6; --bar-mid: #b6c4de;
  --sh-1: rgba(16,24,40,.10); --sh-2: rgba(16,24,40,.16); --sh-3: rgba(16,24,40,.22);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.015em; margin: 0 0 4px; }
h2 { font-size: 20px; margin: 0; } h3, h4 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.error { color: var(--red); min-height: 1.2em; margin: 4px 0; }
.mono, .num { font-family: var(--mono); font-size: .86em; letter-spacing: -.02em; }
a { color: var(--blue); }
i[data-i] { display: inline-flex; width: 16px; height: 16px; flex: none; }
i[data-i] svg { width: 100%; height: 100%; }

/* shell */
.app { display: flex; height: 100vh; height: 100dvh; background: var(--app); }   /* dvh: the visible area, not the part under a phone browser's toolbar */
/* the menu is a drawer, so the harbour can use the whole screen */
.sidebar { position: fixed; z-index: 1500; left: 0; top: 0; bottom: 0; width: 264px; background: var(--app); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 12px 14px 14px; transform: translateX(-102%); transition: transform .22s ease, box-shadow .22s; }
.sidebar.open { transform: none; box-shadow: 20px 0 60px var(--sh-2); }
.scrim { position: fixed; inset: 0; z-index: 1400; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.icon-btn.panel-btn, .icon-btn.drawer-close { display: none; }   /* phones only (see the phone rules) */
.icon-btn.panel-btn { align-items: center; gap: 5px; width: auto; padding: 0 8px; color: var(--ink-2); }
.panel-btn .count:empty { display: none; }
.side-top { height: 44px; display: flex; align-items: center; justify-content: space-between; margin: 0 2px 10px 8px; }
.logo { height: 22px; width: auto; display: block; }
.login-logo { height: 30px; width: auto; align-self: flex-start; margin-bottom: 6px; }
:root[data-theme="light"] .logo, :root[data-theme="light"] .login-logo { filter: brightness(0); }   /* the logo file is white */
.topbar .menu-btn { margin-left: -8px; color: var(--ink-2); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; letter-spacing: -.02em; padding: 2px 8px 18px; }
.mark { width: 28px; height: 28px; border-radius: 8px; background: var(--green); display: grid; place-items: center; color: #08130e; }
.mark i[data-i] { width: 17px; height: 17px; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
#nav > button { display: flex; align-items: center; gap: 11px; background: none; border: 1px solid transparent; color: var(--ink-2); font: 500 14.5px var(--font);
  padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
#nav > button:hover { background: var(--panel); color: var(--ink); }
#nav > button.active { background: var(--card); border-color: var(--line); color: var(--ink); }
#nav > button i { color: var(--muted); } #nav > button.active i { color: var(--ink); }
.nav-h { color: var(--muted); font-size: 13px; padding: 18px 12px 6px; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); margin-left: auto; }
.zone-list { display: flex; flex-direction: column; gap: 1px; }
.zone-item { display: flex; align-items: center; gap: 11px; padding: 7px 12px; border-radius: var(--radius-sm); color: var(--ink-2); font-size: 14px; cursor: pointer; }
.zone-item:hover { background: var(--panel); color: var(--ink); }
.zone-sq { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font: 700 9px var(--mono); color: #0b0b0c; flex: none; }
.zone-item .n { margin-left: auto; font: 500 11px var(--mono); color: var(--muted); }
.zone-item .n.on { color: var(--green); }
.side-foot { padding-top: 12px; border-top: 1px solid var(--line); margin-top: 8px; }
.user { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 10px; }
.user b { display: block; font-size: 13.5px; font-weight: 600; } .user small { color: var(--muted); font-size: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 8px; background: var(--avatar); color: var(--ink); display: grid; place-items: center; font: 600 10px var(--mono); }
.icon-btn { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 7px; display: grid; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1; }
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.crumb { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 14.5px; }
.crumb b { color: var(--ink); font-weight: 500; } .crumb .sep { width: 14px; height: 14px; }
.topright { margin-left: auto; display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.vsep { width: 1px; height: 20px; background: var(--line-2); }
.clock { font: 500 11.5px var(--mono); color: var(--ink-2); letter-spacing: -.02em; }
.conn { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 8px; }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.conn.warn { color: var(--amber); background: rgba(233,162,59,.13); }
.conn.bad { color: var(--red); background: rgba(239,83,80,.13); }
.conn.bad i { animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }
.content { flex: 1; overflow: auto; min-height: 0; }
.tab { display: none; padding: 24px 28px 48px; max-width: 1560px; margin: 0 auto; }
.tab.active { display: block; }
.tab.narrow { max-width: 820px; }
.page-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-h p { margin: 0; max-width: 680px; font-size: 14.5px; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  font: 500 13.5px var(--font); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: transparent; color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled, .btn.disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn i[data-i] { width: 15px; height: 15px; }
input, select { font: 14px var(--font); color: var(--ink); background: var(--app); border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 11px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
select { width: auto; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
label select { width: 100%; }
.seg { display: inline-flex; gap: 2px; background: var(--app); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); font: 500 12.5px var(--font); padding: 5px 10px; border-radius: 7px; cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.seg button.loading { animation: pulse-text 0.9s ease-in-out infinite alternate; }
@keyframes pulse-text { from { opacity: 1; } to { opacity: 0.35; } }
/* thin bar under the top edge while something takes longer than 250 ms */
#busy { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 3000; pointer-events: none; opacity: 0; transition: opacity .2s; overflow: hidden; }
#busy::before { content: ""; position: absolute; top: 0; bottom: 0; width: 30%; background: var(--blue); transform: translateX(-100%); }
#busy.on { opacity: 1; }
#busy.on::before { animation: busy-slide 1.1s ease-in-out infinite; }
@keyframes busy-slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { #busy.on::before { animation: none; width: 100%; transform: none; opacity: .6; } .seg button.loading { animation: none; opacity: .5; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 22px 0 14px; flex-wrap: wrap; }

/* panels & cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel.pad { padding: 20px; }
.panel.flush { overflow: auto; }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg-title, .col-h { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.col-h { margin: 4px 2px 10px; } .col-h.spaced { margin-top: 28px; }
.col-h b, .seg-title b { font-weight: 600; } .col-h i, .seg-title i { color: var(--ink-2); }
.col-h .muted { font-size: 13px; margin-left: 4px; }
.count { font: 500 10.5px var(--mono); color: var(--ink-2); background: var(--card); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 6px; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.cardgrid.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 16px; display: flex; flex-direction: column; min-height: 172px; }
.kpi.short { min-height: 0; }
.kpi-h { display: flex; align-items: center; gap: 9px; color: var(--ink-2); font-size: 14.5px; }
.kpi-h .ic { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; color: #0b0b0c; }
.kpi-h .ic i[data-i] { width: 12px; height: 12px; }
.kpi-h .badge { margin-left: auto; }
.kpi-v { font-size: 36px; font-weight: 600; letter-spacing: -.035em; line-height: 1.1; margin-top: 16px; font-variant-numeric: tabular-nums; }
.kpi-v small { font-size: 16px; color: var(--muted); font-weight: 500; letter-spacing: -.01em; margin-left: 4px; }
.kpi-s { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.kpi-s .up { color: var(--green); } .kpi-s .down { color: var(--red); }
.kpi .viz { margin-top: auto; padding-top: 14px; height: 50px; }
.kpi .viz svg { width: 100%; height: 100%; display: block; overflow: visible; }
.badge { display: inline-flex; align-items: center; gap: 4px; font: 500 10.5px var(--mono); border: 1px solid var(--line-2); border-radius: 7px; padding: 3px 7px; color: var(--ink-2); letter-spacing: -.02em; }
.meter { height: 18px; border-radius: 4px; background: var(--card); overflow: hidden; position: relative; margin-top: auto; }
.meter > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; min-width: 18px; }
.meter > span::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 10px; background: #fff; border-radius: 2px; }

/* chips (tinted status) */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 500; padding: 3px 8px; border-radius: 7px; white-space: nowrap; }
.chip.green { color: var(--green); background: rgba(47,191,113,.12); }
.chip.blue { color: var(--blue); background: rgba(76,141,255,.13); }
.chip.amber { color: var(--amber); background: rgba(233,162,59,.13); }
.chip.red { color: var(--red); background: rgba(239,83,80,.13); }
.chip.purple { color: var(--purple); background: rgba(139,108,246,.14); }
.chip.grey { color: var(--ink-2); background: var(--card); }

/* live: full-bleed map with floating panels */
.tab.live { position: relative; padding: 0; max-width: none; height: 100%; overflow: hidden; }
.tab.live.active { display: block; }
#map { position: absolute; inset: 0; background: var(--water); }
.float { position: absolute; z-index: 600; }
.glass, .float .kpi, .live-panel, .legend { background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); box-shadow: 0 12px 40px var(--sh-1); }
.kpi-strip { top: 14px; left: 14px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100% - 80px); overflow-y: auto; }
.kpi-strip .kpi { width: 260px; flex: none; min-height: 0; padding: 12px 14px 12px; border-radius: 12px; }
.kpi-strip .kpi-h { font-size: 13px; }
.kpi-strip .kpi-v { font-size: 25px; margin-top: 8px; }
.kpi-strip .kpi-v small { font-size: 13px; }
.kpi-strip .kpi-s { font-size: 12.5px; }
.kpi-strip .viz { height: 30px; padding-top: 8px; }
.kpi-strip .meter { height: 12px; margin-top: 10px; }
.kpi-strip .meter > span { min-width: 12px; } .kpi-strip .meter > span::before { top: 3px; bottom: 3px; left: 3px; width: 6px; }
.map-tools { top: 14px; right: 14px; display: flex; gap: 8px; align-items: center; }
.map-tools .seg, .map-tools .btn { background: var(--glass-2); backdrop-filter: blur(10px); }
.live-panel { top: 62px; right: 14px; bottom: 14px; width: 350px; border-radius: var(--radius); padding: 14px 12px; overflow-y: auto; transition: transform .22s ease, opacity .22s; }
.live-panel.closed { transform: translateX(calc(100% + 20px)); opacity: 0; pointer-events: none; }
#vessel-cards { gap: 0; max-height: 52%; overflow-y: auto; margin: 0 -4px 14px; }
.vrow { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 24px; gap: 10px; align-items: center; padding: 8px 8px; border-radius: 9px; cursor: pointer; }
.vrow:hover { background: var(--card); }
.vdot { width: 8px; height: 8px; border-radius: 3px; }
.vrow-main b { display: block; font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vrow-main small, .vrow-r small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; }
.vrow-main small { overflow: hidden; text-overflow: ellipsis; }
.vrow-r .svc-btn { display: flex; margin: 3px 0 0 auto; }
.vrow-r { text-align: right; } .vrow-r b { font-size: 11.5px; font-weight: 500; }
.vrow-b { display: flex; justify-content: flex-end; }
.live-panel { display: flex; flex-direction: column; }
.live-panel .feed { flex: 1; min-height: 120px; }
.live-panel .feed { max-height: none; padding: 0; }
.legend { left: 14px; bottom: 14px; border-radius: var(--radius-sm); padding: 7px 12px; display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; max-width: calc(100% - 400px); }
.leaflet-top.leaflet-left { top: auto; bottom: 56px; }
.leaflet-container { background: var(--water); font: 12px var(--font); }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 8px; border-radius: 2px; display: inline-block; }
.sw.in { background: var(--in); } .sw.out { background: var(--out); } .sw.stale { background: var(--stale); }
.sw.wait { background: var(--unserviced); outline: 1.5px solid var(--unserviced); outline-offset: 1px; }
.sw.zone { border: 1.5px dashed var(--harbour); height: 10px; } .sw.ent { background: var(--entrance); opacity: .5; }
.sw.fix { width: 14px; height: 0; border-top: 1px dashed var(--ink-2); position: relative; }
.sw.fix::after { content: ""; position: absolute; right: -2px; top: -3px; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-2); }
.leaflet-control-zoom { border: 1px solid var(--line-2) !important; border-radius: 9px !important; overflow: hidden; }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: var(--attrib) !important; color: var(--muted) !important; font-size: 10.5px; }
.leaflet-control-attribution a { color: var(--ink-2); }
.boat-label { background: var(--tip); color: var(--ink); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 6px; font: 600 11px var(--font); box-shadow: 0 4px 14px var(--sh-1); }
.boat-label::before { display: none; }
.leaflet-tooltip { background: var(--panel); color: var(--ink); border-color: var(--line-2); }
.zone-label { font: 600 10.5px var(--font); text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; transform: translate(-50%, -50%); display: inline-block; text-shadow: 0 0 4px var(--water), 0 0 2px var(--water); pointer-events: none; }
.gate-label { background: var(--gate-bg); color: var(--gate-ink); border: 1px solid var(--gate-line); font: 600 8.5px var(--mono); letter-spacing: .02em; padding: 1px 5px; border-radius: 4px; white-space: nowrap; transform: translate(-50%, -50%); display: inline-block; }
.place-label { color: var(--muted); font: 600 12px var(--font); letter-spacing: .2em; text-transform: uppercase; white-space: nowrap; }

/* vessel card */
.vcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px 12px; cursor: pointer; }
.vcard:hover { border-color: var(--line-2); }
.vcard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cat { display: flex; align-items: center; gap: 7px; font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.cat i[data-i] { width: 14px; height: 14px; }
.vname { color: var(--ink-2); font-size: 15.5px; margin-top: 12px; }
.vbig { font-size: 26px; font-weight: 600; letter-spacing: -.025em; font-variant-numeric: tabular-nums; margin-top: 1px; }
.vbig small { font-size: 15px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.vbar { height: 4px; background: var(--card); border-radius: 3px; margin: 14px 0 2px; overflow: hidden; }
.vbar span { display: block; height: 100%; border-radius: 3px; }
.vfoot { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--line); margin-top: 14px; padding-top: 11px; }
.vfoot i[data-i] { width: 14px; height: 14px; color: var(--muted); }
.vfoot .r { margin-left: auto; color: var(--ink-2); display: flex; align-items: center; gap: 10px; }
.vmeta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.vmeta b { color: var(--ink-2); font-weight: 500; }
.alerts-inline { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; }
.empty { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.batt { display: inline-flex; align-items: center; gap: 6px; }
.batt i.cell { width: 18px; height: 9px; border: 1.5px solid currentColor; border-radius: 2px; position: relative; display: inline-block; }
.batt i.cell::after { content: ""; position: absolute; right: -4px; top: 2px; width: 2px; height: 3px; background: currentColor; border-radius: 1px; }
.batt i.cell em { position: absolute; left: 1px; top: 1px; bottom: 1px; background: currentColor; border-radius: 1px; }

.feed { list-style: none; padding: 6px; margin: 0; display: flex; flex-direction: column; max-height: 460px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 9px 8px; border-radius: 9px; font-size: 13.5px; align-items: start; }
.feed li:hover { background: var(--card); }
.dot { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; }
.dot i[data-i] { width: 12px; height: 12px; }
.dot.green { background: rgba(47,191,113,.14); color: var(--green); } .dot.blue { background: rgba(76,141,255,.14); color: var(--blue); }
.dot.red { background: rgba(239,83,80,.14); color: var(--red); } .dot.grey { background: var(--card); color: var(--ink-2); }
.dot.purple { background: rgba(155,109,255,.14); color: var(--purple); }
.dot.amber { background: rgba(233,162,59,.15); color: var(--amber); }
.feed time { color: var(--muted); font: 500 10.5px var(--mono); padding-top: 3px; white-space: nowrap; }
.feed small { display: block; color: var(--muted); font-size: 12.5px; }
.feed li.new { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: rgba(47,191,113,.14); } to { background: transparent; } }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 500;
  padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); white-space: nowrap; }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tbody tr:hover td { background: var(--row-hover); }
.tbl small { color: var(--muted); }
/* money: blue = still billing (running total, the boat is in the harbour), green = billed (final) */
.amt-running, .tbl small.amt-running, .vrow small.amt-running { color: var(--blue); }
.amt-billed { color: var(--green); }
.tbl.compact td, .tbl.compact th { padding: 7px 8px; }
.tbl.compact input { padding: 7px 9px; }

/* devices */
.dev { padding: 18px 20px; margin-bottom: 14px; }
.dev-h { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; margin-bottom: 14px; }
.dev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.dev-grid > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.spark { width: 100%; height: 56px; display: block; margin-top: 8px; }
.spark path.l { fill: none; stroke: var(--green); stroke-width: 1.5; }
.spark path.a { fill: rgba(47,191,113,.09); }
.spark line { stroke: var(--red); stroke-dasharray: 3 3; stroke-width: 1; }
.metric > span { font-size: 12.5px; color: var(--muted); display: block; }
.metric > b { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric span.batt { display: inline-flex; font-size: 19px; }
details summary { cursor: pointer; color: var(--ink-2); font-size: 13.5px; margin-top: 14px; }

/* integrations */
.int-card { padding: 18px 20px; }
.int-card h4 { font-size: 15.5px; display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.int-card h4 .chip { margin-left: auto; }
.int-card p { margin: 4px 0 12px; color: var(--ink-2); font-size: 13.5px; }
.int-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.int-card dt { color: var(--muted); } .int-card dd { margin: 0; word-break: break-all; }
pre.code { background: var(--app); border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; font: 11px/1.65 var(--mono); overflow: auto; margin: 10px 0 0; white-space: pre-wrap; word-break: break-all; color: var(--ink-2); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
#demo-recv { padding: 6px 4px; }
#demo-recv > .muted { display: block; padding: 12px 14px; }

/* tariff */
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.formgrid .span2 { grid-column: span 2; }
#tariff-form h4, .calc h4 { margin-bottom: 10px; font-size: 15px; }
.formula { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; color: var(--ink-2); font-size: 13.5px; margin: 18px 0; }
.calc { margin-top: 14px; }
.calc label { width: 180px; }
.calc-out { font-size: 26px; font-weight: 600; margin-left: auto; letter-spacing: -.02em; text-align: right; }
.calc-out small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; letter-spacing: 0; }

/* dialog, login, toasts */
dialog { border: 1px solid var(--line-2); border-radius: 16px; padding: 24px; width: min(580px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); box-shadow: 0 30px 80px var(--sh-3); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin-bottom: 18px; font-size: 18px; }
.login { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; width: min(390px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px var(--sh-2); }
.login-card .brand { padding: 0 0 8px; }
.login-card h2 { font-weight: 600; letter-spacing: -.02em; }
.login-card p { margin: 2px 0 0; }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--card); border: 1px solid var(--line-2); color: var(--ink); padding: 12px 14px; border-radius: 12px; box-shadow: 0 16px 40px var(--sh-2); font-size: 13.5px; max-width: 360px;
  animation: tin .25s ease-out; display: grid; grid-template-columns: 22px 1fr; gap: 10px; }
.toast small { display: block; color: var(--muted); margin-top: 2px; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1180px) { .kpi-strip .kpi:nth-child(n+2) { display: none; } .legend { display: none; } }
@media (max-width: 860px) {
  .kpi-strip { display: none; }
  .live-panel { top: auto; left: 10px; right: 10px; width: auto; height: 45%; }
  .map-tools { left: 10px; right: 10px; flex-wrap: wrap; }
  .topbar { padding: 0 16px; height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px; }
  .clock, .vsep { display: none; }
  .tab { padding: 18px 16px 40px; }
  .formgrid { grid-template-columns: 1fr; } .formgrid .span2 { grid-column: auto; }
  .legend { display: none; }
  .calc label { width: 100%; }
}

/* zone editor */
#zmap { position: absolute; inset: 0; background: var(--water); }
.ze-panel { overflow: hidden; }
.ze-help { color: var(--muted); font-size: 12.5px; margin: 0 4px 12px; line-height: 1.5; }
.kbd { font: 500 10.5px var(--mono); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; color: var(--ink-2); }
.ze-list { flex: 1; overflow-y: auto; margin: 0 -4px; min-height: 80px; }
.ze-item { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.ze-item:hover { background: var(--card); }
.ze-item.on { background: var(--card); border-color: var(--line-2); }
.ze-item b { font-weight: 500; font-size: 13.5px; } .ze-item small { color: var(--muted); font-size: 12px; display: block; }
.ze-item .n { font: 500 10.5px var(--mono); color: var(--muted); }
.ze-form { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.ze-form .formgrid { margin-bottom: 10px; gap: 10px; }
.ze-save { border-top: 1px solid var(--line); padding-top: 12px; }
.ze-hint { font-size: 12.5px; color: var(--ink); background: var(--glass-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 5px 10px; }
.ze-hint:empty { display: none; }
.ze-vertex { width: 12px !important; height: 12px !important; margin: -6px 0 0 -6px !important; background: #fff; border: 2px solid #0b0b0c; border-radius: 3px; cursor: grab; box-shadow: 0 0 0 1px rgba(255,255,255,.4); }
.ze-vertex.first { background: var(--amber); }
.ze-mid { width: 14px !important; height: 14px !important; margin: -7px 0 0 -7px !important; border-radius: 50%; background: var(--glass-2); border: 1px solid var(--line-2);
  color: var(--ink); font: 700 11px/12px var(--font); text-align: center; cursor: copy; opacity: .8; }
.ze-mid:hover { opacity: 1; background: var(--primary); }
#zmap.drawing { cursor: crosshair; }

/* users & access */
.matrix th.role { text-align: center; white-space: normal; min-width: 104px; vertical-align: bottom; }
.matrix th.role b { display: block; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; }
.matrix th.role small { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; }
.matrix th.role .row { justify-content: center; margin-top: 4px; gap: 4px; }
.matrix td.c { text-align: center; }
.matrix tr.grp td { background: var(--panel-2, var(--card)); color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; padding-top: 8px; padding-bottom: 8px; }
.matrix td small { display: block; color: var(--muted); font-family: var(--mono); font-size: 10.5px; }
.matrix input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.matrix input[type=checkbox]:disabled { cursor: default; opacity: .55; }
.matrix td.changed { background: rgba(61,111,245,.1); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: 500 11.5px var(--font); padding: 0 2px; }
.link-btn:hover { color: var(--red); }

/* ---------- service status ---------- */
/* unserviced boats: a soft orange ripple spreads out from the hull and fades (it sits under every hull) */
.svc-halo { pointer-events: none; stroke: var(--orange); stroke-opacity: 0; }
.svc-halo.ripple { animation: svc-ripple 2.6s ease-out infinite; }
@keyframes svc-ripple {
  0% { stroke-width: 2px; stroke-opacity: .55; }
  70% { stroke-opacity: .12; }
  100% { stroke-width: 22px; stroke-opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .svc-halo.ripple { animation: none; stroke-width: 6px; stroke-opacity: .35; } }
.vrow.wait { background: rgba(233,162,59,.07); }
.vrow.wait:hover { background: rgba(233,162,59,.12); }
.svc-btn { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; padding: 2px 7px; border-radius: 6px; cursor: pointer;
  font: 500 11.5px var(--font); color: var(--unserviced); background: rgba(233,162,59,.13); border: 1px solid rgba(233,162,59,.35); }
.svc-btn:hover { background: rgba(233,162,59,.22); }
.svc-btn:disabled { opacity: .45; cursor: default; }
.fix-btn { margin-left: 4px; background: transparent; border-color: var(--line); color: var(--ink-2); }
.fix-btn:hover { background: var(--hover, rgba(127,127,127,.12)); }
.amt-note { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-3, var(--ink-2)); }
.amt-note.warn { color: var(--amber); }
.amt-was { text-decoration: line-through; opacity: .7; margin-right: 4px; }
#fix-form textarea { resize: vertical; font: inherit; }
.svc-btn i[data-i] { width: 12px; height: 12px; }
.svc-kpi.on { border-color: rgba(233,162,59,.55); cursor: pointer; }
.svc-kpi .kpi-s b { color: var(--ink); font-weight: 500; }
.toast.clickable { cursor: pointer; }
.toast.clickable:hover { border-color: var(--unserviced); }
.boat-pop .leaflet-popup-content-wrapper { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 16px 40px var(--sh-2); }
.boat-pop .leaflet-popup-tip { background: var(--card); border: 1px solid var(--line-2); }
.boat-pop .leaflet-popup-content { margin: 12px 14px; font: 13px/1.4 var(--font); }
.boat-pop a.leaflet-popup-close-button { color: var(--muted); }
.boat-pop-in { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 190px; }
.boat-pop-in b { font-size: 14px; font-weight: 600; padding-right: 14px; }
.boat-pop-in small { color: var(--muted); font-size: 12px; }
.boat-pop-in .chip i[data-i] { width: 12px; height: 12px; }

/* theme switch in the top bar */
.theme-btn svg { width: 17px; height: 17px; }

/* ---------- phones ---------- */
@media (max-width: 860px) {
  /* map pages: the side panel is a drawer from the right, opened from the top bar (mirrors the menu on the left) */
  .live-panel, .live-panel.closed { position: fixed; z-index: 1500; top: 0; bottom: 0; right: 0; left: auto; width: min(340px, 88vw);
    height: auto; border-radius: 0; border: 0; border-left: 1px solid var(--line); background: var(--app);
    backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; opacity: 1; pointer-events: auto;
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(102%); transition: transform .22s ease, box-shadow .22s; }
  .live-panel.drawer-open { transform: none; box-shadow: -20px 0 60px var(--sh-2); }
  .live-panel .icon-btn.drawer-close { display: inline-grid; margin-left: auto; margin-right: -4px; }
  .live-panel .chip + .icon-btn.drawer-close { margin-left: 4px; }
  #panel-toggle { display: none; }
  body[data-tab="live"] .icon-btn.panel-btn, body[data-tab="zones"] .icon-btn.panel-btn { display: inline-flex; }
  body[data-tab="zones"] #panel-btn-count { display: none; }
  /* one row of tools: the time range and icon-only buttons; pinch to zoom instead of +/- */
  .map-tools { flex-wrap: nowrap; gap: 6px; }
  .map-tools .btn { font-size: 0; gap: 0; padding: 0; width: 34px; height: 34px; justify-content: center; flex: none; }
  .map-tools .seg { flex: 1; min-width: 0; }
  .map-tools .seg button { flex: 1; padding-left: 0; padding-right: 0; }
  #tab-live .leaflet-control-zoom { display: none; }
  /* summary cards: one compact row instead of three full-width blocks */
  .kpis { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-bottom: 14px; }
  .kpis .kpi { min-height: 0; padding: 10px 11px; }
  .kpis .kpi-h { font-size: 12px; gap: 6px; }
  .kpis .kpi-h .ic { display: none; }
  .kpis .kpi-v { font-size: 20px; margin-top: 6px; }
  .kpis .kpi-v small { font-size: 11.5px; }
  .kpis .kpi-s { font-size: 11.5px; }
  .kpis .kpi .viz { display: none; }
  /* device telemetry: two charts per row */
  .dev { padding: 14px; }
  .dev-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dev-grid > div { padding: 10px; min-width: 0; }
  .dev-grid .metric b { font-size: 17px; }
  .page-h { flex-wrap: wrap; gap: 10px; }
  .page-h input[type="search"] { max-width: none !important; width: 100%; }
}
@media (max-width: 640px) {
  /* wide tables: one labelled card per row (labels come from the column headings, see labelTables in app.js);
     the roles matrix keeps scrolling sideways */
  .tbl:not(.matrix) thead { display: none; }
  .tbl:not(.matrix), .tbl:not(.matrix) tbody, .tbl:not(.matrix) tr { display: block; width: 100%; }
  .tbl:not(.matrix) tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .tbl:not(.matrix) tbody tr:last-child { border-bottom: 0; }
  .tbl:not(.matrix) td, .tbl.compact:not(.matrix) td { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: baseline;
    gap: 2px 6px; padding: 4px 0; border: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  /* the label sits left; everything in the cell stays together on the right */
  .tbl:not(.matrix) td::before { content: attr(data-label); flex: none; max-width: 45%; margin-right: auto; padding-right: 8px;
    color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; text-align: left; overflow-wrap: normal; }
  .tbl:not(.matrix) td:not([data-label])::before, .tbl:not(.matrix) td[data-label=""]::before { content: none; }
  .tbl:not(.matrix) td[data-label=""] { justify-content: flex-end; }
  .tbl:not(.matrix) td[colspan] { display: block; text-align: left; }
  .tbl:not(.matrix) td:first-child { font-weight: 500; }
  .tbl:not(.matrix) tbody tr:hover td { background: none; }
  .tbl:not(.matrix) td input, .tbl:not(.matrix) td select { max-width: 60%; }
}
