:root {
  --bg: #0b0d12;
  --panel: #151821;
  --panel-2: #1b1f2a;
  --border: #262b38;
  --text: #e8e9ec;
  --text-dim: #9aa0ac;
  --accent: #6ea8fe;
  --green: #34d399;
  --green-bg: #0f3d2a;
  --red: #f87171;
  --red-bg: #3d1414;
  --amber: #fbbf24;
  --amber-bg: #3d2f10;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

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

h1, h2, h3 {
  margin: 0;
}

/* ---------- Top bar / filters ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, #11141c 0%, #0e1016 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.4rem 1.75rem 1.15rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.topbar-title h1 {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.topbar-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.logout-link {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
}

.logout-link:hover {
  color: var(--text);
  border-color: var(--accent);
}

.generated-at {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 0.2rem 0 1rem;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.filter-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.8rem;
  text-decoration: none;
  transition: all 0.12s ease;
}

.pill:hover {
  border-color: var(--accent);
  color: var(--text);
}

.pill-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d12;
  font-weight: 600;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.filter-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-row input,
.filter-row select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
}

.filter-row input:focus,
.filter-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-row button {
  background: var(--accent);
  color: #0b0d12;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  align-self: end;
}

.filter-row button:hover {
  filter: brightness(1.08);
}

.reset-link {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-decoration: none;
  align-self: center;
  padding-bottom: 0.55rem;
}

.reset-link:hover {
  color: var(--text);
}

.filter-hint {
  color: var(--text-dim);
  font-size: 0.72rem;
  margin: 0;
}

/* ---------- Filters toggle (plain CSS checkbox pattern, not <details> -
   <details>'s hide/show is implemented via an internal shadow-root slot
   in modern browsers, which author CSS cannot override by specificity.
   A checkbox + sibling selector keeps this fully in our control:
   always open on desktop (default), collapsed-by-default on mobile
   (see media query below). ---------- */

.filters-checkbox {
  display: none;
}

.filters-summary {
  display: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.4rem 0;
}

.filters-summary::before {
  content: "▸ ";
  color: var(--text-dim);
}

.filters-checkbox:checked ~ .filters-summary::before {
  content: "▾ ";
}

.filters-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ---------- Site cards ---------- */

.sites {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 1.5rem;
  padding: 1.75rem;
  max-width: 1500px;
  margin: 0 auto;
}

.site-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.5rem 1.65rem;
  border: 1px solid var(--border);
  border-top: 3px solid var(--green);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

.site-card.offline {
  border-top-color: var(--red);
}

.site-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-card-header h2 {
  font-size: 1.15rem;
}

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-online {
  background: var(--green-bg);
  color: var(--green);
}

.badge-offline {
  background: var(--red-bg);
  color: var(--red);
}

.badge-stale {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge-state {
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.meta {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin: 0.4rem 0;
}

.error {
  color: var(--red);
  font-size: 0.82rem;
  background: var(--red-bg);
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
}

.stats {
  display: flex;
  gap: 1.75rem;
  margin: 0.9rem 0 1.1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Collapsible sections ---------- */

.collapsible {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.collapsible summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  list-style: none;
}

.collapsible summary::-webkit-details-marker {
  display: none;
}

.collapsible summary::before {
  content: "▸";
  color: var(--text-dim);
  font-size: 0.7rem;
}

.collapsible[open] summary::before {
  content: "▾";
}

.summary-count {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 400;
}

/* ---------- Tables ---------- */

.table-wrap {
  max-height: 420px;
  overflow-y: auto;
  overflow-x: auto;
  margin-top: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  text-align: left;
  padding: 0.5rem 0.6rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

tbody tr:hover {
  background: rgba(110, 168, 254, 0.06);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Pagination ---------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.6rem;
  padding-top: 0.1rem;
}

.pager-link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.pager-link:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}

.pager-disabled {
  color: var(--text-dim);
  opacity: 0.4;
  pointer-events: none;
}

.pager-status {
  font-size: 0.74rem;
  color: var(--text-dim);
}

/* ---------- Login page ---------- */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.035) 1px, transparent 0) 0 0/26px 26px,
    var(--bg);
}

.login-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

.login-glow-a {
  width: 640px;
  height: 640px;
  background: radial-gradient(circle, rgba(110, 168, 254, 0.22), transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
}

.login-glow-b {
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.13), transparent 70%);
  bottom: -8%;
  right: -8%;
}

.corner {
  position: fixed;
  width: 30px;
  height: 30px;
  border: 2px solid rgba(110, 168, 254, 0.3);
  z-index: 1;
  pointer-events: none;
}

.corner-tl {
  top: 28px;
  left: 28px;
  border-right: none;
  border-bottom: none;
}

.corner-tr {
  top: 28px;
  right: 28px;
  border-left: none;
  border-bottom: none;
}

.corner-bl {
  bottom: 28px;
  left: 28px;
  border-right: none;
  border-top: none;
}

