/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e4e6eb;
  --grid: #eceef2;
  --axis: #c9ccd3;
  --text: #0f1728;
  --text-2: #4a5263;
  --muted: #858b97;
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, .10);
  --good-text: #0b7a0b;
  --bad-text: #b42f2f;

  --sidebar-bg: #14233a;
  --sidebar-text: #aab6c8;
  --sidebar-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(57, 135, 229, .22);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;

  --st-good: #0ca30c;
  --st-warning: #fab219;
  --st-serious: #ec835a;
  --st-critical: #d03b3b;
  --st-info: #2a78d6;
  --st-neutral: #858b97;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0f14;
    --surface: #151a22;
    --surface-2: #1a2029;
    --border: #252c37;
    --grid: #222935;
    --axis: #353d4a;
    --text: #f1f4f8;
    --text-2: #b9c1cd;
    --muted: #7f8896;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, .16);
    --good-text: #2fbf2f;
    --bad-text: #ef6b6b;
    --sidebar-bg: #0f1520;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --st-info: #3987e5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0f14;
  --surface: #151a22;
  --surface-2: #1a2029;
  --border: #252c37;
  --grid: #222935;
  --axis: #353d4a;
  --text: #f1f4f8;
  --text-2: #b9c1cd;
  --muted: #7f8896;
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, .16);
  --good-text: #2fbf2f;
  --bad-text: #ef6b6b;
  --sidebar-bg: #0f1520;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --st-info: #3987e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  width: 248px; flex: none;
  display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  padding: 20px 14px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #3987e5, #1c5cab); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .03em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: var(--sidebar-strong); font-size: 15px; }
.brand-text small { font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 16px 10px 6px; opacity: .7; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px;
  color: inherit; text-decoration: none; font-weight: 500;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-strong); }
.nav-item.is-active { background: var(--sidebar-active); color: var(--sidebar-strong); }
.nav-item[aria-disabled="true"] { cursor: default; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.08); margin-top: 16px; }
.db-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-neutral); }
.db-dot[data-state="connected"] { background: var(--st-good); }
.db-dot[data-state="error"] { background: var(--st-critical); }

.main { flex: 1; min-width: 0; padding: 0 28px 28px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 0; margin-bottom: 8px;
  background: var(--bg);
}
.page-head { flex: 1; min-width: 0; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn.menu-btn { display: none; }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

/* ---------- Controls ---------- */
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface); cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.segmented { display: inline-flex; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.segmented button {
  border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer;
  font-weight: 500; font-size: 13px; color: var(--text-2);
}
.segmented button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface); cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn.ghost + .btn.ghost { margin-left: 8px; }
select {
  height: 36px; padding: 0 30px 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23858b97' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.search { position: relative; flex: 1; max-width: 340px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
}
.search input::placeholder { color: var(--muted); }

