/* Fireowl Dashboarder — styles. Ink on paper; the charts carry the colour. */

@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo-latin-wdth-normal.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo-latin-ext-wdth-normal.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --page: #f3f3f1; --panel: #fcfcfb; --panel-2: #f6f6f3;
  --ink: #1a1a18; --ink-2: #52514e; --muted: #898781;
  --hair: #e1e0d9; --base: #c3c2b7;
  --ring: rgba(26,26,24,.13); --ring-strong: rgba(26,26,24,.28);
  --wash: rgba(26,26,24,.05); --wash-2: rgba(26,26,24,.09);
  --scrim: rgba(15,15,14,.26);
  --lift: 0 10px 30px rgba(20,20,18,.12), 0 2px 6px rgba(20,20,18,.06);
  --warn: #fab219; --warn-ink: #b07a00; --danger: #c53030;
  --ready: #0ca30c; --error: #d03b3b;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-panel: 10px; --r-control: 7px; --r-chip: 6px;
  --rail: 252px; --gap: 16px;
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c7: #6250d6; --c8: #e34948;
  --other: #b3b2ab; --prev: #c3c2b7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f0f0e; --panel: #1a1a19; --panel-2: #212120;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --hair: #2c2c2a; --base: #383835;
    --ring: rgba(255,255,255,.10); --ring-strong: rgba(255,255,255,.24);
    --wash: rgba(255,255,255,.06); --wash-2: rgba(255,255,255,.10);
    --scrim: rgba(0,0,0,.50);
    --lift: 0 12px 34px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.4);
    --warn-ink: #fab219; --danger: #ef6b6b;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
    --other: #5c5b56; --prev: #6b6a64;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f0f0e; --panel: #1a1a19; --panel-2: #212120;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --hair: #2c2c2a; --base: #383835;
  --ring: rgba(255,255,255,.10); --ring-strong: rgba(255,255,255,.24);
  --wash: rgba(255,255,255,.06); --wash-2: rgba(255,255,255,.10);
  --scrim: rgba(0,0,0,.50);
  --lift: 0 12px 34px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.4);
  --warn-ink: #fab219; --danger: #ef6b6b;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  --other: #5c5b56; --prev: #6b6a64;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--page); color: var(--ink);
  font: 420 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; font-synthesis: none;
}
::selection { background: var(--ink); color: var(--panel); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.cond { font-stretch: 72%; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--wash-2); padding: 1px 5px; border-radius: 4px; }
pre.code { padding: 12px 14px; border-radius: var(--r-control); overflow: auto; white-space: pre-wrap; line-height: 1.5; }

/* ---------- icons ---------- */
.icon { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.xs { width: 14px; height: 14px; }
.icon.dots { stroke-width: 3; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: var(--r-control);
  border: 1px solid var(--ring); background: var(--panel); color: var(--ink); font-weight: 540; font-size: 13px; white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn .icon { margin-left: -2px; }
.btn:hover { background: var(--wash); border-color: var(--ring-strong); }
.btn:active { background: var(--wash-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.btn.primary:hover { opacity: .88; background: var(--ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--wash); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-control);
  background: transparent; color: var(--ink-2); transition: background .12s, color .12s;
}
.iconbtn:hover { background: var(--wash); color: var(--ink); }
.iconbtn[aria-expanded="true"], .iconbtn.on { background: var(--wash-2); color: var(--ink); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--ink-2); font-size: 13px; font-weight: 520; text-decoration: underline; text-decoration-color: var(--base); text-underline-offset: 3px; }
.linkbtn:hover { color: var(--ink); text-decoration-color: currentColor; }
.btnrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btnrow.end { justify-content: flex-end; }

/* ---------- inputs ---------- */
.input, .select, .textarea {
  min-height: 32px; padding: 5px 10px; border-radius: var(--r-control); border: 1px solid var(--ring); background: var(--panel-2); color: var(--ink);
  font-size: 13.5px; width: 100%;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ring-strong); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input.sm { min-height: 28px; padding: 3px 8px; font-size: 13px; }
.textarea { resize: vertical; min-height: 64px; line-height: 1.4; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center;
}
.input[type="number"] { font-variant-numeric: tabular-nums; }
.select.sm { min-height: 28px; padding: 3px 26px 3px 8px; font-size: 13px; }
.row > .select { width: auto; max-width: 100%; }
.input[type="date"] { font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 540; color: var(--ink-2); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box { width: 16px; height: 16px; border: 1.5px solid var(--ring-strong); border-radius: 4px; flex: 0 0 auto; position: relative; background: var(--panel); transition: background .12s, border-color .12s; }
.check input:checked + .box { background: var(--ink); border-color: var(--ink); }
.check input:checked + .box::after { content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px; border: solid var(--panel); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.check input:focus-visible + .box { outline: 2px solid var(--ink); outline-offset: 2px; }
.check.dim { color: var(--muted); }
.dt tr.dim td > code, .dt tr.dim td > input, .dt tr.dim td.num { opacity: .55; }

.seg { display: inline-flex; padding: 2px; background: var(--panel-2); border: 1px solid var(--ring); border-radius: var(--r-control); gap: 2px; }
.seg button { height: 26px; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--ink-2); font-size: 12.5px; font-weight: 540; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--ring); background: var(--panel); color: var(--ink); font-size: 13px; font-weight: 540; }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-chip); background: var(--wash); color: var(--ink-2); font-size: 12px; font-weight: 520; white-space: nowrap; max-width: 100%; }
.chip b { color: var(--ink); font-weight: 620; }
.chip .x { border: 0; background: none; padding: 0; color: var(--muted); display: inline-flex; }
.chip .x:hover { color: var(--ink); }
.chip.lg { height: 28px; font-size: 12.5px; padding: 0 10px; cursor: pointer; }
.chip.off { opacity: .5; text-decoration: line-through; }
.chip.tag { background: var(--panel-2); border: 1px solid var(--ring); color: var(--muted); height: 18px; font-size: 10.5px; padding: 0 5px; font-weight: 600; text-transform: none; }
.chip.tag.warn { color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 45%, transparent); margin-right: 4px; }

