:root {
  --bg: #0b0e1a;
  --panel: #141a2e;
  --panel-2: #1a2138;
  --ink: #e9ecf6;
  --muted: #9aa3bd;
  --faint: #6b7390;
  --accent: #6c8cff;
  --accent-2: #8b6cff;
  --line: #262d47;
  --line-soft: #1e2440;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --ring: 0 0 0 3px rgba(108, 140, 255, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 600px at 78% -8%, rgba(108, 140, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(139, 108, 255, 0.08), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---- Header / footer ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 1rem 2rem;
  background: rgba(11, 14, 26, 0.72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px -6px rgba(108, 140, 255, 0.7);
}
.brand-mark svg { width: 20px; height: 20px; display: block; }
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.2px; }
.tagline { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.82rem; }

main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 2rem; flex: 1; }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.8rem;
  text-align: center;
  padding: 1.1rem 2rem;
}

.intro { color: var(--muted); margin: 0 0 1.3rem; max-width: 72ch; }
.intro strong { color: var(--ink); font-weight: 650; }

/* ---- Search form ---- */
.search {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: end;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.search-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; width: 100%; }
.zone-fieldset {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.1rem 1.1rem;
  margin: 0;
  background: rgba(0, 0, 0, 0.12);
}
.zone-fieldset legend {
  color: var(--accent);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  padding: 0 0.4rem;
}
.zone-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; margin-top: 0.6rem; }
.zone-row:first-of-type { margin-top: 0; }

.search label, .auth-form label {
  display: flex; flex-direction: column; gap: 0.4rem;
  color: var(--muted); font-size: 0.8rem; font-weight: 600;
}
.search input, .search select, .auth-form input {
  background: #0c1020;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  min-width: 210px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus, .search select:focus, .auth-form input:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}

/* ---- Buttons ---- */
button { font: inherit; cursor: pointer; border: 0; border-radius: var(--radius-sm); }
.search button[type="submit"], .auth-form button, .admin-actions button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  padding: 0.65rem 1.3rem;
  font-weight: 650;
  box-shadow: 0 8px 20px -10px rgba(108, 140, 255, 0.9);
  transition: transform 0.08s, filter 0.15s;
}
.search button[type="submit"]:hover, .auth-form button:hover, .admin-actions button:hover { filter: brightness(1.08); }
.search button[type="submit"]:active, .auth-form button:active { transform: translateY(1px); }

.htmx-indicator { opacity: 0; color: var(--muted); transition: opacity 0.2s; align-self: center; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---- Results meta + progress ---- */
.results-meta { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 1.6rem 0 0.8rem; color: var(--muted); }
.query-meta { color: var(--muted); }
.progress { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink); }
.prog-label { color: var(--muted); font-size: 0.85rem; }
.prog-bar {
  display: inline-block; width: 200px; height: 8px;
  background: #0c1020; border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden;
}
.prog-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.3s ease; }
.results-meta .cancel { margin-left: auto; }
.cancel { background: #2a2030; color: #ffb4b4; border: 1px solid #5a2a3a; padding: 0.45rem 0.9rem; }
.cancel:hover { filter: brightness(1.12); }

.filter-toggle { vertical-align: middle; accent-color: var(--accent); }
.filter { color: var(--muted); font-size: 0.85rem; cursor: pointer; margin-left: 0.3rem; }

/* ---- Table ---- */
table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
thead th {
  position: sticky; top: 70px;
  background: #11172b; color: var(--muted);
  font-weight: 650; font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase;
  text-align: left; padding: 0.7rem;
  border-bottom: 1px solid var(--line);
}
td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line-soft); }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(108, 140, 255, 0.06); }
tbody tr:last-child td { border-bottom: 0; }
td:nth-child(5) { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 0.12rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 650; border: 1px solid transparent; }
.badge-verified { background: rgba(54, 198, 146, 0.15); color: #6ee7b7; border-color: rgba(54, 198, 146, 0.4); }
.badge-probable { background: rgba(108, 140, 255, 0.15); color: #acc0ff; border-color: rgba(108, 140, 255, 0.4); }
.badge-catch_all { background: rgba(214, 158, 46, 0.15); color: #f0c47a; border-color: rgba(214, 158, 46, 0.4); }
.badge-unknown { background: rgba(120, 130, 160, 0.15); color: #b6bdd4; border-color: rgba(120, 130, 160, 0.35); }
.badge-invalid { background: rgba(214, 68, 68, 0.15); color: #ff9a9a; border-color: rgba(214, 68, 68, 0.4); }

/* ---- States / misc ---- */
.empty { color: var(--muted); padding: 1rem 0; }
.muted { color: var(--muted); font-style: italic; }
.unidentified td { color: var(--faint); }
#only-identified:checked ~ table .unidentified { display: none; }
code { background: #0c1020; padding: 0.1rem 0.4rem; border-radius: 6px; font-size: 0.85em; }

/* ---- Auth / admin ---- */
.auth-wrap { min-height: 52vh; display: grid; place-items: center; }
.auth-card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.8rem;
  max-width: 420px; width: 100%;
}
.auth-card.wide { max-width: 640px; }
.auth-card h2 { margin: 0 0 0.35rem; }
.auth-card .sub { color: var(--muted); margin: 0 0 1.2rem; font-size: 0.88rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form button { margin-top: 0.3rem; }
.auth-error {
  color: #ffb4b4; background: rgba(214, 68, 68, 0.12); border: 1px solid rgba(214, 68, 68, 0.4);
  border-radius: var(--radius-sm); padding: 0.55rem 0.8rem; margin: 0 0 1rem; font-size: 0.9rem;
}

.adminbar { display: flex; gap: 1rem; align-items: center; color: var(--muted); font-size: 0.88rem; margin-bottom: 1.3rem; }
.adminbar .spacer { flex: 1; }
.adminbar a { color: var(--accent); text-decoration: none; }
.adminbar a:hover { text-decoration: underline; }

.share-row { display: flex; gap: 0.5rem; }
.share-input {
  flex: 1; min-width: 0;
  background: #0c1020; border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: 0.6rem 0.7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem;
}
.copy-btn { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); padding: 0 1rem; }
.copy-btn:hover { border-color: var(--accent); }
.expiry { color: var(--muted); font-size: 0.85rem; margin: 0.85rem 0 0; }
.expiry b { color: var(--ink); font-weight: 650; }
.admin-actions { display: flex; gap: 0.75rem; margin-top: 1.3rem; }
.admin-actions form { margin: 0; }
.admin-actions .cancel { color: #ffb4b4; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  main { padding: 1.1rem; }
  .site-header { padding: 0.9rem 1.1rem; }
  .search input, .search select, .auth-form input { min-width: 0; width: 100%; }
  .search label { width: 100%; }
  thead th { top: 0; }
  table { font-size: 0.82rem; }
}
