:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e2e4e8;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --card-bg: #1a1d23;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #2b2f38;
    --success-bg: #14291d;
    --success-text: #86efac;
    --error-bg: #2a1416;
    --error-text: #fca5a5;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin: 0 auto 20px;
}

.login-card {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 { margin: 0 0 4px; font-size: 20px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input, select {
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

button {
  font-size: 14px;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button.danger { background: var(--danger); }
button.link-button { background: none; color: var(--muted); text-decoration: underline; padding: 0; }

.dashboard { max-width: 900px; margin: 0 auto; padding: 24px 16px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.topbar h1 { font-size: 18px; margin: 0; }

.domain-select { margin-bottom: 20px; }

table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.inline-form { display: inline; }

.add-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.input-group { display: flex; align-items: center; gap: 6px; }

.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; flex-basis: 100%; }

.flash { padding: 10px 12px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }
.flash-password { background: var(--success-bg); color: var(--success-text); }
.flash-password code { font-size: 13px; }

.empty { color: var(--muted); }

.topnav { display: flex; gap: 14px; }
.topnav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topnav a.active { color: var(--text); font-weight: 600; }

.public-card { width: 420px; }
.public-card a { color: var(--accent); }

.selfserve-form { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.checkbox-line { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.checkbox-line input { width: auto; }

.client { margin-bottom: 18px; }
.client h3 { margin: 0 0 6px; font-size: 14px; }
.client ol { margin: 0; padding-left: 20px; font-size: 14px; }
code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 13px; }

.filter-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.csv-link { color: var(--accent); text-decoration: none; font-size: 14px; padding-bottom: 8px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge-ok { background: var(--success-bg); color: var(--success-text); }
.badge-warn { background: var(--error-bg); color: var(--error-text); opacity: 0.75; }
.badge-bad { background: var(--error-bg); color: var(--error-text); }

.muted-row td { color: var(--muted); }

.public {
  --accent: #017bbe;
  --accent-dark: #015f94;
}

.public .brand-logo { display: block; width: 84px; height: 84px; margin: 0 auto 10px; }
.public .brand-logo-wide { display: block; height: 60px; width: auto; margin: 0 0 12px; }
.public-topbar { flex-direction: column; align-items: flex-start; gap: 4px; }

button:hover:not(:disabled) { background: var(--accent-dark); }

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button.is-loading { opacity: 0.75; cursor: progress; }
button.is-loading::after {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
