/* OpenEgiz Hydro portal stylesheet
 *
 * Map-first workbench: the map is full-bleed and every other surface floats over it or
 * slides in on demand. HTML text never drops below 12px (SVG chart text never below 10px);
 * secondary and tertiary ink meet WCAG AA (>= 4.5:1) on the paper surfaces.
 */

/* ------------------------------------------------------------------------- */
/* Fonts (IBM Plex, SIL OFL 1.1 - see /fonts/OFL.txt)                         */
/* ------------------------------------------------------------------------- */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("/fonts/plex-sans-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("/fonts/plex-sans-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("/fonts/plex-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/plex-mono-400-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/plex-mono-400-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/plex-mono-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("/fonts/plex-mono-500-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("/fonts/plex-mono-500-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("/fonts/plex-mono-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ------------------------------------------------------------------------- */
/* Tokens                                                                    */
/* ------------------------------------------------------------------------- */

:root {
  /* Surfaces */
  --paper: #f6f4ee;
  --paper-raised: #fbfaf6;
  --paper-sunk: #ece8df;
  --hud-bg: rgba(246, 244, 238, 0.9);
  --hud-blur: 12px;

  /* Rules */
  --rule: #d8d2c5;
  --rule-strong: #b9b09f;
  --rule-faint: #e6e1d6;

  /* Ink */
  --ink: #18222b;
  --ink-2: #3a4650;
  --ink-3: #55606a;
  --on-accent: #ffffff;

  /* Domain colour */
  --hydro: #0f5c8a;
  --hydro-ink: #0b4a70;
  --hydro-soft: rgba(15, 92, 138, 0.1);
  --copper: #c84b31;
  --copper-ink: #a63a22;
  --copper-soft: rgba(200, 75, 49, 0.12);
  --teal: #1f7a6e;
  --teal-ink: #17665c;
  --teal-soft: rgba(31, 122, 110, 0.1);
  --ochre: #9a6b2f;
  --ochre-ink: #7d5420;
  --ochre-soft: rgba(154, 107, 47, 0.12);
  --violet: #6b3fa0;
  --violet-soft: rgba(107, 63, 160, 0.14);
  --muted-gray: #8a8f93;

  /* Shape */
  --radius-1: 2px;
  --radius-2: 3px;
  --radius-3: 4px;

  /* Type */
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-xs: 12px;
  --fs-s: 13px;
  --fs-m: 14px;
  --fs-l: 16px;
  --fs-xl: 18px;
  --fs-xxl: 20px;

  /* Space */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;

  /* Elevation: floating HUD carries a hairline border plus a tight offset shadow;
     drawers and the dialog carry the wider shadow only. */
  --shadow-hud: 0 1px 2px rgba(24, 34, 43, 0.08), 0 8px 24px rgba(24, 34, 43, 0.1);
  --shadow-edge: 0 1px 2px rgba(24, 34, 43, 0.1);
  --shadow-drawer: -10px 0 24px -16px rgba(24, 34, 43, 0.28);

  /* Workbench geometry */
  --header-h: 48px;
  --passport-w: 384px;
  --cad-h: 248px;
  --sheet-w: 304px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 160ms;
}

/* Over aerial imagery the HUD stays light paper: more opaque, darker rules, firmer edge. */
:root[data-basemap="satellite"] {
  --hud-bg: rgba(246, 244, 238, 0.96);
  --rule: #b9b09f;
  --rule-strong: #8f8676;
  --shadow-hud: 0 1px 2px rgba(0, 0, 0, 0.25), 0 10px 28px rgba(0, 0, 0, 0.35);
  --shadow-edge: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* ------------------------------------------------------------------------- */
/* Base & browser surfaces                                                   */
/* ------------------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-m);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--hydro);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border: 2px solid transparent;
  border-radius: var(--radius-3);
  background-clip: padding-box;
}

::selection {
  background: rgba(15, 92, 138, 0.2);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 2px solid var(--hydro);
  outline-offset: 2px;
}

a {
  color: var(--hydro);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

input[type="checkbox"] {
  accent-color: var(--hydro);
}

.hidden {
  display: none !important;
}

.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;
}

.portal-shell {
  display: grid;
  grid-template-rows: var(--header-h) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

/* ------------------------------------------------------------------------- */
/* Top bar: brand, views, language                                           */
/* ------------------------------------------------------------------------- */

.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--sp-4);
  height: var(--header-h);
  padding: 0 var(--sp-4);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 10;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  display: block;
}

.brand-title {
  font-size: var(--fs-m);
  font-weight: 600;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.top-nav {
  display: flex;
  align-items: stretch;
  gap: var(--sp-2);
  height: 100%;
}

.nav-btn {
  height: 100%;
  padding: 2px var(--sp-3) 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font-size: var(--fs-m);
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}

.nav-btn:hover {
  color: var(--ink);
  border-bottom-color: var(--rule-strong);
}

.nav-btn.active,
.nav-btn.active:hover {
  color: var(--hydro-ink);
  font-weight: 600;
  border-bottom-color: var(--hydro);
}

.nav-btn:focus-visible {
  outline-offset: -2px;
}

.lang-switcher {
  justify-self: end;
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  background: var(--paper-raised);
}

.lang-btn {
  min-width: 40px;
  height: 26px;
  padding: 0 var(--sp-2);
  border: none;
  border-radius: var(--radius-1);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.lang-btn:hover {
  background: var(--paper-sunk);
  color: var(--ink);
}

.lang-btn.active,
.lang-btn.active:hover {
  background: var(--ink);
  color: var(--paper-raised);
}

/* ------------------------------------------------------------------------- */
/* Shared controls                                                           */
/* ------------------------------------------------------------------------- */

.float-surface {
  background: var(--hud-bg);
  -webkit-backdrop-filter: blur(var(--hud-blur));
  backdrop-filter: blur(var(--hud-blur));
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-edge);
}

.seg,
.segmented-control {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  background: var(--paper-raised);
}

.seg.float-surface {
  background: var(--hud-bg);
}

.seg-btn {
  min-height: 28px;
  padding: 0 10px;
  line-height: 1;
  border: none;
  border-radius: var(--radius-1);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-s);
  font-weight: 500;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

.seg-btn.icon {
  min-width: 28px;
  padding: 0;
}

.seg-btn:hover {
  background: var(--paper-sunk);
  color: var(--ink);
}

.seg-btn.active,
.seg-btn.active:hover,
.seg-btn[aria-pressed="true"] {
  background: var(--hydro);
  color: var(--on-accent);
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-s);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

/* `.pill-btn` resets the fill after `.float-surface`; a floating pill restores the HUD fill + blur
   so its label stays legible over satellite imagery. */
.pill-btn.float-surface {
  border-color: var(--rule);
  border-radius: var(--radius-2);
  min-height: 34px;
  background: var(--hud-bg);
  -webkit-backdrop-filter: blur(var(--hud-blur));
  backdrop-filter: blur(var(--hud-blur));
  box-shadow: var(--shadow-edge);
}

.pill-btn:hover {
  background: var(--paper-sunk);
}

.pill-btn[aria-expanded="true"],
.pill-btn[aria-expanded="true"]:hover {
  background: var(--hydro-soft);
  color: var(--hydro-ink);
}

/* A floating trigger keeps its opaque HUD fill under the tint so it stays legible over imagery. */
.pill-btn.float-surface[aria-expanded="true"],
.pill-btn.float-surface[aria-expanded="true"]:hover {
  background: linear-gradient(var(--hydro-soft), var(--hydro-soft)), var(--hud-bg);
}

.pill-btn.float-surface:hover {
  background: linear-gradient(rgba(24, 34, 43, 0.05), rgba(24, 34, 43, 0.05)), var(--hud-bg);
}

.pill-btn .chev {
  color: var(--ink-3);
  transition: transform var(--dur) var(--ease-out);
}

.pill-btn[aria-expanded="true"] .chev {
  color: currentColor;
  transform: rotate(180deg);
}

.pill-btn.has-active {
  color: var(--hydro-ink);
}

.pill-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-1);
  background: var(--hydro);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--rule);
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  background: transparent;
  color: var(--ink-2);
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}

