/*
 * SIWS design system — single source of truth for web UI tokens and shared components.
 * Spec: DESIGN.md, docs/design-system/. Served as /design/siws.css by Portal and ERP.
 * Load it before a page's own <style>; page CSS may compose tokens but must not redefine them.
 * Unity mirrors the dark-surface tokens in apps/twin/.../Authoring/Dashboard.uss (checked by tools/design-check.py).
 */

:root {
  color-scheme: light;

  /* Brand */
  --siws-brand-navy: #102d40;
  --siws-brand-ink: #18374c;
  --siws-brand-rule: #9eb2c0;

  /* Action (teal) — the only interactive accent on light surfaces */
  --siws-action: #087e8b;
  --siws-action-hover: #056772;
  --siws-action-ink: #075c67;
  --siws-action-current: #00616f;
  --siws-action-border: #bed3d7;
  --siws-action-border-strong: #86b3bb;
  --siws-action-tint: #eef6f7;
  --siws-action-selected: #e7f2f3;
  --siws-focus: #58aab7;

  /* Surfaces */
  --siws-bg-page: #f5f7fa;
  --siws-bg-surface: #ffffff;
  --siws-bg-subtle: #f7fafb;
  --siws-bg-muted: #eef3f6;
  --siws-bg-hover: #f0f5f8;
  --siws-bg-overlay: rgba(12, 30, 44, .48);
  --siws-bg-glass: rgba(255, 255, 255, .92);
  --siws-bg-hud: rgba(13, 30, 45, .9);

  /* Lines */
  --siws-line: #dce5ed;
  --siws-line-subtle: #e6edf1;
  --siws-line-strong: #c7d4de;
  --siws-line-input: #cdd8e2;

  /* Text */
  --siws-text: #203349;
  --siws-text-secondary: #42596c;
  --siws-text-muted: #587084;
  --siws-text-subtle: #71879a;
  --siws-text-disabled: #8a99a6;
  --siws-text-inverse: #ffffff;

  /* Semantic status (Carbon-style: fg on bg, never colour alone — pair with a label or icon) */
  --siws-success: #1f7a45;      --siws-success-bg: #e3f4ea;   --siws-success-solid: #2b8a3e;
  --siws-warning: #8a5600;      --siws-warning-bg: #fdf0d9;   --siws-warning-solid: #e67700;
  --siws-danger: #9b2c22;       --siws-danger-bg: #fde8e6;    --siws-danger-solid: #c92a2a;
  --siws-info: #1d5a8f;         --siws-info-bg: #e8f1fa;      --siws-info-solid: #1568a5;
  --siws-neutral: #56697a;      --siws-neutral-bg: #ebf0f3;   --siws-neutral-solid: #868e96;
  --siws-sim: #5b3cc4;          --siws-sim-bg: #efeafd;       --siws-sim-solid: #7048e8;

  /* Production plan vs. actual (control, ERP) */
  --siws-plan: #5c7080;
  --siws-forecast: var(--siws-warning-solid);
  --siws-done: var(--siws-success-solid);
  --siws-late: var(--siws-danger-solid);

  /* Shuttle routes — default palette for new routes; route colour itself comes from ERP data */
  --siws-route-1: #1568a5;
  --siws-route-2: #087867;
  --siws-route-3: #c2571a;
  --siws-route-4: #7048e8;
  --siws-route-5: #b02a6b;
  --siws-route-6: #5c7080;

  /* Wayfinding */
  --siws-origin: #1f8a4c;
  --siws-destination: #c2412d;
  --siws-walk: #2b9be0;
  --siws-drive: #e9822e;
  --siws-live: #d6402f;

  /* Facility categories on maps */
  --siws-facility-dock: #2f7fb0;
  --siws-facility-quay: #8f7fd6;
  --siws-facility-shop: #efb44a;
  --siws-facility-yard: #3fb995;
  --siws-facility-store: #e07fb0;
  --siws-facility-hull: #f0643f;

  /* Dark spatial surfaces (Digital Twin HUD, map HUD). Mirrors --gl-* in
     shared/unity-packages/com.growthlab.ui/Runtime/Resources/GrowthLabUI.uss — keep equal (tools/design-check.py). */
  --siws-dark-bg: rgba(16, 19, 26, 0.92);
  --siws-dark-surface: rgb(30, 35, 46);
  --siws-dark-border: rgb(52, 60, 76);
  --siws-dark-text: rgb(230, 234, 242);
  --siws-dark-text-dim: rgb(150, 160, 178);
  --siws-dark-accent: rgb(84, 160, 255);
  --siws-dark-normal: rgb(64, 190, 120);
  --siws-dark-info: rgb(84, 160, 255);
  --siws-dark-warning: rgb(240, 190, 60);
  --siws-dark-alarm: rgb(235, 80, 70);
  --siws-dark-offline: rgb(120, 128, 140);
  --siws-dark-radius: 6px;

  /* Typography */
  --siws-font-sans: Inter, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --siws-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --siws-font-script: "Snell Roundhand", "Apple Chancery", "Brush Script MT", cursive;
  --siws-text-2xs: 11px;
  --siws-text-xs: 12px;
  --siws-text-sm: 13px;
  --siws-text-md: 14px;
  --siws-text-base: 15px;
  --siws-text-lg: 17px;
  --siws-text-xl: 20px;
  --siws-text-2xl: 25px;
  --siws-text-3xl: 32px;
  --siws-weight-regular: 400;
  --siws-weight-medium: 600;
  --siws-weight-bold: 700;
  --siws-weight-heavy: 800;
  --siws-leading-tight: 1.3;
  --siws-leading: 1.55;

  /* Spacing (4px grid) */
  --siws-space-1: 4px;
  --siws-space-2: 8px;
  --siws-space-3: 12px;
  --siws-space-4: 16px;
  --siws-space-5: 20px;
  --siws-space-6: 24px;
  --siws-space-8: 32px;
  --siws-space-10: 40px;
  --siws-space-12: 48px;
  --siws-gutter: clamp(12px, 2vw, 24px);

  /* Radius */
  --siws-radius-xs: 5px;
  --siws-radius-sm: 7px;
  --siws-radius-md: 10px;
  --siws-radius-lg: 12px;
  --siws-radius-xl: 16px;
  --siws-radius-pill: 999px;

  /* Elevation */
  --siws-shadow-xs: 0 1px 2px rgba(16, 40, 62, .06);
  --siws-shadow-sm: 0 3px 12px rgba(16, 40, 62, .06);
  --siws-shadow-md: 0 8px 26px rgba(25, 55, 77, .14);
  --siws-shadow-lg: 0 18px 60px rgba(32, 51, 73, .16);
  --siws-shadow-float: 0 10px 30px rgba(16, 40, 62, .18);

  /* Layers */
  --siws-z-raised: 10;
  --siws-z-sticky: 100;
  --siws-z-map-ui: 500;
  --siws-z-dropdown: 1000;
  --siws-z-header: 2000;
  --siws-z-drawer: 3000;
  --siws-z-modal: 4000;
  --siws-z-toast: 5000;
  --siws-z-tooltip: 6000;

  /* Motion */
  --siws-dur-instant: 80ms;
  --siws-dur-fast: 150ms;
  --siws-dur-base: 240ms;
  --siws-dur-slow: 400ms;
  --siws-dur-camera: 650ms;
  --siws-ease-standard: cubic-bezier(.2, 0, 0, 1);
  --siws-ease-out: cubic-bezier(.2, .8, .2, 1);
  --siws-ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --siws-ease-emphasis: cubic-bezier(.34, 1.56, .64, 1);

  /* Icons */
  --siws-icon-xs: 14px;
  --siws-icon-sm: 16px;
  --siws-icon-md: 18px;
  --siws-icon-lg: 20px;
  --siws-icon-xl: 24px;

  /* Layout — breakpoints are documented constants (CSS variables cannot drive @media):
     sm 640px · md 900px · lg 1270px */
  --siws-header-h: 72px;
  --siws-content-max: 1230px;
  --siws-touch-target: 44px;
  --siws-ai-top: var(--siws-header-h);
}

