:root {
  --bg: #0f172a;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--surface-2);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--bg);
  color: #fff;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.2px; }
.topbar nav a { color: #cbd5e1; margin-left: 1.25rem; font-size: 0.92rem; }
.topbar nav a:hover, .topbar nav a.active { color: #fff; text-decoration: none; }
.topbar .user { color: #94a3b8; font-size: 0.85rem; }

.container { max-width: 1080px; margin: 2rem auto; padding: 0 1.5rem; }
.narrow { max-width: 460px; }

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 0.75rem; }
.subtitle { color: var(--muted); margin: 0 0 1.5rem; }

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

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; color: #334155; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.field { margin-bottom: 1rem; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-hover); }
.btn.sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: var(--surface-2); }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.74rem; font-weight: 700; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.off { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #e2e8f0; color: #475569; }

.alert { padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.matrix td.tool { font-weight: 600; }
.matrix .cat { background: var(--surface-2); font-weight: 700; }
.toggle { display: flex; align-items: center; gap: 0.4rem; }

.row-actions { display: flex; gap: 0.5rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
code.token { display: block; background: #0f172a; color: #e2e8f0; padding: 0.75rem; border-radius: 8px; word-break: break-all; margin: 0.5rem 0; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.consent-scopes { list-style: none; padding: 0; margin: 1rem 0; }
.consent-scopes li { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.5rem; background: var(--surface-2); }
