/* Ballers Bank card bot dashboard.
   One ground, one ink, one accent (blue, on data and the selected state only). Status colours
   say good/bad. Light by default, true black in dark mode. Tabular figures on every number. */

:root {
  color-scheme: light dark;
  --ground: #f9fafb;
  --surface: #ffffff;
  --line: #e8e8e8;
  --grid: #e5e5e5;
  --ink: #111111;
  --ink-2: #5f6368;
  --ink-3: #6b6b6b;
  --hover: #f3f4f6;
  --active: #ececec;
  --btn: #1d1f20;
  --btn-ink: #ffffff;
  --accent: #2b62e3;
  --pos: #247b50;
  --neg: #c4242a;
  --pos-bg: #dcfae5; --pos-ink: #04250e;
  --neg-bg: #ffedea; --neg-ink: #831c1e;
  --warn-bg: #fffbeb; --warn-ink: #92400e; --warn-line: #fde68a;
  --neutral-bg: #f0f0f0; --neutral-ink: #3c3c3c;
  --skel: #ececec;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #000000;
    --surface: #111111;
    --line: #2e2e2e;
    --grid: #2b2b2b;
    --ink: #ffffff;
    --ink-2: #b4b4b4;
    --ink-3: #949494;
    --hover: #1a1a1a;
    --active: #232323;
    --btn: #ffffff;
    --btn-ink: #111111;
    --accent: #5b8ef7;
    --pos: #3fc07a;
    --neg: #e5566f;
    --pos-bg: #0f2a1a; --pos-ink: #a6ecc1;
    --neg-bg: #2e1216; --neg-ink: #ffb8c3;
    --warn-bg: #261e06; --warn-ink: #f5c66b; --warn-line: #5c4a12;
    --neutral-bg: #1f1f1f; --neutral-ink: #d0d0d0;
    --skel: #1f1f1f;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 400 14px/20px var(--font); font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px;
  padding: 20px 12px; border-right: 1px solid var(--line); background: var(--ground);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius);
  background: var(--btn); color: var(--btn-ink); font-size: 12px; font-weight: 600; letter-spacing: 0;
}
.brand-name { font-size: 14px; font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--ink-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px;
  border-radius: var(--radius); color: var(--ink-2); text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--active); color: var(--ink); font-weight: 500; }
.nav svg { width: 16px; height: 16px; flex: none; }
.nav .count { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding: 0 10px; }
.who { font-size: 12px; color: var(--ink-3); }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--ink-2); cursor: pointer; text-align: left;
  min-height: 24px;
}
.link-btn:hover { color: var(--ink); text-decoration: underline; }
.topbar, .sheet { display: none; }

main { padding: 32px; max-width: 1240px; width: 100%; outline: none; }
main:focus-visible { outline: none; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 24px; line-height: 32px; font-weight: 600; }
.meta { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.head-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack-gap > * + * { margin-top: 16px; }
.section { margin-top: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 16px; line-height: 24px; font-weight: 600; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-pad { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; line-height: 24px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

/* ---------- KPIs: one divided container per agent ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 16px 20px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi-label { font-size: 13px; color: var(--ink-2); }
.kpi-value { font-size: 24px; line-height: 32px; margin-top: 4px; white-space: nowrap; }
.kpi-value.answer { font-size: 32px; line-height: 40px; font-weight: 700; }
.kpi-note { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ---------- budget bars ---------- */
.budget { display: grid; gap: 16px; padding: 20px; }
.budget-row { display: grid; gap: 8px; }
.budget-top { display: flex; justify-content: space-between; gap: 12px; }
.budget-name { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.budget-figs { color: var(--ink-2); }
.track { height: 8px; border-radius: 4px; background: var(--neutral-bg); overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width 300ms ease; }

/* ---------- pills ---------- */
.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral-ink);
}
.pill-pos { background: var(--pos-bg); color: var(--pos-ink); }
.pill-neg { background: var(--neg-bg); color: var(--neg-ink); }
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); box-shadow: inset 0 0 0 1px var(--warn-line); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms ease, opacity 150ms ease, transform 100ms ease;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn-primary:hover { background: var(--btn); opacity: .88; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius);
  border: 0; background: none; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.input, .select {
  height: 40px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); min-width: 0;
}
.select { padding-right: 32px; appearance: none; cursor: pointer; background-repeat: no-repeat;
  background-position: right 10px center; background-size: 16px 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) {
  .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b4b4b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
}
.input:hover, .select:hover { border-color: var(--ink-3); }
.input[aria-invalid="true"] { border-color: var(--neg); }
.input-sm, .select-sm { height: 36px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 36px; width: 100%; }
.seg { display: inline-flex; padding: 2px; border-radius: var(--radius); background: var(--neutral-bg); }
.seg button {
  height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--ink-2);
  cursor: pointer; font-size: 13px; font-weight: 500;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

