/* Data Listo portal — operations-tool design language
   Tokens: light default, dark via [data-theme="dark"] on <html>. */

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --surface-3: #e6eaf0;
  --border: #d8dee6;
  --border-strong: #c3cbd6;
  --text: #1c2430;
  --text-muted: #5b6675;
  --text-dim: #8a94a3;
  --accent: #2457d6;
  --accent-hover: #1d49b3;
  --accent-dim: rgba(36, 87, 214, 0.10);
  --accent-text: #ffffff;
  --ok: #178a4a;
  --ok-dim: rgba(23, 138, 74, 0.12);
  --warn: #b7791f;
  --warn-dim: rgba(183, 121, 31, 0.14);
  --err: #c62828;
  --err-dim: rgba(198, 40, 40, 0.10);
  --sandbox: #f6e7b3;
  --shadow: 0 6px 24px rgba(16, 24, 40, 0.12);
  --radius: 4px;
  --header-h: 56px;
  --sidebar-w: 280px;
  --row-h: 32px;
  --font: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #171d24;
  --surface-2: #1e262f;
  --surface-3: #26303b;
  --border: #2b3441;
  --border-strong: #3a4653;
  --text: #e6ebf1;
  --text-muted: #97a3b3;
  --text-dim: #6c7886;
  --accent: #5b8def;
  --accent-hover: #7aa3f5;
  --accent-dim: rgba(91, 141, 239, 0.16);
  --accent-text: #0f1419;
  --ok: #3ccb7f;
  --ok-dim: rgba(60, 203, 127, 0.14);
  --warn: #e0a43c;
  --warn-dim: rgba(224, 164, 60, 0.16);
  --err: #ef5b5b;
  --err-dim: rgba(239, 91, 91, 0.14);
  --sandbox: #4a3f14;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
