/* DataLab - desktop layout. Colours and sizes are tokens on :root. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --ink: #1d2430;
  --ink-2: #485263;
  --muted: #6c7686;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #e6f4f2;
  --accent-ink: #0b5650;
  --danger: #b42318;   --danger-soft: #fdecea;
  --warning: #a15c07;  --warning-soft: #fdf3e1;
  --success: #067647;  --success-soft: #e7f6ee;
  --info: #175cd3;     --info-soft: #eaf1fd;
  --spark: #7fb8b2;
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-w: 232px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink);
  background: var(--bg); min-width: 1200px;
  display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.ico { flex: none; vertical-align: -3px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.brand-name { display: block; font-weight: 650; font-size: 15px; }
.brand-sub { display: block; font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item.is-disabled { color: #a5adb8; cursor: default; }
.nav-step {
  width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 600;
  display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); flex: none;
}
.nav-item.is-active .nav-step { background: var(--accent); border-color: var(--accent); color: #fff; }
.nav-soon {
  margin-left: auto; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  color: #a5adb8; border: 1px solid var(--border); border-radius: 4px; padding: 0 5px;
}
.nav-section { margin: 18px 10px 6px; display: flex; flex-direction: column; gap: 2px; }
.nav-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.nav-dataset { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.foot-link { color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.foot-link.is-active { color: var(--accent-ink); }

/* ---------------------------------------------------------------- page */
.main { padding: 26px 32px 110px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; }
.page-sub { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-body { padding: 18px 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 15px; }
.section { margin-top: 22px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }

/* ---------------------------------------------------------------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #eef0f3; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 13px; }
.field-hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=search], input[type=number], select {
  height: 32px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; color: var(--ink); background: var(--surface); min-width: 0;
}
select { padding-right: 26px; }
input:focus, select:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px;
}
.check { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-3 { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- alerts & kpis */
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid; margin-bottom: 10px;
}
.alert .ico { margin-top: 1px; }
.alert-success { background: var(--success-soft); border-color: #b5e3c9; color: var(--success); }
.alert-error   { background: var(--danger-soft);  border-color: #f5c2bd; color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: #f2d6a5; color: var(--warning); }
.alert-info    { background: var(--info-soft);    border-color: #c4d7f8; color: var(--info); }
.alert > div { color: var(--ink); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-icon { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.kpi-icon.slate { background: #eef0f3; color: var(--ink-2); }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.25; }
.kpi-sub { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.table-clickable tbody tr:hover { background: var(--surface-2); }
.data-preview td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.data-preview th { position: sticky; top: 0; }
.null { color: #b0b7c2; font-style: italic; }

/* ---------------------------------------------------------------- empty state */
.empty { text-align: center; padding: 56px 20px; }
.empty-icon { width: 48px; height: 48px; border-radius: 12px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.empty h2 { font-size: 16px; margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 0 16px; }

/* ---------------------------------------------------------------- importer */
.dropzone {
  display: block; position: relative;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  padding: 30px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-icon { color: var(--accent); margin-bottom: 8px; }
.dropzone-title { font-weight: 600; }
.dropzone-file { margin-top: 8px; font-weight: 600; color: var(--accent-ink); }
.steps-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.steps-list li { display: flex; gap: 12px; }
.steps-list .nav-step { margin-top: 1px; }
.steps-list strong { display: block; }

/* ---------------------------------------------------------------- role badges */
.role-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2);
}
.role-entity_id, .role-session_id, .role-timestamp { background: #eef2fb; border-color: #cfdaf3; color: #2f4f9a; }
.role-feature { background: var(--accent-soft); border-color: #bfe0dc; color: var(--accent-ink); }
.role-outcome { background: #fdf1e4; border-color: #f3d2ad; color: #9a4d0b; }
.role-ignore { color: #8a93a0; }

/* ---------------------------------------------------------------- column editor */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; color: var(--ink-2); font-weight: 550;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--accent-ink); border-color: var(--accent); }

.checks { display: flex; flex-direction: column; gap: 0; }
.checks .alert { margin-bottom: 6px; padding: 8px 12px; }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
  position: sticky; top: 0; z-index: 4; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.chips { display: flex; gap: 6px; }
.chip {
  height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip .chip-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.is-on .chip-n { color: #c9ced6; }
.toolbar-search { position: relative; margin-left: auto; }
.toolbar-search .ico { position: absolute; left: 9px; top: 8px; color: var(--muted); }
.toolbar-search input { padding-left: 30px; width: 220px; }
.bulk { display: none; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; background: var(--ink); color: #fff; border-radius: var(--radius-sm); }
.bulk.is-on { display: inline-flex; }
.bulk select { height: 28px; }
.bulk .btn { height: 28px; }

.coltable { width: 100%; border-collapse: collapse; table-layout: fixed; }
.coltable th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
.coltable td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.coltable tr:last-child td { border-bottom: 0; }
.coltable tr.is-selected td { background: #f3f8f7; }
.coltable tr.is-hidden { display: none; }
.coltable select, .coltable input[type=number], .coltable input[type=text] { width: 100%; height: 30px; font-size: 13px; }
.coltable .w-check { width: 40px; padding-left: 16px; }
.coltable .w-name { width: 15%; }
.coltable .w-prof { width: 12%; }
.coltable .w-sel { width: 12.5%; }
.coltable .w-sel-w { width: 14%; }
.coltable .w-tr { width: 17%; }
.coltable .w-use { width: 78px; text-align: center; }
.coltable select { padding: 0 18px 0 6px; font-size: 12.5px; }
.coltable td:not(.w-check) { padding-left: 5px; padding-right: 5px; }
.col-name { font-weight: 600; word-break: break-all; }
.col-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.col-reason { font-size: 12px; color: var(--ink-2); margin-top: 6px; display: flex; gap: 5px; }
.col-reason .ico { color: var(--accent); margin-top: 1px; }
.col-param { margin-top: 6px; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.col-param input { width: 64px !important; height: 26px !important; }
.col-param.is-off { display: none; }
select.is-changed { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
select[disabled] { background: var(--surface-2); color: #a5adb8; }
.toggle { position: relative; display: inline-block; width: 34px; height: 20px; margin-top: 5px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: #cfd4da; border-radius: 999px; transition: background .15s; cursor: pointer; }
.toggle span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(14px); }
.toggle input:disabled + span { opacity: .45; cursor: default; }
.toggle input:focus-visible + span { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

.spark { display: block; }
.spark rect { fill: var(--spark); }
.spark-cap { font-size: 11.5px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.topvals { display: flex; flex-direction: column; gap: 3px; }
.topv { position: relative; display: flex; align-items: center; gap: 6px; font-size: 11.5px; height: 16px; padding: 0 4px; }
.topv-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); border-radius: 3px; }
.topv-lab { position: relative; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topv-n { position: relative; color: var(--muted); font-variant-numeric: tabular-nums; }

.savebar {
  position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; z-index: 5;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16, 24, 40, .06);
  padding: 12px 32px; display: flex; align-items: center; gap: 14px;
}
.savebar-status { color: var(--muted); }
.savebar-status strong { color: var(--ink); }
.savebar .spacer { flex: 1; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }

/* ---------------------------------------------------------------- definition list */
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* ---------------------------------------------------------------- error page */
.error-box { max-width: 560px; margin: 60px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; text-align: center; }
.error-code { font-size: 44px; font-weight: 700; color: var(--accent); }
.error-box h1 { font-size: 18px; margin: 6px 0; }
.error-box p { color: var(--muted); }
.error-detail { text-align: left; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); padding: 12px; overflow: auto; max-height: 300px; border-radius: var(--radius-sm); }

/* ---------------------------------------------------------------- features & PCA */
.card-foot { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.card-foot .spacer { flex: 1; }
.fs-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fs-block { border: 0; margin: 0; padding: 16px 20px; border-right: 1px solid var(--border); min-width: 0; }
.fs-block:last-child { border-right: 0; }
.fs-block legend { padding: 0; font-weight: 600; font-size: 13.5px; display: block; width: 100%; }
.fs-help { margin: 4px 0 12px; color: var(--muted); font-size: 12.5px; }
.fs-block .field { margin-top: 10px; }
.fs-block .field select { width: 100%; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; font-size: 13px; }
.opt input[type=radio] { margin-top: 3px; accent-color: var(--accent); }
.opt strong { font-weight: 550; }
.opt-help { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.opt.is-disabled, .check.is-disabled { color: #a5adb8; cursor: default; }
.checks-col { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.checks-col .check { font-weight: 450; }
.inline-num { width: 64px; height: 26px !important; margin: 0 3px; }
.section-title { font-size: 17px; margin: 28px 0 14px; }
.kpi-of { font-size: 13px; font-weight: 500; color: var(--muted); }

.job { padding: 14px 18px; margin-bottom: 16px; border-color: #bfe0dc; position: sticky; top: 12px; z-index: 6;
  box-shadow: 0 6px 20px rgba(16, 24, 40, .10); }
.job-row { display: flex; align-items: center; gap: 12px; color: var(--accent); }
.job-text { display: flex; flex-direction: column; color: var(--ink); flex: 1; }
.job-msg { color: var(--muted); font-size: 12.5px; }
.job-pct { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ink); }
.bar { height: 6px; border-radius: 999px; background: var(--accent-soft); margin-top: 10px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }

.grid-2-even { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #eceef1; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: #b9dcd8; }
.chart .bar.kept { fill: var(--accent); }
.chart .bar:hover { fill: var(--accent-hover); }
.chart .cumline { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.chart .cumdot { fill: transparent; stroke: transparent; }
.chart .cumdot:hover { fill: var(--ink); stroke: #fff; stroke-width: 2; }
.chart-cap { margin: 10px 0 0; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 10px; border-radius: 2px; }
.sw-bar { background: var(--accent); }
.sw-faint { background: #b9dcd8; }
.sw-line { height: 2px; background: var(--ink); width: 16px; }

.heatmap { border-collapse: separate; border-spacing: 2px; margin: 10px 14px 14px; font-size: 12px; }
.heatmap th { font-weight: 600; color: var(--muted); padding: 4px 6px; }
.heatmap .heat-name { text-align: right; font-weight: 400; white-space: nowrap; padding-right: 10px; }
.heatmap .heat { width: 58px; text-align: center; padding: 6px 4px; border-radius: 4px; font-variant-numeric: tabular-nums; }

.table.inputs td { font-size: 13px; white-space: nowrap; }
.table.inputs td:first-child code { white-space: normal; }
.table.inputs tr.is-off td { color: #9aa2ad; }
.table .center { text-align: center; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: #eef0f3; color: var(--ink-2); margin-left: 4px; }
.tag-warn { background: var(--warning-soft); color: var(--warning); }
.corr-strong { color: var(--danger); font-weight: 600; }
.table tr.is-current td { background: var(--accent-soft); }
.leak-list { margin: 6px 0 6px 18px; padding: 0; }
.leak-list li { margin: 2px 0; }

/* ---------------------------------------------------------------- segments */
.seg-id { display: inline-block; min-width: 30px; padding: 1px 7px; border-radius: 5px; background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.seg-table input[type=text] { width: 100%; min-width: 180px; }
.seg-table select { min-width: 150px; }
.seg-table td { vertical-align: middle; }
.seg-table tr.is-u .seg-id { background: #8a93a0; }
.seg-table tr.is-merged td { background: var(--surface-2); }
.seg-table tr.is-merged .seg-id { background: #a5adb8; }
.share { width: 90px; height: 6px; border-radius: 999px; background: #eef0f3; overflow: hidden; margin-bottom: 2px; }
.share span { display: block; height: 100%; background: var(--accent); }
.table.outcomes tr.is-u td, .table.outcomes tr.is-u td:first-child { color: var(--ink-2); }
.table.outcomes tr.total td { font-weight: 600; background: var(--surface-2); }
.table.outcomes th[colspan] { text-align: center; border-left: 1px solid var(--border); }
.lift { display: inline-block; min-width: 46px; padding: 0 6px; border-radius: 4px; font-weight: 600; }
.lift-hi { background: #fdecea; color: var(--danger); }
.lift-mid { background: var(--warning-soft); color: var(--warning); }
.lift-lo { color: var(--muted); }
.chart .pt { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.chart .pt-best { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.chart .axis-strong { fill: var(--accent-ink); font-weight: 700; }
.heatmap .heat-col { vertical-align: bottom; padding: 4px 2px; max-width: 64px; font-size: 11.5px; line-height: 1.2; white-space: normal; text-align: center; }
.heatmap.trans .heat { width: 64px; }
.heatmap.trans .heat.diag { box-shadow: inset 0 0 0 2px rgba(29,36,48,.35); }
details.rules { border-top: 1px solid var(--border); padding: 10px 20px; }
details.rules summary { cursor: pointer; font-weight: 550; display: flex; gap: 8px; align-items: center; }
details.rules ul { margin: 8px 0 2px 20px; padding: 0; }
details.rules li { margin: 6px 0; line-height: 1.5; }
.rule { font-family: var(--mono); font-size: 12.5px; }

.card-head .spacer { flex: 1; }

.busy-banner { position: sticky; top: 12px; z-index: 7; display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  padding: 12px 16px; border-radius: var(--radius); background: var(--accent); color: #fff; font-weight: 550;
  box-shadow: 0 6px 20px rgba(16, 24, 40, .14); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .8s linear infinite; flex: none; }
.job .job-row .ico { animation: pulse 1.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .spinner, .job .job-row .ico { animation: none; } }
details.pca-preview > summary { cursor: pointer; list-style: none; border-bottom: 0; }
details.pca-preview > summary::-webkit-details-marker { display: none; }
details.pca-preview > summary h2::after { content: "Show"; margin-left: 10px; font-size: 12px; font-weight: 600; color: var(--accent); }
details.pca-preview[open] > summary { border-bottom: 1px solid var(--border); }
details.pca-preview[open] > summary h2::after { content: "Hide"; }
.heatmap th.pc-kept { color: var(--accent-ink); }
.pc-note { display: block; font-size: 10px; font-weight: 500; color: #a5adb8; }
.corrmap .heat { width: 38px; min-width: 38px; padding: 5px 2px; font-size: 11px; }
.corrmap .corr-diag { background: #e3e6ea; }
.corrmap .corr-flag { box-shadow: inset 0 0 0 2px var(--ink); }
.corrmap th.corr-col { vertical-align: bottom; height: 150px; padding: 0 0 6px; width: 38px; }
.corrmap th.corr-col span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap;
  font-family: var(--mono); font-weight: 400; font-size: 11.5px; color: var(--ink-2); max-height: 150px; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- outcomes */
.oc-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.oc-grid .checks-col .check { align-items: flex-start; }
.oc-grid .checks-col .check input { margin-top: 2px; }
.tg-table td, .tg-table th { padding-top: 7px; padding-bottom: 7px; }
.tg-table th[colspan] { text-align: center; border-left: 1px solid var(--border); }
.oc-dim { opacity: .35; }
.table.cmp th[colspan] { text-align: center; border-left: 1px solid var(--border); }
.table.cmp tr.is-best td { background: var(--accent-soft); }
.sw-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 0; }
.chart .prline { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .prline.dashed { stroke-dasharray: 5 4; }
.chart .baseline { stroke: #9aa2ad; stroke-width: 1; stroke-dasharray: 2 3; }
.imp { display: flex; flex-direction: column; gap: 7px; }
.imp-row { display: grid; grid-template-columns: minmax(0, 220px) 1fr 52px; gap: 10px; align-items: center; font-size: 12.5px; }
.imp-name { font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-bar { height: 10px; background: #eef0f3; border-radius: 3px; overflow: hidden; }
.imp-bar span { display: block; height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; }
.imp-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.desc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0; }
.desc-block { padding: 14px 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.desc-block h3 { font-size: 13px; margin-bottom: 8px; }
.desc-block .table th, .desc-block .table td { padding: 5px 8px; }
.oc-grid .checks-col .check { display: flex; flex-wrap: wrap; }
.oc-grid .checks-col .check .opt-help { flex-basis: 100%; padding-left: 23px; }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 28px 0 14px; }
.section-row .section-title { margin: 0; }
.col-tidy { color: var(--ink-2) !important; flex-wrap: wrap; cursor: pointer; }
.col-tidy input { width: 14px !important; height: 14px !important; }
.tidy-ex { flex-basis: 100%; padding-left: 20px; color: var(--warning); font-size: 11.5px; }

/* ---------------------------------------------------------------- columns: compact rows + edit panel */
.coltable.compact td { padding-top: 8px; padding-bottom: 8px; vertical-align: middle; }
.coltable.compact .w-edit { width: 78px; text-align: right; padding-right: 14px; }
.coltable.compact .w-name { width: 19%; }
.coltable.compact .w-prof { width: 15%; }
.coltable.compact .w-sel { width: 13%; }
.col-name-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; text-align: left; word-break: break-word; }
.col-name-btn:hover { color: var(--accent); text-decoration: underline; }
.col-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.col-summary { font-size: 12.5px; color: var(--ink-2); }
.coltable tr.is-open td { background: #eef6f4; }
.coltable tr.is-open td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.coltable tr.flash td { animation: rowflash 1.4s ease-out; }
@keyframes rowflash { from { background: #fff4c2; } to { background: transparent; } }
.tag-new { background: #e6f1ff; color: #1f5fa8; }
.col-reason { display: flex; gap: 6px; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 6px; padding: 8px 10px; margin: 0 0 12px; }
.col-reason svg { flex: none; margin-top: 2px; color: var(--accent); }
.is-off { display: none !important; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; background: var(--surface, #fff); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(16,24,40,.08); z-index: 40; display: flex; flex-direction: column; }
.drawer[hidden] { display: none; }
.drawer-head { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 15px; margin: 0; display: flex; gap: 8px; align-items: center; flex: 1; }
.drawer-head .spacer { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-body h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
.drawer-foot { padding: 10px 16px; border-top: 1px solid var(--border); }
body.has-drawer .main { margin-right: 420px; }
.detail-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.detail-head h3 { margin: 0; font-size: 16px; word-break: break-word; }
.detail-block { border-top: 1px solid var(--border); padding: 12px 0; }
.detail-block:first-of-type { border-top: 0; }
.detail-block .field { display: block; font-size: 13px; margin-bottom: 10px; }
.detail-block .field select, .detail-block .field input[type=text], .detail-block .field textarea { display: block; width: 100%; margin-top: 4px; }
.detail-block .field input[type=number] { margin: 0 4px; }
.detail-block .field textarea { font-family: var(--mono, monospace); font-size: 12.5px; }
.field-hint { display: block; font-size: 11.5px; color: var(--muted); font-weight: normal; }
.hint.warn { color: var(--warning); font-size: 12px; margin-left: 4px; }
.dl-tight { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 12.5px; margin: 10px 0 0; }
.dl-tight dt { color: var(--muted); }
.dl-tight dd { margin: 0; word-break: break-word; }
.item-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.item-chip { font-size: 12px; border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 2px 9px; cursor: pointer; }
.item-chip:hover { border-color: var(--accent); }
.item-chip.is-out { text-decoration: line-through; color: var(--muted); background: var(--surface-2); }

/* issues */
.issues > summary { cursor: pointer; list-style: none; }
.issues > summary::-webkit-details-marker { display: none; }
.issue-list { list-style: none; margin: 0; padding: 0 16px 8px; }
.issue { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.issue:first-child { border-top: 0; }
.issue > svg { flex: none; }
.issue-error > svg { color: var(--danger, #c0392b); }
.issue-warning > svg { color: var(--warning); }
.issue-info > svg { color: var(--muted); }
.issue-msg { flex: 1; }
.issue-acts { display: flex; gap: 6px; flex: none; }

/* add a feature */
.sugg { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13px; }
.sugg > div { flex: 1; }
.sugg code, .derive-form code { font-size: 12px; }
.derive-form .field { display: block; font-size: 13px; margin-bottom: 10px; }
.derive-form select, .derive-form input[type=text], .derive-form input[type=number], .derive-form textarea { display: block; width: 100%; margin-top: 4px; }
.derive-form [hidden] { display: none; }
.chips { flex-wrap: wrap; }
.chip { white-space: nowrap; }
.coltable.compact .w-name { width: auto; }
.coltable.compact .w-prof { width: 170px; }
.coltable.compact .w-sel { width: 128px; }
.coltable.compact .w-sum { width: 24%; }
body.has-drawer .savebar { right: 420px; }
body.has-drawer .coltable .c-prof, body.has-drawer .coltable col.w-prof,
body.has-drawer .coltable .c-sum, body.has-drawer .coltable col.w-sum { display: none; }
body.has-drawer .toolbar-search input { width: 160px; }
.issues > summary .spacer { flex: 1; }
.corrmap td.corr-same { background: repeating-linear-gradient(45deg, #f1f3f5 0 4px, #e3e6ea 4px 5px); }
.corrmap .heat-name .tag { font-family: var(--font); }

/* features: what to do */
.advice .card-head { flex-wrap: wrap; }
.adv-list { list-style: none; margin: 0; padding: 0 20px; }
.adv { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.adv:first-child { border-top: 0; }
.adv > svg { flex: none; margin-top: 2px; }
.adv-high > svg { color: var(--danger); }
.adv-medium > svg { color: var(--warning); }
.adv-ok > svg { color: var(--success); }
.adv-body { flex: 1; min-width: 0; }
.adv-body p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.adv-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.adv-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.adv-tip { color: var(--muted) !important; }
.adv-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; align-items: center; }
.adv-chip { font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.adv-keep { font-size: 12px; color: var(--success); margin-right: 6px; }
.adv-act { flex: none; }
.adv.is-done { opacity: .6; }
.adv-more { margin-top: 8px; font-size: 13px; }
.adv-more summary { cursor: pointer; color: var(--accent); }
.adv-more table { margin-top: 6px; max-width: 560px; }
.adv-best td { font-weight: 600; }
.adv-foot { padding: 0 20px 14px; margin: 0; }
.fs-block.flash, .seg-table tr.flash td { animation: rowflash 1.6s ease-out; }
#sg-form .is-changed { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* features: input panel */
.input-link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.input-link code { color: var(--accent-ink); }
.input-link:hover code, button.adv-chip:hover { text-decoration: underline; }
button.adv-chip { font-family: var(--mono); color: var(--accent-ink); cursor: pointer; }
.ip-name { margin: 0 0 6px; font-size: 15px; font-family: var(--mono); word-break: break-word; }
.ip-what { font-size: 13.5px; margin: 0 0 10px; }
.ip-status { font-size: 13px; color: var(--muted); }
.ip-mention { font-size: 12.5px; background: var(--warning-soft); color: var(--warning); border-radius: 6px; padding: 6px 9px; margin: 6px 0; }
.ip-hist { width: 100%; height: 90px; display: block; }
.ip-hist rect { fill: var(--spark); }
.ip-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 2px; }
.detail-block p { font-size: 13px; margin: 6px 0; }
.topv.is-me .topv-lab { font-weight: 700; }
.topv .input-link.topv-lab { font-size: inherit; }
tr.ip-open td { background: #eef6f4; }
.explain { border-bottom: 1px solid var(--border); background: #fbfaf5; }
.explain > summary { cursor: pointer; padding: 9px 20px; font-size: 13px; color: var(--accent-ink); display: flex; gap: 6px; align-items: center; list-style: none; }
.explain > summary::-webkit-details-marker { display: none; }
.explain[open] > summary { font-weight: 600; }
.explain ul { margin: 0; padding: 0 20px 12px 38px; font-size: 13px; color: var(--ink-2); }
.explain li { margin: 5px 0; line-height: 1.45; }
/* outcomes: what drives each model */
.drv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.drv-col { padding: 14px 20px; min-width: 0; }
.drv-col + .drv-col { border-left: 1px solid var(--border); }
.drv-col h3 { font-size: 14px; margin: 0 0 8px; }
.drv-h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 6px; }
.drv td { vertical-align: middle; }
.drv-name code { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.drv-bar { width: 38%; }
.drv-bar span { display: block; height: 10px; border-radius: 3px; }
.drv-pos { background: var(--success); }
.drv-neg { background: #d4513b; }
.drv-bar-h { display: flex; justify-content: space-between; font-weight: normal; }
.drv td.small { white-space: nowrap; }
.drv-bar-h span:first-child { color: #d4513b; }
.drv-bar-h span:last-child { color: var(--success); }
.cmp-chance td { color: var(--muted); }
#sg-group-modes.is-dim { opacity: .45; pointer-events: none; }
/* segments: quality, over time, run comparison */
.q-good { color: var(--success); }
.q-mid { color: var(--warning); }
.q-bad { color: var(--danger); }
.best-mark { color: #d4a72c; }
.runs tr.is-current td { background: var(--accent-soft); }
.ot-rates td:first-child { white-space: nowrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.tag-grp { background: #eef2ff; color: #3730a3; }
.tag-pick { background: var(--accent); color: #fff; }
/* segments: search */
.search > summary { cursor: pointer; list-style: none; }
.search > summary::-webkit-details-marker { display: none; }
.search-head { margin: 0; font-size: 13.5px; line-height: 1.55; }
.search-res .runs td { vertical-align: middle; }
.runs tr.is-best td { background: var(--accent-soft); }

/* sub-tabs */
.subtabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 18px; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); position: sticky; top: 0; z-index: 6;
  box-shadow: 0 2px 8px rgba(16,24,40,.04); }
.subtab { padding: 6px 12px; border-radius: 6px; font-size: 13.5px; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.subtab:hover { background: var(--surface-2); color: var(--ink); }
.subtab.is-on { background: var(--accent); color: #fff; }
.subtab-n { font-size: 11.5px; opacity: .75; margin-left: 2px; }
.panel[hidden] { display: none; }
.panel > .card:first-child, .panel > .section:first-child { margin-top: 0; }
.subtab, .subtab:hover, .subtab.is-on { text-decoration: none; }

/* ---- readable line length: messages and explanations stop at ~80 characters, not full width */
.alert { max-width: 820px; }
.explain ul, .card-body.small, .chart-cap, .page-sub, .field-hint, .card-body.muted { max-width: 760px; }
.explain ul { padding-right: 20px; }
