/* SNS-OS design system.
   World: structural steel. Charcoal shell, SNS red for action and selection,
   warm mill-paper ground, Archivo set wide for titles (after the SNS logotype),
   IBM Plex Mono only for codes: piece marks, sheet numbers, heat numbers. */

@font-face {
  font-family: 'Archivo';
  src: url('fonts/archivo-wdth-wght.woff2') format('woff2-variations'), url('fonts/archivo-wdth-wght.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face { font-family: 'IBM Plex Mono'; src: url('fonts/plex-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('fonts/plex-mono-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('fonts/plex-mono-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  color-scheme: light;
  --font-sans: 'Archivo', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Neutrals: warm steel grays */
  --ground: #f3f3ef;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --sunken: #ecece7;
  --hover: #f4f4f0;
  --line: #e3e3dd;
  --line-strong: #cdcdc5;
  --ink: #16181b;
  --ink-2: #474c52;
  --ink-3: #5f646b;
  --ink-inverse: #ffffff;

  /* Shell (header) */
  --shell: #16181b;
  --shell-2: #212429;
  --shell-3: #2c3036;
  --shell-line: #33373d;
  --shell-ink: #f3f3ef;
  --shell-ink-2: #a9aeb5;

  /* Rail: the second neutral layer */
  --rail: #ebebe6;
  --rail-hover: #e1e1db;
  --rail-ink: #2a2d31;

  /* SNS red */
  --red: #bc111c;
  --red-hover: #a20f18;
  --red-press: #880c14;
  --red-tint: #fbebeb;
  --red-tint-2: #f6d9da;
  --red-ink: #9e0e18;

  --focus: #2b6fd6;

  /* Status (fixed, never themed): mark colors + pill pairs */
  --good: #0ca30c;      --good-bg: #e5f3e5;    --good-ink: #146614;
  --warn: #fab219;      --warn-bg: #fdf2d8;    --warn-ink: #7a5000;
  --serious: #ec835a;   --serious-bg: #fce9e0; --serious-ink: #973a12;
  --crit: #d03b3b;      --crit-bg: #fbe6e6;    --crit-ink: #a11e1e;
  --info-bg: #e8f0fb;   --info-ink: #1d559e;
  --neutral-bg: #ececE7; --neutral-ink: #4a4f55;

  /* Categorical series (validated order) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;

  /* Ordinal steel-progress ramp (one hue, light to dark) */
  --p0: #e6e6e1; --p1: #b7d3f6; --p2: #86b6ef; --p3: #5598e7; --p4: #2a78d6; --p5: #1c5cab; --p6: #104281;

  /* Erection map classes: neutral + five steps of one blue ramp (ordinal) */
  --m0: #e4e4de; --m1: #86b6ef; --m2: #3987e5; --m3: #256abf; --m4: #184f95; --m5: #0d366b;
  --m-ink-light: #16181b; --m-ink-dark: #ffffff;

  /* Chart chrome */
  --grid: #e7e6e0;
  --axis: #c3c2b7;
  --chart-ink: #6b6a65;

  --r-xs: 3px; --r-sm: 5px; --r: 7px; --r-lg: 10px; --r-xl: 14px;
  --shadow-1: 0 1px 2px rgba(20, 22, 25, .06), 0 1px 1px rgba(20, 22, 25, .03);
  --shadow-2: 0 4px 12px -2px rgba(20, 22, 25, .10), 0 2px 4px rgba(20, 22, 25, .05);
  --shadow-pop: 0 18px 40px -12px rgba(20, 22, 25, .32), 0 4px 10px rgba(20, 22, 25, .08);

  --t-2xs: 11px; --t-xs: 11.5px; --t-sm: 12.5px; --t-base: 14px; --t-md: 15px; --t-lg: 17px;
  --t-xl: 20px; --t-2xl: 25px; --t-3xl: 32px; --t-4xl: 44px;

  --hdr-h: 56px;
  --rail-w: 244px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

:root[data-theme="dark"], .theme-dark {
  color-scheme: dark;
  --ground: #0f1012;
  --surface: #17191c;
  --surface-2: #1b1d21;
  --sunken: #111315;
  --hover: #202328;
  --line: #2a2d32;
  --line-strong: #3a3e44;
  --ink: #f1f1ed;
  --ink-2: #c3c5c8;
  --ink-3: #9a9ea4;
  --rail: #131417;
  --rail-hover: #1d1f23;
  --rail-ink: #dcdcd8;
  --red: #d8222d;
  --red-hover: #e33a44;
  --red-press: #b81822;
  --red-tint: #3a1316;
  --red-tint-2: #4a171b;
  --red-ink: #ff8a90;
  --good-bg: #12301a; --good-ink: #7fd98a;
  --warn-bg: #3a2c0a; --warn-ink: #f6c65a;
  --serious-bg: #3b2015; --serious-ink: #f3a383;
  --crit-bg: #3d1517; --crit-ink: #f08a8a;
  --info-bg: #13253d; --info-ink: #8ab8f2;
  --neutral-bg: #24272b; --neutral-ink: #c3c5c8;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --p0: #26292d; --p1: #184f95; --p2: #1c5cab; --p3: #256abf; --p4: #2a78d6; --p5: #5598e7; --p6: #9ec5f4;
  --m0: #2a2d31; --m1: #1c5cab; --m2: #2a78d6; --m3: #5598e7; --m4: #86b6ef; --m5: #cde2fb;
  --m-ink-light: #f1f1ed; --m-ink-dark: #0f1012;
  --grid: #26282b;
  --axis: #383835;
  --chart-ink: #9a9993;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 6px 16px -4px rgba(0, 0, 0, .5);
  --shadow-pop: 0 24px 48px -12px rgba(0, 0, 0, .7), 0 4px 10px rgba(0, 0, 0, .4);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
  font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--red);
}
::selection { background: var(--red-tint-2); color: var(--ink); }
h1, h2, h3, h4, p, ul, ol, figure, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
a.link, .link { color: var(--red-ink); text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; }
a.link:hover, .link:hover { text-decoration-color: currentColor; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
img, svg { display: block; }
.ico { flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
:where(.mono, code):not(text, tspan) { font-family: var(--font-mono); font-size: .92em; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.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; }
.wide { font-variation-settings: 'wdth' 118; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: var(--r); box-shadow: var(--shadow-pop); }
.skip-link:focus { top: 12px; }

/* ---------- App frame ---------- */
.app { min-height: 100vh; display: grid; grid-template-rows: var(--hdr-h) 1fr; grid-template-columns: var(--rail-w) minmax(0, 1fr); grid-template-areas: 'hdr hdr' 'rail main'; }
.app.rail-collapsed { --rail-w: 64px; }
.app.no-rail { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'hdr' 'main'; }
.app.no-rail .rail { display: none; }

/* Header */
.hdr {
  grid-area: hdr; position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 6px;
  height: var(--hdr-h); padding: 0 12px 0 10px;
  background: var(--shell); color: var(--shell-ink);
  border-bottom: 1px solid #000;
}
.hdr-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 2px; border-radius: var(--r); flex-shrink: 0; }
.hdr-brand:hover { background: var(--shell-2); }
.hdr-logo { width: 74px; height: 34px; background: #fff; border-radius: 5px; display: grid; place-items: center; overflow: hidden; }
.hdr-logo img { width: 70px; height: 30px; object-fit: contain; }
.hdr-wordmark { display: flex; flex-direction: column; line-height: 1.05; }
.hdr-wordmark b { font-size: 15px; font-weight: 800; font-variation-settings: 'wdth' 120; letter-spacing: .01em; }
.hdr-wordmark small { font-size: 11px; color: var(--shell-ink-2); letter-spacing: .02em; }
.hdr-sep { width: 1px; height: 28px; background: var(--shell-line); margin: 0 6px; flex-shrink: 0; }
.ctx-btn {
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px 0 12px;
  border-radius: var(--r); color: var(--shell-ink); text-align: left; min-width: 0; max-width: 340px;
  border: 1px solid transparent;
}
.ctx-btn:hover, .ctx-btn[aria-expanded="true"] { background: var(--shell-2); border-color: var(--shell-line); }
.ctx-btn .ctx-lines { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ctx-btn small { font-size: 11px; color: var(--shell-ink-2); letter-spacing: .02em; }
.ctx-btn strong { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-btn .ico { color: var(--shell-ink-2); }
.hdr-spacer { flex: 1; }
.hdr-search {
  display: flex; align-items: center; gap: 8px; height: 36px; width: min(360px, 30vw); padding: 0 10px;
  background: var(--shell-2); border: 1px solid var(--shell-line); border-radius: var(--r); color: var(--shell-ink-2); font-size: 13px;
}
.hdr-search:hover { border-color: #4a4f56; color: var(--shell-ink); }
.hdr-search .hs-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; border: 1px solid color-mix(in srgb, currentColor 55%, transparent); }
.hdr-icon-btn { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--r); color: var(--shell-ink-2); }
.hdr-icon-btn:hover, .hdr-icon-btn[aria-expanded="true"] { background: var(--shell-2); color: var(--shell-ink); }
.hdr-icon-btn .dot-count { position: absolute; top: 5px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--shell); pointer-events: none; }
.live-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px 0 9px; border-radius: 15px;
  border: 1px solid var(--shell-line); color: var(--shell-ink); font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.live-pill:hover { background: var(--shell-2); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #6c7178; position: relative; }
.live-pill[aria-pressed="true"] .live-dot { background: #2fd05a; }
.live-pill[aria-pressed="true"] .live-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid #2fd05a; animation: ping 1.8s var(--ease-out) infinite; }
@keyframes ping { from { transform: scale(.4); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
.sample-chip.local { background: #1d2b3a; color: #9cc4f0; }
.logo-badge { display: grid; place-items: center; width: 100%; height: 100%; padding: 0 6px; background: var(--red); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: 0; font-variation-settings: 'wdth' 84; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: inherit; }
.hdr-logo:has(.logo-badge) { background: none; }
.sample-chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; background: #3a2c0a; color: #f6c65a; font-size: 11.5px; font-weight: 600; }
.avatar-btn { margin-left: 4px; }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: 11.5px; font-weight: 700; color: #fff; background: #5b6168; flex-shrink: 0; letter-spacing: .02em; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -6px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* Rail */
.rail {
  grid-area: rail; position: sticky; top: var(--hdr-h); height: calc(100vh - var(--hdr-h)); overflow-y: auto; overflow-x: hidden;
  background: var(--rail); border-right: 1px solid var(--line); padding: 12px 10px 20px; color: var(--rail-ink);
  display: flex; flex-direction: column; gap: 2px;
}
.rail > * { flex-shrink: 0; }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; gap: 8px; }
.rail-head strong { font-size: 12.5px; font-weight: 700; min-width: 0; }
.rail-head small { display: block; font-size: 11px; color: var(--ink-3); font-weight: 500; }
.rail-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 14px 10px 6px; }
.rail-link {
  display: flex; align-items: center; gap: 11px; height: 34px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; color: var(--rail-ink); white-space: nowrap;
}
.rail-link .ico { color: var(--ink-3); }
.rail-link:hover { background: var(--rail-hover); }
.rail-link.is-active { background: var(--surface); color: var(--red-ink); font-weight: 650; box-shadow: var(--shadow-1); }
.rail-link.is-active .ico { color: var(--red); }
.rail-link .rail-count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rail-link.is-active .rail-count { color: var(--red-ink); }
.rail-foot { margin-top: auto; padding-top: 16px; }
.rail-more { display: none; }
.app.rail-collapsed .rail-link span, .app.rail-collapsed .rail-label, .app.rail-collapsed .rail-head > div, .app.rail-collapsed .rail-count { display: none; }
.app.rail-collapsed .rail-link { justify-content: center; padding: 0; }
.app.rail-collapsed .rail-head { justify-content: center; }

/* Main */
.main { grid-area: main; min-width: 0; outline: none; }
.page { padding: 22px 28px 48px; max-width: 1680px; margin: 0 auto; }
.page.full { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; flex-wrap: wrap; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.crumbs .ico { opacity: .6; }
.page-title { font-size: var(--t-2xl); line-height: 1.12; font-weight: 750; letter-spacing: -.012em; font-variation-settings: 'wdth' 112; text-wrap: balance; }
.page-sub { margin-top: 6px; color: var(--ink-2); font-size: 13.5px; max-width: 80ch; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section-title { font-size: var(--t-lg); font-weight: 700; letter-spacing: -.005em; font-variation-settings: 'wdth' 108; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-head p { color: var(--ink-3); font-size: 12.5px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; height: 40px; padding: 0 14px; font-size: 13.5px; font-weight: 550; color: var(--ink-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--ink); font-weight: 650; }
.tab[aria-selected="true"]::after, .tab[aria-current="page"]::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--red); border-radius: 2px 2px 0 0; }
.tab .count { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 9px; background: var(--sunken); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--r-sm); font-size: 13.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 1px 1px rgba(120, 8, 14, .25); }
.btn-primary:hover { background: var(--red-hover); }
.btn-primary:active { background: var(--red-press); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.btn-secondary:hover { background: var(--hover); border-color: color-mix(in srgb, var(--line-strong) 60%, var(--ink-3)); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-dark { background: var(--shell); color: #fff; }
.btn-dark:hover { background: var(--shell-3); }
.btn-success { background: #127a12; color: #fff; }
.btn-success:hover { background: #0e660e; }
.btn-danger-text { color: var(--crit-ink); }
.btn-danger-text:hover { background: var(--crit-bg); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; gap: 5px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn.is-loading { pointer-events: none; color: transparent !important; position: relative; }
.btn.is-loading::after { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-split { display: inline-flex; }
.btn-split .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-split .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(0, 0, 0, .18); padding: 0 8px; }

/* Segmented */
.seg { display: inline-flex; padding: 3px; background: var(--sunken); border-radius: var(--r); gap: 2px; }
.seg button, .seg a { height: 28px; padding: 0 11px; border-radius: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); min-height: 54px; }
.panel-head.flush { border-bottom: 0; padding-bottom: 4px; }
.panel-title { font-size: 14.5px; font-weight: 700; letter-spacing: -.003em; display: flex; align-items: center; gap: 8px; }
.panel-title .ico { color: var(--ink-3); }
.panel-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; font-weight: 400; }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }
.panel-foot { padding: 10px 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12.5px; color: var(--ink-3); }

/* Layout helpers */
.stack { display: flex; flex-direction: column; gap: var(--gap, 12px); }
.row { display: flex; align-items: center; gap: var(--gap, 10px); }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: var(--gap, 16px); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); align-items: start; }
.g-main-r { grid-template-columns: minmax(300px, 1fr) minmax(0, 1.65fr); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

/* Ledger strip: KPI row inside one panel, divided by hairlines */
.ledger { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.ledger-cell { padding: 14px 18px 12px; border-right: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; gap: 2px; position: relative; text-align: left; }
.ledger-cell:last-child { border-right: 0; }
a.ledger-cell:hover, button.ledger-cell:hover { background: var(--surface-2); }
.ledger-label { font-size: 12px; color: var(--ink-2); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.ledger-value { font-size: 27px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; font-variation-settings: 'wdth' 106; font-variant-numeric: tabular-nums; }
.ledger-value small { font-size: 13px; font-weight: 600; color: var(--ink-3); margin-left: 3px; letter-spacing: 0; }
.ledger-meta { font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ledger-spark { margin-top: 6px; height: 26px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 650; font-size: 11.5px; }
.delta.up-good, .delta.down-good { color: var(--good-ink); }
.delta.up-bad, .delta.down-bad { color: var(--crit-ink); }
.delta.flat { color: var(--ink-3); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 7px; border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral-ink); line-height: 1; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; flex-shrink: 0; }
.pill.no-dot::before { display: none; }
.pill.good { background: var(--good-bg); color: var(--good-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.serious { background: var(--serious-bg); color: var(--serious-ink); }
.pill.crit { background: var(--crit-bg); color: var(--crit-ink); }
.pill.info { background: var(--info-bg); color: var(--info-ink); }
.pill.brand { background: var(--red-tint); color: var(--red-ink); }
.pill.dark { background: var(--shell); color: #fff; }
.code { font-family: var(--font-mono); font-size: 12px; font-weight: 500; padding: 1px 6px; border-radius: 4px; background: var(--sunken); color: var(--ink); white-space: nowrap; letter-spacing: -.01em; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge.quiet { background: var(--sunken); color: var(--ink-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }

/* Meter */
.meter { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.meter-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.meter-top b { font-weight: 650; font-variant-numeric: tabular-nums; }
.meter-track { height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; display: flex; gap: 2px; }
.meter-fill { height: 100%; background: var(--s1); border-radius: 4px; transition: width .4s var(--ease-out); }
.meter-track.thin { height: 5px; }

/* Data table */
.tbl-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tbl-search { display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); width: 240px; color: var(--ink-3); }
.tbl-search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(43, 111, 214, .15); }
.tbl-search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 13px; color: var(--ink); }
.tbl-count { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 10px; border: 1px solid var(--line-strong); border-radius: 15px; font-size: 12.5px; background: var(--surface); color: var(--ink-2); }
.filter-chip select { border: 0; background: transparent; font-size: 12.5px; font-weight: 600; color: var(--ink); padding-right: 2px; cursor: pointer; outline: none; }
.filter-chip.is-set { border-color: var(--red); background: var(--red-tint); color: var(--red-ink); }
.tbl-wrap { overflow: auto; position: relative; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-size: 11.5px; font-weight: 650; color: var(--ink-2); padding: 0 12px; height: 36px; border-bottom: 1px solid var(--line); white-space: nowrap; letter-spacing: .01em; }
.tbl th button { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; color: inherit; height: 100%; }
.tbl th button:hover { color: var(--ink); }
.tbl th[aria-sort] button { color: var(--ink); }
.tbl td { padding: 0 12px; height: 44px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.tbl td.wrap { white-space: normal; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background-color .1s; }
.tbl tbody tr.is-link { cursor: pointer; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr.is-selected { background: var(--red-tint); }
.tbl tbody tr.flash { animation: flash 1.6s var(--ease-out); }
@keyframes flash { from { background: color-mix(in srgb, var(--warn) 24%, transparent); } to { background: transparent; } }
.tbl .num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .title-cell { font-weight: 600; color: var(--ink); }
.sub { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 400; line-height: 1.35; }
.tbl input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--red); }
.tbl td.check, .tbl th.check { width: 36px; padding-right: 0; }
.tbl.compact td { height: 36px; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-strong); height: 40px; }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--shell); color: #fff; font-size: 13px; }
.bulk-bar .btn-ghost { color: #ddd; }
.bulk-bar .btn-ghost:hover { background: var(--shell-3); color: #fff; }

/* Lists */
.list-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, button.list-item:hover { background: var(--hover); }
button.list-item { width: 100%; text-align: left; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.list-item .li-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.li-icon { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); flex-shrink: 0; }
.li-icon.red { background: var(--red-tint); color: var(--red); }
.li-icon.good { background: var(--good-bg); color: var(--good-ink); }
.li-icon.warn { background: var(--warn-bg); color: var(--warn-ink); }
.li-icon.info { background: var(--info-bg); color: var(--info-ink); }

/* Activity feed */
.feed { display: flex; flex-direction: column; }
.feed-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; align-items: start; }
.feed-item:last-child { border-bottom: 0; }
.feed-item.is-new { animation: slideIn .5s var(--ease-out); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); background: color-mix(in srgb, var(--warn) 18%, transparent); } to { opacity: 1; transform: none; } }
.feed-item .feed-ico { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); }
.feed-item time { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed-item p { color: var(--ink-2); line-height: 1.4; }
.feed-item p b { color: var(--ink); font-weight: 600; }
.feed-item .feed-ctx { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field > label .req { color: var(--red); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); font-size: 13.5px; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 88px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23676c73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--line-strong) 55%, var(--ink-3)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(43, 111, 214, .16); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--crit); box-shadow: 0 0 0 3px rgba(208, 59, 59, .12); }
.field-hint { font-size: 11.5px; color: var(--ink-3); }
.field-error { font-size: 11.5px; color: var(--crit-ink); font-weight: 600; display: flex; gap: 5px; align-items: center; }
.field-error[hidden] { display: none; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--red); }

/* Definition list */
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; }
.dl > div { min-width: 0; }
.dl dt { font-size: 11.5px; color: var(--ink-3); font-weight: 600; margin-bottom: 3px; letter-spacing: .01em; }
.dl dd { font-size: 13.5px; color: var(--ink); overflow-wrap: anywhere; }
.dl .full { grid-column: 1 / -1; }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(14, 16, 18, .38); z-index: 60; animation: fadeIn .18s ease-out; }
@keyframes fadeIn { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); z-index: 61; background: var(--surface);
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column; animation: drawerIn .28s var(--ease-out);
}
.drawer.narrow { width: min(560px, 100vw); }
@keyframes drawerIn { from { transform: translateX(28px); opacity: 0; } }
.drawer-head { padding: 16px 20px 0; border-bottom: 1px solid var(--line); }
.drawer-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-kicker { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; }
.drawer-title { font-size: 21px; font-weight: 750; letter-spacing: -.01em; font-variation-settings: 'wdth' 108; margin: 6px 0 10px; line-height: 1.2; text-wrap: balance; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 12px; }
.drawer-head .tabs { margin: 0 -4px; border-bottom: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }
.drawer-section { margin-bottom: 22px; }
.drawer-section > h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin-bottom: 10px; }
.callout { padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; line-height: 1.55; }
.callout.pre { white-space: pre-wrap; }
.callout.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn-ink) 22%, transparent); color: var(--warn-ink); }
.callout.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info-ink) 22%, transparent); color: var(--info-ink); }
.callout.crit { background: var(--crit-bg); border-color: color-mix(in srgb, var(--crit-ink) 22%, transparent); color: var(--crit-ink); }
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.msg-head { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.msg-head b { color: var(--ink); font-weight: 650; font-size: 13px; }
.msg-body { margin-top: 3px; font-size: 13.5px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; }
.msg.official .msg-body { background: var(--good-bg); border: 1px solid color-mix(in srgb, var(--good-ink) 22%, transparent); border-radius: var(--r); padding: 10px 12px; color: var(--ink); }

/* Menus / popovers */
.menu { position: fixed; z-index: 70; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 6px; animation: popIn .16s var(--ease-out); max-height: calc(100vh - 72px); overflow-y: auto; color: var(--ink); overscroll-behavior: contain; }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13.5px; text-align: left; color: var(--ink); }
.menu-item:hover, .menu-item.is-active { background: var(--hover); }
.menu-item .ico { color: var(--ink-3); }
.menu-item small { display: block; font-size: 11.5px; color: var(--ink-3); }
.menu-item .menu-right { margin-left: auto; font-size: 11.5px; color: var(--ink-3); }
.menu-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 10px 10px 4px; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }

