/* Dark palette is the base; light applies when the system asks for it (and
   the user hasn't forced dark) or when the user forces light. The signed-in
   shell sets data-theme from the profile preference. */
:root {
  --bg: #0e1116;
  --panel: #171c24;
  --border: #2a3240;
  --text: #e6e9ee;
  --muted: #8b95a5;
  --accent: #f0a020;
  --danger: #e05252;
  --ok: #4fb477;
  --btn-bg: #f0a020;
  --btn-fg: #14100a;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --border: #d7dce4;
    --text: #1a2230;
    --muted: #5c6675;
    --accent: #9a6200;
    --danger: #b83232;
    --ok: #2e7d54;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #d7dce4;
  --text: #1a2230;
  --muted: #5c6675;
  --accent: #9a6200;
  --danger: #b83232;
  --ok: #2e7d54;
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Centered single-purpose pages (home, login) */
.center-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1.2rem; padding: 0 16px; text-align: center;
}
.center-page h1 { font-size: 3rem; margin: 0; letter-spacing: 0.02em; }
.center-page form { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

input, select, button, textarea {
  font: inherit; color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 0.55rem 0.8rem;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
button { cursor: pointer; background: var(--btn-bg); color: var(--btn-fg); font-weight: 600; border: none; }
button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: 0.5; cursor: default; }

.msg { color: var(--muted); min-height: 1.5em; }
.msg.error { color: var(--danger); }

/* App shell */
nav {
  display: flex; gap: 1.2rem; align-items: center;
  padding: 0.8rem 1.2rem;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; flex-wrap: wrap;
}
nav .brand { font-weight: 700; color: var(--text); margin-right: 0.5rem; }
nav a { color: var(--muted); }
nav a.active, nav a:hover { color: var(--text); text-decoration: none; }
nav .spacer { flex: 1; }
main { max-width: 900px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
h2 { margin-top: 0; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 0.9rem;
}
.card h3 { margin: 0 0 0.3rem; }
.meta { color: var(--muted); font-size: 0.88rem; }
.badge {
  display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; border: 1px solid var(--border);
}
.badge.active { color: var(--accent); border-color: var(--accent); }
.badge.confirmed { color: var(--ok); border-color: var(--ok); }
.badge.false_positive, .badge.denied { color: var(--danger); border-color: var(--danger); }
.badge.expired { color: var(--muted); }
.score { font-variant-numeric: tabular-nums; font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

.post {
  border-left: 3px solid var(--border);
  padding: 0.6rem 0.9rem; margin: 0.7rem 0;
  background: var(--bg); border-radius: 0 8px 8px 0;
  white-space: pre-wrap; word-break: break-word;
}
/* Active-alert banners across the top of the landing page */
.alert-banner {
  display: flex; align-items: center; gap: 0.9rem;
  background: linear-gradient(90deg, rgba(224,82,82,0.18), rgba(224,82,82,0.04));
  border: 1px solid var(--danger); border-left-width: 5px;
  border-radius: 10px; padding: 0.9rem 1.1rem; margin-bottom: 0.7rem;
  color: var(--text); text-decoration: none;
}
.alert-banner:hover { text-decoration: none; background: linear-gradient(90deg, rgba(224,82,82,0.28), rgba(224,82,82,0.08)); }
.ab-pulse {
  width: 12px; height: 12px; border-radius: 50%; background: var(--danger);
  flex-shrink: 0; box-shadow: 0 0 0 0 rgba(224,82,82,0.7); animation: ab-pulse 1.8s infinite;
}
@keyframes ab-pulse {
  0% { box-shadow: 0 0 0 0 rgba(224,82,82,0.6); }
  70% { box-shadow: 0 0 0 12px rgba(224,82,82,0); }
  100% { box-shadow: 0 0 0 0 rgba(224,82,82,0); }
}
.ab-body { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.ab-title { font-weight: 700; font-size: 1.05rem; }
.ab-meta { color: var(--muted); font-size: 0.88rem; }
.ab-arrow { font-size: 1.8rem; color: var(--danger); line-height: 1; }
.all-clear {
  background: var(--panel); border: 1px solid var(--border); border-left: 5px solid var(--ok);
  border-radius: 10px; padding: 0.9rem 1.1rem; margin-bottom: 0.7rem; color: var(--muted);
}
/* Leaflet popups follow the light tiles regardless of app theme */
.leaflet-popup-content { color: #1a2230; }

.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
label.inline { display: flex; gap: 0.5rem; align-items: center; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.validation { border-top: 1px solid var(--border); margin-top: 0.8rem; padding-top: 0.6rem; }
.assist-box { background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; padding: 0.6rem; margin-top: 0.5rem; }
.diff-old { background: rgba(224,82,82,0.12); border-left: 3px solid var(--danger); padding: 0.4rem 0.6rem; white-space: pre-wrap; border-radius: 0 6px 6px 0; font-size: 0.85rem; }
.diff-new { background: rgba(79,180,119,0.12); border-left: 3px solid var(--ok); padding: 0.4rem 0.6rem; white-space: pre-wrap; border-radius: 0 6px 6px 0; font-size: 0.85rem; margin-top: 0.3rem; }
