:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e5e9;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warning: #b45309;
  --warning-soft: #fef3e1;
  --success: #15803d;
  --success-soft: #eafaf0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f26;
    --border: #2b2f38;
    --text: #e7e9ec;
    --text-muted: #9aa1ac;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: #262b45;
    --danger: #f87171;
    --danger-soft: #3a2222;
    --warning: #fbbf24;
    --warning-soft: #3a2f14;
    --success: #4ade80;
    --success-soft: #1c3326;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

/* Author rules setting `display` on a class (e.g. .auth-form { display: flex }) tie in specificity
   with the UA stylesheet's [hidden] rule and win by source order — breaking `hidden` on those
   elements. Force it to always win regardless of what else targets the same element. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

input, button, select {
  font-family: inherit;
  font-size: 0.88rem;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}

input:focus, button:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

button { cursor: pointer; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---- login/register page ---- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.auth-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth-card .brand-icon { font-size: 26px; }
.auth-card h1 { margin: 0; font-size: 1.2rem; }
.auth-card .tagline { color: var(--text-muted); font-size: 0.85rem; margin: 2px 0 22px; }

.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input { width: 100%; }

.auth-toggle { text-align: center; font-size: 0.82rem; color: var(--text-muted); margin: 16px 0 0; }
.auth-toggle a { color: var(--primary); cursor: pointer; }

/* ---- dashboard layout ---- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 26px; }
.brand h1 { margin: 0; font-size: 1.1rem; }

.account-bar { display: flex; align-items: center; gap: 12px; font-size: 0.82rem; color: var(--text-muted); }
#account-email { color: var(--text); font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px 60px;
  align-items: start;
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 24px;
}

.sidebar-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.profile-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

.profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.profile-card:hover { background: var(--bg); }
.profile-card.active { background: var(--primary-soft); border-color: var(--primary); }
.profile-card .name { font-weight: 600; font-size: 0.9rem; }
.profile-card .meta { color: var(--text-muted); font-size: 0.78rem; }

.add-profile-form { display: flex; flex-direction: column; gap: 8px; }
.add-profile-form input { width: 100%; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-icon { font-size: 2rem; display: block; margin-bottom: 8px; }

.content-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.content-header h2 { margin: 0; font-size: 1.3rem; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 9px 4px;
  margin-right: 20px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:focus { outline: none; box-shadow: none; }
.tab-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.activity-controls { display: flex; gap: 8px; margin-bottom: 14px; }
.activity-controls input { flex: 1; }
.activity-controls select { min-width: 160px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.stat-hint { font-size: 0.7rem; color: var(--text-muted); margin-top: 3px; opacity: 0.8; }

@media (max-width: 720px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-age { background: var(--primary-soft); color: var(--primary); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.card-title { margin: 0 0 4px; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.card-hint { color: var(--text-muted); font-size: 0.82rem; margin: 0 0 14px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.card-grid .card { margin-bottom: 0; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-block { background: var(--danger); }
.dot-redact { background: var(--warning); }
.dot-allow { background: var(--success); }

.threshold-header {
  display: grid;
  grid-template-columns: 90px 1fr 1fr;
  gap: 16px;
  padding: 0 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.threshold-list { display: flex; flex-direction: column; gap: 16px; }
.threshold-row { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 16px; align-items: start; }
.threshold-label { font-size: 0.85rem; font-weight: 600; text-transform: capitalize; padding-top: 5px; }
.threshold-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.slider-line { display: flex; align-items: center; gap: 8px; }
.slider-line input[type="range"] { flex: 1; min-width: 0; accent-color: var(--primary); }
.slider-line .value { min-width: 34px; font-variant-numeric: tabular-nums; color: var(--text); font-size: 0.82rem; text-align: right; }
.threshold-desc { font-size: 0.72rem; color: var(--text-muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; margin-bottom: 10px; }
.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip[data-kind="block"], .chip[data-kind="domain-block"] { background: var(--danger-soft); border-color: transparent; }
.chip[data-kind="redact"] { background: var(--warning-soft); border-color: transparent; }
.chip[data-kind="allow"], .chip[data-kind="domain-allow"] { background: var(--success-soft); border-color: transparent; }
.chip button { border: none; background: none; cursor: pointer; color: var(--text-muted); font-size: 0.95rem; line-height: 1; padding: 2px; }
.chip button:hover { color: var(--text); }

.add-row { display: flex; gap: 6px; }
.add-row input { flex: 1; }

/* ---- linking code card ---- */

.link-code-display {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--primary);
  text-align: center;
  padding: 16px;
  background: var(--primary-soft);
  border-radius: 8px;
  margin: 12px 0;
}
.link-code-timer { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }

/* ---- activity log ---- */

.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-row {
  display: grid;
  grid-template-columns: 140px auto auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
}
.log-time { color: var(--text-muted); white-space: nowrap; }
.log-action { padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; white-space: nowrap; }
.log-action.remove { background: var(--danger-soft); color: var(--danger); }
.log-action.blur { background: var(--warning-soft); color: var(--warning); }
.log-action.redact { background: var(--bg); color: var(--text-muted); }
.log-kind { color: var(--text-muted); font-size: 0.75rem; font-weight: 600; white-space: nowrap; border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.log-category { color: var(--text-muted); }
.log-empty { color: var(--text-muted); font-size: 0.85rem; padding: 8px 0; }

.status-line { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; padding: 4px 0; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot.ok { background: var(--success); }
.status-dot.fail { background: var(--danger); }
.status-dot.pending { background: var(--warning); }
.status-detail { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}
