:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1d21;
  --text-dim: #5c6470;
  --border: #dfe3e8;
  --accent: #3b6fe0;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --danger-text: #ffffff;
  --flash-success-bg: #e3f6e8;
  --flash-success-text: #1e6b34;
  --flash-error-bg: #fbe6e4;
  --flash-error-text: #a4261a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1d2025;
    --text: #e8eaed;
    --text-dim: #9aa1ab;
    --border: #2c3036;
    --accent: #6d93ec;
    --accent-text: #0b0f16;
    --danger: #e0574a;
    --danger-text: #0b0f16;
    --flash-success-bg: #163821;
    --flash-success-text: #7fe6a1;
    --flash-error-bg: #3a1f1c;
    --flash-error-text: #f2a79c;
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1d2025;
  --text: #e8eaed;
  --text-dim: #9aa1ab;
  --border: #2c3036;
  --accent: #6d93ec;
  --accent-text: #0b0f16;
  --danger: #e0574a;
  --danger-text: #0b0f16;
  --flash-success-bg: #163821;
  --flash-success-text: #7fe6a1;
  --flash-error-bg: #3a1f1c;
  --flash-error-text: #f2a79c;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-right a { color: var(--text-dim); text-decoration: none; }
.topbar-right a:hover { color: var(--text); }

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  font-size: 1rem;
}

.admin-name { color: var(--text-dim); font-size: 0.9rem; }

.content {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

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

a { color: var(--accent); }

.list-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.list-table th, .list-table td {
  padding: 0.6rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.list-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.list-table tr:last-child td { border-bottom: none; }

.row-actions { display: flex; gap: 0.5rem; }

.alias-table .arrow { color: var(--text-dim); text-align: center; }

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

input[type="text"], input[type="email"], input[type="password"], input[type="search"] {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

#search-box { width: 100%; margin: 1rem 0; }

button {
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  font-weight: 500;
}

button:hover { filter: brightness(1.08); }

.btn-danger { background: var(--danger); color: var(--danger-text); }

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 0.75rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.flashes { margin-bottom: 1rem; }

.flash {
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.flash-success { background: var(--flash-success-bg); color: var(--flash-success-text); }
.flash-error { background: var(--flash-error-bg); color: var(--flash-error-text); }

.login-box {
  max-width: 320px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
}

.login-box form { display: flex; flex-direction: column; gap: 1rem; }
.login-box label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--text-dim); }
