/* ---------- tokens ---------- */
:root {
  --font: "Noto Sans Thai", "IBM Plex Sans Thai", "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --sidebar-w: 232px; --topbar-h: 60px;
  --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / .18);
}
:root, [data-theme="light"] {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8fafc; --sunken: #eef1f5;
  --text: #0f1b2d; --text-2: #3e4b5e; --muted: #6a768a; --line: #e2e7ee; --line-strong: #cfd6e0;
  --accent: #1f5fd1; --accent-hover: #194fb0; --accent-soft: #e7effd; --accent-text: #ffffff;
  --ok: #157f45; --ok-soft: #e3f4ea; --warn: #a15c00; --warn-soft: #fff1d6; --danger: #c3262b; --danger-soft: #fdeaea;
  --sidebar: #0f1b2d; --sidebar-text: #c7d0dd; --sidebar-active: #1d2d45; --sidebar-accent: #6ea0ff;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d1117; --surface: #151b23; --surface-2: #19202a; --sunken: #10151c;
  --text: #e6edf3; --text-2: #c2cbd6; --muted: #8b96a5; --line: #262f3b; --line-strong: #34404f;
  --accent: #5b8def; --accent-hover: #75a0f3; --accent-soft: #1c2a44; --accent-text: #0d1117;
  --ok: #4cc38a; --ok-soft: #14301f; --warn: #e5a83b; --warn-soft: #33270f; --danger: #f2716b; --danger-soft: #3a1b1b;
  --sidebar: #0a0e14; --sidebar-text: #aeb8c5; --sidebar-active: #1a2230; --sidebar-accent: #7aa7ff;
  --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #0d1117; --surface: #151b23; --surface-2: #19202a; --sunken: #10151c;
    --text: #e6edf3; --text-2: #c2cbd6; --muted: #8b96a5; --line: #262f3b; --line-strong: #34404f;
    --accent: #5b8def; --accent-hover: #75a0f3; --accent-soft: #1c2a44; --accent-text: #0d1117;
    --ok: #4cc38a; --ok-soft: #14301f; --warn: #e5a83b; --warn-soft: #33270f; --danger: #f2716b; --danger-soft: #3a1b1b;
    --sidebar: #0a0e14; --sidebar-text: #aeb8c5; --sidebar-active: #1a2230; --sidebar-accent: #7aa7ff;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.xs { font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 16px keeps iOS Safari from zooming into inputs */
input, textarea, select { font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 7px 10px; min-height: 36px; }
input:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; resize: vertical; }

.btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.danger { color: var(--danger); }
.btn.icon { width: 34px; padding: 0; }
.btn.block { width: 100%; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; line-height: 1;
  padding: 4px 8px; border-radius: 99px; background: var(--sunken); color: var(--text-2); white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.status-dot.danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.alert { padding: 8px 12px; border-radius: var(--r-sm); font-size: 13px; margin: 0; }
.alert.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- sign-in ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 28px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 20px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.logo-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; font-weight: 700;
  font-size: 12px; letter-spacing: .5px; color: #fff; background: linear-gradient(135deg, #2f6fe4, #1846a8); }
.logo-mark.sm { width: 30px; height: 30px; font-size: 10px; border-radius: 8px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 15px; padding: 2px 8px 18px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--sidebar-text);
  font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--sidebar-active); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--sidebar-accent); }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.nav .count { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: rgb(255 255 255 / .1); }
