:root {
  --bg: #f7fafc;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --ok: #4fc898;   /* brand green */
  --warn: #f38b09; /* brand orange */
  --bad: #dc2626;
  --accent: #2563eb; /* neutral primary accent */
  --border: #e5e7eb;
  --bg-grad: radial-gradient(1200px 600px at 20% -10%, #ffffff 0%, #f7fafc 60%, #f3f4f6 100%);
}

/* Dark theme overrides (support both body.dark and html[data-theme="dark"]) */
body.dark, html[data-theme="dark"] body, html[data-theme="dark"] {
  --bg: #0f172a;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --bad: #ef4444;
  --accent: #6366f1;
  --border: #1f2937;
  --bg-grad: radial-gradient(1200px 600px at 20% -10%, #1b2548 0%, #0f172a 60%, #0b1020 100%);
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; padding: 32px; font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  min-height: 100vh;
  background: var(--bg-grad) no-repeat fixed;
  background-size: cover;
  background-color: var(--bg);
  color: var(--text);
}

.container { max-width: 980px; margin: 0 auto; }
.topbar { display:flex; align-items:center; justify-content: space-between; gap:12px; }
.brand { display:flex; align-items:center; gap:12px; }
.brand-link { display:inline-flex; align-items:center; text-decoration:none; color: inherit; gap: 10px; }
.logo { height: 36px; width: auto; display:block; }
.logo-dark { display:none; }
html[data-theme="dark"] .logo-light, body.dark .logo-light { display:none; }
html[data-theme="dark"] .logo-dark, body.dark .logo-dark { display:block; }

h1 { font-weight: 700; margin: 0; font-size: 26px; letter-spacing: .2px; }
.subtitle { color: var(--muted); margin: 6px 0 18px; }
.content { margin-top: 40px; }

.search-bar {
  background: var(--panel);
  border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 8px 24px rgba(15,23,42,.06), inset 0 1px 0 rgba(255,255,255,.6);
}
.search-icon { opacity: .6; }
.search-input {
  flex: 1; background: transparent; border: 0; outline: none; color: var(--text);
  font-size: 20px; letter-spacing: .2px;
  min-width: 0; /* prevent flex overflow in Safari/Firefox */
}

/* Normalize form controls inside search bars to avoid native styles */
.search-bar input,
.search-bar select,
.search-bar button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font: inherit;
  color: inherit;
}
.search-bar button { background: none; }
.search-bar select { background-color: transparent; }

/* Buttons for search actions */
.btn {
  display:inline-flex; align-items:center; gap:8px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: 13px;
  line-height: 1.2;
  -webkit-appearance: none;
  appearance: none;
}
 .btn-primary {
  background: var(--accent); color: #fff; border-color: transparent;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* Menu grid (tool shortcuts) */
.menu-grid { display:grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.menu-item { background: var(--panel); border:1px solid var(--border); border-radius: 12px; padding: 12px; text-decoration:none; color: var(--text); display:flex; align-items:center; justify-content:space-between; transition: box-shadow .15s ease, transform .02s ease; }
.menu-item:hover { box-shadow: 0 8px 24px rgba(15,23,42,.08); }
.menu-item .label { font-weight: 600; }
.menu-item .arrow { color: var(--muted); }

/* Cards + tables (report) */
.card { background: var(--panel); border:1px solid var(--border); border-radius: 12px; padding: 12px; }
.category-card { margin-top: 18px; }
table.report { width: 100%; border-collapse: collapse; }
.report th, .report td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.report thead th { color: var(--muted); font-weight: 600; }
.status-pass { color: var(--ok); font-weight: 700; }
.status-warn { color: var(--warn); font-weight: 700; }
.status-fail { color: var(--bad); font-weight: 700; }
.status-info { color: var(--muted); font-weight: 700; }

/* Prevent long values from spilling out of table cells */
.report td .cell-info {
  overflow: hidden;
  overflow-wrap: anywhere; /* break long tokens */
  word-break: break-word;
  hyphens: auto;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Theme toggle switch */
.toggle {
  display:inline-flex; align-items:center; gap:8px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; cursor: pointer; font-weight: 600; font-size: 13px;
}

/* Brand tag next to logo */
.brand-tag {
  display:inline-flex; align-items:center; gap:6px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; font-weight: 600; font-size: 13px;
}

/* Terminal-like output */
.terminal {
  background: #0b1020;
  color: #e5e7eb;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 12px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  overflow: auto;
  max-height: 320px;
}

@media (max-width: 860px) {
  .menu-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  body { padding: 18px; }
  /* Two items per row on small screens */
  .menu-grid { grid-template-columns: repeat(2, 1fr); }

  /* Mobile: simplify top bar layout and center logo */
  .topbar { justify-content: center; gap: 8px; }
  .brand { flex: 1 1 100%; justify-content: center; flex-wrap: wrap; gap: 8px; }
  .brand-link { flex: 0 0 100%; justify-content: center; }
  .brand-tag { margin-top: 4px; }

  /* Mobile: float theme toggle to bottom-right to avoid layout breakage */
  #theme-toggle.toggle {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1000;
    box-shadow: 0 6px 18px rgba(15,23,42,.18);
  }

  /* Mobile: tighten blacklist tables and hide the reason column */
  .rbl-table { font-size: 13px; }
  .rbl-table th, .rbl-table td { padding: 8px 6px; }
  .rbl-table th:nth-child(3),
  .rbl-table td:nth-child(3) { display: none; }
  /* Allow long zone names to wrap on small screens */
  .rbl-table td:first-child, .rbl-table th:first-child { overflow-wrap: anywhere; word-break: break-word; }
  /* Slightly smaller category headings on mobile */
  .category-card h3 { font-size: 16px; }
}

/* Zones list readable layout */
.zones-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 14px;
  max-height: 240px;
  overflow: auto;
}
.zones-list li { overflow-wrap: anywhere; }
@media (max-width: 860px) { .zones-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .zones-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Inline status under search bar (e.g. blacklist loading) */
.search-status {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}
.search-status.active { display: inline-flex; }
.search-status .spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
