/* Cape Signal — dashboard styles. Light + dark themes via [data-theme].
   Dark theme = "Onyx": a near-black neutral base where violet is reserved strictly
   for highlights (live/predicted state, primary action, meters, active nav/tab). */
:root, :root[data-theme="dark"] {
  --ink: #EEECF0;          /* primary text */
  --accent: #7C5CFF;       /* Signal highlight (violet) */
  --accent-bright: #9B7BFF;
  --signal-text: #B9A6FF;  /* Signal as readable text on dark surfaces */
  --now-bg: #221C30;       /* anchorage "now" / accent-lit panel surface */
  --now-border: rgba(140, 108, 255, 0.36);
  --haze: #201E24;         /* neutral chip tint: chips, map bg, dot rings */
  --deep: #0E0D10;         /* sidebar */
  --hero: #221C30;         /* signal-lit hero panel (faint violet lift) */
  --indigo-2: #272231;     /* sidebar active row, meter track */
  --slate: #ABA6B2;        /* secondary text */
  --mist: #1B1A1E;         /* inset surface (buttons, meters, badges) */
  --paper: #161518;        /* card surface, top bar */
  --line: #2A2730;         /* card borders, meter tracks */
  --line-soft: #1F1D22;    /* in-card dividers */
  --page-bg: #0A0A0B;      /* app canvas */
  --muted: #6F6A76;        /* muted text / mono labels */
  --sidebar-muted: #9C97A2;
  --row-active: #201E24;   /* highlighted table row */
  --dot-complete: #645C6E;
  --dot-forecast: #4A4453;
  --map-element: #B2ACBC;  /* light strokes/markers on the dark map */
  --overlay-bg: rgba(10, 10, 11, 0.74);  /* map label/control backgrounds */
  --inset-hover: #272231;  /* secondary button hover */

  --ok-text: #5BD68A;   --ok-bg: rgba(40, 170, 95, 0.14);
  --warn-text: #E8B14C; --warn-bg: rgba(195, 150, 60, 0.15);
  --hot-text: #F2895A;  --hot-bg: rgba(232, 120, 70, 0.15);

  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --display: 'Space Grotesk', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

/* Light theme — sidebar and hero card stay dark navy (per the brand). Light keeps the
   blue "Signal" accent; the violet accent is the dark (Onyx) theme's signature. */
:root[data-theme="light"] {
  --ink: #1A2747;
  --accent: #3D5AF0;       /* Signal (blue) — light theme accent */
  --accent-bright: #5E76F4;
  --signal-text: #3D5AF0;  /* Signal reads as the accent on light surfaces */
  --now-bg: #EAEDFC;       /* anchorage "now" card surface (light) */
  --now-border: rgba(61, 90, 240, 0.22);
  --haze: #EAEDFC;
  --deep: #0F1A33;
  --hero: #0F1A33;
  --indigo-2: #1E2A52;     /* sidebar active row, meter track (light keeps navy) */
  --sidebar-muted: #9AA6C4;
  --slate: #5B6B7B;
  --mist: #F4F6FB;
  --paper: #FFFFFF;
  --line: #E4E7F0;
  --line-soft: #EEF1F4;
  --page-bg: #EDF0F3;
  --muted: #9AA6B2;
  --row-active: #F7F8FE;
  --dot-complete: #5B6B7B;
  --dot-forecast: #C7CEDE;
  --map-element: #1A2747;
  --overlay-bg: rgba(244, 246, 251, 0.85);
  --inset-hover: #ECEFF5;
  --ok-text: #15803D;   --ok-bg: #E9F6EE;
  --warn-text: #A16207; --warn-bg: #FBF1DC;
  --hot-text: #C2410C;  --hot-bg: #FCEBE2;
}

* { box-sizing: border-box; }
/* The `hidden` attribute must always win over component display rules (e.g. the
   login overlay's `display:flex`), otherwise toggling `el.hidden` does nothing. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--page-bg);
  height: 100vh;
  overflow: hidden;
}
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ---- App shell (full-bleed, edge to edge) ---- */
.app-frame {
  display: flex;
  height: 100vh;
  width: 100%;
  background: var(--page-bg);
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 214px;
  flex: none;
  background: var(--deep);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 26px;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px; }
.brand-mark { width: 22px; height: 22px; color: #fff; display: inline-flex; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-word { font-family: var(--display); font-weight: 600; font-size: 15px; color: #fff; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px;
  color: var(--sidebar-muted);
  font-size: 13.5px; text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; color: #fff; }
.nav-item:hover { background: var(--indigo-2); }
.nav-item.is-active { background: var(--indigo-2); color: #fff; font-weight: 500; }
.nav-item .badge {
  margin-left: auto; font-family: var(--mono); font-size: 10px;
  background: var(--accent); color: #fff; border-radius: 20px; padding: 1px 7px;
}

.user-row {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-top: 1px solid var(--indigo-2);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 600; font-size: 12px;
}
.user-meta { display: flex; flex-direction: column; }
.user-name { font-size: 12.5px; color: #fff; }
.user-role { font-family: var(--mono); font-size: 10px; color: #7E8BB5; }

/* ---- Main ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--page-bg); }

.topbar {
  height: 58px; flex: none; background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }
.port-select {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--ink);
  background: none; border: none; cursor: pointer; padding: 4px 6px; border-radius: 7px;
}
.port-select:hover { background: var(--mist); }
.port-select .caret { font-size: 11px; color: var(--muted); }

.weather-chip { font-size: 11px; color: var(--slate); display: flex; align-items: center; gap: 6px; }
.weather-chip .wx-risk {
  font-size: 10px; letter-spacing: 0.5px; padding: 2px 6px; border-radius: 4px;
}
.wx-low { color: var(--ok-text); background: var(--ok-bg); }
.wx-moderate { color: var(--warn-text); background: var(--warn-bg); }
.wx-high { color: var(--hot-text); background: var(--hot-bg); }

.chip {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px;
  padding: 6px 11px; border-radius: 7px; border: none; cursor: pointer;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.chip-live { color: var(--accent-bright); background: var(--haze); }
.chip-live .dot { background: var(--accent); }
.chip-sample { color: var(--slate); background: var(--mist); }
.chip-sample .dot { background: var(--muted); }

/* ---- Port switcher tabs ---- */
.port-tabs {
  flex: none; display: flex; gap: 4px; overflow-x: auto;
  margin: 14px 20px 0; padding: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
}
.port-tabs::-webkit-scrollbar { height: 0; }
.port-tab {
  font-family: var(--display); font-weight: 600; font-size: 13px;
  color: var(--slate); background: none; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 7px; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.port-tab:hover { background: var(--mist); }
.port-tab.is-active { background: var(--accent); color: #fff; }

/* ---- Headline stat cards ---- */
.stat-row {
  flex: none; display: flex; gap: 14px; margin: 14px 20px 0; overflow-x: auto;
}
.stat {
  flex: 1; min-width: 120px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat-val { font-family: var(--display); font-weight: 600; font-size: 26px; color: var(--ink); line-height: 1.1; }
.stat-val.is-empty { color: var(--muted); }
.stat-val.is-accent { color: var(--accent-bright); }
.stat-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  color: var(--muted); text-transform: uppercase;
}

/* ---- Content grid ---- */
.content-grid {
  flex: 1; min-height: 0; padding: 20px;
  display: grid; grid-template-columns: 1.55fr 1fr;
  /* Pin the row to the container height so the columns can't grow past it — without
     this the row sizes to content and the panel/timeline overflow the page. */
  grid-template-rows: minmax(0, 1fr); gap: 18px;
  overflow: hidden;
}
.col-left { display: flex; flex-direction: column; gap: 18px; min-width: 0; min-height: 0; }

/* ---- Map ---- */
/* Persistent size: ~half the dashboard area, regardless of how many vessels list. */
.map-card {
  position: relative; flex: 0 0 50%; min-height: 280px;
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); background: var(--haze);
}
/* The table takes the remaining height and scrolls internally so the map stays put. */
.table-card { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.table-card #t-body { flex: 1 1 0; min-height: 0; overflow-y: auto; }
#map { position: absolute; inset: 0; background: var(--haze); }
.map-coords {
  position: absolute; top: 12px; left: 14px; z-index: 1000; pointer-events: none;
  font-size: 10px; letter-spacing: 2px; color: var(--ink); opacity: 0.85;
  background: var(--overlay-bg); padding: 3px 7px; border-radius: 5px;
}
/* Leaflet, themed dark */
.leaflet-container { font-family: var(--mono); background: var(--haze); }
.leaflet-control-zoom a {
  background: var(--paper); color: var(--ink); border-color: var(--line);
}
.leaflet-control-zoom a:hover { background: var(--mist); }
.leaflet-control-attribution {
  background: var(--overlay-bg) !important; color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--slate) !important; }
.leaflet-control-scale-line { background: var(--overlay-bg); color: var(--slate); border-color: var(--muted); }
.leaflet-tooltip.cs-tip {
  background: #2D2836; color: #fff; border: none; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  font-family: var(--display); font-weight: 600; font-size: 12px; padding: 4px 9px; border-radius: 6px;
}
.leaflet-tooltip.cs-tip::before { display: none; }
.cs-tip .eta { font-family: var(--mono); font-weight: 400; font-size: 11px; color: #C9B8FF; margin-left: 6px; }
.leaflet-tooltip.cs-tip-dim {
  background: #211F27; color: #C9C5CE; font-family: var(--mono); font-weight: 400;
  font-size: 10px; letter-spacing: 0.5px; padding: 3px 7px;
}
/* Favourited / tracked vessels: a gold-edged permanent label so they stand out. */
.leaflet-tooltip.cs-tip-watch { box-shadow: 0 0 0 1.5px #F2B441, 0 4px 12px rgba(0, 0, 0, 0.4); }
/* Zone names (anchorage / approach) — unobtrusive, no background bubble. */
.leaflet-tooltip.cs-zone-label {
  background: transparent; border: none; box-shadow: none;
  color: var(--slate); font-family: var(--mono); font-weight: 400;
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.7;
}
.leaflet-tooltip.cs-zone-label::before { display: none; }
/* Berth id labels — tiny, shown only when zoomed into the harbour. */
.leaflet-tooltip.cs-berth-label {
  background: transparent; border: none; box-shadow: none;
  color: var(--muted); font-family: var(--mono); font-weight: 400;
  font-size: 9px; letter-spacing: 0.3px; padding: 0;
}
.leaflet-tooltip.cs-berth-label::before { display: none; }

/* Map-context vessel popup — basic info for a non-roster hull (click to open). */
.leaflet-popup.cs-popup .leaflet-popup-content-wrapper {
  background: #2D2836; color: #fff; border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.leaflet-popup.cs-popup .leaflet-popup-tip { background: #2D2836; }
.leaflet-popup.cs-popup .leaflet-popup-content { margin: 10px 12px; line-height: 1.4; }
.cs-pop-name { font-family: var(--display); font-weight: 700; font-size: 13px; }
.cs-pop-meta { font-family: var(--mono); font-size: 10px; letter-spacing: 0.5px; color: #C9B8FF; margin-top: 2px; }
.cs-pop-row { font-family: var(--mono); font-size: 10px; color: #C9C5CE; margin-top: 4px; }
.cs-pop-sa { color: var(--signal-text); font-weight: 600; }
.cs-pop-seen { font-family: var(--mono); font-size: 9px; color: #8C8794; margin-top: 4px; }
.cs-pop-link {
  display: inline-block; margin-top: 8px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.5px; color: var(--accent); text-decoration: none;
}
.cs-pop-link:hover { text-decoration: underline; }

/* ---- Vessel table ---- */
.table-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.t-head, .t-row {
  display: grid; grid-template-columns: 1.3fr 1.6fr 0.9fr;
  align-items: center; gap: 10px;
}
.t-head {
  padding: 11px 16px; border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  color: var(--muted); text-transform: uppercase;
}
.t-head .right, .t-row .right { text-align: right; }
.t-row { padding: 13px 16px; border-top: 1px solid var(--line-soft); cursor: pointer; }
.t-row:first-child { border-top: none; }
.t-row:hover { background: var(--row-active); }
.t-row.is-active { background: var(--row-active); border-left: 2px solid var(--accent); }
/* Favourited / tracked vessels float to the top and read as a pinned watchlist. */
.t-row.is-watched { box-shadow: inset 3px 0 0 #F2B441; }
.t-divider {
  display: flex; align-items: center; gap: 8px; padding: 6px 16px 4px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
}
.t-divider::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
/* Archive: outbound vessels whose signal went stale — dropped to the bottom. */
.t-divider-archive { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 10px; color: var(--slate); }
.t-row.t-archived { opacity: 0.55; }
.t-row.t-archived:hover { opacity: 0.8; }
.t-vessel { display: flex; align-items: center; gap: 9px; min-width: 0; }
.t-vmeta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
/* Roster favourite / track toggles */
.t-watch { display: flex; flex-direction: column; gap: 1px; flex: none; }
.t-wbtn {
  background: none; border: none; padding: 0; cursor: pointer; line-height: 1;
  color: var(--line); transition: color 0.12s;
}
.t-wfav { font-size: 12px; }
.t-wtrk { font-size: 8px; }
.t-wbtn:hover { color: var(--slate); }
.t-wfav.on-fav { color: #F2B441; }
.t-wtrk.on-trk { color: var(--accent-bright); }
.t-name { font-family: var(--display); font-weight: 600; font-size: 15px; letter-spacing: -0.2px; color: var(--ink); }
.t-sub { display: flex; align-items: center; gap: 6px; }
.t-imo { font-family: var(--mono); font-size: 9px; letter-spacing: 0.3px; color: var(--muted); }
.t-type {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.5px;
  color: var(--muted); text-transform: uppercase;
}
.t-dest { font-family: var(--mono); font-size: 10px; color: var(--slate); }
.t-dest.is-sa { color: var(--accent-bright); font-weight: 500; }

/* Vessel status badges */
.t-status, .st-badge {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.5px;
  text-transform: uppercase; padding: 1px 6px; border-radius: 4px;
}
.st-badge { font-size: 10px; padding: 2px 8px; }
.st-anchored { color: var(--accent-bright); background: var(--haze); }
.st-berthed { color: var(--slate); background: var(--mist); }
.st-underway { color: var(--slate); background: var(--mist); }
.st-fishing { color: var(--slate); background: var(--mist); }
.st-active { color: #fff; background: var(--accent); }
/* Presence tags: inbound (arriving) · in port area (present) · outbound (leaving). */
.st-inbound { color: var(--accent-bright); background: var(--haze); }
.st-inport { color: var(--slate); background: var(--mist); }
.st-outbound { color: var(--ok-text); background: var(--ok-bg); }
.panel-title-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; row-gap: 6px; }
.t-cell { font-family: var(--mono); font-size: 12px; color: var(--slate); }
/* Lifecycle stage names — slightly smaller, wrap rather than overflow. */
.t-stage { font-size: 11px; line-height: 1.25; color: var(--ink); white-space: normal; }
.t-cell.ink { color: var(--ink); }
.t-cell.accent { color: var(--accent-bright); }

/* Roster row — Stage column: current→next chips + 10-segment position bar. */
.rs-stage { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rs-chips { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rs-cur {
  font-family: var(--mono); font-size: 10px; color: var(--signal-text);
  background: var(--haze); padding: 2px 6px; border-radius: 4px; white-space: nowrap;
}
.rs-arrow { color: var(--dot-forecast); font-size: 10px; }
.rs-next {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rs-bar { display: flex; gap: 3px; }
.rs-seg { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.rs-seg.seg-done { background: var(--dot-complete); }
.rs-seg.seg-now { background: var(--accent); }
/* Roster row — Timing column: drift chip or next ETA, then a risk word. */
.rs-timing { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.rs-eta { font-family: var(--mono); font-size: 11px; color: var(--slate); }
.risk-word { font-family: var(--mono); font-size: 9px; letter-spacing: 0.5px; font-weight: 500; }
.risk-low { color: var(--ok-text); }
.risk-moderate { color: var(--warn-text); }
.risk-high { color: var(--hot-text); }
/* Shared drift chip (roster + timeline): late = HIGH pair, early = LOW pair. */
.drift-chip {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  padding: 2px 7px; border-radius: 4px;
}
.drift-high { color: var(--hot-text); background: var(--hot-bg); }
.drift-low { color: var(--ok-text); background: var(--ok-bg); }

.status {
  font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: 4px;
  text-transform: uppercase; display: inline-block;
}
.status-low { color: var(--ok-text); background: var(--ok-bg); }
.status-moderate { color: var(--warn-text); background: var(--warn-bg); }
.status-high { color: var(--hot-text); background: var(--hot-bg); }

/* ---- Right column: weather card + vessel panel ---- */
/* min-height:0 lets these shrink inside the viewport-capped grid, so the panel can
   bound its height and the timeline scrolls instead of overflowing the page. */
.col-right { display: flex; flex-direction: column; gap: 18px; min-width: 0; min-height: 0; }
.col-right .panel { flex: 1; min-height: 0; }

.wx-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; display: flex; flex-direction: column; gap: 14px; flex: none;
}
.wx-head { display: flex; align-items: center; justify-content: space-between; }
.wx-eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px;
  color: var(--muted); text-transform: uppercase;
}
.wx-rating {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px;
  padding: 3px 9px; border-radius: 4px; text-transform: uppercase;
}
.wx-metrics { display: flex; gap: 14px; }
.wx-metric {
  flex: 1; background: var(--mist); border-radius: 8px; padding: 12px 14px;
}
.wx-val { font-family: var(--display); font-weight: 600; font-size: 26px; color: var(--ink); }
.wx-unit { font-family: var(--display); font-weight: 500; font-size: 13px; color: var(--slate); margin-left: 3px; }
.wx-metric .wx-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.5px;
  color: var(--muted); text-transform: uppercase; margin-top: 4px;
}
.wx-text { font-size: 13.5px; line-height: 1.55; color: var(--slate); margin: 0; }
.wx-empty { color: var(--muted); font-size: 13px; }

/* ---- Vessel detail panel ---- */
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px; display: flex; flex-direction: column; gap: 18px; min-width: 0;
}
.panel-head { display: flex; align-items: center; gap: 12px; }
.panel-head-main { flex: 1; min-width: 0; }
.panel-tile {
  width: 42px; height: 42px; border-radius: 10px; background: var(--haze); flex: none;
  color: var(--map-element);
  display: flex; align-items: center; justify-content: center;
}
.panel-tile svg { width: 24px; height: 24px; }
.panel-title { font-family: var(--display); font-weight: 600; font-size: 18px; color: var(--ink); }
.panel-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.hero {
  background: var(--hero); border: 1px solid var(--now-border);
  border-radius: 11px; padding: 18px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}
.hero-label { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; color: #9183B0; text-transform: uppercase; }
.hero-value { font-family: var(--display); font-weight: 600; font-size: 28px; color: #fff; margin: 5px 0 12px; }
.hero-bar-row { display: flex; align-items: center; gap: 10px; }
.hero-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--indigo-2); overflow: hidden; }
.hero-bar > span { display: block; height: 100%; background: var(--accent); }
.hero-pct { font-family: var(--mono); font-size: 12px; color: #C9B8FF; }
.hero-caption { font-family: var(--mono); font-size: 10px; color: #847E8C; margin-top: 6px; }

/* ---- Port-call timeline (Signal Rail) ---- */
/* Fill the remaining panel height; scroll only when the lifecycle is taller. */
.timeline-block { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.timeline-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 8px; }
.timeline-scroll::-webkit-scrollbar { width: 6px; }
.timeline-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.timeline-scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.tl-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.tl-eyebrow { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.tl-count { font-family: var(--mono); font-size: 10px; color: var(--muted); }

.tl-node { display: flex; gap: 14px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; width: 13px; flex: none; }
.tl-line { width: 2px; flex: 1; background: var(--line); }
.tl-body { flex: 1; min-width: 0; padding-bottom: 14px; }
.tl-sub .tl-body { padding-bottom: 13px; }
.tl-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

.tl-title { font-size: 13.5px; color: var(--slate); }
.tl-title-strong { color: var(--ink); font-weight: 500; }
.tl-title-status { color: var(--muted); }
.tl-sub-title { font-size: 13px; }
.tl-tag { font-family: var(--mono); font-size: 10px; color: var(--dot-forecast); }

.tl-right { display: inline-flex; align-items: baseline; gap: 7px; flex: none; }
.tl-time { font-family: var(--mono); font-size: 11px; color: var(--slate); white-space: nowrap; }
.tl-plan { color: var(--muted); }
.tl-est { color: var(--signal-text); }
.tl-pending-t { color: var(--dot-forecast); }
.tl-done-t { color: var(--muted); }
.tl-held { color: var(--signal-text); }
/* Berth slot chip — on at-berth stages (timeline rows + the "now" card). */
.tl-berth, .now-berth {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.3px; font-weight: 500;
  color: var(--signal-text); background: var(--haze); white-space: nowrap;
  padding: 1px 6px; border-radius: 4px;
}
.now-berth { background: transparent; border: 1px solid var(--now-border); }

/* Drift: a coloured chip + the struck-through baseline plan. */
.tl-driftrow { display: flex; align-items: center; gap: 9px; margin-top: 7px; }
.tl-struck { font-family: var(--mono); font-size: 10px; color: var(--muted); text-decoration: line-through; }

/* Dots — sized/filled per state. */
.tl-dot { border-radius: 50%; margin-top: 3px; }
.tl-actual .tl-dot { width: 9px; height: 9px; background: var(--dot-complete); }
.tl-done .tl-dot { width: 9px; height: 9px; background: var(--dot-complete); }
.tl-estimated .tl-dot { width: 12px; height: 12px; background: var(--paper); border: 2px solid var(--accent); }
.tl-scheduled .tl-dot { width: 11px; height: 11px; background: var(--paper); border: 2px solid var(--dot-forecast); }
.tl-pending .tl-dot { width: 11px; height: 11px; background: var(--paper); border: 2px solid var(--dot-forecast); }
.tl-sub .tl-dot { width: 8px; height: 8px; background: var(--paper); border: 2px solid var(--dot-forecast); margin-top: 4px; }
.tl-status .tl-dot { width: 7px; height: 7px; background: var(--dot-forecast); margin-top: 5px; }
.tl-endpoint .tl-dot { width: 12px; height: 12px; background: var(--paper); border: 2px solid var(--accent); }

/* Current = live "now" node: pulsing Signal dot + tinted card. */
.tl-current .tl-dot {
  width: 13px; height: 13px; background: var(--accent); --halo: var(--haze);
  animation: tl-pulse 1.8s ease-in-out infinite;
}
@keyframes tl-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--halo); }
  50% { box-shadow: 0 0 0 7px var(--halo); }
}
.now-card { background: var(--now-bg); border: 1px solid var(--now-border); border-radius: 9px; padding: 11px 13px; }
.now-head { display: flex; align-items: center; gap: 8px; }
.now-title { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.now-pill {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.5px; color: #fff;
  background: var(--accent); padding: 1px 6px; border-radius: 4px;
}
.now-live { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.now-blink { width: 6px; height: 6px; border-radius: 50%; background: var(--signal-text); animation: tl-blink 1.4s ease-in-out infinite; }
@keyframes tl-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.now-elapsed, .now-elapsed-static { font-family: var(--mono); font-size: 13px; color: var(--signal-text); }
.now-sub { font-family: var(--mono); font-size: 10px; color: var(--muted); }
/* Discharge/loading sub-states inside the Berthed now-card. */
.now-subs {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--now-border);
  display: flex; flex-direction: column; gap: 6px;
}
.now-sub-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.now-sub-name { font-size: 12.5px; color: var(--slate); }

/* Upcoming group — collapsed summary / expandable sub-nodes. */
.up-head { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.up-label { font-size: 13px; color: var(--slate); }
.up-meta { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.up-chevron { margin-left: auto; font-size: 10px; color: var(--muted); }
.up-summary { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

.panel-voyage { font-family: var(--mono); font-size: 11.5px; color: var(--slate); margin-top: 4px; }
.dest-sa {
  font-size: 9px; font-weight: 600; letter-spacing: 0.5px; margin-left: 5px;
  padding: 1px 5px; border-radius: 4px; background: var(--accent); color: #fff;
}

.actions { margin-top: auto; display: flex; gap: 9px; }
.btn {
  text-align: center; font-family: var(--sans); font-weight: 600; font-size: 13px;
  padding: 11px 14px; border-radius: 9px; border: none; cursor: pointer;
}
.btn-primary { flex: 1; color: #fff; background: var(--accent); }
.btn-primary:hover { background: #6B4DE6; }
.btn-secondary { color: var(--ink); background: var(--mist); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--inset-hover); }

/* ---- Theme toggle button (top bar) ---- */
.icon-btn {
  width: 30px; height: 30px; flex: none; border-radius: 8px; cursor: pointer;
  background: var(--mist); border: 1px solid var(--line); color: var(--slate);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }

.panel-empty { color: var(--muted); font-size: 14px; padding: 24px 0; text-align: center; }

/* Stack the two columns on narrower viewports; give the map a real height. */
@media (max-width: 1000px) {
  .content-grid { grid-template-columns: 1fr; }
  .map-card { min-height: 300px; height: 300px; flex: none; }
}

/* Collapse the sidebar to an icon rail on small screens (e.g. embedded preview). */
@media (max-width: 720px) {
  .sidebar { width: 60px; padding: 16px 8px; gap: 18px; align-items: center; }
  .brand-word, .nav-item span:not(.badge), .user-meta { display: none; }
  .nav-item { justify-content: center; padding: 10px; position: relative; }
  .nav-item .badge { position: absolute; margin: 0; transform: translate(14px, -12px); }
  .user-row { justify-content: center; padding: 10px 0; }
  .content-grid { padding: 14px; }
  .topbar { padding: 0 14px; }
}

@media (max-width: 480px) {
  .topbar-right .mono.muted { display: none; }
  .t-head, .t-row { grid-template-columns: 1.2fr 1.4fr 0.8fr; }
}

/* ===================================================================== */
/* Multi-view layout (Live map / Vessels directory / Vessel detail)       */
/* ===================================================================== */
.view[hidden] { display: none !important; }
#view-dashboard.view:not([hidden]) { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.view-title { font-family: var(--display); font-weight: 600; font-size: 18px; color: var(--ink); }
.dash-controls { display: flex; align-items: center; gap: 14px; }

/* ---- Vessels directory ---- */
.v-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.v-search {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px;
}
.v-search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.v-search input {
  flex: 1; border: none; background: transparent; outline: none; color: var(--ink);
  font-family: var(--sans); font-size: 14px;
}
.v-search input::placeholder { color: var(--muted); }
.vfilters { display: flex; gap: 6px; }
.vfilter {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.3px; cursor: pointer;
  padding: 7px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper); color: var(--slate);
}
.vfilter:hover { color: var(--ink); }
.vfilter.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.v-count { font-size: 11px; color: var(--muted); margin-left: auto; }
.v-select {
  font-family: var(--sans); font-size: 12px; color: var(--ink); cursor: pointer;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.v-select:hover { border-color: var(--accent); }

/* Sortable column headers */
.v-col {
  display: inline-flex; align-items: center; gap: 2px; cursor: pointer;
  background: none; border: none; padding: 0; color: inherit;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
}
.v-col:hover { color: var(--ink); }
.v-col.is-sorted { color: var(--accent-bright); }
.v-sort { font-size: 8px; }

.v-list-head, .v-row {
  display: grid; align-items: center; gap: 10px;
  grid-template-columns: 30px 1.7fr 0.9fr 0.6fr 0.9fr 1.3fr 1fr 92px;
}
.v-list-head {
  padding: 8px 14px; font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted);
}
.v-list-head .right { text-align: right; }
.v-list { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.v-row { padding: 12px 14px; border-top: 1px solid var(--line-soft); cursor: pointer; }
.v-row:first-child { border-top: none; }
.v-row:hover { background: var(--row-active); }
.v-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--slate); }
.v-name { display: flex; flex-direction: column; gap: 2px; }
.v-name .t-name { font-size: 14px; }
.v-star {
  background: none; border: none; cursor: pointer; font-size: 16px;
  color: var(--line); padding: 0; line-height: 1;
}
.v-star:hover { color: #F2B441; }
.v-star.on { color: #F2B441; }
.v-trk {
  justify-self: end; font-family: var(--mono); font-size: 10px; letter-spacing: 0.3px; cursor: pointer;
  padding: 5px 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--mist); color: var(--slate);
}
.v-trk:hover { color: var(--ink); border-color: var(--accent); }
.v-trk.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.v-more-wrap { display: flex; justify-content: center; margin-top: 16px; }
.v-more-wrap .btn { max-width: 280px; }

/* ---- Vessel detail ---- */
.d-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.d-back { font-family: var(--mono); font-size: 12px; color: var(--accent-bright); text-decoration: none; padding-top: 6px; white-space: nowrap; }
.d-back:hover { text-decoration: underline; }
.d-head-main { flex: 1; min-width: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.d-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.d-title { font-family: var(--display); font-weight: 600; font-size: 24px; color: var(--ink); }
.d-chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 5px; background: var(--mist); color: var(--slate);
}
/* AIS freshness pill (live = recent fix, stale = >1h). */
.d-fresh {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.3px; padding: 3px 8px; border-radius: 5px;
}
.d-fresh-dot { width: 7px; height: 7px; border-radius: 50%; }
.d-fresh.is-live { color: var(--ok-text); background: var(--ok-bg); }
.d-fresh.is-live .d-fresh-dot { background: var(--ok-text); animation: tl-blink 1.6s ease-in-out infinite; }
.d-fresh.is-stale { color: var(--muted); background: var(--mist); }
.d-fresh.is-stale .d-fresh-dot { background: var(--muted); }
.panel-fresh { margin-left: auto; }
.d-head-actions { display: flex; gap: 9px; }
.d-star, .d-trk {
  font-family: var(--mono); font-size: 11px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--paper); color: var(--slate); cursor: pointer;
}
.d-star.on { color: #F2B441; border-color: #F2B441; }
.d-trk.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.d-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.d-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.d-card-wide { grid-column: 1 / -1; }
.d-card-title { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.d-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line-soft); }
.d-row:first-of-type { border-top: none; }
.d-key { font-size: 12.5px; color: var(--muted); }
.d-val { font-family: var(--mono); font-size: 12.5px; color: var(--ink); text-align: right; word-break: break-word; }
.d-map-card { padding: 0; overflow: hidden; height: 320px; }
#vdetail-map { width: 100%; height: 100%; background: var(--haze); }

.d-hist { display: flex; flex-direction: column; }
.d-hist-row {
  display: grid; grid-template-columns: 1.1fr 1fr 1.6fr 60px; gap: 10px; align-items: center;
  padding: 9px 0; border-top: 1px solid var(--line-soft); font-size: 12px;
}
.d-hist-row:first-child { border-top: none; }
.dh-type { color: var(--ink); font-weight: 500; }
.dh-dur { text-align: right; color: var(--accent-bright); }
.d-decl { grid-template-columns: 0.9fr 1.3fr 1fr 0.7fr; }

@media (max-width: 1000px) {
  .d-grid { grid-template-columns: 1fr; }
}

/* ===================================================================== */
/* Ports page                                                            */
/* ===================================================================== */
.ports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.port-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; cursor: pointer; display: flex; flex-direction: column; gap: 14px;
}
.port-card:hover { border-color: var(--accent); }
.pc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pc-name { font-family: var(--display); font-weight: 600; font-size: 16px; color: var(--ink); }
.pc-terms { font-size: 10px; color: var(--muted); margin-top: 2px; }
.pc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pc-stat { display: flex; flex-direction: column; gap: 2px; }
.pc-num { font-family: var(--display); font-weight: 600; font-size: 20px; color: var(--ink); }
.pc-lbl { font-family: var(--mono); font-size: 9px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); }
.pc-vol { display: flex; flex-direction: column; gap: 1px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.pc-vol-n { font-family: var(--display); font-weight: 600; font-size: 18px; color: var(--accent-bright); }
.pc-vol-l { font-family: var(--mono); font-size: 9px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); }

/* Port-detail stat cards */
.pstats { margin-bottom: 16px; }
.d-grid.pstats { grid-template-columns: repeat(6, 1fr); }
.pstat { display: flex; flex-direction: column; gap: 4px; }
.pstat-num { font-family: var(--display); font-weight: 600; font-size: 24px; color: var(--ink); }
.pstat-num.is-accent { color: var(--accent-bright); }
.pstat-lbl { font-family: var(--mono); font-size: 9px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); }
.d-section-title { font-family: var(--display); font-weight: 600; font-size: 16px; color: var(--ink); margin: 22px 0 14px; }

/* Charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-empty { font-size: 12.5px; color: var(--muted); padding: 18px 0; }
.ax-grid { stroke: var(--line-soft); stroke-width: 1; }
.ax-y, .ax-x { font-family: var(--mono); font-size: 9px; fill: var(--muted); }
.ax-hit { fill: var(--ink); fill-opacity: 0; cursor: default; }
.ax-hit:hover { fill-opacity: 0.05; }
.chart-key { font-family: var(--mono); font-size: 9px; letter-spacing: 0; text-transform: none; color: var(--muted); margin-left: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin: 0 3px 0 8px; vertical-align: 0; }
.dot-a { background: var(--accent-bright); }
.dot-b { background: var(--accent); }

/* Cursor-following chart tooltip */
.chart-tip {
  position: fixed; z-index: 9999; pointer-events: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28); padding: 8px 10px;
  font-family: var(--mono); font-size: 11px; color: var(--ink); line-height: 1.5; max-width: 220px;
}
.chart-tip b { font-family: var(--display); font-size: 12px; }
.chart-tip .tip-a { color: var(--accent-bright); }
.chart-tip .tip-b { color: var(--accent); }

/* Horizontal bars (trade partners, freight mix) */
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; cursor: default; }
.hbar:hover .hbar-track { outline: 1px solid var(--line); }
.hbar-name { font-size: 12px; color: var(--slate); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 9px; background: var(--mist); border-radius: 4px; overflow: hidden; display: flex; }
.hbar-seg { display: block; height: 100%; }
.hbar-seg.seg-a { background: var(--accent-bright); }
.hbar-seg.seg-b { background: var(--accent); }
.hbar-fill { display: block; height: 100%; border-radius: 4px; }
.hbar-val { font-size: 11px; color: var(--ink); }

/* Import/export split bar */
.splitbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--mist); }
.seg-a { background: var(--accent-bright); }
.seg-b { background: var(--accent); }
.split-legend { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 11px; color: var(--slate); }

@media (max-width: 1100px) {
  .d-grid.pstats { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Alerts (redesigned: attention band + grouped vessel activity) ---- */
#view-alerts { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.alerts-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.alerts-head-line { font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: -0.4px; color: var(--ink); }
.alerts-sub { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 2px; }
.a-markread {
  font-family: var(--sans); font-weight: 600; font-size: 12.5px; color: var(--slate);
  background: var(--mist); border: 1px solid var(--line); padding: 8px 13px; border-radius: 8px; cursor: pointer;
}
.a-markread:hover { color: var(--ink); border-color: var(--inset-hover); }

.afilters { display: flex; gap: 8px; flex-wrap: wrap; }
.afilter {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--haze); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 13px; font-family: var(--sans); font-weight: 600; font-size: 12.5px;
  color: var(--slate); transition: all 0.12s;
}
.afilter:hover { border-color: var(--inset-hover); color: var(--ink); }
.afilter.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.afilter-n {
  font-family: var(--mono); font-size: 10px; min-width: 18px; text-align: center;
  padding: 1px 7px; border-radius: 10px; background: var(--line); color: var(--accent-dim, #9183B0);
}
.afilter.on .afilter-n { background: rgba(255, 255, 255, 0.22); color: #fff; }

.asec { display: flex; flex-direction: column; gap: 11px; }
.asec-head { display: flex; align-items: center; gap: 10px; }
.asec-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.asec-label { font-size: 10.5px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent-dim, #9183B0); }
.asec-rule { flex: 1; height: 1px; background: var(--line-soft); }
.asec-hint { font-size: 10px; color: var(--dot-forecast); }

.acards { display: flex; flex-direction: column; gap: 11px; }
.acard {
  display: flex; gap: 14px; background: var(--paper); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 12px; padding: 16px 18px; transition: border-color 0.12s;
}
.acard[data-vessel-link] { cursor: pointer; }
.acard:hover { border-color: var(--inset-hover); }
.acard-chip { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.acard-main { flex: 1; min-width: 0; }
.acard-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.acard-titles { display: flex; align-items: center; gap: 9px; min-width: 0; flex-wrap: wrap; }
.acard-title { font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--ink); white-space: nowrap; }
.acard-tag { font-size: 9.5px; letter-spacing: 0.8px; padding: 2px 7px; border-radius: 4px; flex: none; }
.acard-ago { font-size: 11px; color: var(--muted); white-space: nowrap; flex: none; }
.acard-body { font-size: 13.5px; color: var(--slate); margin-top: 4px; line-height: 1.5; }
.acard-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.a-impact { display: inline-flex; align-items: center; gap: 9px; background: var(--mist); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; }
.a-impact-l { font-size: 9.5px; letter-spacing: 0.5px; color: var(--muted); text-transform: uppercase; }
.a-impact-v { font-size: 12px; color: var(--ink); }
.a-impact-d { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; }
.acard-meta { font-size: 10.5px; letter-spacing: 0.5px; color: var(--muted); margin-left: auto; }
.alert-new { font-family: var(--mono); font-size: 8px; letter-spacing: 0.5px; font-weight: 700; color: #fff; background: var(--accent); padding: 1px 5px; border-radius: 3px; flex: none; }

/* Grouped vessel activity */
.agrps { display: flex; flex-direction: column; gap: 10px; }
.agrp { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.agrp-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px; cursor: pointer; }
.agrp-head:hover { background: var(--row-active); }
.agrp-id { display: flex; align-items: center; gap: 13px; min-width: 0; }
.agrp-chip { width: 38px; height: 38px; border-radius: 10px; background: var(--haze); display: flex; align-items: center; justify-content: center; flex: none; }
.agrp-name-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.agrp-name { font-family: var(--display); font-weight: 600; font-size: 14.5px; color: var(--ink); }
.agrp-status { font-size: 10px; color: var(--sidebar-muted); background: var(--haze); padding: 2px 8px; border-radius: 5px; }
.agrp-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.agrp-right { display: flex; align-items: center; gap: 16px; flex: none; }
.agrp-dots { display: flex; align-items: center; gap: 5px; }
.agrp-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.agrp-chev { color: var(--muted); display: inline-flex; transition: transform 0.15s ease; }
.agrp-chev.open { transform: rotate(180deg); }
.agrp-body { border-top: 1px solid var(--line-soft); padding: 6px 18px 12px; }
.aev { display: flex; align-items: center; gap: 14px; padding: 8px 0; }
.aev-time { font-size: 11px; color: var(--muted); width: 96px; flex: none; }
.aev-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.aev-label { font-family: var(--display); font-weight: 500; font-size: 13px; color: var(--ink); width: 150px; flex: none; }
.aev-sub { font-size: 12.5px; color: var(--slate); min-width: 0; }
.ae-title { font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--slate); }
.ae-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }

@media (max-width: 640px) {
  .aev-label { width: auto; }
  .aev-time { width: 80px; }
}

/* ---- Login screen ---- */
.login-screen {
  position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
  background: var(--page-bg); padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.login-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.login-brand .brand-mark { width: 26px; height: 26px; }
.login-brand .brand-word { font-family: var(--display); font-weight: 600; font-size: 17px; }
.login-title { font-family: var(--display); font-weight: 600; font-size: 22px; color: var(--ink); margin-top: 4px; }
.login-sub { font-size: 13px; color: var(--muted); margin-top: -8px; line-height: 1.5; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.login-field input {
  font-family: var(--sans); font-size: 14px; color: var(--ink); background: var(--mist);
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; text-transform: none; letter-spacing: 0;
}
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-error { font-size: 12.5px; color: var(--hot-text); background: var(--hot-bg); padding: 8px 11px; border-radius: 8px; }
.login-btn {
  font-family: var(--sans); font-weight: 600; font-size: 14px; color: #fff; background: var(--accent);
  border: none; border-radius: 9px; padding: 12px; cursor: pointer; margin-top: 4px;
}
.login-btn:hover { background: #6B4DE6; }
.login-btn:disabled { opacity: 0.6; cursor: default; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-link {
  background: none; border: none; cursor: pointer; align-self: flex-start; padding: 2px 0;
  font-family: var(--sans); font-size: 12.5px; color: var(--accent-bright);
}
.login-link:hover { text-decoration: underline; }
.login-note { font-size: 12.5px; padding: 9px 11px; border-radius: 8px; line-height: 1.5; }
.login-note.ok { color: var(--ok-text); background: var(--ok-bg); }
.invite-link { font-family: var(--mono); font-size: 10.5px; color: var(--accent-bright); word-break: break-all; }

/* ---- Account / settings ---- */
.user-row { text-decoration: none; cursor: pointer; }
.user-row:hover { background: var(--row-active); border-radius: 9px; }
#view-account { max-width: 920px; margin: 0 auto; }
.acct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.acct-card { display: flex; flex-direction: column; gap: 12px; }
.acct-card-wide { grid-column: 1 / -1; }
.acct-field { display: flex; flex-direction: column; gap: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.acct-field input {
  font-family: var(--sans); font-size: 14px; color: var(--ink); background: var(--mist);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; text-transform: none; letter-spacing: 0;
}
.acct-field input:focus { outline: none; border-color: var(--accent); }
.acct-field input:disabled { color: var(--muted); }
.acct-actions { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.acct-actions .btn-primary, .acct-actions .btn-secondary { flex: none; }
.acct-sub { font-size: 13px; color: var(--slate); }
.acct-msg { font-family: var(--mono); font-size: 11px; }
.acct-msg.ok { color: var(--ok-text); }
.acct-msg.err { color: var(--hot-text); }
.team-list { display: flex; flex-direction: column; }
.team-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.team-row:first-child { border-top: none; }
.team-email { font-size: 13px; color: var(--ink); }
.team-admin { font-family: var(--mono); font-size: 8px; letter-spacing: 0.5px; color: var(--accent-bright); background: var(--haze); padding: 1px 5px; border-radius: 3px; }
.team-name { font-size: 11px; color: var(--slate); }
.team-seen { font-size: 10px; color: var(--muted); text-align: right; }
.team-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.team-add input[type="email"], .team-add input[type="text"], .team-add input[type="password"] {
  font-family: var(--sans); font-size: 13px; color: var(--ink); background: var(--mist);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; flex: 1; min-width: 120px;
}
.team-admin-check { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--slate); }
@media (max-width: 720px) { .acct-grid { grid-template-columns: 1fr; } }
