:root{
  --bg:#f7f7f7;
  --surface:#ffffff;
  --surface-2:#e8e8e8;
  --line:#e8e8e8;
  --line-strong:#c2c2c2;
  --ink:#1a1a1a;
  --ink-2:#636363;
  --accent:#024ad8;
  --accent-strong:#0e3191;
  --accent-bright:#296ef9;
  --accent-soft:#c9e0fc;
  --gold:#356373;
  --good:#2f9e57;
  --good-soft:#e2f3e7;
  --warn:#c47a12;
  --warn-soft:#fce8c8;
  --bad:#b3262b;
  --bad-soft:#f9d4d2;
  --done:#636363;
  --done-soft:#e8e8e8;
  --shadow: 0 2px 8px rgba(26,26,26,.08);
  --shadow-modal: 0 8px 24px rgba(26,26,26,.12);
  --radius: 16px;
  --radius-sm: 4px;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#1a1a1a;
    --surface:#292929;
    --surface-2:#333333;
    --line:#3d3d3d;
    --line-strong:#636363;
    --ink:#ffffff;
    --ink-2:#c2c2c2;
    --accent:#296ef9;
    --accent-strong:#c9e0fc;
    --accent-bright:#296ef9;
    --accent-soft:#0e3191;
    --gold:#8ebdce;
    --good:#4cbf78;
    --good-soft:#173423;
    --warn:#e8a54b;
    --warn-soft:#4a3210;
    --bad:#f28b8b;
    --bad-soft:#5a1313;
    --done:#8b96a0;
    --done-soft:#333333;
    --shadow: 0 2px 8px rgba(0,0,0,.35);
    --shadow-modal: 0 8px 24px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"]{
  --bg:#1a1a1a;
  --surface:#292929;
  --surface-2:#333333;
  --line:#3d3d3d;
  --line-strong:#636363;
  --ink:#ffffff;
  --ink-2:#c2c2c2;
  --accent:#296ef9;
  --accent-strong:#c9e0fc;
  --accent-bright:#296ef9;
  --accent-soft:#0e3191;
  --gold:#8ebdce;
  --good:#4cbf78;
  --good-soft:#173423;
  --warn:#e8a54b;
  --warn-soft:#4a3210;
  --bad:#f28b8b;
  --bad-soft:#5a1313;
  --done:#8b96a0;
  --done-soft:#333333;
  --shadow: 0 2px 8px rgba(0,0,0,.35);
  --shadow-modal: 0 8px 24px rgba(0,0,0,.5);
}

*{ box-sizing:border-box; }
html{ color-scheme: light dark; }
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:"Manrope", system-ui, sans-serif;
  padding:0;
  -webkit-user-select:text;
}
h1,h2,h3{ font-family:"Manrope", sans-serif; font-weight:500; text-wrap:balance; margin:0; }
.mono{ font-family:"IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
a{ color:var(--accent); }
:focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
}
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration:.01ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.01ms !important;
    scroll-behavior:auto !important;
  }
}

/* ---------- app chrome ---------- */
.app-chrome{
  position:sticky; top:0; z-index:20;
  background:var(--bg);
  border-bottom:1px solid var(--line);
}
.topbar{
  padding:10px 20px;
  display:flex; flex-wrap:wrap; gap:10px 16px;
  align-items:center;
  width:100%; box-sizing:border-box;
  -webkit-app-region: drag;
}
.topbar button, .topbar input, .topbar nav{ -webkit-app-region: no-drag; }
.brand{ display:flex; align-items:center; gap:10px; flex:none; }
.brand .brand-logo{
  flex:none; height:32px; width:32px; display:block;
  border-radius:8px;
}
.brand .brand-name{
  font-size:17px; font-weight:700; letter-spacing:.15px; color:var(--ink);
}
.app-nav{
  display:flex; flex-wrap:wrap; gap:4px;
  flex:1 1 280px;
  -webkit-app-region: no-drag;
}
.app-nav button{
  font-family:inherit; cursor:pointer;
  background:transparent; color:var(--ink-2);
  border:1px solid transparent; border-radius:var(--radius-sm);
  padding:7px 12px; font-size:12px; font-weight:600;
  text-transform:uppercase; letter-spacing:.4px;
}
.app-nav button:hover{ color:var(--accent); border-color:var(--line-strong); }
.app-nav button.active{
  color:var(--accent); background:var(--accent-soft);
  border-color:color-mix(in srgb, var(--accent) 35%, var(--line));
}

