/* ===========================================================================
   Staff console: design tokens and styles.
   The frame (the rail, top bar, page head, tabs, numbers strip, dialog and notice) is drawn by @ballast/admin's createConsole
   (console-* class names). Colours are tokens only: the token blocks below are the one place a hex colour is written. Every other
   rule in this file, and every page's own stylesheet, reads var(--token).
   Three views (data-view on <html>: both, map, business) and two themes (data-bs-theme on <html>: light, dark; the theme follows the
   system unless the person chooses, see the kit's theme switch). The font is Inter when it is installed, else the system UI font.
   =========================================================================== */

/* TOKENS BEGIN */

/* Fixed data colours: map markers, code panes and the brand marks. They do not change with the view or the theme. */
:root {
  --c-red: #e74c3c;
  --c-green: #27ae60;
  --c-blue: #1f78b4;
  --c-navy: #0b3d66;
  --c-amber: #f39c12;
  --c-violet: #8e44ad;
  --c-purple: #7b2d8e;
  --c-purple-deep: #5d2069;
  --c-yellow: #f1c40f;
  --c-orange: #fd7e14;
  --c-link-blue: #0d6efd;
  --c-grey: #888888;
  --c-code-bg: #1e1e1e;
  --c-code-text: #d4d4d4;
  --c-primary: #0d6efd;
  --c-secondary: #6c757d;
  --c-success: #198754;
  --c-danger: #dc3545;
  --on-danger: #ffffff;
  --on-ok: #ffffff;
  --mark-tg: #424a75;
  --mark-sl: #007a3b;

  /* metrics */
  --rail-w: 264px;
  --topbar-h: 64px;
  --control-h: 36px;
  --r-shell: 16px;
  --r-card: 14px;
  --r-md: 12px;
  --r-sm: 10px;
  --r-ctl: 8px;
  --r-badge: 6px;

  --sans: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
}

/* Both, light: the default, before a view or a theme is set. */
:root,
:root[data-bs-theme="light"] {
  color-scheme: light;
  --canvas: #f5f5f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #efeff3;
  --surface-pane: #fafafb;
  --surface-row: #efeff3;
  --border: #e2e2e8;
  --border-soft: #ececf1;
  --track: #c4c6d0;
  --text: #16171c;
  --text-strong: #000000;
  --text-2: #3f414c;
  --text-3: #55585f;
  --text-4: #6b6e79;
  --text-5: #74777f;
  --accent: #2b2d3a;
  --accent-strong: #16171c;
  --accent-text: #16171c;
  --accent-link: #2b2d3a;
  --accent-surface: #ececf1;
  --accent-surface-alt: #f5f5f8;
  --accent-border: #cfd0d9;
  --accent-contrast: #ffffff;
  --ok: #1d6f42;
  --ok-text: #1d6f42;
  --ok-surface: #e5f3ea;
  --ok-border: #b9dfc8;
  --warn: #80530a;
  --warn-text: #80530a;
  --warn-surface: #fbf0d9;
  --warn-surface-deep: #f6e3bd;
  --danger: #c4302b;
  --danger-text: #b42318;
  --danger-surface: #fdecea;
  --info-text: #0b5b6b;
  --info-surface: #e2f4f8;
  --info-border: #a9dbe6;
  --warn-border: #ecd39b;
  --danger-border: #fdecea;
}