input, select { font: inherit; color: var(--text); }
b, strong { font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; justify-content: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.link-btn { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; }
.link-btn:hover { text-decoration: underline; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg-btn { height: 30px; padding: 0 12px; border: none; background: var(--surface); color: var(--text-muted); cursor: pointer; font-weight: 500; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--accent-dim); color: var(--accent); }
.seg-sm .seg-btn { height: 24px; padding: 0 9px; font-size: 12px; }

/* ---------- Auth screen ---------- */
.auth-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card { width: 360px; padding: 32px 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.auth-logo { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.auth-logo span, .brand .dot, .home-logo span { color: var(--accent); }
.auth-app { color: var(--text-muted); margin: 4px 0 22px; }
.auth-or { margin: 16px 0 10px; color: var(--text-dim); font-size: 12px; text-align: center; }
.auth-email { display: flex; flex-direction: column; gap: 8px; }
.auth-email input { height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.auth-note { margin-top: 14px; color: var(--err); font-size: 12px; min-height: 16px; }
/* Public demo tenants (sidecar users.queryToolPublic): email first, staff SSO demoted to a link */
.auth-card.public { display: flex; flex-direction: column; }
.auth-card.public .auth-logo { order: 0; } .auth-card.public .auth-app { order: 1; }
.auth-card.public .auth-email { order: 2; } .auth-card.public .auth-note { order: 3; }
.auth-card.public .auth-or { order: 4; margin: 0; }
.auth-card.public #authSsoBtn { order: 5; margin-top: 2px; background: none; border: 0; color: var(--text-dim); font-size: 12px; text-decoration: underline; box-shadow: none; }
.auth-card.public #authSsoBtn:hover { color: var(--text); }
.auth-card.public .auth-email button { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-rows: var(--header-h) 1fr; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: inherit; text-decoration: none; }
.brand-sep { width: 1px; height: 22px; background: var(--border); }
.brand-app { color: var(--text-muted); font-size: 13px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.env-pill {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid var(--ok); border-radius: 999px; background: var(--ok-dim); color: var(--ok); font-weight: 600; font-size: 12px;
}
.env-pill .env-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.env-pill select { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.env-pill.env-test { border-color: var(--warn); background: var(--warn-dim); color: var(--warn); }
.env-pill.env-test .env-dot { background: var(--warn); }
.theme-select { height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-muted); font-size: 12px; cursor: pointer; }
.theme-select:hover { color: var(--text); border-color: var(--border-strong); }
.user-chip { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px 0 4px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); font-size: 12px; max-width: 240px; }
.user-initial { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11px; }
.user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar {
  display: flex; flex-direction: column; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar-backdrop { display: none; }
.sidebar-search { padding: 10px 12px 6px; }
.sidebar-search input { width: 100%; height: 30px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.sidebar-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

.nav { border-top: 1px solid var(--border); }
.nav-cat { border-bottom: 1px solid var(--border); }
.nav-cat-head {
  display: flex; align-items: center; width: 100%; height: 32px; padding: 0 12px;
  border: none; background: none; cursor: pointer; text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text);
}
.nav-cat-head:hover { background: var(--surface-2); }
.nav-cat-head .count { margin-left: 8px; color: var(--text-dim); font-weight: 500; letter-spacing: 0; }
.nav-cat-head .caret { margin-left: auto; transition: transform 0.15s; color: var(--text-dim); }
.nav-cat.open .nav-cat-head .caret { transform: rotate(90deg); }
.nav-cat-items { display: none; padding: 2px 0 6px; background: var(--surface-2); }
.nav-cat.open .nav-cat-items { display: block; }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 30px; padding: 4px 12px 4px 24px;
  border: none; background: none; text-align: left; cursor: pointer; color: var(--text-muted); font-size: 13px;
}
.nav-item::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: var(--surface-3); }
.nav-item.active { color: var(--accent); font-weight: 600; background: var(--accent-dim); }
.nav-item.active::before { background: var(--accent); }
.nav-empty { padding: 12px 14px; color: var(--text-dim); font-size: 12px; }

.nav-section-label { padding: 12px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.nav-modules { display: flex; flex-direction: column; gap: 6px; padding: 4px 12px 8px; }
.module-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 32px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text-muted);
  cursor: pointer; font-weight: 500;
}
.module-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }
a.module-btn { text-decoration: none; }
.module-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 11px; line-height: 1.7; }
.sidebar-footer a { color: var(--text-muted); text-decoration: none; }

.main { overflow: auto; }
.page { padding: 18px 22px 40px; min-height: 100%; }