.icon-btn:hover {
  background: var(--paper-sunk);
  border-color: var(--rule);
  color: var(--ink);
}

.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: var(--fs-s);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: border-color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}

.text-btn:hover {
  border-color: var(--rule-strong);
  background: var(--paper);
}

.text-btn.active,
.text-btn.strong {
  border-color: var(--hydro);
  color: var(--hydro-ink);
}

.text-btn.active {
  background: var(--hydro-soft);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: var(--fs-s);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}

.action-btn:hover {
  border-color: var(--rule-strong);
  background: var(--paper);
}

.action-btn.primary {
  min-height: 40px;
  background: var(--copper);
  border-color: var(--copper);
  color: var(--on-accent);
  font-size: var(--fs-m);
  font-weight: 600;
}

.action-btn.primary:hover {
  background: var(--copper-ink);
  border-color: var(--copper-ink);
}

.action-btn.primary:disabled {
  opacity: 0.7;
}

.link-btn {
  color: var(--hydro);
  font-size: var(--fs-s);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.link-btn:hover {
  color: var(--hydro-ink);
}

.id-chip {
  display: inline-block;
  max-width: 100%;
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper-sunk);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: copy;
}

.id-chip:hover {
  border-color: var(--rule-strong);
  color: var(--ink);
}

.id-chip.copied::after {
  content: " · " attr(data-copied);
  color: var(--teal-ink);
  font-family: var(--font-sans);
  font-weight: 600;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}

.field-label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink-2);
}

.field-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

.survey-select,
.survey-input {
  width: 100%;
  min-height: 32px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur) var(--ease-out);
}

.survey-select {
  font-family: var(--font-sans);
}

.survey-select:hover,
.survey-input:hover {
  border-color: var(--rule-strong);
}

.survey-select:focus-visible,
.survey-input:focus-visible {
  outline-offset: 0;
  border-color: var(--hydro);
}

.survey-input::placeholder {
  color: var(--ink-3);
}

.popover-title {
  padding: var(--sp-1) var(--sp-2) var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-2);
}

.popover-empty {
  margin: 0;
  padding: var(--sp-2);
  font-size: var(--fs-s);
  color: var(--ink-2);
}

/* ------------------------------------------------------------------------- */
/* Atlas: full-bleed map + floating HUD                                      */
/* ------------------------------------------------------------------------- */

.atlas-view {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--paper-sunk);
}

.map-canvas {
  position: absolute;
  inset: 0;
}

.map-fallback-svg {
  width: 100%;
  height: 100%;
  background: var(--paper-sunk);
  display: block;
}

/* Top-left: Filters + Objective */
.map-toolbar {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px;
  max-width: calc(100% - 24px);
}

.objective-field {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 6px;
  min-width: 0;
}

.objective-prefix {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
}

.objective-select {
  min-height: 32px;
  max-width: 220px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-s);
  font-weight: 600;
  text-overflow: ellipsis;
}

.objective-select:hover {
  background: var(--paper-sunk);
}

/* Filter sheet (on demand) */
.filter-sheet {
  position: absolute;
  top: 58px;
  left: var(--sp-3);
  z-index: 6;
  width: var(--sheet-w);
  max-height: calc(100% - 150px);
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}

.atlas-view.cad-open .filter-sheet {
  max-height: calc(100% - var(--cad-h) - 84px);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 6px 6px 6px var(--sp-4);
  border-bottom: 1px solid var(--rule);
}

.sheet-title {
  margin: 0;
  font-size: var(--fs-m);
  font-weight: 600;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  overflow-y: auto;
  min-height: 0;
}

.sheet-foot {
  display: flex;
  justify-content: flex-end;
  padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--rule);
}

/* Top-right: camera cluster (wraps into two rows when space is short) */
.camera-cluster {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 6px;
  max-width: calc(100% - 420px);
}

.atlas-view.passport-open .camera-cluster {
  right: calc(var(--passport-w) + var(--sp-3));
  max-width: calc(100% - var(--passport-w) - 420px);
}

/* Bottom-left: result summary, Top Rivers, cursor telemetry */
.map-summary {
  position: absolute;
  left: var(--sp-3);
  bottom: var(--sp-3);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: calc(100% - 180px);
}

.summary-pill {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: 100%;
  padding: 2px 2px 2px var(--sp-3);
}

.summary-line {
  font-family: var(--font-mono);
  font-size: var(--fs-s);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.rivers-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + var(--sp-2));
  width: 352px;
  max-width: calc(100vw - 24px);
  padding: var(--sp-2) var(--sp-1) var(--sp-1);
  box-shadow: var(--shadow-edge);
}