/* Both, dark */
:root[data-bs-theme="dark"] {
  color-scheme: dark;
  --canvas: #0c0e12;
  --surface: #14161c;
  --surface-raised: #14161c;
  --surface-sunken: #0f1116;
  --surface-pane: #121419;
  --surface-row: #1b1e25;
  --border: #2a2d36;
  --border-soft: #22252d;
  --track: #434753;
  --text: #ecedf1;
  --text-strong: #ffffff;
  --text-2: #d0d3dc;
  --text-3: #b8bbc6;
  --text-4: #8d909c;
  --text-5: #7d8090;
  --accent: #e3e4ea;
  --accent-strong: #ffffff;
  --accent-text: #ffffff;
  --accent-link: #e3e4ea;
  --accent-surface: #262a35;
  --accent-surface-alt: #1b1e26;
  --accent-border: #3a3e4b;
  --accent-contrast: #111217;
  --ok: #6fd59a;
  --ok-text: #6fd59a;
  --ok-surface: #12281b;
  --ok-border: #1f4d33;
  --warn: #f2c46b;
  --warn-text: #f2c46b;
  --warn-surface: #33260d;
  --warn-surface-deep: #1f1607;
  --danger: #c4302b;
  --danger-text: #ff9a90;
  --danger-surface: #3a1614;
  --info-text: #67e8f9;
  --info-surface: #062e3b;
  --info-border: #0f5566;
  --warn-border: #5c4316;
  --danger-border: #3a1614;
  --on-ok: #042f22;
}

/* TransitGraph (map view), light: the Unseen Horizons indigo */
:root[data-view="map"] {
  --canvas: #f7f6fb;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #f0eef7;
  --surface-pane: #fbfafd;
  --surface-row: #f0eef7;
  --border: #e3e0ee;
  --border-soft: #eeebf6;
  --track: #bdb8d3;
  --text: #15132a;
  --text-strong: #0b0a1a;
  --text-2: #2d2a45;
  --text-3: #47445f;
  --text-4: #5f5b76;
  --text-5: #716d88;
  --accent: #424a75;
  --accent-strong: #2f2a57;
  --accent-text: #2f2a57;
  --accent-link: #424a75;
  --accent-surface: #ebe9f6;
  --accent-surface-alt: #f4f3fa;
  --accent-border: #c7c2e2;
  --accent-contrast: #ffffff;
}

/* TransitGraph (map view), dark */
:root[data-view="map"][data-bs-theme="dark"] {
  --canvas: #05080a;
  --surface: #0e1217;
  --surface-raised: #0e1217;
  --surface-sunken: #080b0f;
  --surface-pane: #0b0f14;
  --surface-row: #161b22;
  --border: #252b35;
  --border-soft: #1b2029;
  --track: #3a4250;
  --text: #e8f6f9;
  --text-strong: #ffffff;
  --text-2: #c9d1dc;
  --text-3: #b6bfcc;
  --text-4: #8b95a4;
  --text-5: #6f7a8a;
  --accent: #a8b1d8;
  --accent-strong: #cdd3ee;
  --accent-text: #cdd3ee;
  --accent-link: #a8b1d8;
  --accent-surface: #1d2138;
  --accent-surface-alt: #171b2d;
  --accent-border: #3b4374;
  --accent-contrast: #0b0d1a;
}

/* Sherlane (business view), light: the app's green */
:root[data-view="business"] {
  --canvas: #f5f6f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #eef0f3;
  --surface-pane: #fafbfc;
  --surface-row: #eef0f3;
  --border: #e1e4e9;
  --border-soft: #eceef2;
  --track: #bfc4cd;
  --text: #141820;
  --text-strong: #0a0d12;
  --text-2: #2c3340;
  --text-3: #3f4756;
  --text-4: #4b5361;
  --text-5: #5f6774;
  --accent: #007a3b;
  --accent-strong: #006b37;
  --accent-text: #006b37;
  --accent-link: #007a3b;
  --accent-surface: #e8f6ee;
  --accent-surface-alt: #f3faf6;
  --accent-border: #b7dfc7;
  --accent-contrast: #ffffff;
}