/* Mega tools menu */
.mega { width: min(920px, calc(100vw - 24px)); padding: 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 18px; }
.mega h4 { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 6px 8px; }
.mega .menu-item { padding: 7px 8px; }
.mega-col { min-width: 0; }

/* Project picker */
.picker { width: min(560px, calc(100vw - 24px)); padding: 0; }
.picker-search { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.picker-search:focus-within { box-shadow: inset 0 -2px 0 var(--focus); }
.picker-search input { flex: 1; border: 0; outline: none; background: transparent; font-size: 14px; color: var(--ink); }
.picker-list { padding: 6px; max-height: 420px; overflow-y: auto; }
.picker-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 9px 10px; border-radius: var(--r); width: 100%; text-align: left; }
.picker-item:hover, .picker-item.is-active { background: var(--hover); }
.picker-num { font-family: var(--font-mono); font-size: 11px; font-weight: 600; display: grid; place-items: center; height: 40px; border-radius: var(--r-sm); background: var(--sunken); color: var(--ink-2); }

/* Command palette */
.cmdk-wrap { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; background: rgba(14, 16, 18, .42); animation: fadeIn .15s; }
.cmdk { width: min(660px, calc(100vw - 24px)); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); overflow: hidden; border: 1px solid var(--line); animation: popIn .18s var(--ease-out); }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.cmdk-input:focus-within { box-shadow: inset 0 -2px 0 var(--focus); }
.cmdk-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--ink); }
.cmdk-results { max-height: 420px; overflow-y: auto; padding: 6px; }
.cmdk-results .menu-item { padding: 9px 10px; }
.cmdk-results .menu-item[aria-selected="true"] { background: var(--red-tint); }
.cmdk-results .menu-item[aria-selected="true"] .ico { color: var(--red); }
.cmdk-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-3); background: var(--surface-2); }

