/* =====================================================================
   AI-SHM monitoring console
   High-performance HMI approach: neutral grey surfaces for normal
   operation; colour is reserved for damage severity (alarms) and for
   interactive controls. Every severity colour is paired with a shape
   and a text label, so meaning never depends on colour alone.
   ===================================================================== */

@font-face { font-family: "Plex Sans"; src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Condensed"; src: url("../fonts/ibm-plex-sans-condensed-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Condensed"; src: url("../fonts/ibm-plex-sans-condensed-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  color-scheme: light;
  --field:        #E3E6E9;   /* page */
  --panel:        #F4F5F6;   /* panels */
  --inset:        #EBEDEF;   /* table heads, wells */
  --line:         #CBD0D5;
  --line-strong:  #99A2AC;
  --ink:          #1A222A;
  --ink-2:        #47525D;
  --ink-3:        #66717C;
  --steel:        #A3ACB6;   /* structure, normal state */
  --steel-edge:   #5F6A75;
  --wall:         #7D8792;
  --action:       #1E5A9C;
  --action-hover: #174A82;
  --action-ink:   #FFFFFF;
  --focus:        #1E5A9C;
  --series:       #2A6CB8;
  --grid:         #D6DADF;

  /* severity: validated as an ordered set (CVD + normal-vision separation) */
  --b-healthy:  #66717C;
  --b-minor:    #E5BE00;
  --b-moderate: #E2711D;
  --b-severe:   #B81F2D;
  --b-critical: #6A0F22;
  --b-minor-ink:    #1A1400;
  --b-moderate-ink: #1F0E00;
  --b-severe-ink:   #FFFFFF;
  --b-critical-ink: #FFFFFF;
  --b-tint-minor:    #F6EDC4;
  --b-tint-moderate: #F7DEC9;
  --b-tint-severe:   #F2D3D5;
  --b-tint-critical: #E9D1D5;

  --sidebar-w: 232px;
  --radius-panel: 6px;
  --radius-ctl: 4px;
  --radius-pill: 3px;

  --font-ui: "Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Plex Condensed", "Plex Sans", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --field: #13171B; --panel: #1B2025; --inset: #22282E; --line: #2F373F; --line-strong: #4B5661;
    --ink: #E5E9ED; --ink-2: #AEB7C0; --ink-3: #8A949E;
    --steel: #4E5965; --steel-edge: #8C97A2; --wall: #6A7581;
    --action: #6EA2DF; --action-hover: #8DB6E8; --action-ink: #0D1825; --focus: #8DB6E8;
    --series: #6EA2DF; --grid: #2A3138;
    --b-healthy: #8A949E; --b-minor: #F2D04B; --b-moderate: #F07C2C; --b-severe: #CF2E3E; --b-critical: #F04DB8;
    --b-minor-ink: #1A1400; --b-moderate-ink: #1F0E00; --b-severe-ink: #FFFFFF; --b-critical-ink: #2A0712;
    --b-tint-minor: #3A3317; --b-tint-moderate: #3D2717; --b-tint-severe: #3E1D22; --b-tint-critical: #43203A;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --field: #13171B; --panel: #1B2025; --inset: #22282E; --line: #2F373F; --line-strong: #4B5661;
  --ink: #E5E9ED; --ink-2: #AEB7C0; --ink-3: #8A949E;
  --steel: #4E5965; --steel-edge: #8C97A2; --wall: #6A7581;
  --action: #6EA2DF; --action-hover: #8DB6E8; --action-ink: #0D1825; --focus: #8DB6E8;
  --series: #6EA2DF; --grid: #2A3138;
  --b-healthy: #8A949E; --b-minor: #F2D04B; --b-moderate: #F07C2C; --b-severe: #CF2E3E; --b-critical: #F04DB8;
  --b-minor-ink: #1A1400; --b-moderate-ink: #1F0E00; --b-severe-ink: #FFFFFF; --b-critical-ink: #2A0712;
  --b-tint-minor: #3A3317; --b-tint-moderate: #3D2717; --b-tint-severe: #3E1D22; --b-tint-critical: #43203A;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--field);
  color: var(--ink);
  font: 400 14px/1.5 var(--font-ui);
  font-feature-settings: "tnum" 1;
}
a { color: var(--action); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--action-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: 0.005em; }
p { margin: 0 0 0.75em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(90deg, var(--panel) 0 calc(var(--sidebar-w) - 1px), var(--line) calc(var(--sidebar-w) - 1px) var(--sidebar-w), transparent var(--sidebar-w)); }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px 18px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.brand svg { flex: none; }
.brand b { display: block; font: 600 17px/1.15 var(--font-display); }
.brand span { display: block; font-size: 12px; color: var(--ink-3); }

