:root {
  color-scheme: light;
  --bg: oklch(97.8% 0.003 250);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(96.6% 0.004 250);
  --fg: oklch(21% 0.014 250);
  --muted: oklch(46% 0.012 250);
  --border: oklch(89% 0.006 250);
  --border-strong: oklch(74% 0.01 250);
  --accent: oklch(51% 0.13 152);
  --on-accent: oklch(99% 0 0);
  --ok: oklch(52% 0.13 150);
  --warn: oklch(60% 0.13 70);
  --danger: oklch(52% 0.18 25);
  --info: oklch(52% 0.11 250);
  --accent-soft: color-mix(in oklch, var(--accent) 9%, transparent);
  --ok-soft: color-mix(in oklch, var(--ok) 11%, transparent);
  --warn-soft: color-mix(in oklch, var(--warn) 14%, transparent);
  --danger-soft: color-mix(in oklch, var(--danger) 10%, transparent);
  --info-soft: color-mix(in oklch, var(--info) 10%, transparent);
  --fg-soft: color-mix(in oklch, var(--fg) 5%, transparent);
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 3px;
  --radius-lg: 4px;
  font-family: var(--font-body);
  font-synthesis: none;
  background: var(--bg);
  color: var(--fg);
}
[data-theme='dark'] {
  color-scheme: dark;
  --bg: oklch(19% 0.012 250);
  --surface: oklch(22.5% 0.014 250);
  --surface-2: oklch(25% 0.015 250);
  --fg: oklch(93% 0.006 250);
  --muted: oklch(67% 0.012 250);
  --border: oklch(30% 0.014 250);
  --border-strong: oklch(42% 0.016 250);
  --accent: oklch(72% 0.13 152);
  --on-accent: oklch(20% 0.016 250);
  --ok: oklch(72% 0.13 150);
  --warn: oklch(78% 0.12 75);
  --danger: oklch(68% 0.16 25);
  --info: oklch(70% 0.11 250);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-size: 13.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
svg { display: block; width: 17px; height: 17px; flex: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; line-height: 1.4; }
h2 { font-size: 13px; font-weight: 650; letter-spacing: -.005em; }
h3 { font-size: 14px; }
small { font-size: 11px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 2px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 11px; }
.num, .cell-id { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.cell-id { font-size: 12px; overflow-wrap: anywhere; }
.required { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 15px; background: var(--surface); border: 1px solid var(--accent); transform: translateY(-180%); }
.skip-link:focus { transform: translateY(0); }

/* ── buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 13px; min-height: 34px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--fg); font-size: 13px; font-weight: 550; letter-spacing: -.005em; line-height: 1.4; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.btn svg { width: 14px; height: 14px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: color-mix(in oklch, var(--accent) 84%, var(--fg)); }
.btn.secondary { background: var(--surface); color: var(--fg); border-color: var(--border-strong); }
.btn.secondary:hover:not(:disabled) { border-color: var(--fg); }
.btn.ghost { background: transparent; border-color: transparent; padding: 7px 9px; }
.btn.ghost:hover:not(:disabled) { background: var(--fg-soft); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in oklch, var(--danger) 40%, transparent); }
.btn.danger:hover:not(:disabled) { background: var(--danger); color: var(--surface); }
.btn.icon-button { width: 30px; height: 30px; min-height: 30px; padding: 0; display: grid; place-items: center; border: 1px solid var(--border); background: var(--surface); }
.btn.icon-button:hover:not(:disabled) { border-color: var(--fg); }
.btn.icon-button svg { width: 15px; height: 15px; }
.danger-text { color: var(--danger); }
.actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* ── app shell ───────────────────────────────────────────── */
.app-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 14px 10px; border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 6px 16px; border-bottom: 1px solid var(--border); }
.brand-mark { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); }
.brand-mark svg { width: 17px; height: 17px; }
.brand b { display: block; font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .05em; }
.side-nav { display: flex; flex-direction: column; gap: 1px; margin-top: 8px; }
.side-label { padding: 12px 8px 5px; color: var(--muted); font-family: var(--font-mono); font-size: 10px; letter-spacing: .11em; text-transform: uppercase; }
.nav-item { position: relative; display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px; border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--muted); font-size: 13px; font-weight: 500; text-align: left; }
.nav-item svg { width: 15px; height: 15px; }
.nav-item:hover { background: var(--fg-soft); color: var(--fg); }
.nav-item.is-active { background: var(--surface-2); color: var(--fg); font-weight: 650; box-shadow: inset 2px 0 0 var(--accent); }
.nav-item.is-active svg { color: var(--accent); }
.side-foot { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.side-foot > .btn { justify-content: flex-start; width: 100%; }
.side-user { display: flex; align-items: center; gap: 8px; padding: 8px 4px 0; border-top: 1px solid var(--border); }
.avatar { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); font-family: var(--font-mono); font-weight: 650; }
.side-user > div { flex: 1; min-width: 0; }
.side-user b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.side-user small { display: block; color: var(--muted); font-family: var(--font-mono); font-size: 9.5px; }
.side-note { margin: 7px 4px 0; color: var(--muted); font-size: 10px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 66px; padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.breadcrumb { margin-bottom: 2px; color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .03em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.last-updated { color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }
.view { padding: 18px 20px 36px; }
.page-description { margin-bottom: 16px; color: var(--muted); font-size: 12px; }
.view-content { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.grid { display: grid; gap: 14px; min-width: 0; }
.grid-2-1 { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
.grid-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid .quick-links { grid-template-columns: 1fr; }
.grid .quick-links a { border-right: 0; border-bottom: 1px solid var(--border); }
.grid .quick-links a:last-child { border-bottom: 0; }

/* ── panels / tables ─────────────────────────────────────── */
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 11px 15px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; }
.panel-head .btn { min-height: 29px; padding: 5px 9px; font-size: 11.5px; }
.panel-head .hint { margin-left: auto; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; text-align: left; font-size: 12.5px; }
th, td { padding: 9px 13px; vertical-align: middle; overflow-wrap: anywhere; }
th { border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
th:first-child { width: 23%; }
td { border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td strong { font-weight: 600; }
td small { display: block; margin-top: 2px; color: var(--muted); font-size: 10.5px; overflow-wrap: anywhere; }
td .btn { min-height: 27px; padding: 4px 8px; font-size: 11px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: var(--radius); background: var(--fg-soft); color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .02em; line-height: 1.5; white-space: nowrap; }
.badge.success { background: var(--ok-soft); color: var(--ok); }
.badge.warning { background: var(--warn-soft); color: color-mix(in oklch, var(--warn) 78%, var(--fg)); }
.badge.danger-text { background: var(--danger-soft); color: var(--danger); }
.badge.dot::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 15px; border-top: 1px solid var(--border); color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }
.pagination .btn { min-height: 28px; padding: 5px 9px; font-size: 11px; }
.page-size { display: inline-flex; align-items: center; gap: 6px; }
.page-size select { width: auto; min-height: 28px; padding: 3px 6px; font-size: 11px; }

/* ── KPI / quick links ───────────────────────────────────── */
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.metric { min-width: 0; padding: 12px 13px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.metric-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; }
.metric strong { display: block; margin-top: 6px; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 20px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric p { margin-top: 4px; color: var(--muted); font-size: 10.5px; }
.metric:nth-last-child(-n+2) strong { color: var(--accent); }
.quick-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.quick-links a { display: flex; align-items: center; gap: 12px; padding: 18px 16px; border-right: 1px solid var(--border); }
.quick-links a:last-child { border-right: 0; }
.quick-links a:hover { background: var(--surface-2); }
.quick-links a > svg:first-child { color: var(--accent); }
.quick-links a > svg:last-child { width: 14px; margin-left: auto; color: var(--muted); }
.quick-links b { display: block; font-size: 12.5px; font-weight: 600; }
.quick-links small { display: block; margin-top: 3px; color: var(--muted); font-size: 10.5px; }
.quota-strip { display: flex; flex-wrap: wrap; gap: 16px 26px; padding: 11px 15px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--muted); font-size: 12px; }
.quota-strip b { margin-left: 5px; color: var(--fg); font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── forms ───────────────────────────────────────────────── */
input:not([type='checkbox']):not([type='radio']), select, textarea { display: block; width: 100%; min-width: 0; min-height: 34px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--fg); font-size: 13px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: color-mix(in oklch, var(--muted) 70%, transparent); }
textarea { resize: vertical; }
input[type='checkbox'] { width: 15px; height: 15px; flex: none; margin: 3px 0 0; accent-color: var(--accent); }
input[type='radio'] { width: 15px; height: 15px; flex: none; margin: 3px 0 0; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin-bottom: 16px; }
.field > span { color: var(--muted); font-size: 11.5px; font-weight: 550; }
.field small { color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.check-field { display: flex; align-items: flex-start; gap: 9px; margin: 0 0 16px; font-size: 12.5px; }
.check-field small { display: block; margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.settings-form { max-width: 890px; padding: 20px 20px 0; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 16px 0; border-top: 1px solid var(--border); }
.form-foot p { max-width: 70%; }
.form-error, .callout { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); }
.form-error { margin-bottom: 16px; border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.search-form { display: flex; flex-wrap: wrap; gap: 8px; }
.search-form > input { width: 280px; flex: 0 1 280px; }

/* ── states ──────────────────────────────────────────────── */
.empty, .load-error { padding: 48px 20px; text-align: center; }
.empty svg { width: 29px; height: 29px; margin: 0 auto 14px; color: var(--muted); }
.empty p, .load-error p { margin-top: 6px; color: var(--muted); font-size: 12px; }
.load-error { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.load-error .btn { margin-top: 16px; }
.loading { display: flex; flex-direction: column; gap: 14px; min-height: 300px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.skeleton { height: 40px; border-radius: var(--radius); background: var(--surface-2); animation: pulse 1.5s ease-in-out infinite; }
.skeleton-title { width: 35%; height: 20px; margin-bottom: 8px; }
@keyframes pulse { 50% { opacity: .45; } }

/* ── dialog / notifications ─────────────────────────────── */
dialog { width: min(530px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; overflow-y: auto; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--fg); }
dialog::backdrop { background: rgb(10 17 25 / 48%); }
.dialog-head { padding: 15px 18px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 14px; }
.dialog-body { padding: 18px; }
.dialog-body p { overflow-wrap: anywhere; }
.dialog-body .field:last-of-type { margin-bottom: 0; }
.dialog-body .form-error { margin-top: 16px; margin-bottom: 0; }
.dialog-intro { margin-bottom: 18px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 13px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.notifications { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 40px)); }
.notification { display: flex; align-items: flex-start; gap: 14px; padding: 11px 14px; border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--surface); font-size: 12px; overflow-wrap: anywhere; }
.notification.error { border-left-color: var(--danger); }
.notice-close { margin-left: auto; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ── auth ────────────────────────────────────────────────── */
.auth-layout { display: grid; grid-template-columns: minmax(360px, 40%) minmax(0, 1fr); min-height: 100vh; }
.auth-aside { display: flex; flex-direction: column; padding: 32px 40px 22px; border-right: 1px solid var(--border); background: var(--surface); }
.auth-aside .brand { padding-left: 0; border: 0; }
.auth-story { max-width: 380px; margin: auto 0; padding: 60px 0; }
.relay-graphic { display: flex; align-items: center; gap: 15px; margin-bottom: 28px; font-size: 12px; }
.relay-graphic span { padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); }
.relay-graphic svg { width: 28px; height: 28px; color: var(--accent); }
.auth-story h1 { font-size: clamp(30px, 3vw, 42px); font-weight: 600; letter-spacing: -1px; line-height: 1.4; }
.auth-story > p { max-width: 310px; margin: 17px 0 30px; color: var(--muted); font-size: 13px; line-height: 1.9; }
.auth-feature { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; }
.auth-feature svg { color: var(--accent); }
.auth-aside-foot { color: var(--muted); font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em; }
.auth-main { display: flex; flex-direction: column; min-width: 0; padding: 24px 36px 20px; }
.auth-toolbar { display: flex; justify-content: flex-end; }
.auth-card { width: 100%; max-width: 370px; margin: auto; padding: 38px 0; }
.auth-card h2 { font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
.auth-description { margin: 9px 0 24px; color: var(--muted); font-size: 12px; }
.auth-tabs { display: flex; gap: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.auth-tabs a { display: block; padding: 0 4px 10px; border-bottom: 2px solid transparent; color: var(--muted); }
.auth-tabs a[aria-current] { border-color: var(--accent); color: var(--fg); font-weight: 600; }
.auth-submit { width: 100%; min-height: 39px; margin-top: 4px; justify-content: space-between; padding-right: 14px; padding-left: 14px; }
.session-note { display: flex; align-items: flex-start; gap: 7px; margin-top: 18px; color: var(--muted); font-size: 10.5px; }
.session-note svg { width: 14px; height: 14px; margin-top: 1px; }
.auth-footer { color: var(--muted); font-family: var(--font-mono); font-size: 10px; text-align: center; letter-spacing: .03em; }

/* ── responsive ──────────────────────────────────────────── */
@media (min-width: 1550px) { .view { padding-right: 32px; padding-left: 32px; } }
@media (max-width: 1200px) { .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1024px) { .grid-2-1, .grid-1-1 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1000px) {
  .topbar { padding: 10px 16px; }
  .view { padding: 16px; }
  .last-updated { display: none; }
  .quick-links { grid-template-columns: 1fr; }
  .quick-links a { border-right: 0; border-bottom: 1px solid var(--border); }
  .quick-links a:last-child { border-bottom: 0; }
}
@media (max-width: 900px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; padding: 12px; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-label { display: none; }
  .side-foot { margin-top: 8px; }
  .side-user { border-top: 0; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-main { padding: 12px 25px 20px; }
  .auth-card { padding: 30px 0 45px; }
  .form-grid { grid-template-columns: 1fr; }
  .settings-form { padding-right: 15px; padding-left: 15px; }
  .search-form > input { width: 100%; flex: 1 1 100%; }
  .table-wrap { margin-right: -1px; margin-left: -1px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; } }