/* ---------- Home ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.tile { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tile-val { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-label { margin-top: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.home-prompt { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 120px 0 60px; }
.home-logo { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.home-sub { margin-top: 6px; color: var(--text-muted); }

/* ---------- Home cards ---------- */
.home-section-label { margin: 18px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { display: block; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: inherit; text-decoration: none; }
.card:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.card-title { font-weight: 600; font-size: 14px; }
.card-desc { margin-top: 4px; color: var(--text-muted); font-size: 12px; min-height: 32px; }
.card-cta { margin-top: 8px; color: var(--accent); font-size: 12px; font-weight: 600; }

/* ---------- Pivot / matrix pages ---------- */
/* Module pages get a slimmer, denser sidebar so the matrix has the room; the
   menu button collapses it entirely on desktop (.app.nav-collapsed). */
body.module-page .app { --sidebar-w: 200px; }
body.module-page .sidebar-search { padding: 8px 8px 4px; }
body.module-page .nav-cat-head { height: 28px; padding: 0 8px; font-size: 10px; }
body.module-page .nav-item { min-height: 26px; padding: 2px 8px 2px 18px; font-size: 12px; }
body.module-page .nav-section-label { padding: 10px 8px 3px; font-size: 10px; }
body.module-page .nav-modules { gap: 4px; padding: 2px 8px 6px; }
body.module-page .module-btn { height: 28px; font-size: 12px; }
body.module-page .sidebar-footer { padding: 8px; }
body.module-page .page { padding: 12px 16px 32px; }
.app.nav-collapsed { grid-template-columns: 0 1fr; }
.app.nav-collapsed .sidebar { display: none; }
.app.nav-collapsed .main { grid-column: 1 / -1; }
.pv-back { display: inline-block; margin-bottom: 8px; color: var(--text-muted); font-size: 12px; text-decoration: none; }
.pv-back:hover { color: var(--accent); text-decoration: underline; }
.pv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pv-param { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.pv-param select { height: 30px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.pv-presets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.pv-edited { font-size: 11px; color: var(--warn); font-weight: 600; margin-left: 4px; }
.pv-config { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-top: 10px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.pv-group { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pv-group-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); margin-right: 2px; }
.pv-chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px 0 9px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-2); font-size: 12px; cursor: grab; }
.pv-chip.dragging { opacity: 0.4; }
.pv-chip-x { width: 16px; height: 16px; border: none; border-radius: 50%; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 13px; line-height: 14px; padding: 0; }
.pv-chip-x:hover { background: var(--err-dim); color: var(--err); }
.pv-add-btn { width: 24px; height: 24px; border: 1px dashed var(--border-strong); border-radius: 999px; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 15px; line-height: 20px; padding: 0; }
.pv-add-btn:hover { color: var(--accent); border-color: var(--accent); }
.pv-add .dropdown-menu { left: 0; right: auto; top: 28px; max-height: 320px; overflow: auto; min-width: 200px; }
.pv-menu-empty { padding: 7px 10px; color: var(--text-dim); font-size: 12px; }
.pv-group-opts { margin-left: auto; gap: 10px; font-size: 12px; color: var(--text-muted); }
.pv-group-opts label { display: inline-flex; align-items: center; gap: 4px; }
.pv-body { display: grid; grid-template-columns: 220px 1fr; gap: 12px; margin-top: 10px; align-items: start; }
.pv-body:has(.pv-rail.collapsed) { grid-template-columns: 34px 1fr; }
.pv-rail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; position: sticky; top: 0; max-height: calc(100vh - var(--header-h) - 40px); overflow: auto; }
.pv-rail-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 10px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.pv-rail.collapsed .pv-rail-head { padding: 6px 4px; justify-content: center; border: none; }
.pv-rail.collapsed .pv-rail-head > span:first-child { display: none; }
.pv-rail-toggle { width: 24px; height: 24px; }
.pv-badge { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 10px; font-weight: 700; text-align: center; line-height: 16px; }
.pv-filter { border-bottom: 1px solid var(--border); }
.pv-filter summary { padding: 7px 10px; cursor: pointer; font-weight: 600; color: var(--text); list-style: none; display: flex; align-items: center; }
.pv-filter summary::before { content: '›'; margin-right: 6px; color: var(--text-dim); transition: transform 0.15s; }
.pv-filter[open] summary::before { transform: rotate(90deg); }
.pv-filter-body { padding: 0 8px 8px; }
.pv-filter-search { width: 100%; height: 26px; padding: 0 8px; margin-bottom: 4px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); font-size: 12px; }
.pv-filter-links { display: flex; gap: 10px; margin: 2px 0 4px; }
.pv-filter-opts { max-height: 220px; overflow: auto; }
.pv-filter-opts label { display: flex; align-items: center; gap: 6px; padding: 2px 2px; border-radius: 3px; cursor: pointer; }
.pv-filter-opts label:hover { background: var(--surface-2); }
.pv-filter-opts label span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-count { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.pv-main { min-width: 0; }
.pv-status { margin: 0 0 8px; }
.pv-matrix-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.pv-scroll { overflow: auto; max-height: calc(100vh - var(--header-h) - 60px); }
.pv-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
.pv-table th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-muted); font-weight: 600; padding: 0 10px; height: 28px; white-space: nowrap; border-bottom: 1px solid var(--border-strong); border-right: 1px solid var(--border); text-align: right; }
.pv-table th.pv-tier { text-align: center; background: var(--surface-3); color: var(--text); }
.pv-table th.pv-label-h { text-align: left; left: 0; z-index: 3; }
.pv-table th.pv-m { cursor: pointer; user-select: none; }
.pv-table th.pv-m:hover { color: var(--text); }
.pv-table th.pv-m.sorted { color: var(--accent); }
.pv-table tr:nth-child(2) th, .pv-table tr:nth-child(3) th, .pv-table tr:nth-child(4) th { top: 28px; }
.pv-table tr:nth-child(3) th { top: 56px; } .pv-table tr:nth-child(4) th { top: 84px; }
.pv-table th.pv-gt, .pv-table td.pv-gt { border-left: 2px solid var(--border-strong); }
.pv-table td { padding: 0 10px; height: var(--row-h, 30px); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; text-align: right; }
.pv-table td.pv-label { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; font-weight: 500; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.pv-row:not(.leaf):not(.pv-total) .pv-label { cursor: pointer; }
.pv-row:not(.leaf):not(.pv-total) .pv-label:hover { color: var(--accent); }
.pv-row.lvl-0:not(.leaf) td { background: var(--surface-2); font-weight: 600; }
.pv-row.lvl-0:not(.leaf) td.pv-label { background: var(--surface-2); }
.pv-row.lvl-1:not(.leaf) td.pv-label { font-weight: 600; }
.pv-row.leaf td.pv-label { font-weight: 400; color: var(--text); }
.pv-caret { display: inline-block; width: 14px; color: var(--text-dim); }
.pv-dot { display: inline-block; width: 14px; }
.pv-n { margin-left: 8px; color: var(--text-dim); font-weight: 400; font-size: 11px; }
.pv-total td { background: var(--surface-3); font-weight: 700; border-top: 2px solid var(--border-strong); }
.pv-total td.pv-label { background: var(--surface-3); }
.pv-v.pos { color: var(--ok); } .pv-v.neg { color: var(--err); }
.pv-compact { --row-h: 23px; } .pv-compact .pv-table { font-size: 11.5px; } .pv-compact .pv-table th { height: 24px; }
.pv-compact .pv-table tr:nth-child(2) th { top: 24px; } .pv-compact .pv-table tr:nth-child(3) th { top: 48px; } .pv-compact .pv-table tr:nth-child(4) th { top: 72px; }
@media (max-width: 900px) { .pv-body { grid-template-columns: 1fr; } .pv-rail { position: static; max-height: 260px; } .pv-group-opts { margin-left: 0; } }

/* ---------- Report ---------- */
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.report-title { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.report-desc { color: var(--text-muted); margin-top: 2px; max-width: 760px; }
.report-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: 34px; min-width: 160px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 30; }
.dropdown-menu button { display: block; width: 100%; padding: 7px 10px; border: none; background: none; text-align: left; cursor: pointer; border-radius: 3px; }
.dropdown-menu button:hover { background: var(--surface-2); }

.param-bar {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  margin-top: 14px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.param { display: flex; flex-direction: column; gap: 4px; }
.param-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.param select, .param input { height: 30px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); min-width: 140px; }
.param select:focus, .param input:focus, .filter-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.presets { display: flex; gap: 4px; flex-wrap: wrap; }
.preset { height: 24px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text-muted); font-size: 12px; cursor: pointer; }
.preset.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.daterange-inputs { display: flex; align-items: center; gap: 6px; }
.daterange-inputs span { color: var(--text-dim); }