/* Sherlane (business view), dark */
:root[data-view="business"][data-bs-theme="dark"] {
  --canvas: #0f1217;
  --surface: #151920;
  --surface-raised: #151920;
  --surface-sunken: #0c0f14;
  --surface-pane: #12161d;
  --surface-row: #1b2029;
  --border: #283039;
  --border-soft: #1e242d;
  --track: #3a424e;
  --text: #eef0f3;
  --text-strong: #ffffff;
  --text-2: #d3d8df;
  --text-3: #b9c0cb;
  --text-4: #8c94a1;
  --text-5: #7b8391;
  --accent: #3ccf7a;
  --accent-strong: #7ee0a4;
  --accent-text: #7ee0a4;
  --accent-link: #3ccf7a;
  --accent-surface: #13281c;
  --accent-surface-alt: #0f1f16;
  --accent-border: #245c3b;
  --accent-contrast: #06160d;
}

/* Both (both view): the neutral palette is the default above; the view only names its brand. */
:root[data-view="both"] {
  --accent-surface-alt: #f5f5f8;
}
:root[data-view="both"][data-bs-theme="dark"] {
  --accent-surface-alt: #1b1e26;
}

/* TOKENS END */

@keyframes pulseDot { 0% { opacity: 1 } 50% { opacity: .35 } 100% { opacity: 1 } }
@keyframes spin { to { transform: rotate(360deg) } }


/* ---------------------------------------------------------------- base ---- */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-link); text-decoration: none; }
a:hover { color: var(--accent-text); }

h1, h2, h3 { margin: 0; font-weight: 700; }

.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.dim { color: var(--text-4); }
.faint { color: var(--text-5); }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* ------------------------------------------------------ console frame ---- */

.console-shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}
.console-shell.is-folded { grid-template-columns: 76px minmax(0, 1fr); }
.console-shell.is-fullscreen { display: flex; flex-direction: column; min-height: 0; height: 100vh; height: 100dvh; }
/* A full-screen page: the bar on top, and the page's area fills the rest of the window. The legacy content is absolute inside it, so a
   map sized to 100% of it fills the space under the bar, and its panels sit inside that space. */
.console-shell.is-fullscreen > .console-page { flex: 1 1 auto; min-height: 0; position: relative; }
.console-shell.is-fullscreen .console-content.is-legacy { position: absolute; inset: 0; max-width: none; padding: 0; overflow: hidden; }

.console-rail {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-sizing: border-box;
}
.console-shell.is-folded .console-rail { padding: 18px 10px; }

.console-rail-head { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.console-shell.is-folded .console-rail-head { flex-direction: column; }

.console-mark {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 72% auto;
}
:root[data-view="map"] .console-mark { color: transparent; background-color: var(--mark-tg); background-image: url(/staff/brand/transitgraph-mark.svg); }
:root[data-view="business"] .console-mark { color: transparent; background-color: var(--mark-sl); background-image: url(/staff/brand/sherlane-mark.svg); }
:root[data-view="both"] .console-mark { background: linear-gradient(135deg, var(--mark-tg) 50%, var(--mark-sl) 50%); color: var(--on-danger); }

.console-name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.console-name b { font-size: 16px; font-weight: 650; }
.console-name span { font-size: 13px; color: var(--text-3); }

.console-fold {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.console-fold:hover { background: var(--surface-row); color: var(--text); }

.console-views {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-row);
}
.console-view {
  flex: 1 1 0;
  min-height: 40px;
  padding: 0 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}
.console-view:hover { color: var(--text); }
.console-view.is-active { background: var(--surface); color: var(--accent-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); font-weight: 650; }

.console-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.console-group { display: flex; flex-direction: column; gap: 2px; }
.console-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 12px 4px;
}

.console-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
}
.console-item:hover { background: var(--surface-row); color: var(--text); }
.console-item.is-active { background: var(--accent-surface); color: var(--accent-text); font-weight: 650; }
.console-item > i { width: 20px; text-align: center; flex: 0 0 20px; }
.console-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.console-count,
.console-badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}
.console-count { color: var(--text-3); font-weight: 550; }
.console-badge { background: var(--danger); color: var(--on-danger); }
.console-badge.is-accent { background: var(--accent); color: var(--accent-contrast); }
.console-badge.is-warn { background: var(--warn-surface); color: var(--warn-text); }
.console-dot { margin-left: auto; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.console-dot.is-live { animation: pulseDot 2s infinite; }

.console-rail-foot { display: flex; flex-direction: column; gap: 8px; }
.console-rail-foot .mono,
.console-env { font-family: var(--mono); font-size: 11px; color: var(--text-4); padding-left: 4px; }
.console-theme {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-row);
}
.console-theme-btn {
  flex: 1 1 0;
  min-height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  text-transform: capitalize;
  cursor: pointer;
}
.console-theme-btn:hover { color: var(--text); }
.console-theme-btn.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); font-weight: 600; }

