/* TopWise · Formation Tops Prediction — shell stylesheet.
   Layout (one column grid, full viewport): top bar (row 1: brand / title / well / demo badge; row 2: the
   display controls, the "Drilling parameters" disclosure and the theme toggle, then the compact drilling-
   parameter readouts, collapsed by default on laptop-size screens) → look-ahead KPI strip → view tabs +
   playback toolbar → <main class="views">: the correlation workspace (log-paper canvas + tops / prediction
   side panel) or the 3D visualization, filling the remaining height.
   Themes: tokens on :root (light) and :root[data-theme="dark"] (dark, the default — <html> ships with
   data-theme="dark" and main.js always sets an explicit theme). The --c-* tokens are the canvas palette:
   render.js / ui.js / dashboard.js / viz3d.js read them by name, so every --c-* value is #rrggbb. */

/* ================================================================ tokens: light */
:root {
  color-scheme: light;
  --font-display: "Saira Semi Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-ui: "IBM Plex Sans Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* spacing (8 px scale), radii */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px;
  --r-sm: 6px; --r: 8px; --r-lg: 10px;

  /* UI surfaces and text */
  --bg: #edf1f6;
  --bg-glow: rgba(31, 102, 224, 0.06);
  --surface: #f8fafc;
  --surface-2: #ffffff;
  --surface-3: #e9eef5;
  --line: #d3dbe6;                /* passive dividers and card edges */
  --line-strong: #7a8aa0;         /* interactive control outlines: >= 3:1 on --bg, --surface and --surface-2 */
  --line-soft: color-mix(in srgb, var(--line) 60%, transparent);
  --text: #0e1a2b;
  --text-2: #435369;
  --text-3: #5c6c83;
  --accent: #1f66e0;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --good: #0f7d3a;
  --warn: #9a5b00;
  --warn-ink: #ffffff;
  --crit: #c42b2b;
  --callout: #1f66e0;
  --callout-soft: #e4eefd;
  --over: #fcefd6;
  --kpi-tint: #e4eefd;
  --shadow-1: 0 1px 2px rgba(16, 32, 64, 0.06), 0 1px 1px rgba(16, 32, 64, 0.03);
  --shadow-pop: 0 2px 6px rgba(16, 32, 64, 0.08), 0 14px 36px rgba(16, 32, 64, 0.16);
  --backdrop: rgba(14, 26, 43, 0.40);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5' fill='none' stroke='%23435369' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --accent-text: #1a5ccc;         /* accent used as small text on accent-tinted fills (>= 4.5:1) */
  /* legend chips for the two hatched zones: same hues as --c-undrilled / --c-await, strong enough for 3:1 */
  --lg-undrilled: #66768c;
  --lg-await: #2f8f8f;
  --side-w: 440px;                /* correlation side panel width (the toast stack keeps clear of it) */

  /* canvas palette (read by the renderer, the dashboard, the legend and the 3D view) */
  --c-paper: #ffffff;
  --c-ink: #0e1a2b;
  --c-ink2: #435369;
  --c-ink3: #97a4b5;
  --c-grid: #e1e7ef;
  --c-grid-strong: #c3cedb;
  --c-grid-fine: #f0f3f7;
  --c-chrome: #e4eaf1;
  --c-chrome2: #eaeff5;
  --c-band: #c7e1fb;              /* legacy single band colour: no longer yellow */
  --c-band-ink: #0c2442;
  --c-band-drill: #cdeccf;        /* drilling well Victor-1 + its Updated / Original columns */
  --c-band-drill-ink: #0f2e14;
  --c-band-offset: #c7e1fb;       /* every offset well */
  --c-band-offset-ink: #0c2442;
  --c-well-drill: #d92d2d;
  --c-well-offset: #2f6fd0;
  --c-gr: #0f8a2c;
  --c-rop: #8e44ad;
  --c-a40: #2a78d6;
  --c-p34: #e0602b;
  --c-p16: #13a37a;
  --c-sand: #e9c84a;
  --c-shale: #5f6b5a;
  --c-sep-pos: #2a78d6;
  --c-sep-neg: #e0602b;
  --c-fm1: #5b6770;
  --c-mjn: #d43d3d;
  --c-mjnm: #4338ca;
  --c-mjnl: #c47f00;
  --c-other: #6b7280;
  --c-bit: #0e1a2b;
  --c-pick: #c42b2b;
  --c-cand: #b5179e;
  --c-truth: #0e1a2b;
  --c-undrilled: #b9c3cf;         /* neutral slate: everything below the bit */
  --c-await: #94cdc8;             /* teal: logged by the bit, not yet by the LWD sensors (a different hue) */
  --c-cross: #1f66e0;
  --c-label-bg: #ffffff;
  --c-unit-fm1: #a3abb4;
  --c-unit-u: #f0a9a9;
  --c-unit-m: #b3aee8;
  --c-unit-l: #efcf8f;
  --c-swob: #b26a00;
  --c-stor: #6d4ab3;
  --c-rpm: #2b8c8c;
  --c-mse: #8a3b3b;
  --c-off-a: #2563c9;             /* offsets: three blue-family hues (green now means "drilling well") */
  --c-off-b: #08809e;
  --c-off-c: #7048d8;
  --c-good: #0f7d3a;
  --c-warn: #9a5b00;
  --c-crit: #c42b2b;
  --c-accent: #1f66e0;
}