.backbone-list {
  display: flex;
  flex-direction: column;
  max-height: 340px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--rule);
}

.backbone-item {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: var(--sp-2);
  row-gap: 1px;
  padding: 7px var(--sp-2);
  border: none;
  border-bottom: 1px solid var(--rule-faint);
  background: transparent;
  text-align: left;
  color: var(--ink);
  transition: background-color var(--dur) var(--ease-out);
}

.backbone-item:last-child {
  border-bottom: none;
}

.backbone-item:hover {
  background: var(--paper-sunk);
}

.backbone-item:focus-visible {
  outline-offset: -2px;
}

.backbone-item.active {
  background: var(--hydro-soft);
}

.backbone-item.active .backbone-item-main {
  color: var(--hydro-ink);
}

.backbone-item-main {
  font-size: var(--fs-s);
  font-weight: 600;
}

.backbone-item-ref {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  align-self: center;
  font-variant-numeric: tabular-nums;
}

.backbone-item-sub {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

/* Cursor telemetry strip: coordinates + scale ruler, one compact row */
.map-telemetry {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 7px 10px;
  font-size: var(--fs-xs);
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

.tele-readout {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.tele-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.tele-key {
  color: var(--ink-3);
  font-weight: 500;
}

.tele-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

#tele-lat,
#tele-lon {
  min-width: 7.5ch;
}

#tele-elev {
  min-width: 6ch;
}

.map-scale-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: var(--sp-3);
  border-left: 1px solid var(--rule);
  align-self: stretch;
}

.scale-rule {
  display: block;
  width: 48px;
  height: 6px;
  border: 1px solid var(--ink);
  border-top: none;
}

.scale-label {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Bottom-right: Layers & legend */
.map-layers {
  position: absolute;
  right: var(--sp-3);
  bottom: var(--sp-3);
  z-index: 4;
}

.atlas-view.passport-open .map-layers {
  right: calc(var(--passport-w) + var(--sp-3));
}

.atlas-view.cad-open .map-summary,
.atlas-view.cad-open .map-layers {
  bottom: calc(var(--cad-h) + var(--sp-3));
}

.layers-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + var(--sp-2));
  width: 320px;
  max-width: calc(100vw - 24px);
  padding: var(--sp-2) var(--sp-1) var(--sp-1);
}

.layer-row {
  display: grid;
  grid-template-columns: 16px 22px minmax(0, 1fr);
  align-items: center;
  gap: var(--sp-2);
  min-height: 32px;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-1);
  font-size: var(--fs-s);
  color: var(--ink);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease-out);
}

.layer-row:hover {
  background: var(--paper-sunk);
}

.layer-row input {
  margin: 0;
  width: 15px;
  height: 15px;
}

.layer-row:has(input:not(:checked)) {
  color: var(--ink-2);
}

.layer-row:has(input:not(:checked)) .swatch {
  opacity: 0.4;
  filter: grayscale(1);
}

.layer-divider {
  height: 1px;
  margin: var(--sp-1) var(--sp-2);
  background: var(--rule);
}

.swatch {
  justify-self: center;
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: var(--radius-1);
}

.swatch-terrain {
  width: 18px;
  height: 12px;
  border: 1px solid var(--rule-strong);
  background: linear-gradient(135deg, var(--paper-raised) 0%, var(--paper-sunk) 45%, var(--rule-strong) 100%);
}

.swatch-river {
  background: var(--hydro);
}

.swatch-cascade {
  height: 4px;
  background: var(--copper);
}

.swatch-curtain {
  width: 7px;
  height: 15px;
  border-radius: 0;
  background: linear-gradient(to top, var(--hydro) 0%, var(--copper) 100%);
}

/* Matches the map's existing-plant marker (dark fill, light ring). */
.swatch-plant {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1.5px var(--paper-raised), 0 0 0 2.5px var(--rule-strong);
}

.swatch-excluded {
  height: 4px;
  background: var(--ochre);
}

.swatch-swot {
  height: 4px;
  background: var(--violet);
}

.swatch-blind-zone {
  width: 18px;
  height: 12px;
  border-radius: var(--radius-1);
  background: var(--violet-soft);
  border: 1px dashed var(--violet);
}

/* Map hover tooltip (positioned by app.js through transform) */
.map-hover-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 8;
  min-width: 168px;
  max-width: 260px;
  padding: 7px 10px 8px;
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-edge);
  color: var(--ink);
  font-size: var(--fs-xs);
  line-height: 1.35;
  pointer-events: none;
  will-change: transform;
}

.tip-kind {
  display: block;
  margin: 0 0 6px;
  color: var(--ink-3);
  font-weight: 500;
}

.tip-title {
  display: block;
  margin: 0 0 1px;
  font-size: var(--fs-s);
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.tip-grid {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: var(--sp-3);
  row-gap: 2px;
  margin: 0;
  padding-top: 5px;
  border-top: 1px solid var(--rule);
}

.tip-grid dt {
  color: var(--ink-2);
}

.tip-grid dd {
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.tip-hint {
  display: block;
  margin-top: 5px;
  color: var(--ink-3);
}

/* MapLibre attribution: compact, above the Layers button */
.atlas-view .maplibregl-ctrl-bottom-right {
  bottom: 52px;
  right: 6px;
}

.atlas-view.passport-open .maplibregl-ctrl-bottom-right {
  right: calc(var(--passport-w) + 6px);
}

.atlas-view.cad-open .maplibregl-ctrl-bottom-right {
  bottom: calc(var(--cad-h) + 52px);
}

.atlas-view .maplibregl-ctrl-attrib {
  background: var(--hud-bg);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
}

.atlas-view .maplibregl-ctrl-attrib a {
  color: var(--ink-2);
}

.atlas-view .maplibregl-ctrl-attrib.maplibregl-compact {
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  box-shadow: none;
}

/* ------------------------------------------------------------------------- */
/* River Profile drawer                                                      */
/* ------------------------------------------------------------------------- */

.cad-drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--cad-h);
  z-index: 3;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-top: 1px solid var(--rule-strong);
}

.atlas-view.passport-open .cad-drawer {
  right: var(--passport-w);
}

.cad-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 38px;
  padding: 3px 6px 3px var(--sp-4);
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
  min-width: 0;
}