.console-shell.is-folded .console-name,
.console-shell.is-folded .console-views,
.console-shell.is-folded .console-group-label,
.console-shell.is-folded .console-item-text,
.console-shell.is-folded .console-count,
.console-shell.is-folded .console-env,
.console-shell.is-folded .console-theme,
.console-shell.is-folded .console-rail-foot .mono { display: none; }
.console-shell.is-folded .console-item { justify-content: center; padding: 0; position: relative; }
.console-shell.is-folded .console-item .console-badge { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }

.console-main { display: flex; flex-direction: column; min-width: 0; }

.console-topbar {
  display: flex;
  align-items: center;
  gap: 12px 20px;
  padding: 12px 32px;
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
  box-sizing: border-box;
}
.console-spacer { flex: 1; }
.console-search { position: relative; flex: 0 1 380px; min-width: 0; }
.console-search-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--canvas);
  color: var(--text);
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  box-sizing: border-box;
}
.console-search-input:focus { outline: none; border-color: var(--accent); }
.console-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  z-index: 10;
}
.console-search-results.console-hidden { display: none; }
.console-search-result { display: block; padding: 10px 14px; color: var(--text); text-decoration: none; border-top: 1px solid var(--border-soft); }
.console-search-result:first-child { border-top: 0; }
.console-search-result:hover { background: var(--surface-row); }
.console-search-text { display: block; font-weight: 600; }
.console-search-sub { display: block; font-size: 13px; color: var(--text-3); }
.console-search-empty { padding: 12px 14px; color: var(--text-3); }
.console-search-empty.is-error { color: var(--danger-text); }
.console-avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--accent-surface);
  color: var(--accent-text);
  font-weight: 650;
  cursor: pointer;
}

.console-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 32px 0;
  width: 100%;
  box-sizing: border-box;
}
.console-crumb { font-size: 14px; color: var(--text-3); }
.console-title { margin: 0; font-size: 28px; font-weight: 680; letter-spacing: -.01em; color: var(--text-strong); }
.console-purpose { margin: 0; color: var(--text-2); font-size: 15.5px; max-width: 720px; }
.console-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.console-meta { font-family: var(--mono); font-size: 12px; color: var(--text-4); margin-right: auto; }
.console-numbers { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; }
.console-number {
  flex: 1 1 170px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  min-width: 0;
}
.console-number-value { display: block; font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.console-number-value.is-uncounted { font-size: 15px; font-weight: 550; font-style: italic; color: var(--text-4); }
.console-number-label { display: block; font-size: 13.5px; color: var(--text-2); }
.console-number.is-ok .console-number-value { color: var(--ok-text); }
.console-number.is-warn .console-number-value { color: var(--warn-text); }
.console-number.is-bad .console-number-value { color: var(--danger-text); }
.console-number.is-accent .console-number-value { color: var(--accent-text); }

.console-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 6px; }
.console-tab {
  min-height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.console-tab:hover { color: var(--text); }
.console-tab.is-active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 650; }

/* The page head and content take the whole width beside the rail; only running text (.console-purpose) keeps a reading width. */
.console-content { padding: 24px 32px 48px; width: 100%; box-sizing: border-box; font-size: 16px; }
/* A page's Bootstrap .container (most map pages, the AI page, the source editors) would centre it at a fixed width: inside the
   console it takes the whole width, as the console's own pages do. */