/* ================================================================ tokens: dark (default) */
/* Deep navy surfaces that echo the logo's frame (#042042), layered from page to raised card. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08111f;
  --bg-glow: rgba(90, 162, 255, 0.07);
  --surface: #0e1a2d;
  --surface-2: #13223a;
  --surface-3: #1a2c48;
  --line: #24395a;
  --line-strong: #5a7397;
  --text: #e6edf6;
  --text-2: #a9b8cc;
  --text-3: #8295b0;
  --accent: #5aa2ff;
  --accent-ink: #04122a;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --good: #3fcf83;
  --warn: #f5ad42;
  --warn-ink: #1c1200;
  --crit: #ff6b6b;
  --callout: #5aa2ff;
  --callout-soft: #12284a;
  --over: #3a2c12;
  --kpi-tint: #12284a;
  --shadow-1: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-pop: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 44px rgba(0, 0, 0, 0.55);
  --backdrop: rgba(2, 6, 14, 0.64);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5' fill='none' stroke='%23a9b8cc' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --accent-text: #5aa2ff;
  --lg-undrilled: #7d90ab;
  --lg-await: #3fb0ad;

  --c-paper: #0c1a2d;
  --c-ink: #e6edf6;
  --c-ink2: #a9b8cc;
  --c-ink3: #6b819f;
  --c-grid: #1b3050;
  --c-grid-strong: #2b4568;
  --c-grid-fine: #132540;
  --c-chrome: #0f1d32;
  --c-chrome2: #081221;
  --c-band: #a3c8f0;
  --c-band-ink: #0a1f3c;
  --c-band-drill: #a6dcae;
  --c-band-drill-ink: #0a2410;
  --c-band-offset: #a3c8f0;
  --c-band-offset-ink: #0a1f3c;
  --c-well-drill: #ff5c5c;
  --c-well-offset: #5b9dff;
  --c-gr: #3ccb6a;
  --c-rop: #b18cff;
  --c-a40: #4f9dff;
  --c-p34: #ff7f4d;
  --c-p16: #2fc9a1;
  --c-sand: #c9a531;
  --c-shale: #7f8f8a;
  --c-sep-pos: #4f9dff;
  --c-sep-neg: #ff7f4d;
  --c-fm1: #8aa0b6;
  --c-mjn: #f06a6a;
  --c-mjnm: #9d93ff;
  --c-mjnl: #e09a1f;
  --c-other: #9aa6b4;
  --c-bit: #f2f6fb;
  --c-pick: #ff6b6b;
  --c-cand: #ff5fd2;
  --c-truth: #f2f6fb;
  --c-undrilled: #2a3c56;
  --c-await: #1f4d55;
  --c-cross: #5aa2ff;
  --c-label-bg: #13223a;
  --c-unit-fm1: #3d4a5c;
  --c-unit-u: #7a3b45;
  --c-unit-m: #4b4685;
  --c-unit-l: #7a6224;
  --c-swob: #f5ad42;
  --c-stor: #a78bfa;
  --c-rpm: #4fd1c5;
  --c-mse: #f08080;
  --c-off-a: #6ea8ff;
  --c-off-b: #3fd0e6;
  --c-off-c: #b394ff;
  --c-good: #3fcf83;
  --c-warn: #f5ad42;
  --c-crit: #ff6b6b;
  --c-accent: #5aa2ff;
}

/* ================================================================ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1400px 520px at 12% -8%, var(--bg-glow), transparent 70%) no-repeat, var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button, select, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }
.mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
:where(button, select, input, a, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.side, .menu, .log, .pop-list, .modal-card, .overlay, .table-wrap { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.scroller { scrollbar-color: var(--line) var(--c-chrome2); }

.app {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* the console takes whatever height is left (it never forces a page scroll); the 3D view keeps a floor */
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: var(--sp-2);
  padding: var(--sp-2) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.app[data-view="viz3d"] { grid-template-rows: auto auto auto minmax(420px, 1fr); }
/* <main>: holds the two view panels (correlation console | 3D), one shown at a time */
.views { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); min-width: 0; min-height: 0; }

/* shared card look for the shell bars */
.topbar, .kpi, .toolbar, .viewtabs, .viewer, .callout, .tabs, .tabpanel {
  background: var(--surface);
  border: 1px solid var(--line);
}
.vdiv { flex: none; width: 1px; align-self: stretch; min-height: 24px; background: var(--line); }

/* ================================================================ top bar */
.topbar {
  display: flex; flex-direction: column; gap: 10px;
  border-radius: var(--r-lg); padding: 10px 14px; box-shadow: var(--shadow-1); min-width: 0;
}
.topbar-row { display: flex; align-items: center; gap: 8px 16px; min-width: 0; }
.topbar-main { flex-wrap: nowrap; }
.topbar-controls { flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line-soft); }

.brand { display: flex; align-items: center; gap: 12px; flex: none; min-width: 0; }
.brand-pic { display: block; flex: none; line-height: 0; }
.brand-logo {
  display: block; height: 44px; width: auto; border-radius: 6px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 12%, transparent), 0 2px 8px rgba(0, 0, 0, 0.22);
}
/* dark theme: a light frame (R01) so the logo's navy frame and charcoal strata stand clear of the navy header.
   A ring, not a border or padding, so the image keeps its size and aspect ratio. */
:root[data-theme="dark"] .brand-logo {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--text) 72%, transparent), 0 2px 8px rgba(0, 0, 0, 0.35);
}
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-name { font: 700 21px/1 var(--font-display); letter-spacing: 0.01em; color: var(--text); }
/* tagline (R02): two lines, small and bold, in the title colour (navy on light, near-white on dark) */
.brand-sub { font: 600 11.5px/1.15 var(--font-ui); color: var(--text); letter-spacing: 0.01em; }
.brand-sub > span { display: block; white-space: nowrap; }
.app-title {
  margin: 0; min-width: 0; flex: 0 1 auto;
  font: 600 25px/1.15 var(--font-display); letter-spacing: 0.005em; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }

.well-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 10px;
  border-radius: 999px; background: var(--surface-2); white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--c-band-drill) 50%, var(--line));
  font-weight: 600; font-size: 13px;
}
.well-chip .dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); }
.well-chip .dot.live { background: var(--crit); box-shadow: 0 0 0 3px color-mix(in srgb, var(--crit) 25%, transparent); animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--crit) 0%, transparent); } }

.demo-badge {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 32px; padding: 3px 10px; border-radius: var(--r); line-height: 1.15; white-space: nowrap; cursor: help;
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.demo-badge b { font: 700 11.5px var(--font-ui); letter-spacing: 0.14em; color: var(--accent-text); }
.demo-badge small { font: 400 10px var(--font-ui); color: var(--text-2); }

/* theme toggle: shows the theme you would switch TO (sun while dark, moon while light) */
#btnTheme svg { width: 16px; height: 16px; }
#btnTheme .ico-moon { display: none; }
:root[data-theme="light"] #btnTheme .ico-moon { display: block; }
:root[data-theme="light"] #btnTheme .ico-sun { display: none; }

/* right end of the controls row (R10 row 2): drilling-parameters disclosure + theme toggle.
   The disclosure only shows where the readouts row starts collapsed (see "drilling parameters" under responsive). */
.ctl-end { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
#btnReadouts { display: none; }
#btnReadouts svg { width: 12px; height: 12px; transform: rotate(-90deg); transition: transform 0.15s; }
#btnReadouts[aria-expanded="true"] svg { transform: none; }
#btnReadouts[aria-expanded="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, var(--line-strong)); }

/* ---------------- display controls: Display mode · Plot depth · Secondary readout */
.displayctl { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; min-width: 0; }
.ctl { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.ctl-label, .sel > span {
  font: 600 11px var(--font-ui); text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-2); white-space: nowrap;
}
.modeswitch {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
}
.mode-opt {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px 0 10px; border-radius: var(--r); cursor: pointer; user-select: none;
  font: 600 13.5px var(--font-ui); color: var(--text-2);
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.mode-opt:hover { color: var(--text); background: var(--surface-3); }
.mode-opt input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid currentColor; background: transparent;
}
.mode-opt input:checked { border-color: currentColor; background: radial-gradient(circle, currentColor 0 3px, transparent 3.6px); }
.mode-opt input:focus-visible { outline: none; }
.mode-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-opt:has(input:checked) { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22); }
.mode-opt small {
  font: 600 10px var(--font-data); letter-spacing: 0.02em; padding: 1px 5px; border-radius: 4px;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
/* on the selected (accent) pill a tint would lighten the blue behind the white light-theme text: outline it instead */
.mode-opt:has(input:checked) small { background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 45%, transparent); }

/* ---------------- selects (shared) */
.sel { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); min-width: 0; }
.sel select, .menu-row select {
  appearance: none; -webkit-appearance: none; height: 32px; max-width: 100%;
  padding: 0 28px 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface-2) var(--chev) no-repeat right 9px center / 10px 7px;
  color: var(--text); font: 500 13px var(--font-ui); cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.sel select:hover, .menu-row select:hover { border-color: color-mix(in srgb, var(--text-3) 60%, var(--line-strong)); }
