/* ============================================================
   REKOM Status Dashboard — Design System v2
   Modern control-room aesthetic. Mobile-first. Dark-first.
   ============================================================ */

:root {
  /* Core palette — inspired by LD dark-green/gold warmth */
  --bg-primary: #0c1214;
  --bg-secondary: #111a1d;
  --bg-card: #141f23;
  --bg-card-hover: #19272c;
  --bg-elevated: #1a2930;
  --bg-glass: rgba(20, 31, 35, 0.7);

  --text-primary: #e8e4df;
  --text-secondary: #8a9a9e;
  --text-muted: #556a70;

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.03);

  /* Status colors — softer, more refined */
  --status-ok: #34d399;
  --status-ok-soft: #2d8b6a;
  --status-ok-bg: rgba(52, 211, 153, 0.08);
  --status-ok-glow: rgba(52, 211, 153, 0.25);
  --status-ok-border: rgba(52, 211, 153, 0.2);

  --status-warn: #fbbf24;
  --status-warn-soft: #a07c28;
  --status-warn-bg: rgba(251, 191, 36, 0.08);
  --status-warn-glow: rgba(251, 191, 36, 0.25);
  --status-warn-border: rgba(251, 191, 36, 0.2);

  --status-error: #f87171;
  --status-error-soft: #a03535;
  --status-error-bg: rgba(248, 113, 113, 0.08);
  --status-error-glow: rgba(248, 113, 113, 0.25);
  --status-error-border: rgba(248, 113, 113, 0.2);

  --status-unknown: #94a3b8;
  --status-unknown-bg: rgba(148, 163, 184, 0.08);
  --status-unknown-glow: rgba(148, 163, 184, 0.15);
  --status-unknown-border: rgba(148, 163, 184, 0.15);

  /* Accent */
  --accent: #34d399;
  --accent-bg: rgba(52, 211, 153, 0.06);

  /* Sizing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #f0f1f5;
  --bg-secondary: #e4e6ec;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f8fa;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(240, 241, 245, 0.85);

  --text-primary: #0f1419;
  --text-secondary: #3d4852;
  --text-muted: #6b7b8d;

  --border: rgba(0, 0, 0, 0.1);
  --border-hover: rgba(0, 0, 0, 0.18);
  --border-subtle: rgba(0, 0, 0, 0.06);

  --status-ok: #0d9668;
  --status-ok-soft: #0d9668;
  --status-ok-bg: rgba(13, 150, 104, 0.08);
  --status-ok-glow: rgba(13, 150, 104, 0.15);
  --status-ok-border: rgba(13, 150, 104, 0.2);

  --status-warn: #b45309;
  --status-warn-soft: #b45309;
  --status-warn-bg: rgba(180, 83, 9, 0.08);
  --status-warn-glow: rgba(180, 83, 9, 0.15);
  --status-warn-border: rgba(180, 83, 9, 0.2);

  --status-error: #dc2626;
  --status-error-soft: #dc2626;
  --status-error-bg: rgba(220, 38, 38, 0.08);
  --status-error-glow: rgba(220, 38, 38, 0.15);
  --status-error-border: rgba(220, 38, 38, 0.2);

  --status-unknown: #64748b;
  --status-unknown-bg: rgba(100, 116, 139, 0.08);
  --status-unknown-glow: rgba(100, 116, 139, 0.1);
  --status-unknown-border: rgba(100, 116, 139, 0.15);

  --accent: #0d9668;
  --accent-bg: rgba(13, 150, 104, 0.06);
}

/* ============ RESET ============ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* ============ POLL PROGRESS BAR ============ */
.poll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 200;
  overflow: hidden;
  background: transparent;
}

.poll-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, transparent, var(--status-ok), transparent);
  transition: width 15s linear;
  opacity: 0.6;
}

.poll-progress-bar.reset {
  transition: none;
  width: 0%;
}

.poll-progress-bar.active {
  width: 100%;
}

/* ============ LOGIN SCREEN ============ */
#login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(52, 211, 153, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(52, 211, 153, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, black 20%, transparent 70%);
}

.login-content {
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-align: center;
  width: 100%;
  max-width: 400px;
  padding: 2rem 1.5rem;
  margin-top: -20vh;
}

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

/* Brand block: logo + STATUS — pulses as one unit */
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeUp 0.6s var(--ease-out) both, logoPulse 4s 0.8s ease-in-out infinite;
  margin-bottom: 3rem;
}

.login-brand-logo {
  height: 120px;
  width: auto;
  display: block;
}