.cad-title-group {
  flex: 0 1 auto;
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  min-width: 0;
}

.cad-title {
  margin: 0;
  font-size: var(--fs-m);
  font-weight: 600;
  white-space: nowrap;
}

.cad-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cad-readout {
  flex: 1 1 0;
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--hydro-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Idle instructions are prose: sans, quieter ink; the cursor readout keeps mono numerals. */
.cad-readout.is-hint {
  font-family: var(--font-sans);
  color: var(--ink-3);
}

.cad-viewport {
  flex: 1;
  min-height: 0;
  position: relative;
  padding: var(--sp-1) var(--sp-2) 2px;
}

.cad-svg {
  width: 100%;
  height: 100%;
  display: block;
  font-variant-numeric: tabular-nums;
}

.cad-svg text {
  font-variant-numeric: tabular-nums;
}

.cad-step-hit {
  cursor: pointer;
}

.cad-step-hit .step-box {
  fill: var(--hydro-soft);
  stroke: var(--hydro);
  stroke-width: 1;
  transition: fill var(--dur) var(--ease-out);
}

.cad-step-hit .step-path {
  fill: none;
  stroke: var(--hydro-ink);
  stroke-width: 1.5;
}

.cad-step-hit .step-house {
  fill: var(--hydro-ink);
  stroke: var(--paper-raised);
  stroke-width: 1;
}

.cad-step-hit .step-label {
  fill: var(--ink);
}

.cad-step-hit:hover .step-box,
.cad-step-hit.is-selected .step-box {
  fill: var(--copper-soft);
  stroke: var(--copper);
}

.cad-step-hit:hover .step-path,
.cad-step-hit.is-selected .step-path {
  stroke: var(--copper);
}

.cad-step-hit.is-selected .step-box {
  stroke-width: 1.5;
}

.cad-step-hit.is-selected .step-path {
  stroke-width: 2.2;
}

.cad-step-hit:hover .step-house,
.cad-step-hit.is-selected .step-house {
  fill: var(--copper);
}

.cad-step-hit:hover .step-label,
.cad-step-hit.is-selected .step-label {
  fill: var(--copper-ink);
}

.cad-cursor {
  pointer-events: none;
}

/* ------------------------------------------------------------------------- */
/* Site Passport drawer                                                      */
/* ------------------------------------------------------------------------- */

.passport-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  width: var(--passport-w);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  border-left: 1px solid var(--rule-strong);
  box-shadow: var(--shadow-drawer);
}

.passport-header {
  padding: var(--sp-3) var(--sp-4) var(--sp-3);
}

.passport-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
  margin: 0 -8px 0 0;
}

.passport-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px var(--sp-2);
  margin: 0 0 var(--sp-2);
}

.passport-meta-row .passport-subtitle {
  margin: 0;
}

.passport-badge:empty {
  display: none;
}

.passport-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.passport-badge.existing {
  border-color: var(--hydro);
  background: var(--hydro-soft);
  color: var(--hydro-ink);
}

.passport-title {
  margin: 2px 0 4px;
  font-size: var(--fs-xl);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.passport-subtitle {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-s);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.passport-subtitle:empty {
  display: none;
}

/* Ruled KPI matrix: flush cells separated by 1px rules */
.passport-kpis,
.whatif-kpi-grid,
.twin-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  overflow: hidden;
}

.passport-kpis {
  margin: 0 var(--sp-4) var(--sp-3);
}

.kpi-tile {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 10px 8px;
  background: var(--paper-raised);
  min-width: 0;
}

.kpi-tile-label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-tile-value {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.kpi-tile-unit {
  margin-left: var(--sp-1);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-2);
}

.passport-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 var(--sp-4) var(--sp-3);
}

.passport-badges:empty {
  display: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

.status-badge.teal {
  border-color: transparent;
  background: var(--teal-soft);
  color: var(--teal-ink);
}

.status-badge.teal-outline {
  border-color: var(--teal);
  background: transparent;
  color: var(--teal-ink);
}

.status-badge.copper {
  border-color: transparent;
  background: var(--copper-soft);
  color: var(--copper-ink);
}

.status-badge.ochre {
  border-color: transparent;
  background: var(--ochre-soft);
  color: var(--ochre-ink);
}

.status-badge.ochre-solid {
  border-color: var(--ochre);
  background: var(--ochre-soft);
  color: var(--ochre-ink);
  font-weight: 600;
}

.status-badge.violet {
  border-color: transparent;
  background: var(--violet);
  color: var(--on-accent);
}

.status-badge.violet-outline {
  border: 1px dashed var(--violet);
  background: transparent;
  color: var(--violet);
}

/* Tabs: text tabs on a shared baseline rule, active tab underlined */
.passport-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: var(--sp-4);
  padding: 0 var(--sp-4);
  /* Baseline rule drawn as a background so the active underline can sit on it. */
  background:
    linear-gradient(var(--rule), var(--rule)) var(--sp-4) bottom / calc(100% - 2 * var(--sp-4)) 1px no-repeat,
    var(--paper);
}

.tab-btn {
  flex: 0 1 auto;
  min-height: 34px;
  padding: 4px 0 2px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-s);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}

.tab-btn:hover {
  color: var(--ink);
  border-bottom-color: var(--rule-strong);
}

.tab-btn.active,
.tab-btn.active:hover {
  color: var(--hydro-ink);
  font-weight: 600;
  border-bottom-color: var(--hydro);
}

.passport-body {
  flex: 1 0 auto;
  padding: var(--sp-1) var(--sp-4) var(--sp-4);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.spec-accordion {
  border-bottom: 1px solid var(--rule);
}

.spec-accordion > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 40px;
  font-size: var(--fs-s);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  transition: color var(--dur) var(--ease-out);
}

.spec-accordion > summary::-webkit-details-marker {
  display: none;
}

.spec-accordion > summary::after {
  content: "";
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--dur) var(--ease-out);
}

.spec-accordion[open] > summary::after {
  transform: rotate(-135deg) translateY(-2px);
}

.spec-accordion > summary:hover {
  color: var(--hydro-ink);
}

.spec-accordion > summary:focus-visible {
  outline-offset: -2px;
}

.accordion-body {
  padding: 0 0 var(--sp-3);
}

.passport-section {
  margin-bottom: var(--sp-4);
}

.passport-section-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 6px;
}

/* Label/value datasheet rows aligned on a hairline grid */
.spec-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--sp-3);
}