/* Dark theme for every web screen. /design/siws-theme.js sets <html data-theme="light|dark"> from the viewer's
 * choice (light · dark · follow the system) before first paint. Pages without the attribute stay light.
 * Redefines values only; token names are the light set above. --siws-dark-* (Twin/map HUD) is separate. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --siws-brand-ink: #e3ebf1;
  --siws-brand-rule: #4b6275;
  --siws-action: #2fb3bf;
  --siws-action-hover: #4cc6d1;
  --siws-action-ink: #7fd6de;
  --siws-action-current: #8fdde4;
  --siws-action-border: #2a5961;
  --siws-action-border-strong: #3c7a84;
  --siws-action-tint: #11303a;
  --siws-action-selected: #153a44;
  --siws-focus: #4cc6d1;
  --siws-bg-page: #0d1720;
  --siws-bg-surface: #141f2a;
  --siws-bg-subtle: #18242f;
  --siws-bg-muted: #1e2c38;
  --siws-bg-hover: #1c2a36;
  --siws-bg-overlay: rgba(0, 0, 0, .6);
  --siws-bg-glass: rgba(20, 31, 42, .92);
  --siws-line: #26384a;
  --siws-line-subtle: #1f2f3d;
  --siws-line-strong: #34495c;
  --siws-line-input: #3a4f62;
  --siws-text: #e3ebf1;
  --siws-text-secondary: #c3d0da;
  --siws-text-muted: #9fb1c0;
  --siws-text-subtle: #8599aa;
  --siws-text-disabled: #61748a;
  --siws-text-inverse: #08161c;
  --siws-success: #6fd39a;      --siws-success-bg: #12301f;   --siws-success-solid: #3fb06a;
  --siws-warning: #f2b85c;      --siws-warning-bg: #3a2a0f;   --siws-warning-solid: #f29a2e;
  --siws-danger: #f28b80;       --siws-danger-bg: #3d1a17;    --siws-danger-solid: #e5584c;
  --siws-info: #7db6ec;         --siws-info-bg: #12304a;      --siws-info-solid: #4a94d6;
  --siws-neutral: #a3b3c0;      --siws-neutral-bg: #1e2c38;   --siws-neutral-solid: #7d8a96;
  --siws-sim: #b3a1ff;          --siws-sim-bg: #261f47;       --siws-sim-solid: #8f72ff;
  --siws-plan: #8fa3b3;
  --siws-shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --siws-shadow-sm: 0 3px 12px rgba(0, 0, 0, .35);
  --siws-shadow-md: 0 8px 26px rgba(0, 0, 0, .45);
  --siws-shadow-lg: 0 18px 60px rgba(0, 0, 0, .55);
  --siws-shadow-float: 0 10px 30px rgba(0, 0, 0, .5);
}

@media (max-width: 640px) {
  :root { --siws-header-h: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --siws-dur-instant: 1ms;
    --siws-dur-fast: 1ms;
    --siws-dur-base: 1ms;
    --siws-dur-slow: 1ms;
    --siws-dur-camera: 1ms;
  }
  *, *::before, *::after { animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
:where(button, a, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--siws-focus);
  outline-offset: 2px;
}
:where(button, [role="button"]):disabled, [aria-disabled="true"] { cursor: not-allowed; }
.siws-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Global header (all web apps) ----------
 * Markup: <body><header class="siws-header"> lockup · nav.siws-nav · session </header>
 * Legacy pages use a bare <body>><header>; both forms get the same fixed geometry. */
