/* =====================================================================
   BMS_Tools — dark operations console
   Theme tokens + base + shell + shared components
   ===================================================================== */

:root {
  /* ---- surfaces (deep desaturated blue-black) ---- */
  --bg-0:  oklch(0.145 0.012 256);   /* app base */
  --bg-1:  oklch(0.178 0.014 256);   /* rail / chrome */
  --panel: oklch(0.197 0.015 256);   /* panel surface */
  --panel-2: oklch(0.224 0.017 256); /* elevated / header strip */
  --panel-3: oklch(0.255 0.018 256); /* hover / input */
  --inset: oklch(0.165 0.013 256);   /* wells, tables */

  /* ---- hairlines ---- */
  --line:    oklch(0.30 0.016 256);
  --line-2:  oklch(0.37 0.02 256);
  --line-strong: oklch(0.46 0.025 256);

  /* ---- ink ---- */
  --ink:     oklch(0.93 0.008 256);
  --ink-2:   oklch(0.74 0.014 256);
  --ink-3:   oklch(0.58 0.016 256);
  --ink-4:   oklch(0.46 0.016 256);

  /* ---- accent (cyan-teal, the interactive color) ---- */
  --acc:     oklch(0.74 0.125 195);
  --acc-dim: oklch(0.62 0.10 195);
  --acc-ink: oklch(0.18 0.04 220);
  --acc-glow: oklch(0.74 0.125 195 / 0.16);

  /* ---- status (shared chroma/lightness, varied hue) ---- */
  --ok:    oklch(0.76 0.15 152);
  --warn:  oklch(0.80 0.135 82);
  --alarm: oklch(0.68 0.17 25);
  --info:  oklch(0.72 0.12 248);
  --viol:  oklch(0.70 0.13 300);

  --ok-bg:    oklch(0.76 0.15 152 / 0.14);
  --warn-bg:  oklch(0.80 0.135 82 / 0.14);
  --alarm-bg: oklch(0.68 0.17 25 / 0.15);
  --info-bg:  oklch(0.72 0.12 248 / 0.14);
  --viol-bg:  oklch(0.70 0.13 300 / 0.14);

  /* ---- lifecycle phase hues (rail grouping) ---- */
  --ph-capture:  oklch(0.72 0.12 248);
  --ph-engineer: oklch(0.74 0.125 195);
  --ph-document: oklch(0.70 0.13 300);
  --ph-deliver:  oklch(0.80 0.135 82);
  --ph-system:   oklch(0.66 0.012 256);

  /* ---- type ---- */
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  /* ---- technical background pattern ---- */
  --grid-dot:  oklch(1 0 0 / 0.05);
  --grid-line:       oklch(1 0 0 / 0.045);
  --grid-line-major: oklch(1 0 0 / 0.09);
  --grid-size: 24px;
  --glow-1: oklch(0.74 0.125 195 / 0.05);
  --glow-2: oklch(0.70 0.13 300 / 0.04);

  /* ---- metrics ---- */
  --r: 6px;
  --r-sm: 4px;
  --r-lg: 10px;
  --h-top: 52px;
  --h-status: 26px;
  --w-rail: 248px;
  --density: 1;     /* scaled by tweaks */
  --shadow: 0 1px 0 oklch(1 0 0 / 0.03) inset, 0 8px 24px -12px oklch(0 0 0 / 0.6);
  --shadow-pop: 0 16px 50px -16px oklch(0 0 0 / 0.7), 0 0 0 1px var(--line);
}

/* =====================================================================
   LIGHT THEME — technical / paper register
   ===================================================================== */
