*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0a0e14;
  --surface: #121820;
  --surface-2: #1a2230;
  --border: rgba(255, 255, 255, 0.07);
  --text: #e8edf4;
  --muted: #7d8da6;
  --accent: #4f8cff;
  --accent-dim: rgba(79, 140, 255, 0.15);
  --public: #34d399;
  --tailscale: #a78bfa;
  --local: #fbbf24;
  --radius: 14px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

html,
body {
  margin: 0;
  min-height: 100%;
}

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

.bg-grid {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 20% -5%, rgba(79, 140, 255, 0.12), transparent),
    radial-gradient(ellipse 50% 40% at 90% 10%, rgba(167, 139, 250, 0.08), transparent),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: auto, auto, 48px 48px, 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  background: rgba(10, 14, 20, 0.82);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.main-nav {
  display: flex;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem;
}

.nav-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.nav-btn:hover {
  color: var(--text);
}

.nav-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.view-panel.hidden {
  display: none !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  font-size: 1.75rem;
  color: var(--accent);
  line-height: 1;
}

.brand-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.host-badge {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(79, 140, 255, 0.25);
}

.updated {
  font-size: 0.8rem;
  color: var(--muted);
}

.main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.search-wrap input {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
  border-color: rgba(79, 140, 255, 0.5);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.filter-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.filter-btn.active {
  color: var(--text);
  border-color: rgba(79, 140, 255, 0.4);
  background: var(--accent-dim);
}

.category-section {
  margin-bottom: 2rem;
}

.category-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.category-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.category-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 140, 255, 0.3);
  box-shadow: var(--shadow);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.card-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.card-badge.public { background: rgba(52, 211, 153, 0.15); color: var(--public); }
.card-badge.tailscale { background: rgba(167, 139, 250, 0.15); color: var(--tailscale); }
.card-badge.local { background: rgba(251, 191, 36, 0.15); color: var(--local); }

.card-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.card-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.card-url {
  font-size: 0.75rem;
  color: var(--accent);
  word-break: break-all;
  font-family: ui-monospace, "Cascadia Code", monospace;
}

.card-host {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}

.hidden {
  display: none !important;
}

.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem 1.5rem 2.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.footer code {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.7;
}

.infra-summary {
  margin: 0 0 1.5rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

.infra-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.infra-block {
  padding: 1.15rem 1.2rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.infra-heading {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.infra-sub {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.infra-lead,
.infra-meta {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.host-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.host-card {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.host-name {
  margin: 0;
  font-size: 1rem;
}

.host-role {
  margin: 0.2rem 0 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.host-dl {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.host-dl div {
  display: flex;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.host-dl dt {
  min-width: 4.5rem;
  color: var(--muted);
}

.host-dl dd {
  margin: 0;
}

.host-notes {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.path-list {
  display: grid;
  gap: 0.65rem;
}

.path-card {
  padding: 0.85rem 0.95rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.path-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
}

.path-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

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

.infra-table th,
.infra-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.infra-table th {
  color: var(--muted);
  font-weight: 600;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.infra-list,
.infra-notes {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
}

.infra-list code {
  font-size: 0.78rem;
}

/* --- Monitor tab --- */

.monitor-summary {
  margin-bottom: 1.25rem;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.summary-card {
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-card.ok {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.06);
}

.summary-card.warn {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.06);
}

.summary-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

.summary-denom {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}

.summary-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.monitor-block {
  margin-bottom: 1.5rem;
}

.monitor-heading {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.monitor-hosts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.monitor-host-card,
.monitor-svc-card {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.monitor-host-top,
.monitor-svc-top {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.monitor-host-top h3,
.monitor-svc-top h3 {
  margin: 0;
  flex: 1;
  font-size: 0.95rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
  background: var(--muted);
}

.status-up .status-dot {
  background: var(--public);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.status-down .status-dot {
  background: #f87171;
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.45);
}

.status-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.status-badge.status-up {
  color: var(--public);
  background: rgba(52, 211, 153, 0.12);
}

.status-badge.status-down {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
}

.lat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.lat-chip {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

.host-metrics {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.monitor-services {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}

.monitor-svc-host {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.monitor-svc-lat {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
}

.monitor-svc-card.critical {
  border-color: rgba(79, 140, 255, 0.25);
}

.crit-mark {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  vertical-align: middle;
}

.lat-bar {
  height: 3px;
  margin-top: 0.55rem;
  border-radius: 2px;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}

.lat-bar::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: min(calc(var(--lat, 0ms) / 5), 100%);
  background: linear-gradient(90deg, var(--public), var(--accent));
  border-radius: 2px;
}

.monitor-svc-detail {
  margin: 0.4rem 0 0;
  font-size: 0.72rem;
  color: #f87171;
}

.monitor-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.monitor-error {
  color: #f87171;
  font-size: 0.9rem;
}

.collector-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.collector-pill {
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.collector-pill.fresh {
  color: var(--public);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}

.collector-pill.stale {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}

.host-sources {
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.monitor-nodes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}

.node-snapshot-card {
  padding: 0.85rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.node-snapshot-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.node-snapshot-head h3 {
  margin: 0;
  font-size: 0.92rem;
}

.node-snapshot-time {
  font-size: 0.7rem;
  color: var(--muted);
}

.node-snapshot-summary {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.node-snapshot-hosts .monitor-host-card {
  margin-bottom: 0.5rem;
}

@media (max-width: 600px) {
  .header-inner {
    padding: 1rem;
  }

  .main {
    padding: 1rem;
  }

  .cards {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .search-wrap input,
  .filter-btn {
    transition: none;
  }
}