body:has(> header) { padding-top: var(--siws-header-h); }
body > header, .siws-header {
  position: fixed; inset: 0 0 auto; z-index: var(--siws-z-header);
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(0, auto) minmax(200px, 1fr);
  grid-template-rows: var(--siws-header-h);
  align-items: center;
  height: var(--siws-header-h); min-height: 0;
  margin: 0; padding: 0 var(--siws-space-6); gap: 0 var(--siws-space-4);
  background: var(--siws-bg-surface); color: var(--siws-brand-ink);
  border-bottom: 1px solid var(--siws-line);
  font: var(--siws-weight-regular) var(--siws-text-md)/var(--siws-leading) var(--siws-font-sans);
  letter-spacing: normal; white-space: nowrap;
}
body > header > :first-child { grid-column: 1; grid-row: 1; justify-self: start; min-width: 0; margin: 0; }
body > header > :is(.siws-header-end, .hoon-account, .siws-session, #session-bar, #viewer, #header-account) {
  grid-column: 3; grid-row: 1; justify-self: end;
  order: 0; width: auto; min-width: 0; margin: 0; flex-wrap: nowrap;
}
body > header .erp-product, body > header .erp-help-links { display: none; }
body > header .brand { color: inherit; text-decoration: none; }

/* Brand lockup — "Hoon HEAVY INDUSTRIES". Keep the wordmark, script face and rule. */
.hoon-lockup { display: inline-flex; align-items: center; gap: 10px; color: var(--siws-brand-ink); text-decoration: none; white-space: nowrap; }
.hoon-word { display: inline-flex; align-items: center; gap: 0; line-height: 1; }
.hoon-word img { display: block; width: 36px; height: 36px; object-fit: contain; mix-blend-mode: multiply; filter: grayscale(1) invert(1) contrast(2) url(#hoon-ink); }
.hoon-word b { font: italic 700 41px/.86 var(--siws-font-script); letter-spacing: -.05em; padding: 0 3px 4px 0; }
.hoon-industry { display: inline-block; font: 750 10px/1.4 var(--siws-font-sans); letter-spacing: .11em; padding-left: 10px; border-left: 1px solid var(--siws-brand-rule); }
.hoon-lockup.hoon-on-dark { color: var(--siws-text-inverse); }
.hoon-on-dark .hoon-word img { mix-blend-mode: lighten; filter: none; }
.hoon-on-dark .hoon-industry { color: #d6e7ee; }
[data-theme="dark"] :is(body > header, .siws-header) .hoon-word img { mix-blend-mode: screen; filter: grayscale(1) contrast(2.4); }
:is(body > header, .siws-header) .hoon-lockup { gap: 10px; color: var(--siws-brand-ink); }
:is(body > header, .siws-header) .hoon-word img { width: 36px; height: 36px; }
:is(body > header, .siws-header) .hoon-word b { font-size: 41px; }
:is(body > header, .siws-header) .hoon-industry { font-size: 10px; letter-spacing: .11em; padding-left: 10px; max-width: none; white-space: nowrap; }

/* Global navigation */
.siws-nav {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: safe center; gap: 2px;
  min-width: 0; max-width: 100%; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent;
  overflow-x: auto; scrollbar-width: none;
}
.siws-nav::-webkit-scrollbar { display: none; }
body > header > .siws-nav { grid-column: 2; grid-row: 1; order: 0; position: static; height: var(--siws-header-h); width: auto; }
.siws-nav a {
  display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 6px 10px; border: 0; border-radius: var(--siws-radius-sm);
  background: transparent; color: var(--siws-text-secondary);
  font: var(--siws-weight-medium) var(--siws-text-sm)/var(--siws-leading-tight) var(--siws-font-sans);
  text-decoration: none; white-space: nowrap; filter: none; box-shadow: none;
  transition: background-color var(--siws-dur-fast) var(--siws-ease-standard), color var(--siws-dur-fast) var(--siws-ease-standard);
}
.siws-nav a:hover { background: var(--siws-bg-hover); color: var(--siws-action-current); filter: none; }
.siws-nav a[aria-current="page"] { background: var(--siws-action-selected); color: var(--siws-action-current); font-weight: var(--siws-weight-bold); }
.siws-nav a:focus-visible { outline: 2px solid var(--siws-action); outline-offset: -2px; }
.siws-nav svg { width: var(--siws-icon-sm); height: var(--siws-icon-sm); flex: none; }
/* Nav groups: a trigger with a menu under it on wide screens (hover, focus or tap opens it; siws-theme.js keeps
 * aria-expanded in step). Phones lay every link flat in the scrolling strip (see the 640px block below). */
@media (min-width: 641px) { .siws-nav { overflow: visible; } }
.siws-nav-group { position: relative; flex: none; }
/* .siws-nav .siws-nav-trigger outranks page-level `nav button` rules (the ERP page styles its own tab bars that way). */
.siws-nav .siws-nav-trigger {
  display: inline-flex; align-items: center; gap: 6px; width: auto; min-height: 38px; margin: 0; padding: 6px 8px 6px 10px; border: 0;
  box-shadow: none; text-align: left;
  border-radius: var(--siws-radius-sm); background: transparent; color: var(--siws-text-secondary); cursor: pointer;
  font: var(--siws-weight-medium) var(--siws-text-sm)/var(--siws-leading-tight) var(--siws-font-sans); white-space: nowrap;
  transition: background-color var(--siws-dur-fast) var(--siws-ease-standard), color var(--siws-dur-fast) var(--siws-ease-standard);
}
.siws-nav .siws-nav-trigger:hover, .siws-nav-group[data-open] .siws-nav-trigger { background: var(--siws-bg-hover); color: var(--siws-action-current); }
.siws-nav-trigger:focus-visible { outline: 2px solid var(--siws-action); outline-offset: -2px; }
.siws-nav .siws-nav-group:has(a[aria-current="page"]) .siws-nav-trigger { background: var(--siws-action-selected); color: var(--siws-action-current); font-weight: var(--siws-weight-bold); }
.siws-nav .siws-nav-trigger .siws-nav-caret { display: block; width: 14px; height: 14px; transition: transform var(--siws-dur-fast) var(--siws-ease-standard); }
.siws-nav-group[data-open] .siws-nav-caret { transform: rotate(180deg); }
.siws-nav-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--siws-z-dropdown); display: none;
  min-width: 188px; padding: var(--siws-space-1); border: 1px solid var(--siws-line); border-radius: var(--siws-radius-md);
  background: var(--siws-bg-surface); box-shadow: var(--siws-shadow-md);
}
.siws-nav-menu::before { content: ""; position: absolute; inset: -8px 0 100%; }  /* hover bridge over the gap */
.siws-nav-group[data-open] .siws-nav-menu { display: grid; gap: 2px; animation: siws-pop-in var(--siws-dur-fast) var(--siws-ease-out); }
@media (hover: hover) { .siws-nav-group:hover .siws-nav-menu { display: grid; gap: 2px; } }
.siws-nav-menu a { justify-content: flex-start; min-height: var(--siws-touch-target); padding-inline: 12px; color: var(--siws-text); }

/* Session / account menu */
.siws-session { display: flex; align-items: center; justify-content: flex-end; gap: var(--siws-space-3); }
.siws-session svg { width: var(--siws-icon-md); height: var(--siws-icon-md); flex: none; }
.siws-session-action {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 6px 9px;
  border: 0; border-radius: 9px; background: transparent; color: var(--siws-text-secondary);
  font: 650 var(--siws-text-sm)/1.4 var(--siws-font-sans); text-decoration: none; white-space: nowrap; cursor: pointer;
}
.siws-session-action[hidden], :is(.siws-session, .hoon-account, #session-bar, #header-account) [hidden] { display: none; }
.siws-session-action:hover { background: var(--siws-bg-hover); color: var(--siws-action-current); }
.siws-session details { position: relative; }
.siws-session-action > span { max-width: clamp(65px, 14vw, 140px); overflow: hidden; text-overflow: ellipsis; }
.siws-session summary { cursor: pointer; list-style: none; background: var(--siws-action-selected); color: var(--siws-action-current); }
.siws-session summary::-webkit-details-marker { display: none; }
.siws-account-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--siws-z-dropdown);
  min-width: 185px; padding: 6px; border: 1px solid var(--siws-line); border-radius: var(--siws-radius-lg);
  background: var(--siws-bg-surface); box-shadow: var(--siws-shadow-md);
  animation: siws-pop-in var(--siws-dur-fast) var(--siws-ease-out);
}
.siws-account-panel p { margin: 0 0 4px; padding: 7px 9px; border-bottom: 1px solid var(--siws-line-subtle); color: var(--siws-text-muted); overflow-wrap: anywhere; font-size: var(--siws-text-xs); }
.siws-account-panel button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 42px; padding: 7px 9px; border: 0; border-radius: var(--siws-radius-sm); background: var(--siws-bg-surface); color: var(--siws-danger); text-align: left; font: inherit; font-size: var(--siws-text-sm); cursor: pointer; }
.siws-account-panel button:hover { background: var(--siws-danger-bg); }