[data-theme="light"] {
  --bg-0:  oklch(0.955 0.004 256);
  --bg-1:  oklch(0.985 0.002 256);
  --panel: oklch(1 0 0);
  --panel-2: oklch(0.975 0.003 256);
  --panel-3: oklch(0.935 0.006 256);
  --inset: oklch(0.965 0.004 256);

  --line:    oklch(0.88 0.006 256);
  --line-2:  oklch(0.80 0.009 256);
  --line-strong: oklch(0.70 0.012 256);

  --ink:   oklch(0.26 0.02 256);
  --ink-2: oklch(0.40 0.02 256);
  --ink-3: oklch(0.52 0.018 256);
  --ink-4: oklch(0.64 0.015 256);

  --acc:     oklch(0.58 0.12 205);
  --acc-dim: oklch(0.50 0.11 205);
  --acc-ink: oklch(1 0 0);
  --acc-glow: oklch(0.58 0.12 205 / 0.13);

  --ok:    oklch(0.54 0.14 152);
  --warn:  oklch(0.58 0.13 70);
  --alarm: oklch(0.54 0.18 25);
  --info:  oklch(0.52 0.14 248);
  --viol:  oklch(0.50 0.16 300);
  --ok-bg:    oklch(0.54 0.14 152 / 0.12);
  --warn-bg:  oklch(0.58 0.13 70 / 0.13);
  --alarm-bg: oklch(0.54 0.18 25 / 0.11);
  --info-bg:  oklch(0.52 0.14 248 / 0.11);
  --viol-bg:  oklch(0.50 0.16 300 / 0.11);

  --ph-capture:  oklch(0.52 0.14 248);
  --ph-engineer: oklch(0.55 0.12 205);
  --ph-document: oklch(0.50 0.16 300);
  --ph-deliver:  oklch(0.58 0.13 70);
  --ph-system:   oklch(0.55 0.01 256);

  --grid-dot: oklch(0.45 0.02 256 / 0.07);
  --grid-line:       oklch(0.45 0.04 256 / 0.09);
  --grid-line-major: oklch(0.45 0.07 256 / 0.17);
  --glow-1: oklch(0.58 0.12 205 / 0.06);
  --glow-2: oklch(0.50 0.16 300 / 0.04);

  --shadow: 0 1px 2px oklch(0.4 0.02 256 / 0.06), 0 8px 24px -16px oklch(0.4 0.02 256 / 0.22);
  --shadow-pop: 0 18px 48px -18px oklch(0.3 0.02 256 / 0.28), 0 0 0 1px var(--line);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.005em;
}
#app { height: 100%; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: content-box; }

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--acc); text-decoration: none; }

.mono { font-family: var(--mono); font-feature-settings: "zero" 1; font-variant-numeric: tabular-nums; }
.cap { text-transform: uppercase; letter-spacing: 0.09em; font-size: 10.5px; font-weight: 600; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.faint { color: var(--ink-4); }

/* =====================================================================
   APP SHELL
   ===================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--w-rail) 1fr;
  grid-template-rows: var(--h-top) 1fr var(--h-status);
  height: 100%;
  min-height: 0;
}
.shell.railCollapsed { grid-template-columns: 64px 1fr; }

/* ---- bottom instrument status strip ---- */
.statusbar {
  grid-column: 1 / -1; grid-row: 3;
  display: flex; align-items: center; gap: 0;
  padding: 0 14px; font-family: var(--mono); font-size: 10.5px;
  background: linear-gradient(180deg, oklch(0.16 0.013 256), var(--bg-1));
  border-top: 1px solid var(--line); color: var(--ink-3);
  white-space: nowrap; overflow: hidden;
}
[data-theme="light"] .statusbar { background: linear-gradient(180deg, var(--panel-2), var(--bg-1)); }
.statusbar .seg { display: flex; align-items: center; gap: 7px; padding: 0 13px; height: 100%; border-right: 1px solid var(--line); }
.statusbar .seg:first-child { padding-left: 2px; }
.statusbar .seg.end { border-right: none; border-left: 1px solid var(--line); }
.statusbar .spacer { flex: 1; }
.statusbar b { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.statusbar .k { color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.06em; }
.statusbar .live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); animation: pulse 2.4s ease-in-out infinite; }
.statusbar .acc { color: var(--acc); }
@media (max-width: 1000px) { .statusbar .seg.opt { display: none; } }