.console-content .container,
.console-content .container-sm,
.console-content .container-md,
.console-content .container-lg,
.console-content .container-xl,
.console-content .container-xxl { max-width: none; padding-left: 0; padding-right: 0; }
.console-content.is-legacy { padding-top: 16px; }

.console-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
  box-sizing: border-box;
}
.console-bar .console-title { font-size: 20px; }
.console-back { color: var(--accent-link); text-decoration: none; font-weight: 600; }
.console-page { padding: 0; }

.console-dialog {
  width: calc(100% - 32px);
  max-width: 480px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.console-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.console-dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 22px; margin: 0; }
.console-dialog-title { margin: 0; font-size: 18px; font-weight: 650; color: var(--text-strong); }
.console-dialog-body { margin: 0; color: var(--text-2); }
.console-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.console-notice {
  position: sticky;
  bottom: 16px;
  margin: 0 32px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.console-notice-text { flex: 1; min-width: 0; }

.console-hidden { display: none !important; }

/* The login page's brand block (login.html stays as it is). */
.rail-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  background: var(--accent-strong);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-contrast);
}
.rail-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* -------------------------------------------------------- responsive ---- */

@media (max-width: 1200px) {
  .console-title { font-size: 24px; }
}

@media (max-width: 900px) {
  .console-shell,
  .console-shell.is-folded { display: block; }
  .console-rail {
    position: static;
    height: auto;
    flex-direction: column;
    padding: 14px 16px;
    gap: 12px;
  }
  .console-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .console-group { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .console-group-label { display: none; }
  .console-item { min-height: 40px; }
  .console-topbar { padding: 10px 16px; }
  .console-search { display: none; }
  .console-head { padding: 20px 16px 0; }
  .console-content { padding: 16px; }
  .console-notice { margin: 0 16px 12px; }
}

@media (max-width: 640px) {
  .console-title { font-size: 22px; }
  .console-number { flex: 1 1 140px; }
  .console-tab { padding: 0 10px; }
  .console-env { display: none; }
}

/* ---------------------------------------------------------------- icons ---- */

.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: var(--icon) center/contain no-repeat;
  mask: var(--icon) center/contain no-repeat;
}

.icon-logo     { --icon: url(icons/logo_white.svg); }
.icon-map      { --icon: url(icons/map_white.svg); }
.icon-ticket   { --icon: url(icons/ticket_white.svg); }
.icon-train    { --icon: url(icons/train_white.svg); }
.icon-shop     { --icon: url(icons/shop_bag_white.svg); }
.icon-profile  { --icon: url(icons/profile_white.svg); }
.icon-settings { --icon: url(icons/settings_white.svg); }
.icon-arrow    { --icon: url(icons/arrow_right_white.svg); }
.icon-eye      { --icon: url(icons/eye.svg); }
.icon-eye-off  { --icon: url(icons/eye_cl.svg); }

/* ----------------------------------------------------------------- kpis ---- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.kpi {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.kpi.is-accent { border-color: var(--accent-border); }
.kpi.is-accent .kpi-label { color: var(--accent-text); }

.kpi-label {
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--text-4);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpi-row { display: flex; align-items: baseline; gap: 8px; }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-family: var(--mono); font-size: 11px; color: var(--text-4); }
.kpi-unit { font-size: 14px; color: var(--text-4); }

.kpi-delta { font-size: 12px; font-weight: 600; }
.kpi-delta.is-up { color: var(--ok-text); }
.kpi-delta.is-down { color: var(--warn-text); }
.kpi-delta.is-flat { color: var(--text-4); }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; }
.spark i { flex: 1; background: var(--accent-border); border-radius: 2px; min-height: 2px; }
.spark i:nth-last-child(2) { background: var(--accent-strong); }
.spark i:last-child { background: var(--accent); }

.bars { display: flex; gap: 3px; height: 8px; }
.bars i { flex: 1; border-radius: 2px; background: var(--ok); }
.bars i.is-warn { background: var(--warn); }
.bars i.is-danger { background: var(--danger); }

.meter { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--ok); }
.meter.is-warn > i { background: var(--warn); }
.meter.is-danger > i { background: var(--danger); }

/* ---------------------------------------------------------------- cards ---- */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.card.is-flush { padding: 18px; gap: 14px; }
.card.is-grow { flex: 1; min-height: 0; }
.card.is-accent { border-color: var(--accent-border); }

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 13px; font-weight: 700; }
.card-meta { font-family: var(--mono); font-size: 11px; color: var(--text-4); }
.card-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.card-body.is-scroll { overflow-y: auto; }