#view-dashboard, #view-route, #view-wipsummary, #view-flow{ width:100%; }

.app-clock{
  display:flex; align-items:baseline; gap:8px;
  font-family:'IBM Plex Mono', ui-monospace, monospace;
  padding:0 2px; flex:none;
}
.app-clock #clockTime{ font-size:14px; font-weight:600; color:var(--ink); letter-spacing:.02em; font-variant-numeric:tabular-nums; }
.app-clock .clock-date{ font-size:11px; color:var(--ink-2); }

.importer{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-left:auto; }
.file-btn, .ghost-btn{ font-family:inherit; cursor:pointer; }
.file-btn{
  display:inline-flex; align-items:center; gap:8px;
  background:var(--accent); color:#fff;
  border:none; border-radius:var(--radius-sm);
  padding:8px 14px; font-size:12px; font-weight:600;
  text-transform:uppercase; letter-spacing:.4px;
}
.file-btn:hover{ background:var(--accent-strong); }
.file-btn.small{ padding:6px 12px; font-size:11px; }
.ghost-btn{
  background:transparent; color:var(--ink);
  border:1px solid var(--line-strong); border-radius:var(--radius-sm);
  padding:7px 12px; font-size:12px; font-weight:600;
  text-transform:uppercase; letter-spacing:.4px;
}
.ghost-btn:hover{ border-color:var(--accent); color:var(--accent); }
.ghost-btn.small{ padding:6px 12px; font-size:11px; }
.ghost-btn:disabled{ opacity:.4; cursor:not-allowed; }
.file-status{ font-size:12.5px; color:var(--ink-2); }
.file-status.warn{ color:var(--warn); }

.source-bar{
  display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px;
  padding:6px 20px 8px; font-size:12.5px; color:var(--ink-2);
  background:var(--surface);
  border-top:1px solid var(--line);
}
.source-bar .src{
  color:var(--accent); font-weight:600; font-size:11.5px;
  max-width:min(42ch, 100%);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.src-badge{
  font-size:10px; font-weight:700; letter-spacing:.04em; text-transform:uppercase;
  padding:2px 7px; border-radius:999px; flex:none;
  background:var(--accent-soft); color:var(--accent);
}
.src-badge.live{ background:var(--good-soft); color:var(--good); }
.source-bar #sourceMeta{ color:var(--ink-2); }
.source-bar .file-status{ color:var(--accent); margin-left:auto; }

main{ width:100%; box-sizing:border-box; padding:18px 20px 32px; display:flex; flex-direction:column; gap:22px; }

.sample-banner{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  background:var(--surface-2); border:1px solid var(--line-strong);
  color:var(--ink); border-radius:var(--radius-sm); padding:10px 14px; font-size:13px;
}
.sample-banner b{ color:var(--accent); }
[hidden]{ display:none !important; }

.dropzone{
  position:fixed; inset:0; z-index:50;
  display:none; align-items:center; justify-content:center;
  background:color-mix(in srgb, var(--accent) 12%, transparent);
  backdrop-filter: blur(2px);
  border:3px dashed var(--accent);
  font-size:18px; font-weight:600; color:var(--accent);
  pointer-events:none;
}
.dropzone.active{ display:flex !important; }

.welcome-screen{
  min-height:100vh; box-sizing:border-box;
  display:flex; align-items:center; justify-content:center; padding:24px;
}
.welcome-card{
  max-width:420px; width:100%; text-align:center;
  display:flex; flex-direction:column; align-items:center; gap:14px;
}
.welcome-logo{ width:56px; height:56px; border-radius:14px; }
.welcome-card h1{ font-size:22px; font-weight:700; margin:0; color:var(--ink); }
.welcome-sub{ font-size:13.5px; line-height:1.5; color:var(--ink-2); margin:0; }
.welcome-actions{ display:flex; gap:10px; flex-wrap:wrap; justify-content:center; margin-top:6px; }
.welcome-hint{ font-size:12px; color:var(--ink-2); margin:2px 0 0; }
.welcome-status{ font-size:12.5px; color:var(--warn); margin:0; min-height:1em; }

section{ display:flex; flex-direction:column; gap:12px; }
.section-head{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.section-head h2{ font-size:20px; font-weight:500; }
.section-num{ color:var(--accent); font-weight:700; margin-right:8px; }
.section-note{ font-size:12.5px; color:var(--ink-2); max-width:60ch; }

/* ---------- KPI tiles ---------- */
.kpi-row{
  display:grid; gap:12px;
  grid-template-columns:repeat(auto-fit, minmax(150px,1fr));
}
.kpi{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px 16px;
  display:flex; flex-direction:column; gap:6px;
}
.kpi .label{ font-size:11.5px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-2); font-weight:500; }
.kpi .value{ font-size:26px; font-weight:500; font-family:"IBM Plex Mono", monospace; overflow-wrap:anywhere; }
.kpi .value.compact{ font-size:16px; line-height:1.25; }
.kpi .sub{ font-size:12px; color:var(--ink-2); }
.kpi.accent{ border-color:color-mix(in srgb, var(--accent) 40%, var(--line)); }
.kpi.accent .value{ color:var(--accent); }

/* ---------- two column ---------- */
.twocol{ display:grid; grid-template-columns:1.3fr 1fr; gap:18px; align-items:start; }
@media (max-width:820px){ .twocol{ grid-template-columns:1fr; } }

.card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:20px;
  display:flex; flex-direction:column; gap:12px;
}

