:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #dfe3e8;
  --text: #1a1f27;
  --text-dim: #5b6472;
  --accent: #2b5fd9;
  --accent-2: #0e7c66;
  --danger: #b3261e;
  --warn: #a15c00;
  --ok: #0e7c66;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20,25,35,.06), 0 1px 1px rgba(20,25,35,.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1319;
    --surface: #161c25;
    --surface-2: #1d2430;
    --border: #2a3340;
    --text: #e6e9ee;
    --text-dim: #9aa4b2;
    --accent: #6d93ef;
    --accent-2: #3fc9a8;
    --danger: #ff6b64;
    --warn: #e0a53a;
    --ok: #3fc9a8;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1319;
  --surface: #161c25;
  --surface-2: #1d2430;
  --border: #2a3340;
  --text: #e6e9ee;
  --text-dim: #9aa4b2;
  --accent: #6d93ef;
  --accent-2: #3fc9a8;
  --danger: #ff6b64;
  --warn: #e0a53a;
  --ok: #3fc9a8;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: var(--surface);
  border-right: 1px solid var(--border); padding: 16px 12px;
}
.sidebar h1 { font-size: 15px; margin: 4px 8px 16px; }
.sidebar nav a {
  display: block; padding: 8px 10px; border-radius: var(--radius);
  color: var(--text); font-size: 13.5px; margin-bottom: 2px;
}
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.main { flex: 1; padding: 20px 24px 60px; max-width: 1400px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 18px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { font-family: var(--mono); font-size: 24px; font-weight: 600; }
.label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-ok, .badge-CONFIRMED_RESEARCH { background: rgba(14,124,102,.15); color: var(--ok); }
.badge-warn, .badge-CANDIDATE, .badge-REVIEW { background: rgba(161,92,0,.15); color: var(--warn); }
.badge-danger, .badge-INVALIDATED { background: rgba(179,38,30,.15); color: var(--danger); }
.badge-muted, .badge-EXPIRED, .badge-OTHER, .badge-SYSTEM, .badge-REVISED { background: var(--surface-2); color: var(--text-dim); }
.badge-DATA_UNAVAILABLE, .badge-ERROR { background: rgba(179,38,30,.15); color: var(--danger); }
.badge-NEVER_SYNCED { background: var(--surface-2); color: var(--text-dim); }
.badge-LONG { background: rgba(14,124,102,.15); color: var(--ok); }
.badge-SHORT { background: rgba(179,38,30,.15); color: var(--danger); }

.mono { font-family: var(--mono); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }

form.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
form.filters input, form.filters select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 9px; font-size: 13px;
}
button, .btn {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  padding: 7px 14px; font-size: 13px; cursor: pointer;
}
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.theme-toggle { background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; }

pre.payload { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; overflow-x: auto; font-size: 12px; max-height: 480px; overflow-y: auto; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 340px; }
.login-card input { width: 100%; margin-bottom: 10px; padding: 9px 10px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.error-text { color: var(--danger); font-size: 13px; margin-bottom: 8px; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; border-right: none; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 10px 12px; }
  .sidebar h1 { display: none; }
  .sidebar nav { display: flex; gap: 4px; }
  .sidebar nav a { white-space: nowrap; padding: 6px 10px; }
  .main { padding: 14px 14px 50px; }
}
