:root {
  --bg: #0f1419;
  --surface: #1a2029;
  --surface-2: #232b36;
  --border: #2e3947;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #38bdf8;
  --accent-2: #34d399;
  --danger: #f87171;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

.hidden { display: none !important; }

/* ---------- Auth ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: radial-gradient(circle at 30% 20%, #16202b, var(--bg));
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.logo, .brand { font-size: 1.8rem; font-weight: 800; letter-spacing: -.5px; }
.logo span, .brand span { color: var(--accent); }
.tagline { color: var(--muted); margin: .2rem 0 1.5rem; font-size: .9rem; }
.auth-form h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.auth-form label, .modal-form label {
  display: block;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: .9rem;
}
.auth-form input, .modal-form input, .modal-form textarea, .modal-form select {
  display: block;
  width: 100%;
  margin-top: .3rem;
  padding: .6rem .7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
.modal-form textarea { min-height: 140px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.hint { font-size: .8rem; color: var(--muted); margin: -.3rem 0 1rem; }
.form-msg { font-size: .85rem; color: var(--danger); min-height: 1.1em; margin: .5rem 0 0; }
.form-msg.ok { color: var(--accent-2); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: .5rem .9rem;
  border-radius: 8px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #2b3543; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06222e; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; font-size: 1.2rem; padding: .3rem .6rem; }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger:hover { background: rgba(248,113,113,.12); }
.btn.small { padding: .3rem .6rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.brand { font-size: 1.3rem; }
.tabs { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  padding: .5rem .8rem;
  border-radius: 8px;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.user-menu { position: relative; display: flex; align-items: center; gap: .5rem; }
.whoami { color: var(--muted); font-size: .85rem; }
.dropdown {
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 200px;
  overflow: hidden;
  z-index: 30;
}
.dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  padding: .6rem .9rem;
  cursor: pointer;
}
.dropdown button:hover { background: #2b3543; }

/* ---------- Content ---------- */
.content { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }
.toolbar {
  display: flex;
  gap: .6rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
  align-items: center;
}
.view-title { margin: 0; flex: 1; font-size: 1.2rem; }
.search {
  flex: 1;
  min-width: 180px;
  padding: .55rem .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
.filter {
  padding: .55rem .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.card h3 { margin: 0; font-size: 1.05rem; word-break: break-word; }
.card .body { color: var(--text); font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.card .meta { color: var(--muted); font-size: .8rem; word-break: break-word; }
.card a.linkurl { color: var(--accent); text-decoration: none; font-size: .85rem; word-break: break-all; }
.card a.linkurl:hover { text-decoration: underline; }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.badge {
  font-size: .72rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.wcag { background: rgba(56,189,248,.14); color: #7dd3fc; border-color: rgba(56,189,248,.3); }
.badge.lvl { background: rgba(52,211,153,.14); color: #6ee7b7; border-color: rgba(52,211,153,.3); }
.badge.axe { background: rgba(167,139,250,.14); color: #c4b5fd; border-color: rgba(167,139,250,.3); }
.card-actions { display: flex; gap: .3rem; margin-top: auto; padding-top: .4rem; flex-wrap: wrap; }
.card-actions .spacer { flex: 1; }
.empty { color: var(--muted); text-align: center; padding: 3rem 1rem; }

/* ---------- Users table ---------- */
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td {
  text-align: left;
  padding: .7rem .6rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.users-table th { color: var(--muted); font-weight: 600; }
.role-pill { font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: grid;
  place-items: center;
  padding: 1.2rem;
  z-index: 50;
}
.modal-box {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
}
.modal-box h2 { margin: 0 0 1.2rem; }
.modal-close {
  position: absolute;
  top: .8rem; right: 1rem;
  background: none; border: none;
  color: var(--muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}
.modal-form .row { display: flex; gap: .8rem; }
.modal-form .row > label { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-2);
  color: #062b1e;
  padding: .7rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 60;
}
.toast.err { background: var(--danger); color: #3b0a0a; }

@media (max-width: 600px) {
  .modal-form .row { flex-direction: column; gap: 0; }
  .whoami { display: none; }
}