.spec-label,
.spec-val {
  padding: 5px 0;
  border-bottom: 1px solid var(--rule-faint);
}

.spec-label {
  font-size: var(--fs-s);
  color: var(--ink-2);
}

.spec-val {
  font-family: var(--font-mono);
  font-size: var(--fs-s);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

.spec-label:nth-last-child(2),
.spec-val:last-child {
  border-bottom: none;
}

.spec-val.copper,
.copper {
  color: var(--copper-ink);
}

.spec-val.teal,
.teal {
  color: var(--teal-ink);
}

.fine-note,
.prefeasibility-note {
  margin: var(--sp-2) 0 0;
  padding: var(--sp-2) 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--ochre-soft);
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--ink-2);
}

.ext-placeholder {
  margin: 0;
  padding: var(--sp-3);
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-2);
  background: var(--paper-sunk);
  color: var(--ink-2);
  font-size: var(--fs-s);
}

.passport-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: auto;
  padding: 10px var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--rule);
  background: var(--paper);
}

.passport-secondary {
  display: flex;
  gap: var(--sp-2);
}

.passport-secondary .text-btn {
  flex: 1;
}

.passport-feedback {
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.passport-feedback:empty {
  display: none;
}

.passport-feedback.error {
  color: var(--copper-ink);
}

/* ------------------------------------------------------------------------- */
/* Passport engineering suite: cutaway, hydrograph, What-If, H-Q             */
/* ------------------------------------------------------------------------- */

.eng-suite {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding-top: var(--sp-3);
}

.eng-block {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--rule);
}

.eng-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.eng-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 22px;
}

.eng-block-header .passport-section-title,
.whatif-header-row .passport-section-title {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.eng-eco-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  background: var(--teal-soft);
  color: var(--teal-ink);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

.eng-eco-badge:empty {
  display: none;
}

.eng-eco-badge.stress {
  border-color: var(--copper);
  background: var(--copper-soft);
  color: var(--copper-ink);
}

.eng-eco-badge.wet {
  background: var(--hydro-soft);
  color: var(--hydro-ink);
}

.eng-regime-tag,
.eng-hq-coord {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.scenario-toggle {
  display: grid;
  /* minmax(0, …) lets long Kazakh labels wrap inside a 320 px passport instead of overflowing it. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  background: var(--paper-raised);
}

.scen-btn {
  min-height: 28px;
  padding: 3px 6px;
  border: none;
  border-radius: var(--radius-1);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.2;
  overflow-wrap: normal;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

.scen-btn:hover {
  background: var(--paper-sunk);
  color: var(--ink);
}

.scen-btn.active,
.scen-btn.active:hover {
  background: var(--hydro);
  color: var(--on-accent);
}

/* Compact cutaway stage (3D viewport + callout pins + camera bar) */
.cutaway-stage {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  background: var(--paper-sunk);
  overflow: hidden;
}

.cutaway-viewport {
  width: 100%;
  height: 232px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  background: var(--paper-sunk);
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.cutaway-stage .cutaway-viewport {
  height: 240px;
  border: none;
  border-radius: 0;
}

.cutaway-viewport:active {
  cursor: grabbing;
}

.cutaway-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cutaway-callouts {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.callout-pin {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  color: var(--ink);
  transition: opacity var(--dur) var(--ease-out);
  will-change: transform;
}

.callout-pin.is-hidden {
  opacity: 0;
}

.callout-dot {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 1.5px var(--paper-raised);
}

.callout-tag {
  position: absolute;
  left: 12px;
  top: -11px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 6px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  font-size: var(--fs-xs);
  line-height: 1.35;
  white-space: nowrap;
}

.callout-tag::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: 8px;
  height: 1px;
  background: currentColor;
}

/* Pins near the right stage edge: tag sits left of the dot with a mirrored leader. */
.callout-pin.flip .callout-tag {
  left: auto;
  right: 12px;
}

.callout-pin.flip .callout-tag::before {
  right: auto;
  left: 100%;
}

.callout-key {
  color: var(--ink-2);
}

.callout-val {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.callout-pin[data-callout="intakeElev"],
.callout-pin[data-callout="netHead"],
.callout-pin.stress {
  color: var(--copper);
}

.callout-pin[data-callout="intakeElev"] .callout-val,
.callout-pin[data-callout="netHead"] .callout-val,
.callout-pin.stress .callout-val {
  color: var(--copper-ink);
}

.callout-pin[data-callout="ecoFlow"]:not(.stress) {
  color: var(--teal);
}

.callout-pin[data-callout="ecoFlow"]:not(.stress) .callout-val {
  color: var(--teal-ink);
}

.cutaway-stage-bar {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 5px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-1);
  pointer-events: none;
}

.cutaway-stage-bar > * {
  pointer-events: auto;
}

.cutaway-cam-presets.compact {
  /* Always one row: in a narrow passport (1024 px, Kazakh labels) the bar scrolls sideways
     inside itself instead of wrapping over the stage; Expand keeps its slot. */
  flex: 0 1 auto;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 1px;
  gap: 1px;
  background: var(--hud-bg);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.cutaway-cam-presets.compact::-webkit-scrollbar {
  display: none;
}

/* When the bar overflows, a scroll-linked edge fade marks the side that still has presets. */
@supports (animation-timeline: scroll()) {
  .cutaway-cam-presets.compact {
    animation: cam-bar-edge linear both;
    animation-timeline: scroll(self inline);
  }

  @keyframes cam-bar-edge {
    from {
      -webkit-mask-image: linear-gradient(to right, var(--ink) calc(100% - 24px), transparent);
      mask-image: linear-gradient(to right, var(--ink) calc(100% - 24px), transparent);
    }

    to {
      -webkit-mask-image: linear-gradient(to left, var(--ink) calc(100% - 24px), transparent);
      mask-image: linear-gradient(to left, var(--ink) calc(100% - 24px), transparent);
    }
  }
}

.cutaway-cam-presets.compact .seg-btn {
  flex-shrink: 0;
  min-height: 24px;
  padding: 0 5px;
  font-size: var(--fs-xs);
}

.cutaway-cam-presets .seg-btn.active,
.cutaway-cam-presets .seg-btn[aria-pressed="true"],
.cutaway-cam-presets .seg-btn.active:hover {
  background: var(--hydro);
  color: var(--on-accent);
}

.cutaway-cam-presets .seg-btn:focus-visible,
.theater-scenarios .seg-btn:focus-visible {
  outline-offset: 0;
}

.cutaway-expand {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-color: var(--rule);
  background: var(--hud-bg);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.cutaway-expand:hover {
  background: var(--paper-raised);
  border-color: var(--rule-strong);
}

.cutaway-meta-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px var(--sp-3);
  padding: 5px var(--sp-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* The turbine name in the meta strip is a label, not a selection: keep it off copper. */
.cutaway-meta-strip .copper {
  color: var(--hydro-ink);
}

.cutaway-hint {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-wrap: balance;
}

.hydrograph-host,
.hq-host {
  width: 100%;
}

.hydrograph-svg,
.hq-svg {
  width: 100%;
  height: auto;
  display: block;
  font-variant-numeric: tabular-nums;
}

.hydrograph-legend,
.hq-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.hydrograph-legend span,
.hq-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hleg-swatch {
  display: inline-block;
  width: 10px;
  height: 8px;
}

.hleg-diverted {
  background: var(--hydro);
}

.hleg-bypass {
  background: var(--teal);
}

.hleg-spill {
  background: var(--hydro);
  opacity: 0.35;
}

.hq-dot-active,
.hq-dot-site {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--copper);
}

.hq-dot-site {
  background: var(--hydro);
  opacity: 0.6;
}

.hq-dot-plant {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--ink);
  transform: rotate(45deg);
}

.hq-point-hit {
  cursor: pointer;
}

.whatif-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px var(--sp-3) var(--sp-3);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
}

.whatif-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.whatif-header-row .text-btn {
  min-height: 26px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-xs);
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.slider-val {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Themed range input: hairline track, square-shouldered thumb */
.slider-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: var(--radius-1);
  background: var(--rule);
}

.slider-row input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: var(--radius-1);
  background: var(--rule);
}

.slider-row input[type="range"]::-moz-range-progress {
  height: 3px;
  background: var(--hydro);
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 16px;
  margin-top: -6.5px;
  border: 1px solid var(--hydro-ink);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  box-shadow: inset 0 0 0 3px var(--hydro);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 16px;
  border: 1px solid var(--hydro-ink);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  box-shadow: inset 0 0 0 3px var(--hydro);
}

.slider-row input[type="range"]:hover::-webkit-slider-runnable-track {
  background: var(--rule-strong);
}

.slider-row input[type="range"]:focus-visible {
  outline-offset: 1px;
}

.wkpi {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px var(--sp-2) 7px;
  background: var(--paper-raised);
  min-width: 0;
}

.wkpi-label {
  font-size: var(--fs-xs);
  line-height: 1.3;
  color: var(--ink-3);
  text-wrap: balance;
}

.wkpi-val {
  font-family: var(--font-mono);
  font-size: var(--fs-s);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}

.wkpi-val.copper {
  color: var(--copper-ink);
}

.wkpi-val.teal {
  color: var(--teal-ink);
}

.wkpi-val.ochre {
  color: var(--ochre-ink);
}

/* ------------------------------------------------------------------------- */
/* Expanded cutaway dialog                                                   */
/* ------------------------------------------------------------------------- */

.cutaway-modal {
  width: calc(100vw - 48px);
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-3);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-hud);
  overflow: hidden;
}

.cutaway-modal[open] {
  display: flex;
  flex-direction: column;
}

.cutaway-modal::backdrop {
  background: rgba(24, 34, 43, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.theater-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.theater-title-group {
  flex: 1 1 280px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px var(--sp-3);
  min-width: 0;
}

.theater-title {
  margin: 0;
  font-size: var(--fs-l);
  font-weight: 600;
  letter-spacing: -0.005em;
}

.theater-sub {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.theater-scenarios .seg-btn {
  font-size: var(--fs-xs);
}

.theater-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--sp-4);
  background: var(--paper-sunk);
  overflow: hidden;
}

.theater-canvas {
  position: absolute;
  inset: 0;
  cursor: grab;
}

.theater-canvas:active {
  cursor: grabbing;
}

.theater-stage .cutaway-callouts {
  z-index: 1;
}

.theater-toolbar {
  position: absolute;
  left: 50%;
  bottom: var(--sp-4);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 3px 10px 3px 3px;
  transform: translateX(-50%);
  background: var(--hud-bg);
  -webkit-backdrop-filter: blur(var(--hud-blur));
  backdrop-filter: blur(var(--hud-blur));
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  max-width: calc(100% - 32px);
}

.theater-toolbar .seg {
  border: none;
  background: transparent;
  padding: 0;
}

.theater-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-s);
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
}