.login-brand-status {
  margin-top: -2.15rem;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.45em;
  color: var(--text-muted);
  text-transform: uppercase;
}

@keyframes logoPulse {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.55; transform: translateY(-6px); }
}

/* Bottom section: subtitle, sign-in, footer */
.login-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  animation: fadeUp 0.8s 0.2s var(--ease-out) both;
}

.login-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.login-error {
  background: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  color: var(--status-error);
  font-size: 0.85rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
}

.google-signin-wrap {
  display: flex;
  justify-content: center;
}

.login-footer {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ============ TOPBAR ============ */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 42px;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar-left { flex: 1; }
.topbar-center { flex: 0 0 auto; }
.topbar-right { flex: 1; justify-content: flex-end; }

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.topbar-logo img {
  height: 48px;
  width: auto;
}
.topbar-logo span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  animation: topbarStatusPulse 4s ease-in-out infinite;
}

@keyframes topbarStatusPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.25; }
}

.live-clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--status-ok);
  background: var(--status-ok-bg);
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  border: 1px solid var(--status-ok-border);
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--status-ok);
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Install App Button */
.install-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.install-btn.show { display: flex; }
.install-btn:hover { color: var(--accent); border-color: var(--accent); }

/* iOS Install Modal */
.ios-install-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
}
.ios-install-overlay.visible { opacity: 1; pointer-events: auto; }
.ios-install-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 1rem;
  padding: 2rem 1.75rem;
  max-width: 320px;
  width: 90%;
  text-align: center;
  position: relative;
}
.ios-install-modal h3 {
  color: var(--text-primary);
  font-size: 1rem;
  letter-spacing: 0.1em;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}
.ios-install-step {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  margin-bottom: 0.5rem;
}
.ios-install-step svg { vertical-align: middle; margin: 0 0.15rem; }
.ios-install-step strong { color: var(--text-primary); }
.ios-install-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  opacity: 0.6; transition: opacity 0.3s; line-height: 0;
}
.ios-install-close:hover { opacity: 1; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-smooth);
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-card);
}

.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Light theme refinements */
[data-theme="light"] #topbar {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .topbar-logo img {
  filter: brightness(0) saturate(100%);
}

[data-theme="light"] .service-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .service-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] #controls {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] .search-input {
  background: #ffffff;
  border-color: var(--border);
}

[data-theme="light"] .filter-pill {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="light"] .filter-pill.active {
  background: var(--text-primary);
  color: #ffffff;
  border-color: var(--text-primary);
}

[data-theme="light"] .modal-card {
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .hero-status-text {
  color: var(--text-primary);
}

[data-theme="light"] .section-divider-label {
  color: var(--text-secondary);
}

[data-theme="light"] .comp-badge {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--border);
}

.topbar-name {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.topbar-logout {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  text-decoration: none;
}

.topbar-logout:hover {
  color: var(--status-error);
  background: var(--status-error-bg);
}

/* ============ HERO — AMBIENT STATUS BANNER ============ */
#hero {
  padding: 4.5rem 1.25rem 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Ambient gradient background */
.hero-glow {
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 140%;
  height: 200%;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.12;
  transition: all 1.5s var(--ease-smooth);
  filter: blur(80px);
}

.hero-glow.status-operational { background: radial-gradient(ellipse, var(--status-ok), transparent 70%); }
.hero-glow.status-degraded { background: radial-gradient(ellipse, var(--status-warn), transparent 70%); }
.hero-glow.status-major_outage,
.hero-glow.status-critical_outage { background: radial-gradient(ellipse, var(--status-error), transparent 70%); }
.hero-glow.status-unknown { background: radial-gradient(ellipse, var(--status-unknown), transparent 70%); }

.hero-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  margin-bottom: 1rem;
  position: relative;
  transition: all 0.8s var(--ease-smooth);
}

.hero-status-icon.operational {
  background: var(--status-ok-bg);
  border: 1.5px solid var(--status-ok-border);
  color: var(--status-ok);
  box-shadow: 0 0 30px var(--status-ok-glow);
}

.hero-status-icon.degraded {
  background: var(--status-warn-bg);
  border: 1.5px solid var(--status-warn-border);
  color: var(--status-warn);
  box-shadow: 0 0 30px var(--status-warn-glow);
}

.hero-status-icon.major_outage,
.hero-status-icon.critical_outage {
  background: var(--status-error-bg);
  border: 1.5px solid var(--status-error-border);
  color: var(--status-error);
  box-shadow: 0 0 30px var(--status-error-glow);
}

.hero-status-icon.unknown {
  background: var(--status-unknown-bg);
  border: 1.5px solid var(--status-unknown-border);
  color: var(--status-unknown);
}