.notice {
  margin-bottom: 16px; padding: 10px 14px; border-radius: 10px;
  background: var(--accent-soft); color: var(--text-2); font-size: 13px;
}
.notice.is-error { background: rgba(208, 59, 59, .12); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px 14px;
}
.kpi-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin: 4px 0 6px; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.delta { font-size: 12px; font-weight: 600; white-space: nowrap; }
.delta.good { color: var(--good-text); }
.delta.bad { color: var(--bad-text); }
.delta.flat { color: var(--muted); }
.delta small { font-weight: 400; color: var(--muted); margin-left: 3px; }
.spark { width: 72px; height: 26px; }
.spark path { stroke: var(--series-1); stroke-width: 2; fill: none; }
.spark .area { stroke: none; fill: var(--accent-soft); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Cards & grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; min-width: 0;
}
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head.wrap { flex-wrap: wrap; }
.card-head h2 { font-size: 15px; }
.card-sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.chart-box { position: relative; }
.h-200 { height: 200px; }
.h-260 { height: 260px; }
.h-300 { height: 300px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item b { font-weight: 600; color: var(--text); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.line { height: 3px; width: 14px; border-radius: 2px; }
.swatch.dashed { width: 14px; height: 0; border-top: 2px dashed var(--text-2); border-radius: 0; }

.donut-wrap { display: flex; flex-direction: column; gap: 14px; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.donut-center strong { font-size: 22px; font-weight: 600; }
.donut-center span { font-size: 12px; color: var(--muted); }
.mix-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.mix-list li { display: grid; grid-template-columns: 14px 1fr auto auto; align-items: center; gap: 8px; font-size: 13px; }
.mix-list .n { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }
.mix-list .p { font-variant-numeric: tabular-nums; color: var(--muted); width: 48px; text-align: right; }

/* ---------- Table ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.toolbar .btn { margin-left: auto; }
.table-wrap { overflow-x: auto; margin: 0 -20px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 20px; text-align: left; white-space: nowrap; }
.table th {
  font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  background: var(--surface-2); border-block: 1px solid var(--border); cursor: pointer; user-select: none;
}
.table th:hover { color: var(--text); }
.table th[aria-sort] { color: var(--text); }
.table th[aria-sort="ascending"]::after { content: " ↑"; }
.table th[aria-sort="descending"]::after { content: " ↓"; }
.table td { border-bottom: 1px solid var(--border); color: var(--text-2); }
.table td:first-child { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.table tbody tr:hover td { background: var(--surface-2); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.table td.num { color: var(--text); font-weight: 500; }
.table .empty { text-align: center; color: var(--muted); padding: 32px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--st-neutral)); }
[data-status="neutral"], [data-tone="neutral"] { --dot: var(--st-neutral); }
[data-status="info"], [data-tone="info"] { --dot: var(--st-info); }
[data-status="good"], [data-tone="good"] { --dot: var(--st-good); }
[data-status="warning"], [data-tone="warning"] { --dot: var(--st-warning); }
[data-status="critical"], [data-tone="critical"] { --dot: var(--st-critical); }
.badge.sm { font-size: 11px; padding: 0 7px 0 6px; margin-left: 4px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.status-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.status-pills .badge { cursor: pointer; }
.status-pills .badge b { font-variant-numeric: tabular-nums; }
.status-pills .badge[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; color: var(--muted); font-size: 13px; }

.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 26px 0 0; }

/* ---------- Sample components ---------- */
.el-tag {
  flex: none; align-self: flex-start;
  font-size: 11px; font-weight: 600; letter-spacing: .03em; font-variant-numeric: tabular-nums;
  color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 7px;
}
.head-right { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.h-80 { height: 80px; }

.hero { display: flex; flex-direction: column; }
.hero-value { font-size: 40px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.hero-meta { margin: 6px 0 12px; }
.hero .chart-box { margin: auto -20px -18px; }

.kpi-block { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.kpi-block-head { display: flex; align-items: center; gap: 8px; }
.kpi-block .kpis { margin: 0; flex: 1; }
.kpis-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.progress-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.progress-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; color: var(--text-2); }
.progress-val { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--series-1); border-radius: 99px; }
.progress.is-over i { background: var(--st-critical); }

.leaderboard { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.leaderboard li { display: grid; grid-template-columns: 26px 32px 1fr auto; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.leaderboard li:last-child { border-bottom: 0; }
.rank { display: grid; place-items: center; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank.top { color: var(--text); }
.rank svg { color: var(--st-warning); width: 20px; height: 20px; }
.lb-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.lb-name { display: flex; flex-direction: column; gap: 5px; font-weight: 500; min-width: 0; }
.lb-name i { display: block; height: 4px; border-radius: 99px; background: var(--series-1); opacity: .55; }
.lb-val { font-weight: 600; font-variant-numeric: tabular-nums; }

.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-top: 8px;
  border: 1px solid var(--border); border-left: 3px solid var(--dot); border-radius: 8px;
  background: var(--surface-2); font-size: 13px; color: var(--text-2);
}
.alert svg { color: var(--dot); margin-top: 1px; }
.alert b { color: var(--text); font-weight: 600; }

.heatmap-wrap { overflow-x: auto; }
.heatmap { display: grid; grid-template-columns: 40px repeat(24, minmax(22px, 1fr)); gap: 3px; min-width: 640px; }
.hm-x, .hm-y { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hm-x { text-align: left; }
.hm-y { display: flex; align-items: center; }
.hm-cell {
  aspect-ratio: 1.6; border-radius: 4px;
  background: color-mix(in srgb, var(--series-1) calc(var(--v) * 100%), var(--surface-2));
}
.hm-cell:hover { outline: 2px solid var(--text); outline-offset: -1px; }
.heat-scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.heat-scale i { width: 90px; height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--surface-2), var(--series-1)); border: 1px solid var(--border); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field input, .field select { height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background-color: var(--surface); font-weight: 400; }
.field select { padding-right: 30px; }
.field .segmented { align-self: flex-start; }
.switch, .check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { position: relative; width: 36px; height: 20px; border-radius: 99px; background: var(--axis); transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.danger { color: var(--bad-text); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.pager .btn.ghost { border-color: var(--border); }

.state-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mini-empty, .mini-loading { border: 1px dashed var(--border); border-radius: 10px; padding: 18px; min-height: 170px; }
.mini-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; }
.mini-empty svg { width: 28px; height: 28px; color: var(--muted); margin-bottom: 6px; }
.mini-empty span { color: var(--muted); font-size: 12.5px; }
.mini-loading { display: flex; flex-direction: column; gap: 10px; }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 64px 24px; }
.empty-state svg { width: 36px; height: 36px; color: var(--muted); margin-bottom: 12px; }
.empty-state h2 { font-size: 17px; }
.empty-state p { color: var(--text-2); max-width: 440px; margin: 6px 0 0; }
.empty-state a { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .span-8, .span-4 { grid-column: span 12; }
  .donut-wrap { flex-direction: row; align-items: center; }
  .donut-wrap .chart-box { flex: 0 0 220px; }
  .mix-list { flex: 1; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.is-open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
  .icon-btn.menu-btn { display: grid; }
  .main { padding: 0 16px 20px; }
  .span-6 { grid-column: span 12; }
  .table-wrap { margin: 0 -16px; }
  .card { padding: 16px; }
}
@media (max-width: 600px) {
  .topbar { position: static; gap: 10px; align-items: flex-start; }
  .page-head h1 { font-size: 19px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 20px; }
  .spark { display: none; }
  .donut-wrap { flex-direction: column; }
  .donut-wrap .chart-box { flex: none; width: 100%; }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar .btn { margin-left: 0; }
  .form-grid, .state-pair { grid-template-columns: 1fr; }
  .hero-value { font-size: 32px; }
  .hero .chart-box { margin: auto -16px -16px; }
}

.muted { color: var(--muted); }

/* ---------- DB schema page ---------- */
code, .tname { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.tname { font-size: 15px; font-weight: 600; }
.chip-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13px;
}
.chip:hover { border-color: var(--accent); }
.chip span { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.join-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.join-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; }
.join-list code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }
.join-eq { color: var(--muted); font-weight: 600; }
.schema-card { scroll-margin-top: 90px; }
.sample-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 18px 0 8px; }
.schema-cols th, .sample-rows th { cursor: default; }
.schema-cols td, .sample-rows td, .schema-cols th, .sample-rows th { padding: 8px 20px; }
.sample-rows th { text-transform: none; letter-spacing: 0; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 500; }
.sample-rows td { font-variant-numeric: tabular-nums; color: var(--text); }
.schema-cols td:first-child, .sample-rows td:first-child { font-weight: 400; }
@media (max-width: 900px) {
  .schema-cols td, .sample-rows td, .schema-cols th, .sample-rows th { padding: 8px 16px; }
}

/* Long column names wrap instead of forcing horizontal scroll. */
.table th { white-space: normal; vertical-align: bottom; line-height: 1.3; }

/* ---------- Editable inclusion columns ---------- */
.table td.edit-col, .table td.sum-col { white-space: nowrap; vertical-align: middle; }
.table th.edit-col, .table th.sum-col { min-width: 150px; }
.edit-cell { display: inline-flex; align-items: center; gap: 6px; }
.cell-select, .pct-input input {
  height: 32px; border: 1px solid var(--border); border-radius: 8px; background-color: var(--surface);
  font-variant-numeric: tabular-nums; color: var(--text);
}
.cell-select { padding: 0 28px 0 10px; background-position: right 8px center; }
.cell-select:hover, .pct-input input:hover { border-color: var(--axis); }
.pct-input { position: relative; display: inline-flex; align-items: center; }
.pct-input input { width: 78px; padding: 0 22px 0 10px; text-align: right; -moz-appearance: textfield; }
.pct-input input::-webkit-outer-spin-button, .pct-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pct-input span { position: absolute; right: 9px; color: var(--muted); font-size: 12.5px; pointer-events: none; }
.save-state { width: 14px; height: 14px; flex: none; display: inline-grid; place-items: center; font-size: 12px; }
.save-state[data-state="saving"]::after { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.save-state[data-state="saved"]::after { content: "✓"; color: var(--good-text); font-weight: 700; }
.save-state[data-state="error"]::after { content: "!"; color: var(--bad-text); font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

.hv-cell { display: flex; align-items: center; gap: 12px; }
.hv-meter { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.meter { position: relative; height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--series-1); transition: width .15s; }
.meter-label { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.meter-label b { color: var(--text); font-weight: 600; }
.over-flag { color: var(--bad-text); font-weight: 600; font-size: 12px; margin-left: 6px; }
.hv-meter.is-over .meter i { background: var(--st-critical); }

.sum-cell { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.sum-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.sum-top b { font-weight: 600; color: var(--text); }
.sum-top .muted { font-size: 12px; }
.meter.capped { overflow: visible; }
.cap-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text-2); border-radius: 1px; }
.sum-cell.is-over .meter i { background: var(--st-critical); }
.sum-cell.is-over .sum-top b { color: var(--bad-text); }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 360px;
  padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--surface); font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.is-error { background: var(--st-critical); color: #fff; }

/* Summer table: 8 columns, keep it within the card on laptop widths. */
#summerTable .table th, #summerTable .table td { padding-left: 12px; padding-right: 12px; }
#summerTable .table th:first-child, #summerTable .table td:first-child { padding-left: 20px; }
#summerTable .table th:last-child, #summerTable .table td:last-child { padding-right: 20px; }
.hv-cell { flex-direction: column; align-items: stretch; gap: 6px; }
.hv-meter { min-width: 0; }
.table th.edit-col, .table th.sum-col { min-width: 0; }
.hv-cell, .sum-cell { width: 150px; min-width: 150px; }