.sel select:disabled { cursor: not-allowed; background-image: none; padding-right: 10px; border-style: dashed; color: var(--text-2); opacity: 1; }
select option { background: var(--surface-2); color: var(--text); }
.displayctl .sel select { min-width: 132px; }

/* ---------------- compact drilling-parameter readouts (own row; beside the display controls on very wide screens) */
.readouts {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 6px 16px;
  margin: 0; flex: 1 1 100%; min-width: 0; padding-top: 8px; border-top: 1px solid var(--line-soft);
}
.rogroup { display: flex; flex-wrap: wrap; gap: 4px 14px; padding-right: 16px; border-right: 1px solid var(--line-soft); }
.rogroup:last-child { border-right: 0; padding-right: 0; }
.ro { display: flex; flex-direction: column; gap: 1px; min-width: 66px; }
.ro.wide { min-width: 130px; }
.ro.narrow { min-width: 46px; }
.ro.prog { min-width: 150px; }
.ro dt { font: 500 9.5px var(--font-ui); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.ro dd { margin: 0; font: 600 14.5px/1.3 var(--font-data); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.ro dd small { font: 400 10px var(--font-ui); color: var(--text-3); margin-left: 3px; }
.ro .small-dd { font-size: 12.5px; }
.ro dd .spark { width: 52px; height: 15px; vertical-align: -2px; margin-left: 6px; }
.ro dd .delta { font: 500 10px var(--font-data); margin-left: 4px; color: var(--text-3); }
.ro dd .delta.up { color: var(--good); }
.ro dd .delta.down { color: var(--warn); }
.ro .sub { font: 400 10px var(--font-ui); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.ro .fmsw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
/* the readouts that carry the active depth reference (.is-ref) and the secondary readout (.is-sec); set by ui.js */
.ro.is-ref dt { color: var(--accent); }
.ro.is-ref dt::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-right: 4px; vertical-align: 1px; }
.ro.is-sec dt { color: var(--text-2); }
.progbar { position: relative; height: 6px; background: color-mix(in srgb, var(--line) 80%, transparent); border-radius: 4px; margin-top: 6px; overflow: visible; }
.progbar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; width: 0; }
.progbar b { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--text); left: 0; border-radius: 1px; }
.progends { display: flex; justify-content: space-between; font: 400 9px var(--font-ui); color: var(--text-3); margin-top: 2px; }