.corner-br {
  bottom: 28px;
  right: 28px;
  border-left: none;
  border-top: none;
}

.login-particle {
  position: fixed;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  box-shadow: 0 0 8px 2px rgba(110, 168, 254, 0.4);
  pointer-events: none;
  z-index: 0;
  animation: loginDrift 17s ease-in-out infinite;
}

.p1 {
  top: 18%;
  left: 22%;
  animation-duration: 16s;
}

.p2 {
  top: 72%;
  left: 14%;
  animation-duration: 19s;
  animation-delay: -4s;
}

.p3 {
  top: 24%;
  left: 80%;
  animation-duration: 17s;
  animation-delay: -8s;
}

.p4 {
  top: 76%;
  left: 84%;
  animation-duration: 21s;
  animation-delay: -2s;
}

@keyframes loginDrift {
  0%, 100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(18px, -22px);
  }
}

.login-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.15rem;
}

.login-status-badge {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: "Outfit", inherit;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  background: rgba(21, 24, 33, 0.7);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.42rem 0.95rem;
  backdrop-filter: blur(6px);
}

.login-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px 1px rgba(52, 211, 153, 0.6);
  animation: loginDotPulse 2.2s ease-in-out infinite;
}

@keyframes loginDotPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.login-footer {
  font-family: "Outfit", inherit;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  opacity: 0.7;
  text-align: center;
  margin: 0;
}

@keyframes loginCardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-card {
  position: relative;
  z-index: 1;
  background: rgba(21, 24, 33, 0.88);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2.25rem 2.25rem;
  width: 100%;
  max-width: 380px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 24px 70px -24px rgba(0, 0, 0, 0.75);
  animation: loginCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes markPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(110, 168, 254, 0.45);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(110, 168, 254, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(110, 168, 254, 0);
  }
}

.login-mark {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  margin: 0 auto 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #4d76c9);
  color: #0b0d12;
  animation: markPulse 2.6s ease-out infinite;
}

.login-title {
  font-family: "Outfit", var(--font-display, inherit);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
  background: linear-gradient(135deg, #ffffff 30%, var(--accent) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  color: var(--text-dim);
  font-size: 0.84rem;
  text-align: center;
  margin: 0 0 1.85rem;
  line-height: 1.5;
}

.login-error {
  background: var(--red-bg);
  color: var(--red);
  font-size: 0.82rem;
  padding: 0.6rem 0.8rem;
  border-radius: 9px;
  margin: 0 0 1.2rem;
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-icon {
  position: absolute;
  left: 0.9rem;
  color: var(--text-dim);
  pointer-events: none;
}

.login-field input {
  width: 100%;
  background: rgba(11, 13, 18, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.68rem 0.85rem 0.68rem 2.6rem;
  font-size: 0.92rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-field input::placeholder {
  color: var(--text-dim);
  opacity: 0.55;
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.16);
}

.login-button {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #5b8ee8);
  color: #0b0d12;
  border: none;
  border-radius: 10px;
  padding: 0.75rem;
  font-weight: 700;
  font-size: 0.94rem;
  cursor: pointer;
  margin-top: 0.4rem;
  box-shadow: 0 6px 18px -6px rgba(110, 168, 254, 0.55);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.login-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -6px rgba(110, 168, 254, 0.7);
  filter: brightness(1.05);
}

.login-button:active {
  transform: translateY(0);
}

/* ---------- Mobile (desktop layout above is untouched - .filters-body
   defaults to display:flex unconditionally, only hidden below) ---------- */

@media (max-width: 720px) {
  body.login-page {
    padding: 1.25rem;
  }

  .corner,
  .login-particle {
    display: none;
  }

  .login-status-badge {
    font-size: 0.6rem;
    text-align: center;
    padding: 0.4rem 0.7rem;
  }

  .topbar {
    padding: 0.85rem 1rem;
  }

  .filters-toggle {
    border-top: 1px solid var(--border);
    margin-top: 0.6rem;
    padding-top: 0.5rem;
  }

  .filters-summary {
    display: block;
  }

  .filters-body {
    display: none;
  }

  .filters-checkbox:checked ~ .filters-body {
    display: flex;
  }

  .topbar-title h1 {
    font-size: 1.2rem;
  }

  .generated-at {
    margin: 0.2rem 0 0.85rem;
  }

  .filter-row {
    gap: 0.6rem;
  }

  .filter-row label {
    flex: 1 1 45%;
    min-width: 130px;
  }

  .filter-row input,
  .filter-row select {
    width: 100%;
  }

  .filter-row button,
  .reset-link {
    flex: 1 1 100%;
  }

  .filter-row button {
    width: 100%;
  }

  .sites {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
  }

  .site-card {
    padding: 1.1rem 1.1rem;
  }

  .site-card-header h2 {
    font-size: 1.05rem;
  }

  .stats {
    gap: 1.1rem;
    flex-wrap: wrap;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  table {
    font-size: 0.76rem;
  }

  thead th,
  tbody td {
    padding: 0.4rem 0.5rem;
  }
}