/* Toasts */
.toasts { position: fixed; left: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 420px; padding: 11px 12px 11px 14px; border-radius: var(--r-lg); background: var(--shell); color: #fff; box-shadow: var(--shadow-pop); font-size: 13.5px; animation: toastIn .3s var(--ease-out); }
.toast .ico { color: #6fdc84; }
.toast.err .ico { color: #ff8a8a; }
.toast button { margin-left: auto; color: #fff; font-weight: 650; font-size: 12.5px; padding: 4px 8px; border-radius: 4px; }
.toast button:hover { background: var(--shell-3); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* Empty, skeleton */
.empty { padding: 40px 24px; text-align: center; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .empty-ico { width: 48px; height: 48px; border-radius: 50%; background: var(--sunken); display: grid; place-items: center; color: var(--ink-3); margin-bottom: 6px; }
.empty h3 { font-size: 15.5px; color: var(--ink); font-weight: 700; }
.empty p { max-width: 46ch; font-size: 13px; color: var(--ink-3); }
.skeleton { background: linear-gradient(90deg, var(--sunken), var(--hover), var(--sunken)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-sans); font-size: 11px; fill: var(--chart-ink); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .crosshair { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 0; opacity: .5; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--shell); color: #fff; border-radius: var(--r); padding: 8px 10px;
  font-size: 12px; box-shadow: var(--shadow-pop); min-width: 140px; transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap; opacity: 0; transition: opacity .12s;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { display: block; font-size: 11.5px; color: #c8ccd2; font-weight: 600; margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; }
.chart-tip .tip-row span:last-child { margin-left: auto; padding-left: 12px; font-weight: 650; }
.chart-tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }

/* Status ramp legend (steel progress) */
.ramp-legend { display: flex; gap: 2px; align-items: stretch; font-size: 11px; color: var(--ink-2); flex-wrap: wrap; }
.ramp-legend span { display: inline-flex; align-items: center; gap: 6px; padding-right: 12px; }
.ramp-legend i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }

/* Erection grid map — the signature */
.emap { position: relative; }
.emap svg { width: 100%; height: auto; display: block; }
.emap.scroll { overflow-x: auto; }
.emap.fit svg { max-height: 460px; }
.emap .bubble circle { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.2; }
.emap .bubble text { font-family: var(--font-sans); font-weight: 700; font-size: 12px; fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.emap .gridline { stroke: var(--ink-3); stroke-width: .8; stroke-dasharray: 10 4 2 4; opacity: .55; }
.emap .bay { stroke: var(--surface); stroke-width: 3; transition: fill .6s var(--ease-out); cursor: pointer; }
.emap .bay:hover { stroke: var(--ink); stroke-width: 2; }
.emap .col { stroke: var(--surface); stroke-width: 1.5; }
.emap .bay.pulse { animation: bayPulse 1.6s var(--ease-out); }
@keyframes bayPulse { 0% { filter: brightness(1.6) saturate(1.3); } 100% { filter: none; } }
.emap .crane { fill: none; stroke: var(--red); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .7; }
.emap .crane-dot { fill: var(--red); stroke: var(--surface); stroke-width: 2; }
.emap .crane-label { font-size: 11.5px; font-weight: 700; fill: var(--red-ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.emap .bay-label { font-size: 10px; font-weight: 600; fill: #fff; pointer-events: none; font-variant-numeric: tabular-nums; }
.emap .bay-label.dark { fill: var(--ink); }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--sunken); border-radius: var(--r-lg); display: flex; flex-direction: column; min-height: 200px; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; font-size: 12.5px; font-weight: 700; }
.kcol-head small { font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.kcol-body { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 560px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 10px; box-shadow: var(--shadow-1); text-align: left; width: 100%; font-size: 12.5px; }
.kcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.kcard .kc-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.kcard .kc-title { font-weight: 600; margin: 4px 0 2px; color: var(--ink); }
.kcard .kc-meta { font-size: 11.5px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }

/* Gantt */
.gantt { position: relative; overflow-x: auto; }
.gantt-row { display: grid; grid-template-columns: 280px 1fr; min-height: 34px; border-bottom: 1px solid var(--line); align-items: center; background: var(--surface); }
.gantt-row:hover { background: var(--hover); }
.gantt-name { padding: 0 12px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; position: sticky; left: 0; background: inherit; }
.gantt-track { position: relative; height: 34px; }
.gantt-bar { position: absolute; top: 9px; height: 16px; border-radius: 4px; background: var(--p2); overflow: hidden; }
.gantt-bar .done { position: absolute; inset: 0 auto 0 0; background: var(--p5); }
.gantt-bar.crit { background: color-mix(in srgb, var(--crit) 35%, var(--surface)); }
.gantt-bar.crit .done { background: var(--crit); }
.gantt-bar.milestone { width: 12px !important; height: 12px; top: 11px; transform: rotate(45deg); border-radius: 2px; background: var(--ink); }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 2; }
.gantt-scale { display: grid; grid-template-columns: 280px 1fr; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); position: sticky; top: 0; z-index: 3; }
.gantt-scale .ticks { position: relative; height: 34px; }
.gantt-scale .tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); font-size: 11px; color: var(--ink-3); padding: 9px 6px; white-space: nowrap; }

/* Calendar heat */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; }
.heat i { width: 12px; height: 12px; border-radius: 2px; background: var(--p0); display: block; }

/* Notification panel */
.notif { width: min(420px, calc(100vw - 24px)); padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-head strong { font-size: 14px; }

/* Sample-data ribbon inside pages */
.source-note { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.source-note .ico { color: var(--warn); }

/* Hero band on dashboards */
.hero-band { position: relative; border-radius: var(--r-xl); overflow: hidden; background: var(--shell); color: var(--shell-ink); padding: 22px 24px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end; isolation: isolate; }
.hero-band h1 { font-size: 30px; line-height: 1.1; font-weight: 750; letter-spacing: -.015em; font-variation-settings: 'wdth' 116; text-wrap: balance; }
.hero-band p { color: var(--shell-ink-2); margin-top: 8px; font-size: 14px; max-width: 70ch; }
.hero-band .hero-meta { display: flex; gap: 22px; flex-wrap: wrap; }
.hero-band .hero-stat { display: flex; flex-direction: column; }
.hero-band .hero-stat small { font-size: 11.5px; color: var(--shell-ink-2); }
.hero-band .hero-stat b { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; font-variation-settings: 'wdth' 108; }
.hero-band .btn-secondary { background: var(--shell-2); color: var(--shell-ink); border-color: var(--shell-line); box-shadow: none; }
.hero-band .btn-secondary:hover { background: var(--shell-3); }

/* Weather chip */
.wx { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.wx b { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Utility spacing */
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; }
.text-sm { font-size: 12.5px; } .text-xs { font-size: 11.5px; } .fw-6 { font-weight: 600; } .fw-7 { font-weight: 700; }
.right { text-align: right; }

/* TV / fullscreen tools */
.app.tv { grid-template-rows: 0 1fr; }
.app.tv .hdr { display: none; }

/* Responsive */
@media (max-width: 1280px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger { --cols: 4 !important; }
  .mega { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hdr-wordmark { display: none; }
}
@media (max-width: 1080px) {
  .app { --rail-w: 64px; }
  .app .rail-link span, .app .rail-label, .app .rail-head > div, .app .rail-count { display: none; }
  .app .rail-link { justify-content: center; padding: 0; }
  .app .rail-head { justify-content: center; }
  .g-main, .g-main-r { grid-template-columns: minmax(0, 1fr); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hdr-search { width: 40px; padding: 0; justify-content: center; }
  .hdr-search .kbd { display: none; }
  .hdr-search .hs-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 760px) {
  :root { --hdr-h: 54px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'hdr' 'main'; padding-bottom: 64px; }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: 64px; z-index: 45; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); gap: 4px; background: var(--surface);
  }
  .rail-head, .rail-label, .rail-foot, .rail-scope-badge { display: none !important; }
  /* Phone tool bar: the persona's pinned tools, the current tool, and More. */
  .rail { overflow: hidden; justify-content: space-between; }
  .app .rail-link:not(.pin):not(.is-active) { display: none; }
  .app .rail-link, .rail-more { flex: 1 1 0; flex-direction: column; height: 52px; min-width: 0; gap: 3px; padding: 7px 2px 0; font-size: 11px; justify-content: flex-start; }
  .app .rail-link .rail-lbl-full { display: none !important; }
  .app .rail-link > span:not(.rail-count):not(.rail-lbl-full), .rail-more span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; text-align: center; line-height: 1.15; white-space: nowrap; font-size: 11px; }
  .app .rail-link { position: relative; }
  .app .rail-link .rail-count { display: block; position: absolute; top: 3px; left: calc(50% + 6px); margin: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--sunken); color: var(--ink-2); font-size: 11px; line-height: 16px; text-align: center; }
  .rail-more { display: flex; align-items: center; border-radius: var(--r-sm); color: var(--rail-ink); font-weight: 500; }
  .rail-more .ico { color: var(--ink-3); }
  .rail-link.is-active { box-shadow: none; background: var(--red-tint); }
  /* Gloved-hand targets */
  .btn { height: auto; min-height: 44px; white-space: normal; text-align: center; max-width: 100%; }
  .panel-head, .panel-head .row, .page-actions, .tbl-toolbar { flex-wrap: wrap; }
  .btn-sm, .btn-xs { min-height: 40px; }
  .btn-icon { min-width: 44px; }
  .input, .select { height: 44px; font-size: 16px; }
  .textarea { font-size: 16px; }
  .seg button, .seg a { height: 40px; }
  .filter-chip { height: 40px; }
  .filter-chip select { font-size: 14px; min-height: 36px; }
  .tab { height: 44px; }
  .check-row input, .tbl input[type=checkbox] { width: 20px; height: 20px; }
  .hdr-icon-btn { width: 40px; height: 40px; }
  .hdr-icon-btn .dot-count { top: 2px; right: 0; }
  .menu.sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100% !important; max-height: 82vh; border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .page { padding: 16px 16px 40px; }
  .page-title { font-size: 22px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .ledger { --cols: 2 !important; }
  .ledger-cell { border-bottom: 1px solid var(--line); }
  .ledger-cell:nth-child(2n) { border-right: 0; }
  .ledger-value { font-size: 22px; }
  .hdr { gap: 2px; padding: 0 6px; }
  .hdr-sep, .sample-chip span, .live-pill span:not(.live-dot), .hdr-hide-sm, .director-sub { display: none; }
  .mode-banner { padding: 5px 10px; }
  .director-bar { gap: 6px; }
  .director-step { padding: 3px 7px; font-size: 11px; }
  .director-hub-link { padding: 3px 6px; font-size: 11px; }
  .director-step span { display: none; }
  .live-pill { width: 30px; padding: 0; justify-content: center; }
  .ctx-btn { max-width: 46vw; padding: 0 6px; }
  .hdr-logo { width: 58px; }
  .hdr-logo img { width: 54px; }
  .form-grid, .dl { grid-template-columns: minmax(0, 1fr); }
  .drawer { width: 100vw; }
  .mega { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-band { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .hero-band h1 { font-size: 24px; }
  .tbl-search { width: 100%; }
  .page-actions { width: 100%; }
  .gantt-row, .gantt-scale { grid-template-columns: 160px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  /* Keep the final state, readable progress and live status; remove decorative travel/pulses. */
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .hdr, .rail, .page-actions, .tbl-toolbar, .toasts { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .panel { box-shadow: none; break-inside: avoid; }
}

/* ---------- QA round 2: product hardening ---------- */
/* Save-failure banner: stays until saving works again. */
.sys-banner { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 95; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--r-lg); background: var(--crit-ink); color: #fff; box-shadow: var(--shadow-pop); font-size: 13.5px; line-height: 1.4; }
.sys-banner span { flex: 1 1 320px; }
.sys-banner .btn-secondary { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .6); }
/* Long unbroken text never stretches a drawer or a card. */
.drawer-title, .drawer-body, .feed-item, .list-item, .callout { overflow-wrap: anywhere; }
.pill.sim { background: var(--sunken); color: var(--ink-2); }
/* Voided records shown through a deep link. */
.void-banner { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; margin-bottom: 14px; border-radius: var(--r); background: var(--sunken); color: var(--ink-2); font-size: 13px; }
.gate-note { font-size: 12px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; }
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
/* Project rail fits a 900px-tall laptop screen without scrolling. */
@media (min-width: 761px) and (max-height: 1000px) {
  .rail { padding-top: 8px; padding-bottom: 10px; gap: 1px; }
  .rail-link { height: 27px; font-size: 13px; }
  .rail-label { padding: 9px 10px 3px; }
  .rail-head { padding-bottom: 6px; }
  .rail-foot { padding-top: 8px; }
}
@media (max-width: 760px) {
  /* Toasts sit above the phone tool bar instead of covering it. */
  .toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }
  .sys-banner { bottom: calc(76px + env(safe-area-inset-bottom)); left: 12px; right: 12px; }
  /* Lists become cards on phones: every column stays visible with its label, nothing scrolls sideways. */
  .dt .tbl-wrap { overflow: visible; }
  .dt .tbl, .dt .tbl tbody, .dt .tbl tr, .dt .tbl td, .dt .tbl tfoot { display: block; width: 100%; }
  .dt .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dt .tbl tbody tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .dt .tbl tbody tr:last-child { border-bottom: 0; }
  .dt .tbl td { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; height: auto; min-height: 26px; padding: 3px 0; border: 0; white-space: normal; max-width: none; text-align: right; overflow: visible; }
  .dt .tbl td::before { content: attr(data-label); flex-shrink: 0; text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); }
  .dt .tbl td[data-label=""]::before { content: none; }
  .dt .tbl td[data-label=""] { justify-content: flex-start; }
  .dt .tbl td:first-child { justify-content: flex-start; text-align: left; font-weight: 650; }
  .dt .tbl td:first-child::before { content: none; }
  .dt .tbl td > .title-cell, .dt .tbl td .sub { text-align: right; }
  .dt .tbl td.check { width: auto; }
  .dt .tbl tfoot tr { padding: 10px 14px; background: var(--surface-2); }
  .dt .tbl tfoot td { border: 0; height: auto; background: transparent; justify-content: flex-end; }
  .dt .tbl tfoot td:empty { display: none; }
  .dt .tbl tbody tr td[colspan] { display: block; text-align: left; }
  .dt .tbl tbody tr td[colspan]::before { content: none; }
}
.feed-link { color: inherit; text-decoration: none; }
.feed-link:hover { text-decoration: underline; color: var(--red-ink); }
.feed-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
@media (max-width: 760px) {
  /* The record's title reads as the card heading, full width under its number. */
  .dt .tbl td:has(> .title-cell) { display: block; text-align: left; padding: 2px 0 6px; }
  .dt .tbl td:has(> .title-cell)::before { content: none; }
  .dt .tbl td:has(> .title-cell) .sub { text-align: left; }
}

/* Persistent provenance at every width, including demo wall display. */
.mode-banner{grid-column:2;position:relative}.app.no-rail .mode-banner{grid-column:1/-1}.sample-chip{flex-shrink:0}@media(max-width:760px){.mode-banner{grid-column:1/-1}.sample-chip{display:inline-flex!important}.hdr .live-pill{display:none}}

/* Provenance is a real row, not an auto-placed item after the work. */
.app{grid-template-rows:var(--hdr-h) auto 1fr;grid-template-areas:'hdr hdr' 'rail mode' 'rail main'}
.app .mode-banner{grid-area:mode}.app.no-rail{grid-template-rows:var(--hdr-h) auto 1fr;grid-template-areas:'hdr' 'mode' 'main'}
@media(max-width:760px){.app{grid-template-columns:minmax(0,1fr);grid-template-areas:'hdr' 'mode' 'main'}.hub-chrome .hdr-search{display:flex;width:auto}.hub-chrome .hdr-logo{width:58px}.hub-chrome .hdr-logo img{width:54px}.hub-chrome .hdr-wordmark{display:none}}

.app.tv{grid-template-rows:0 auto 1fr;grid-template-areas:'hdr' 'mode' 'main'}
.rail-lbl-short{display:none}
@media(min-width:761px) and (max-width:1080px){.work-intro{grid-template-columns:minmax(0,1fr)}.work-bottom{grid-template-columns:minmax(0,1fr);gap:28px}.hub-chrome .hdr-search{width:auto;padding:8px 14px}}
@media(max-width:760px){.hdr .sample-chip,.hdr [data-help],.hdr [data-quick]{display:none!important}.hdr-brand{gap:4px}.hdr .ctx-btn{max-width:58vw}}

/* ---------- 3-Layer Corporate Hierarchy & Role Switcher ---------- */
.hdr-role-switch {
  display: inline-flex;
  align-items: center;
  background: var(--shell-2);
  border: 1px solid var(--shell-line);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
  margin-left: 6px;
}
.hdr-role-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--shell-ink-2);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.hdr-role-btn:hover {
  color: var(--shell-ink);
  background: rgba(255, 255, 255, 0.06);
}
.hdr-role-btn.is-active {
  background: var(--red);
  color: #fff;
}
.hdr-role-btn.is-active.is-foreman {
  background: #854d0e;
  color: #fff;
}
.rail-scope-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 8px 8px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1px solid var(--warn);
  font-size: 11.5px;
  font-weight: 700;
}
.mode-banner {
  background: var(--surface-2);
  color: var(--ink);
  padding: 7px 18px;
  border-bottom: 1px solid var(--line-strong);
}
.director-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}
.director-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.director-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.director-sub {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}
.director-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.director-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 11.5px;
  cursor: pointer;
}
.director-step b {
  color: var(--ink);
  font-weight: 750;
}
.director-step:hover {
  border-color: var(--red);
  color: var(--ink);
}
.director-step.is-active {
  background: var(--red-tint);
  border-color: var(--red);
  color: var(--red-ink);
}
.director-step.is-active b {
  color: var(--red-ink);
}
.director-divider {
  width: 1px;
  height: 18px;
  background: var(--line-strong);
  margin: 0 2px;
}
.director-hub-link {
  font-size: 11.5px;
  font-weight: 650;
  padding: 4px 8px;
  color: var(--ink-2);
}
@media (max-width: 1120px) {
  .hdr-role-switch { display: none; }
}

/* Keep company actions reachable at intermediate desktop widths. */
.hub-chrome .hdr{min-width:0}.hub-chrome .hub-nav{min-width:0;flex:1;flex-wrap:wrap;justify-content:flex-end;gap:6px}.hub-chrome .hub-mode-seg{min-width:0;flex-wrap:wrap}.hub-chrome .hdr-brand{flex-shrink:0}.hub-chrome .hdr-spacer{min-width:0}

/* Company profile drawers (ui/company.js) */
.cp-brand { display: flex; align-items: center; gap: 8px; }
.cp-brand input[type="color"] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; flex-shrink: 0; }
.cp-brand .input { width: 120px; }
.cp-swatch { display: grid; place-items: center; width: 64px; height: 36px; border-radius: var(--r-sm); color: #fff; font-weight: 700; font-size: 13px; }
.cp-logo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-logo-box { display: grid; place-items: center; width: 150px; height: 60px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; text-align: center; }
.cp-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Inspection checklist results in the record drawer */
.sf-ck-list { display: flex; flex-direction: column; }
.sf-ck-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; align-items: start; }
.sf-ck-row small { display: block; color: var(--ink-3); font-size: 12px; }
.sf-ck-row.fail { color: var(--crit-ink); font-weight: 600; }

/* One-column grid, and filter chips that never push a phone sideways */
.g-one { grid-template-columns: minmax(0, 1fr); }
.filter-chip { max-width: 100%; min-width: 0; }
.filter-chip select { max-width: 100%; min-width: 0; text-overflow: ellipsis; }