/* ---- top bar ---- */
.topbar {
  grid-column: 1 / -1; grid-row: 1;
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px 0 14px;
  background: linear-gradient(180deg, var(--bg-1), oklch(0.16 0.013 256));
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; width: calc(var(--w-rail) - 14px); flex-shrink: 0; min-width: 0; }
.brandMark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--acc), var(--acc-dim));
  box-shadow: 0 0 0 1px oklch(0.74 0.125 195 / 0.4), 0 4px 14px -4px var(--acc-glow);
}
.brandMark svg { display: block; }
.brandName { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brandName b { color: var(--acc); font-weight: 700; }
.brandName span { color: var(--ink-3); font-weight: 500; }

.topProject {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 10px 5px 12px; margin-left: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  cursor: pointer; transition: border-color 140ms ease-out, background-color 140ms ease-out;
  outline: none; position: relative;
}
.topProject:hover { border-color: var(--line-2); background: var(--panel-2); }
.topProject:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
[data-theme="light"] .topbar { background: linear-gradient(180deg, var(--panel), var(--bg-1)); }
.topProject .pj { display: grid; line-height: 1.2; min-width: 0; }
.topProject .pj b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topProject .pj small { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topProject .chev { color: var(--ink-3); font-size: 11px; }

.topSpacer { flex: 1; }

.busPill {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-2);
}
.busPill .busDot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.45 } }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.busPill b { color: var(--ink); font-weight: 600; }
.busPill { flex-shrink: 0; }
@media (max-width: 1180px) { .busPill .mono { display: none; } }
@media (max-width: 1040px) { .busFlow { display: none; } .brandName span { display: none; } }
@media (max-width: 900px) { .topProject .pj small { display: none; } }
.busFlow { display: flex; gap: 3px; align-items: center; }
.busFlow i { width: 3px; height: 11px; border-radius: 2px; background: var(--acc); opacity: .25; animation: flow 1.4s linear infinite; }
.busFlow i:nth-child(2){ animation-delay: .18s } .busFlow i:nth-child(3){ animation-delay: .36s } .busFlow i:nth-child(4){ animation-delay: .54s }
@keyframes flow { 0%,100%{ opacity:.2 } 50%{ opacity:.9 } }

.iconBtn {
  min-width: 44px; min-height: 44px; width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--ink-2); transition: border-color 140ms ease-out, color 140ms ease-out, background-color 140ms ease-out;
  outline: none; position: relative;
}
.iconBtn:hover { border-color: var(--line-2); color: var(--ink); background: var(--panel-2); }
.iconBtn:active { transform: scale(0.96); }
.iconBtn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.userChip { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 12px; color: var(--acc-ink); background: linear-gradient(150deg, var(--acc), var(--acc-dim)); }

/* ---- tool rail ---- */
.rail {
  grid-row: 2; grid-column: 1;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  padding: 10px 10px 16px;
  min-height: 0;
}
.railSearch {
  display: flex; align-items: center; gap: 8px;
  background: var(--inset); border: 1px solid var(--line); border-radius: var(--r);
  padding: 7px 10px; margin-bottom: 4px; color: var(--ink-3);
}
.railSearch input { background: none; border: none; outline: none; color: var(--ink); width: 100%; font-size: 12.5px; }
.railSearch kbd {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px; background: var(--panel);
}

.railGroup { margin-top: 12px; }
.railGroupHd {
  display: flex; align-items: center; gap: 8px; padding: 0 8px 6px;
}
.railGroupHd .ph { width: 6px; height: 6px; border-radius: 2px; }
.railGroupHd span { text-transform: uppercase; letter-spacing: 0.1em; font-size: 9.5px; font-weight: 700; color: var(--ink-4); }
.railGroupHd .ct { margin-left: auto; font-family: var(--mono); font-size: 9.5px; color: var(--ink-4); }