/* switch: on = near-black, not the accent */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 33px; height: 20px; margin: 0; cursor: pointer; }
.switch-track { width: 33px; height: 20px; border-radius: 10px; background: var(--neutral-bg); box-shadow: inset 0 0 0 1px var(--line); position: relative; transition: background-color 150ms ease; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 150ms ease; }
.switch input:checked + .switch-track { background: var(--btn); box-shadow: none; }
.switch input:checked + .switch-track::after { transform: translateX(13px); background: var(--btn-ink); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled, .switch input:disabled ~ * { cursor: not-allowed; }
.switch input:disabled + .switch-track { opacity: .4; }
.switch input:disabled ~ [data-switch-text] { color: var(--ink-3); }

/* ---------- filters ---------- */
.filters { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.filter-summary { font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  height: 36px; padding: 0 12px; text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--hover); }
.table .num { text-align: right; white-space: nowrap; }
.cell-main { color: var(--ink); line-height: 20px; overflow-wrap: anywhere; }
.cell-sub { font-size: 12px; line-height: 16px; color: var(--ink-3); margin-top: 2px; }
.dash { color: var(--ink-3); }
.only-m { display: none; }
.ext { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); text-decoration: none; min-height: 32px; white-space: nowrap; }
.ext:hover { color: var(--ink); text-decoration: underline; }
.ext svg { width: 14px; height: 14px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.pager-btns { display: flex; gap: 8px; }

/* ---------- chart ---------- */
.chart-wrap { padding: 16px 20px 20px; }
.chart-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chart-readout { font-size: 13px; color: var(--ink-2); height: 20px; margin: 12px 0 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }  /* one line: a wrap would move the chart under the pointer */
.chart-readout strong { color: var(--ink); font-weight: 600; }
.chart { width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--ink-3); font-size: 11px; }
.chart .axis-title { fill: var(--ink-3); font-size: 11px; }
.chart .bar { fill: var(--accent); }
.chart .zero { stroke: var(--grid); stroke-width: 2; }
.chart .col { cursor: pointer; outline: none; }
.chart .col .hit, .chart rect.hit { fill: transparent; }
.chart .col:hover .hit, .chart .col:focus-visible .hit { fill: var(--hover); }
.chart .val { fill: var(--ink-2); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart .ref { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .mark { stroke: var(--ink-2); stroke-width: 1; }
.chart .ref-label { fill: var(--ink-2); font-size: 11px; }
.chart .end-label { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart rect.hit { cursor: crosshair; outline: none; }
.chart rect.hit:focus-visible { stroke: var(--accent); stroke-width: 2; }
.chart .hit-dot { fill: transparent; cursor: pointer; outline: none; }
.chart .hit-dot:hover, .chart .hit-dot:focus-visible { fill: var(--accent); fill-opacity: .15; stroke: var(--accent); stroke-width: 1; }
.panel-note { font-size: 13px; color: var(--ink-2); padding: 0 20px 16px; }
details.data { border-top: 1px solid var(--line); }
details.data > summary { cursor: pointer; padding: 10px 20px; font-size: 13px; color: var(--ink-2); list-style: none; }
details.data > summary::-webkit-details-marker { display: none; }
details.data > summary::before { content: "+ "; }
details.data[open] > summary::before { content: "− "; }
details.data > summary:hover { color: var(--ink); }
details.data .table { margin-bottom: 4px; }
.barlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bl-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.bl-name { font-weight: 500; overflow-wrap: anywhere; }
.bl-val { white-space: nowrap; color: var(--ink); }
.bl-bar { height: 10px; margin-top: 6px; }
.bl-fill { height: 100%; width: 0; background: var(--accent); border-radius: 0 4px 4px 0; transition: width 300ms ease; }
.bl-sub { font-size: 12px; line-height: 16px; color: var(--ink-3); margin-top: 4px; }

/* ---------- settings ---------- */
.settings-agent .panel-head { gap: 16px; }
.setting { display: grid; grid-template-columns: minmax(200px, 320px) minmax(0, 1fr); gap: 24px; padding: 20px; border-bottom: 1px solid var(--line); }
.setting:last-of-type { border-bottom: 0; }
.setting-label { font-weight: 500; }
.setting-help { font-size: 12px; line-height: 16px; color: var(--ink-3); margin-top: 4px; }
.setting-control { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.affix { position: relative; display: inline-flex; align-items: center; }
.affix .input { width: 140px; text-align: right; }
.affix-pre { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.affix-pre + .input { padding-left: 24px; }
.affix-post { margin-left: 8px; color: var(--ink-3); }
.field-error { color: var(--neg); font-size: 12px; line-height: 16px; width: 100%; }
.preview { font-size: 13px; color: var(--ink-2); background: var(--ground); border-radius: var(--radius); padding: 12px 14px; margin: 0 20px 20px; }
.panel-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); }

/* ---------- keyword bots ---------- */
.name-input { width: 100%; max-width: 320px; }
.kw-box { display: grid; gap: 8px; width: 100%; }
.kw-box .chips { padding: 0; }
.kw-add { display: flex; gap: 8px; max-width: 420px; }
.kw-add .input { flex: 1; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--line); font-size: 14px; cursor: pointer; }
.check:hover { background: var(--hover); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.check:has(input:checked) { box-shadow: inset 0 0 0 1px var(--accent); }
.btn-quiet { margin-right: auto; background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { color: var(--neg); background: var(--hover); }
.saved { font-size: 12px; color: var(--ink-3); }
details.night > summary { cursor: pointer; list-style: none; }
details.night > summary::-webkit-details-marker { display: none; }
details.night > summary h2::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 10px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(-45deg); transition: transform 150ms ease; }
details.night[open] > summary h2::before { transform: rotate(45deg); }
details.night:not([open]) > summary { border-bottom: 0; }
.notice { display: flex; gap: 10px; padding: 12px 16px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn-ink); box-shadow: inset 0 0 0 1px var(--warn-line); font-size: 13px; }

/* ---------- players ---------- */
.add-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px auto; gap: 8px; }
.add-row label { display: block; }
.add-row .input, .add-row .select { width: 100%; }
.add-row .field-error { grid-column: 1 / -1; }
.add-row .field-error:empty { display: none; }
.sport-group + .sport-group { border-top: 1px solid var(--line); }
.sport-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 20px 6px; }
.sport-head h2 { font-size: 16px; line-height: 24px; font-weight: 600; }
.sport-head .meta { font-weight: 400; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 20px 16px; }
.chip { display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 2px 0 12px; border-radius: var(--radius); background: var(--ground); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; }
.chip.new { box-shadow: inset 0 0 0 1px var(--accent); }
.chip-static { padding: 0 12px; }
.chip button { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--ink-3); cursor: pointer; }
.chip button:hover { background: var(--hover); color: var(--ink); }
.chip svg { width: 14px; height: 14px; }
[data-savebar] { position: sticky; bottom: 16px; z-index: 5; }
.savebar {
  margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius); background: var(--btn); color: var(--btn-ink);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.savebar .btn { height: 36px; min-height: 36px; }