.nav { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-ctl);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--inset); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--inset); color: var(--ink); border-left-color: var(--action); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; }
.nav-sep { height: 1px; background: var(--line); margin: 12px 6px; }

.sidebar-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.sidebar-foot p { margin: 0 0 4px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar-title { min-width: 0; flex: 1 1 320px; }
.topbar-title h1 { font-size: 24px; line-height: 1.15; }
.topbar-title p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.topbar-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.clock { text-align: right; line-height: 1.2; padding-right: 6px; }
.clock b { display: block; font: 600 16px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.clock span { font-size: 12px; color: var(--ink-3); }

.content { padding: 22px 28px 40px; display: grid; gap: 18px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 7px 14px;
  border-radius: var(--radius-ctl);
  border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink);
  font: 500 14px/1.2 var(--font-ui);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--inset); color: var(--ink); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.btn-primary { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.btn-primary:hover { background: var(--action-hover); border-color: var(--action-hover); color: var(--action-ink); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-icon { padding: 7px; width: 36px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.input, .select {
  min-height: 34px; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-ctl);
  background: var(--panel); color: var(--ink);
  font: 400 14px/1.2 var(--font-ui);
}
.input::placeholder { color: var(--ink-3); }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-panel); min-width: 0; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 16px; }
.panel-head .meta { font-size: 12.5px; color: var(--ink-3); }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid-hero { grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); }
.grid-2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- severity shapes + pills ---------- */
.shape { display: inline-block; width: 10px; height: 10px; flex: none; background: currentColor; }
.shape-healthy  { border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 2px var(--b-healthy); }
.shape-minor    { clip-path: polygon(50% 0, 100% 100%, 0 100%); background: var(--b-minor); }
.shape-moderate { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); background: var(--b-moderate); }
.shape-severe   { background: var(--b-severe); }
.shape-critical { clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); background: var(--b-critical); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 6px; border-radius: var(--radius-pill);
  font-size: 12.5px; font-weight: 500; line-height: 1.5;
  background: var(--inset); color: var(--ink);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill-minor    { background: var(--b-tint-minor); border-color: transparent; }
.pill-moderate { background: var(--b-tint-moderate); border-color: transparent; }
.pill-severe   { background: var(--b-tint-severe); border-color: transparent; }
.pill-critical { background: var(--b-tint-critical); border-color: transparent; }

/* ---------- alarm banner ---------- */
.alarm {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius-panel);
  border: 1px solid transparent;
}
.alarm .shape { width: 16px; height: 16px; }
.alarm-text { flex: 1 1 240px; min-width: 0; }
.alarm-text strong { font: 600 16px/1.3 var(--font-display); display: block; }
.alarm-text span { font-size: 13px; }
.alarm-severe   { background: var(--b-severe); color: var(--b-severe-ink); }
.alarm-critical { background: var(--b-critical); color: var(--b-critical-ink); }
.alarm-severe .shape, .alarm-critical .shape { background: currentColor; }
.alarm .btn { background: transparent; color: inherit; border-color: currentColor; }
.alarm .btn:hover { background: rgba(255,255,255,.12); color: inherit; }
.alarm-notice { background: var(--panel); border-color: var(--line); color: var(--ink); }
.alarm-notice .btn { color: var(--ink); border-color: var(--line-strong); }

