/* Stir Foods Production Control Center */
:root {
  --font: 'Barlow', 'Segoe UI', system-ui, sans-serif;
  --font-cond: 'Barlow Condensed', 'Barlow', 'Segoe UI', system-ui, sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --gap: 12px;
  --state-running: #2fbf5f;
  --state-downtime: #e5484d;
  --state-changeover: #f5871f;
  --state-setup: #3b8cf0;
  --state-cleaning: #c9a227;
  --state-stopped: #94a0ae;
  --state-idle: #6d7886;
}
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0b0e12;
  --panel: #141a21;
  --panel-2: #1b222b;
  --panel-3: #232c37;
  --line: #27313c;
  --text: #f0f3f6;
  --text-dim: #b4bdc8;
  --muted: #8a95a2;
  --grid: #222b35;
  --axis: #3a4552;
  --tooltip: #232c37;
  --neutral-series: #5d6877;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --on-state: #06090c;
}
[data-theme='light'] {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-2: #f3f5f7;
  --panel-3: #e6eaee;
  --line: #d8dee4;
  --text: #10161c;
  --text-dim: #46515c;
  --muted: #68737f;
  --grid: #e6e9ec;
  --axis: #b7bfc7;
  --tooltip: #ffffff;
  --neutral-series: #a3acb6;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --state-running: #15913f;
  --state-changeover: #d96f0e;
  --state-cleaning: #a8850f;
  --state-stopped: #66717e;
  --state-idle: #8a95a2;
  --on-state: #ffffff;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.35; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

/* ---- Banners ---- */
.demo-banner { background: repeating-linear-gradient(135deg, #7a4a00, #7a4a00 14px, #6b4100 14px, #6b4100 28px); color: #fff; text-align: center; font-weight: 700; padding: 5px 12px; letter-spacing: .04em; font-size: 14px; }
.warn-banner { background: var(--state-changeover); color: #111; text-align: center; font-weight: 600; padding: 6px 12px; }
.demo-note { color: var(--state-changeover); font-weight: 700; margin-bottom: 8px; }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 22px; padding: 10px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 38px; height: 38px; border-radius: 8px; background: var(--state-running); color: #06140b; display: grid; place-items: center; font-family: var(--font-cond); font-weight: 600; font-size: 21px; }
.brand-title { display: flex; flex-direction: column; font-size: inherit; font-weight: inherit; }
.brand-name { font-weight: 700; font-size: 18px; line-height: 1.1; }
.brand-sub { color: var(--text-dim); font-size: 13px; line-height: 1.2; }
.top-when { display: flex; flex-direction: column; }
.top-date { font-weight: 600; font-size: 14px; white-space: nowrap; }
.top-shift { color: var(--text-dim); font-size: 13px; }
.top-clock { font-family: var(--font-cond); font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.overall { padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; background: var(--panel-3); white-space: nowrap; }
.overall::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--state-idle); margin-right: 8px; }
.overall[data-level='OK']::before { background: var(--state-running); }
.overall[data-level='PARTIAL']::before { background: var(--state-changeover); }
.overall[data-level='ALERT']::before { background: var(--state-downtime); }
.top-kpis { display: flex; gap: 22px; margin-left: auto; }
.top-kpi-label { font-family: var(--font-cond); font-weight: 500; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.top-kpi-value { font-family: var(--font-cond); font-weight: 600; font-size: 28px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.top-kpi.c-run .top-kpi-value { color: var(--state-running); }
.top-kpi.c-down .top-kpi-value { color: var(--state-downtime); }
.top-tools { display: flex; align-items: center; gap: 8px; }
.live-pill { font-family: var(--font-cond); font-weight: 600; font-size: 13px; letter-spacing: .08em; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--state-downtime); color: var(--state-downtime); }
.live-pill[data-live='true'] { border-color: var(--state-running); color: var(--state-running); }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); display: grid; place-items: center; font-size: 16px; }
.icon-btn:hover { background: var(--panel-3); }
.nav-row { display: flex; justify-content: space-between; align-items: center; padding: 0 16px; border-top: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.main-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.main-nav a { text-decoration: none; padding: 8px 14px; color: var(--text-dim); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; }
.main-nav a:hover { color: var(--text); }
.main-nav a.active { color: var(--text); border-bottom-color: var(--state-running); }
.user-box { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }
.user-name { font-weight: 600; }
.user-role { color: var(--muted); font-family: var(--font-cond); letter-spacing: .05em; }
:fullscreen .nav-row { display: none; }

.content { padding: var(--gap) 12px 32px; }

/* ---- Line cards ---- */
/* Facility → Department scope and line groups on the dashboard */
.scope-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin-bottom: var(--gap); }
.scope-field { display: flex; align-items: center; gap: 8px; }
.scope-label { font-family: var(--font-cond); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.line-area { display: flex; flex-direction: column; gap: calc(var(--gap) * 1.5); }
.line-group-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.line-group-title { font-size: 18px; font-weight: 700; letter-spacing: .01em; }
.line-group-sum { color: var(--text-dim); font-size: 14px; font-variant-numeric: tabular-nums; }
.line-group.no-head .line-group-head { display: none; }
.line-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.line-grid[data-count='1'] { grid-template-columns: minmax(0, 620px); justify-content: center; }
.line-grid[data-count='2'] { grid-template-columns: repeat(2, minmax(0, 620px)); justify-content: center; }
.line-grid[data-count='3'] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1500px) { .line-grid:not([data-count='1']) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .line-grid, .line-grid:not([data-count='1']) { grid-template-columns: minmax(0, 1fr); } }

.line-card { --accent: var(--state-idle); background: var(--panel); border: 1px solid var(--line); border-top: 5px solid var(--accent); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; transition: border-color .35s ease, box-shadow .35s ease; }
.state-run { --accent: var(--state-running); }
.state-down { --accent: var(--state-downtime); box-shadow: 0 0 0 1px var(--state-downtime); }
.state-co { --accent: var(--state-changeover); }
.state-setup { --accent: var(--state-setup); }
.state-clean { --accent: var(--state-cleaning); }
.state-stopped { --accent: var(--state-stopped); }
.state-idle { --accent: var(--state-idle); }

.lc-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 8px; gap: 8px; }
.lc-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.lc-name { font-family: var(--font-cond); font-size: 30px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.lc-type { color: var(--muted); font-size: 13px; }
.lc-status { text-align: right; }
.status-main { display: inline-flex; align-items: center; gap: 7px; background: var(--accent); color: var(--on-state); border-radius: 6px; padding: 3px 11px; font-family: var(--font-cond); font-weight: 600; font-size: 20px; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; transition: background-color .35s ease; }
.state-down .status-main { color: #fff; }
.state-setup .status-main { color: #fff; }
.state-run .status-icon { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.status-timer { display: block; font-family: var(--font-cond); font-size: 22px; font-weight: 600; color: var(--accent); line-height: 1.15; font-variant-numeric: tabular-nums; min-height: 25px; }

.lc-context { padding: 0 12px 8px; min-height: 62px; }
.reason-alert { display: block; width: 100%; background: var(--state-downtime); color: #fff; border: 0; border-radius: var(--radius-sm); padding: 8px; font-family: var(--font-cond); font-weight: 600; font-size: 18px; letter-spacing: .03em; margin-bottom: 6px; animation: alertpulse 1.4s ease-in-out infinite; }
@keyframes alertpulse { 50% { opacity: .68; } }
.lc-detail { color: var(--accent); font-weight: 600; font-size: 14px; }
.lc-detail:empty { display: none; }
.lc-product { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-meta { color: var(--text-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-overrun { color: var(--state-changeover); font-size: 13px; font-weight: 600; margin-top: 3px; }

.lc-bpm { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 14px; align-items: center; padding: 8px 12px; background: var(--panel-2); border-top: 1px solid var(--line); }
.bpm-head { display: flex; align-items: center; gap: 6px; }
.bpm-now { display: block; font-family: var(--font-cond); font-weight: 600; font-size: 62px; line-height: .98; color: var(--text); }
.bpm-now.muted { color: var(--muted); }
.bpm-age { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; min-height: 16px; }
.bpm-side { display: grid; gap: 2px; min-width: 0; }
.bpm-side .stat { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 0; background: none; }
.bpm-side .tile-value { font-size: 20px; }
.bpm-edit { align-self: stretch; border: 1px solid var(--axis); background: var(--panel-3); border-radius: var(--radius-sm); font-family: var(--font-cond); font-weight: 600; font-size: 16px; letter-spacing: .03em; padding: 6px 10px; max-width: 74px; line-height: 1.1; }
.bpm-edit:hover { background: var(--axis); }
.source-tag { font-family: var(--font-cond); font-weight: 600; font-size: 12px; letter-spacing: .06em; border-radius: 4px; padding: 0 5px; background: var(--state-setup); color: #fff; }
.source-tag.tag-manual { background: transparent; color: var(--text-dim); border: 1px solid var(--axis); }
.gauge { position: relative; height: 6px; background: var(--panel-3); }
.gauge-fill { height: 100%; background: var(--accent); transition: width .5s ease; }
.gauge-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }

.stat-label { font-family: var(--font-cond); font-weight: 500; font-size: 13px; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; white-space: nowrap; }
.tile-value { font-family: var(--font-cond); font-weight: 600; font-size: 23px; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.time-bar { display: flex; height: 7px; margin: 8px 12px 0; gap: 2px; border-radius: 4px; overflow: hidden; background: var(--panel-3); }
.seg { display: block; flex: 0 0 0; flex-basis: 0; min-width: 0; transition: flex-grow .6s ease; }
.seg-run { background: var(--state-running); } .seg-down { background: var(--state-downtime); } .seg-co { background: var(--state-changeover); }
.seg-setup { background: var(--state-setup); } .seg-clean { background: var(--state-cleaning); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; padding: 8px 12px; }
.stat-grid .stat { display: flex; flex-direction: column; min-width: 0; }
.c-run .tile-value { color: var(--state-running); } .c-down .tile-value { color: var(--state-downtime); } .c-co .tile-value { color: var(--state-changeover); }
.c-setup .tile-value { color: var(--state-setup); } .c-clean .tile-value { color: var(--state-cleaning); }

.progress-block { padding: 2px 12px 8px; }
.progress-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); }
.prog-value { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.progress { height: 8px; background: var(--panel-3); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.progress-fill { height: 100%; background: var(--series-1); border-radius: 4px; transition: width .6s ease; }
.produced-row { margin-top: 3px; }
.link-btn { background: none; border: 0; padding: 2px 0; color: var(--text-dim); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; text-align: left; }
.link-btn:hover { color: var(--text); }

.controls { margin-top: auto; padding: 10px 12px 12px; border-top: 1px solid var(--line); display: grid; gap: 7px; }
.controls-main { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.controls-sub { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.ctl { border: 0; border-radius: 8px; font-family: var(--font-cond); font-weight: 600; letter-spacing: .03em; min-height: 56px; font-size: 21px; padding: 4px 6px; line-height: 1.05; transition: filter .12s ease, transform .06s ease, opacity .2s ease; }
.controls-sub .ctl { min-height: 48px; font-size: 16px; }
.ctl:hover:not(:disabled) { filter: brightness(1.12); }
.ctl:active:not(:disabled) { transform: scale(.98); }
.ctl:disabled { opacity: .26; }
.ctl-go { background: var(--state-running); color: #05140a; }
.ctl-stop { background: var(--state-downtime); color: #fff; }
.ctl-co { background: var(--state-changeover); color: #1a0f02; }
.ctl-setup { background: var(--state-setup); color: #fff; }
.ctl-clean { background: var(--state-cleaning); color: #171102; }
.ctl-end { background: var(--panel-3); color: var(--text); border: 1px solid var(--axis); }
[data-theme='light'] .ctl-go { color: #fff; }

/* ---- Analytics ---- */
.analytics { margin-top: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); transition: opacity .2s ease; }
.analytics.refreshing { opacity: .8; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 20px; font-weight: 700; }
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg-control { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.seg-wrap { flex-wrap: wrap; margin-bottom: var(--gap); }
.seg-control button { border: 0; background: none; color: var(--text-dim); padding: 6px 11px; border-radius: 6px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.seg-control button:hover { background: var(--panel-2); }
.seg-control button.active { background: var(--panel-3); color: var(--text); font-weight: 600; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px; }
.kpi-label { font-family: var(--font-cond); font-size: 13px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-family: var(--font-cond); font-size: 30px; font-weight: 600; line-height: 1.1; }
.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
@media (max-width: 1000px) { .panel-grid { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.panel-off { opacity: .6; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.panel-head .panel-title { margin: 0; }
.chart-box { position: relative; height: 270px; }
.chart-tall { height: 340px; }
.ranked { display: grid; gap: 1px; }
.ranked-row { display: grid; grid-template-columns: minmax(130px, 34%) 1fr 104px; gap: 10px; align-items: center; padding: 4px 6px; background: none; border: 0; text-align: left; border-radius: 5px; width: 100%; min-height: 30px; }
.ranked-row:has(.ranked-cum) { grid-template-columns: minmax(130px, 34%) 1fr 64px 56px; }
.ranked-row.clickable:hover { background: var(--panel-2); }
.ranked-label { min-width: 0; }
.ranked-name { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranked-sub { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranked-track { height: 12px; }
.ranked-bar { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; transition: width .5s ease; }
.ranked-right { text-align: right; font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ranked-cum { text-align: right; font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ranked-header { display: grid; grid-template-columns: 1fr 64px 76px; gap: 10px; font-family: var(--font-cond); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 0 6px 4px; text-align: right; }
.ranked-header span:first-child { text-align: left; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-family: var(--font-cond); font-weight: 600; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 5px 8px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
.table td { padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:hover { background: var(--panel-2); }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--axis); }
.table-compact { font-size: 13px; }
.table-compact td { padding: 4px 7px; white-space: nowrap; }
.table-summary { color: var(--text-dim); font-size: 14px; margin-bottom: 8px; font-weight: 600; }
.row-actions { display: flex; gap: 5px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 10px; font-size: 14px; }
.state-chip { font-family: var(--font-cond); font-weight: 600; font-size: 13px; letter-spacing: .03em; padding: 1px 7px; border-radius: 4px; color: #fff; white-space: nowrap; }
.chip-downtime { background: var(--state-downtime); } .chip-changeover { background: var(--state-changeover); color: #1a0f02; }
.chip-setup { background: var(--state-setup); } .chip-cleaning { background: var(--state-cleaning); color: #171102; }
.tag-btn { background: none; border: 1px solid var(--state-changeover); color: var(--state-changeover); border-radius: 4px; padding: 1px 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.order-status { font-weight: 600; white-space: nowrap; }
/* Headcount */
.plan-hc { display: flex; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.plan-hc-label { font-weight: 600; white-space: nowrap; }
.input.plan-hc-input { width: 72px; text-align: right; min-height: 34px; padding: 4px 8px; }
.plan-hc strong { font-size: 18px; }
.plan-hc-of { color: var(--text-dim); white-space: nowrap; }
.plan-hc-short { color: var(--state-downtime); font-weight: 700; white-space: nowrap; }
.plan-hc.hc-missing .plan-hc-label { color: var(--state-changeover); }
.dds-hc-short { color: var(--state-downtime); font-weight: 700; }
.lc-hc { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.lc-hc:empty { display: none; }
.lc-hc.hc-short { color: var(--state-downtime); font-weight: 700; }
.lc-hc.hc-missing { color: var(--state-changeover); }

/* Schedule upload preview */
.sched-days { display: grid; gap: 14px; max-height: 58vh; overflow: auto; padding-right: 4px; }
.sched-day { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.sched-day-head { font-size: 16px; margin-bottom: 6px; }
.sched-table td { vertical-align: top; font-size: 14px; }
.sched-run { padding: 2px 0; }
.sched-run.act-skip > span:first-child { text-decoration: line-through; color: var(--text-dim); }
.sched-run.act-keep > span:first-child { color: var(--text-dim); }

/* Mechanic calls: status on line cards and the tablet */
.mech-status { border-radius: var(--radius-sm); padding: 6px 10px; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.mech-status.is-called { background: var(--state-changeover); color: #1b0f00; animation: alertpulse 1.4s ease-in-out infinite; }
.mech-status.is-accepted { background: color-mix(in srgb, var(--state-setup) 25%, transparent); color: var(--text); border: 1px solid var(--state-setup); }
.tb-band-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; margin-top: 6px; }
.tb-band-sub:has(> .tb-reason:empty):has(> .tb-mech[hidden]) { display: none; }
.tb-band-sub .tb-reason { margin-top: 0; }
.tb-mech { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-left: auto; }
.tb-mech[hidden] { display: none; }
.tb-mech-text { font-size: 18px; font-weight: 700; background: rgb(0 0 0 / .22); border-radius: 8px; padding: 4px 10px; }
.tb-mech-text:empty { display: none; }
/* Long mechanic notes stay short on the card and tablet; the full text is in the tooltip and Downtime History. */
.mech-status, .tb-mech-text { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.mech-status[hidden], .tb-mech-text:empty { display: none; }
.tb-mech-text.is-called { animation: alertpulse 1.4s ease-in-out infinite; }
.tb-call-mech { border: 2px solid currentColor; border-radius: 10px; background: rgb(0 0 0 / .22); color: inherit; font-family: var(--font-cond); font-size: 18px; font-weight: 700; letter-spacing: .03em; padding: 0 14px; min-height: 32px; line-height: 1; }

/* Mechanic screen */
.mech-body { background: var(--bg); }
.mech-app { max-width: 900px; margin: 0 auto; padding: 12px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.mech-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.mech-title { font-family: var(--font-cond); font-size: 26px; }
.mech-who { color: var(--text-dim); }
.mech-tools { display: flex; align-items: center; gap: 10px; }
.mech-clock { font-family: var(--font-cond); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mech-list { display: grid; gap: 14px; }
.mech-card { border-radius: 16px; padding: 16px 18px; border: 2px solid var(--line); background: var(--panel); display: grid; gap: 8px; }
.mech-card.is-waiting { border: 4px solid var(--state-downtime); background: color-mix(in srgb, var(--state-downtime) 14%, var(--panel)); animation: mechflash 1s steps(2, start) infinite; }
.mech-card.is-mine { border-color: var(--state-running); }
.mech-card.is-taken { opacity: .8; }
@keyframes mechflash { 50% { border-color: transparent; } }
.mech-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.mech-line { font-family: var(--font-cond); font-size: 40px; font-weight: 700; line-height: 1; }
.mech-down { text-align: right; color: var(--text-dim); font-size: 14px; display: grid; }
.mech-timer { font-family: var(--font-cond); font-size: 34px; color: var(--state-downtime); font-variant-numeric: tabular-nums; }
.mech-reason { font-size: 22px; font-weight: 700; }
.mech-reason span { font-weight: 400; color: var(--text-dim); font-size: 18px; }
.mech-meta { color: var(--text-dim); font-size: 15px; }
.mech-accept { min-height: 84px; font-size: 34px; font-family: var(--font-cond); letter-spacing: .04em; }
.mech-taken { font-size: 20px; font-weight: 700; padding: 10px 0 2px; }
.mech-card.is-mine .mech-taken { color: var(--state-running); }
.mech-empty { text-align: center; padding: 50px 10px; color: var(--text-dim); font-size: 20px; border: 1px dashed var(--line); border-radius: 16px; }
.mech-empty-icon { font-size: 48px; color: var(--state-running); }
.mech-sub { font-size: 16px; color: var(--text-dim); margin-top: 10px; }
.mech-recent { display: grid; gap: 4px; }
.mech-recent-item { border-radius: 8px; background: var(--panel); }
.mech-recent-item .mech-notes { margin: 0 10px 8px; }
.mech-recent-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 10px; font-size: 14px; }
.mech-finish { min-height: 64px; font-size: 24px; font-family: var(--font-cond); letter-spacing: .03em; }
.mech-notes { border-left: 4px solid var(--state-running); background: color-mix(in srgb, var(--state-running) 10%, transparent); border-radius: 8px; padding: 8px 12px; }
.mech-notes-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.mech-notes-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; margin-top: 2px; }
.mech-notes-input { width: 100%; font-size: 18px; min-height: 130px; }
.hist-mech { display: grid; gap: 2px; max-width: 280px; font-size: 13px; }
.hist-mech-notes { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-dim); }
@media (max-width: 640px) { .mech-recent-row { grid-template-columns: 1fr 1fr; } .mech-line { font-size: 32px; } }
.mech-start { position: fixed; inset: 0; z-index: 50; background: rgb(8 10 14 / .96); color: #fff; display: grid; place-content: center; text-align: center; gap: 14px; padding: 24px; }
.mech-start[hidden] { display: none; }
.mech-start-icon { font-size: 64px; }
.mech-start h1 { font-family: var(--font-cond); font-size: 40px; margin: 0; }
.mech-start p { color: #c3cbd5; font-size: 18px; max-width: 520px; margin: 0 auto; }
.mech-start-btn { min-height: 90px; font-size: 32px; font-family: var(--font-cond); padding: 0 40px; }

/* Daily Direction Setting */
.dds { display: flex; flex-direction: column; gap: var(--gap); }
.dds-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 10px; }
.dds-tools { display: flex; gap: 6px; align-items: center; }
.dds-viewonly { font-family: var(--font-cond); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; margin-right: 6px; }
.dds-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .dds-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dds-date { display: flex; gap: 6px; align-items: center; }
.dds-date .input { flex: 1; min-width: 0; }
.dds-static { padding: 8px 0; font-weight: 600; }
.dds-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
@media (max-width: 1100px) { .dds-grid2 { grid-template-columns: minmax(0, 1fr); } }
.dds-band { font-family: var(--font-cond); letter-spacing: .06em; }
.dds-table td, .dds-table th { vertical-align: middle; }
.dds-input { min-height: 34px; padding: 4px 8px; }
.input.dds-w-num { width: 96px; max-width: 96px; text-align: right; display: inline-block; }
.dds-target { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.dds-target .field-hint { margin-left: 8px; font-weight: 400; }
.dds-chip { display: inline-block; min-width: 64px; text-align: center; border-radius: 6px; padding: 3px 8px; font-family: var(--font-cond); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.dds-green { background: color-mix(in srgb, var(--state-running) 22%, transparent); color: var(--state-running); }
.dds-yellow { background: color-mix(in srgb, var(--state-cleaning) 25%, transparent); color: var(--state-cleaning); }
.dds-red { background: color-mix(in srgb, var(--state-downtime) 22%, transparent); color: var(--state-downtime); }
.dds-none { color: var(--text-dim); min-width: 0; }
.dds-eff th.dds-shift { text-align: center; border-bottom: 2px solid var(--line); }
.dds-eff .dds-st { white-space: nowrap; }
.dds-group td { background: var(--panel-2); font-weight: 700; font-size: 13px; color: var(--text-dim); letter-spacing: .02em; }
.dds-inline { display: flex; gap: 8px; align-items: center; }
.dds-close.has-open { border-color: var(--state-downtime); }
.dds-gaps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dds-gaps li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dds-gaps li span:not(.dds-chip) { flex: 1; min-width: 160px; }
.dds-gaps li.covered { opacity: .7; }
.dds-gaps em { color: var(--state-running); font-style: normal; font-size: 13px; }
.dds-gaps em.dds-missing { color: var(--state-downtime); }
.dds-ok { color: var(--state-running); font-weight: 600; }
.dds-actions td { font-size: 14px; }
.dds-status { min-width: 130px; min-height: 32px; padding: 2px 6px; }
.st-complete { color: var(--state-running); }
.st-blocked { color: var(--state-downtime); }
.st-in-progress { color: var(--state-setup); }
.st-carryover { color: var(--state-changeover); }

/* Product Fill Yield */
.produced-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fy-btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 6px; padding: 3px 10px; font-family: var(--font-cond); font-weight: 600; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.fy-btn:hover { background: var(--panel-3); }
.tb-hour-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; min-width: 0; }
.tb-hour-row > * { min-width: 0; }
.tb-hour-row .tb-hour { flex-wrap: nowrap; gap: 10px; }
.tb-hour-row .tb-hour > strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.tb-hour-row .tb-hour > .tb-label, .tb-hour-row .tb-hour > .tb-cta { white-space: nowrap; flex: none; }
.tb-hour-row > .tb-hour[hidden] + .tb-yield { grid-column: 1 / -1; }
.tb-yield strong { margin-right: 0 !important; }
.fy-table { margin-bottom: 14px; }
.fy-table tr.clickable { cursor: pointer; }
.fy-ok { color: var(--state-running); }
.fy-under { color: var(--state-changeover); }
.fy-over { color: var(--state-downtime); }
.fy-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.fy-chip { display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 6px 10px; text-align: left; }
.fy-chip span { font-size: 12px; color: var(--text-dim); }
.fy-chip.active { border-color: var(--state-running); box-shadow: 0 0 0 1px var(--state-running) inset; }
.fy-chip.done strong::after { content: ' ✓'; color: var(--state-running); }
.fy-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .fy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fy-result { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: baseline; background: var(--panel-2); border-radius: 10px; padding: 10px 14px; margin-top: 6px; }
.fy-result strong { font-size: 22px; font-family: var(--font-cond); }

/* Viewer role: watch only, no controls. */
.watch-only .controls, .watch-only .bpm-edit, .watch-only .reason-alert { display: none !important; }
.watch-only .produced-row .link-btn { pointer-events: none; color: inherit; text-decoration: none; }
.watch-only-banner { background: var(--panel-2, #1b2129); color: var(--text-dim, #b4bdc8); text-align: center; padding: 6px 12px; font-size: 13px; }
.os-in_progress, .os-running { color: var(--state-running); } .os-done { color: var(--text-dim); }
.os-changing-to { color: var(--state-changeover, #a855f7); font-weight: 700; } .os-on-line { color: var(--state-downtime, #dc2626); font-weight: 700; } .os-partly-run { color: var(--muted); } .os-completed { color: var(--text-dim); } .os-cancelled { color: var(--muted); text-decoration: line-through; }
.empty { color: var(--muted); padding: 22px 8px; text-align: center; font-size: 14px; }
.empty-big { padding: 16px; background: var(--panel); border: 1px dashed var(--axis); border-radius: var(--radius); }
.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); max-width: 1800px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; }
.page-note { color: var(--text-dim); font-size: 14px; max-width: 110ch; }

/* ---- Forms and buttons ---- */
.btn { border: 1px solid var(--axis); background: var(--panel-2); border-radius: 7px; padding: 8px 14px; font-weight: 600; font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--panel-3); }
.btn:disabled, .btn.disabled { opacity: .4; pointer-events: none; }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-family: var(--font-cond); font-size: 20px; letter-spacing: .03em; min-height: 52px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--state-setup); border-color: transparent; color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--state-setup); filter: brightness(1.12); }
.btn-go { background: var(--state-running); border-color: transparent; color: #05140a; }
.btn-go:hover:not(:disabled) { background: var(--state-running); filter: brightness(1.12); }
[data-theme='light'] .btn-go { color: #fff; }
.btn-danger { background: var(--state-downtime); border-color: transparent; color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--state-downtime); filter: brightness(1.12); }
.btn-step { min-width: 58px; min-height: 58px; font-size: 18px; font-family: var(--font-cond); }
.btn-back { margin-bottom: 8px; }
.input { width: 100%; background: var(--panel-2); border: 1px solid var(--axis); border-radius: 7px; padding: 8px 10px; font-size: 15px; min-height: 40px; }
.input-sm { width: auto; min-height: 34px; padding: 4px 8px; font-size: 14px; }
.input-big { font-size: 22px; min-height: 54px; }
.input-huge { font-family: var(--font-cond); font-size: 46px; font-weight: 600; text-align: center; min-height: 64px; flex: 1; min-width: 100px; }
.mono { font-family: Consolas, 'Courier New', monospace; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; min-width: 0; }
.field-label { font-family: var(--font-cond); font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--text-dim); text-transform: uppercase; }
.field-hint { font-size: 12.5px; color: var(--muted); }
.center { text-align: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.filter-form { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: flex-start; }
.filter-form .field { flex: 0 1 180px; margin-bottom: 4px; }
.filter-form .field:has(.seg-control) { flex: 0 1 auto; }
.export-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; padding: 6px 0; margin-right: 14px; }
.check input { width: 20px; height: 20px; }
.check-row { display: flex; flex-wrap: wrap; }
.form-error { color: var(--state-downtime); font-weight: 600; min-height: 20px; margin-bottom: 6px; font-size: 14px; }
.code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 10px; overflow-x: auto; font-family: Consolas, 'Courier New', monospace; font-size: 13px; }
.report-preview { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.report-preview > div:empty { display: none; }
.report-title { margin-bottom: 8px; }
.report-title h3 { font-size: 18px; }
.report-title span { color: var(--text-dim); font-size: 14px; }
.report-preview .panel { margin-bottom: var(--gap); }

/* ---- Modals ---- */
.modal { background: var(--panel); color: var(--text); border: 1px solid var(--axis); border-radius: 12px; padding: 0; width: min(640px, 94vw); max-height: 92vh; box-shadow: 0 24px 64px rgb(0 0 0 / .5); }
.modal[open] { animation: rise .16s ease-out; display: flex; flex-direction: column; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal-wide { width: min(1000px, 96vw); }
.modal::backdrop { background: rgb(0 0 0 / .62); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-family: var(--font-cond); font-size: 26px; font-weight: 600; line-height: 1.1; }
.modal-sub { color: var(--text-dim); font-size: 14px; margin-top: 2px; }
.modal-timer { margin-left: auto; font-family: var(--font-cond); font-size: 30px; font-weight: 600; color: var(--state-downtime); font-variant-numeric: tabular-nums; }
.modal-body { padding: 14px 16px 16px; overflow-y: auto; }
.modal-text { margin-bottom: 12px; color: var(--text-dim); }
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 14px; }
.choice-list { display: grid; gap: 7px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 1px; border: 2px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 10px 12px; min-height: 58px; justify-content: center; }
.choice strong { font-size: 17px; }
.choice span { color: var(--text-dim); font-size: 13.5px; }
.choice:hover { border-color: var(--axis); }
.choice.selected { border-color: var(--state-running); background: var(--panel-3); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.tile-grid-cats { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile { display: flex; flex-direction: column; justify-content: center; gap: 1px; border: 1px solid var(--axis); background: var(--panel-2); border-radius: 8px; text-align: left; padding: 10px 12px; min-height: 66px; transition: background-color .1s ease; }
.tile:hover:not(:disabled) { background: var(--panel-3); }
.tile strong { font-size: 17px; line-height: 1.15; }
.tile span { color: var(--text-dim); font-size: 13px; }
.tile-cat { flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; min-height: 76px; }
.tile-code { flex: none; width: 34px; height: 34px; border-radius: 6px; background: var(--panel-3); display: grid; place-items: center; font-family: var(--font-cond); font-size: 20px; font-weight: 600; color: var(--text) !important; }
.picker-title { font-family: var(--font-cond); font-size: 15px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); margin: 2px 0 6px; }
.recent-block { margin-bottom: 14px; }
.picker-foot { margin-top: 12px; }
.stepper { display: flex; gap: 6px; align-items: stretch; flex-wrap: wrap; justify-content: center; margin-bottom: 8px; }
.audit-list { display: grid; gap: 10px; }
.audit-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.audit-head { font-size: 14px; }
.audit-reason { font-style: italic; color: var(--text-dim); margin: 4px 0; }
.audit-diff { font-size: 14px; margin-top: 2px; }
.audit-key { display: inline-block; min-width: 86px; color: var(--muted); }
.audit-diff del { color: var(--state-downtime); }
.audit-diff ins { color: var(--state-running); text-decoration: none; font-weight: 600; }
.audit-json { font-size: 11.5px; word-break: break-all; color: var(--text-dim); display: block; max-width: 340px; }

/* ---- Sign-in ---- */
.auth-page {
  position: fixed; inset: 0; overflow: auto; display: grid; place-items: center; padding: 16px;
  /* Sign-in picture: the plant floor on the left, the Stir Foods OEE Dashboard mark bottom right. */
  background: #0b0e12 url('/img/login-bg.webp') left center / cover no-repeat;
}
.auth-card {
  background: color-mix(in srgb, var(--panel) 88%, transparent); border: 1px solid var(--line); border-radius: 14px; padding: 26px; width: min(430px, 100%);
  backdrop-filter: blur(6px); box-shadow: 0 20px 60px rgb(0 0 0 / .55);
}
@media (max-width: 760px) { .auth-page { background-position: 30% center; } }
.auth-card .brand { margin-bottom: 22px; }

/* ---- Toasts ---- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 1000; max-width: min(460px, 92vw); }
.toast { background: var(--panel-3); border: 1px solid var(--axis); border-left: 5px solid var(--series-1); padding: 11px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / .4); font-weight: 500; animation: rise .16s ease-out; transition: opacity .3s ease; }
.toast.leaving { opacity: 0; }
.toast-ok { border-left-color: var(--state-running); }
.toast-warn { border-left-color: var(--state-changeover); }
.toast-error { border-left-color: var(--state-downtime); }

@media (max-width: 1500px) {
  .top-kpis { margin-left: 0; order: 5; width: 100%; justify-content: space-between; }
  .top-tools { margin-left: auto; }
  .topbar { position: static; }
}
/* ---- Hourly Sheet ---- */
.page-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.seg-big button { padding: 9px 14px; font-size: 15px; font-weight: 600; }
.sheet-selectors .field { flex: 0 1 auto; }
.sheet-selectors .input { width: 170px; }
.sheet-start { max-width: 640px; }
.sheet-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; margin-bottom: 10px; }
.sheet-head-fields { display: flex; gap: 12px; }
.sheet-head-fields .field { margin: 0; width: 170px; }
.sheet-kpis { display: flex; gap: 22px; }
.sheet-kpi span { display: block; font-family: var(--font-cond); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.sheet-kpi strong { font-family: var(--font-cond); font-size: 28px; font-weight: 600; line-height: 1.05; white-space: nowrap; }
.sheet-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.sheet-status { font-family: var(--font-cond); font-weight: 600; letter-spacing: .05em; font-size: 14px; padding: 3px 9px; border-radius: 5px; background: var(--panel-3); margin-right: 6px; }
.sheet-status.is-open { color: var(--state-running); }
.sheet-table td { padding: 7px 8px; }
.sheet-table tbody tr.sheet-row.clickable { cursor: pointer; }
.sheet-row { height: 50px; }
.sheet-row-now { box-shadow: inset 4px 0 0 var(--state-running); background: var(--panel-2); }
.sheet-hour strong { font-family: var(--font-cond); font-size: 20px; margin-right: 6px; }
.sheet-hour span { color: var(--muted); font-size: 13px; }
.sheet-hour em { display: inline-block; margin-left: 6px; font-style: normal; font-family: var(--font-cond); font-weight: 600; font-size: 12px; color: var(--state-running); }
.sheet-hour { white-space: nowrap; }
.sheet-product strong { display: block; font-weight: 600; white-space: nowrap; }
.sheet-product span { color: var(--muted); font-size: 12.5px; }
.sheet-enter { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.sheet-actual { font-family: var(--font-cond); font-size: 20px; font-weight: 600; }
.sheet-dt { font-size: 13.5px; min-width: 120px; }
.sheet-dt strong { font-weight: 600; white-space: nowrap; }
.sheet-note { color: var(--muted); }
.peak-edited { border-bottom: 2px solid var(--state-changeover); }
.earned { font-weight: 700; font-variant-numeric: tabular-nums; }
.earned-low { color: var(--state-downtime); }
.earned-mid { color: var(--state-changeover); }
.earned-good { color: var(--state-running); }
.sheet-warn-row td { padding: 0 8px 7px; border-top: 0; }
.sheet-warn { color: var(--state-changeover); font-size: 13px; font-weight: 500; }
.sheet-table tr:has(+ .sheet-warn-row) td { border-bottom: 0; }
.dt-entry { margin-bottom: 2px; }
.dt-tag { display: inline-block; margin-left: 5px; font-family: var(--font-cond); font-weight: 600; font-size: 11px; letter-spacing: .05em; padding: 0 4px; border-radius: 3px; border: 1px solid var(--axis); color: var(--text-dim); white-space: nowrap; }
.dt-tag-open { border-color: var(--state-downtime); color: var(--state-downtime); }
.sheet-link-note { margin-bottom: 8px; }
.sheet-blockers { margin: 0 0 10px; padding: 8px 12px 8px 28px; border-left: 4px solid var(--state-changeover); background: var(--panel-2); border-radius: 4px; font-size: 14px; }
.timer-list { display: grid; gap: 4px; margin-bottom: 4px; }
.timer-stop { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; background: var(--panel-2); border-radius: 6px; padding: 7px 10px; }
.timer-stop em { color: var(--muted); font-style: normal; font-size: 13px; }
.timer-empty { display: block; margin-bottom: 8px; }
.hour-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.hour-grid-product { grid-template-columns: 3fr 1fr; }
.hour-grid-product select { min-height: 54px; font-size: 18px; }
.hour-actual { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: stretch; background: var(--panel-2); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.hour-actual .field { margin: 0; }
.input-actual { background: var(--panel); }
.sheet-earned-live { display: flex; flex-direction: column; justify-content: center; }
.sheet-earned-live span { font-family: var(--font-cond); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sheet-earned-live strong { font-family: var(--font-cond); font-size: 46px; font-weight: 600; line-height: 1; }
.sheet-earned-live em { color: var(--state-changeover); font-style: normal; font-size: 13.5px; font-weight: 600; }
.dt-row { display: grid; grid-template-columns: 22px minmax(0, 2fr) 84px minmax(0, 2fr); gap: 8px; align-items: center; margin-bottom: 7px; }
.dt-num { font-family: var(--font-cond); font-size: 18px; color: var(--muted); text-align: center; }
.hour-form .link-btn { font-size: 12.5px; }
@media (max-width: 700px) {
  .hour-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dt-row { grid-template-columns: 22px minmax(0, 1fr) 76px; }
  .dt-row input:last-child { grid-column: 2 / -1; }
  .sheet-actions { margin-left: 0; }
}
/* ---- Run plan and product search ---- */
.seg-wrap-inline { flex-wrap: wrap; }
.plan-status { margin-left: auto; }
.plan-load { flex: 1 1 320px; max-width: 520px; }
.plan-load-text { font-size: 13.5px; color: var(--text-dim); }
.plan-load-bar { margin-top: 4px; }
.progress-fill.over { background: var(--state-changeover); }
.plan-seq { font-family: var(--font-cond); font-size: 20px; font-weight: 600; width: 34px; }
.plan-table td:nth-child(2) strong { white-space: nowrap; }
.allergen { font-family: var(--font-cond); font-weight: 600; letter-spacing: .05em; border: 1px solid var(--axis); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.plan-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.plan-chip { display: flex; flex-direction: column; align-items: flex-start; text-align: left; border: 2px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 7px 10px; max-width: 280px; }
.plan-chip strong { font-size: 14px; }
.plan-chip span { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.plan-chip.active, .sku-result.active { border-color: var(--state-running); }
.sku-search { margin-bottom: 10px; }
.sku-box { margin-bottom: 12px; }
.co-hint { margin-top: 10px; }
.sku-input { font-family: var(--font-cond); font-size: 28px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.sku-input::placeholder { text-transform: none; font-weight: 400; font-size: 20px; }
.sku-results { display: grid; gap: 4px; margin-top: 6px; }
.sku-results-tall { max-height: 320px; overflow-y: auto; margin-bottom: 10px; }
.sku-result { display: grid; grid-template-columns: 120px 1fr; gap: 2px 10px; text-align: left; border: 2px solid var(--line); background: var(--panel-2); border-radius: 7px; padding: 7px 10px; }
.sku-result em { grid-column: 2; font-style: normal; font-size: 12.5px; color: var(--muted); }
.sku-result:hover { border-color: var(--axis); }
.sku-tag { margin-left: 6px; text-transform: none; letter-spacing: 0; font-family: var(--font); font-weight: 600; color: var(--text); }
.sku-tag.muted { color: var(--muted); font-weight: 400; }
.plan-picked { display: flex; flex-direction: column; gap: 2px; background: var(--panel-2); border-left: 4px solid var(--state-running); border-radius: 4px; padding: 8px 12px; margin-bottom: 10px; }
.plan-picked span { color: var(--text-dim); font-size: 13.5px; }
.import-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.import-row .input[type=file], .import-row .input[type=search] { max-width: 420px; }
.import-counts { margin-bottom: 10px; }
.issue-group { border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; margin-bottom: 6px; }
.issue-group summary { cursor: pointer; font-weight: 600; }
@media (max-width: 700px) { .sku-result { grid-template-columns: 1fr; } .sku-result em { grid-column: 1; } }
/* ================= Operator tablet (/tablet) ================= */
body.tablet { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body.tablet button, body.tablet a { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.tb-demo { font-size: 12px; padding: 3px; }
.tb-app { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; min-height: 0; }
.tb-demo + .tb-app { height: calc(100dvh - 22px); }
.tb-top { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tb-line-btn { font-family: var(--font-cond); font-size: 30px; font-weight: 600; background: none; border: 0; padding: 4px 6px; border-radius: 8px; white-space: nowrap; }
.tb-line-btn:active { background: var(--panel-3); }
.tb-who { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; margin-right: auto; }
.tb-who strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-who span { color: var(--muted); font-size: 13px; }
.tb-clock { font-family: var(--font-cond); font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tb-live { width: 14px; height: 14px; border-radius: 50%; background: var(--state-downtime); flex: none; }
.tb-live.on { background: var(--state-running); }
.tb-icon { width: 54px; height: 54px; border-radius: 10px; border: 1px solid var(--axis); background: var(--panel-2); font-size: 24px; }
.tb-page { overflow-y: auto; min-height: 0; padding: 8px 12px; -webkit-overflow-scrolling: touch; }
.tb-page > .page { max-width: none; }
.tb-tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tb-tab { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 64px; border: 0; background: none; color: var(--text-dim); font-size: 18px; font-weight: 600; border-top: 4px solid transparent; }
.tb-tab.active { color: var(--text); border-top-color: var(--state-running); background: var(--panel-2); }
.tb-tab-icon { font-size: 20px; }

.tb-line { --accent: var(--state-idle); display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 12px; align-items: start; }
.tb-line.state-run { --accent: var(--state-running); } .tb-line.state-down { --accent: var(--state-downtime); } .tb-line.state-co { --accent: var(--state-changeover); }
.tb-line.state-setup { --accent: var(--state-setup); } .tb-line.state-clean { --accent: var(--state-cleaning); } .tb-line.state-stopped { --accent: var(--state-stopped); }
.tb-left { display: grid; gap: 8px; min-width: 0; }
.tb-band { background: var(--accent); color: var(--on-state); border-radius: 14px; padding: 9px 20px; transition: background-color .35s ease; }
.tb-line.state-down .tb-band, .tb-line.state-setup .tb-band { color: #fff; }
.tb-band-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tb-state-row { display: flex; align-items: center; gap: 14px; }
.tb-state-icon { font-size: 44px; line-height: 1; }
.tb-line.state-run .tb-state-icon { animation: pulse 2s ease-in-out infinite; }
.tb-state { font-family: var(--font-cond); font-size: 58px; font-weight: 600; letter-spacing: .02em; line-height: 1; }
.tb-timer { font-family: var(--font-cond); font-size: 52px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.tb-reason { font-size: 20px; font-weight: 600; margin-top: 8px; }
.tb-reason:empty { display: none; }
.tb-pick-reason { display: block; width: 100%; margin-top: 12px; min-height: 64px; border: 3px solid currentColor; border-radius: 12px; background: rgb(0 0 0 / .22); color: inherit; font-family: var(--font-cond); font-size: 26px; font-weight: 600; letter-spacing: .03em; animation: alertpulse 1.4s ease-in-out infinite; }
.tb-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; }
.tb-product { font-size: 23px; font-weight: 700; line-height: 1.15; }
.tb-sku { color: var(--text-dim); font-size: 17px; margin-top: 3px; }
.tb-progress { height: 10px; margin-top: 8px; }
.tb-progress-text { color: var(--text-dim); font-size: 15px; margin-top: 4px; }
.tb-progress-text:empty { display: none; }
.tb-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tb-tile { display: flex; flex-direction: column; align-items: flex-start; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; min-height: 78px; color: var(--text); }
.tb-tile.tappable:active { background: var(--panel-3); }
.tb-label { font-family: var(--font-cond); font-size: 15px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.tb-big { font-family: var(--font-cond); font-size: 48px; font-weight: 600; line-height: 1; margin-top: 2px; }
.tb-big.muted { color: var(--muted); }
.tb-sub { color: var(--text-dim); font-size: 15px; margin-top: 4px; }
.tb-cta { margin-top: auto; padding-top: 8px; font-family: var(--font-cond); font-size: 17px; font-weight: 600; letter-spacing: .05em; color: var(--series-1); }
.tb-minis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tb-mini { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; min-width: 0; }
.tb-mid { font-family: var(--font-cond); font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tb-mid.c-run { color: var(--state-running); } .tb-mid.c-down { color: var(--state-downtime); }
.tb-hour { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; min-height: 56px; color: var(--text); }
.tb-hour strong { font-size: 19px; margin-right: auto; }
.tb-hour .tb-cta { margin: 0; padding: 0; }
.tb-hour.due { border: 2px solid var(--state-changeover); }
.tb-hour.due .tb-cta { color: var(--state-changeover); }
.tb-overrun { color: var(--state-changeover); font-weight: 600; font-size: 16px; }

.tb-right { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; position: sticky; top: 0; min-width: 0; }
.tb-right > * { min-width: 0; }
.tb-btn { border: 0; border-radius: 14px; font-family: var(--font-cond); font-weight: 600; letter-spacing: .03em; font-size: 26px; min-height: 84px; padding: 6px 10px; line-height: 1.05; transition: transform .06s ease, filter .12s ease, opacity .2s ease; }
.tb-btn:active:not(:disabled) { transform: scale(.97); filter: brightness(1.12); }
.tb-btn:disabled { opacity: .22; }
.tb-go { background: var(--state-running); color: #05140a; min-height: 108px; font-size: 40px; }
.tb-stop { background: var(--state-downtime); color: #fff; min-height: 108px; font-size: 36px; }
.tb-co { background: var(--state-changeover); color: #1a0f02; }
.tb-setup { background: var(--state-setup); color: #fff; }
.tb-clean { background: var(--state-cleaning); color: #171102; }
.tb-end { background: var(--panel-3); color: var(--text); border: 2px solid var(--axis); min-height: 70px; font-size: 22px; }
.tb-row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tb-row3 .tb-btn { font-size: 21px; min-height: 96px; }
[data-theme='light'] .tb-go { color: #fff; }

.tb-line-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.tb-line-choice { --accent: var(--state-idle); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-height: 96px; padding: 14px; border-radius: 12px; border: 2px solid var(--line); border-left: 8px solid var(--accent); background: var(--panel-2); text-align: left; }
.tb-line-choice strong { font-family: var(--font-cond); font-size: 30px; }
.tb-line-choice.active { border-color: var(--state-running); border-left-color: var(--accent); }
.tb-line-choice.state-run { --accent: var(--state-running); } .tb-line-choice.state-down { --accent: var(--state-downtime); } .tb-line-choice.state-co { --accent: var(--state-changeover); }
.tb-line-choice.state-setup { --accent: var(--state-setup); } .tb-line-choice.state-clean { --accent: var(--state-cleaning); }
.tb-menu { display: grid; gap: 10px; }
body.tablet .modal { width: min(760px, 96vw); }
body.tablet .modal-wide { width: min(1100px, 97vw); }
body.tablet .tile { min-height: 80px; }
body.tablet .tile strong { font-size: 19px; }
body.tablet .choice { min-height: 70px; }
body.tablet .btn-lg { min-height: 64px; font-size: 24px; }

.tb-plan { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); display: grid; gap: 3px; }
.tb-plan-row { display: grid; grid-template-columns: 26px auto minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 15px; padding: 2px 8px; border-radius: 6px; }
.tb-plan-row strong { white-space: nowrap; }
.tb-plan-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-dim); }
.tb-plan-seq { font-family: var(--font-cond); font-weight: 600; color: var(--muted); }
.tb-plan-status { font-family: var(--font-cond); font-weight: 600; font-size: 13px; letter-spacing: .05em; }
.tb-plan-row.is-now { background: var(--panel-3); }
.tb-plan-row.is-now .tb-plan-status { color: var(--state-running); }
.tb-plan-row.is-next .tb-plan-status { color: var(--state-changeover); }
.tb-plan-row.live-changing_to .tb-plan-status { color: var(--state-changeover); }
.tb-plan-row.live-on_line .tb-plan-status { color: var(--state-downtime); }
.tb-plan-row.is-done { opacity: .55; }
.tb-plan-row.is-done strong { text-decoration: line-through; }
.tb-next { background: transparent; border: 3px solid var(--state-changeover); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 80px; }
.tb-next-label { font-size: 24px; color: var(--state-changeover); }
.tb-next-sku { font-family: var(--font); font-size: 15px; font-weight: 600; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0; }
.next-item { display: flex; flex-direction: column; gap: 3px; background: var(--panel-2); border-left: 5px solid var(--state-changeover); border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; }
.next-item strong { font-size: 20px; }
.next-go { background: var(--state-changeover); color: #1a0f02; border-color: transparent; }
.tb-max { display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 4px 12px; text-align: center; }
.tb-max-value { font-family: var(--font-cond); font-size: 34px; font-weight: 600; line-height: 1; }
.tb-max-sub { font-size: 13px; color: var(--muted); }
.hour-ask .input-huge { width: 100%; margin-bottom: 6px; }
.hour-item { display: flex; flex-direction: column; gap: 2px; background: var(--panel-2); border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; }
.hour-item strong { font-size: 18px; }
.hour-earned { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 16px; margin-bottom: 10px; }
.hour-earned strong { color: var(--text); font-size: 18px; }
/* Portrait or small tablets: one column, buttons first so the thumb reaches them. */
@media (max-width: 900px) {
  .tb-line { grid-template-columns: minmax(0, 1fr); }
  .tb-right { position: static; order: -1; grid-template-columns: 1fr 1fr; }
  .tb-right .tb-go, .tb-right .tb-stop { min-height: 104px; font-size: 30px; }
  .tb-row3 { grid-column: 1 / -1; }
  .tb-end { grid-column: 1 / -1; }
  .tb-band-wrap { order: -2; }
  .tb-left { display: contents; }
  .tb-state { font-size: 46px; }
  .tb-timer { font-size: 42px; }
  .tb-minis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-who span { display: none; }
}
@media (max-width: 520px) {
  .tb-clock { display: none; }
  .tb-line-btn { font-size: 24px; }
  .tb-big { font-size: 48px; }
}
@media print { .topbar, .controls, .demo-banner { display: none; } }