.savebar-actions { display: flex; gap: 8px; flex: none; }
.savebar .btn-ghost { background: transparent; color: var(--btn-ink); border-color: transparent; }
.savebar .btn-light { background: var(--btn-ink); color: var(--btn); border-color: var(--btn-ink); }

/* ---------- states ---------- */
.skel { display: inline-block; height: 1em; width: 64px; border-radius: 4px; background: var(--skel); vertical-align: middle; }
.empty { display: flex; align-items: center; min-height: 38px; padding: 10px 14px; margin: 16px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--ink-2); font-size: 13px; }
.error-block { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; margin: 16px 20px; border-radius: var(--radius); background: var(--neg-bg); color: var(--neg-ink); font-size: 13px; }
.status-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- dialog ---------- */
.dialog { border: 0; border-radius: 12px; padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 48px rgba(0,0,0,.28); }
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog form { padding: 20px; }
.dialog h2 { font-size: 16px; line-height: 24px; font-weight: 600; }
.dialog p { color: var(--ink-2); margin-top: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: min(360px, 100%); }
.login .brand { padding: 0; margin-bottom: 32px; }
.login h1 { font-size: 24px; line-height: 32px; font-weight: 600; margin-bottom: 16px; }
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field-label { font-weight: 500; }
.form .input { width: 100%; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .search { grid-column: 1 / -1; }
  .setting { grid-template-columns: 1fr; gap: 12px; }
}

/* ---------- phone ---------- */
@media (max-width: 767px) {
  body { font-size: 14px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 10; height: 48px;
    padding: 0 8px; background: var(--ground); border-bottom: 1px solid var(--line);
  }
  .topbar-title { font-weight: 600; }
  .sheet[hidden] { display: none; }
  .sheet:not([hidden]) { display: flex; flex-direction: column; position: fixed; inset: 0; z-index: 40; background: var(--ground); padding: 8px 16px 24px; }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; height: 48px; margin-bottom: 8px; }
  .nav-sheet a { height: 48px; font-size: 16px; }
  .nav-sheet svg { width: 20px; height: 20px; }
  .sheet-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }
  main { padding: 16px; }
  .page-head h1 { font-size: 20px; line-height: 28px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 14px 16px; }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--line); }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .kpi-value.answer { font-size: 28px; line-height: 36px; }
    .filters { grid-template-columns: 1fr 1fr; }
  .btn, .input, .select { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .add-row { grid-template-columns: 1fr 1fr; }
  .add-row .btn { grid-column: 1 / -1; }
  .affix .input { width: 120px; }
  .preview { margin: 0 16px 16px; }
  .setting { padding: 16px; }
}
@media (max-width: 639px) {
  /* tables become two-line lists; hidden columns move into the second line */
  .stack thead { display: none; }
  .stack tr { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .stack tbody tr:last-child { border-bottom: 0; }
  .stack td { display: block; padding: 0; border: 0; }
  .stack tbody tr:hover td { background: none; }
  .stack .m-hide { display: none; }
  .stack .m-main { flex: 1; min-width: 0; }
  .stack .m-end { text-align: right; }
  .only-m { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
