:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --border: #dde1ea;
  --text: #1a1d29;
  --text-dim: #5c6478;
  --accent: #3b5fc4;
  --ok: #1f9d68;
  --warn: #b4790a;
  --bad: #c93b24;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;
    --surface: #171a23;
    --border: #262b38;
    --text: #e7e9ee;
    --text-dim: #9aa1b2;
    --accent: #5b8cff;
    --ok: #3ecf8e;
    --warn: #e8b93a;
    --bad: #e8543a;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a23;
  --border: #262b38;
  --text: #e7e9ee;
  --text-dim: #9aa1b2;
  --accent: #5b8cff;
  --ok: #3ecf8e;
  --warn: #e8b93a;
  --bad: #e8543a;
}

* { box-sizing: border-box; }

:root { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 400;
}
.theme-toggle:hover { color: var(--text); }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a { color: var(--text-dim); text-decoration: none; font-size: 0.95rem; }
.topbar nav a:hover { color: var(--text); }

.logout-form button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.content { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }

h1 { font-size: 1.5rem; margin-bottom: 20px; }
h2 { font-size: 1.1rem; margin-top: 32px; color: var(--text-dim); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--text-dim); font-size: 0.85rem; }

.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; overflow-x: auto; display: block; }
.data-table thead, .data-table tbody { display: table; width: 100%; table-layout: fixed; }
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.data-table th { color: var(--text-dim); font-weight: 600; }
.data-table a { color: var(--accent); }

.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.82rem; color: var(--text-dim); }

.badge { padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge-ok { background: rgba(62, 207, 142, 0.15); color: var(--ok); }
.badge-warn { background: rgba(232, 185, 58, 0.15); color: var(--warn); }
.badge-bad { background: rgba(232, 84, 58, 0.15); color: var(--bad); }

.inline-form { display: flex; gap: 8px; margin: 16px 0; }
.inline-form input { flex: 1; max-width: 320px; }

input[type="text"], input[type="password"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 6px;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
button.danger { background: var(--bad); }

.callout { border-radius: 8px; padding: 14px 18px; margin-bottom: 12px; }
.callout-warn { background: rgba(232, 185, 58, 0.12); border: 1px solid rgba(232, 185, 58, 0.4); }
.key-reveal { font-family: monospace; font-size: 0.95rem; margin-top: 8px; word-break: break-all; }

.error { color: var(--bad); font-size: 0.85rem; margin: 8px 0; }

form label { font-size: 0.85rem; color: var(--text-dim); margin-top: 4px; }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-card h1 { margin: 0; font-size: 1.3rem; }
.login-card .error { color: var(--bad); font-size: 0.85rem; margin: 0; }

.login-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.login-card-header .theme-toggle { padding: 4px 8px; font-size: 0.8rem; }