/* Header end: theme switch + the page's account element (wrapped by /design/siws-theme.js). */
.siws-header-end { display: flex; align-items: center; justify-content: flex-end; gap: var(--siws-space-1); min-width: 0; }
.siws-header-end > :last-child { min-width: 0; }
.siws-theme { position: relative; flex: none; }
.siws-theme summary { background: transparent; color: var(--siws-text-secondary); }
.siws-theme summary:hover { background: var(--siws-bg-hover); color: var(--siws-action-current); }
.siws-theme svg { width: var(--siws-icon-md); height: var(--siws-icon-md); flex: none; }
.siws-theme .siws-theme-dark, [data-theme="dark"] .siws-theme .siws-theme-light { display: none; }
[data-theme="dark"] .siws-theme .siws-theme-dark { display: block; }
.siws-theme-panel { min-width: 180px; }
.siws-theme-panel button { color: var(--siws-text); }
.siws-theme-panel button:hover { background: var(--siws-bg-hover); }
.siws-theme-panel button[aria-pressed="true"] { background: var(--siws-action-selected); color: var(--siws-action-current); font-weight: var(--siws-weight-bold); }
.siws-theme-panel button[aria-pressed="true"]::after { content: "✓"; margin-left: auto; }
@media (max-width: 900px) { .siws-theme-name { display: none; } }