.card-foot {
  margin-top: auto;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-4);
}

.split { display: grid; grid-template-columns: 1fr 380px; gap: 20px; flex: 1; min-height: 0; }
.split.is-wide { grid-template-columns: 1fr 400px; }
.stack { display: flex; flex-direction: column; gap: 20px; min-height: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.section-label {
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--text-4);
  font-weight: 700;
}

.rule { display: flex; align-items: center; gap: 10px; }
.rule::before, .rule::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.rule > span { font-family: var(--mono); font-size: 10.5px; color: var(--text-5); }

/* --------------------------------------------------------------- tables ---- */

/* The console's grid lists: a <div class="table"> of .thead and .trow rows. Scoped to div, because a real <table class="table">
   is Bootstrap's: display: flex on a <table> breaks its column layout, and the header cells no longer line up with the rows. */

div.table { display: flex; flex-direction: column; min-width: 0; }

div.table > .thead,
div.table > .trow {
  display: grid;
  grid-template-columns: var(--cols, repeat(auto-fit, minmax(0, 1fr)));
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
}

div.table > .thead {
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--text-5);
  text-transform: uppercase;
}

div.table > .trow {
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}

div.table > .trow:last-child { border-bottom: 0; }
div.table > .trow:hover { background: var(--surface-row); }
div.table > .trow.is-flagged { background: var(--accent-surface-alt); }
div.table > .trow.is-selected { background: var(--accent-surface); }
div.table > .trow > div { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
div.table .id { font-family: var(--mono); color: var(--accent-link); }
div.table .num { font-weight: 600; font-variant-numeric: tabular-nums; }
div.table .sub { font-family: var(--mono); font-size: 11px; color: var(--text-4); }

.table-scroll { overflow-x: auto; }
.table-scroll > div.table { min-width: 720px; }

/* --------------------------------------------------------------- badges ---- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-badge);
  background: var(--border);
  color: var(--text-2);
  white-space: nowrap;
}

.badge.is-ok { background: var(--ok-surface); color: var(--ok-text); }
.badge.is-warn { background: var(--warn-surface); color: var(--warn-text); }
.badge.is-danger { background: var(--danger-surface); color: var(--danger-text); }
.badge.is-info { background: var(--info-surface); color: var(--info-text); }
.badge.is-accent { background: var(--accent-surface); color: var(--accent-text); }
.badge.is-neutral { background: var(--border); color: var(--text-2); }

/* Route-type chip rendered by rtBadge() in route-colors.js. no other rule styles it, so a bare
   inline background used to sit flush against the letters. Matches .route-type-badge on the map. */
.rt-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--accent-contrast);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--ok);
}

.dot.is-live { animation: pulseDot 2s infinite; }
.dot.is-warn { background: var(--warn); }
.dot.is-danger { background: var(--danger); }
.dot.is-idle { background: var(--track); animation: none; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  font: inherit;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-3);
  cursor: pointer;
}

.pill:hover { color: var(--text-2); border-color: var(--track); }

.pill.is-active {
  background: var(--accent-surface);
  color: var(--accent-text);
  border-color: transparent;
  font-weight: 600;
}

/* -------------------------------------------------------------- buttons ---- */