/* Breathing ring animation */
.hero-status-icon::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0;
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0; transform: scale(0.95); }
  50% { opacity: 0.2; transform: scale(1.1); }
}

.hero-status-text {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  transition: all 0.5s var(--ease-out);
  position: relative;
}

/* Status pills */
.hero-pills {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: relative;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.3s var(--ease-smooth);
}

.hero-pill .pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.hero-pill.ok .pill-dot { background: var(--status-ok); }
.hero-pill.warn .pill-dot { background: var(--status-warn); }
.hero-pill.error .pill-dot { background: var(--status-error); }
.hero-pill.muted { opacity: 0.4; }

/* Breathing line */
.hero-line {
  margin: 1.5rem auto 0;
  width: 100%;
  max-width: 300px;
  height: 1px;
  position: relative;
  overflow: hidden;
  opacity: 0.5;
}

.hero-line::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--status-ok), transparent);
  animation: scanLine 3s ease-in-out infinite;
}

.hero-line.status-degraded::after { background: linear-gradient(90deg, transparent, var(--status-warn), transparent); }
.hero-line.status-major_outage::after,
.hero-line.status-critical_outage::after { background: linear-gradient(90deg, transparent, var(--status-error), transparent); }

@keyframes scanLine {
  0% { left: -50%; }
  100% { left: 100%; }
}

/* ============ CONTROLS ============ */
#controls {
  padding: 0.75rem 1.25rem 1rem;
  position: sticky;
  top: 42px;
  z-index: 50;
  transition: top 0.3s ease;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.controls-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 180px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.7rem 0.5rem 2.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.search-input::placeholder { color: var(--text-muted); }

/* View toggle button */
.view-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}
.view-toggle:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}
/* In grid mode: show the list icon (to switch TO list) */
.view-toggle .icon-grid { display: none; }
.view-toggle .icon-list { display: block; }
/* In list mode: show the grid icon (to switch TO grid) */
.view-list .view-toggle .icon-grid { display: block; }
.view-list .view-toggle .icon-list { display: none; }

/* ============ LIST VIEW ============ */
.view-list .group-cards {
  grid-template-columns: 1fr !important;
  gap: 0;
}

.view-list .service-card {
  border-radius: 0;
  border-top: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.45rem 0.75rem;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 1rem;
  row-gap: 0;
  align-items: center;
}
.view-list .service-card:first-child {
  border-top: 2px solid var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.view-list .service-card:last-child {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border-bottom: 1px solid var(--border);
}
.view-list .service-card:only-child { border-radius: var(--radius-sm); }

/* Row 1: header + footer meta on the right */
.view-list .card-header {
  grid-column: 1;
  grid-row: 1;
  gap: 0.5rem;
}
.view-list .card-footer {
  grid-column: 2;
  grid-row: 1;
  margin-top: 0;
  justify-content: flex-end;
}

/* Row 2: description spans full width */
.view-list .service-desc {
  grid-column: 1 / -1;
  grid-row: 2;
  font-size: 0.7rem;
  margin: 0;
  padding: 0;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact tweaks */
.view-list .service-name { font-size: 0.82rem; }
.view-list .service-icon { width: 16px; height: 16px; }
.view-list .service-icon svg,
.view-list .service-icon img { width: 16px; height: 16px; }
.view-list .status-dot { width: 7px; height: 7px; }
.view-list .status-label { font-size: 0.68rem; }
.view-list .service-group-tag { font-size: 0.5rem; }
.view-list .comp-badge { font-size: 0.58rem; padding: 0.1rem 0.3rem; }
.view-list .service-ago,
.view-list .service-response-time { font-size: 0.58rem; }
.view-list .meta-sep { font-size: 0.5rem; }

/* In list view, use left border for status color instead of top */
.view-list .service-card { border-left-width: 3px; }
.view-list .service-card.status-operational { border-top-color: var(--border); border-left-color: var(--status-ok); }
.view-list .service-card.status-degraded { border-top-color: var(--border); border-left-color: var(--status-warn); }
.view-list .service-card.status-major_outage,
.view-list .service-card.status-critical_outage { border-top-color: var(--border); border-left-color: var(--status-error); }
.view-list .service-card.status-unknown { border-top-color: var(--border); border-left-color: var(--status-unknown); }
.view-list .service-card:first-child { border-top-color: var(--border); }

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

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

.filter-pill {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s var(--ease-smooth);
  white-space: nowrap;
}

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

.filter-pill.active {
  background: var(--accent-bg);
  border-color: var(--status-ok-border);
  color: var(--status-ok);
}

/* ============ SERVICES GRID ============ */
#services {
  padding: 0 1.25rem 3rem;
}

.services-grid {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Group headers */
.group-section {
  margin-top: 1.25rem;
}

.group-section:first-child {
  margin-top: 0.5rem;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
}

.group-name {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.group-count {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
}

.group-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Service cards container — responsive grid */
.group-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
}

/* Section divider between services and websites */
.section-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 0.75rem;
}

.section-divider-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.section-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Favicon images in service icons */
.favicon-icon {
  border-radius: 2px;
  object-fit: contain;
}

/* Service card — vertical layout, uniform height */
.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--text-muted);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  cursor: pointer;
  transition: all 0.25s var(--ease-smooth);
  position: relative;
  min-width: 0;
  min-height: 160px;
}