.theater-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
}

.theater-readouts {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 256px;
  margin: 0;
  padding: 2px 10px;
  background: var(--hud-bg);
  -webkit-backdrop-filter: blur(var(--hud-blur));
  backdrop-filter: blur(var(--hud-blur));
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
}

.theater-readouts:empty {
  display: none;
}

.theater-readouts > div {
  display: contents;
}

.theater-readouts dt,
.theater-readouts dd {
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
  font-size: var(--fs-xs);
}

.theater-readouts dt {
  color: var(--ink-2);
}

.theater-readouts dd {
  margin: 0;
  padding-left: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-s);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  color: var(--ink);
}

.theater-readouts > dt:last-of-type,
.theater-readouts > dd:last-of-type,
.theater-readouts > div:last-child > dt,
.theater-readouts > div:last-child > dd {
  border-bottom: none;
}

.theater-readouts dd.copper {
  color: var(--copper-ink);
}

/* ------------------------------------------------------------------------- */
/* Passport SWOT & validation slot                                           */
/* ------------------------------------------------------------------------- */

.swot-observed-card,
.swot-blind-card {
  padding: 10px var(--sp-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  background: var(--paper-raised);
  margin-bottom: var(--sp-3);
}

.swot-blind-card {
  border-style: dashed;
  border-color: var(--violet);
}

.swot-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.swot-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-1);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.swot-badge.observed {
  background: var(--violet);
  color: var(--on-accent);
}

.swot-badge.blind {
  background: var(--paper-raised);
  color: var(--violet);
  border: 1px dashed var(--violet);
}

.swot-refresh-btn {
  min-height: 28px;
  padding: 0 10px;
  font-size: var(--fs-xs);
}

