/* NetDown design system — shared by every page and component.
 *
 * Rules
 *  - Colour by role, never by hex in page code: use the tokens below.
 *  - Status colours (--ok/--warn/--partial/--bad/--maint) mean status only. Layers/series use the
 *    --layer-* and --series-* tokens. Status is always paired with a label or icon, never colour alone.
 *  - Light and dark are both first-class: tokens are redefined for dark, and an explicit
 *    [data-theme] on <html> wins over the OS setting either way.
 *  - Icons: Material Symbols Rounded (self-hosted). <span class="ms">public</span>; add .ms-fill for filled.
 *  - Touch targets >= 36px; focus is always visible.
 */

@font-face {
  font-family: "Material Symbols Rounded";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/static/vendor/fonts/material-symbols-rounded.woff2") format("woff2");
}

:root {
  color-scheme: light;
  /* surfaces & text */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;          /* raised inside a surface: inputs, chips, stat tiles */
  --surface-3: #e7eaef;          /* hover / pressed */
  --text: #12161c;
  --text-2: #4b5563;             /* secondary */
  --text-3: #6b7280;             /* muted, captions */
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --accent: #2563eb;             /* links, primary actions, focus */
  --accent-text: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --shadow-1: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  --shadow-2: 0 10px 30px rgb(16 24 40 / .16);
  /* status (reserved) */
  --ok: #0ca30c; --maint: #2a78d6; --warn: #e09a00; --partial: #e6703c; --bad: #d03b3b; --unknown: #8a94a3;
  /* layers & series (never status) */
  --layer-backbone: #0891b2; --layer-cable: #7c6cf0; --layer-reports: #2a78d6; --layer-you: #1f8fff;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4;
  /* shape */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b0e13; --surface: #141921; --surface-2: #1b222c; --surface-3: #232b37;
    --text: #e8ecf1; --text-2: #b4bdc9; --text-3: #8c96a3;
    --line: #242c37; --line-strong: #323c49;
    --accent: #6aa8ff; --accent-text: #08111f;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 12px 34px rgb(0 0 0 / .55);
    --maint: #3987e5; --warn: #f5b324; --partial: #f08a5a; --bad: #ef5a5a; --unknown: #6b7685;
    --layer-backbone: #22d3ee; --layer-cable: #a29bfe; --layer-reports: #3987e5;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e13; --surface: #141921; --surface-2: #1b222c; --surface-3: #232b37;
  --text: #e8ecf1; --text-2: #b4bdc9; --text-3: #8c96a3;
  --line: #242c37; --line-strong: #323c49;
  --accent: #6aa8ff; --accent-text: #08111f;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 12px 34px rgb(0 0 0 / .55);
  --maint: #3987e5; --warn: #f5b324; --partial: #f08a5a; --bad: #ef5a5a; --unknown: #6b7685;
  --layer-backbone: #22d3ee; --layer-cable: #a29bfe; --layer-reports: #3987e5;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html:has(body.nd), body.nd { overflow-x: clip; }   /* off-screen tooltips must never widen the page */
body.nd { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; }
.nd a { color: var(--accent); text-decoration: none; }
.nd a:hover { text-decoration: underline; text-underline-offset: 2px; }
.nd :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.nd h1, .nd h2, .nd h3 { letter-spacing: -0.01em; line-height: 1.25; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- icons */
.ms { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 20px;
  line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap;
  direction: ltr; -webkit-font-feature-settings: "liga"; font-feature-settings: "liga";
  font-variation-settings: "FILL" 0; vertical-align: middle; user-select: none; flex: none; }
.ms-fill { font-variation-settings: "FILL" 1; }
.ms-sm { font-size: 16px; } .ms-lg { font-size: 24px; }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-pad { padding: 16px; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 650; }
.section-sub { color: var(--text-3); font-size: 13px; margin: 2px 0 0; }
.divider { height: 1px; background: var(--line); border: 0; margin: 12px 0; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
  padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); font: 600 14px/1 var(--font); cursor: pointer; text-decoration: none !important;
  transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: var(--r-sm); border: 1px solid transparent;
  background: transparent; color: var(--text-2); display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.nd a.icon-btn { color: var(--text-2); text-decoration: none; }
.nd a.icon-btn:hover { color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: calc(var(--r-sm) + 3px); }
.seg button { border: 0; background: transparent; color: var(--text-2); font: 600 13px/1 var(--font);
  min-height: 30px; padding: 0 12px; border-radius: var(--r-sm); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* toggle chips (e.g. map layers): icon + label, pressed state */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px 0 10px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  font: 600 13px/1 var(--font); cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); }
.chip .ms { font-size: 18px; color: var(--chip-c, var(--text-3)); }
.chip[aria-pressed="false"] .ms { opacity: .55; }

/* status badge: dot + label (status never colour-only) */
.badge { display: inline-flex; align-items: center; gap: 6px; font: 650 12px/1 var(--font); color: var(--text);
  padding: 5px 9px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--c, var(--unknown)) 14%, transparent); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--unknown)); }

/* ---------------------------------------------------------------- forms */
.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.input, .select, .textarea { width: 100%; font: 15px/1.4 var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 9px 11px; }
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field .hint { font-weight: 400; color: var(--text-3); font-size: 12px; }
.field .error { font-weight: 500; color: var(--bad); font-size: 12px; }

/* ---------------------------------------------------------------- tooltips: <el data-tip="…"> */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px);
  transform: translate(-50%, 4px); opacity: 0; pointer-events: none; white-space: pre-line; width: max-content;
  max-width: 240px; padding: 7px 9px; border-radius: 8px; background: #111722; color: #eef2f7;
  font: 500 12px/1.35 var(--font); box-shadow: var(--shadow-2); transition: opacity .12s, transform .12s; z-index: 40; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: .25s; }
[data-tip-pos="below"]::after { bottom: auto; top: calc(100% + 8px); }
@media (hover: none) { [data-tip]::after { display: none; } }

/* ---------------------------------------------------------------- modal & sheet */
dialog.modal { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  padding: 0; width: min(560px, calc(100vw - 24px)); max-height: min(86vh, 900px); box-shadow: var(--shadow-2); }
dialog.modal::backdrop { background: rgb(5 8 14 / .55); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 4px 18px 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- lists & tables */
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); }
.list-row:hover { background: var(--surface-2); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--text-3); font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.table tr:hover td { background: var(--surface-2); }

/* ---------------------------------------------------------------- utility */
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