.bars{ display:flex; flex-direction:column; gap:9px; }
.bar-row{ display:grid; grid-template-columns:96px 1fr auto; align-items:center; gap:10px; font-size:13px; }
.bar-row .name{ color:var(--ink-2); font-weight:500; }
.bar-track{ background:var(--surface-2); border-radius:6px; height:16px; overflow:hidden; }
.bar-fill{ height:100%; background:var(--accent); border-radius:6px 0 0 6px; transition:width .4s ease; }
.bar-row .num{ font-family:"IBM Plex Mono", monospace; color:var(--ink); white-space:nowrap; font-size:12.5px; }
.bar-row .num .pct{ color:var(--ink-2); margin-left:5px; }

.stack{ height:26px; border-radius:7px; overflow:hidden; display:flex; border:1px solid var(--line); }
.stack > div{ height:100%; }
.legend{ display:flex; flex-wrap:wrap; gap:10px 16px; font-size:12.5px; }
.legend .item{ display:flex; align-items:center; gap:7px; color:var(--ink-2); }
.legend .sw{ width:10px; height:10px; border-radius:3px; flex:none; }

.thresh-row{ display:flex; gap:16px; flex-wrap:wrap; font-size:12.5px; color:var(--ink-2); align-items:center; }
.thresh-row label{ display:flex; align-items:center; gap:6px; }
.thresh-row input{
  width:46px; font-family:"IBM Plex Mono",monospace; font-size:12.5px;
  background:var(--surface-2); border:1px solid var(--line-strong); border-radius:var(--radius-sm);
  color:var(--ink); padding:3px 5px;
}

/* ---------- risk summary chips ---------- */
.risk-chips{ display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px; }
.chip{
  font-family:inherit; text-align:left; cursor:pointer;
  border-radius:8px; padding:12px 14px; display:flex; flex-direction:column; gap:4px;
  border:1px solid var(--line); background:var(--surface); color:inherit;
}
.chip:hover{ border-color:var(--line-strong); }
.chip.is-selected{ outline:2px solid var(--accent); outline-offset:1px; box-shadow:inset 0 0 0 1px var(--accent); }
.chip .n{ font-family:"IBM Plex Mono",monospace; font-size:22px; font-weight:600; }
.chip .l{ font-size:11.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-2); }
.chip.bottleneck{ background:var(--bad-soft); }
.chip.bottleneck .n{ color:var(--bad); }
.chip.stagnant{ background:var(--bad-soft); }
.chip.stagnant .n{ color:var(--bad); }
.chip.priority{ background:var(--accent-soft); }
.chip.priority .n{ color:var(--accent-strong); }
.chip.watch{ background:var(--warn-soft); }
.chip.watch .n{ color:var(--warn); }
.chip.total{ background:var(--accent-soft); border-color:color-mix(in srgb, var(--accent) 40%, var(--line)); }
.chip.total .n{ color:var(--accent); }
.chip.total .l{ color:var(--accent-strong); }