/* ================================================================ look-ahead KPI strip */
.lookahead { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-2); min-width: 0; }
.kpi {
  position: relative; min-width: 0; overflow: hidden; container-type: inline-size;
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 14px 10px 17px; border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  transition: background-color 0.25s, border-color 0.25s;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0;
  background: var(--line); transition: background-color 0.25s;
}
.kpi-k {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  font: 600 12.5px/1.2 var(--font-ui); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-k > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.kpi-sw { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--text-3); box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 16%, transparent); }
.kpi-v { display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; }
.kpi-num {
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
  font: 700 30px/1.08 var(--font-ui); font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.005em; color: var(--text);
}
.kpi-u { flex: none; font: 500 13px var(--font-ui); color: var(--text-2); }
.kpi-s { min-height: 1.3em; font: 400 11.5px/1.3 var(--font-ui); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* (narrow-card sizes: @container rules at the end of the file, so they cap every media-query size) */
/* Distance ahead: the highlighted card */
.kpi-dist { background: var(--kpi-tint); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.kpi-dist::before { background: var(--accent); }
.kpi-dist .kpi-k { color: var(--text); }
.kpi-dist .kpi-s { color: var(--text-2); }
/* states (ui.js toggles good | warn | crit | muted) */
.kpi.good::before { background: var(--good); }
.kpi.warn { background: color-mix(in srgb, var(--warn) 13%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.kpi.warn::before { background: var(--warn); }
.kpi.warn .kpi-num { color: var(--warn); }
.kpi.crit { background: color-mix(in srgb, var(--crit) 12%, var(--surface)); border-color: color-mix(in srgb, var(--crit) 55%, var(--line)); }
.kpi.crit::before { background: var(--crit); }
.kpi.crit .kpi-num { color: var(--crit); }
.kpi.muted .kpi-num, .kpi.muted .kpi-u { color: var(--text-3); }
.kpi.muted::before { background: var(--line); }

/* ================================================================ view tabs + toolbar */
.viewbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--sp-2); min-width: 0; }
.viewtabs { display: flex; gap: 2px; padding: 3px; border-color: var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-1); flex: none; }
.viewtab {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 0; border-radius: var(--r); background: transparent; color: var(--text-2); cursor: pointer; white-space: nowrap;
  font: 600 13.5px var(--font-ui); transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.viewtab svg { flex: none; width: 15px; height: 15px; fill: currentColor; }
.viewtab .vt-short { display: none; }   /* short label for narrower toolbars (see responsive) */
.viewtab:hover { color: var(--text); background: var(--surface-3); }
.viewtab[aria-selected="true"] {
  color: var(--text); background: color-mix(in srgb, var(--accent) 16%, var(--surface-2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}
.viewtab[aria-selected="true"] svg { color: var(--accent); }

.toolbar {
  flex: 1 1 620px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 5px 8px; border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.tgroup { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; min-width: 0; }
.tgroup.grow { flex: 1 1 200px; min-width: min-content; }   /* never narrower than slider + time label */
.tg-more { margin-left: auto; }
#scrubLabel { flex: none; min-width: 84px; text-align: right; color: var(--text-2); white-space: nowrap; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap;
  font: 500 13px/1 var(--font-ui);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-3); border-color: color-mix(in srgb, var(--text-3) 55%, var(--line-strong)); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn svg { flex: none; width: 14px; height: 14px; fill: currentColor; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--text)); border-color: color-mix(in srgb, var(--accent) 86%, var(--text)); }
.btn.primary:disabled:hover { background: var(--accent); border-color: var(--accent); }
.btn.icon { width: 32px; padding: 0; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.icon.small { width: 28px; padding: 0; font-size: 16px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { border-color: var(--crit); color: var(--crit); }
.btn[aria-pressed="true"]:not(.primary) { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, var(--line-strong)); color: var(--text); }
#btnPlay { min-width: 84px; }
.btn-group {
  display: inline-flex; align-items: stretch; height: 32px; overflow: hidden;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface-2);
}
.btn-group .btn { height: 30px; border: 0; border-radius: 0; background: transparent; }
.btn-group .btn:hover { background: var(--surface-3); }
.btn-group .btn:focus-visible { outline-offset: -2px; }
.scale { min-width: 64px; text-align: center; }
.btn-group .scale { display: flex; align-items: center; justify-content: center; padding: 0 6px; color: var(--text-2); border-inline: 1px solid var(--line-soft); }

/* checkboxes; in the toolbar they are pill toggles with a small switch */
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.chk input { accent-color: var(--accent); margin: 0; }
/* toolbar toggles: same 13 px text and corner radius as the buttons and selects beside them (.chk.pill beats
   the side panel's 11 px .pill); only the small switch inside stays round */
.chk.pill {
  height: 32px; padding: 0 12px 0 8px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface-2); white-space: nowrap;
  font-size: 13px;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.chk.pill:hover { background: var(--surface-3); color: var(--text); border-color: color-mix(in srgb, var(--text-3) 55%, var(--line-strong)); }
.chk.pill:has(input:checked) { color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, var(--line-strong)); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.chk.pill input {
  appearance: none; -webkit-appearance: none; flex: none; cursor: pointer;
  width: 28px; height: 16px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface-3) radial-gradient(circle at 7px 50%, var(--text-2) 0 4.5px, transparent 5px) no-repeat;
  transition: background-color 0.15s, border-color 0.15s;
}
.chk.pill input:checked { border-color: var(--accent); background: var(--accent) radial-gradient(circle at 19px 50%, var(--accent-ink) 0 4.5px, transparent 5px) no-repeat; }

/* scrubber with event / pick ticks */
.scrubwrap { position: relative; flex: 1 1 auto; min-width: 120px; height: 26px; display: flex; align-items: center; }
.cv-scrub { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scrubwrap input[type="range"] { position: relative; width: 100%; margin: 0; accent-color: var(--accent); background: transparent; cursor: pointer; }

/* ---------------- More menu */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 300px;
  /* opens below the toolbar, which ends at roughly 260-355 px; main.js may cap it exactly from where it opens */
  max-height: min(680px, max(220px, calc(100vh - 360px))); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 2px; padding: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
}
.menu > * { flex-shrink: 0; }   /* a capped menu scrolls its rows instead of squashing them */
.menu-title { font: 600 10.5px var(--font-ui); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin: 10px 6px 3px; }
.menu-title:first-child { margin-top: 2px; }
.menu-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 8px; padding: 4px 6px; border-radius: var(--r-sm); font-size: 13px; color: var(--text); }
.menu-row.chk { justify-content: flex-start; }
.menu-row.chk:hover { background: var(--surface-3); }
.menu-row select { height: 28px; font-size: 12.5px; background-color: var(--surface); }
.menu-row input[type="number"] { height: 28px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: 500 12.5px var(--font-data); }
#offsetToggles { justify-content: flex-start; gap: 4px 14px; }
#offsetToggles .chk { color: var(--text); }
.menu-btn { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px; color: var(--text); }
.menu-btn:hover { background: var(--surface-3); }
.menu-btn.file { position: relative; overflow: hidden; }
.menu-btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.menu-btn.file:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }

/* segmented buttons (Appearance, log filters) */
.seg, .logfilters { display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); }
.menu-row.seg { margin: 0 6px 4px; padding: 3px; }
.seg-btn {
  flex: 1; border: 0; background: transparent; color: var(--text-2); padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer;
  font: 500 12.5px var(--font-ui); transition: background-color 0.15s, color 0.15s;
}
.seg-btn:hover { color: var(--text); background: var(--surface-3); }
.seg-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ================================================================ correlation workspace */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w); gap: var(--sp-2); min-height: 0; min-width: 0; }
.app.side-collapsed .workspace { grid-template-columns: minmax(0, 1fr); }
.app.side-collapsed .side { display: none; }
.viewer {
  display: grid; grid-template-rows: auto minmax(0, 1fr) 64px auto; grid-template-columns: minmax(0, 1fr);
  min-width: 0; min-height: 0; background: var(--c-chrome); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1);
}
.viewer-body { display: grid; grid-template-columns: 46px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); min-height: 0; min-width: 0; position: relative; }
.cv-mini { display: block; width: 46px; height: 100%; border-right: 1px solid var(--line); background: var(--surface); cursor: pointer; touch-action: none; }
.scroller { overflow-x: auto; overflow-y: hidden; min-height: 0; position: relative; }
.cv-head, .cv-body { display: block; }
.cv-body { cursor: crosshair; touch-action: none; }
.cv-runway { display: block; width: 100%; height: 64px; border-top: 1px solid var(--line); background: var(--surface); cursor: crosshair; touch-action: none; }
.statusline {
  min-width: 0; min-height: 26px; padding: 4px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 11.5px; color: var(--text-2); background: var(--surface); border-top: 1px solid var(--line);
}
.statusline .kbd { margin-left: 0; margin-right: 3px; }

