@view-transition { navigation: auto; }

@import url("assets/fonts/inter.css");

:root,
[data-theme="dark"] {
  --bg: #070b12;
  --surface: #111827;
  --surface-elevated: #1a2332;
  --surface-hover: #243044;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e2e8f0;
  --text-strong: #ffffff;
  --text-muted: #a8b8cc;
  --text-faint: #7b8fa6;
  --accent: #7eb8ff;
  --accent-soft: rgba(126, 184, 255, 0.18);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.22);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.22);
  --warn: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--border);
  --nav-bg: rgba(7, 11, 18, 0.92);
  --skeleton-from: #1e293b;
  --skeleton-mid: #334155;
  --overlay: rgba(0, 0, 0, 0.6);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --nav-h: 52px;
  --gap: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 180ms;
  --card-w: 168px;
  --card-h: 108px;
  --footer-space: 56px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-hover: #f1f5f9;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #1e293b;
  --text-strong: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.15);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.15);
  --warn: #b45309;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 0 0 1px var(--border);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.1), 0 0 0 1px var(--border);
  --nav-bg: rgba(255, 255, 255, 0.94);
  --skeleton-from: #e2e8f0;
  --skeleton-mid: #f1f5f9;
  --overlay: rgba(15, 23, 42, 0.25);
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease) !important;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Subtle gradient depth on body */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(ellipse 80% 60% at 10% 0%, rgba(110, 168, 254, 0.04), transparent 50%);
}

[data-theme="light"] body::before {
  background: radial-gradient(ellipse 80% 60% at 10% 0%, rgba(59, 130, 246, 0.03), transparent 50%);
}

/* Custom scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-hover) transparent;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-hover); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* NAVBAR */
.navbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 max(var(--space-5), 20px);
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--nav-h);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
  text-decoration: none;
  flex-shrink: 0;
  letter-spacing: -0.03em;
  transition: color var(--duration) var(--ease);
}

.logo:hover { color: var(--accent); }

.nav-segment {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  justify-content: center;
}

.nav-segment > a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.nav-segment > a:hover {
  color: var(--text-strong);
  background: var(--surface-hover);
}

.nav-segment > a.active {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(126, 184, 255, 0.25);
}

[data-theme="light"] .nav-segment > a.active {
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.2);
}

/* Nav Dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.nav-dropdown-trigger:hover {
  color: var(--text-strong);
  background: var(--surface-hover);
}

.nav-dropdown-trigger.active {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(126, 184, 255, 0.25);
}

.nav-dropdown-chevron {
  flex-shrink: 0;
  transition: transform var(--duration) var(--ease);
}

.nav-dropdown.open .nav-dropdown-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2);
  background: var(--surface-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 150px;
  z-index: 100;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown-trigger:focus + .nav-dropdown-menu,
.nav-dropdown-menu:hover {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.nav-dropdown-menu a {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.nav-dropdown-menu a:hover {
  color: var(--text-strong);
  background: var(--surface-hover);
}

.nav-dropdown-menu a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.theme-toggle, .menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.theme-toggle:hover, .menu-toggle:hover {
  color: var(--text-strong);
  background: var(--surface-hover);
}

.theme-toggle:active, .menu-toggle:active {
  transform: scale(0.92);
}

.theme-icon { display: none; }
[data-theme="dark"] .theme-icon-sun, :root:not([data-theme]) .theme-icon-sun { display: block; }
[data-theme="light"] .theme-icon-moon { display: block; }
.menu-toggle { display: none; }

.menu-toggle.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* MAIN */
.compact-main {
  flex: 1;
  padding: var(--space-4) var(--space-5);
  padding-bottom: var(--space-3);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  min-height: 0;
  animation: pageFadeIn 0.3s var(--ease);
  view-transition-name: main;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* FOOTER */
.site-footer {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-5);
  text-align: center;
}

.site-footer-text {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.4;
}

.site-footer-heart {
  display: inline-block;
}

.site-footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--duration) var(--ease);
}

.site-footer-link:hover {
  color: var(--accent);
}