.btn {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  height: var(--control-h);
  padding: 0 14px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: var(--track); color: var(--text-strong); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.is-primary {
  background: var(--accent-strong);
  border-color: transparent;
  color: var(--accent-contrast);
  font-weight: 600;
}

.btn.is-primary:hover { filter: brightness(1.12); }

.btn.is-accent {
  border-color: var(--accent-border);
  color: var(--accent-text);
  font-weight: 600;
}

.btn.is-ok { background: var(--ok); border-color: transparent; color: var(--on-ok); font-weight: 600; }
.btn.is-danger { border-color: var(--danger-surface); color: var(--danger-text); font-weight: 600; }
.btn.is-block { width: 100%; justify-content: center; }
.btn.is-sm { height: 28px; padding: 0 10px; font-size: 11px; }

.pager { display: flex; gap: 6px; }

.pager .btn {
  height: 26px;
  padding: 0 9px;
  font-size: 11px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- lists ---- */

.list { display: flex; flex-direction: column; }

.list > .row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-soft);
  min-width: 0;
}

.list > .row:last-child { border-bottom: 0; }
.list > .row:hover { background: var(--surface-row); }
.list > .row.is-selected { background: var(--accent-surface-alt); }
.list .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list .grow b { font-size: 12.5px; font-weight: 600; }
.list .grow span { font-family: var(--mono); font-size: 10.5px; color: var(--text-4); }

.tile {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: var(--r-ctl);
  background: var(--accent-surface);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-text);
}

.tile.is-warn { background: var(--warn-surface); color: var(--warn-text); }
.tile.is-danger { background: var(--danger-surface); color: var(--danger-text); }
.tile.is-muted { background: var(--surface); color: var(--text-3); border: 1px solid var(--border); }

/* ---------------------------------------------------------------- notes ---- */

.note {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--surface-row);
  border: 1px solid var(--border);
}

.note::before { content: ''; width: 3px; flex: 0 0 3px; border-radius: 2px; background: var(--track); }
.note > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.note b { font-size: 12.5px; font-weight: 600; }
.note span { font-size: 11.5px; color: var(--text-3); }

.note.is-accent { background: var(--accent-surface-alt); border-color: var(--accent-border); }
.note.is-accent::before { background: var(--accent); }
.note.is-warn { background: var(--warn-surface-deep); border-color: var(--warn-surface); }
.note.is-warn::before { background: var(--warn); }
.note.is-warn b { color: var(--warn-text); }
.note.is-danger { background: var(--danger-surface); border-color: var(--danger-surface); }
.note.is-danger::before { background: var(--danger); }
.note.is-danger b { color: var(--danger-text); }

/* --------------------------------------------------------------- fields ---- */

.field { display: flex; flex-direction: column; gap: 5px; }

.field > label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-4);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.field > .hint { font-size: 11px; color: var(--text-4); }

.input, .select {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-ctl);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  outline: none;
}

.input:focus, .select:focus { border-color: var(--accent-border); }
.input.is-mono { font-family: var(--mono); font-size: 12px; color: var(--accent-link); }
.input.is-readonly { color: var(--text-2); }

.select { appearance: none; cursor: pointer; }

.toggle {
  width: 40px;
  height: 22px;
  flex: 0 0 40px;
  border-radius: 11px;
  background: var(--border);
  border: 0;
  padding: 2px;
  display: flex;
  justify-content: flex-start;
  cursor: pointer;
}

.toggle > i { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); display: block; }
.toggle.is-on { background: var(--ok); justify-content: flex-end; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row > div { display: flex; flex-direction: column; gap: 2px; }
.switch-row b { font-size: 12.5px; font-weight: 600; }
.switch-row span { font-size: 11px; color: var(--text-4); }

/* ----------------------------------------------------------------- code ---- */

.code {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--text-3);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.code .k { color: var(--accent-link); }
.code .s { color: var(--ok-text); }
.code .n { color: var(--warn-text); }
.code .add { color: var(--ok-text); }
.code .del { color: var(--danger-text); }

.log {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.9;
  padding: 12px 18px;
  color: var(--text-3);
  overflow: auto;
}

.log .t { color: var(--text-5); }
.log .ok { color: var(--ok-text); }
.log .err { color: var(--danger-text); }
.log .warn { color: var(--warn-text); }

.kv { display: grid; grid-template-columns: 92px 1fr; row-gap: 7px; column-gap: 10px; font-size: 12px; }
.kv > dt { color: var(--text-4); margin: 0; }
.kv > dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* -------------------------------------------------------------- feedback ---- */

.alert {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--danger-border);
  background: var(--danger-surface);
  color: var(--danger-text);
  font-size: 12.5px;
}