.service-card .card-footer {
  margin-top: auto;
}

/* Search-matched components shown on card */
.search-match-comps {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.search-match-comp {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
}

.search-match-name {
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-match-status {
  font-size: 0.65rem;
  font-weight: 500;
  flex-shrink: 0;
}

.search-match-status.operational { color: var(--status-ok); }
.search-match-status.degraded { color: var(--status-warn); }
.search-match-status.major_outage, .search-match-status.critical_outage { color: var(--status-error); }

.service-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.service-card:hover { border-top-color: inherit; }

/* Top border status colors */
.service-card.status-operational { border-top-color: var(--status-ok); }
.service-card.status-degraded { border-top-color: var(--status-warn); }
.service-card.status-major_outage,
.service-card.status-critical_outage { border-top-color: var(--status-error); }
.service-card.status-unknown { border-top-color: var(--status-unknown); }

/* Status change flash */
.service-card.status-changed {
  animation: statusFlash 1.2s var(--ease-out);
}

@keyframes statusFlash {
  0% { box-shadow: inset 0 0 0 1px var(--border); }
  20% { box-shadow: inset 0 0 20px var(--status-ok-glow); }
  100% { box-shadow: inset 0 0 0 1px transparent; }
}

.service-card.status-degraded.status-changed { animation-name: statusFlashWarn; }
@keyframes statusFlashWarn {
  0% { box-shadow: inset 0 0 0 1px var(--border); }
  20% { box-shadow: inset 0 0 20px var(--status-warn-glow); }
  100% { box-shadow: inset 0 0 0 1px transparent; }
}

.service-card.status-major_outage.status-changed { animation-name: statusFlashError; }
@keyframes statusFlashError {
  0% { box-shadow: inset 0 0 0 1px var(--border); }
  20% { box-shadow: inset 0 0 20px var(--status-error-glow); }
  100% { box-shadow: inset 0 0 0 1px transparent; }
}

/* Card header: icon + name + status */
.card-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.service-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.service-name {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.service-name::first-letter {
  text-transform: uppercase;
}

.service-group-tag {
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  width: fit-content;
}

/* Card description */
.service-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Card footer: meta info */
.card-footer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.meta-sep {
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 0.6rem;
}

.comp-badge {
  font-size: 0.62rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  white-space: nowrap;
}

.service-response-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--text-muted);
}

.service-ago {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.service-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  opacity: 0;
  animation: dotPulse 2.5s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 0; }
  50% { transform: scale(1.4); opacity: 0.25; }
}

.status-dot.operational { background: var(--status-ok); }
.status-dot.operational::after { background: var(--status-ok); }
.status-dot.degraded { background: var(--status-warn); }
.status-dot.degraded::after { background: var(--status-warn); }
.status-dot.major_outage,
.status-dot.critical_outage { background: var(--status-error); }
.status-dot.major_outage::after,
.status-dot.critical_outage::after { background: var(--status-error); }
.status-dot.unknown { background: var(--status-unknown); }
.status-dot.unknown::after { background: var(--status-unknown); animation: none; }

.status-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-label.operational { color: var(--status-ok); }
.status-label.degraded { color: var(--status-warn); }
.status-label.major_outage,
.status-label.critical_outage { color: var(--status-error); }
.status-label.unknown { color: var(--status-unknown); }

