/* Shared tokens, reset and components. System fonts only. */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #191919;
  --text-2: #5c5f66;
  --border: #dcdfe4;
  --grid: #e8eaee;
  --accent: #1757ac;
  --accent-contrast: #ffffff;
  --focus: #257de0;
  --danger: #b3261e;
  --ok: #1b6e2d;
  --warn-bg: #fff4d6;
  --warn-text: #5c4300;
  --err-bg: #fde8e7;
  --ok-bg: #e3f4e6;
  /* categorical series, fixed order */
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101113;
    --surface: #191919;
    --surface-2: #232427;
    --text: #efefef;
    --text-2: #9c9c9c;
    --border: #34363a;
    --grid: #2b2d31;
    --accent: #6aabf1;
    --accent-contrast: #101113;
    --focus: #6aabf1;
    --danger: #f2877f;
    --ok: #7fd48f;
    --warn-bg: #3a2f10;
    --warn-text: #f3d98b;
    --err-bg: #3d1d1b;
    --ok-bg: #16301c;
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
    --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.btn {
  font: inherit; font-weight: 600;
  min-height: 44px; padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); font-size: .9rem; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-2); font-weight: 600; font-size: .8rem; white-space: nowrap; }
caption { text-align: left; color: var(--text-2); font-size: .85rem; padding-bottom: 6px; }
.table-wrap { overflow-x: auto; }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.notice { padding: 12px 14px; border-radius: 10px; font-size: .95rem; }
.notice-error { background: var(--err-bg); color: var(--danger); }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-warn { background: var(--warn-bg); color: var(--warn-text); }