.navItem {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px;
  padding: 7px 9px; border-radius: var(--r-sm); border: 1px solid transparent;
  color: var(--ink-2); background: none; text-align: left;
  transition: background-color 120ms ease-out, color 120ms ease-out, border-color 120ms ease-out;
  position: relative; outline: none;
}
.navItem:hover { background: var(--panel); color: var(--ink); }
.navItem:focus-visible { outline: 2px solid var(--acc); outline-offset: -1px; }
.navItem .ni-ic { width: 18px; height: 18px; flex-shrink: 0; color: var(--ink-3); display: grid; place-items: center; }
.navItem .ni-label { font-size: 12.5px; font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navItem .ni-badge {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600; padding: 1px 6px; border-radius: 999px;
  background: var(--panel-3); color: var(--ink-2);
}
.navItem .ni-badge.alarm { background: var(--alarm-bg); color: var(--alarm); }
.navItem .ni-badge.warn { background: var(--warn-bg); color: var(--warn); }
.navItem.active {
  background: linear-gradient(90deg, var(--acc-glow), transparent 70%), var(--panel);
  color: var(--ink); border-color: var(--line);
}
.navItem.active::before {
  content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--phc, var(--acc));
}
.navItem.active .ni-ic { color: var(--phc, var(--acc)); }
.railCollapsed .ni-label, .railCollapsed .ni-badge, .railCollapsed .railGroupHd span,
.railCollapsed .railGroupHd .ct, .railCollapsed .railSearch input, .railCollapsed .railSearch kbd { display: none; }
.railCollapsed .navItem { justify-content: center; padding: 8px; }
.railCollapsed .railSearch { justify-content: center; }