.comp-badge {
  font-size: 0.6rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.service-card:hover .comp-badge {
  border-color: var(--border-hover);
}

/* ============ SERVICE DETAIL MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  animation: modalOverlayIn 0.35s var(--ease-out) forwards;
}

.modal-overlay.closing {
  animation: modalOverlayOut 0.3s var(--ease-smooth) forwards;
}

@keyframes modalOverlayIn {
  to {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

@keyframes modalOverlayOut {
  from {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  to {
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-top: 3px solid var(--text-muted);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  transform-origin: var(--origin-x, 50%) var(--origin-y, 50%);
  animation: modalCardIn 0.4s var(--ease-spring) forwards;
  opacity: 0;
  transform: scale(0.85) translateY(10px);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.modal-overlay.closing .modal-card {
  animation: modalCardOut 0.25s var(--ease-smooth) forwards;
}

@keyframes modalCardIn {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalCardOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
}

/* Status top border on modal */
.modal-card.status-operational { border-top-color: var(--status-ok); }
.modal-card.status-degraded { border-top-color: var(--status-warn); }
.modal-card.status-major_outage,
.modal-card.status-critical_outage { border-top-color: var(--status-error); }
.modal-card.status-unknown { border-top-color: var(--status-unknown); }

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 1;
}

.modal-close:hover {
  background: var(--status-error-bg);
  border-color: var(--status-error-border);
  color: var(--status-error);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-right: 2.5rem;
}

.modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-title-wrap {
  flex: 1;
  min-width: 0;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.modal-group {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.modal-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.modal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding: 0.8rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.modal-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.modal-meta-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-meta-item span:last-child {
  font-size: 0.82rem;
  color: var(--text-primary);
}

.modal-meta-item .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
}

.modal-components {
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.modal-section-title {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.modal-comp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-comp-row:last-child {
  border-bottom: none;
}

.modal-comp-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.modal-comp-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.modal-source-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s ease;
  width: fit-content;
}

.modal-source-link:hover {
  color: var(--accent);
  border-color: var(--status-ok-border);
  background: var(--accent-bg);
}

/* Incidents on cards */
.card-incident-badge {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--status-warn);
  background: var(--status-warn-bg);
  border: 1px solid var(--status-warn-border);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  width: fit-content;
}

/* Incidents in modal */
.modal-incidents {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.modal-incident {
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  border: 1px solid var(--status-warn-border);
  background: var(--status-warn-bg);
}

.modal-incident.error {
  border-color: var(--status-error-border);
  background: var(--status-error-bg);
}

.incident-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.incident-badge {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
  color: var(--status-warn);
  background: rgba(251, 191, 36, 0.15);
}

.incident-badge.error {
  color: var(--status-error);
  background: rgba(248, 113, 113, 0.15);
}

.incident-service-tag {
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}

.incident-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-top: 0.3rem;
}

.incident-updates {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.4rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--border);
}

.incident-update-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.incident-update-status {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  color: var(--text-muted);
}

.incident-update-time {
  font-size: 0.6rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

.incident-update-body {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-top: 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.incident-update-body.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.incident-read-more {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 0.2rem 0 0;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.incident-read-more:hover {
  opacity: 1;
}

/* ============ FOOTER ============ */
#footer {
  text-align: center;
  padding: 1.5rem 1.25rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.footer-sep {
  margin: 0 0.4rem;
  opacity: 0.4;
}

/* ============ SKELETON LOADING ============ */
.skeleton {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  height: 60px;
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 25%, var(--bg-card-hover) 50%, transparent 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============ RESPONSIVE ============ */

/* Tablet: 2 cards per row */
@media (min-width: 640px) {
  .group-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  #hero { padding: 5rem 1.5rem 1rem; }
  #controls { padding: 0.75rem 1.5rem 1rem; }
  #services { padding: 0 1.5rem 3rem; }
}

/* Desktop: 3 cards per row, better spacing */
@media (min-width: 1100px) {
  .group-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  #topbar { padding: 0 2rem; }
  #hero { padding: 5rem 2rem 1rem; }
  #controls { padding: 0.75rem 2rem 1rem; }
  #services { padding: 0 2rem 3rem; }
}

@media (max-width: 639px) {
  .topbar-name { display: none; }

  .controls-inner {
    flex-wrap: wrap;
  }

  .search-wrap { min-width: 0; flex: 1; }
  .view-toggle { flex-shrink: 0; }

  .filter-pills { width: 100%; }

  .filter-pills {
    overflow-x: auto;
    padding-bottom: 2px;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .filter-pills::-webkit-scrollbar { display: none; }
}

@media (max-width: 480px) {
  .live-clock { display: none; }
  .topbar-logo span { display: none; }
}

/* ============ ANIMATIONS ============ */
.fade-in {
  animation: fadeUp 0.4s var(--ease-out) both;
}

.fade-in-stagger {
  opacity: 0;
  animation: fadeUp 0.35s var(--ease-out) both;
}

/* Accessibility: reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* No results */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