@media (max-width: 1180px) { :is(body > header, .siws-header) .siws-nav > a > svg:first-child, .siws-nav .siws-nav-trigger > svg:first-child { display: none; } }
@media (max-width: 900px) {
  body > header, .siws-header { grid-template-columns: auto minmax(0, 1fr) auto; padding: 0 10px; column-gap: 6px; }
  .siws-nav a { padding: 6px; font-size: var(--siws-text-xs); gap: 3px; }
  :is(body > header, .siws-header) .siws-nav svg { display: none; }
  :is(body > header, .siws-header) .hoon-lockup { gap: 4px; }
  :is(body > header, .siws-header) .hoon-word img { width: 25px; height: 25px; }
  :is(body > header, .siws-header) .hoon-word b { font-size: 29px; }
  :is(body > header, .siws-header) .hoon-industry { font-size: 7px; letter-spacing: 0; padding-left: 4px; }
  body > header > :is(.siws-header-end, .hoon-account, .siws-session, #session-bar, #viewer, #header-account) { font-size: var(--siws-text-2xs); max-width: 160px; }
}
/* Phones: brand + session on row 1 (56px), full-width nav on row 2 (48px). Header height stays a token. */
@media (max-width: 640px) {
  body > header, .siws-header { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 56px 48px; padding: 0 12px; }
  body > header > .siws-nav { grid-column: 1 / -1; grid-row: 2; height: 48px; justify-content: flex-start; border-top: 1px solid var(--siws-line-subtle); }
  body > header > :is(.siws-header-end, .hoon-account, .siws-session, #session-bar, #viewer, #header-account) { grid-column: 2; grid-row: 1; max-width: 60vw; }
  .siws-nav a { min-height: var(--siws-touch-target); padding-inline: 8px; }
  :is(body > header, .siws-header) .hoon-lockup { gap: 6px; }
  :is(body > header, .siws-header) .hoon-word img { width: 30px; height: 30px; }
  :is(body > header, .siws-header) .hoon-word b { font-size: 34px; }
  :is(body > header, .siws-header) .hoon-industry { font-size: 9px; letter-spacing: .06em; padding-left: 6px; }
}
@media (max-width: 640px) {
  /* Phones: groups open flat into the strip, in NAV order; the current link is scrolled into view. */
  .siws-nav-group, .siws-nav-menu, .siws-nav-group[data-open] .siws-nav-menu { display: contents; }
  .siws-nav .siws-nav-trigger, .siws-nav-menu::before { display: none; }
  .siws-nav-menu a { justify-content: center; min-height: var(--siws-touch-target); padding-inline: 8px; color: var(--siws-text-secondary); }
  .siws-nav { scroll-padding-inline: var(--siws-space-6); mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 20px), transparent); }
}
@media (max-width: 360px) {
  .siws-nav { gap: 1px; }
  .siws-nav a { padding-inline: 4px; font-size: var(--siws-text-2xs); }
}