.railFoot { margin-top: auto; padding-top: 12px; }
.engineCard {
  background: linear-gradient(180deg, var(--panel), var(--inset));
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px;
  box-shadow: 0 1px 0 var(--line) inset;
}
.engineCard .ec-hd { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; }
.engineCard .ec-hd b { font-size: 11px; font-weight: 600; }
.engineCard .ec-hd .busDot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.engineCard .ec-row { display: flex; justify-content: space-between; align-items: center; font-size: 11px; padding: 2px 0; color: var(--ink-3); }
.engineCard .ec-row b { color: var(--ink); font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.railCollapsed .engineCard { display: none; }

/* ---- workspace ---- */
.workspace {
  grid-row: 2; grid-column: 2;
  overflow: auto; min-height: 0; position: relative;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(var(--grid-line-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line-major) 1px, transparent 1px);
  background-size:
    var(--grid-size) var(--grid-size),
    var(--grid-size) var(--grid-size),
    calc(var(--grid-size) * 4) calc(var(--grid-size) * 4),
    calc(var(--grid-size) * 4) calc(var(--grid-size) * 4);
  background-position: -1px -1px;
}
.shell.glow .workspace {
  background-image:
    radial-gradient(1100px 640px at 82% -10%, var(--glow-1), transparent 60%),
    radial-gradient(820px 560px at -6% 112%, var(--glow-2), transparent 55%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(var(--grid-line-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line-major) 1px, transparent 1px);
  background-size:
    100% 100%, 100% 100%,
    var(--grid-size) var(--grid-size),
    var(--grid-size) var(--grid-size),
    calc(var(--grid-size) * 4) calc(var(--grid-size) * 4),
    calc(var(--grid-size) * 4) calc(var(--grid-size) * 4);
  background-position: 0 0, 0 0, -1px -1px, -1px -1px, -1px -1px, -1px -1px;
}
.shell.noGrid .workspace { background-image: none; }
.shell.noGrid.glow .workspace {
  background-image:
    radial-gradient(1100px 640px at 82% -10%, var(--glow-1), transparent 60%),
    radial-gradient(820px 560px at -6% 112%, var(--glow-2), transparent 55%);
  background-size: 100% 100%, 100% 100%;
}

/* sheet registration crosshairs — pinned to the workspace cell, non-scrolling */
.sheetMarks { grid-row: 2; grid-column: 2; position: relative; pointer-events: none; z-index: 6; }
.shell.noGrid .sheetMarks { display: none; }
.sheetMarks i {
  position: absolute; width: 13px; height: 13px;
  color: var(--line-strong); opacity: 0.7;
}
.sheetMarks i::before, .sheetMarks i::after { content: ""; position: absolute; background: currentColor; }
.sheetMarks i::before { left: 6px; top: 0; width: 1px; height: 13px; }
.sheetMarks i::after { top: 6px; left: 0; height: 1px; width: 13px; }
.sheetMarks i.tl { left: 12px; top: 12px; }
.sheetMarks i.tr { right: 24px; top: 12px; }
.sheetMarks i.bl { left: 12px; bottom: 12px; }
.sheetMarks i.br { right: 24px; bottom: 12px; }

.work-inner { padding: 22px 26px 60px; max-width: 1480px; margin: 0 auto; }

.pageHead { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
.pageHead .ph-ic {
  width: 42px; height: 42px; border-radius: var(--r-sm); flex-shrink: 0;
  display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--phc, var(--acc)); box-shadow: 0 1px 0 var(--line) inset, 0 4px 12px -4px oklch(0 0 0 / 0.12);
}
.pageHead h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.pageHead .ph-lead { color: var(--ink-3); font-size: 13px; margin-top: 2px; max-width: 70ch; }
.pageHead .ph-act { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.crumb { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-4); margin-bottom: 12px; }
.crumb b { color: var(--ink-2); font-weight: 500; }
.crumb .sep { opacity: .5; }

/* =====================================================================
   SHARED COMPONENTS
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 7px 13px; border-radius: var(--r-sm); min-height: 44px;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink);
  font-size: 12.5px; font-weight: 500; transition: background-color 130ms ease-out, border-color 130ms ease-out, box-shadow 130ms ease-out; white-space: nowrap;
  outline: none; position: relative;
}
.btn:hover { background: var(--panel-3); border-color: var(--line-strong); }
.btn:active { transform: scale(0.96); }
.btn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 11.5px; min-height: auto; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--panel); color: var(--ink); }
.btn.ghost:active { transform: scale(0.96); }
.btn.primary {
  background: linear-gradient(180deg, var(--acc), var(--acc-dim));
  border-color: transparent; color: var(--acc-ink); font-weight: 600;
  box-shadow: 0 4px 14px -6px var(--acc-glow);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:active { transform: scale(0.96); }
.btn.primary:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.btn.danger { color: var(--alarm); border-color: oklch(0.68 0.17 25 / 0.4); background: var(--alarm-bg); }
.btn.danger:active { transform: scale(0.96); }
.btn svg { display: block; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow);
  animation: fadeInUp 280ms ease-out;
}
.card-hd {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.card-hd h3 { font-size: 13px; font-weight: 600; }
.card-hd .sub { font-size: 11px; color: var(--ink-3); }
.card-hd .hd-act { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-bd { padding: 14px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 500;
  background: var(--panel-3); color: var(--ink-2); border: 1px solid var(--line);
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--ok); background: var(--ok-bg); border-color: oklch(0.76 0.15 152 / 0.3); }
.chip.warn { color: var(--warn); background: var(--warn-bg); border-color: oklch(0.80 0.135 82 / 0.3); }
.chip.alarm { color: var(--alarm); background: var(--alarm-bg); border-color: oklch(0.68 0.17 25 / 0.3); }
.chip.info { color: var(--info); background: var(--info-bg); border-color: oklch(0.72 0.12 248 / 0.3); }
.chip.viol { color: var(--viol); background: var(--viol-bg); border-color: oklch(0.70 0.13 300 / 0.3); }
.chip.acc { color: var(--acc); background: var(--acc-glow); border-color: oklch(0.74 0.125 195 / 0.3); }

.tag {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  padding: 1px 6px; border-radius: var(--r-sm); background: var(--inset);
  border: 1px solid var(--line); color: var(--ink-2);
}

.bar { height: 6px; border-radius: 999px; background: var(--inset); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--acc); }

/* data table */
.dtable { width: 100%; border-collapse: collapse; font-size: 12px; }
.dtable th {
  text-align: left; font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); padding: 8px 12px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel-2); z-index: 1; white-space: nowrap;
}
.dtable td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dtable tbody tr { transition: background .1s; }
.dtable tbody tr:hover { background: var(--panel-2); }
.dtable tbody tr.sel { background: var(--acc-glow); }
.dtable tbody tr:last-child td { border-bottom: none; }
.tableWrap { overflow: auto; }