/* ---------- tables ---------- */
.table-wrap{ overflow:auto; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.table-wrap-tall{ max-height:min(52vh, 520px); }
table{ border-collapse:collapse; width:100%; font-size:13px; min-width:640px; }
thead th{
  text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.05em;
  color:var(--ink-2); font-weight:600; padding:10px 12px; border-bottom:1px solid var(--line);
  background:var(--surface-2); position:sticky; top:0;
  white-space:nowrap;
}
tbody td{ padding:9px 12px; border-bottom:1px solid var(--line); vertical-align:middle; }
tbody tr:last-child td{ border-bottom:none; }
tbody tr:hover{ background:var(--surface-2); }
td.num, th.num{ text-align:right; font-family:"IBM Plex Mono",monospace; }
td.lot{ font-family:"IBM Plex Mono",monospace; font-size:12.5px; }

.pill{
  display:inline-flex; align-items:center; gap:5px;
  padding:3px 9px; border-radius:9999px; font-size:11.5px; font-weight:600;
  white-space:nowrap;
}
.pill.bottleneck{ background:var(--bad-soft); color:var(--bad); }
.pill.stagnant{ background:var(--bad-soft); color:var(--bad); }
.pill.priority{ background:var(--accent-soft); color:var(--accent-strong); }
.pill.watch{ background:var(--warn-soft); color:var(--warn); }
.pill.ok{ background:var(--good-soft); color:var(--good); }
.pill.done{ background:var(--done-soft); color:var(--done); }
.stripe{ box-shadow: inset 3px 0 0 0 var(--bad); }
.stripe.watch{ box-shadow: inset 3px 0 0 0 var(--warn); }

/* ---------- layer x process matrix ---------- */
.matrix-card{ padding:16px; gap:14px; }
.matrix-toolbar{
  display:flex; flex-wrap:wrap; gap:8px 12px; align-items:center;
  font-size:12.5px; color:var(--ink-2);
}
.matrix-toolbar #routeStatus{ flex:1 1 180px; min-width:0; }
.matrix-toggle{ display:flex; align-items:center; gap:6px; cursor:pointer; user-select:none; }
.matrix-toggle input{ accent-color:var(--accent); }
.matrix-scope{ display:flex; gap:0; margin-left:auto; border:1px solid var(--line-strong); border-radius:var(--radius-sm); overflow:hidden; }
.matrix-scope button{
  font-family:inherit; cursor:pointer; background:transparent; color:var(--ink-2);
  border:none; padding:6px 12px; font-size:11.5px; font-weight:600;
  text-transform:uppercase; letter-spacing:.4px;
}
.matrix-scope button + button{ border-left:1px solid var(--line-strong); }
.matrix-scope button.active{ background:var(--accent-soft); color:var(--accent); }
.matrix-body{ display:grid; grid-template-columns:minmax(0,1fr) 220px; gap:14px; align-items:start; }
@media (max-width:980px){ .matrix-body{ grid-template-columns:1fr; } }
.matrix-side{
  display:flex; flex-direction:column; gap:10px; min-width:0;
  position:sticky; top:96px;
}
.matrix-legend-title{
  font-size:11.5px; font-weight:700; color:var(--ink-2); letter-spacing:.04em; text-transform:uppercase;
}
.matrix-legend{ display:flex; flex-direction:column; flex-wrap:wrap; gap:8px; font-size:12.5px; color:var(--ink-2); }
.matrix-legend .item{ display:flex; align-items:center; gap:6px; }
.matrix-legend .dot{ width:9px; height:9px; border-radius:50%; flex:none; }
.matrix-detail{
  border:1px solid var(--line); border-radius:var(--radius-sm);
  background:var(--surface-2); padding:10px 12px; min-height:88px;
  font-size:12.5px;
}
.matrix-detail-head{
  font-weight:600; color:var(--ink); margin-bottom:8px;
  display:flex; justify-content:space-between; gap:8px; flex-wrap:wrap;
}
.matrix-detail-head span{ color:var(--ink-2); font-weight:500; font-family:"IBM Plex Mono",monospace; font-size:11.5px; }
.matrix-lot-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; max-height:360px; overflow:auto; }
.matrix-lot-list li{ display:flex; gap:8px; align-items:flex-start; }
.matrix-lot-list .dot{ width:8px; height:8px; border-radius:50%; flex:none; margin-top:5px; }
.matrix-lot-list .lot{ font-family:"IBM Plex Mono",monospace; font-size:12px; }
.matrix-lot-list .meta{ font-size:11.5px; color:var(--ink-2); }
.matrix-other{
  border-top:1px solid var(--line); padding-top:12px;
  display:flex; flex-direction:column; gap:8px;
}
.matrix-other-head{ font-size:12.5px; color:var(--ink-2); }
.matrix-other-chips{ display:flex; flex-wrap:wrap; gap:8px; }
.matrix-other-chip{
  font-family:inherit; cursor:pointer;
  background:var(--surface-2); color:var(--ink);
  border:1px solid var(--line-strong); border-radius:999px;
  padding:5px 10px; font-size:12px;
}
.matrix-other-chip span{ font-family:"IBM Plex Mono",monospace; color:var(--accent); margin-left:4px; }
.matrix-wrap{ overflow:auto; border:1px solid var(--ink); border-radius:var(--radius-sm); max-height:min(70vh, 640px); background:var(--surface); }
.matrix{ border-collapse:collapse; font-size:12px; min-width:100%; }
.matrix th, .matrix td{ border:1px solid var(--ink); padding:6px 7px; vertical-align:middle; }
.matrix thead th{
  position:sticky; top:0; z-index:2;
  background:var(--surface); color:var(--ink);
  font-size:10.5px; text-transform:none; letter-spacing:0; font-weight:600;
  white-space:normal; min-width:72px; max-width:92px; text-align:center;
  line-height:1.25; height:64px;
}
.matrix thead th.matrix-layer-head{ left:0; z-index:3; text-align:left; min-width:88px; max-width:none; }
.matrix tbody th{
  position:sticky; left:0; z-index:1;
  background:var(--surface); text-align:left; font-size:13px; font-weight:700;
  white-space:nowrap; min-width:88px;
}
.matrix td{ min-width:72px; min-height:44px; height:44px; text-align:center; cursor:pointer; }
.matrix td.empty{ background:transparent; }
.matrix td:hover{ background:var(--surface-2); }
.matrix td.is-selected{ outline:2px solid var(--accent); outline-offset:-2px; background:var(--accent-soft); }
.matrix .dot-cluster{ display:flex; flex-wrap:wrap; gap:4px; justify-content:center; align-items:center; }
.matrix .dot-cluster .dot{ width:8px; height:8px; border-radius:50%; flex:none; }
.matrix .dot-cluster .more{ font-size:10px; color:var(--ink-2); font-family:"IBM Plex Mono",monospace; margin-left:2px; }

