/* ---------------- THEMES ---------------- */
/* Light is the default (no data-theme attribute). Dark is opt-in via [data-theme="dark"].
   The toggle button + a small no-FOUC script in base.html flip data-theme on <html>. */

:root {
  /* light */
  --bg:          #fafbfc;
  --bg-elev:     #ffffff;
  --bg-elev-2:   #f4f6f9;
  --border:      #e4e7ec;
  --text:        #111418;
  --text-muted:  #5e6772;
  --text-faint:  #9aa3b1;
  --accent:      #0ea271;
  --accent-ink:  #04140b;
  --accent-fade: rgba(14, 162, 113, 0.12);
  --danger:      #c73344;
  --danger-fade: rgba(199, 51, 68, 0.08);
  --shadow:      0 8px 24px rgba(15, 25, 40, 0.06), 0 2px 6px rgba(15, 25, 40, 0.04);
  --bg-glow:
    radial-gradient(900px 500px at 50% -10%, rgba(14, 162, 113, 0.05), transparent 60%);

  --radius:      10px;
  --radius-sm:   6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  --bg:          #0b0d10;
  --bg-elev:     #14171c;
  --bg-elev-2:   #1a1f26;
  --border:      #232a33;
  --text:        #e6eaf0;
  --text-muted:  #8b94a1;
  --text-faint:  #5b6573;
  --accent:      #7cffb2;
  --accent-ink:  #06120a;
  --accent-fade: rgba(124, 255, 178, 0.15);
  --danger:      #ff6b7a;
  --danger-fade: rgba(255, 107, 122, 0.12);
  --shadow:      0 12px 40px rgba(0, 0, 0, 0.45);
  --bg-glow:
    radial-gradient(1100px 600px at 50% -10%, rgba(124, 255, 178, 0.07), transparent 60%),
    radial-gradient(700px 400px at 50% 110%, rgba(124, 255, 178, 0.04), transparent 60%);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ---------------- THEME TOGGLE ---------------- */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 100;
  transition:
    background-color 0.25s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.12s ease,
    box-shadow 0.2s ease;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-faint);
  box-shadow: var(--shadow);
}
.theme-toggle:active { transform: scale(0.93); }
.theme-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-fade);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
  position: absolute;
  transition:
    transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease;
}
/* Show what you'd switch TO (moon in light, sun in dark) */
.theme-toggle .icon-sun  { opacity: 0; transform: rotate(90deg)  scale(0.5); }
.theme-toggle .icon-moon { opacity: 1; transform: rotate(0deg)   scale(1);   }
[data-theme="dark"] .theme-toggle .icon-sun  { opacity: 1; transform: rotate(0deg)   scale(1);   }
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.5); }

/* ---------------- AUTH PAGE ---------------- */
body.auth {
  display: grid;
  place-items: center;
  background: var(--bg-glow), var(--bg);
}
.auth-shell {
  width: 100%;
  max-width: 380px;
  padding: 24px;
}
.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.auth-head { text-align: center; margin-bottom: 24px; }
.brand-dot {
  display: inline-block;
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 6px var(--accent-fade);
  margin-bottom: 14px;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}
.auth-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.auth-sub {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}
.alert {
  background: var(--danger-fade);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.field input {
  width: 100%;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 14px;
  font-family: var(--sans);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.25s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-fade);
}
.field input[type="password"] {
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

button.primary {
  width: 100%;
  margin-top: 6px;
  padding: 11px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s, background-color 0.25s;
}
button.primary:hover { filter: brightness(1.06); }
button.primary:active { transform: translateY(1px); }

/* ---------------- LOGGED-IN SHELL ---------------- */
.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 28px 80px;
}
.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  transition: border-color 0.25s ease;
}
.top h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.muted { color: var(--text-muted); font-size: 13px; margin: 0; }
.topnav { display: flex; align-items: center; gap: 10px; }

a.ghost-link {
  text-decoration: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
}
a.ghost-link:hover { color: var(--text); border-color: var(--text-faint); }

button.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--sans);
}
button.ghost:hover { color: var(--text); border-color: var(--text-faint); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}
.placeholder {
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 64px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.placeholder p { margin: 0; }

/* ---------------- DATA TABLE ---------------- */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 12px 16px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
}
table.data td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data td.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 40px;
}
.mono { font-family: var(--mono); font-size: 12px; }
.ua-col { max-width: 240px; }
.ua {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

.pill {
  display: inline-block;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 500;
  letter-spacing: 0.02em;
  font-family: var(--mono);
}
.pill-ok   { background: var(--accent-fade); color: var(--accent); }
.pill-fail { background: var(--danger-fade); color: var(--danger); }

.row-fail .mono { color: var(--text-muted); }