.swot-blind-reason,
.swot-blind-note {
  margin: 6px 0;
  font-size: var(--fs-s);
  color: var(--ink-2);
}

.swot-status-msg {
  padding: 6px var(--sp-2);
  margin-bottom: var(--sp-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  font-size: var(--fs-xs);
}

.swot-status-msg.ok {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal-ink);
}

.swot-status-msg.offline {
  background: var(--ochre-soft);
  border-color: var(--ochre);
  color: var(--ochre-ink);
}

.swot-chart-label {
  margin: 10px 0 var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-2);
}

.swot-sparkline {
  width: 100%;
  height: auto;
  display: block;
}

.swot-empty {
  font-size: var(--fs-s);
  color: var(--ink-2);
}

/* ------------------------------------------------------------------------- */
/* Secondary workspaces (Validation, Twins)                                  */
/* ------------------------------------------------------------------------- */

.ext-workspace {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
}

.ext-card {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px var(--sp-5) 32px;
}

.val-title,
.ws-title {
  margin: 0;
  font-size: var(--fs-xxl);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

/* Shared data table: hairline rows, right-aligned tabular numerals, whole-row hover */
.val-table-wrap,
.twin-table-wrap {
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  background: var(--paper-raised);
  overflow-x: auto;
}

.val-table,
.twin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-s);
}

.val-table th,
.val-table td,
.twin-table th,
.twin-table td {
  border-bottom: 1px solid var(--rule-faint);
  text-align: left;
  white-space: nowrap;
}

.val-table th,
.twin-table th {
  background: var(--paper);
  border-bottom-color: var(--rule-strong);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink-2);
  vertical-align: bottom;
  /* Headers wrap at word boundaries so long Kazakh labels never widen a numeric column. */
  white-space: normal;
}

.val-table th[title],
.twin-table th[title] {
  cursor: help;
}

.val-table tbody tr:last-child td,
.twin-table tbody tr:last-child td {
  border-bottom: none;
}

.val-table .num,
.twin-table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.val-table th.num,
.twin-table th.num {
  font-family: var(--font-sans);
}

/* Validation Lab */
.val-shell {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px var(--sp-5) 32px;
}

.val-loading,
.val-error {
  padding: var(--sp-5) 0;
  font-size: var(--fs-m);
  color: var(--ink-2);
}

.val-error {
  color: var(--copper-ink);
}

.val-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.val-heading {
  min-width: 0;
}

.val-subtitle {
  margin: var(--sp-1) 0 0;
  font-size: var(--fs-s);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.val-note {
  margin: 0;
  max-width: 120ch;
  font-size: var(--fs-s);
  color: var(--ink-2);
  text-wrap: pretty;
}

.val-plots-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-3);
}

.val-plot-card {
  margin: 0;
  padding: 10px var(--sp-3) 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  background: var(--paper-raised);
  min-width: 0;
  container: val-card / inline-size;
}

.val-plot-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-2);
}

.val-plot-title {
  font-size: var(--fs-s);
  font-weight: 600;
}

.val-plot-count {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.val-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 6px 0 4px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.val-stats > div {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 4px 6px;
  border-left: 1px solid var(--rule-faint);
}

.val-stats > div:first-child {
  border-left: none;
  padding-left: 0;
}

.val-stats dt {
  font-size: var(--fs-xs);
  line-height: 1.3;
  color: var(--ink-3);
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Long stat labels (Kazakh) need two columns once a card narrows; short labels hold four longer. */
@container val-card (max-width: 400px) {
  :lang(kk) .val-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  :lang(kk) .val-stats > div:nth-child(odd) {
    border-left: none;
    padding-left: 0;
  }

  :lang(kk) .val-stats > div:nth-child(n + 3) {
    border-top: 1px solid var(--rule-faint);
  }
}

@container val-card (max-width: 260px) {
  .val-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .val-stats > div:nth-child(odd) {
    border-left: none;
    padding-left: 0;
  }

  .val-stats > div:nth-child(n + 3) {
    border-top: 1px solid var(--rule-faint);
  }
}

.val-stats dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-s);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.val-scatter-svg {
  width: 100%;
  height: auto;
  display: block;
  font-variant-numeric: tabular-nums;
}

.val-scatter-pt {
  cursor: pointer;
  transition: r var(--dur) var(--ease-out);
}

.val-scatter-pt:hover,
.val-scatter-pt:focus-visible {
  r: 6;
  fill-opacity: 1;
  stroke: var(--ink);
  outline: none;
}

.val-table-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.val-search {
  max-width: 320px;
  font-family: var(--font-sans);
}

.val-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.val-legend span {
  display: inline-flex;
  align-items: center;
}

.val-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}

.val-dot.mountain {
  background: var(--hydro);
}

.val-dot.lowland {
  background: var(--paper-raised);
  border: 1.5px solid var(--ink-2);
}

.val-line-1to1 {
  display: inline-block;
  width: 16px;
  border-top: 1.5px dashed var(--ink-3);
  margin-right: 6px;
}

.val-row-count {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.val-table th,
.val-table td {
  padding: 6px 10px;
}

.val-table td.plant-name,
.val-table td.val-river,
.val-table td.val-typ {
  white-space: normal;
}

.val-table td.plant-name {
  min-width: 96px;
}

.val-table .residual.neg {
  color: var(--ochre-ink);
}

.val-table .residual.pos {
  color: var(--hydro-ink);
}

.plant-name {
  font-weight: 600;
}

.plant-id {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--ink-3);
}

.val-row {
  cursor: pointer;
  transition: background-color var(--dur) var(--ease-out);
}

.val-row:hover,
.val-row:focus-visible {
  background: var(--hydro-soft);
}

.val-row:focus-visible,
.twin-row:focus-visible {
  outline: 2px solid var(--hydro);
  outline-offset: -2px;
}

.val-row:hover .plant-name,
.val-row:focus-visible .plant-name {
  color: var(--hydro-ink);
}

.val-typ-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 6px;
  line-height: 1.3;
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.val-typ-tag.mountain {
  color: var(--hydro-ink);
  background: var(--hydro-soft);
}

.val-typ-tag.lowland {
  color: var(--ink-2);
  background: transparent;
  border-color: var(--rule-strong);
}

.val-match-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px dashed var(--muted-gray);
  border-radius: var(--radius-1);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 500;
}

/* Excluded rows (no model match): grayscale, still clickable */
.val-row.is-excluded td {
  color: var(--ink-3);
}