/* ---------- beam mimic ---------- */
.mimic { display: block; width: 100%; height: auto; }
.mimic text { font-family: var(--font-ui); fill: var(--ink-2); font-size: 15px; }
.mimic .t-strong { fill: var(--ink); font-weight: 600; }
.mimic .t-small { font-size: 14px; fill: var(--ink-3); }
.mimic .t-member { font-family: var(--font-display); font-size: 17px; font-weight: 600; fill: var(--ink); }
.mimic .wall { fill: var(--wall); }
.mimic .hatch line { stroke: var(--steel-edge); stroke-width: 1.4; }
.mimic .member { fill: var(--steel); stroke: var(--steel-edge); stroke-width: 1; }
.mimic .member.is-damaged { stroke-width: 2; }
.mimic .member.is-minor    { fill: var(--b-minor); }
.mimic .member.is-moderate { fill: var(--b-moderate); }
.mimic .member.is-severe   { fill: var(--b-severe); }
.mimic .member.is-critical { fill: var(--b-critical); }
.mimic .t-member.on-minor    { fill: var(--b-minor-ink); }
.mimic .t-member.on-moderate { fill: var(--b-moderate-ink); }
.mimic .t-member.on-severe   { fill: var(--b-severe-ink); }
.mimic .t-member.on-critical { fill: var(--b-critical-ink); }
.mimic .node { fill: var(--panel); stroke: var(--ink-2); stroke-width: 2; }
.mimic .dim { stroke: var(--ink-3); stroke-width: 1; fill: none; }
.mimic .mode { fill: none; stroke: var(--series); stroke-width: 1.6; stroke-dasharray: 5 5; opacity: .75; }
.mimic .callout-line { stroke: var(--ink); stroke-width: 1.2; }
.mimic .callout-box { fill: var(--panel); stroke: var(--ink); stroke-width: 1.2; }
.mimic .ring { fill: none; stroke-width: 2; }
.mimic .ring-minor { stroke: var(--b-minor); } .mimic .ring-moderate { stroke: var(--b-moderate); }
.mimic .ring-severe { stroke: var(--b-severe); } .mimic .ring-critical { stroke: var(--b-critical); }
@media (prefers-reduced-motion: no-preference) {
  .mimic .ring { animation: ring 2.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
  @keyframes ring { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.06, 1.9); } }
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--ink-2); padding: 0 16px 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 18px; height: 10px; border: 1px solid var(--steel-edge); background: var(--steel); }
.sw-dash { width: 20px; height: 0; border-top: 2px dashed var(--series); }

.member-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.member-strip > div { padding: 10px 14px; border-right: 1px solid var(--line); min-width: 0; }
.member-strip > div:last-child { border-right: 0; }
.member-strip b { display: block; font: 600 14px/1.3 var(--font-display); }
.member-strip span { font-size: 12px; color: var(--ink-3); }
.member-strip .state { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }
.member-strip .is-hit { background: var(--inset); box-shadow: inset 0 3px 0 var(--hit, var(--ink)); }