/* PAGE ABOUT */
.page-about {
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  margin-bottom: var(--space-4);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.page-about summary {
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  transition: color var(--duration) var(--ease);
}

.page-about summary:hover { color: var(--accent); }
.page-about summary::-webkit-details-marker { display: none; }
.page-about summary::before { content: "\25B8 "; transition: transform var(--duration) var(--ease); display: inline-block; }
.page-about[open] summary::before { transform: rotate(90deg); }

.page-about-body {
  padding: var(--space-3) var(--space-4) var(--space-4);
  max-height: 120px;
  overflow-y: auto;
}

.page-about-body p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: var(--space-1);
}

/* SINGLE-COLUMN PAGE LAYOUT */
.page-single {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  height: 100%;
  min-height: 0;
}

.page-single .grid {
  flex: 1;
  overflow-y: auto;
  align-content: start;
  padding-bottom: var(--footer-space);
  scroll-padding-bottom: var(--footer-space);
}

.page-single-monitor {
  height: 100%;
  min-height: 0;
}

.page-single-monitor .monitor-table-fill {
  flex: 1;
  min-height: 340px;
  overflow: hidden;
}

/* PAGE VIEWPORT (legacy two-col for category pages) */
.page-viewport {
  display: flex;
  gap: var(--gap);
  height: 100%;
  min-height: 0;
}

.page-viewport-single { display: block; }

.page-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
}

.page-body-single {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.page-body-single .grid-cards-compact {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  padding-bottom: var(--footer-space);
  scroll-padding-bottom: var(--footer-space);
}

/* STATS STRIP (horizontal, compact) */
.stats-strip {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.stats-strip .stat-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

[data-theme="light"] .stats-strip .stat-row {
  background: var(--surface-hover);
}

.stats-strip .stat-row-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.stats-strip .stat-row-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  flex-shrink: 0;
}

.stats-strip .stat-row-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stats-strip .stat-row-bar {
  width: 56px;
  height: 5px;
  background: var(--surface-hover);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px var(--border);
}

.stats-strip .stat-row-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s var(--ease);
}

.stats-strip .stat-row-uptime {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  flex: 0 0 auto;
}

.stats-strip .text-link {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.stats-strip .text-link:hover {
  background: var(--accent);
  color: #fff;
}

[data-theme="light"] .stats-strip .text-link:hover {
  color: #fff;
}

/* Legacy stats panel (used on Monitor) */
.stats-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  height: 100%;
  padding: var(--space-3);
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stats-panel-horizontal {
  flex-direction: row;
  flex-wrap: wrap;
  height: auto;
  padding: var(--space-4);
  align-items: center;
}

.stats-panel-horizontal .stat-row {
  flex: 1;
  min-width: 100px;
}

.stat-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stat-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
}

.stat-row-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-row-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-row-bar {
  height: 5px;
  background: var(--surface-hover);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--border);
}

.stat-row-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s var(--ease);
  width: var(--fill-width, 0%);
}

.stat-row-fill-empty {
  --fill-width: 0%;
}

.stat-row-value-sub {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}