/* ---------- Components (opt-in classes for new UI; see docs/design-system/components.md) ---------- */

/* Button */
.siws-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--siws-space-2);
  min-height: 40px; padding: 7px 14px; border: 1px solid var(--siws-action); border-radius: var(--siws-radius-sm);
  background: var(--siws-action); color: var(--siws-text-inverse);
  font: var(--siws-weight-bold) var(--siws-text-sm)/1.2 var(--siws-font-sans); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--siws-dur-fast) var(--siws-ease-standard), border-color var(--siws-dur-fast) var(--siws-ease-standard), box-shadow var(--siws-dur-fast) var(--siws-ease-standard), transform var(--siws-dur-instant) var(--siws-ease-standard);
}
.siws-btn:not(:disabled):hover { background: var(--siws-action-hover); border-color: var(--siws-action-hover); }
.siws-btn:not(:disabled):active { transform: translateY(1px); }
.siws-btn:disabled { opacity: .45; }
.siws-btn--secondary { background: var(--siws-bg-surface); color: var(--siws-action-ink); border-color: var(--siws-action-border); }
.siws-btn--secondary:not(:disabled):hover { background: var(--siws-action-tint); border-color: var(--siws-action-border-strong); }
.siws-btn--ghost { background: transparent; color: var(--siws-text-secondary); border-color: transparent; }
.siws-btn--ghost:not(:disabled):hover { background: var(--siws-bg-hover); border-color: transparent; color: var(--siws-action-current); }
.siws-btn--danger { background: var(--siws-danger-solid); border-color: var(--siws-danger-solid); }
.siws-btn--danger:not(:disabled):hover { background: var(--siws-danger); border-color: var(--siws-danger); }
.siws-btn--sm { min-height: 32px; padding: 4px 10px; font-size: var(--siws-text-xs); }
.siws-btn--icon { min-width: 40px; padding: 0; }
@media (pointer: coarse) { .siws-btn { min-height: var(--siws-touch-target); } }