/* ---------- hero (status) panel ---------- */
.hero-body { display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.hero-readout { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.hero-readout .facts { border-bottom: 0; }
.hero-mimic { padding: 18px 18px 0; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.hero-mimic .legend { padding: 4px 0 14px; }

/* ---------- readout panel ---------- */
.readout { display: flex; flex-direction: column; }
.readout-main { padding: 18px 18px 14px; }
.readout-label { font-size: 13px; color: var(--ink-3); margin: 0; }
.readout-value { font: 600 64px/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; margin: 6px 0 2px; }
.readout-value small { font-size: 28px; font-weight: 500; color: var(--ink-2); margin-left: 4px; }

.scale { margin: 18px 0 6px; }
.scale-bar { position: relative; display: grid; height: 14px; gap: 2px; }
.scale-bar > i { display: block; }
.scale-bar .z-healthy  { background: var(--line); }
.scale-bar .z-minor    { background: var(--b-minor); }
.scale-bar .z-moderate { background: var(--b-moderate); }
.scale-bar .z-severe   { background: var(--b-severe); }
.scale-bar .z-critical { background: var(--b-critical); }
.scale-marker { position: absolute; top: -9px; width: 2px; height: 32px; background: var(--ink); transform: translateX(-1px); }
.scale-marker::before { content: ""; position: absolute; top: -2px; left: -5px; border: 6px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
.scale-ticks { position: relative; height: 18px; margin-top: 6px; font-size: 11.5px; color: var(--ink-3); }
.scale-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.scale-ticks span:first-child { transform: none; }
.scale-ticks span:last-child { transform: translateX(-100%); }

.facts { display: grid; grid-template-columns: auto 1fr; margin: 0; border-top: 1px solid var(--line); }
.facts dt, .facts dd { margin: 0; padding: 9px 18px; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--ink-3); font-size: 13px; padding-right: 8px; }
.facts dd { text-align: right; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.facts dt:nth-last-child(2), .facts dd:last-child { border-bottom: 0; }

.action-box { margin: 0; padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.action-box b { display: block; font: 600 18px/1.25 var(--font-display); }
.action-box span { font-size: 12.5px; color: var(--ink-3); }

/* ---------- KPI strip ---------- */
.strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.strip > div { padding: 14px 18px; border-right: 1px solid var(--line); min-width: 0; }
.strip > div:last-child { border-right: 0; }
.strip dt { font-size: 12.5px; color: var(--ink-3); }
.strip dd { margin: 4px 0 0; font: 600 26px/1.1 var(--font-display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.strip dd small { font: 400 13px/1.3 var(--font-ui); color: var(--ink-3); display: block; margin-top: 3px; }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.short { height: 220px; }

.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 110px minmax(0, 1fr) 54px; align-items: center; gap: 10px; font-size: 13px; }
.hbar-label { display: flex; align-items: center; gap: 7px; color: var(--ink); }
.hbar-track { height: 14px; background: var(--inset); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 0; }
.hbar-fill.f-healthy  { background: var(--b-healthy); }
.hbar-fill.f-minor    { background: var(--b-minor); }
.hbar-fill.f-moderate { background: var(--b-moderate); }
.hbar-fill.f-severe   { background: var(--b-severe); }
.hbar-fill.f-critical { background: var(--b-critical); }
.hbar-val { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-weight: 500; color: var(--ink-2); font-size: 12.5px;
  background: var(--inset); padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--inset); }
table.data .r { text-align: right; }
table.data .file { font-weight: 500; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data .file a { color: var(--ink); text-decoration: none; }
table.data .file a:hover { text-decoration: underline; color: var(--action); }
table.data th[data-sort] { cursor: pointer; user-select: none; }
table.data th[data-sort]::after { content: ""; display: inline-block; margin-left: 6px; border: 4px solid transparent; border-top-color: var(--ink-3); transform: translateY(2px); opacity: .5; }
table.data th[aria-sort="ascending"]::after { border-top-color: transparent; border-bottom-color: var(--ink); transform: translateY(-2px); opacity: 1; }
table.data th[aria-sort="descending"]::after { border-top-color: var(--ink); opacity: 1; }
.dmg { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.dmg-bar { width: 64px; height: 6px; background: var(--inset); border: 1px solid var(--line); flex: none; }
.dmg-bar i { display: block; height: 100%; background: var(--ink-2); }
.dmg b { font-weight: 600; min-width: 52px; text-align: right; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1 1 220px; }
.empty-row td { text-align: center; color: var(--ink-3); padding: 28px 14px; }

/* ---------- model panel ---------- */
.models td:first-child b { display: block; font-weight: 600; }
.models td:first-child span { font-size: 12px; color: var(--ink-3); }
.models .metric { font: 600 18px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.pipeline-note { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }

/* ---------- upload ---------- */
.drop {
  display: grid; place-items: center; text-align: center; gap: 8px;
  padding: 44px 24px; border: 2px dashed var(--line-strong); border-radius: var(--radius-panel);
  background: var(--inset); cursor: pointer;
}
.drop:hover, .drop.is-over { border-color: var(--action); background: var(--panel); }
.drop svg { width: 40px; height: 40px; stroke: var(--ink-3); fill: none; stroke-width: 1.4; }
.drop b { font: 600 18px/1.3 var(--font-display); }
.drop .muted { font-size: 13px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-chosen { display: none; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-ctl); background: var(--panel); }
.file-chosen.is-set { display: flex; }
.file-chosen b { font-weight: 600; overflow-wrap: anywhere; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.error-box { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-ctl); background: var(--b-tint-severe); color: var(--ink); margin-bottom: 14px; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: none; }
.is-busy .spin { display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--line-strong); border-radius: 50%; font: 600 13px/1 var(--font-display); color: var(--ink-2); }
.steps b { display: block; font-weight: 600; }
.steps span { font-size: 13px; color: var(--ink-3); }

.spec { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.spec td:last-child { text-align: right; color: var(--ink-2); }
.spec tr:last-child td { border-bottom: 0; }
code, .code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; background: var(--inset); padding: 1px 5px; border-radius: 3px; }

/* ---------- figures ---------- */
.figure img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-ctl); background: #fff; }
.figure figcaption { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }

/* ---------- prose pages ---------- */
.prose { max-width: 70ch; }
.prose h2 { font-size: 20px; margin: 4px 0 8px; }
.prose p { color: var(--ink-2); }
.lead { font-size: 16px; color: var(--ink-2); max-width: 66ch; }
.cards-plain { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.contact-list { display: grid; grid-template-columns: max-content 1fr; gap: 0; margin: 0; }
.contact-list dt, .contact-list dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; }
.contact-list dt { color: var(--ink-3); padding-right: 28px; }
.contact-list dt:nth-last-child(2), .contact-list dd:last-child { border-bottom: 0; }

.footer { padding: 14px 28px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); margin-top: auto; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .grid-hero, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .hero-body { grid-template-columns: minmax(0, 1fr); }
  .hero-readout { border-right: 0; border-bottom: 1px solid var(--line); }
  .strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .strip > div:nth-child(3) { border-right: 0; }
  .strip > div:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { border-bottom: 0; padding: 0 8px 0 0; }
  .brand span { display: none; }
  .nav { display: flex; margin: 0; gap: 2px; }
  .nav a { padding: 7px 9px; border-left: 0; border-bottom: 2px solid transparent; border-radius: 0; white-space: nowrap; }
  .nav a[aria-current="page"] { border-bottom-color: var(--action); }
  .nav-sep, .sidebar-foot, .nav .nav-extra { display: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .grid-even { grid-template-columns: minmax(0, 1fr); }
  .member-strip { grid-template-columns: repeat(5, minmax(88px, 1fr)); overflow-x: auto; }
  .clock { display: none; }
}
@media (max-width: 600px) {
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip > div { border-right: 0; border-top: 1px solid var(--line); }
  .strip > div:nth-child(odd) { border-right: 1px solid var(--line); }
  .strip > div:nth-child(-n+2) { border-top: 0; }
  .readout-value { font-size: 52px; }
  .topbar-title h1 { font-size: 21px; }
  .hbar { grid-template-columns: 92px minmax(0, 1fr) 46px; }
  .nav a span { display: none; }
  .nav a { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar-tools, .toolbar, .btn { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}
.node-sw { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink-2); display: inline-block; }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.nowrap { white-space: nowrap; }
.mimic-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 700px) {
  .mimic { min-width: 640px; }
  .hero-mimic { padding: 14px 12px 0; }
}
.steps-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); column-gap: 24px; }
.steps-row li { border-bottom: 0; }

/* =====================================================================
   Live monitoring (control room)
   ===================================================================== */
:root { --live: #1E8E6A; --learn: #2A6CB8; }
:root[data-theme="dark"] { --live: #3CC79A; --learn: #6EA2DF; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --live: #3CC79A; --learn: #6EA2DF; } }

/* sidebar groups */
.nav-group { font-size: 12px; color: var(--ink-3); padding: 14px 10px 4px; }
.nav .dot, .state-dot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; flex: none; background: var(--line-strong); }
.nav .badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: 600; text-align: center; background: var(--inset); color: var(--ink-2); line-height: 18px; }
.nav .badge.is-alarm { background: var(--b-severe); color: var(--b-severe-ink); }
.nav .badge.is-warning { background: var(--b-minor); color: var(--b-minor-ink); }
.st-normal .state-dot, .state-dot.st-normal { background: var(--live); }
.state-dot.st-learning { background: var(--learn); }
.state-dot.st-warning { background: var(--b-minor); border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.state-dot.st-alarm { background: var(--b-severe); border-radius: 1px; }
.state-dot.st-offline, .state-dot.st-nodata { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }

/* live indicator in the top bar */
.live-ind { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 0 6px; }
.live-ind i { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.live-ind.is-live i { background: var(--live); }
@media (prefers-reduced-motion: no-preference) {
  .live-ind.is-live i { animation: blink 1.6s ease-in-out infinite; }
  @keyframes blink { 50% { opacity: .35; } }
}
.demo-chip { font-size: 12px; padding: 2px 8px; border-radius: 3px; background: var(--inset); color: var(--ink-2); border: 1px dashed var(--line-strong); }

/* state pills (live) */
.pill-state { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 8px; border-radius: 3px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); background: var(--inset); color: var(--ink); white-space: nowrap; }
.pill-state.st-normal { color: var(--ink); }
.pill-state.st-warning { background: var(--b-tint-minor); border-color: transparent; }
.pill-state.st-alarm { background: var(--b-severe); border-color: transparent; color: var(--b-severe-ink); }
.pill-state.st-alarm .state-dot { background: currentColor; }
.pill-state.st-learning { color: var(--learn); }

/* system ribbon */
.ribbon { display: grid; grid-template-columns: minmax(260px, 1.3fr) repeat(4, minmax(0, 1fr)); align-items: stretch; }
.ribbon > div { padding: 16px 18px; border-right: 1px solid var(--line); min-width: 0; }
.ribbon > div:last-child { border-right: 0; }
.ribbon .headline { display: flex; gap: 14px; align-items: center; }
.ribbon .headline .shape { width: 18px; height: 18px; }
.ribbon .headline b { display: block; font: 600 20px/1.2 var(--font-display); }
.ribbon .headline span { font-size: 13px; color: var(--ink-3); }
.ribbon dt { font-size: 12.5px; color: var(--ink-3); }
.ribbon dd { margin: 4px 0 0; font: 600 24px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.ribbon dd small { font: 400 12.5px/1.3 var(--font-ui); color: var(--ink-3); margin-left: 4px; }
.ribbon.is-alarm { border-color: var(--b-severe); box-shadow: inset 4px 0 0 var(--b-severe); }
.ribbon.is-warning { box-shadow: inset 4px 0 0 var(--b-minor); }

/* overview layout */
.grid-overview { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.tile { display: flex; flex-direction: column; }
.tile .panel-head h2 a { color: var(--ink); text-decoration: none; }
.tile .panel-head h2 a:hover { color: var(--action); }
.tile-draw { padding: 10px 14px 0; }
.tile-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.tile-stats > div { padding: 10px 14px; border-right: 1px solid var(--line); min-width: 0; }
.tile-stats > div:last-child { border-right: 0; }
.tile-stats dt { font-size: 12px; color: var(--ink-3); }
.tile-stats dd { margin: 2px 0 0; font: 600 17px/1.2 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-spark { height: 64px; padding: 6px 14px 10px; border-top: 1px solid var(--line); position: relative; }
.tile-spark canvas { width: 100% !important; height: 48px !important; }
.tile-spark .spark-label { position: absolute; top: 6px; right: 14px; font-size: 11.5px; color: var(--ink-3); }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.progress { height: 6px; background: var(--inset); border-radius: 3px; overflow: hidden; flex: 1 1 auto; max-width: 160px; }
.progress i { display: block; height: 100%; background: var(--learn); border-radius: 3px; transition: width .4s; }

/* schematic drawings */
.schem { display: block; width: 100%; height: auto; }
.schem text { font-family: var(--font-ui); font-size: 13px; fill: var(--ink-3); }
.schem .chord { stroke: var(--steel-edge); stroke-width: 4; stroke-linecap: round; }
.schem .member { stroke: var(--steel-edge); stroke-width: 2.2; opacity: .85; }
.schem .joint { fill: var(--panel); stroke: var(--steel-edge); stroke-width: 1.5; }
.schem .support { fill: var(--wall); stroke: none; }
.schem .ground, .schem .hatch { stroke: var(--ink-3); stroke-width: 1.4; }
.schem .dim { stroke: var(--ink-3); stroke-width: 1; }
.schem .tower { fill: var(--wall); }
.schem .cable { stroke: var(--steel-edge); stroke-width: 2.4; fill: none; }
.schem .hanger { stroke: var(--steel-edge); stroke-width: 1.2; }
.schem .deck, .schem .slab, .schem .beam { fill: var(--steel); stroke: var(--steel-edge); stroke-width: 1; }
.schem .wall { fill: var(--wall); }
.schem .arrow { stroke: var(--ink-3); stroke-width: 1.5; fill: none; }

.sensor { cursor: pointer; }
.sensor .halo { fill: transparent; stroke: transparent; stroke-width: 2; }
.sensor .dot { fill: var(--panel); stroke: var(--ink-2); stroke-width: 2.5; }
.sensor .code { font: 600 13px var(--font-display); fill: var(--ink); text-anchor: middle; }
.sensor .val { font-size: 11.5px; fill: var(--ink-3); text-anchor: middle; }
.sensor.st-normal .dot { fill: var(--live); stroke: var(--panel); }
.sensor.st-learning .dot { fill: var(--panel); stroke: var(--learn); stroke-dasharray: 3 2.5; }
.sensor.st-warning .dot { fill: var(--b-minor); stroke: var(--b-minor-ink); stroke-width: 1.5; }
.sensor.st-alarm .dot { fill: var(--b-severe); stroke: var(--panel); }
.sensor.st-alarm .halo { stroke: var(--b-severe); }
.sensor.st-warning .halo { stroke: var(--b-minor); }
.sensor.st-offline .dot, .sensor.st-nodata .dot { fill: var(--panel); stroke: var(--ink-3); stroke-dasharray: 2 3; }
.sensor.is-selected .halo { stroke: var(--action); stroke-width: 2.5; }
.sensor:focus-visible { outline: none; }
.sensor:focus-visible .halo { stroke: var(--focus); stroke-width: 3; }
@media (prefers-reduced-motion: no-preference) {
  .sensor.st-alarm .halo, .sensor.st-warning .halo { animation: halo 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
  @keyframes halo { 0% { transform: scale(.7); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
  .sensor.st-normal .dot { transition: fill .3s; }
}
.schem-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); padding: 4px 16px 14px; }
.schem-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 2px solid var(--ink-2); background: var(--panel); }
.lg.st-normal { background: var(--live); border-color: var(--live); }
.lg.st-learning { border: 2px dashed var(--learn); }
.lg.st-warning { background: var(--b-minor); border-color: var(--b-minor); border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.lg.st-alarm { background: var(--b-severe); border-color: var(--b-severe); border-radius: 1px; }
.lg.st-offline { border: 2px dotted var(--ink-3); }

/* structure page */
.grid-live { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); }
.status-list { margin: 0; display: grid; grid-template-columns: auto 1fr; }
.status-list dt, .status-list dd { margin: 0; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.status-list dt { color: var(--ink-3); font-size: 13px; }
.status-list dd { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.status-list dt:nth-last-child(2), .status-list dd:last-child { border-bottom: 0; }
.big-state { padding: 18px 16px; display: flex; gap: 14px; align-items: center; border-bottom: 1px solid var(--line); }
.big-state .shape { width: 20px; height: 20px; }
.big-state b { display: block; font: 600 22px/1.2 var(--font-display); }
.big-state span { font-size: 13px; color: var(--ink-3); }
.chart-live { position: relative; height: 230px; }
.chart-live.tall { height: 260px; }
.chart-note { font-size: 12.5px; color: var(--ink-3); padding: 0 16px 12px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-ctl); overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: 5px 10px; font: 500 13px var(--font-ui); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--inset); color: var(--ink); }
table.data tr.is-selected td { background: var(--inset); }
table.data tr.clickable { cursor: pointer; }
.demo-panel { border-style: dashed; }
.demo-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 14px 16px; }
.demo-row label { font-size: 13px; color: var(--ink-2); }
.demo-row input[type=range] { width: 180px; accent-color: var(--b-severe); }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: grid; grid-template-columns: 16px 1fr auto; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); align-items: start; font-size: 13.5px; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list .shape { margin-top: 5px; }
.alert-list small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.alert-list .is-cleared { opacity: .6; }
.empty-note { padding: 18px 16px; color: var(--ink-3); font-size: 13.5px; }

/* learning page */
.bar { height: 8px; background: var(--inset); border-radius: 4px; overflow: hidden; min-width: 90px; }
.bar i { display: block; height: 100%; background: var(--learn); }
.phase { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.metric-cell b { font: 600 16px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.metric-cell small { display: block; color: var(--ink-3); font-size: 11.5px; }
tr.is-active-version td { background: var(--inset); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 11.5px; font-weight: 600; background: var(--action); color: var(--action-ink); }
.tag.quiet { background: var(--inset); color: var(--ink-2); }

/* connect page */
pre.code { margin: 0; padding: 12px 14px; background: var(--inset); border: 1px solid var(--line); border-radius: var(--radius-ctl); overflow-x: auto; font: 12.5px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink); white-space: pre; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row code { flex: 1 1 auto; overflow-x: auto; white-space: nowrap; padding: 7px 10px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.howto h3 { font-size: 15px; margin: 16px 0 6px; }
.howto h3:first-child { margin-top: 0; }
.howto p { color: var(--ink-2); font-size: 13.5px; }

@media (max-width: 1280px) {
  .grid-overview { grid-template-columns: minmax(0, 1fr); }
  .ribbon { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ribbon > div:first-child { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--line); }
  .ribbon > div:nth-child(odd) { border-right: 0; }
}
@media (max-width: 1100px) {
  .grid-live { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .nav-group { display: none; }
  .nav .dot, .nav .badge { margin-left: 6px; }
}
@media (max-width: 600px) {
  .tile-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-stats > div:nth-child(2) { border-right: 0; }
  .tile-stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .ribbon { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* tile polish */
.tile-draw { flex: 1 1 auto; display: flex; align-items: center; }
.tile .schem > text { display: none; }
.tile .schem .sensor .dot { r: 15px; stroke-width: 4; }
.tile .schem .sensor .halo { r: 24px; }
.tile .schem .sensor .code { font-size: 26px; }
.tile .schem .chord { stroke-width: 6; }
.tile-spark { height: auto; padding: 8px 14px 10px; }
.tile-spark .spark-label { position: static; display: block; margin-bottom: 4px; }
.tile-spark canvas { height: 44px !important; }
#sensor-table th, #sensor-table td { padding-left: 10px; padding-right: 10px; }
#sensor-table td:nth-child(2) { min-width: 120px; }
@media (min-width: 1281px) { .ribbon { grid-template-columns: minmax(320px, 1.6fr) repeat(4, minmax(0, 1fr)); } }
.brand b { white-space: nowrap; }
.tile .schem .sensor .code { transform: translateY(16px); }
.tile .schem .sensor .code[y^="-"] { transform: translateY(-14px); }
#sensor-table td.r { white-space: nowrap; }

/* =====================================================================
   AI damage assessment
   ===================================================================== */
.ai-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ai-grid > section { padding: 0; border-right: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; }
.ai-grid > section:last-child { border-right: 0; }
.ai-grid h3 { font-size: 15px; padding: 12px 16px 0; display: flex; justify-content: space-between; gap: 8px; }
.ai-grid h3 a { color: var(--ink); text-decoration: none; }
.ai-grid h3 a:hover { color: var(--action); }
.ai-card { padding: 8px 16px 14px; flex: 1 1 auto; }
.ai-head { margin-bottom: 8px; }
.ai-value { font: 600 44px/1 var(--font-display); margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.ai-value small { font-size: 22px; font-weight: 500; color: var(--ink-2); margin-left: 3px; }
.ai-value.ai-ok { color: var(--live); }
.ai-label { font-size: 12.5px; color: var(--ink-3); margin: 0 0 8px; }
.ai-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 12px 0 0; font-size: 13px; }
.ai-facts dt { color: var(--ink-3); }
.ai-facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.ai-model { font-size: 11.5px; color: var(--ink-3); margin: 12px 0 0; border-top: 1px dashed var(--line); padding-top: 8px; }
.ai-wide { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr); }
.ai-wide .ai-card { border-right: 1px solid var(--line); }
.ai-wide .ai-explain { padding: 14px 16px; font-size: 13px; color: var(--ink-2); }
.ai-wide .ai-explain p { margin: 0 0 8px; }
.ai-drivers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.ai-drivers span { border: 1px solid var(--line); background: var(--inset); border-radius: 3px; padding: 2px 8px; font-size: 12.5px; }
.schem .ai-zone { fill: var(--b-severe); fill-opacity: .18; stroke: var(--b-severe); stroke-width: 2; stroke-dasharray: 6 4; }
.schem .ai-zone.z-minor { fill: var(--b-minor); stroke: var(--b-minor); }
.schem .ai-zone.z-moderate { fill: var(--b-moderate); stroke: var(--b-moderate); }
.schem .ai-zone.z-critical { fill: var(--b-critical); stroke: var(--b-critical); }
.schem .ai-zone.is-suspected { fill-opacity: .1; }
@media (prefers-reduced-motion: no-preference) {
  .schem .ai-zone { animation: zone 2s ease-in-out infinite; }
  @keyframes zone { 50% { fill-opacity: .32; } }
}
@media (max-width: 1280px) { .ai-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-grid > section:nth-child(2) { border-right: 0; } .ai-grid > section:nth-child(n+3) { border-top: 1px solid var(--line); } }
@media (max-width: 700px) { .ai-grid { grid-template-columns: minmax(0, 1fr); } .ai-grid > section { border-right: 0; border-top: 1px solid var(--line); }
  .ai-wide { grid-template-columns: minmax(0, 1fr); } .ai-wide .ai-card { border-right: 0; border-bottom: 1px solid var(--line); } }