/* ---------- WIP summary pivot (Excel-style) ---------- */
.pivot-wrap{ overflow:auto; border:1px solid var(--line-strong); border-radius:var(--radius-sm); max-height:min(78vh, 720px); background:var(--surface); }
.pivot{ border-collapse:collapse; font-size:12px; min-width:100%; }
.pivot th, .pivot td{ border:1px solid #b1b1b1; padding:4px 7px; }
.pivot thead th{
  position:sticky; top:0; z-index:2;
  background:#f2f2f2; color:var(--ink);
  font-size:10.5px; text-transform:none; letter-spacing:0; font-weight:600;
  white-space:normal; min-width:64px; max-width:88px; text-align:center;
  line-height:1.25; height:52px;
}
.pivot thead .pivot-title-row th{
  text-align:left; font-size:12px; height:auto; max-width:none;
  background:#fff; color:var(--ink);
}
.pivot thead .pivot-fam, .pivot thead .pivot-draw, .pivot thead .pivot-layer{
  text-align:left; min-width:120px; max-width:none; white-space:nowrap;
}
.pivot tbody th{
  text-align:left; font-weight:500; background:var(--surface);
  white-space:nowrap; font-size:12px;
}
.pivot tbody th.pivot-fam{ position:sticky; left:0; z-index:1; min-width:140px; }
.pivot tbody th.pivot-draw{ position:sticky; left:140px; z-index:1; min-width:150px; }
.pivot tbody th.pivot-layer{ min-width:110px; }
.pivot td.num{ font-family:"IBM Plex Mono",monospace; font-size:12px; }
.pivot td.pivot-empty{ background:transparent; }
.pivot-twist{
  font-family:inherit; cursor:pointer; background:transparent; border:none;
  color:var(--ink-2); padding:0 6px 0 0; font-size:11px; line-height:1;
}
.pivot-twist:hover{ color:var(--accent); }
.pivot-leaf:hover td, .pivot-leaf:hover th{ background:var(--surface-2); }
.pivot-drawing-total th, .pivot-drawing-total td{
  background:#ffe566; font-weight:600;
}
.pivot-family-total th, .pivot-family-total td{
  background:#f4b942; font-weight:700;
}
.pivot-grand th, .pivot-grand td{
  background:#5dade2; font-weight:700; color:#083344;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .pivot thead th{ background:#333; color:var(--ink); }
  :root:not([data-theme="light"]) .pivot thead .pivot-title-row th{ background:var(--surface); }
  :root:not([data-theme="light"]) .pivot th, :root:not([data-theme="light"]) .pivot td{ border-color:#555; }
  :root:not([data-theme="light"]) .pivot-drawing-total th,
  :root:not([data-theme="light"]) .pivot-drawing-total td{ background:#6b5a12; color:#fff; }
  :root:not([data-theme="light"]) .pivot-family-total th,
  :root:not([data-theme="light"]) .pivot-family-total td{ background:#8a5a12; color:#fff; }
  :root:not([data-theme="light"]) .pivot-grand th,
  :root:not([data-theme="light"]) .pivot-grand td{ background:#1f4e79; color:#fff; }
}

.matrix .lot-cell{ font-family:"IBM Plex Mono",monospace; font-size:11px; line-height:1.6; }
.matrix .lot-cell .more{ font-size:10px; color:var(--ink-2); font-style:italic; margin-top:2px; }
#lotMatrixWrap td{ min-width:110px; }

.table-toolbar{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; justify-content:space-between; }
.search{
  background:var(--surface); border:1px solid var(--line-strong); border-radius:var(--radius-sm);
  padding:10px 12px; font-size:13px; color:var(--ink); font-family:inherit;
  min-width:220px;
}
.search:focus-visible{ outline:none; border-color:var(--accent); }
.search::placeholder{ color:var(--ink-2); }
.count-note{ font-size:12px; color:var(--ink-2); }

th.sortable{ cursor:pointer; user-select:none; }
th.sortable:hover{ color:var(--ink); }
th.sortable .arrow{ opacity:.4; margin-left:3px; }
th.sortable.active .arrow{ opacity:1; color:var(--accent); }

details.raw summary{
  cursor:pointer; font-size:13px; font-weight:600; color:var(--ink-2);
  padding:4px 0; list-style:none;
}
details.raw summary::-webkit-details-marker{ display:none; }
details.raw summary::before{ content:"▸ "; color:var(--accent); }
details.raw[open] summary::before{ content:"▾ "; }

.notes{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:24px; font-size:12.5px; color:var(--ink-2); line-height:1.6;
  box-shadow:var(--shadow);
}
.notes b{ color:var(--ink); }
.notes ul{ margin:8px 0 0; padding-left:18px; }

.empty-cell{ color:var(--ink-2); font-style:italic; }
.priority-empty .n{ font-family:"IBM Plex Mono",monospace; font-size:26px; font-weight:600; color:var(--ink); }
.priority-empty .l{ font-size:11.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-2); margin-bottom:8px; }
.priority-empty p{ margin:0; font-size:13px; color:var(--ink-2); line-height:1.45; }

/* ---------- flow analyses ---------- */
.snap-tape{
  display:flex; gap:8px; overflow-x:auto; align-items:flex-end;
  padding:4px 2px 2px; min-height:110px;
}
.snap-day{
  display:flex; flex-direction:column; align-items:center; gap:3px;
  min-width:42px; flex:none; color:var(--ink-2); font-size:10.5px;
}
.snap-val{ font-family:"IBM Plex Mono",monospace; font-size:11px; color:var(--ink); font-weight:600; }
.snap-col{
  width:22px; height:72px; display:flex; align-items:flex-end;
  background:var(--surface-2); border-radius:4px; overflow:hidden;
}
.snap-bar{ width:100%; background:var(--accent); border-radius:3px 3px 0 0; min-height:4px; }
.snap-date{ font-family:"IBM Plex Mono",monospace; }
.snap-meta{ font-size:10px; }
.snap-meta.stagnant{ color:var(--bad); }

.cc-bubbles{
  display:flex; flex-wrap:wrap; gap:14px 18px; align-items:flex-end;
  padding-bottom:8px; margin-bottom:8px; border-bottom:1px solid var(--line);
}
.cc-bubble{ display:flex; flex-direction:column; align-items:center; gap:6px; min-width:72px; }
.cc-dot{
  display:flex; align-items:center; justify-content:center;
  background:var(--accent-soft); color:var(--accent-strong);
  border-radius:50%; font-family:"IBM Plex Mono",monospace;
  font-size:12px; font-weight:600; line-height:1;
}
.cc-name{ font-size:11px; color:var(--ink-2); text-align:center; max-width:110px; line-height:1.3; }

.yield-block + .yield-block{ margin-top:14px; }
.yield-title{ font-size:11.5px; font-weight:600; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-2); margin-bottom:6px; }
.yield-strip{ min-width:0; }
.yield-strip th, .yield-strip td{ padding:6px 8px; }
tr.yield-low td.num{ color:var(--bad); font-weight:600; }

/* ---------- reading guide popup ---------- */
.guide-overlay{
  position:fixed; inset:0; z-index:80;
  display:flex; align-items:center; justify-content:center;
  padding:24px;
  background:rgba(26,26,26,.52);
  backdrop-filter:blur(3px);
}
.guide-overlay[hidden]{ display:none !important; }
.guide-popup{
  width:min(640px, 100%);
  max-height:min(560px, calc(100vh - 48px));
  background:var(--surface); color:var(--ink);
  border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow-modal);
  display:flex; flex-direction:column;
  animation:guidePop .16s ease;
}
@keyframes guidePop{
  from{ opacity:0; transform:translateY(10px) scale(.98); }
  to{ opacity:1; transform:none; }
}
.guide-head{
  display:flex; align-items:flex-start; gap:12px;
  padding:18px 18px 14px 20px; border-bottom:1px solid var(--line);
  flex:none;
}
.guide-head-text{ flex:1; min-width:0; }
.guide-head-text h2{ font-size:16px; margin:0 0 2px; font-weight:600; }
.guide-head-text p{ margin:0; font-size:12.5px; color:var(--ink-2); line-height:1.4; }
.guide-close{
  flex:none; width:32px; height:32px; padding:0; margin:-4px -4px 0 0;
  border:none; border-radius:var(--radius-sm); cursor:pointer;
  background:transparent; color:var(--ink-2); font-size:22px; line-height:1;
  font-family:inherit;
}
.guide-close:hover{ background:var(--surface-2); color:var(--ink); }
.guide-layout{
  display:grid; grid-template-columns:148px minmax(0,1fr);
  min-height:0; flex:1;
}
.guide-nav{
  display:flex; flex-direction:column; gap:2px;
  padding:10px 8px; border-right:1px solid var(--line);
  background:var(--surface-2); overflow:auto;
}
.guide-nav button{
  font-family:inherit; cursor:pointer; text-align:left;
  background:transparent; color:var(--ink-2);
  border:none; border-radius:var(--radius-sm);
  padding:8px 10px; font-size:12px; font-weight:600;
}
.guide-nav button:hover{ color:var(--accent); background:var(--surface); }
.guide-nav button.active{
  color:var(--accent); background:var(--surface);
  box-shadow:inset 2px 0 0 var(--accent);
}
.guide-body{
  padding:16px 20px 18px; overflow:auto; font-size:13.5px; line-height:1.55;
  min-height:0;
}
.guide-body h3{ font-size:14px; margin:0 0 8px; }
.guide-body p, .guide-body ul{ margin:0 0 10px; color:var(--ink); }
.guide-body ul{ padding-left:18px; }
.guide-body li{ margin:5px 0; }
.guide-body code{
  font-family:"IBM Plex Mono", monospace; font-size:12px;
  background:var(--surface-2); padding:1px 5px; border-radius:3px;
}
.guide-foot{
  flex:none; display:flex; justify-content:flex-end;
  padding:10px 16px 14px; border-top:1px solid var(--line);
}
.guide-foot[hidden]{ display:none !important; }
.guide-foot .file-btn{ padding:8px 16px; font-size:12px; }
@media (max-width: 560px){
  .guide-layout{ grid-template-columns:1fr; }
  .guide-nav{
    flex-direction:row; flex-wrap:wrap; gap:4px;
    border-right:none; border-bottom:1px solid var(--line);
  }
  .guide-nav button.active{ box-shadow:none; background:var(--accent-soft); }
}

/* ---------- lot action tracker ---------- */
.action-filter, .action-form input, .action-form select, .action-form textarea{
  font:inherit; color:var(--ink); background:var(--surface);
  border:1px solid var(--line-strong); border-radius:6px; padding:9px 10px;
}
.action-filter{ font-size:12px; max-width:100%; }
.action-help, .action-feedback{ font-size:12px; color:var(--ink-2); margin:8px 0 12px; }
.action-feedback:empty, #actionError:empty{ display:none; }
.action-lot{
  font:inherit; color:var(--accent); background:none; border:0; padding:4px 0;
  cursor:pointer; text-decoration:underline; text-underline-offset:3px; text-align:left;
}
.action-lot:focus-visible, .action-form :focus-visible, .action-filter:focus-visible{
  outline:2px solid var(--accent); outline-offset:3px;
}
.action-cell{ min-width:210px; max-width:320px; }
.action-summary{ font-size:12px; margin-top:5px; white-space:normal; overflow-wrap:anywhere; }
.action-next{ color:var(--ink-2); display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.action-muted{ color:var(--ink-2); font-size:12px; }
.action-overdue{ color:var(--bad); font-weight:600; }
.action-dialog{
  position:fixed; inset:0 0 0 auto; margin:0; padding:0;
  width:min(540px, 100vw); height:100dvh; max-height:100dvh; max-width:100vw;
  border:0; border-left:1px solid var(--line); background:var(--surface); color:var(--ink);
  box-shadow:var(--shadow-modal); overflow:auto;
}
.action-dialog::backdrop{ background:rgba(26,26,26,.45); }
.action-dialog .guide-head{ position:sticky; top:0; z-index:1; background:var(--surface); }
.action-dialog .guide-head-text{ overflow-wrap:anywhere; }

.confirm-dialog{
  margin:auto; padding:0; border:1px solid var(--line-strong); border-radius:var(--radius);
  width:min(460px, 92vw); max-height:85vh; overflow:auto;
  background:var(--surface); color:var(--ink); box-shadow:var(--shadow-modal);
}
.confirm-dialog::backdrop{ background:rgba(26,26,26,.45); }
.confirm-dialog .guide-head{ padding:18px 20px 14px; border-bottom:1px solid var(--line); }
.confirm-body{ padding:16px 20px; font-size:13px; }
.confirm-body ul{ margin:8px 0 0; padding-left:18px; display:flex; flex-direction:column; gap:4px; color:var(--warn); }
.confirm-dialog .action-form-footer{ padding:14px 20px 18px; border-top:1px solid var(--line); }
.action-form{ padding:20px; display:flex; flex-direction:column; gap:18px; font-size:13px; }
.action-form-grid{ display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.action-form label{ display:flex; flex-direction:column; gap:7px; font-weight:600; min-width:0; }
.action-form input, .action-form select, .action-form textarea{ width:100%; min-width:0; font-weight:400; }
.action-form textarea{ resize:vertical; }
.action-form p{ margin:0; }
.action-form-footer{ display:flex; justify-content:flex-end; gap:10px; padding-top:14px; border-top:1px solid var(--line); }
.action-history h3{ font-size:13px; margin-bottom:10px; }
.action-history ol{ list-style:none; padding:0; margin:0; max-height:220px; overflow:auto; }
.action-history li + li{ margin-top:12px; border-top:1px solid var(--line); padding-top:12px; }
.action-history time{ font-size:11px; color:var(--ink-2); }
.action-history li p{ margin-top:5px; white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.5; }
.action-discard{ padding:12px; border:1px solid var(--line-strong); border-radius:8px; }
.action-discard p{ margin-bottom:10px; }
.action-discard[hidden]{ display:none; }
@media (max-width:560px){ .action-form-grid{ grid-template-columns:1fr; } }

footer{
  display:flex; align-items:center; justify-content:center;
  flex-wrap:wrap; text-align:center;
  gap:6px 8px;
  padding:10px 24px;
  border-top:1px solid var(--line);
  margin-top:12px;
}
.footer-mark{
  width:16px; height:16px; flex:none;
  border-radius:4px;
}
.footer-text{
  font-size:11.5px; line-height:1.4; color:var(--ink-2);
}
.footer-text strong{ color:var(--ink); font-weight:600; }
.footer-note{ margin-left:6px; opacity:.85; }