.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.filter-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.filter-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-select { height: 26px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); font-size: 12px; max-width: 220px; color: var(--text-muted); }
.filter-select.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); font-weight: 600; }

.status-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 8px; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.status-spacer { flex: 1; }

.grid-wrap { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.grid-scroll { overflow: auto; max-height: calc(100vh - var(--header-h) - 230px); }
.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
.grid th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-muted);
  font-weight: 600; text-align: left; padding: 0 10px; height: 30px; white-space: nowrap;
  border-bottom: 1px solid var(--border-strong); border-right: 1px solid var(--border); cursor: pointer; user-select: none;
}
.grid th:hover { color: var(--text); }
.grid th .th-label { display: inline-block; }
.grid th .th-hide { display: none; margin-left: 6px; width: 16px; height: 16px; line-height: 14px; padding: 0; border: none; border-radius: 3px; background: transparent; color: var(--text-dim); font-size: 13px; cursor: pointer; vertical-align: middle; }
.grid th:hover .th-hide { display: inline-block; }
.grid th .th-hide:hover { background: var(--err-dim); color: var(--err); }
.grid th.dragging { opacity: 0.5; }
.grid th.drop-left { box-shadow: inset 3px 0 0 var(--accent); }
.grid th.drop-right { box-shadow: inset -3px 0 0 var(--accent); }
.grid th .sort-ind { margin-left: 4px; color: var(--accent); font-size: 10px; }
.grid th.num, .grid td.num { text-align: right; }
.grid td { padding: 0 10px; height: var(--row-h); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.grid tr:hover td { background: var(--surface-2); }
.grid-wrap.compact { --row-h: 24px; }
.grid-wrap.compact .grid td { font-size: 11.5px; }
.grid-empty { padding: 48px; text-align: center; color: var(--text-dim); }
.grid-empty-cta { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.grid-empty-cta p { margin: 0; }
.grid-error { padding: 20px; color: var(--err); background: var(--err-dim); border-top: 1px solid var(--err); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; }
.grid-loading { padding: 40px; text-align: center; color: var(--text-muted); }

.chart-wrap { margin-top: 4px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.chart-controls { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px; color: var(--text-muted); }
.chart-controls select { margin-left: 6px; height: 26px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
#chartCanvas { max-height: 460px; }

/* ---------- Popover ---------- */
.popover { position: absolute; z-index: 40; width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.popover-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
.popover-body { max-height: 360px; overflow: auto; padding: 6px; }
.popover-foot { padding: 6px 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-dim); }
.col-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 3px; cursor: grab; }
.col-row:hover { background: var(--surface-2); }
.col-row.dragging { opacity: 0.4; }
.col-row .handle { color: var(--text-dim); }

/* ---------- Reference / content pages ---------- */
.content { max-width: 960px; }
.content h1 { font-size: 20px; font-weight: 600; margin: 0 0 6px; }
.content h2 { font-size: 15px; font-weight: 600; margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.content p, .content li { color: var(--text-muted); }
.content table { width: 100%; border-collapse: collapse; font-size: 12px; background: var(--surface); border: 1px solid var(--border); }
.content th, .content td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.content th { background: var(--surface-2); color: var(--text-muted); font-weight: 600; }
.content code { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.content .muted { color: var(--text-dim); }
.dict-search { width: 100%; max-width: 420px; height: 30px; padding: 0 10px; margin: 8px 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.dict-obj { margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.dict-obj summary { padding: 8px 12px; cursor: pointer; font-weight: 600; font-family: var(--mono); font-size: 12px; }
.dict-obj summary .muted { font-weight: 400; font-family: var(--font); margin-left: 8px; }

.banner { margin-bottom: 14px; padding: 8px 12px; border-radius: var(--radius); background: var(--sandbox); color: var(--text); font-size: 12px; }

/* ---------- Toast ---------- */
.toast { position: fixed; right: 18px; bottom: 18px; padding: 9px 14px; background: var(--text); color: var(--bg); border-radius: var(--radius); font-size: 12px; opacity: 0; transform: translateY(6px); transition: all 0.2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: var(--header-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 25; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .sidebar-backdrop { position: fixed; inset: var(--header-h) 0 0 0; background: rgba(0,0,0,0.35); z-index: 24; }
  .sidebar-backdrop.open { display: block; }
  .brand-app { display: none; }
  .user-email { display: none; }
  .page { padding: 14px; }
  .grid-scroll { max-height: calc(100vh - var(--header-h) - 300px); }
}