.nav .count.warn:not(:empty) { background: var(--warn); color: #1a1200; }
.nav .count:empty { display: none; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 8px; }
.bot-mini { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.page-title { font-size: 17px; font-weight: 600; }
.quick-search { margin-left: auto; }
.quick-search input { width: 240px; padding-left: 32px; min-height: 34px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b96a5' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3 3'/%3E%3C/svg%3E") 10px center no-repeat; }
.theme-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.theme-switch button { border: none; background: var(--surface); color: var(--muted); width: 32px; height: 32px; cursor: pointer; font-size: 14px; }
.theme-switch button + button { border-left: 1px solid var(--line); }
.theme-switch button.on { background: var(--accent-soft); color: var(--accent); }
.user-menu { position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--accent-soft);
  color: var(--accent); font-weight: 600; cursor: pointer; }
.popover { position: absolute; right: 0; top: 42px; width: 230px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 14px; display: grid; gap: 6px; }
.pop-name { font-weight: 600; }

.content { padding: 20px 24px 48px; display: grid; gap: 16px; max-width: 1400px; width: 100%; }
.view { display: grid; gap: 16px; align-content: start; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.panel.flush { padding: 0; }
/* No overflow:hidden here: it would make the panel the sticky container and the header would
   sit 60px down inside it. Round the corners on the cells instead. */
.panel.flush .data-table th:first-child { border-top-left-radius: var(--r); }
.panel.flush .data-table th:last-child { border-top-right-radius: var(--r); }
.panel.narrow { max-width: 720px; display: grid; gap: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- KPIs ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 6px; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .split { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; margin-top: 4px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.attention-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.attention-item:last-child { border-bottom: none; }
.attention-item:hover .sheet-name { color: var(--accent); }

/* ---------- toolbar + chips ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 13px; font-weight: 500; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip span { color: var(--muted); font-size: 12px; margin-left: 2px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.on span { color: inherit; opacity: .8; }
.search-input { margin-left: auto; width: 320px; max-width: 100%; }

/* ---------- table ---------- */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th { position: sticky; top: var(--topbar-h); z-index: 1; background: var(--surface-2); text-align: left;
  font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tbody tr { cursor: pointer; transition: background .1s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr.is-paused td { opacity: .6; }
.data-table tbody tr.is-pinned td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.data-table tbody tr.is-late td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.w-rank { width: 64px; } .w-prog { width: 200px; } .w-date { width: 150px; } .w-eta { width: 190px; } .w-act { width: 96px; }
.rank { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.sheet-name { font-weight: 600; color: var(--text); }
.meta { font-size: 12px; color: var(--muted); }
.note { font-size: 12px; background: var(--warn-soft); color: var(--text-2); padding: 2px 8px; border-radius: var(--r-sm); display: inline-block; margin-top: 4px; }
.progress { height: 6px; background: var(--sunken); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.eta-value { font-weight: 600; }
.eta-value.late { color: var(--danger); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.table-foot { padding: 10px 12px; display: flex; justify-content: center; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.finished summary { cursor: pointer; font-weight: 600; }
.finished ul { margin: 10px 0 0; padding-left: 18px; font-size: 13px; }

/* ---------- cards (review, search) ---------- */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); display: grid; gap: 6px; }
.card .cid { font-family: var(--mono); font-size: 16px; font-weight: 600; letter-spacing: .5px; }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- drawer ---------- */
.backdrop { position: fixed; inset: 0; background: rgb(10 15 25 / .45); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 31; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .2s ease; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 17px; }
.drawer-body { padding: 16px 20px 32px; overflow-y: auto; display: grid; gap: 18px; align-content: start; }
.drawer-section { display: grid; gap: 8px; }
.drawer-section h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; }
.stat-box b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.stat-box span { font-size: 12px; color: var(--muted); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: var(--r-sm); font-size: 13px; box-shadow: var(--shadow-lg); }

.bottom-nav { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .w-eta { width: 160px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 0 14px; gap: 8px; }
  .content { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  .quick-search input { width: 180px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { position: relative; display: grid; justify-items: center; gap: 2px; padding: 8px 0 10px; font-size: 11px;
    color: var(--muted); text-decoration: none; }
  .bottom-nav a span { font-size: 18px; line-height: 1; }
  .bottom-nav a.active { color: var(--accent); }
  .dot-count { position: absolute; top: 6px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }

  /* table becomes cards */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tbody tr { display: grid; grid-template-columns: 44px 1fr auto; gap: 4px 10px; padding: 12px 14px;
    border-bottom: 1px solid var(--line); }
  .data-table td { padding: 0; border: none; }
  .data-table td.c-rank { grid-row: span 3; }
  .data-table td.c-name { grid-column: 2; }
  .data-table td.c-act { grid-column: 3; grid-row: 1; }
  .data-table td.c-prog, .data-table td.c-due, .data-table td.c-eta { grid-column: 2 / span 2; }
  .data-table td.c-due:empty { display: none; }
  .data-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  .search-input { width: 100%; margin-left: 0; }
}
@media (max-width: 560px) {
  .page-title { font-size: 15px; }
  .quick-search { display: none; }
  .theme-switch { margin-left: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpis .kpi:first-child { grid-column: 1 / -1; }
  .kpi { padding: 10px 12px; }
  #envBadge { display: none !important; }
  .kpi .value { font-size: 22px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- live view ---------- */
.live-pill { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 0 rgb(61 220 132 / .6); animation: ping 1.6s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgb(61 220 132 / .55); } 80%, 100% { box-shadow: 0 0 0 8px rgb(61 220 132 / 0); } }

.flow { display: grid; grid-template-columns: minmax(140px, 1fr) 80px minmax(170px, 1fr) 80px minmax(280px, 2fr); align-items: stretch;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.flow-node { display: grid; align-content: center; gap: 2px; }
.flow-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.flow-value { font-size: 22px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
#flowKtb { font-size: 15px; }
.flow-arrow { position: relative; align-self: center; height: 4px; margin: 0 10px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.flow-arrow span { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, var(--accent) 0 10px, transparent 10px 22px); opacity: .25; }
.flow.running .flow-arrow span { opacity: .9; animation: flowmove 1s linear infinite; }
@keyframes flowmove { from { transform: translateX(-22px); } to { transform: translateX(0); } }
.flow-counts { display: flex; gap: 10px; }
.cnt { flex: 1; border-radius: var(--r-sm); padding: 6px 10px; display: grid; }
.cnt b { font-size: 20px; }
.cnt span { font-size: 12px; }
.cnt.ok { background: var(--ok-soft); color: var(--ok); }
.cnt.no { background: var(--sunken); color: var(--text-2); }
.cnt.under { background: var(--warn-soft); color: var(--warn); }
.bump { animation: bump .45s ease; display: inline-block; }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.25); } 100% { transform: scale(1); } }

.live-grid { display: grid; gap: 16px; grid-template-columns: minmax(200px, 1fr) minmax(0, 2.2fr) minmax(240px, 1.2fr); align-items: start; }
.live-col { padding: 14px; }
.conveyor, .feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.conveyor li { display: grid; gap: 0; padding: 6px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.conveyor li:first-child { border-color: var(--accent); background: var(--accent-soft); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); }
.feed-main, .feed-side { display: grid; min-width: 0; }
.feed-side { justify-items: end; }
.feed-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.feed-dot.ok { background: var(--ok); } .feed-dot.under { background: var(--warn); } .feed-dot.no { background: var(--muted); }
.entering { animation: slidein .45s cubic-bezier(.2, .8, .2, 1); }
.feed .entering { animation: dropin .55s cubic-bezier(.2, .8, .2, 1); }
.leaving { animation: slideout .4s ease forwards; }
@keyframes slidein { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes slideout { to { opacity: 0; transform: translateX(40px); height: 0; padding-top: 0; padding-bottom: 0; margin: 0; } }
@keyframes dropin { 0% { opacity: 0; transform: translateY(-16px) scale(.97); background: var(--accent-soft); } 60% { opacity: 1; } 100% { transform: none; } }

.lanes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.lane { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); display: grid; gap: 10px;
  transition: border-color .2s, box-shadow .2s, opacity .2s; }
.lane:not(.busy) { opacity: .7; }
.lane.holding { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.lane.waiting { border-style: dashed; }
.lane-head { display: flex; align-items: center; gap: 8px; }
.lane-name { font-weight: 600; }
.lane-done { margin-left: auto; }
.lane-cid { font-size: 20px; font-weight: 650; letter-spacing: .5px; }
.lane-sheet { min-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.steps li { display: grid; gap: 4px; justify-items: center; }
.steps li span { width: 100%; height: 6px; border-radius: 99px; background: var(--sunken); transition: background .3s; }
.steps li em { font-style: normal; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.steps li.done span { background: var(--ok); }
.steps li.current span { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.steps li.current em { color: var(--accent); font-weight: 600; }
@keyframes pulse { 50% { opacity: .35; } }
.lane-foot { display: flex; justify-content: space-between; font-size: 13px; }
.lane-step { font-weight: 500; }
.lane.flash-ok { animation: flash-ok 1s ease; } .lane.flash-no { animation: flash-no 1s ease; }
.lane.flash-under { animation: flash-under 1s ease; } .lane.flash-skip, .lane.flash-review { animation: flash-skip 1s ease; }
@keyframes flash-ok { 0% { background: var(--ok-soft); border-color: var(--ok); } 100% { } }
@keyframes flash-no { 0% { background: var(--sunken); border-color: var(--muted); } 100% { } }
@keyframes flash-under { 0% { background: var(--warn-soft); border-color: var(--warn); } 100% { } }
@keyframes flash-skip { 0% { background: var(--danger-soft); border-color: var(--danger); } 100% { } }

@media (max-width: 1200px) {
  .live-grid { grid-template-columns: 1fr 1fr; }
  .lanes { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 760px) {
  .flow { grid-template-columns: 1fr 1fr; gap: 12px; }
  .flow-arrow { display: none; }
  .flow-node.results { grid-column: 1 / -1; }
  .live-grid { grid-template-columns: 1fr; }
  .bottom-nav a { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- report ---------- */
/* success/fail: blue + critical red, validated for CVD in both modes (dataviz validate_palette.js) */
:root, [data-theme="light"] { --c-success: #257de0; --c-fail: #dc3c3d; --c-grid: #e7e7e7; --c-axis: #c2c2c2; }
[data-theme="dark"] { --c-success: #338ced; --c-fail: #dc3c3d; --c-grid: #303030; --c-axis: #474747; }
@media (prefers-color-scheme: dark) { [data-theme="auto"] { --c-success: #338ced; --c-fail: #dc3c3d; --c-grid: #303030; --c-axis: #474747; } }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.sw.success { background: var(--c-success); } .sw.fail { background: var(--c-fail); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; padding: 5px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.date-range input { min-height: 34px; padding: 4px 8px; }
.chart { position: relative; width: 100%; overflow: hidden; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--c-grid); stroke-width: 1; }
.chart .axis { stroke: var(--c-axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar.success { fill: var(--c-success); }
.chart .bar.fail { fill: var(--c-fail); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit.on { fill: var(--text); fill-opacity: .05; }
.chart-tip { position: absolute; pointer-events: none; min-width: 200px; max-width: 300px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); box-shadow: var(--shadow-lg); padding: 10px 12px; font-size: 13px; z-index: 2; }
.tip-title { font-weight: 600; margin-bottom: 4px; }
.tip-row b { margin-left: 4px; }
.tip-sub { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.table-scroll { overflow-x: auto; }
.data-table.compact td, .data-table.compact th { padding: 7px 10px; position: static; }
.num-col { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar { display: grid; grid-template-columns: minmax(150px, 1.2fr) 2fr 60px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.hbar-track { height: 10px; background: var(--sunken); border-radius: 99px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--c-fail); border-radius: 0 4px 4px 0; }
.hbar-value { text-align: right; font-weight: 600; }
.kpi .label .sw { margin-right: 2px; }
@media (max-width: 560px) {
  .hbar { grid-template-columns: 1fr 60px; }
  .hbar-track { grid-column: 1 / -1; grid-row: 2; }
  .legend { display: none; }
}