.field { display: grid; gap: 5px; }
.field > label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; color: var(--ink-3); }
.input, .select {
  width: 100%; background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 10px; color: var(--ink); outline: none; transition: border-color 130ms ease-out, background-color 130ms ease-out, box-shadow 130ms ease-out; font-size: 12.5px;
}
.input:focus, .select:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-glow); background: var(--bg-0); outline: none; }
.input::placeholder { color: var(--ink-4); }
select.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237c8aa3' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.kpi-spark { display: flex; align-items: flex-end; gap: 2px; height: 26px; }
.kpi-spark i { flex: 1; background: var(--acc); border-radius: 1px; opacity: .55; min-height: 2px; }

.segbar { display: inline-flex; background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.segbar button { padding: 5px 11px; border-radius: 3px; background: none; border: none; color: var(--ink-3); font-size: 11.5px; font-weight: 500; transition: background-color 120ms ease-out, color 120ms ease-out, box-shadow 120ms ease-out; min-height: 44px; outline: none; }
.segbar button.on { background: var(--panel-3); color: var(--ink); box-shadow: 0 1px 3px oklch(0 0 0 / .3); }
.segbar button:focus-visible { outline: 1px solid var(--acc); outline-offset: -1px; }

.empty { display: grid; place-items: center; gap: 8px; padding: 40px; color: var(--ink-4); text-align: center; }

.scroll-y { overflow-y: auto; }

/* generic grid helpers */
.grid { display: grid; gap: 16px; }
.grid > *, .row > * { min-width: 0; }
.work-inner { min-width: 0; }
.row { display: flex; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.center { align-items: center; }

/* tooltip-ish status dot */
.sdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sdot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.sdot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.sdot.alarm { background: var(--alarm); box-shadow: 0 0 0 3px var(--alarm-bg); }
.sdot.info { background: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }
.sdot.off { background: var(--ink-4); }

/* density tweak */
.shell { font-size: calc(13px * var(--density)); }

/* ambient glow toggle (opt-in) */
.shell.glow { }

/* =====================================================================
   MOBILE MODE — drawer navigation + single-column reflow
   Driven by the `.shell.mobile` class (matchMedia ≤820px OR force toggle).
   ===================================================================== */
.shell { position: relative; }

/* hamburger — hidden on desktop, shown in mobile */
.menuBtn {
  display: none; min-width: 44px; min-height: 44px; width: 36px; height: 36px; flex-shrink: 0;
  place-items: center; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-2);
  transition: border-color 140ms ease-out, color 140ms ease-out, background-color 140ms ease-out;
  outline: none; position: relative;
}
.menuBtn:hover { border-color: var(--line-2); color: var(--ink); background: var(--panel-2); }
.menuBtn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.menuBtn.open { color: var(--acc); border-color: var(--acc); background: var(--acc-glow); }

/* scrim — only materialises in mobile */
.railScrim { display: none; }

.shell.mobile { grid-template-columns: 1fr; }
.shell.mobile .menuBtn { display: grid; }

/* condensed top bar */
.shell.mobile .topbar { gap: 9px; padding: 0 10px; }
.shell.mobile .brand { width: auto; flex: 0 0 auto; gap: 8px; }
.shell.mobile .brandName { font-size: 14px; }
.shell.mobile .topProject { margin-left: 0; padding: 5px 9px; min-width: 0; max-width: 46vw; }
.shell.mobile .topProject .pj small { display: none; }
.shell.mobile .topProject .chev { display: none; }
.shell.mobile .busPill { display: none; }
.shell.mobile .hideMobile { display: none; }
.shell.mobile .topSpacer { flex: 1; }

/* rail becomes a slide-in drawer, anchored to the shell (works framed too) */
.shell.mobile .rail {
  position: absolute; top: var(--h-top); bottom: var(--h-status); left: 0;
  width: min(86vw, 318px); z-index: 60;
  transform: translateX(-101%); visibility: hidden;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .28s;
  box-shadow: var(--shadow-pop); border-right: 1px solid var(--line-2);
}
.shell.mobile.railOpen .rail {
  transform: translateX(0); visibility: visible;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s;
}
.shell.mobile .railScrim {
  display: block; position: absolute; top: var(--h-top); bottom: var(--h-status); left: 0; right: 0;
  background: oklch(0 0 0 / 0.52); z-index: 55; opacity: 0; pointer-events: none;
  transition: opacity .28s; backdrop-filter: blur(1px);
}
.shell.mobile.railOpen .railScrim { opacity: 1; pointer-events: auto; }

/* workspace fills the single column */
.shell.mobile .workspace { grid-column: 1; grid-row: 2; }
.shell.mobile .work-inner { padding: 16px 13px 52px; }
.shell.mobile .sheetMarks { display: none; }

/* page header reflows */
.shell.mobile .pageHead { gap: 13px; flex-wrap: wrap; margin-bottom: 14px; }
.shell.mobile .pageHead h1 { font-size: 18px; }
.shell.mobile .pageHead .ph-lead { font-size: 12px; }
.shell.mobile .pageHead .ph-ic { width: 38px; height: 38px; }

/* generic layout helpers collapse to one column on mobile */
.shell.mobile .work-inner .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)) !important; }
.shell.mobile .work-inner .row { flex-wrap: wrap; }
.shell.mobile .props { grid-template-columns: 1fr 1fr; }
.shell.mobile .statStrip { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: 1fr 1fr; }
.shell.mobile .steps,
.shell.mobile .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.shell.mobile .listCard { max-height: none; }