/* ---------- popovers, menus ---------- */
.popover {
  position: fixed; z-index: 60; min-width: 200px; max-width: min(420px, 100vw - 24px); max-height: min(560px, 100vh - 24px); overflow: auto;
  padding: 6px; border-radius: var(--r-panel); background: var(--panel); box-shadow: var(--lift), 0 0 0 1px var(--ring);
  animation: pop-in .12s ease-out;
}
.popover.wide { max-width: min(560px, 100vw - 24px); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.menu { display: flex; flex-direction: column; }
.menu .item { display: flex; align-items: center; gap: 9px; min-height: 32px; padding: 6px 10px; border: 0; border-radius: 6px; background: none; text-align: left; font-size: 13.5px; font-weight: 480; color: var(--ink); width: 100%; }
.menu .item .icon { width: 16px; height: 16px; color: var(--ink-2); }
.menu .item:hover, .menu .item:focus-visible { background: var(--wash); }
.menu .item .hintr { margin-left: auto; color: var(--muted); font-size: 12px; }
.menu .item.danger { color: var(--danger); }
.menu .item.danger .icon { color: var(--danger); }
.menu .sep { height: 1px; background: var(--hair); margin: 5px 4px; }
.menu .head { font-size: 12px; font-weight: 520; color: var(--muted); padding: 6px 10px 2px; }
.menu .item .check-mark { width: 16px; display: inline-flex; justify-content: center; }

/* value picker */
.picker { width: 320px; max-width: calc(100vw - 24px); }
.picker .pk-title { font-size: 13.5px; font-weight: 620; padding: 6px 8px 4px; }
.picker .pk-search { padding: 4px 6px 6px; }
.picker .pk-list { max-height: 300px; overflow: auto; padding: 2px 0; }
.picker .pk-row { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 3px 8px; border-radius: 6px; }
.picker .pk-row:hover { background: var(--wash); }
.picker .pk-row .lab { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.picker .pk-row .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.picker .pk-row .only { opacity: 0; font-size: 12px; }
.picker .pk-row:hover .only { opacity: 1; }
.picker .pk-foot { display: flex; align-items: center; gap: 8px; padding: 8px 8px 4px; border-top: 1px solid var(--hair); margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.picker .pk-foot .grow { flex: 1; }
.picker .pk-empty { padding: 14px 8px; color: var(--muted); font-size: 13px; }
.picker .pk-range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; padding: 6px 8px; }

/* question picker */
.qpick { width: 440px; max-width: calc(100vw - 24px); }
.qpick .qp-list { max-height: 380px; overflow: auto; }
.qpick .qp-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.qpick .qp-row:hover, .qpick .qp-row.active { background: var(--wash); }
.qpick .qp-row .ql { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qpick .qp-row .qv { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.qpick .qp-row.disabled { opacity: .4; cursor: not-allowed; }

/* ---------- dialogs ---------- */
dialog.dlg { width: min(460px, 100vw - 32px); padding: 0; border: 0; border-radius: var(--r-panel); background: var(--panel); color: var(--ink); box-shadow: var(--lift), 0 0 0 1px var(--ring); }
dialog.dlg.wide { width: min(640px, 100vw - 32px); }
dialog.dlg::backdrop { background: var(--scrim); }
dialog.dlg form, dialog.dlg .dlg-body { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
dialog.dlg h2 { font-size: 20px; font-weight: 700; font-stretch: 80%; line-height: 1.15; }
dialog.dlg p { color: var(--ink-2); font-size: 14px; }
dialog.dlg .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- drawers ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); animation: fade-in .16s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 51; width: min(640px, 100vw); background: var(--panel); box-shadow: var(--lift); display: flex; flex-direction: column; animation: drawer-in .18s cubic-bezier(.2,.7,.2,1); }
.drawer.narrow { width: min(430px, 100vw); }
.drawer.wide { width: min(760px, 100vw); }
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.drawer .dr-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 14px 22px; border-bottom: 1px solid var(--hair); }
.drawer .dr-head h2 { font-size: 20px; font-weight: 700; font-stretch: 80%; line-height: 1.15; flex: 1; }
.drawer .dr-body { flex: 1; overflow: auto; padding: 18px 22px 28px; display: flex; flex-direction: column; gap: 22px; }
.drawer .dr-foot { display: flex; align-items: center; gap: 10px; padding: 12px 22px; border-top: 1px solid var(--hair); }
.drawer .dr-foot .hint { flex: 1; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section > h3 { font-size: 13px; font-weight: 640; color: var(--ink); font-stretch: 92%; display: flex; align-items: center; gap: 8px; }
.section > h3 .n { font-size: 11px; color: var(--muted); font-weight: 600; width: 18px; height: 18px; border: 1px solid var(--ring); border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; }
.frow { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: start; }
.frow > .label { padding-top: 7px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 9px 14px; border-radius: var(--r-panel); background: var(--ink); color: var(--panel); font-size: 13.5px; box-shadow: var(--lift); max-width: min(560px, 100vw - 32px); animation: toast-in .16s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.toast.error { background: var(--danger); color: #fff; }
.toast .act { height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: rgba(255,255,255,.18); color: inherit; font-weight: 620; font-size: 12.5px; }
.toast .act:hover { background: rgba(255,255,255,.28); }

.spinner { width: 16px; height: 16px; border: 2px solid var(--hair); border-top-color: var(--ink); border-radius: 50%; animation: spin .9s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; overflow: auto; padding: 20px 14px 16px 16px; border-right: 1px solid var(--hair); display: flex; flex-direction: column; gap: 22px; background: var(--page); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.brand .mark { width: 30px; height: 30px; }
.brand .name { font-size: 17px; font-weight: 700; font-stretch: 78%; line-height: 1.1; }
.rail .sec-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.navlist { display: flex; flex-direction: column; gap: 2px; }
.navitem { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border: 0; border-radius: var(--r-control); background: none; color: var(--ink); font-size: 13.5px; width: 100%; text-align: left; text-decoration: none; }
.navitem .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navitem .c { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.navitem:hover { background: var(--wash); }
.navitem[aria-current="page"] { background: var(--ink); color: var(--panel); }
.navitem[aria-current="page"] .c { color: var(--panel); opacity: .7; }
.navitem.dragging { opacity: .4; }
.navitem.drop-before { box-shadow: 0 -2px 0 var(--ink); }
.navitem.drop-after { box-shadow: 0 2px 0 var(--ink); }
.projsw { display: flex; align-items: center; gap: 8px; width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel); text-align: left; }
.projsw .t { flex: 1; min-width: 0; overflow: hidden; }
.projsw .t .pn { font-size: 13.5px; font-weight: 620; font-stretch: 92%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projsw .t .ps { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projsw:hover { border-color: var(--ring-strong); background: var(--wash); }
.rail details.trash summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); font-weight: 560; padding: 4px; }
.rail details.trash summary::-webkit-details-marker { display: none; }
.rail details.trash summary .icon { transition: transform .12s; }
.rail details.trash[open] summary .icon.chev { transform: rotate(90deg); }
.trash-row { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; font-size: 12.5px; }
.trash-row .t { flex: 1; min-width: 0; }
.trash-row .t .ti { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-row .t .tm { color: var(--muted); font-size: 11.5px; }
.rail .foot { margin-top: auto; border-top: 1px solid var(--hair); padding-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.datastat { display: grid; grid-template-columns: 14px 1fr; gap: 6px 8px; align-items: start; padding: 0 4px; }
.datastat .dot { width: 8px; height: 8px; border-radius: 50%; margin: 6px 3px 0; background: var(--muted); }
.datastat .dot.ready { background: var(--ready); }
.datastat .dot.error { background: var(--error); }
.datastat .dot.loading { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.datastat .l1 { font-size: 13px; font-weight: 600; }
.datastat .l2 { font-size: 12px; color: var(--muted); line-height: 1.35; }
.whoami { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.whoami .u { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; padding: 26px 34px 64px; }
.main > .inner { max-width: 1480px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border: 1px solid var(--ring); border-radius: var(--r-panel); background: var(--panel); font-size: 13px; color: var(--ink-2); margin-bottom: 18px; }
.banner .icon { color: var(--warn-ink); }
.banner.preview { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.banner.preview .btn { background: var(--panel); color: var(--ink); border-color: var(--panel); }
.banner.preview .btn.primary { background: var(--panel); color: var(--ink); }

/* header */
.dhead { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.dhead .tt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.dhead h1 { font-size: 34px; font-weight: 720; font-stretch: 70%; line-height: 1.05; letter-spacing: -.004em; }
.dhead .desc { font-size: 14.5px; color: var(--ink-2); max-width: 72ch; }
.dhead .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dhead .acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* filter bar + base meter */
.fbar-sentinel { height: 1px; }
.fbar { position: sticky; top: 0; z-index: 20; margin: 0 -34px 18px; padding: 10px 34px 0; background: var(--page); }
.fbar.stuck { box-shadow: 0 1px 0 var(--hair); }
.fbar .frow1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 36px; }
.fbar .fchips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.fbar .fchip { display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 4px 0 10px; border-radius: var(--r-control); border: 1px solid var(--ring); background: var(--ink); color: var(--panel); font-size: 12.5px; font-weight: 520; max-width: 100%; cursor: default; }
.fbar .fchip .ft { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; cursor: pointer; }
.fbar .fchip .ft b { font-weight: 680; }
.fbar .fchip .x { border: 0; background: none; color: inherit; opacity: .7; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; }
.fbar .fchip .x:hover { opacity: 1; background: rgba(255,255,255,.15); }
.fbar .fchip.off { background: var(--panel); color: var(--muted); text-decoration: line-through; }
.fbar .fchip.saved .ft::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; opacity: .7; vertical-align: 1px; }
.fbar .fchip.bad { background: var(--danger); border-color: var(--danger); color: #fff; text-decoration: none; }
.fbar .fbtn { height: 34px; }
.fbar .fcount { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fbar .fright { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.meter { position: relative; height: 34px; padding: 10px 0 0; }
.meter .track { position: relative; height: 10px; border-radius: 4px; background: var(--wash); overflow: hidden; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); border-radius: 4px; transition: width .32s cubic-bezier(.2,.7,.2,1); }
.meter .segs { position: absolute; left: 0; top: 0; bottom: 0; right: 0; }
.meter .seg-mark { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--panel); opacity: .9; }
.meter .mtext { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.meter .mtext b { color: var(--ink-2); font-weight: 600; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; }
.w-3 { grid-column: span 3; } .w-4 { grid-column: span 4; } .w-6 { grid-column: span 6; } .w-8 { grid-column: span 8; } .w-12 { grid-column: span 12; }
@media (max-width: 1180px) { .w-3, .w-4 { grid-column: span 6; } .w-8 { grid-column: span 12; } }
@media (max-width: 900px) { .w-3, .w-4, .w-6, .w-8, .w-12 { grid-column: span 12; } }
.addtile { grid-column: span 12; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 90px; border: 1.5px dashed var(--ring-strong); border-radius: var(--r-panel); background: none; color: var(--ink-2); font-size: 13.5px; font-weight: 540; }
.addtile:hover { border-color: var(--ink); color: var(--ink); background: var(--wash); }

/* cards */
.card { display: flex; flex-direction: column; background: var(--panel); border-radius: var(--r-panel); box-shadow: 0 0 0 1px var(--ring); min-width: 0; position: relative; transition: box-shadow .12s; }
.card:hover { box-shadow: 0 0 0 1px var(--ring-strong); }
.card.arrange { box-shadow: 0 0 0 1px var(--ring-strong); }
.card.dragging { opacity: .4; }
.card.drop-left { box-shadow: -4px 0 0 var(--ink), 0 0 0 1px var(--ring-strong); }
.card.drop-right { box-shadow: 4px 0 0 var(--ink), 0 0 0 1px var(--ring-strong); }
.card .chead { display: flex; align-items: flex-start; gap: 8px; padding: 13px 10px 0 16px; }
.card .chead .grip { color: var(--muted); cursor: grab; display: none; margin-top: 1px; }
.card.arrange .chead .grip { display: inline-flex; }
.card .chead .ct { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.card .chead h3 { font-size: 15px; font-weight: 620; font-stretch: 92%; line-height: 1.3; }
.card .chead .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.card .chead .tools { display: flex; gap: 2px; opacity: 0; transition: opacity .1s; }
.card:hover .tools, .card:focus-within .tools, .card.arrange .tools, .card.menu-open .tools { opacity: 1; }
@media (hover: none) { .card .chead .tools { opacity: 1; } }
.card .cbody { padding: 8px 12px 4px; flex: 0 0 auto; min-height: 0; position: relative; box-sizing: border-box; }
.card .cbody.h-s { height: 210px; } .card .cbody.h-m { height: 300px; } .card .cbody.h-l { height: 450px; }
.card.kind-stat .cbody.h-s { height: 136px; } .card.kind-stat .cbody.h-m { height: 220px; } .card.kind-stat .cbody.h-l { height: 310px; }
.card.kind-table .cbody, .card.kind-openend .cbody { height: auto; display: flex; flex-direction: column; }
.card.kind-table .cbody > .tblwrap, .card.kind-openend .cbody > .tblwrap { flex: 0 1 auto; min-height: 0; max-height: none; }
.card.kind-table .cbody > .tnotes { flex: 0 0 auto; }
.card.kind-table .cbody.h-s, .card.kind-openend .cbody.h-s { max-height: 330px; } .card.kind-table .cbody.h-m, .card.kind-openend .cbody.h-m { max-height: 500px; } .card.kind-table .cbody.h-l, .card.kind-openend .cbody.h-l { max-height: 760px; }
.card .cbody .chart { position: absolute; inset: 8px 10px 4px 8px; }
.card .cbody.refreshing .chart, .card .cbody.refreshing .tblwrap { opacity: .45; transition: opacity .2s .15s; }
.card .cstate { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }
.card .cstate.error { color: var(--ink-2); }
.card .cstate.error .icon { color: var(--danger); }
.card .cstate b { color: var(--ink); font-weight: 620; }
.card .cfoot { display: flex; align-items: flex-end; gap: 10px; padding: 2px 16px 12px; font-size: 12px; min-height: 18px; margin-top: auto; }
.card .cfoot .note { color: var(--ink-2); flex: 1; min-width: 0; }
.card .cfoot .basis { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; text-align: right; white-space: nowrap; }
.card .cfoot .basis .warnx { color: var(--warn-ink); display: inline-flex; align-items: center; gap: 4px; }
.card .cfoot .notes { color: var(--muted); }
.arrbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--hair); flex-wrap: wrap; }
.arrbar .icon { color: var(--muted); }
.arrbar .grow { flex: 1; }
.card:fullscreen { border-radius: 0; padding: 18px 22px; overflow: auto; }
.card:fullscreen .cbody { height: auto !important; min-height: 60vh; max-height: none !important; }
.card:fullscreen .tools { opacity: 1; }
.card.needs-attention .chead h3::before { content: ""; }

/* stat tile */
.stat { display: flex; flex-direction: column; height: 100%; padding: 2px 4px; gap: 4px; }
.stat .val { font-size: 40px; font-weight: 640; font-stretch: 74%; line-height: 1.05; letter-spacing: -.01em; font-variant-numeric: proportional-nums; }
.cbody.h-m .stat .val, .cbody.h-l .stat .val { font-size: 56px; }
.stat .cmp { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.stat .cmp b { font-weight: 640; color: var(--ink); }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat .bar { margin-top: auto; height: 6px; border-radius: 3px; background: var(--wash); position: relative; overflow: hidden; }
.stat .bar .f { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c1); border-radius: 3px; }

/* cross tables */
.tblwrap { overflow: auto; max-height: inherit; border-radius: 6px; }
table.xt { border-collapse: separate; border-spacing: 0; font-size: 12.5px; font-variant-numeric: tabular-nums; width: 100%; }
table.xt th, table.xt td { padding: 5px 10px; border-bottom: 1px solid var(--hair); text-align: right; vertical-align: bottom; white-space: nowrap; }
table.xt th { font-weight: 560; color: var(--ink-2); font-size: 12px; background: var(--panel); position: sticky; z-index: 2; }
table.xt thead tr:nth-child(1) th { top: 0; }
table.xt thead tr:nth-child(2) th { top: 27px; }
table.xt thead tr:nth-child(3) th { top: 54px; font-size: 11px; color: var(--muted); font-weight: 520; padding-top: 2px; padding-bottom: 3px; }
table.xt thead th.grp { text-align: center; border-bottom: 1px solid var(--base); font-weight: 620; color: var(--ink); }
table.xt thead th.col { max-width: 140px; white-space: normal; line-height: 1.25; }
table.xt th.lbl, table.xt td.lbl { text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 1; min-width: 160px; max-width: 320px; white-space: normal; font-variant-numeric: normal; }
table.xt thead th.lbl { z-index: 3; }
table.xt tr.r-base td { color: var(--ink-2); font-weight: 600; background: var(--panel-2); }
table.xt tr.r-base td.lbl { background: var(--panel-2); }
table.xt tr.r-net td { font-weight: 640; }
table.xt tr.r-header td { font-weight: 620; color: var(--ink-2); font-size: 12px; padding-top: 10px; }
table.xt tr.r-stat td { font-style: italic; color: var(--ink-2); }
table.xt tr.r-qhead td { font-weight: 640; color: var(--ink); padding-top: 12px; font-size: 13px; }
table.xt td .sig { font-size: 10px; color: var(--ink-2); margin-left: 3px; font-weight: 640; letter-spacing: .02em; vertical-align: 1px; }
table.xt td .cnt { display: block; color: var(--muted); font-size: 10.5px; line-height: 1.1; }
table.xt td.small { color: var(--muted); }
table.xt td.total, table.xt th.total { border-right: 1px solid var(--hair); }
table.xt tbody tr:hover td { background: var(--wash); }
table.xt tbody tr:hover td.lbl { background: var(--wash); }
table.xt td .mbar { display: inline-block; height: 6px; background: var(--base); opacity: .75; border-radius: 0 3px 3px 0; margin-left: 6px; vertical-align: 1px; }
table.xt tr.r-base .mbar { display: none; }
.tnotes { font-size: 11.5px; color: var(--muted); padding: 8px 4px 0; line-height: 1.4; }

/* plain data tables (chart as table, admin lists) */
table.dt { border-collapse: collapse; width: 100%; font-size: 13px; }
table.dt th, table.dt td { padding: 7px 14px; border-bottom: 1px solid var(--hair); text-align: left; vertical-align: top; }
table.dt th { font-size: 12.5px; font-weight: 560; color: var(--ink-2); position: sticky; top: 0; background: var(--panel); z-index: 1; cursor: pointer; user-select: none; }
table.dt th.num, table.dt td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dt tbody tr:hover td { background: var(--wash); }
table.dt td.lbl { min-width: 120px; white-space: normal; }
table.dt .key { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 2px; }
table.dt tfoot td { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--base); font-weight: 600; }
table.dt .mbar { display: inline-block; height: 6px; background: var(--base); opacity: .75; border-radius: 0 3px 3px 0; margin-left: 6px; vertical-align: 1px; }

/* open ends */
.oe { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.oe .oe-tools { display: flex; gap: 8px; align-items: center; }
.oe .oe-list { overflow: auto; flex: 1; min-height: 0; border-top: 1px solid var(--hair); }
.oe .oe-row { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 8px 4px; border-bottom: 1px solid var(--hair); font-size: 13px; }
.oe .oe-row .oid { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.oe .oe-row .otext { line-height: 1.4; white-space: pre-wrap; }
.oe .oe-row .octx { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; }
.oe .oe-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.oe .oe-foot .grow { flex: 1; }
.words { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; overflow: auto; }
.words .wrow { display: grid; grid-template-columns: 120px 1fr 44px; gap: 8px; align-items: center; font-size: 12.5px; }
.words .wrow .wb { height: 10px; background: var(--c1); border-radius: 3px; }
.words .wrow .wn { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }

/* builder */
.preview { background: var(--page); border-radius: var(--r-panel); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.preview .ptitle { font-size: 17px; font-weight: 640; font-stretch: 90%; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; margin: -2px -6px; background: transparent; width: 100%; }
.preview .ptitle:hover, .preview .ptitle:focus { border-color: var(--ring-strong); background: var(--panel); outline: none; }
.preview .pbody { position: relative; height: 250px; background: var(--panel); border-radius: 8px; box-shadow: 0 0 0 1px var(--ring); overflow: hidden; }
.preview .pbody.tall { height: 360px; }
.preview .pbody .chart { position: absolute; inset: 8px; }
.preview .pbody .tblwrap { max-height: 100%; height: 100%; padding: 4px; }
.preview .pbody .oe { padding: 8px; }
.preview .pmsg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.preview .pmeta { font-size: 12px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.ocard { text-align: left; padding: 9px 11px; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel-2); display: flex; flex-direction: column; gap: 2px; }
.ocard b { font-size: 13px; font-weight: 620; }
.ocard span { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.ocard:hover { border-color: var(--ring-strong); }
.ocard[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.ocard:disabled { opacity: .35; cursor: not-allowed; }
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ttile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel-2); font-size: 11.5px; font-weight: 540; color: var(--ink-2); }
.ttile svg { width: 44px; height: 30px; stroke: var(--ink-2); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ttile svg .fill { fill: var(--ink-2); stroke: none; opacity: .5; }
.ttile:hover { border-color: var(--ring-strong); }
.ttile[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); }
.ttile[aria-pressed="true"] svg { stroke: var(--ink); }
.ttile:disabled { opacity: .35; cursor: not-allowed; }
.qbtn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 5px 10px; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel-2); text-align: left; font-size: 13.5px; }
.qbtn .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qbtn .t.ph { color: var(--muted); }
.qbtn:hover { border-color: var(--ring-strong); }
.codelist { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto; padding: 4px; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel-2); }
.codelist .check { padding: 4px 6px; border-radius: 5px; }
.codelist .check:hover { background: var(--wash); }
.codelist .check .lab { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.codelist .check .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.netrow { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--ring); border-radius: var(--r-control); font-size: 13px; }
.netrow .codes { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.bannerrow { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel-2); }
.bannerrow .brh { display: flex; align-items: center; gap: 8px; }
.bannerrow .brh .t { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bannerrow .brh .sub { font-size: 12px; color: var(--muted); }
.bannerrow .groups { display: flex; flex-direction: column; gap: 6px; }
.bannerrow .grp { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; }
.wtsel { display: flex; align-items: center; gap: 8px; }

/* filter builder */
.cond { display: grid; grid-template-columns: minmax(180px, 1.2fr) 130px minmax(160px, 1.4fr) auto; gap: 8px; align-items: start; padding: 10px; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel); }
.cond .cv { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cond .cn { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.cgroup { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px dashed var(--ring-strong); border-radius: var(--r-panel); background: var(--panel-2); }
.cgroup .cg-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.cgroup .cg-head .grow { flex: 1; }
.cgroup.nested { background: var(--page); }
.matchcount { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-control); background: var(--panel-2); font-size: 13px; }
.matchcount b { font-weight: 640; font-variant-numeric: tabular-nums; }
.matchcount .mbar { flex: 1; height: 8px; border-radius: 4px; background: var(--wash-2); position: relative; overflow: hidden; }
.matchcount .mbar .f { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); border-radius: 4px; transition: width .3s; }

/* saved filters list */
.sflist { display: flex; flex-direction: column; gap: 6px; }
.sfrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel); }
.sfrow .n { font-weight: 600; font-size: 13.5px; }
.sfrow .d { font-size: 12px; color: var(--muted); }
.sfrow .acts { display: flex; gap: 2px; }

/* data export variable picker */
.varlist { max-height: 380px; overflow: auto; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel-2); padding: 4px; }
.vgroup, .vitem { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 4px; min-height: 30px; padding: 2px 6px 2px 2px; border-radius: 6px; }
.vitem { grid-template-columns: 1fr; padding-left: 34px; min-height: 26px; }
.vgroup:hover, .vitem:hover { background: var(--wash); }
.vgroup .vx { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.vlab { display: flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; font-size: 13px; }
.vlab input { width: 15px; height: 15px; accent-color: var(--ink); flex: 0 0 auto; }
.vlab .vt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.vlab .vn { margin-left: auto; padding-left: 8px; color: var(--muted); font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.vitem .vlab { font-size: 12.5px; color: var(--ink-2); }
.warnline { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-control); background: var(--wash); font-size: 12.5px; }
.warnline .icon { color: var(--warn-ink); flex: 0 0 auto; margin-top: 1px; }
.hint.warn { color: var(--warn-ink); }
.warnline.err { color: var(--danger); }
.warnline.err .icon { color: var(--danger); }

/* Multi-answer questions */
.ms-list { display: flex; flex-direction: column; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel); }
.ms-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-width: 0; }
.ms-row + .ms-row { border-top: 1px solid var(--hair); }
.ms-main { flex: 1; min-width: 0; }
.ms-title { font-size: 13.5px; font-weight: 600; color: var(--ink); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ms-meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-meta code { font-size: 11.5px; color: var(--ink-2); }
.ms-acts { display: flex; align-items: center; gap: 6px; flex: none; }
.chip.tag.ok { color: var(--c3); border-color: color-mix(in srgb, var(--c3) 40%, transparent); }
.ms-answers { display: flex; flex-direction: column; gap: 4px; }
.ms-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed var(--ring-strong); border-radius: var(--r-control); }
.ms-ans-row { display: grid; grid-template-columns: 22px auto minmax(140px, 1fr) auto auto 40px auto; align-items: center; gap: 6px; }
.ms-ans-row .vn { color: var(--muted); font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.ms-i { color: var(--muted); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; }
.ms-mv { display: inline-flex; }
.ms-mv .iconbtn { width: 22px; height: 26px; }
.ms-pct { color: var(--muted); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-flex; gap: 4px; align-items: center; justify-content: flex-end; }
.ms-impact { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ms-impact li { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2); }
.ms-impact li .icon { flex: none; margin-top: 2px; color: var(--muted); }
.ms-impact li.warn .icon { color: var(--warn-ink); }
.ms-impact li.warn { color: var(--ink); }
.ms-impact .uses { color: var(--muted); }
@media (max-width: 600px) {
  .ms-row { flex-direction: column; align-items: stretch; }
  .ms-ans-row { grid-template-columns: 22px auto 1fr auto; }
  .ms-ans-row .vn, .ms-ans-row .chip, .ms-ans-row .ms-pct, .ms-ans-row > span:empty { display: none; }
}

/* history */
.vlist { display: flex; flex-direction: column; gap: 8px; }
.vrow { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--ring); border-radius: var(--r-control); }
.vrow .vh { display: flex; align-items: center; gap: 8px; }
.vrow .vh .v { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.vrow .vh .t { font-weight: 620; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow .vs { font-size: 13px; color: var(--ink-2); }
.vrow .vm { font-size: 12px; color: var(--muted); }
.vrow .va { display: flex; gap: 6px; margin-top: 4px; }
.pillcur { font-size: 11px; font-weight: 640; padding: 1px 7px; border-radius: 999px; background: var(--ink); color: var(--panel); }

/* empty states, full page states */
.empty { text-align: center; padding: 36px 20px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty h2 { font-size: 22px; font-weight: 700; font-stretch: 78%; }
.empty p { color: var(--ink-2); max-width: 52ch; }
.starters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; width: 100%; max-width: 900px; margin-top: 10px; }
.starter { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border: 1px solid var(--ring); border-radius: var(--r-panel); background: var(--panel-2); text-align: left; }
.starter b { font-size: 13.5px; font-weight: 620; }
.starter span { font-size: 12px; color: var(--muted); }
.starter:hover { border-color: var(--ink); }
.fullpage { max-width: 700px; margin: 0 auto; padding: 8vh 24px 60px; display: flex; flex-direction: column; gap: 18px; }
.fullpage .mark { width: 34px; height: 34px; }
.fullpage h1 { font-size: 40px; font-weight: 720; font-stretch: 68%; line-height: 1.04; }
.fullpage p { font-size: 15px; color: var(--ink-2); max-width: 60ch; line-height: 1.5; }
.fullpage .errbox { padding: 12px 14px; border: 1px solid var(--danger); border-radius: var(--r-control); color: var(--ink); font-size: 13.5px; }
.authbox { width: min(420px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 24px; background: var(--panel); border-radius: var(--r-panel); box-shadow: 0 0 0 1px var(--ring); }
.authbox h2 { font-size: 22px; font-weight: 700; font-stretch: 78%; }
.authbox .err { color: var(--danger); font-size: 13px; }
.authbox .ok { color: var(--ink-2); font-size: 13.5px; }

/* admin */
.page { display: flex; flex-direction: column; gap: 18px; }
.page h1 { font-size: 34px; font-weight: 720; font-stretch: 70%; line-height: 1.05; letter-spacing: -.004em; }
.page h2 { font-size: 20px; font-weight: 700; font-stretch: 80%; margin-top: 8px; }
.panel { background: var(--panel); border-radius: var(--r-panel); box-shadow: 0 0 0 1px var(--ring); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.panel h3 { font-size: 15px; font-weight: 640; font-stretch: 92%; }
.panel .tblwrap { max-height: 560px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--hair); }
.tabs button { height: 36px; padding: 0 12px; border: 0; background: none; color: var(--ink-2); font-size: 13.5px; font-weight: 560; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 620; background: var(--wash); color: var(--ink-2); }
.status-pill.active { background: var(--ink); color: var(--panel); }
.status-pill.pending { background: var(--warn); color: #1a1a18; }
.status-pill.failed, .status-pill.rejected { background: var(--danger); color: #fff; }
.diffbox { display: flex; flex-direction: column; gap: 10px; }
.diffbox .warn { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-control); background: var(--wash); color: var(--ink); font-size: 13px; }
.diffbox .warn.strong { background: var(--danger); color: #fff; }
.diffbox .warn .icon { flex: 0 0 auto; margin-top: 1px; }
.difflist { font-size: 12.5px; max-height: 220px; overflow: auto; border: 1px solid var(--ring); border-radius: var(--r-control); padding: 6px 10px; }
.difflist div { padding: 2px 0; border-bottom: 1px solid var(--hair); }
.difflist div:last-child { border-bottom: 0; }
.difflist .vn { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--ink-2); margin-right: 8px; }
.stats4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat4 { padding: 10px 12px; border-radius: var(--r-control); background: var(--panel-2); }
.stat4 b { display: block; font-size: 22px; font-weight: 640; font-stretch: 74%; font-variant-numeric: tabular-nums; }
.stat4 span { font-size: 12px; color: var(--muted); }
.dropzone { border: 1.5px dashed var(--ring-strong); border-radius: var(--r-panel); padding: 22px; text-align: center; color: var(--ink-2); font-size: 13.5px; background: var(--panel-2); }
.dropzone.over { border-color: var(--ink); background: var(--wash); }
.progress { height: 6px; border-radius: 3px; background: var(--wash-2); overflow: hidden; }
.progress .f { height: 100%; background: var(--ink); transition: width .2s; }

/* Export tray: bottom right; moves left of an open drawer (wide screens) or shrinks to its header (narrow ones). */
.tray { position: fixed; right: 16px; bottom: 16px; z-index: 55; width: min(360px, 100vw - 32px); background: var(--panel); border: 1px solid var(--ring); border-radius: var(--r-panel); box-shadow: var(--lift); overflow: hidden; animation: toast-in .16s ease-out; }
.tr-head { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 8px; width: 100%; height: 42px; padding: 0 12px; cursor: pointer; font-size: 13px; color: var(--ink); }
.tr-head:hover { background: var(--wash); }
.tr-head:focus-visible { outline: 2px solid var(--c1); outline-offset: -2px; }
.tr-head b { font-weight: 620; }
.tr-sum { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tr-mini { display: none; flex: 1; min-width: 40px; height: 4px; }
.tray.collapsed .tr-mini, .tray .tr-mini.show { display: block; }
.tray .tr-mini.hidden { display: none !important; }
.tr-chev { margin-left: auto; display: inline-flex; color: var(--muted); transition: transform .15s; }
.tray.collapsed .tr-chev { transform: rotate(180deg); }
.tray.collapsed .tr-list { display: none; }
.tr-list { border-top: 1px solid var(--hair); max-height: min(60vh, 420px); overflow: auto; }
.tr-item { padding: 10px 12px 11px; display: flex; flex-direction: column; gap: 7px; }
.tr-item + .tr-item { border-top: 1px solid var(--hair); }
.tr-row { display: flex; align-items: flex-start; gap: 10px; }
.tr-text { flex: 1; min-width: 0; }
.tr-title { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-subt { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-acts { display: flex; align-items: center; gap: 4px; flex: none; }
.tr-item .progress { height: 5px; }
.tr-item .progress .f { background: var(--c1); }
.tr-item[data-status="stopping"] .progress .f { background: var(--muted); }
.tr-msg { display: flex; gap: 10px; font-size: 11.5px; color: var(--ink-2); min-width: 0; }
.tr-msg .m { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-msg .e { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.tr-item[data-status="done"] .tr-msg .m { white-space: normal; color: var(--ink-2); }
.tr-item[data-status="failed"] .tr-msg .m { white-space: normal; color: var(--danger); }
.tr-item[data-status="done"] .tr-title::before { content: "✓ "; color: var(--ready); }
@media (min-width: 1000px) { body.has-drawer .tray { right: auto; left: 16px; } }
@media (max-width: 999px) {
  body.has-drawer .tray { bottom: 82px; left: 50%; right: auto; transform: translateX(-50%); }
  body.has-drawer .tray .tr-list { display: none; }
  body.has-drawer .tray.busy .tr-mini { display: block; }
}
@media (max-width: 600px) {
  .tray { right: 8px; left: 8px; bottom: 8px; width: auto; }
  body.has-drawer .tray { left: 8px; right: 8px; transform: none; width: auto; }
  body.has-tray .toasts { top: 14px; bottom: auto; }
}
.userlist { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow: auto; padding: 6px; border: 1px solid var(--ring); border-radius: var(--r-control); background: var(--panel-2); }

/* tooltip (ECharts) */
.tt { font: 12.5px/1.35 var(--font); color: var(--ink); min-width: 120px; }
.tt-head { color: var(--ink-2); font-weight: 520; margin-bottom: 6px; }
.tt-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 8px; padding: 1px 0; }
.tt-key { width: 14px; height: 3px; border-radius: 2px; }
.tt-key.box { width: 10px; height: 10px; border-radius: 3px; margin-left: 2px; }
.tt-val { font-weight: 680; font-variant-numeric: tabular-nums; }
.tt-lab { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.tt-foot { margin-top: 6px; color: var(--muted); font-size: 11.5px; }
.tt-row.dim .tt-val, .tt-row.dim .tt-lab { opacity: .55; }

/* responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; align-content: flex-start; gap: 10px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--hair); overflow: visible; flex-wrap: wrap; }
  .rail .brand .name { display: none; }
  .rail .brand .mark { width: 26px; height: 26px; }
  .rail .sec, .rail details.trash, .rail .foot .datastat .l2 { display: none; }
  .rail .projsw { width: auto; max-width: 240px; height: 34px; }
  .rail .projsw .t .ps { display: none; }
  .rail .mobnav { display: flex; gap: 6px; overflow: auto; flex: 1 1 100%; order: 10; padding-bottom: 2px; }
  .rail .mobnav .navitem { height: 30px; border-radius: 999px; border: 1px solid var(--ring); width: auto; white-space: nowrap; }
  .rail .mobnav .navitem .c { display: none; }
  .rail .foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; align-items: center; gap: 6px; }
  .rail .foot .datastat, .rail .foot > .navitem { display: none; }
  .rail .whoami .u { display: none; }
  .main { overflow-x: hidden; }
  .main { padding: 20px 16px 48px; }
  .fbar { margin: 0 -16px 16px; padding: 8px 16px 0; }
  .dhead { flex-direction: column; }
  .dhead h1 { font-size: 28px; }
  .frow { grid-template-columns: 1fr; }
  .cond { grid-template-columns: 1fr; }
}
@media (min-width: 901px) { .rail .mobnav { display: none; } }
@media (max-width: 520px) {
  .drawer .dr-body { padding: 16px; }
  .drawer .dr-head { padding: 12px 12px 12px 16px; }
  .drawer .dr-foot { padding: 10px 16px; }
}

/* reduced motion, print, forced colours */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
@media print {
  .rail, .fbar, .dhead .acts, .card .tools, .toasts, .tray, .banner, .arrbar, .addtile { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .card { break-inside: avoid; box-shadow: 0 0 0 1px #ccc; }
}
@media (forced-colors: active) {
  .card, .popover, .drawer, dialog.dlg, .btn, .input, .select { border: 1px solid CanvasText; }
  .navitem[aria-pressed="true"], .seg button[aria-pressed="true"], .btn.primary, .fbar .fchip { background: Highlight; color: HighlightText; forced-color-adjust: none; }
}

/* Question setup: sets, iterations, groups, scores */
.ms-answers.dim { opacity: .45; pointer-events: none; }
.ms-ans-row.it { grid-template-columns: 22px 0 minmax(140px, 1fr) auto 0 0 0; }
button.chip { cursor: pointer; font: inherit; border: 1px solid var(--ring); background: var(--panel-2); color: var(--ink-2); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.chip:hover { background: var(--wash); color: var(--ink); }
.dt.scores td { vertical-align: middle; }
.dt.scores input[type="number"] { width: 110px; }
.dt.scores tr.dim td { color: var(--muted); }
.ms-row .chip.tag + .chip.tag { margin-left: 0; }

details.adv { margin-top: 4px; }
details.adv > summary { list-style: none; display: inline-flex; align-items: center; gap: 4px; }
details.adv > summary::before { content: "▸"; font-size: 10px; }
details.adv[open] > summary::before { content: "▾"; }
details.adv > .stack { padding: 8px 0 2px 12px; border-left: 2px solid var(--hair); margin-top: 6px; }
.scoregrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; }
.scoregrid .sg { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.scoregrid .sg .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.scoregrid .sg input { width: 84px; }
table.xt tr.r-missing td { color: var(--muted); font-style: italic; }

table.xt td.lbl.indent { padding-left: 22px; }
.bannerrow.custom .ms-ans-row.grp { grid-template-columns: 22px auto minmax(120px, 1fr) auto 0 auto auto; }

table.xt th.col.extra, table.xt td.extra { border-left: 1px dashed var(--ring-strong); }

.ms-ans-row .ms-i input[type="checkbox"] { margin: 0 4px 0 0; vertical-align: middle; }
.ms-ans-row.merged .vn { white-space: normal; max-width: 260px; }

.ms-answers.mergeable .ms-ans-row { grid-template-columns: 48px auto minmax(140px, 1fr) auto auto 40px auto; }
.ms-answers.mergeable .ms-i { display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px; }