/* Text stays at ink-3 (AA on every row surface); muted-gray is for rules, tags and swatches only. */
.val-row.is-excluded .plant-name,
.val-row.is-excluded .plant-id {
  color: var(--ink-3);
}

.val-row.is-excluded .plant-name {
  font-weight: 500;
}

.val-row.is-excluded .val-typ-tag {
  filter: grayscale(1);
  color: var(--ink-3);
  background: transparent;
  border-color: var(--muted-gray);
}

.val-row.is-excluded .residual {
  color: var(--ink-3);
}

.val-hint {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

/* Digital Twins: passport tab */
.twin-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-top: var(--sp-3);
}

.twin-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.twin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

.twin-pill.ok {
  border-color: transparent;
  background: var(--teal-soft);
  color: var(--teal-ink);
}

.twin-pill.live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
}

.twin-pill.alert {
  border-color: var(--copper);
  background: var(--copper-soft);
  color: var(--copper-ink);
}

.twin-pill.muted {
  border-style: dashed;
  border-color: var(--muted-gray);
  color: var(--ink-3);
}

.twin-id-code {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-2);
  background: var(--paper-sunk);
  border-radius: var(--radius-1);
  padding: 1px 6px;
  word-break: break-all;
}

.twin-desc {
  margin: 0;
  font-size: var(--fs-s);
  color: var(--ink-2);
  line-height: 1.5;
  max-width: 75ch;
}

.twin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: 6px;
}

.twin-section-head .passport-section-title {
  flex: 1;
  margin-bottom: 0;
}

.twin-section-head .text-btn {
  min-height: 26px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-xs);
}

.twin-scenario-bar {
  width: 100%;
  flex-wrap: wrap;
}

.twin-scenario-bar .seg-btn {
  flex: 1 1 auto;
  font-size: var(--fs-xs);
}

.twin-telemetry-grid .tel-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px var(--sp-2) 7px;
  background: var(--paper-raised);
  min-width: 0;
}

.tel-label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tel-val {
  font-family: var(--font-mono);
  font-size: var(--fs-m);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}

.tel-val .tel-unit {
  margin-left: 3px;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.twin-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.twin-feedback {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  min-height: 16px;
}

.twin-feedback.error {
  color: var(--copper-ink);
}

.twin-loading {
  font-size: var(--fs-s);
  color: var(--ink-3);
  padding: var(--sp-2) 0;
}

/* Digital Twins: workspace roster */
.twin-workspace-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.twin-workspace-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.twin-workspace-head .twin-desc {
  margin-top: var(--sp-1);
}

.ws-count {
  display: inline-block;
  min-width: 26px;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper-raised);
  color: var(--hydro-ink);
  font-family: var(--font-mono);
  font-size: var(--fs-m);
  font-weight: 500;
  text-align: center;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.twin-workspace-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.twin-table th,
.twin-table td {
  padding: 9px var(--sp-3);
  vertical-align: middle;
}

.twin-table td:first-child {
  white-space: normal;
}

.twin-row {
  transition: background-color var(--dur) var(--ease-out);
}

.twin-row:hover,
.twin-row:focus-within {
  background: var(--hydro-soft);
}

.twin-row-name {
  font-weight: 600;
  color: var(--ink);
}

.twin-row-meta {
  margin-bottom: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.twin-copy-id {
  max-width: 240px;
}

.twin-num-unit {
  margin-left: 4px;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.twin-row-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  white-space: nowrap;
}

.twin-inline-scenario {
  min-width: 128px;
}

/* Inactive twins (no telemetry yet): grayscale roster row */
.twin-row.is-inactive td,
.twin-row.is-inactive .twin-row-name,
.twin-row.is-inactive .twin-row-meta,
.twin-row.is-inactive .twin-num-unit {
  color: var(--ink-3);
}

.twin-row.is-inactive .twin-row-name {
  font-weight: 500;
}

.twin-row.is-inactive .twin-pill,
.twin-row.is-inactive .id-chip {
  filter: grayscale(1);
  color: var(--ink-3);
}

.twin-empty {
  text-align: center;
  padding: var(--sp-5) var(--sp-3);
  color: var(--ink-2);
  white-space: normal !important;
}

/* ------------------------------------------------------------------------- */
/* Responsive                                                                */
/* ------------------------------------------------------------------------- */

@media (max-width: 1240px) {
  :root {
    --passport-w: 320px;
    --cad-h: 224px;
  }

  /* Region presets yield to the passport; 2D/3D, basemap and zoom stay. */
  .atlas-view.passport-open .camera-presets {
    display: none;
  }

  .atlas-view.passport-open .objective-prefix {
    display: none;
  }

  /* Passport open: regroup into a narrow two-row block (2D/3D + zoom, then basemap). */
  .atlas-view.passport-open .camera-cluster {
    max-width: 204px;
  }

  .atlas-view.passport-open .camera-cluster > .seg-vertical {
    order: 1;
  }

  .atlas-view.passport-open .camera-cluster > .basemap-switch {
    order: 2;
  }

  .passport-kpis .kpi-tile-value {
    font-size: var(--fs-l);
  }

  .passport-tabs {
    gap: var(--sp-3);
  }

  .tab-btn {
    font-size: var(--fs-xs);
  }

  .atlas-view.passport-open .map-summary {
    max-width: calc(100% - var(--passport-w) - 150px);
  }

  .val-plots-row {
    gap: var(--sp-2);
  }

  .val-table th,
  .val-table td {
    padding: 6px 5px;
  }

  /* Twins roster: action links stack under "View on Atlas"; the ID chip narrows. */
  .twin-row-links {
    flex-direction: column;
    align-items: flex-start;
  }

  .twin-copy-id {
    max-width: 200px;
  }

  .twin-table th,
  .twin-table td {
    padding-left: var(--sp-2);
    padding-right: var(--sp-2);
  }

  /* Stack the match tag under the typology tag so the table fits 1024px without scrolling. */
  .val-match-tag {
    display: flex;
    width: fit-content;
    margin: 3px 0 0;
  }

  .cutaway-modal {
    width: calc(100vw - 32px);
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
  }
}

@media (max-width: 900px) {
  .brand-title {
    display: none;
  }

  .camera-cluster {
    flex-direction: column;
    align-items: flex-end;
  }

  .val-plots-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