/* Input, select, search */
.siws-input, .siws-select {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--siws-line-input); border-radius: var(--siws-radius-sm);
  background: var(--siws-bg-surface); color: var(--siws-text); font: inherit; font-size: var(--siws-text-md);
  transition: border-color var(--siws-dur-fast) var(--siws-ease-standard), box-shadow var(--siws-dur-fast) var(--siws-ease-standard);
}
.siws-input:focus, .siws-select:focus { border-color: var(--siws-action); box-shadow: 0 0 0 3px var(--siws-action-tint); outline: none; }
.siws-input[aria-invalid="true"] { border-color: var(--siws-danger-solid); }
.siws-search { position: relative; display: flex; align-items: center; }
.siws-search > svg { position: absolute; left: 11px; width: var(--siws-icon-sm); height: var(--siws-icon-sm); color: var(--siws-text-subtle); pointer-events: none; }
.siws-search > .siws-input { padding-left: 34px; }
.siws-filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--siws-space-2); }
.siws-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 11px;
  border: 1px solid var(--siws-line-input); border-radius: var(--siws-radius-pill); background: var(--siws-bg-surface);
  color: var(--siws-text-secondary); font: var(--siws-weight-medium) var(--siws-text-xs)/1.2 var(--siws-font-sans); cursor: pointer;
}
.siws-chip[aria-pressed="true"] { background: var(--siws-action-selected); border-color: var(--siws-action-border-strong); color: var(--siws-action-current); }

/* Card / panel */
.siws-card { padding: var(--siws-space-4) var(--siws-space-5); border: 1px solid var(--siws-line); border-radius: var(--siws-radius-lg); background: var(--siws-bg-surface); box-shadow: var(--siws-shadow-xs); }
.siws-card--interactive { transition: border-color var(--siws-dur-fast) var(--siws-ease-standard), box-shadow var(--siws-dur-fast) var(--siws-ease-standard); }
.siws-card--interactive:hover { border-color: var(--siws-action-border-strong); box-shadow: var(--siws-shadow-sm); }

/* Data table — compact 40px rows, sticky header, tabular numbers */
.siws-table-wrap { overflow: auto; border: 1px solid var(--siws-line); border-radius: var(--siws-radius-lg); background: var(--siws-bg-surface); }
.siws-table { width: 100%; border-collapse: collapse; text-align: left; font-size: var(--siws-text-sm); font-variant-numeric: tabular-nums; }
.siws-table th { position: sticky; top: 0; z-index: 1; padding: 10px 12px; background: var(--siws-bg-subtle); color: var(--siws-text-muted); font-size: var(--siws-text-xs); font-weight: var(--siws-weight-medium); border-bottom: 1px solid var(--siws-line); white-space: nowrap; }
.siws-table td { padding: 10px 12px; border-bottom: 1px solid var(--siws-line-subtle); }
.siws-table tbody tr:hover { background: var(--siws-bg-subtle); }
.siws-table tbody tr[aria-selected="true"] { background: var(--siws-action-tint); box-shadow: inset 3px 0 var(--siws-action); }
.siws-table .num { text-align: right; }

/* Status badge — tone via data-tone: success | warning | danger | info | neutral | sim */
.siws-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--siws-radius-pill);
  background: var(--siws-neutral-bg); color: var(--siws-neutral);
  font: var(--siws-weight-bold) var(--siws-text-xs)/1.5 var(--siws-font-sans); white-space: nowrap;
}
.siws-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.siws-badge[data-tone="success"] { background: var(--siws-success-bg); color: var(--siws-success); }
.siws-badge[data-tone="warning"] { background: var(--siws-warning-bg); color: var(--siws-warning); }
.siws-badge[data-tone="danger"]  { background: var(--siws-danger-bg);  color: var(--siws-danger); }
.siws-badge[data-tone="info"]    { background: var(--siws-info-bg);    color: var(--siws-info); }
.siws-badge[data-tone="sim"]     { background: var(--siws-sim-bg);     color: var(--siws-sim); }