/* Each alert variant has its own tokens in both themes, so a note (info, success) is not drawn in the danger colours. A bare .alert
   (the kit's no-access notice) keeps the danger look it always had. */
.alert-danger { background: var(--danger-surface); border-color: var(--danger-border); color: var(--danger-text); }
.alert-success { background: var(--ok-surface); border-color: var(--ok-border); color: var(--ok-text); }
.alert-info { background: var(--info-surface); border-color: var(--info-border); color: var(--info-text); }
.alert-warning { background: var(--warn-surface); border-color: var(--warn-border); color: var(--warn-text); }
.alert-secondary { background: var(--surface-sunken); border-color: var(--border); color: var(--text-3); }
.alert-light { background: var(--surface-pane); border-color: var(--border); color: var(--text-2); }

.empty {
  padding: 40px 18px;
  text-align: center;
  color: var(--text-4);
  font-size: 12.5px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 18px;
  color: var(--text-4);
  font-size: 12.5px;
}

.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

.skeleton {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 0%, var(--surface-row) 50%, var(--border) 100%);
  background-size: 200% 100%;
  animation: pulseDot 1.4s ease-in-out infinite;
}

/* ----------------------------------------------------------------- auth ---- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, var(--accent-surface-alt) 0%, transparent 70%),
    var(--canvas);
}

.auth-card {
  width: 360px;
  max-width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-shell);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-head { display: flex; align-items: center; gap: 12px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }


/* -------------------------------------------------------- responsive ---- */

@media (max-width: 1200px) {
  .split, .split.is-wide { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .kpis, .grid-2, .grid-4 { grid-template-columns: 1fr; }
}

/* Home pages (staff UI Part C): the heading over each group of needs-you lines. Colours are the tokens, not hex. */
.section-title { margin: 0 0 10px; font-size: 13px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }

/* --------------------------------------------------- Bootstrap tables ---- */
/* The pages' <table class="table"> (Bootstrap) in the console's look: no dark header bar, small capital headers, soft row lines,
   a hover row, and the table in a bordered box. Colours are the view's tokens, so they follow the view and the theme. */
.console-content .table {
  --bs-table-color: var(--text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border-soft);
  --bs-table-striped-color: var(--text);
  --bs-table-striped-bg: var(--surface-pane);
  --bs-table-hover-color: var(--text);
  --bs-table-hover-bg: var(--surface-row);
  --bs-table-active-bg: var(--accent-surface);
  margin-bottom: 0;
  font-size: 15px;
  vertical-align: middle;
}
.console-content .table > thead,
.console-content .table > thead.table-dark,
.console-content .table > thead.table-light {
  --bs-table-color: var(--text-4);
  --bs-table-bg: var(--surface-sunken);
  --bs-table-border-color: var(--border);
}
.console-content .table > thead th {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 10px 14px;
  border-bottom-width: 1px;
}
.console-content .table > tbody > tr > * { padding: 11px 14px; }
.console-content .table.table-sm > tbody > tr > * { padding: 7px 12px; }
.console-content .table.table-sm > thead th { padding: 8px 12px; }
.console-content .table > tbody > tr:last-child > * { border-bottom: 0; }
.console-content .table-responsive {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1rem;
}
.console-content .card .table-responsive,
.console-content .staff-card .table-responsive { border-radius: 8px; }