/* slightly larger touch targets in the drawer */
.shell.mobile .navItem { padding: 10px 10px; }
.shell.mobile .railSearch { padding: 9px 11px; }

/* =====================================================================
   MOBILE PREVIEW — phone frame around a forced-mobile shell (desktop demo)
   ===================================================================== */
#app:has(.shell.forceMobile) {
  display: grid; place-items: center;
  background:
    radial-gradient(900px 600px at 50% -10%, oklch(0.24 0.014 256), transparent 70%),
    oklch(0.115 0.009 256);
}
[data-theme="light"] #app:has(.shell.forceMobile) {
  background:
    radial-gradient(900px 600px at 50% -10%, oklch(0.9 0.006 256), transparent 70%),
    oklch(0.82 0.008 256);
}
.shell.forceMobile {
  position: relative;
  width: 404px; max-width: 96vw;
  height: 868px; max-height: 95vh;
  margin: auto; overflow: hidden;
  border-radius: 34px;
  box-shadow:
    0 0 0 2px oklch(0.32 0.01 256),
    0 0 0 11px oklch(0.10 0.008 256),
    0 0 0 13px oklch(0.34 0.012 256),
    0 60px 140px -34px oklch(0 0 0 / 0.85);
}
/* notch / camera pill */
.shell.forceMobile::before {
  content: ""; position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
  width: 118px; height: 7px; border-radius: 999px;
  background: oklch(0.10 0.008 256); z-index: 80; pointer-events: none;
}
.shell.forceMobile .topbar { padding-top: 6px; }