/* Overlay surfaces: modal, drawer, floating panel, tooltip, toast */
.siws-backdrop { position: fixed; inset: 0; z-index: var(--siws-z-modal); background: var(--siws-bg-overlay); animation: siws-fade-in var(--siws-dur-base) var(--siws-ease-out); }
.siws-modal {
  position: fixed; left: 50%; top: 50%; z-index: var(--siws-z-modal); width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 48px); overflow: auto;
  translate: -50% -50%; padding: var(--siws-space-6); border-radius: var(--siws-radius-xl); background: var(--siws-bg-surface); box-shadow: var(--siws-shadow-lg);
  animation: siws-pop-in var(--siws-dur-base) var(--siws-ease-out);
}
dialog.siws-modal::backdrop { background: var(--siws-bg-overlay); }
.siws-drawer {
  position: fixed; top: var(--siws-header-h); right: 0; bottom: 0; z-index: var(--siws-z-drawer); width: min(420px, 100%); overflow: auto;
  padding: var(--siws-space-5); background: var(--siws-bg-surface); border-left: 1px solid var(--siws-line); box-shadow: var(--siws-shadow-md);
  transform: translateX(100%); transition: transform var(--siws-dur-slow) var(--siws-ease-out);
}
.siws-drawer[data-open="true"] { transform: none; }
.siws-floating {
  position: absolute; z-index: var(--siws-z-map-ui); padding: var(--siws-space-3) var(--siws-space-4);
  border-radius: var(--siws-radius-xl); background: var(--siws-bg-glass); box-shadow: var(--siws-shadow-float);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.siws-floating--dark { background: var(--siws-bg-hud); color: var(--siws-text-inverse); }
.siws-tooltip {
  position: absolute; z-index: var(--siws-z-tooltip); max-width: 260px; padding: 5px 9px; border-radius: var(--siws-radius-sm);
  background: var(--siws-bg-hud); color: var(--siws-text-inverse); font-size: var(--siws-text-xs); line-height: 1.4; pointer-events: none;
  animation: siws-fade-in var(--siws-dur-fast) var(--siws-ease-out);
}
.siws-toast-region { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: var(--siws-z-toast); display: grid; gap: var(--siws-space-2); width: min(360px, calc(100% - 32px)); }
.siws-toast {
  display: flex; align-items: flex-start; gap: var(--siws-space-2); padding: 10px 14px; border-radius: var(--siws-radius-md);
  background: var(--siws-bg-surface); border: 1px solid var(--siws-line); border-left: 4px solid var(--siws-info-solid); box-shadow: var(--siws-shadow-md);
  font-size: var(--siws-text-sm); animation: siws-rise-in var(--siws-dur-base) var(--siws-ease-out);
}
.siws-toast[data-tone="success"] { border-left-color: var(--siws-success-solid); }
.siws-toast[data-tone="warning"] { border-left-color: var(--siws-warning-solid); }
.siws-toast[data-tone="danger"]  { border-left-color: var(--siws-danger-solid); }

/* Loading, skeleton, empty and error states */
.siws-spinner { display: inline-block; width: var(--siws-icon-sm); height: var(--siws-icon-sm); border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: siws-spin .8s linear infinite; }
.siws-skeleton { display: block; min-height: 12px; border-radius: var(--siws-radius-xs); background: linear-gradient(90deg, var(--siws-bg-muted) 0 40%, var(--siws-bg-subtle) 50%, var(--siws-bg-muted) 60% 100%) 0 0 / 300% 100%; animation: siws-shimmer 1.4s linear infinite; }
.siws-empty, .siws-error {
  display: grid; justify-items: center; gap: var(--siws-space-2); padding: var(--siws-space-10) var(--siws-space-6);
  color: var(--siws-text-muted); text-align: center; font-size: var(--siws-text-sm);
}
.siws-empty strong, .siws-error strong { color: var(--siws-text); font-size: var(--siws-text-base); }
.siws-error { color: var(--siws-danger); }

/* Map markers (DOM markers on Leaflet / SVG maps) */
.siws-marker {
  display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--siws-text-inverse); border-radius: 50%;
  background: var(--siws-marker-color, var(--siws-action)); color: var(--siws-text-inverse); box-shadow: 0 2px 6px rgba(12, 30, 44, .35);
  font: var(--siws-weight-heavy) var(--siws-text-2xs)/1 var(--siws-font-sans);
  animation: siws-marker-in var(--siws-dur-base) var(--siws-ease-emphasis) both;
}
.siws-marker--stop { width: 18px; height: 18px; border-width: 3px; border-color: var(--siws-marker-color, var(--siws-action)); background: var(--siws-text-inverse); }
.siws-marker--origin { --siws-marker-color: var(--siws-origin); }
.siws-marker--destination { --siws-marker-color: var(--siws-destination); border-radius: 50% 50% 50% 0; rotate: -45deg; }
.siws-marker--vehicle { border-radius: var(--siws-radius-sm); width: 30px; height: 22px; }
.siws-marker[aria-selected="true"] { outline: 3px solid var(--siws-marker-color, var(--siws-action)); outline-offset: 2px; }

/* ---------- Motion primitives ---------- */
@keyframes siws-spin { to { transform: rotate(360deg); } }
@keyframes siws-fade-in { from { opacity: 0; } }
@keyframes siws-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes siws-rise-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes siws-marker-in { from { opacity: 0; transform: scale(.6); } }
@keyframes siws-shimmer { to { background-position: -150% 0; } }
