:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1b1f23;
  --muted: #5f6b76;
  --line: #dde3e9;
  --brand: #0f766e;
  --brand-dark: #0b5d57;
  --yellow-bg: #fff8db; --yellow-fg: #7a5a00; --yellow-line: #f5d76e;
  --orange-bg: #fff1e6; --orange-fg: #9a3f00; --orange-line: #f7b27a;
  --red-bg: #fde8e8; --red-fg: #9b1c1c; --red-line: #f2a0a0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111518; --surface: #1a2024; --text: #e6e9ec; --muted: #98a4ae; --line: #2c353c;
    --brand: #2dd4bf; --brand-dark: #14b8a6;
    --yellow-bg: #3a3100; --yellow-fg: #ffe28a; --yellow-line: #7a6a1a;
    --orange-bg: #3d2000; --orange-fg: #ffc08a; --orange-line: #8a4a1a;
    --red-bg: #3d1212; --red-fg: #ffb3b3; --red-line: #8a2a2a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
h1, h2 { margin: 0; font-weight: 650; }
code { background: var(--line); padding: 1px 6px; border-radius: 4px; font-size: 0.92em; }
.muted { color: var(--muted); margin: 0; font-size: 0.9em; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 14px; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; width: 100%; padding: 11px; }
button.primary:not(:disabled):hover { background: var(--brand-dark); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--line); }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Login */
.login-body { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand img { border-radius: 10px; }
.brand h1 { font-size: 1.35rem; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.9em; }
.brand.small { margin: 0; gap: 10px; }
label { display: block; font-size: 0.9em; margin-bottom: 6px; color: var(--muted); }
.pw-row { display: flex; gap: 8px; margin-bottom: 14px; }
.pw-row input { flex: 1; min-width: 0; }
.pw-row button { padding: 8px 12px; }
.alert { margin-top: 16px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 0.93em; }
.alert.yellow { background: var(--yellow-bg); color: var(--yellow-fg); border-color: var(--yellow-line); }
.alert.orange { background: var(--orange-bg); color: var(--orange-fg); border-color: var(--orange-line); }
.alert.red { background: var(--red-bg); color: var(--red-fg); border-color: var(--red-line); }
.countdown { margin-top: 12px; display: flex; align-items: baseline; justify-content: center; gap: 10px; color: var(--red-fg); }
.countdown strong { font-size: 2rem; font-variant-numeric: tabular-nums; }

/* Dashboard */
.topbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
.tabs button { white-space: nowrap; padding: 6px 12px; border-color: transparent; }
.tabs button.active { background: var(--brand); color: #fff; }
.topbar-actions { display: flex; gap: 6px; margin-left: auto; }
.content { padding: 16px; max-width: 1400px; margin: 0 auto; }
.empty { text-align: center; padding: 60px 16px; color: var(--muted); }
.ds-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ds-head h2 { font-size: 1.3rem; }
.search-row { display: flex; gap: 8px; }
.search-row input { min-width: 220px; }
.warn { background: var(--orange-bg); color: var(--orange-fg); border: 1px solid var(--orange-line); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 0.92em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.card-label { color: var(--muted); font-size: 0.85em; }
.card-value { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.card-sub { color: var(--muted); font-size: 0.8em; }
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 600px; font-size: 0.93em; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); cursor: pointer; user-select: none; font-weight: 600; color: var(--muted); }
th.sorted { color: var(--brand); }
th.sorted.asc::after { content: " ▲"; font-size: 0.7em; }
th.sorted.desc::after { content: " ▼"; font-size: 0.7em; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--bg); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 14px 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 0.9em; }
@media (max-width: 600px) {
  .content { padding: 10px; }
  .search-row { width: 100%; }
  .search-row input { flex: 1; min-width: 0; }
}