.stat-fill-ok { background: linear-gradient(90deg, var(--success), #86efac); }
.stat-fill-warn { background: linear-gradient(90deg, var(--warn), #fcd34d); }
.stat-fill-crit { background: linear-gradient(90deg, var(--danger), #fda4af); }

.stat-row-uptime {
  margin-top: auto;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.stats-panel-horizontal .stat-row-uptime {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  flex: 0 0 auto;
}

.stats-unavailable {
  font-size: 12px;
  color: var(--text-faint);
  padding: var(--space-3);
  text-align: center;
}

/* DASH BAR */
.dash-bar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.dash-bar-cats {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.text-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
  flex-shrink: 0;
}

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

/* GRID */
.grid {
  display: grid;
  gap: var(--gap);
}

.grid-cards {
  grid-template-columns: repeat(auto-fill, var(--card-w));
  grid-auto-rows: var(--card-h);
  justify-content: start;
  align-items: stretch;
}

.grid-cards-compact {
  grid-template-columns: repeat(auto-fill, var(--card-w));
  grid-auto-rows: var(--card-h);
  justify-content: start;
  align-items: stretch;
}

.grid-cards-compact .card,
.grid-cards .card {
  width: 100%;
  height: 100%;
  min-height: var(--card-h);
  overflow: hidden;
}

/* CARDS */
.card {
  background: var(--surface-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), background var(--duration) var(--ease);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--surface-hover);
}

.card-compact {
  padding: var(--space-3) var(--space-4);
  justify-content: flex-start;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  flex: 1;
  min-height: 0;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.35;
  letter-spacing: -0.02em;
  flex: 1;
  min-width: 0;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.card-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.4;
  word-break: break-word;
}

.card-compact .card-desc { display: none; }

.card-compact .card-head {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  justify-content: space-between;
}

.card-status {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  flex-shrink: 0;
  width: 100%;
  margin-top: auto;
}

.status-pair {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.01em;
  line-height: 1;
  min-width: 22px;
}

.status-ms {
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  line-height: 1;
}

.status-ms-online { color: var(--text-muted); }

.status-ms-offline { color: var(--danger); opacity: 0.9; }

.skeleton-ms {
  display: inline-block;
  width: 32px;
  height: 10px;
  border-radius: 4px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-hover);
  box-shadow: 0 0 0 2px var(--surface-elevated), 0 0 0 3px var(--border);
  transition: background 0.4s var(--ease), box-shadow 0.4s var(--ease);
  flex-shrink: 0;
}

.status-dot-loading {
  background: var(--text-muted);
  animation: pulse 1.4s var(--ease) infinite;
}

.status-dot-online {
  background: var(--success);
  box-shadow: 0 0 0 2px var(--surface-elevated), 0 0 0 3px var(--success-soft), 0 0 10px var(--success-soft);
}

.status-dot-offline {
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface-elevated), 0 0 0 3px var(--danger-soft), 0 0 10px var(--danger-soft);
}

.status-dot-na {
  background: var(--text-faint);
  opacity: 0.55;
}

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

/* Legacy ping (non-compact) */
.card-pings { display: flex; gap: var(--space-2); margin-top: var(--space-1); }
.ping-chip { display: flex; align-items: center; gap: var(--space-1); font-size: 11px; }
.ping-chip-label { color: var(--text-faint); font-size: 10px; }
.ping-dot { width: 6px; height: 6px; border-radius: 50%; }
.ping-badge { display: flex; align-items: center; gap: 3px; font-weight: 500; font-size: 11px; }
.ping-online { color: var(--success); }
.ping-online .ping-dot { background: var(--success); }
.ping-offline { color: var(--danger); }
.ping-offline .ping-dot { background: var(--danger); }
.ping-na { color: var(--text-faint); }
.ping-loading { min-width: 30px; }

/* CATEGORY PILLS — ghost style */
.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 14px;
  background: var(--surface-elevated);
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.category-pill:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  transform: translateY(-1px);
}

.category-pill.active {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(126, 184, 255, 0.25);
}

[data-theme="light"] .category-pill.active {
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.category-pill-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.category-pill.active .category-pill-count {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .category-pill.active .category-pill-count {
  background: rgba(255, 255, 255, 0.65);
}

@media (max-width: 900px) {
  .dash-bar {
    flex-wrap: nowrap;
    align-items: stretch;
  }

  .dash-bar-cats {
    position: relative;
    mask-image: linear-gradient(
      to right,
      transparent,
      #000 14px,
      #000 calc(100% - 14px),
      transparent
    );
    -webkit-mask-image: linear-gradient(
      to right,
      transparent,
      #000 14px,
      #000 calc(100% - 14px),
      transparent
    );
  }

  .category-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--space-4);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: var(--space-2);
    padding-bottom: 2px;
  }

  .category-pills::-webkit-scrollbar {
    display: none;
  }

  .category-pill {
    flex-shrink: 0;
    scroll-snap-align: start;
  }

  .category-pill:hover {
    transform: none;
  }
}

/* HEALTH */
.health-line {
  font-size: 13px;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.health-hero {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.health-summary-loading {
  min-height: 18px;
  display: flex;
  align-items: center;
}

/* STATUS TABLE */
.status-table-wrap {
  overflow: auto;
  height: 100%;
}

.status-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.status-table th, .status-table td {
  padding: 10px var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.status-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--border-strong);
}

.status-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .status-table tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.02);
}

.status-table tbody td:first-child {
  font-weight: 500;
  color: var(--text-strong);
}

.status-table tbody tr {
  transition: background var(--duration) var(--ease);
}

.status-table tbody tr:hover { background: var(--surface-hover); }
.status-table tr:last-child td { border-bottom: none; }

.status-online { color: var(--success); font-weight: 500; }
.status-offline { color: var(--danger); font-weight: 500; }
.status-na { color: var(--text-faint); }

/* Table dot cells */
.status-dot-cell {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  box-shadow: 0 0 0 2px var(--surface-elevated);
}

.status-dot-cell-online {
  background: var(--success);
  box-shadow: 0 0 0 2px var(--surface-elevated), 0 0 8px var(--success-soft);
}

.status-dot-cell-offline {
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface-elevated), 0 0 8px var(--danger-soft);
}

.status-dot-cell-na {
  background: var(--text-faint);
  opacity: 0.55;
}

/* MONITOR TABLE */
.monitor-table-fill {
  overflow: hidden;
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* SKELETON */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  display: inline-block;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--skeleton-from) 0%, var(--skeleton-mid) 50%, var(--skeleton-from) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton-ping { width: 30px; height: 10px; }
.skeleton-stat { width: 40px; height: 14px; }
.skeleton-line { width: 180px; height: 14px; }
.skeleton-cell { width: 36px; height: 12px; }

/* FADE IN + STAGGER */
.fade-in {
  animation: fadeIn 0.4s var(--ease) both;
  animation-delay: var(--fade-delay, 0ms);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-bg { display: none; }

/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .compact-main { animation: none; }
}

/* MOBILE */
@media (max-width: 768px) {
  :root {
    --gap: 12px;
    --nav-h: 56px;
  }

  body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    font-size: 15px;
  }

  body.nav-open {
    overflow: hidden;
  }

  /* ── Navbar ── */
  .navbar {
    padding-left: max(var(--space-3), env(safe-area-inset-left, 0));
    padding-right: max(var(--space-3), env(safe-area-inset-right, 0));
    gap: var(--space-4);
    min-height: var(--nav-h);
  }

  .logo {
    font-size: 15px;
    font-weight: 600;
    max-width: none;
    color: var(--text-strong);
  }

  .menu-toggle { display: flex; }

  .theme-toggle,
  .menu-toggle {
    width: 44px;
    height: 44px;
  }

  /* Compact nav dropdown (top-right) */
  .nav-segment {
    position: fixed;
    top: calc(var(--nav-h) + 8px);
    right: max(var(--space-3), env(safe-area-inset-right, 0));
    left: auto;
    bottom: auto;
    width: min(288px, calc(100vw - var(--space-4)));
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2);
    background: var(--surface-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
    z-index: 1001;
    max-height: calc(100dvh - var(--nav-h) - 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-segment::before {
    display: none;
  }

  .nav-segment.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  .nav-segment.closing {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    pointer-events: none;
  }

  .nav-segment > a {
    width: 100%;
    text-align: left;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    min-height: 42px;
    display: flex;
    align-items: center;
    font-size: 14px;
  }

  .nav-segment > a.active,
  .nav-dropdown-menu a.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
  }

  .nav-dropdown {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .nav-dropdown-trigger {
    display: flex;
    width: 100%;
    justify-content: space-between;
    padding: 11px 14px;
    min-height: 42px;
    border-radius: var(--radius-sm);
    font-size: 14px;
  }

  .nav-dropdown-menu {
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: none;
    box-shadow: none;
    background: transparent;
    border: none;
    padding: 0;
    min-width: auto;
    max-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: max-height 0.22s var(--ease), opacity 0.18s var(--ease);
  }

  .nav-dropdown.open .nav-dropdown-menu {
    pointer-events: auto;
    max-height: 240px;
    padding: 0 0 var(--space-1);
  }

  .nav-dropdown:hover .nav-dropdown-menu,
  .nav-dropdown-trigger:focus + .nav-dropdown-menu,
  .nav-dropdown-menu:hover {
    transform: none;
    pointer-events: none;
  }

  .nav-dropdown.open:hover .nav-dropdown-menu,
  .nav-dropdown.open .nav-dropdown-menu {
    pointer-events: auto;
  }

  .nav-dropdown-menu a {
    width: 100%;
    padding: 10px 14px 10px 22px;
    min-height: 40px;
    display: flex;
    align-items: center;
    font-size: 13px;
    border-radius: var(--radius-sm);
  }

  .nav-bg.active {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 1000;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  /* ── Main content ── */
  .compact-main {
    overflow: visible;
    padding: var(--space-4);
    padding-left: max(var(--space-4), env(safe-area-inset-left, 0));
    padding-right: max(var(--space-4), env(safe-area-inset-right, 0));
    padding-bottom: max(var(--footer-space), calc(var(--space-4) + env(safe-area-inset-bottom, 0)));
    animation: none;
  }

  .site-footer {
    padding: var(--space-4);
    padding-left: max(var(--space-4), env(safe-area-inset-left, 0));
    padding-right: max(var(--space-4), env(safe-area-inset-right, 0));
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom, 0));
  }

  .site-footer-text {
    font-size: 11px;
  }

  .page-single,
  .page-viewport,
  .page-body-single,
  .page-single-monitor {
    height: auto;
    min-height: 0;
    gap: var(--space-4);
  }

  .page-single-monitor .monitor-table-fill {
    min-height: 320px;
  }

  .page-single .grid,
  .page-body-single .grid-cards-compact {
    flex: none;
    overflow: visible;
    padding-bottom: var(--space-4);
    scroll-padding-bottom: var(--space-4);
  }

  .page-about {
    margin-bottom: var(--space-3);
  }

  .page-about summary {
    padding: var(--space-3) var(--space-4);
    font-size: 13px;
  }

  .page-about-body {
    max-height: none;
    padding: var(--space-2) var(--space-4) var(--space-4);
  }

  .page-about-body p {
    font-size: 13px;
  }

  /* ── Stats strip ── */
  .stats-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
  }

  .stats-strip .stat-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--surface);
    border-radius: var(--radius-sm);
  }

  .stats-strip .stat-row-head {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
  }

  .stats-strip .stat-row-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .stats-strip .stat-row-value {
    font-size: 15px;
  }

  .stats-strip .stat-row-bar {
    display: block;
    width: 100%;
    height: 3px;
  }

  .stats-strip .text-link {
    grid-column: 1 / -1;
    margin: 0;
    padding: var(--space-3);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
  }

  .stats-strip .text-link:active {
    background: var(--accent);
    color: #fff;
  }

  /* ── Category pills — hidden on mobile ── */
  .dash-bar {
    display: none;
  }

  /* ── Cards ── */
  .grid-cards-compact,
  .grid-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: var(--card-h);
    justify-content: stretch;
    gap: var(--space-2);
  }

  .grid-cards-compact .card,
  .grid-cards .card {
    width: 100%;
    height: 100%;
    min-height: var(--card-h);
  }

  .card {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
  }

  .card:active {
    transform: scale(0.97);
    background: var(--surface-hover);
  }

  .card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
    background: var(--surface-elevated);
  }

  .card-title {
    font-size: 13px;
    line-height: 1.35;
  }

  .status-dot {
    width: 10px;
    height: 10px;
  }

  /* ── Monitor ── */
  .monitor-table-fill {
    border-radius: var(--radius-lg);
  }

  .status-table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .status-table {
    font-size: 13px;
    min-width: 280px;
  }

  .status-table th,
  .status-table td {
    padding: 12px var(--space-3);
  }

  .status-table th:nth-child(3),
  .status-table th:nth-child(5),
  .status-table td:nth-child(3),
  .status-table td:nth-child(5) {
    display: none;
  }

  .status-table td:first-child {
    font-weight: 500;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 380px) {
  .grid-cards-compact,
  .grid-cards {
    grid-template-columns: 1fr;
    grid-auto-rows: var(--card-h);
  }

  .stats-strip {
    grid-template-columns: 1fr;
  }
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--surface-hover);
  }

  .card:active {
    transform: translateY(-2px);
  }
}