/* legend strip: well chips + layer toggles (built by ui.js) */
.legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 32px; padding: 4px 8px;
  background: var(--surface); border-bottom: 1px solid var(--line); font-size: 11px; color: var(--text-2);
}
.legend .lg-group { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.legend .lg-group + .lg-group { border-left: 1px solid var(--line-soft); padding-left: 12px; }
.lg {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px solid transparent; border-radius: 999px;
  background: transparent; cursor: pointer; font: 500 11px/1.4 var(--font-ui); color: var(--text-2);
  transition: background-color 0.15s, color 0.15s, opacity 0.15s;
}
button.lg:hover { background: var(--surface-3); color: var(--text); }
.lg[aria-pressed="false"] { opacity: 0.42; text-decoration: line-through; }
.lg .dash { display: inline-block; width: 22px; height: 0; border-top: 2px solid; }
.lg .dash.dotted { border-top-style: dotted; }
.lg .dash.dashed { border-top-style: dashed; }
.lg .sw { width: 11px; height: 9px; border-radius: 2px; border: 0; }
.lg .sw.sand { background: var(--c-sand); }
.lg .sw.shale { background: var(--c-shale); }
.lg .sw.sep { background: linear-gradient(90deg, var(--c-sep-pos), var(--c-sep-neg)); }
/* undrilled = slate "/" hatch, awaiting LWD = teal "\" hatch (the canvas uses the same hues and directions);
   both outlined so the chip edge shows on any surface */
.lg .sw.hatch, .lg .sw.await { width: 12px; height: 10px; border: 1px solid var(--line-strong); border-radius: 2px; }
.lg .sw.hatch { background: repeating-linear-gradient(135deg, var(--lg-undrilled) 0 1.5px, transparent 1.5px 4px); }
.lg .sw.await { background: repeating-linear-gradient(45deg, var(--lg-await) 0 1.5px, transparent 1.5px 4px); }
.lg .sw.band { background: color-mix(in srgb, var(--c-mjn) 30%, transparent); border: 1px solid var(--warn); }
.lg .sw.heat { background: linear-gradient(90deg, color-mix(in srgb, var(--c-rop) 10%, transparent), color-mix(in srgb, var(--c-rop) 70%, transparent)); }
.lg .sw.cand { background: var(--c-cand); }
.lg .sw.bit { background: var(--c-bit); }
.lg .sw.datum { background: var(--accent); }
.lg .sw.truth { background: repeating-linear-gradient(90deg, var(--c-truth) 0 2px, transparent 2px 4px); }
/* well chips: pastel band colour with its own dark ink (never white text on a light chip) */
.lg .wb {
  display: inline-block; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 4px; text-align: center;
  background: var(--c-band-offset); color: var(--c-band-offset-ink); font: 700 9.5px/16px var(--font-ui);
}
.lg.drill .wb { background: var(--c-band-drill); color: var(--c-band-drill-ink); }

/* hover inspector */
.tip {
  position: absolute; z-index: 20; pointer-events: none; min-width: 170px; max-width: 270px; padding: 7px 9px;
  font-size: 11px; line-height: 1.4; color: var(--text);
  background: color-mix(in srgb, var(--surface-2) 94%, transparent); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-pop);
}
.tip .tip-h { font-family: var(--font-ui); font-weight: 600; font-size: 12px; margin-bottom: 3px; display: flex; justify-content: space-between; gap: 8px; }
.tip .tip-h small { font-weight: 400; color: var(--text-2); }
.tip .row { display: flex; justify-content: space-between; gap: 10px; }
.tip .row .k { color: var(--text-2); }
.tip .chip { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.tip .sep { border-top: 1px solid var(--line); margin: 4px 0; }

/* first-run card over the correlation view */
.firstrun { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.firstrun-card {
  pointer-events: auto; width: min(440px, 90%); display: flex; flex-direction: column; gap: 10px; padding: 16px 18px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop);
  animation: pop-in 0.22s ease-out;
}
.firstrun-card .eyebrow { color: var(--accent); }
.firstrun-text { font-size: 13.5px; line-height: 1.5; }
.firstrun-text b { font-family: var(--font-data); font-weight: 600; }
.kbd {
  display: inline-block; margin-left: 4px; padding: 0 5px; vertical-align: 1px;
  font: 500 10px/1.5 var(--font-data); color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
}
.btn .kbd { margin-left: 0; }
.btn.primary .kbd { color: inherit; background: transparent; border-color: color-mix(in srgb, var(--accent-ink) 40%, transparent); }

/* ================================================================ 3D view (fills the same area as the workspace) */
/* viz3d.js draws its own framed panel (.v3-wrap, absolutely filling #viz3dRoot); the section only sizes it. */
.view3d { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.viz3d-root { position: relative; flex: 1 1 auto; width: 100%; min-width: 0; min-height: 0; }
#view3d .v3-wrap { border-radius: var(--r-lg); box-shadow: var(--shadow-1); }   /* same corners / elevation as the console panels */
/* toolbar groups that only make sense for the console */
#app[data-view="viz3d"] .console-only { display: none; }

/* ================================================================ side panel */
.side { display: flex; flex-direction: column; gap: var(--sp-2); min-height: 0; min-width: 0; overflow-y: auto; }
/* children keep their natural height and the panel scrolls (a shrinking callout collapses to its header) */
.side > * { flex-shrink: 0; }
.callout {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px 12px 17px; border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.callout::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--callout); }
.callout-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.eyebrow { font: 600 10.5px var(--font-ui); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-2); }
.eyebrow .rank { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--line); border-radius: 999px; font-size: 9.5px; letter-spacing: 0.04em; color: var(--text-3); text-transform: none; }
.callout-name { font: 700 26px/1.1 var(--font-display); letter-spacing: 0.01em; }
.callout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.callout-grid > div { display: flex; flex-direction: column; min-width: 0; }
.callout-grid .v small { display: block; font: 400 10px var(--font-ui); color: var(--text-3); letter-spacing: 0; }
.k { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.v { font-size: 14px; font-weight: 500; }
.pill { font-size: 11px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.pill.high { border-color: color-mix(in srgb, var(--good) 60%, var(--line)); color: var(--good); }
.pill.medium { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); color: var(--warn); }
.pill.low { border-color: color-mix(in srgb, var(--crit) 60%, var(--line)); color: var(--crit); }
.pill .micro { display: inline-block; width: 36px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--line) 70%, transparent); margin-right: 6px; vertical-align: 1px; overflow: hidden; }
.pill .micro b { display: block; height: 100%; background: currentColor; border-radius: 3px; }
table.eta { width: 100%; border-collapse: collapse; font-size: 11.5px; }
table.eta th { font: 600 10px var(--font-ui); color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; text-align: right; padding: 3px 4px; }
table.eta th:first-child { text-align: left; }
table.eta td { text-align: right; padding: 3px 4px; border-top: 1px solid var(--line-soft); line-height: 1.15; }
table.eta td small { display: block; color: var(--text-3); font-size: 10px; }
table.eta td.p50 { font-weight: 600; }
table.eta td.warn { color: var(--warn); }
table.eta .crit { color: var(--crit); font-weight: 600; }
table.eta caption { caption-side: bottom; text-align: left; font: 400 10px var(--font-ui); color: var(--text-3); padding: 3px 4px 0; }
.trust { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.tchip { min-width: 0; padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 10px; line-height: 1.2; background: var(--surface-2); }
.tchip b { display: block; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tchip.strong { border-color: color-mix(in srgb, var(--good) 60%, var(--line)); color: var(--good); }
.tchip.fair { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); color: var(--warn); }
.tchip.weak { border-color: color-mix(in srgb, var(--crit) 60%, var(--line)); color: var(--crit); }
.tchip.na { color: var(--text-3); }
.sig { height: 150px; }
.cv-sig { width: 100%; height: 150px; display: block; }
.approach { height: 30px; }
.cv-approach { width: 100%; height: 30px; display: block; }
.det-row { height: 46px; }
.cv-det { width: 100%; height: 46px; display: block; }
.callout-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.alerts { display: flex; flex-direction: column; gap: 4px; }
.alert {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 6px; align-items: center; padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--warn) 60%, var(--line)); border-left: 4px solid var(--warn); border-radius: var(--r-sm);
  background: var(--over); font-size: 11.5px;
}
.alert svg { width: 12px; height: 12px; fill: var(--warn); }
.alert .acts { display: flex; gap: 3px; }
.alert .acts button { border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 5px; padding: 1px 7px; font-size: 10.5px; cursor: pointer; }
.alert .acts button:hover { border-color: var(--text-3); }
.attention {
  text-align: left; border: 1px solid var(--warn); background: var(--over); color: var(--text);
  border-radius: var(--r-sm); padding: 5px 8px; font-size: 12px; cursor: pointer;
}
.endcard { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.endcard .big { font: 600 22px var(--font-data); }
.endcard .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }

/* tabs + panels (one card: the tab bar sits on the panel) */
.tabs {
  display: flex; gap: 2px; padding: 2px 6px 0; margin-bottom: calc(-1 * var(--sp-2));
  border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom-color: var(--line-soft);
}
.tab {
  position: relative; border: 0; background: transparent; padding: 9px 12px 10px; cursor: pointer;
  color: var(--text-2); font: 600 13px var(--font-ui); border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: color 0.15s, background-color 0.15s;
}
.tab:hover { color: var(--text); background: var(--surface-3); }
.tab[aria-selected="true"] { color: var(--text); background: transparent; }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tab .badge { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 999px; background: var(--warn); color: var(--warn-ink); font-size: 10px; font-weight: 700; margin-left: 6px; line-height: 15px; text-align: center; }
.tabpanel { border-top: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); padding: 10px; min-width: 0; box-shadow: var(--shadow-1); }

/* tops table */
.table-wrap { overflow-x: auto; }
table.tops { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tops th {
  position: sticky; top: 0; z-index: 1; text-align: left; vertical-align: bottom; padding: 5px 6px; white-space: nowrap;
  font: 600 10.5px var(--font-ui); color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
table.tops th .th-u { display: block; font: 500 9.5px var(--font-data); color: var(--text-3); text-transform: none; letter-spacing: 0; }
/* Original / Updated belong to the drilling well: the same light-green key as its column headers */
#topsHead th:nth-child(2), #topsHead th:nth-child(3) { box-shadow: inset 0 -2px 0 var(--c-band-drill); }
table.tops td { padding: 4px 6px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.tops td:first-child { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
table.tops .num { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
table.tops tr { cursor: pointer; }
table.tops tbody tr:hover td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
table.tops tr.minor td:first-child { padding-left: 24px; color: var(--text-2); }
table.tops tr.above td { color: var(--text-3); }
table.tops tr.group td { font: 600 11px var(--font-ui); color: var(--text-2); background: var(--surface); padding: 6px 6px 3px; cursor: default; letter-spacing: 0.02em; }
table.tops tr.group td .pred { font-style: italic; font-weight: 400; }
table.tops tr.group.above-toggle td { cursor: pointer; color: var(--text-3); }
table.tops .chev { width: 11px; height: 11px; fill: currentColor; vertical-align: -1px; margin-right: 4px; transform: rotate(-90deg); transition: transform 0.12s; }
table.tops .chev.open { transform: rotate(0); }
table.tops .usw { display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
table.tops .rng { width: 96px; padding: 1px 4px; }
table.tops .rng svg { display: block; width: 92px; height: 12px; }
table.tops tr[data-top] td:first-child { box-shadow: inset 4px 0 0 transparent; }
table.tops tr.next td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
table.tops tr.next td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
table.tops tr.over td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
table.tops tr.over td { background: color-mix(in srgb, var(--warn) 13%, transparent); }
table.tops tr.early td:first-child { box-shadow: inset 4px 0 0 var(--c-sep-pos); }
table.tops tr.deep td:first-child { box-shadow: inset 4px 0 0 var(--c-sep-neg); }
table.tops tr.sel td { outline: 1px solid var(--accent); outline-offset: -1px; }
table.tops tr.now td { border-top: 1px solid var(--accent); }
table.tops tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.tops td.muted { color: var(--text-3); }
table.tops td.dc { position: relative; }
table.tops td.dc i { position: absolute; right: 4px; top: 50%; height: 3px; transform: translateY(-50%); background: currentColor; opacity: 0.25; border-radius: 2px; max-width: calc(100% - 8px); }
table.tops td.dc span { position: relative; }
table.tops td.dc.pred { color: var(--text-3); font-style: italic; }
table.tops td.dc.d0 { color: var(--text-2); }
table.tops td.dc.d1 { color: var(--text); }
table.tops td.dc.d2 { color: var(--warn); }
table.tops td.dc.d3 { color: var(--crit); }
/* on the tinted next / overdue rows the muted grey falls under 4.5:1 (light theme): use the secondary text colour */
table.tops tr.next td.muted, table.tops tr.next td.dc.pred, table.tops tr.next .st,
table.tops tr.over td.muted, table.tops tr.over td.dc.pred { color: var(--text-2); }
.mk { display: inline-block; width: 18px; height: 0; border-top: 3px solid; vertical-align: middle; margin-right: 6px; }
.mk.minor { border-top-width: 2px; border-top-style: dotted; }
.st { font-size: 10px; margin-left: 5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 2px; vertical-align: 0; }
.st svg { width: 10px; height: 10px; fill: currentColor; }
.st.ok { color: var(--good); }
.st.ok .mono { color: var(--text-3); margin-left: 2px; }
.st.warn { color: var(--warn); }
.note { font-size: 11.5px; line-height: 1.5; color: var(--text-2); margin: 10px 2px 2px; }
.note kbd, .modal-body kbd {
  font: 500 10.5px var(--font-data); padding: 0 5px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
}
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; border: 1px solid var(--line); }
.sw.next { background: color-mix(in srgb, var(--accent) 25%, transparent); border-left: 3px solid var(--accent); }
.sw.over { background: color-mix(in srgb, var(--warn) 25%, transparent); border-left: 3px solid var(--warn); }
.sw.early { border-left: 3px solid var(--c-sep-pos); }
.sw.deep { border-left: 3px solid var(--c-sep-neg); }

/* engine / verify */
.eng h4 { margin: 6px 0 8px; font: 600 15px var(--font-display); }
.eng table { width: 100%; border-collapse: collapse; font-size: 12px; }
.eng td { padding: 4px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.eng .bar { height: 6px; background: var(--accent); border-radius: 3px; min-width: 2px; }
.eng .muted { color: var(--text-2); font-size: 11.5px; }

/* dashboard (dashboard.js injects its own rules on top; cards stay on --surface-2, its halos assume that) */
.dash { display: flex; flex-direction: column; gap: 8px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.tile { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.tile.good { border-left: 3px solid var(--good); }
.tile.warn { border-left: 3px solid var(--warn); }
.tile-k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-2); }
.tile-v { font-size: 19px; font-weight: 600; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-s { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-bar { height: 4px; background: color-mix(in srgb, var(--line) 60%, transparent); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.tile-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.card { padding: 9px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.card header { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.card h4 { margin: 0; font: 600 14px var(--font-display); letter-spacing: 0.01em; }
.card .hint { font-size: 10.5px; color: var(--text-3); }
.chart { display: block; width: 100%; }
.wlist { display: flex; flex-direction: column; gap: 5px; }
.wrow { display: grid; grid-template-columns: 64px 1fr 40px; gap: 6px; align-items: center; font-size: 12px; }
.wname { font-weight: 600; }
.wbar { height: 8px; background: color-mix(in srgb, var(--line) 60%, transparent); border-radius: 4px; overflow: hidden; }
.wbar i { display: block; height: 100%; border-radius: 4px; }
.wval { text-align: right; }
.wsub { grid-column: 2 / 4; font-size: 10.5px; color: var(--text-3); margin-top: -4px; }

/* log */
.logfilters { margin-bottom: 8px; }
.log { list-style: none; margin: 0; padding: 0 0 0 4px; font-size: 12px; display: flex; flex-direction: column; max-height: 460px; overflow-y: auto; position: relative; }
.log li { display: grid; grid-template-columns: 70px 14px 1fr; gap: 6px; align-items: start; padding: 3px 0; }
.log li[data-md] { cursor: pointer; border-radius: var(--r-sm); }
.log li[data-md]:hover { background: var(--surface-3); }
.log li.flash { background: var(--accent-soft); }
.log .when { font-family: var(--font-data); color: var(--text-2); font-size: 11px; line-height: 1.2; }
.log .when small { display: block; color: var(--text-3); }
.log .chip { width: 10px; height: 10px; border-radius: 50%; margin-top: 3px; position: relative; }
.log .chip::after { content: ""; position: absolute; left: 4px; top: 12px; width: 2px; height: 16px; background: var(--line); }
.log li:last-child .chip::after { display: none; }
.log .pick { color: var(--crit); font-weight: 600; }
.log .txt small { display: block; color: var(--text-3); font-size: 10.5px; }

/* ================================================================ popover, modal, toasts, overlay */
.popover {
  position: fixed; z-index: 40; width: 280px; padding: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  animation: pop-in 0.14s ease-out;
}
.pop-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; margin: 0 0 6px 4px; }
.pop-list { display: flex; flex-direction: column; gap: 2px; max-height: 300px; overflow-y: auto; }
.pop-item { display: flex; justify-content: space-between; gap: 8px; border: 0; background: transparent; text-align: left; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px; }
.pop-item:hover, .pop-item:focus-visible { background: var(--surface-3); }
.pop-item .d { color: var(--text-3); font-family: var(--font-data); font-size: 11.5px; }
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--backdrop); backdrop-filter: blur(3px); }
.modal-card {
  max-width: min(960px, 100%); max-height: 90vh; overflow: auto; padding: 14px 18px 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop);
  animation: pop-in 0.18s ease-out;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font: 600 18px var(--font-display); margin-bottom: 8px; }
.modal-body { font-size: 13.5px; line-height: 1.55; }
.modal-body img { max-width: 100%; display: block; border-radius: var(--r); }
.toasts {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: flex; flex-direction: column; gap: 8px; width: 320px; max-width: calc(100vw - 32px); pointer-events: none;
}
/* Desktop: the stack sits over the bottom-right of the correlation canvas, clear of the side panel's tabs and
   pick buttons (app padding 12 + panel + gap 8 + 12 inside the canvas edge); in the 3D view the same offset keeps
   it between the scene legend and the layers panel. Back in the corner when the console's side panel is hidden. */
@media (min-width: 1101px) {
  .toasts { right: calc(var(--side-w) + 32px); }
  body:has(#app.side-collapsed[data-view="console"]) .toasts { right: 16px; }
}
/* toast bodies are click-through (whatever sits underneath keeps working); only their buttons take clicks */
.toast {
  display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; align-items: center; pointer-events: none;
  padding: 9px 12px; font-size: 12.5px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  animation: toast-in 0.2s ease-out;
}
.toast svg { width: 14px; height: 14px; fill: var(--text-2); }
.toast.pick svg { fill: var(--accent); }
.toast.auto svg { fill: var(--c-cand); }
.toast.warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.toast.warn svg { fill: var(--warn); }
.toast button, .toast a { pointer-events: auto; }
.toast .undo { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm); padding: 3px 9px; font-size: 11.5px; cursor: pointer; font-weight: 600; }
.toast .undo svg { width: 12px; height: 12px; fill: currentColor; }
.toast .undo:hover { border-color: var(--accent); color: var(--accent); }
.overlay {
  position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column; gap: 10px; overflow: auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg);
}
.overlay-head { display: flex; align-items: center; gap: 12px; }
.overlay-title { font: 600 19px var(--font-display); }
.overlay-sub { flex: 1; font-size: 12px; color: var(--text-2); }
.dash.wide { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 12px; align-content: start; }
.dash.wide .tiles { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(0.985); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ================================================================ responsive */
@media (min-width: 2000px) {
  :root { --side-w: 480px; }
  .app { gap: 10px; padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
  .kpi-num { font-size: 32px; }
}
@media (min-width: 2200px) {
  /* basis 0: the readouts take the space left between the display controls and the theme toggle */
  .readouts { flex: 1 1 0; justify-content: flex-end; margin-left: auto; padding-top: 0; border-top: 0; }
  .ctl-end { order: 3; margin-left: 0; }   /* theme toggle stays at the right end, after the readouts */
}
@media (max-width: 1600px) {
  :root { --side-w: 404px; }
  .readouts { gap: 4px 12px; }
  .rogroup { gap: 2px 12px; padding-right: 12px; }
  .ro { min-width: 60px; }
  .ro.wide { min-width: 120px; }
  .ro.prog { min-width: 130px; }
  .ro .sub { max-width: 170px; }
}
/* an opened readouts row stays on one line from 1181 px up (Inc and MD/TVD also sit in the Victor-1 track header) */
@media (max-width: 1480px) {
  .ro.hole { display: none; }
  .ro dd .spark { display: none; }
}
@media (max-width: 1320px) {
  .ro.narrow { display: none; }
  .ro.prog, .ro.wide { min-width: 110px; }
}
@media (max-width: 1400px) {
  .app-title { font-size: 22px; }
  .brand-name { font-size: 18px; }   /* the h1 stays the most prominent heading (R10) */
}
/* view tabs + toolbar on one 44 px line from about 1180 px up: hide the Speed label and narrow the scrubber,
   then the short console label, the icon-only More button and tighter gaps */
@media (max-width: 1519px) {
  .tg-play .sel > span { display: none; }   /* "Speed": the select keeps its aria-label */
  .scrubwrap { min-width: 100px; }
  .tgroup.grow { flex: 1 1 150px; }
  #scrubLabel { min-width: 0; }
  .toolbar { column-gap: 10px; }
}
@media (max-width: 1439px) {
  /* "Correlation console" -> "Console" and "More" -> its ··· icon on screen; the full names stay the
     accessible names (visually hidden text) and tooltips */
  .viewtab { padding: 0 10px; }
  .viewtab .vt-long, .tg-more .btn-label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .viewtab .vt-short { display: inline; }
  #btnMenu { width: 32px; padding: 0; }
  .toolbar { column-gap: 8px; padding-inline: 6px; }
  .tgroup { gap: 4px; }
  .scrubwrap { min-width: 64px; }
  #scrubLabel { font-size: 11px; }
  #btnPlay { min-width: 76px; }
  .chk.pill { padding: 0 10px 0 6px; gap: 6px; }
}
@media (max-width: 1279px) {
  .viewtab { padding: 0 8px; gap: 6px; }
  .toolbar { column-gap: 6px; }
  #btnSide { padding: 0 10px; }
}
/* drilling parameters: on laptop-width and short screens the readouts row starts collapsed behind the
   "Drilling parameters" disclosure in the controls row (every ro* element stays in the DOM and keeps updating) */
@media (max-width: 1599px), (max-height: 920px) and (max-width: 2199px) {
  #btnReadouts { display: inline-flex; }
  .topbar:not(:has(#btnReadouts[aria-expanded="true"])) .readouts { display: none; }
}
/* short laptop screens: keep the canvas tall */
@media (max-height: 820px) and (min-width: 1101px) {
  .app { gap: 4px; padding-block: 4px; }
  .topbar { gap: 6px; padding: 6px 12px; }
  .topbar-controls { padding-top: 6px; }
  .brand-logo { height: 38px; }
  .brand-name { font-size: 17px; }
  .brand-sub { font-size: 11px; }
  .app-title { font-size: 21px; }
  .kpi { padding: 5px 12px 5px 15px; gap: 0; }
  .kpi::before { top: 6px; bottom: 6px; }
  .lookahead .kpi-num { font-size: 24px; }   /* R12 minimum; beats the card-width steps below */
  .kpi-s { font-size: 11px; }
}
@media (max-width: 1100px) {
  .app, .app[data-view="viz3d"] { height: auto; min-height: 100%; grid-template-rows: auto auto auto auto; }
  .views { grid-template-rows: auto; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .viewer { height: 74vh; min-height: 520px; }
  .view3d { height: 74vh; min-height: 520px; }
  .side { overflow: visible; }
  .lookahead { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kpi-bit, .kpi-next, .kpi-dist { grid-column: span 2; }
  .kpi-range, .kpi-delta { grid-column: span 3; }
}
@media (max-width: 1024px) {
  .topbar-main { flex-wrap: wrap; row-gap: 6px; }
  .topbar-main > .vdiv { display: none; }
  .topbar-end { order: 2; }
  .app-title { order: 3; flex-basis: 100%; font-size: 20px; }
  .brand-name { font-size: 17px; }
}
@media (max-width: 900px) {
  .viewer { grid-template-rows: auto minmax(0, 1fr) 40px auto; }
  .cv-runway { height: 40px; }
  .toasts { width: 260px; }
  .legend { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .legend::-webkit-scrollbar { display: none; }
  .lg, .lg-group { white-space: nowrap; flex-shrink: 0; }
  .legend .lg-group { flex-wrap: nowrap; }
  .viewtabs { flex: 1 1 100%; }
  .viewtab { flex: 1 1 0; }
}
@media (max-width: 760px) {
  .well-chip { display: none; }
  .displayctl > .vdiv { display: none; }
}
@media (max-width: 640px) {
  .app { padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .topbar { padding: 10px; gap: 8px; }
  .brand { flex: 1 1 auto; gap: 10px; }
  .brand-logo { height: 34px; }
  .brand-name { font-size: 16px; }
  .brand-sub { font-size: 10.5px; }
  .topbar-end { gap: 6px; }
  .demo-badge { padding: 2px 7px; min-height: 30px; }
  .demo-badge b { font-size: 10.5px; letter-spacing: 0.1em; }
  .app-title { font-size: 19px; }
  .displayctl { width: 100%; gap: 8px; }
  .ctl { width: 100%; flex-wrap: wrap; gap: 6px; }
  .modeswitch { flex: 1 1 100%; }
  .mode-opt { flex: 1 1 0; justify-content: center; }
  .displayctl .sel { flex: 1 1 140px; flex-direction: column; align-items: stretch; gap: 4px; }
  .displayctl .sel select { min-width: 0; width: 100%; }
  .lbl-x { display: none; }
  .readouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; flex: 1 1 100%; }
  .rogroup { display: contents; }
  .ro { min-width: 0; }
  .ro.hole, .ro.narrow { display: none; }
  .ro dd { font-size: 13.5px; }
  .ro dd .spark, .ro dd .delta { display: none; }
  .ro.wide, .ro.prog { grid-column: 1 / -1; }
  .ro.mech { grid-column: span 2; }
  .ro .sub { max-width: none; }
  .lookahead { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-bit, .kpi-next, .kpi-range, .kpi-delta { grid-column: auto; }
  .kpi-dist { grid-column: 1 / -1; }
  .kpi { padding: 8px 10px 8px 14px; }
  .toolbar { gap: 6px 8px; padding: 6px; }
  .tgroup { flex-wrap: wrap; }
  .tgroup.grow { flex-basis: 100%; order: 5; }
  .scale { min-width: 52px; }
  .menu { position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: auto; max-height: 75vh; }
  .callout-name { font-size: 21px; }
  .toasts { width: calc(100vw - 32px); right: 16px; }
  .viewer { height: 70vh; min-height: 460px; }
  .view3d { height: 70vh; min-height: 520px; }
  .firstrun-card { width: 94%; }
  .dash.wide { grid-template-columns: minmax(0, 1fr); }
}
/* KPI value size follows the card width (P10–P90 is the longest value: "1,472–1,492"). It never drops under
   R12's 24 px: on narrow (phone) cards the unit wraps under the number instead. */
@container (max-width: 236px) { .kpi-num { font-size: 26px; } }
@container (max-width: 196px) { .kpi-num { font-size: 24px; } .kpi-u { font-size: 12px; } .kpi-v { flex-wrap: wrap; gap: 0 4px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
