
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --border: #dde1e7; --text: #1d2330; --muted: #667085;
  --accent: #a3294f; --accent-text: #ffffff; --focus: #3b6fd8;
  --lane-purchasing: #d9822b; --lane-operations: #1f8a7a; --lane-sales: #7a4fc4; --lane-scm: #2f6fd1;
  --sev-error: #c93636; --sev-warn: #c77a00; --sev-info: #5a6b85;
  --sev-error-bg: #fdecec; --sev-warn-bg: #fff4e0; --sev-info-bg: #eef1f6;
  --changed: #fff6d6; --good: #1f8a4c; --bad: #c93636;
  --truck: #8a6d3b; --sea: #2f7fbf; --flow: #8792a2; --off: #b8bec8;
  --team: #2f6fd1; --team-bg: #e6eefc; --sandbox: #c77a00; --sandbox-bg: #fff0d1;  
  --past: #6b5b95; --past-bg: #ece8f5;  
  --p1: #e07b39; --p2: #d4a017; --p3: #c2457a; --p4: #2f8f9d; --p5: #5b7bd6; --p6: #8a5cc2;
  --tint: 12%;  
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --surface: #1b1f27; --surface-2: #232834; --border: #343b4a; --text: #e6e9ef; --muted: #98a1b3;
    --accent: #d2577d; --focus: #7aa2ff;
    --sev-error-bg: #3a1e22; --sev-warn-bg: #3a2c12; --sev-info-bg: #232a36; --changed: #3a3418;
    --flow: #6c7689; --off: #4a5162;
    --team: #7aa2ff; --team-bg: #1b2a44; --sandbox: #f0a33a; --sandbox-bg: #3a2c12;
    --past: #b3a3e0; --past-bg: #2a2440;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --surface: #1b1f27; --surface-2: #232834; --border: #343b4a; --text: #e6e9ef; --muted: #98a1b3;
  --accent: #d2577d; --focus: #7aa2ff;
  --sev-error-bg: #3a1e22; --sev-warn-bg: #3a2c12; --sev-info-bg: #232a36; --changed: #3a3418;
  --flow: #6c7689; --off: #4a5162;
  --team: #7aa2ff; --team-bg: #1b2a44; --sandbox: #f0a33a; --sandbox-bg: #3a2c12;
  --past: #b3a3e0; --past-bg: #2a2440;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); display: flex; flex-direction: column; overflow: hidden;
  word-break: keep-all; overflow-wrap: break-word; }   
.top, .tabs, .mode-banner { flex: none; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }


.top { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand h1 { font-size: 18px; }
.brand .muted { font-size: 12px; }
.meta { display: flex; gap: 12px; align-items: center; }
.meta input { width: 7em; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.meta select { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled, .reset:disabled { opacity: .4; cursor: not-allowed; }
.btn.danger { border-color: var(--sev-error); color: var(--sev-error); }
.btn.small { padding: 2px 9px; font-size: 12px; }
.tabs { display: flex; gap: 4px; align-items: flex-end; padding: 8px 16px 0; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 5; }
.tab { border: 1px solid transparent; border-bottom: none; background: none; padding: 8px 16px; border-radius: 8px 8px 0 0; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab[aria-selected="true"] { color: var(--text); background: var(--bg); border-color: var(--border); }
.warn-toggle[aria-expanded="true"] .caret { display: inline-block; transform: rotate(180deg); }
.warn-toggle { margin-left: 14px; border: none; background: none; cursor: pointer; padding: 6px 0 8px; display: flex; gap: 6px; align-items: center; color: var(--text); }


.badge { display: inline-block; min-width: 1.6em; text-align: center; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.sev-error { background: var(--sev-error-bg); color: var(--sev-error); }
.badge.sev-warn { background: var(--sev-warn-bg); color: var(--sev-warn); }
.badge.sev-info { background: var(--sev-info-bg); color: var(--sev-info); }

.warn-panel { position: fixed; right: 16px; z-index: 30; width: min(760px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.18); max-height: 60vh; overflow: auto; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px; }
.warn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.warn-list.compact .warn-item { padding: 6px 8px; background: var(--surface); }
.warn-list.compact .warn-why { display: none; }
.warn-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; border-left: 4px solid; background: var(--surface-2); }
.warn-item.sev-error { border-color: var(--sev-error); } .warn-item.sev-warn { border-color: var(--sev-warn); } .warn-item.sev-info { border-color: var(--sev-info); }
.warn-body { flex: 1; min-width: 0; }
.warn-title { font-weight: 700; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.warn-msg { margin-top: 2px; }
.warn-why { margin-top: 2px; font-size: 12px; color: var(--muted); }
.warn-empty { color: var(--muted); padding: 6px; }
.role-chip { font-size: 11px; font-weight: 600; padding: 0 7px; border-radius: 999px; color: #fff; }
.role-chip.role-purchasing { background: var(--lane-purchasing); } .role-chip.role-operations { background: var(--lane-operations); }
.role-chip.role-sales { background: var(--lane-sales); } .role-chip.role-scm { background: var(--lane-scm); }

main { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.mapview, .timelineview { height: 100%; display: flex; flex-direction: column; min-height: 0; }


.swimlane { display: grid; gap: 0; }
.role-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: -1px; }
.role-tab, .lane { --role: var(--border); }
.role-purchasing { --role: var(--lane-purchasing); } .role-operations { --role: var(--lane-operations); }
.role-sales { --role: var(--lane-sales); } .role-scm { --role: var(--lane-scm); }
.lane-purchasing { --role: var(--lane-purchasing); } .lane-operations { --role: var(--lane-operations); }
.lane-sales { --role: var(--lane-sales); } .lane-scm { --role: var(--lane-scm); }

.role-tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1.5px solid var(--role); border-bottom: none; border-radius: 10px 10px 0 0; background: color-mix(in srgb, var(--role) var(--tint), var(--surface)); color: var(--text); cursor: pointer; }
.role-tab-name { font-weight: 700; font-size: 15px; }
.role-tab[aria-selected="true"] { background: var(--role); color: #fff; }
.lane { background: var(--surface); border: 1.5px solid var(--role); border-radius: 0 12px 12px 12px; }
.lane-warns { margin: 12px 12px 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.lane-warns summary { cursor: pointer; font-weight: 700; margin-bottom: 6px; }
.lane-warns .warn-list { position: relative; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.lane-warns.none { color: var(--muted); font-size: 13px; }
.lane-body { padding: 12px; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; min-width: 0; }
.group { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; min-width: 0; max-width: 100%; }
.group:has(> .cards) { flex-basis: 100%; }

#lane-sales .group:has(> .cards) { flex: 1 1 820px; }
#lane-sales .cards { grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }
.group-stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; max-width: 100%; }
.group h3 { font-size: 13px; margin-bottom: 8px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.card > * { min-width: 0; }   
.card .lbl { white-space: nowrap; }
.card .ctl select { max-width: 230px; }
.card.terminated { border-style: dashed; opacity: .75; }
.card-title { font-weight: 700; }
.card-sub { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; margin-top: 4px; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 28px; }
.field-computed { border-top: 1px dashed var(--border); padding-top: 4px; margin-top: 2px; }
.lbl { font-size: 13px; }
.unit { color: var(--muted); font-size: 12px; }
.help { color: var(--muted); cursor: help; margin-left: 4px; font-size: 12px; }
.ctl { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; min-width: 0; }
.ctl select { min-width: 0; text-overflow: ellipsis; }
.ctl.changed select, .ctl.changed input[type="number"] { background: var(--changed); }
.ctl select, .ctl input[type="number"], .grid input[type="number"], .field input, .field select { padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); max-width: 210px; }
.ctl input[type="number"] { width: 6.5em; }
.ctl select:disabled, input:disabled { opacity: .55; }
.reset { flex: none; border: none; background: none; cursor: pointer; color: var(--accent); padding: 0 2px; }
.fixed { font-size: 12px; color: var(--muted); text-align: right; white-space: pre-line; }
.info { font-size: 12px; color: var(--muted); font-style: italic; text-align: right; font-variant-numeric: tabular-nums; white-space: pre-line; }

.card .field:has(> .ctl > .info), .card .field:has(> .ctl > .fixed) { align-items: flex-start; }
.card .field:has(> .ctl > .info) > .lbl, .card .field:has(> .ctl > .fixed) > .lbl { flex: none; padding-top: 1px; }
.computed { font-weight: 700; font-variant-numeric: tabular-nums; }

.switch { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--focus); } 100% { box-shadow: none; } }

table.grid { border-collapse: collapse; font-size: 13px; }
.grid th, .grid td { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.grid thead th { font-size: 12px; color: var(--muted); font-weight: 600; }
.grid tbody th { font-weight: 500; white-space: nowrap; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.why { font-size: 12px; color: var(--muted); max-width: 380px; }
.matrix input[type="number"] { width: 6em; }
.check { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font-weight: 700; }
.check.on span { color: var(--good); } .check.off span { color: var(--bad); }


.map-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.map-svg { display: block; width: 100%; min-width: 1100px; height: auto; }
.node-box { fill: color-mix(in srgb, var(--role, var(--border)) var(--tint), var(--surface)); stroke: var(--role, var(--border)); stroke-width: 2; }
.node-box.dashed { stroke-dasharray: 6 4; }
.node.dim { opacity: .45; }
.node-title { font-size: 14px; font-weight: 700; fill: var(--text); }
.node-line { font-size: 12.5px; fill: var(--text); }
.node-line.sub { fill: var(--muted); font-size: 11.5px; }
.node-line.bad { fill: var(--bad); font-weight: 700; } .node-line.good { fill: var(--good); font-weight: 700; }

.node.sev-error .node-sev circle { fill: var(--sev-error); }
.node.sev-warn .node-sev circle { fill: var(--sev-warn); }
.node.sev-info .node-sev circle { fill: var(--sev-info); }
.node-sev-t { font-size: 14px; font-weight: 800; fill: #fff; }
.pill { fill: var(--surface-2); stroke: var(--border); }
.pill.truck { fill: var(--truck); stroke: none; } .pill.sea { fill: var(--sea); stroke: none; }
.pill.ops { fill: var(--lane-operations); stroke: none; } .pill.scm { fill: var(--lane-scm); stroke: none; } .pill.sales { fill: var(--lane-sales); stroke: none; }
.pill-t { font-size: 11.5px; fill: var(--text); }
.pill.truck + .pill-t, .pill.sea + .pill-t, .pill.ops + .pill-t, .pill.scm + .pill-t, .pill.sales + .pill-t { fill: #fff; font-weight: 600; }
.edge path { fill: none; stroke: var(--flow); stroke-width: 2; }
.edge.truck path { stroke: var(--truck); } .edge.sea path { stroke: var(--sea); stroke-dasharray: 7 4; }
.edge.off path { stroke: var(--off); opacity: .6; }
.arrow-head { fill: var(--flow); }
.edge-label-bg { fill: var(--surface); stroke: var(--border); }
.edge-label { font-size: 11.5px; fill: var(--text); }
.frozen rect { fill: none; stroke: var(--lane-scm); stroke-width: 1.5; stroke-dasharray: 5 4; }
.frozen-t { font-size: 12.5px; fill: var(--lane-scm); font-weight: 700; }
.pflow { fill: none; stroke-width: 2.2; opacity: .9; }
.pflow.p1 { stroke: var(--p1); } .pflow.p2 { stroke: var(--p2); } .pflow.p3 { stroke: var(--p3); }
.pflow.p4 { stroke: var(--p4); } .pflow.p5 { stroke: var(--p5); } .pflow.p6 { stroke: var(--p6); }
.pflow.off { stroke: var(--off); stroke-dasharray: 3 4; opacity: .7; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 4px; font-size: 12px; }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 18px; height: 4px; border-radius: 2px; display: inline-block; }
.sw.p1 { background: var(--p1); } .sw.p2 { background: var(--p2); } .sw.p3 { background: var(--p3); }
.sw.p4 { background: var(--p4); } .sw.p5 { background: var(--p5); } .sw.p6 { background: var(--p6); }
.sw.off { background: repeating-linear-gradient(90deg, var(--off) 0 3px, transparent 3px 6px); }
.sw.truck { background: var(--truck); } .sw.sea { background: repeating-linear-gradient(90deg, var(--sea) 0 7px, transparent 7px 10px); }


.map-fit, .timelineview .map-scroll { flex: 1; min-height: 0; overflow: hidden; }
.map-fit .map-svg, .timelineview .timeline-svg { min-width: 0; width: 100%; height: 100%; }
.mapview .legend, .timelineview .legend, .timeline-head { flex: none; }
.mapview .legend { padding-top: 6px; }


.timeline-head h3 { font-size: 15px; }
.timeline-head p { margin: 2px 0 10px; font-size: 12px; }
.frozen-band { fill: var(--lane-scm); opacity: .07; }
.tick.d0 { stroke: var(--accent); stroke-width: 2.5; }
.d0-t { fill: var(--accent); font-weight: 800; font-size: 13px; }
.tick-w { font-size: 10px; fill: var(--muted); }
.diamond { fill: var(--lane-scm); }
.order-mark { stroke: var(--text); stroke-width: 2; } .order-mark.early { stroke: var(--bad); }
.seg.prod { fill: var(--accent); }
.seg-t.strong { font-weight: 700; fill: var(--text); } .seg-t.bad { fill: var(--bad); font-weight: 700; }
.sw.ops { background: var(--lane-operations); } .sw.scm { background: var(--lane-scm); } .sw.scm2 { background: var(--lane-scm); opacity: .45; }
.sw.band { background: var(--lane-scm); opacity: .2; height: 10px; } .sw.limit { background: var(--good); width: 4px; height: 12px; }
.timeline-svg { display: block; width: 100%; min-width: 1100px; height: auto; }
.tick { stroke: var(--border); }
.tick-t, .axis-t { font-size: 11px; fill: var(--muted); }
.sec-t { font-size: 13px; font-weight: 700; fill: var(--text); }
.row-t { font-size: 12px; fill: var(--text); }
.seg-t { font-size: 11px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.trow.dim { opacity: .45; }
.seg.truck { fill: var(--truck); } .seg.sea { fill: var(--sea); } .seg.ops { fill: var(--lane-operations); }
.seg.scm { fill: var(--lane-scm); } .seg.scm2 { fill: var(--lane-scm); opacity: .45; }
.window { stroke: var(--text); stroke-width: 2; }
.limit { stroke: var(--good); stroke-width: 3; } .limit.over { stroke: var(--bad); }
.frozen-line { stroke: var(--lane-scm); stroke-width: 2; stroke-dasharray: 6 4; }
.frozen-lt { font-size: 11px; fill: var(--lane-scm); font-weight: 700; }


.prob { border-top: 1px dashed var(--border); padding-top: 6px; margin-top: 2px; display: grid; gap: 3px; }
.prob-h { font-size: 12px; font-weight: 700; }
.prob-row { display: grid; grid-template-columns: 52px 1fr 38px 32px; gap: 6px; align-items: center; font-size: 12px; }
.prob-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.prob-bar i { display: block; height: 100%; border-radius: 4px; }
.prob-v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.prob-g { font-size: 11px; font-weight: 700; }
.prob-note { font-size: 11px; padding-left: 58px; }
.g-hi { color: var(--good); } .g-mid { color: var(--sev-warn); } .g-lo { color: var(--bad); } .g-na { color: var(--muted); }
.prob-bar i.g-hi { background: var(--good); } .prob-bar i.g-mid { background: var(--sev-warn); } .prob-bar i.g-lo { background: var(--bad); }
.prob-summary { margin-bottom: 10px; font-size: 13px; }
.pill.g-hi { fill: var(--good); stroke: none; } .pill.g-mid { fill: var(--sev-warn); stroke: none; } .pill.g-lo { fill: var(--bad); stroke: none; }
.pill.g-hi + .pill-t, .pill.g-mid + .pill-t, .pill.g-lo + .pill-t { fill: #fff; font-weight: 600; }


#roi-strip { margin-left: auto; align-self: center; padding-bottom: 6px; }
.roi-strip { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 3px 12px; cursor: pointer; font-variant-numeric: tabular-nums; }
.fin-kv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 6px 0 4px; font-size: 13px; }
.fin-kv div { display: flex; flex-direction: column; }
.grid.small { font-size: 12px; width: 100%; } .grid.small th, .grid.small td { padding: 3px 6px; }
.roi-table .changed-row td { background: var(--changed); }
.pos-t { color: var(--pos); font-weight: 700; } .neg-t { color: var(--neg); font-weight: 700; }
:root { --pos: #2a7ab8; --neg: #c4573a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --pos: #5aa2dc; --neg: #e07a5c; } }
.roi-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.fin-inputs { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; position: sticky; top: 0; }
.fin-inputs h3 { font-size: 15px; } .fin-inputs h4 { font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.fin-inputs p { font-size: 12px; margin: 4px 0 6px; }
.fin-field { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 30px; font-size: 13px; }
.fin-field input { width: 9em; padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.roi-main { display: grid; gap: 16px; min-width: 0; }
.roi-main h3 { font-size: 15px; margin-bottom: 6px; }
.roi-note { margin: 0; font-size: 12px; }
.roi-hero { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px; min-width: 130px; }
.tile.main { border-color: var(--accent); border-width: 2px; }
.tile-l { font-size: 12px; color: var(--muted); }
.tile-v { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile-v.sm { font-size: 20px; }
.tile-d { font-size: 13px; font-weight: 700; color: var(--muted); } .tile-d.pos { color: var(--pos); } .tile-d.neg { color: var(--neg); }
.tile-arrow { align-self: center; font-size: 22px; color: var(--muted); }
.fin-missing, .roi-hero .bad { flex-basis: 100%; margin: 0; font-size: 12px; }
.roi-hero .bad { color: var(--bad); font-weight: 700; }
.roi-chart, .roi-unmodeled, .roi-main > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.roi-svg { width: 100%; height: auto; display: block; }
.roi-svg .zero { stroke: var(--muted); stroke-width: 1; }
.roi-lbl, .roi-val { font-size: 12px; fill: var(--text); } .roi-na { font-size: 12px; fill: var(--muted); font-style: italic; }
.bar.pos { fill: var(--pos); } .bar.neg { fill: var(--neg); }
.sw.pos { background: var(--pos); height: 10px; } .sw.neg { background: var(--neg); height: 10px; }
.roi-unmodeled ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }

.roi-bridge { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 6px; }
.roi-group { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.roi-group > summary, .roi-total { display: grid; grid-template-columns: minmax(0, 1fr) auto 120px 120px 110px 64px; gap: 10px; align-items: center; padding: 8px 12px; font-variant-numeric: tabular-nums; }
.roi-group > summary { cursor: pointer; background: var(--surface-2); font-weight: 700; list-style: none; }
.roi-group > summary::-webkit-details-marker { display: none; }
.roi-group > summary .g-name::before { content: '▸ '; color: var(--muted); }
.roi-group[open] > summary .g-name::before { content: '▾ '; }
.roi-group .g-cnt { font-size: 12px; font-weight: 500; }
.roi-total { font-weight: 800; background: var(--surface-2); border-radius: 10px; }   
.roi-group > summary .num, .roi-total .num { text-align: right; }
.roi-total span:first-child { grid-column: span 2; }
.roi-total.head { background: none; font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 0; padding-bottom: 0; }
.roi-table { width: 100%; table-layout: fixed; margin: 0; }
.roi-table thead { display: none; }
.roi-table td { padding: 6px 12px; }
.roi-table td:nth-child(2), .roi-table td:nth-child(3) { width: 130px; } .roi-table td:nth-child(4) { width: 120px; } .roi-table td:nth-child(5) { width: 74px; }
.roi-table tr[title] { cursor: help; }
.conf { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.conf.c-sure, .conf.c-high { background: color-mix(in srgb, var(--good) 15%, var(--surface)); color: var(--good); }
.conf.c-mid { background: var(--sev-info-bg); color: var(--sev-info); }
.conf.c-low { background: var(--sev-warn-bg); color: var(--sev-warn); }
.conf.c-none { background: var(--sev-error-bg); color: var(--sev-error); }
.fin-more { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.fin-more > summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
@media (max-width: 900px) { .roi-layout { grid-template-columns: 1fr; } .fin-inputs { position: static; }
  .roi-group > summary, .roi-total { grid-template-columns: minmax(0, 1fr) 90px 90px 80px; } .roi-group .g-cnt, .roi-total.head span:first-child { display: none; } .roi-total span:first-child { grid-column: auto; }
  .roi-table td:nth-child(5) { display: none; } .roi-table td:nth-child(2), .roi-table td:nth-child(3) { width: 90px; } .roi-table td:nth-child(4) { width: 80px; } }


dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); width: min(1100px, 96vw); max-height: 90vh; padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
#calib-body { padding: 12px 16px; display: grid; gap: 18px; }
.calib-sec h3 { font-size: 15px; margin-bottom: 6px; }
.calib-sec p { margin: 0 0 8px; font-size: 12px; }
.builtin-obs td { color: var(--muted); }
.calib-sec .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.calib-sec .field { max-width: 460px; }
.calib-sec input[type="number"] { width: 7em; }

@media (max-width: 760px) {
  .cards { grid-template-columns: 1fr; }
  main { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.mapview, .timelineview { height: 100%; display: flex; flex-direction: column; min-height: 0; }
  .group, .group-stack { width: 100%; overflow-x: auto; }
}


.kpi-note { margin-bottom: 10px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 720px), 1fr)); gap: 14px; }
.kpi-role { background: var(--surface); border: 1.5px solid var(--role, var(--border)); border-radius: 10px; padding: 10px 12px; min-width: 0; overflow-x: auto; }
.kpi-role h3 { font-size: 15px; margin-bottom: 6px; }
.grid.kpi { width: 100%; } .grid.kpi td.num, .grid.kpi th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid.kpi th, .grid.kpi td { padding: 4px 6px; white-space: nowrap; }
.grid.kpi tbody th { white-space: normal; min-width: 7em; }   
.kpi-now { font-weight: 700; } .kpi-good { color: var(--good); font-weight: 600; } .kpi-bad { color: var(--bad); font-weight: 600; }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: 1fr; } }


.mode-banner { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; padding: 7px 16px; border-bottom: 3px solid; }
.mode-banner.team { background: var(--team-bg); border-color: var(--team); }
.mode-banner.sandbox { background: var(--sandbox-bg); border-color: var(--sandbox); }
.mode-left, .presence { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-width: 0; }
.mode-name { font-size: 15px; font-weight: 800; }
.mode-banner.team .mode-name { color: var(--team); }
.mode-banner.sandbox .mode-name { color: var(--sandbox); }
.mode-desc { font-size: 13px; }
body[data-mode="sandbox"]::after { content: ''; position: fixed; inset: 0; border: 4px solid var(--sandbox); pointer-events: none; z-index: 60; }
.presence-h { font-size: 12px; font-weight: 700; }
.who-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--who); }
.who-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--who); }
.who-chip.idle { opacity: .5; }
.who-mode { font-size: 11px; color: var(--sandbox); font-weight: 700; }
.who-legend { font-size: 12px; }

.mode-banner.past { justify-content: flex-start; background: var(--past-bg); border-color: var(--past); }
.mode-banner.past .mode-name { color: var(--past); }
body.viewing::after { content: ''; position: fixed; inset: 0; border: 4px solid var(--past); pointer-events: none; z-index: 61; }


.ctl.by select, .ctl.by input[type="number"], td.by input[type="number"] { background: color-mix(in srgb, var(--who) 16%, var(--surface)); border-color: var(--who); box-shadow: 0 0 0 1px var(--who); }
td.by { box-shadow: inset 0 0 0 2px var(--who); }
td.mcell.by { background: color-mix(in srgb, var(--who) 16%, transparent); }
.sync-pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); }
.sync-pill.ok { color: var(--good); }
.sync-pill.bad { color: var(--bad); border-color: var(--bad); }
#sync-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 6px; max-width: min(420px, calc(100vw - 32px)); }
.sync-toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 12px; font-size: 13px; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }


#lane-purchasing .group:has(> .cards) { flex-basis: 100%; }
#lane-purchasing .cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#lane-purchasing .card .ctl select { max-width: 100%; }
#lane-purchasing .card .ctl input[type="number"] { width: 5em; }   
#lane-purchasing .card .lbl { white-space: normal; flex: none; max-width: 55%; }   
.card-empty { place-content: start; background: var(--surface-2); border-style: dashed; color: var(--muted); }
.card-plain .field:has(.info) { display: block; }
.card-plain .field .info { display: block; text-align: left; margin-top: 2px; }
.card-plain .field:has(.info) > .ctl { display: flex; }   
.group h3 .help { cursor: help; font-weight: 400; }


#lane-operations .lane-body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch;
  grid-template-areas: "inbound rm fg" "mix mix mix" "bottling bottling bottling" "lines lines lines" "assign assign assign"; }
#lane-operations [data-group="ops.inbound"] { grid-area: inbound; }
#lane-operations [data-group="ops.rm"] { grid-area: rm; }
#lane-operations [data-group="ops.fg"] { grid-area: fg; }
#lane-operations [data-group="ops.mix"] { grid-area: mix; }
#lane-operations [data-group="ops.bottling"] { grid-area: bottling; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 28px; }
#lane-operations [data-group="ops.bottling"] h3 { margin: 0; }
#lane-operations [data-group="ops.bottling"] .field { gap: 10px; }
#lane-operations [data-group="ops.lines"] { grid-area: lines; }
#lane-operations [data-group="ops.assign"] { grid-area: assign; }
#lane-operations .group { max-width: none; }
#lane-operations table.grid { width: 100%; }
#lane-operations .field input:not([type="checkbox"]), #lane-operations .field select { width: 110px; }   
#lane-operations .grid .fixed, #lane-operations .grid .info { white-space: nowrap; }

@media (max-width: 1280px) {
  #lane-purchasing .cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  #lane-operations .lane-body { grid-template-columns: 1fr; grid-template-areas: "inbound" "rm" "fg" "mix" "bottling" "lines" "assign"; }
  #lane-operations .group { overflow-x: auto; }
}
