/* Production Planning dashboard
   Colors come from the validated data-viz palette (light and dark steps selected separately). */

:root {
  color-scheme: light;
  --page: #f6f6f3;
  --card: #ffffff;
  --surface: #fcfcfb;          /* chart surface */
  --surface-2: #f0efec;        /* not scheduled, input wells */
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7b7973;
  --grid: #e8e7e1;
  --grid-strong: #d6d5cd;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.09);
  --shadow: 0 1px 2px rgba(20, 20, 16, 0.04), 0 4px 18px rgba(20, 20, 16, 0.05);
  --accent: #256abf;
  --accent-hover: #1c5cab;
  --accent-soft: #e6f0fc;
  --focus: #2a78d6;

  /* parts: categorical slots 1-6 */
  --p0: #2a78d6; --p1: #eb6834; --p2: #1baf7a; --p3: #eda100; --p4: #e87ba4; --p5: #008300;
  --p0-ink: #0b0b0b; --p1-ink: #0b0b0b; --p2-ink: #0b0b0b; --p3-ink: #0b0b0b; --p4-ink: #0b0b0b; --p5-ink: #ffffff;

  --change: #2f2e2b;           /* mold change: unique ink color */
  --change-ink: #ffffff;
  --idle-hatch: #a8a69e;
  --down: #d03b3b;
  --down-2: #e98a8a;

  /* status (fixed) */
  --good: #0ca30c; --warn: #fab219; --crit: #d03b3b;
  --good-bg: #ecf7ec; --good-line: #bfe3bf;
  --warn-bg: #fff6e0; --warn-line: #f5d68d;
  --crit-bg: #fcecec; --crit-line: #efc0c0;
  --meter-track: #cde2fb; --meter-fill: #2a78d6;
  --ot-wash: rgba(250, 178, 25, 0.08);
  --freeze: #0b0b0b;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --card: #161615;
    --surface: #1a1a19;
    --surface-2: #242422;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #9a9890;
    --grid: #2a2a28;
    --grid-strong: #383835;
    --axis: #45443f;
    --border: rgba(255, 255, 255, 0.09);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 22px rgba(0, 0, 0, 0.35);
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-soft: #14253b;
    --focus: #5598e7;
    --p0: #3987e5; --p1: #d95926; --p2: #199e70; --p3: #c98500; --p4: #d55181; --p5: #008300;
    --p0-ink: #0b0b0b; --p1-ink: #0b0b0b; --p2-ink: #0b0b0b; --p3-ink: #0b0b0b; --p4-ink: #0b0b0b; --p5-ink: #ffffff;
    --change: #d8d7cf;
    --change-ink: #0b0b0b;
    --idle-hatch: #6e6c66;
    --down: #d03b3b;
    --down-2: #8c3434;
    --good-bg: #122512; --good-line: #1f4a1f;
    --warn-bg: #2b2311; --warn-line: #5c4714;
    --crit-bg: #2c1515; --crit-line: #5e2626;
    --meter-track: #16304f; --meter-fill: #3987e5;
    --ot-wash: rgba(250, 178, 25, 0.07);
    --freeze: #ffffff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
[hidden] { display: none !important; }
.print-only { display: none; }

.page { max-width: 1440px; margin: 0 auto; padding: 28px 28px 40px; }

/* ------------------------------------------------------------------ masthead */
.masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.masthead h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; }
.masthead .sub { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.mast-side { display: flex; align-items: center; gap: 12px; }
.solve-note { color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-weight: 550; font-size: 13.5px; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { border-color: var(--axis); background: var(--surface); }
.btn:focus-visible, .seg button:focus-visible, .toggle:focus-visible, .tabs button:focus-visible, .chip:focus-visible {
  outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.danger-link { border: none; background: none; color: var(--text-2); padding: 0 4px; height: auto; font-weight: 500; }
.btn.danger-link:hover { color: var(--crit); background: none; }

/* ------------------------------------------------------------------ KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.kpi .k-label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .k-value { font-size: 34px; font-weight: 680; letter-spacing: -0.025em; line-height: 1.1; }
.kpi .k-unit { font-size: 15px; font-weight: 500; color: var(--text-2); margin-left: 6px; letter-spacing: 0; }
.kpi .k-sub { font-size: 12.5px; color: var(--text-2); }
.kpi .k-sub b { color: var(--text); font-weight: 600; }
.kpi.st-good { background: var(--good-bg); border-color: var(--good-line); }
.kpi.st-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.kpi.st-crit { background: var(--crit-bg); border-color: var(--crit-line); }
.k-reasons { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text-2); }
.k-reasons li { margin: 2px 0; }
.k-reasons li:first-child { color: var(--text); }
.meter { height: 8px; border-radius: 999px; background: var(--meter-track); overflow: hidden; margin: 4px 0 2px; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--meter-fill); }
.meter.over > span { background: linear-gradient(90deg, var(--meter-fill) 0 calc(100% - 6px), var(--warn) calc(100% - 6px)); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 13px; color: var(--text); white-space: nowrap; }
.badge .ic { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; flex: none; }
.badge .ic svg { width: 11px; height: 11px; }
.badge.good .ic { background: var(--good); }
.badge.warn .ic { background: var(--warn); color: #3b2a00; }
.badge.crit .ic { background: var(--crit); }
.badge.big { font-size: 15px; padding: 4px 12px 4px 5px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); }
.badge.big .ic { width: 22px; height: 22px; }
.badge.big .ic svg { width: 13px; height: 13px; }

/* ------------------------------------------------------------------ tabs */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin: 4px 0 16px; }
.tabs button {
  border: none; background: transparent; padding: 8px 16px; border-radius: 9px; font-weight: 600; font-size: 13.5px;
  color: var(--text-2); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

/* ------------------------------------------------------------------ cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card h2 { font-size: 18px; font-weight: 680; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.hint { color: var(--text-2); font-size: 12.5px; margin: 4px 0 0; }
.block-title { font-size: 15px; font-weight: 680; }

/* schedule card header: countermeasure (top-left) · title · print (top-right) */
.card-top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 16px; margin-bottom: 14px; }
.card-title { align-self: center; }
.card-top .toggle { justify-self: start; }
.card-top .print-btn { justify-self: end; }
.card-title { text-align: center; }
.card-title h2 { font-size: 20px; }
.toggle {
  display: inline-flex; align-items: center; gap: 10px; max-width: 380px; text-align: left; cursor: pointer;
  border: 1px dashed var(--axis); background: var(--surface); border-radius: 12px; padding: 8px 12px;
}
.toggle:hover { border-color: var(--text-2); }
.toggle[aria-pressed="true"] { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.toggle .switch { width: 34px; height: 20px; border-radius: 999px; background: var(--axis); position: relative; flex: none; transition: background .15s; }
.toggle .switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s;
}
.toggle[aria-pressed="true"] .switch { background: var(--accent); }
.toggle[aria-pressed="true"] .switch::after { transform: translateX(14px); }
.toggle-text { font-size: 12.5px; line-height: 1.3; font-weight: 550; }

/* ------------------------------------------------------------------ legend */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 0 0 10px; font-size: 12.5px; color: var(--text-2); }
.legend .it { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 10px; border-radius: 3px; flex: none; }
.legend .sep { width: 1px; height: 14px; background: var(--grid-strong); }
.sw.change { background: var(--change); width: 6px; border-radius: 2px; }
.sw.idle { background: repeating-linear-gradient(135deg, var(--idle-hatch) 0 1.5px, transparent 1.5px 3.5px); border: 1px solid var(--grid-strong); }
.sw.down { background: repeating-linear-gradient(45deg, var(--down) 0 3px, var(--down-2) 3px 5px); }
.sw.off { background: var(--surface-2); border: 1px solid var(--grid-strong); }
.sw.done { background: var(--p0); opacity: .45; }
.sw.freeze { width: 2px; height: 14px; background: var(--freeze); border-radius: 1px; }

/* ------------------------------------------------------------------ gantt */
.gantt-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); transition: opacity .2s; }
.busy .gantt-wrap, .busy .sequence, .busy .bottom, .busy #outTable { opacity: .45; }
.gantt { --label-w: 118px; --head-h: 50px; --marks-h: 22px; --row-h: 76px; position: relative; min-width: 978px; padding: 0 14px 6px 0; }
.g-head { position: relative; height: var(--head-h); margin-left: var(--label-w); border-bottom: 1px solid var(--axis); }
.g-day { position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.g-dayname { text-align: center; font-weight: 650; font-size: 12.5px; padding-bottom: 2px; white-space: nowrap; }
.g-dayname small { font-weight: 500; color: var(--text-2); margin-left: 4px; }
.g-day.ot .g-dayname { color: #9a6700; }
.g-ot-chip { display: inline-block; margin-left: 6px; vertical-align: 1px; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #8a5c00; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 999px; padding: 0 6px; line-height: 15px; white-space: nowrap; }
.g-shifts { display: flex; border-top: 1px solid var(--grid); }
.g-shift { flex: 1; min-width: 0; overflow: hidden; text-align: center; font-size: 10.5px; color: var(--muted); padding: 2px 0 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.g-marks { position: relative; height: var(--marks-h); margin-left: var(--label-w); }
.g-rows { position: relative; }
.g-row { display: flex; height: var(--row-h); border-bottom: 1px solid var(--grid); }
.g-row:last-child { border-bottom: none; }
.g-label { width: var(--label-w); flex: none; display: flex; flex-direction: column; justify-content: center; padding: 0 12px 0 16px; }
.g-label b { font-size: 14px; font-weight: 680; }
.g-label span { font-size: 11px; color: var(--text-2); line-height: 1.3; }
.g-track { position: relative; flex: 1; }
.g-lines { position: absolute; top: 0; bottom: 0; left: var(--label-w); right: 0; pointer-events: none; }
.g-vline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--grid); }
.g-vline.day { background: var(--grid-strong); }
.g-ot { position: absolute; top: 0; bottom: 0; background: var(--ot-wash); }
.g-freeze { position: absolute; top: calc(-1 * var(--marks-h)); bottom: 0; width: 2px; margin-left: -1px; background: var(--freeze); opacity: .85; }
.g-due { position: absolute; top: calc(-1 * var(--marks-h)); bottom: 0; width: 0; border-left: 2px solid #0f7b3e; }
.flag {
  position: absolute; top: 3px; transform: translateX(-50%); font-size: 10.5px; font-weight: 650; white-space: nowrap;
  background: var(--freeze); color: var(--surface); border-radius: 999px; padding: 1px 8px; line-height: 15px; z-index: 6;
}
.flag.due { background: #0f7b3e; color: #fff; }
.flag.right { transform: translateX(-100%); border-top-right-radius: 3px; border-bottom-right-radius: 3px; }

.blk { position: absolute; top: 22px; height: 36px; border-radius: 5px; outline: none; }
.blk:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus); z-index: 9; }
.blk.run {
  background: var(--c); color: var(--ink); display: flex; flex-direction: column; justify-content: center;
  padding: 0 8px; z-index: 1; cursor: default; transition: filter .12s;
}
.blk.run:hover, .blk.run.hl { filter: brightness(1.07) saturate(1.06); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c); z-index: 5; }
.blk.run.done { opacity: .48; }
.rlab {
  position: absolute; top: 22px; height: 36px; z-index: 5; pointer-events: none; padding: 0 8px; color: var(--ink);
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  text-shadow: 0 0 2px var(--c), 0 0 3px var(--c), 0 0 4px var(--c);
}
.rlab span { display: inline-block; white-space: nowrap; }
.rlab .l1 { font-weight: 650; font-size: 12px; line-height: 1.25; }
.rlab .l2 { font-size: 11px; line-height: 1.25; opacity: .9; font-variant-numeric: tabular-nums; }
.rlab .l1.solo { font-size: 11.5px; }
.rlab.done { opacity: .6; text-shadow: none; }
.blk.change { top: 17px; height: 46px; background: var(--change); border-radius: 3px; z-index: 4; min-width: 6px; transform: translateX(-50%); }
.blk.change.long { background: repeating-linear-gradient(135deg, var(--change) 0 5px, color-mix(in srgb, var(--change) 72%, var(--surface)) 5px 8px); transform: none; }
.blk.change.done { opacity: .55; }
.blk.idle { background: repeating-linear-gradient(135deg, var(--idle-hatch) 0 1.5px, var(--surface) 1.5px 3.5px); border-radius: 1px; z-index: 3; top: 22px; height: 36px; }
.blk.down { top: 17px; height: 46px; background: repeating-linear-gradient(45deg, var(--down) 0 5px, var(--down-2) 5px 8px); z-index: 6; border-radius: 3px; min-width: 4px; }
.blk.off { background: var(--surface-2); z-index: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11.5px; border-radius: 5px; }
.blk.off span { white-space: nowrap; }
.tag { position: absolute; top: 1px; transform: translateX(-50%); font-size: 10.5px; font-weight: 650; white-space: nowrap; color: var(--text-2); pointer-events: none; z-index: 7; }
.tag.down { color: var(--crit); }
.tag.long { color: var(--text); }
.g-empty { padding: 40px 20px; text-align: center; color: var(--text-2); }

/* ------------------------------------------------------------------ tooltip */
.tooltip {
  position: fixed; z-index: 60; max-width: 310px; background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 10px 32px rgba(0, 0, 0, .16); padding: 10px 12px; font-size: 12.5px; pointer-events: none;
}
.tt-head { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 13px; margin-bottom: 4px; }
.tt-key { width: 14px; height: 4px; border-radius: 2px; flex: none; }
.tt-value { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.tt-row { color: var(--text-2); margin-top: 2px; }
.tt-row b { color: var(--text); font-weight: 600; }
.tt-note { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--grid); color: var(--text-2); }

/* ------------------------------------------------------------------ bottom summary */
.bottom { margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 14px 16px; }
.verdict { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; margin-bottom: 12px; }
.verdict .badge { margin-top: 1px; }
.verdict p { margin: 0; }
.verdict .v-title { font-weight: 650; }
table.prod { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.prod th, table.prod td { padding: 6px 10px; text-align: right; border-top: 1px solid var(--grid); white-space: nowrap; }
table.prod thead th { border-top: none; color: var(--text-2); font-weight: 600; }
table.prod th:first-child, table.prod td:first-child { text-align: left; color: var(--text-2); font-weight: 600; }
table.prod thead th .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.mark { display: inline-flex; align-items: center; gap: 5px; justify-content: flex-end; }
.mark .dot { width: 14px; height: 14px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; }
.mark .dot svg { width: 9px; height: 9px; }
.mark.good .dot { background: var(--good); }
.mark.warn .dot { background: var(--warn); color: #3b2a00; }
.mark.crit .dot { background: var(--crit); }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------------------ sequence */
.sequence-block { margin-top: 20px; }
.sequence { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
.seq-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px 14px 8px; min-width: 0; }
.seq-card h4 { font-size: 14.5px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.seq-card h4 span { font-size: 11.5px; font-weight: 500; color: var(--text-2); }
.seq-list { list-style: none; margin: 8px 0 0; padding: 0; }
.seq-list li { display: grid; grid-template-columns: 20px 12px minmax(0, 1fr); gap: 4px 8px; padding: 8px 0; border-top: 1px solid var(--grid); font-size: 12.5px; }
.seq-n { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.seq-key { width: 10px; height: 10px; border-radius: 3px; margin-top: 4px; }
.seq-key.change { background: var(--change); width: 5px; margin-left: 2px; border-radius: 2px; }
.seq-key.down { background: repeating-linear-gradient(45deg, var(--down) 0 2px, var(--down-2) 2px 4px); }
.seq-key.end { background: none; border: 2px solid var(--axis); border-radius: 50%; }
.seq-main { min-width: 0; }
.seq-title { font-weight: 600; }
.seq-title .q { float: right; font-weight: 650; font-variant-numeric: tabular-nums; margin-left: 8px; }
.seq-time { color: var(--text-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.seq-list li.done .seq-title, .seq-list li.done .seq-time { color: var(--muted); }
.seq-list li.done .seq-title::before { content: "✓ "; color: var(--good); font-weight: 700; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 650; border-radius: 999px; padding: 0 7px; margin-left: 6px; vertical-align: 1px; }
.pill.ot { background: var(--warn-bg); color: #8a5c00; border: 1px solid var(--warn-line); }
.pill.long { background: var(--surface-2); color: var(--text); border: 1px solid var(--grid-strong); }

/* ------------------------------------------------------------------ reschedule */
.ev-form { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); min-width: 120px; }
.f.grow { flex: 1 1 240px; }
.f.num { min-width: 110px; width: 130px; }
.f select, .f input, textarea {
  height: 36px; border: 1px solid var(--grid-strong); border-radius: 9px; background: var(--card); padding: 0 10px;
  font-size: 13.5px; font-weight: 500; color: var(--text); min-width: 0;
}
.f select:focus, .f input:focus, textarea:focus, .doh-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.ev-preview { margin: 10px 0 0; font-size: 12.5px; color: var(--text-2); min-height: 18px; }
.ev-preview b { color: var(--text); }
.ev-log { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ev-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
.ev-num { font-weight: 700; font-size: 12px; background: var(--surface-2); border-radius: 8px; padding: 3px 8px; font-variant-numeric: tabular-nums; }
.ev-title { font-weight: 650; font-size: 13.5px; }
.ev-title .when { font-weight: 500; color: var(--text-2); }
.ev-msg { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.ev-side { display: flex; align-items: center; gap: 10px; }
.ev-status { font-size: 11.5px; font-weight: 650; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--grid-strong); white-space: nowrap; }
.ev-status.applied { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.ev-status.skipped { background: var(--warn-bg); border-color: var(--warn-line); }
.ev-empty { color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ output table */
.table-toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.tb-left { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.tb-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.doh-field, .ot-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.doh-field input { width: 110px; height: 36px; border: 1px solid var(--grid-strong); border-radius: 9px; background: var(--card); padding: 0 10px; font-size: 14px; font-weight: 600; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; height: 36px; }
.seg button { border: none; background: transparent; border-radius: 8px; padding: 0 11px; font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button[aria-checked="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.dirty-note { font-size: 12.5px; font-weight: 600; color: #8a5c00; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 999px; padding: 3px 10px; }
.btn.strong { height: 40px; padding: 0 18px; font-size: 14px; }
.table-head { margin-bottom: 8px; }
table.out { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.out th {
  font-size: 12px; font-weight: 650; color: var(--text-2); text-align: right; padding: 10px 10px 8px; border-bottom: 1px solid var(--axis);
  vertical-align: bottom; line-height: 1.25;
}
table.out th:first-child, table.out td:first-child { text-align: left; }
table.out th .ed { display: block; font-weight: 500; font-size: 10.5px; color: var(--muted); }
table.out td { padding: 7px 10px; border-bottom: 1px solid var(--grid); text-align: right; font-variant-numeric: tabular-nums; vertical-align: middle; }
table.out tfoot td { border-bottom: none; font-weight: 650; padding-top: 10px; }
.part-cell { display: flex; align-items: center; gap: 10px; }
.part-cell .sw { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.part-cell b { font-weight: 650; }
.part-cell small { display: block; color: var(--text-2); font-size: 11.5px; white-space: nowrap; }
input.cell {
  width: 100%; min-width: 72px; max-width: 118px; height: 32px; text-align: right; border: 1px solid transparent; border-radius: 8px;
  background: var(--surface-2); padding: 0 8px; font-size: 13.5px; font-variant-numeric: tabular-nums;
}
input.cell:hover { border-color: var(--grid-strong); }
input.cell:focus { outline: none; border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
input.cell.changed { background: var(--warn-bg); border-color: var(--warn-line); }
input.cell.bad { border-color: var(--crit); background: var(--crit-bg); }
td.ro { color: var(--text); }
td.stale { color: var(--muted); }
.cell-note { display: block; font-size: 10.5px; color: var(--text-2); margin-top: 2px; white-space: nowrap; }
.outcome { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.outcome small { color: var(--text-2); font-size: 11px; white-space: nowrap; }

/* ------------------------------------------------------------------ workbook */
.dl-row { display: flex; gap: 10px; flex-wrap: wrap; }
.dl-note { margin-top: 10px; }
.cli { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font: 12.5px/1.55 ui-monospace, "SF Mono", Menlo, monospace; overflow-x: auto; margin: 12px 0 0; white-space: pre; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip[aria-pressed="true"] small { color: rgba(255, 255, 255, .8); }
.table-scroll.tall { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 12px; }
table.grid th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 650; padding: 7px 10px; white-space: nowrap; z-index: 1; }
table.grid td { padding: 6px 10px; border-top: 1px solid var(--grid); white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
table.grid.mono td { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; }
.ddl { margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
textarea { width: 100%; height: auto; padding: 10px 12px; font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, monospace; resize: vertical; }
.sql-actions { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.gl-section { margin-top: 18px; }
.gl-section:first-child { margin-top: 0; }
.gl-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
table.gloss { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.gloss th { text-align: left; font-weight: 650; color: var(--text-2); font-size: 11.5px; padding: 6px 10px; border-bottom: 1px solid var(--axis); }
table.gloss td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.gloss td.sym { font-weight: 700; white-space: nowrap; width: 150px; }
table.gloss td.fx { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; color: var(--text); width: 34%; }
table.gloss td.use { color: var(--text-2); }

/* ------------------------------------------------------------------ misc */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; background: var(--text); color: var(--card); padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 550; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); max-width: min(560px, calc(100vw - 32px)); }
.toast.error { background: var(--crit); color: #fff; }
.busy-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 80; overflow: hidden; }
.busy-bar span { position: absolute; top: 0; bottom: 0; width: 30%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; border-radius: 3px; }
@keyframes slide { from { left: -30%; } to { left: 100%; } }
.page-foot { margin-top: 8px; text-align: center; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .sequence { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .page { padding: 18px 16px 32px; }
  .kpis { grid-template-columns: 1fr; }
  .masthead { flex-direction: column; align-items: flex-start; }
  .card { padding: 16px; }
  .tb-right { margin-left: 0; width: 100%; justify-content: space-between; }
}
@media (max-width: 720px) {
  .card-top { grid-template-columns: 1fr; }
  .card-top .toggle, .card-top .print-btn { justify-self: stretch; max-width: none; }
  .card-title { text-align: left; order: -1; }
}
@media (min-width: 721px) and (max-width: 1000px) {
  .card-top .toggle { max-width: 280px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0s !important; }
}

/* ------------------------------------------------------------------ print: schedule + sequence */
@media print {
  :root {
    color-scheme: light;
    --page: #ffffff; --card: #ffffff; --surface: #ffffff; --surface-2: #f0efec; --text: #0b0b0b; --text-2: #52514e; --muted: #7b7973;
    --grid: #e8e7e1; --grid-strong: #d6d5cd; --axis: #c3c2b7; --border: rgba(11, 11, 11, .14);
    --p0: #2a78d6; --p1: #eb6834; --p2: #1baf7a; --p3: #eda100; --p4: #e87ba4; --p5: #008300;
    --p0-ink: #0b0b0b; --p1-ink: #0b0b0b; --p2-ink: #0b0b0b; --p3-ink: #0b0b0b; --p4-ink: #0b0b0b; --p5-ink: #ffffff;
    --change: #2f2e2b; --change-ink: #ffffff; --idle-hatch: #a8a69e; --down-2: #e98a8a; --freeze: #0b0b0b;
    --good-bg: #ecf7ec; --warn-bg: #fff6e0; --crit-bg: #fcecec; --good-line: #bfe3bf; --warn-line: #f5d68d; --crit-line: #efc0c0;
    --ot-wash: rgba(250, 178, 25, 0.10);
  }
  @page { size: landscape; margin: 9mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; font-size: 12px; }
  .page { max-width: none; padding: 0; }
  .no-print, .kpis, .tabs, #tab-workbook, .toast, .tooltip, .busy-bar { display: none !important; }
  .print-only { display: block !important; }
  .masthead { margin-bottom: 6px; }
  .masthead h1 { font-size: 20px; }
  .card { border: none; box-shadow: none; padding: 0; margin: 0; }
  .card-top { display: block; margin-bottom: 4px; }
  .card-title { text-align: left; }
  .card-title h2 { font-size: 15px; }
  .print-settings { font-size: 11px; color: var(--text-2); margin: 0 0 6px; }
  .gantt-wrap { overflow: visible; border-color: #d6d5cd; }
  .gantt { min-width: 0 !important; --row-h: 70px; }
  .blk.run.done { opacity: .5; }
  .bottom, .seq-card { break-inside: avoid; }
  .sequence-block { break-inside: avoid; }
  .sequence { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .seq-list li { padding: 5px 0; font-size: 11px; }
  .hint { font-size: 10.5px; }
}
