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

:root {
  --bg: #070b14;
  --bg2: #0c1220;
  --surface: #111827;
  --surface2: #1a2235;
  --surface3: #0f172a;
  --border: #1e293b;
  --border-light: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --green: #22c55e;
  --green-bright: #4ade80;
  --green-dim: rgba(34, 197, 94, 0.15);
  --yellow: #facc15;
  --yellow-dim: rgba(250, 204, 21, 0.12);
  --red: #ef4444;
  --red-bright: #f87171;
  --red-dim: rgba(239, 68, 68, 0.12);
  --accent: #009c3b;
  --gold: #ffdf00;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 156, 59, 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, 48px 48px, 48px 48px;
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }

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

.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 20, 0.92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.9rem 0;
  flex-wrap: wrap;
}

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

.brand img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 156, 59, 0.25);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #fff, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-text p {
  font-size: 0.7rem;
  color: var(--muted);
  max-width: 280px;
}

.nav {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
  font-size: 0.875rem;
  font-weight: 500;
}

.nav a { color: var(--muted); transition: color 0.15s; }
.nav a:hover, .nav a.active { color: var(--text); }

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 0.85rem;
  color: var(--muted);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.55rem 0;
  width: 200px;
  font-size: 0.85rem;
}

.search-box input:focus { outline: none; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,156,59,0.15); }

/* Alert banners */
.alert-banner,
.status-ok-banner {
  margin: 1.25rem 0 0.75rem;
  padding: 1rem 1.35rem;
  border-radius: 14px;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.alert-banner {
  border: 2px dashed var(--red);
  background: linear-gradient(135deg, rgba(239,68,68,0.12), rgba(239,68,68,0.04));
  box-shadow: 0 0 32px rgba(239, 68, 68, 0.2), inset 0 0 24px rgba(239,68,68,0.05);
  animation: pulse-red 3s ease-in-out infinite;
}

.alert-banner.warning {
  border-color: var(--yellow);
  background: linear-gradient(135deg, rgba(250,204,21,0.12), rgba(250,204,21,0.04));
  box-shadow: 0 0 28px rgba(250, 204, 21, 0.15);
  animation: pulse-yellow 3s ease-in-out infinite;
}

.status-ok-banner {
  border: 1px solid rgba(34,197,94,0.3);
  background: linear-gradient(135deg, rgba(34,197,94,0.1), transparent);
}

.alert-icon { font-size: 1.4rem; line-height: 1; }

.ok-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
  margin-top: 4px;
  animation: blink 2s ease-in-out infinite;
}

.alert-banner strong,
.status-ok-banner strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.2rem;
}

.alert-banner span,
.status-ok-banner span {
  font-size: 0.78rem;
  color: var(--muted);
}

.alert-banner.hidden,
.status-ok-banner.hidden { display: none; }

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 32px rgba(239,68,68,0.2); }
  50% { box-shadow: 0 0 48px rgba(239,68,68,0.35); }
}

@keyframes pulse-yellow {
  0%, 100% { box-shadow: 0 0 28px rgba(250,204,21,0.15); }
  50% { box-shadow: 0 0 40px rgba(250,204,21,0.28); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Layout */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.75rem;
  padding: 1rem 0 3rem;
}

@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
}

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 1rem;
  font-weight: 600;
}

.section-title.critical {
  color: var(--red-bright);
  text-shadow: 0 0 20px rgba(239,68,68,0.3);
}

.critical-section {
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.critical-section.hidden { display: none; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tab {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover {
  border-color: var(--border-light);
  color: var(--text);
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), #007a2f);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(0,156,59,0.3);
}

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

.cards-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
  .cards-grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .cards-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .cards-grid-4 { grid-template-columns: 1fr; }
}

.card {
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface3) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  opacity: 0.8;
}

.card.online::before { background: var(--green); }
.card.unstable::before { background: var(--yellow); }
.card.offline::before { background: var(--red); }

.card.online {
  border-color: rgba(34,197,94,0.25);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.card.unstable {
  border-color: rgba(250,204,21,0.35);
  box-shadow: 0 0 24px rgba(250,204,21,0.08);
}

.card.offline {
  border-color: rgba(239,68,68,0.4);
  box-shadow: 0 0 28px rgba(239,68,68,0.12);
  animation: card-alert 2.5s ease-in-out infinite;
}

@keyframes card-alert {
  0%, 100% { box-shadow: 0 0 28px rgba(239,68,68,0.12); }
  50% { box-shadow: 0 0 36px rgba(239,68,68,0.22); }
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-light);
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}

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

.card-org {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  flex: 1;
}

.card-org img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  flex-shrink: 0;
  padding: 2px;
}

.card-org-info {
  min-width: 0;
  flex: 1;
}

.card-org h3 {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-org small {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  align-self: flex-start;
}

.badge.online { background: var(--green-dim); color: var(--green-bright); border: 1px solid rgba(34,197,94,0.3); }
.badge.unstable { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(250,204,21,0.3); }
.badge.offline { background: var(--red-dim); color: var(--red-bright); border: 1px solid rgba(239,68,68,0.35); }

.sparkline-wrap {
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  margin: 0.5rem 0 0.65rem;
}

.sparkline {
  width: 100%;
  height: 44px;
  display: block;
}

.card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem 0.25rem;
  font-size: 0.62rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
}

.card-metrics > div {
  min-width: 0;
}

.card-metrics label {
  display: block;
  margin-bottom: 0.15rem;
  line-height: 1.2;
  word-break: break-word;
}

.card-metrics strong {
  display: block;
  color: var(--text);
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
}

.stat-panel {
  background: linear-gradient(180deg, var(--surface2), var(--surface3));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.35rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.stat-item { margin-bottom: 1.1rem; }

.stat-item label {
  font-size: 0.7rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.25rem;
}

.stat-item .value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-item .value.green { color: var(--green-bright); }
.stat-item .value.red { color: var(--red-bright); }

.trend-bar {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.trend-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green-bright));
  border-radius: 999px;
  transition: width 0.5s ease;
}

.stat-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.activity {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.45;
}

.disclaimer {
  margin-top: 1.5rem;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  opacity: 0.8;
}

/* Detail page */
.detail-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 2rem 0 1.5rem;
  flex-wrap: wrap;
}

.detail-hero img {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
  padding: 4px;
}

.detail-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--muted);
}

.contingency {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0 1.5rem;
}

.contingency.hidden { display: none; }
.contingency h3 { color: var(--red-bright); margin-bottom: 0.5rem; }

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  padding-bottom: 3rem;
}

@media (max-width: 860px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.latency-chart { width: 100%; height: 200px; }

.uptime-grid {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 3px;
}

.uptime-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--green-dim);
}

.uptime-cell.warn { background: var(--yellow-dim); }
.uptime-cell.down { background: var(--red-dim); }
.uptime-cell.empty { background: var(--surface3); }

.timeline { list-style: none; }

.timeline li {
  border-left: 2px solid var(--border);
  padding: 0 0 1rem 1rem;
  margin-left: 0.5rem;
  position: relative;
  font-size: 0.85rem;
}

.timeline li::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  position: absolute;
  left: -5px;
  top: 4px;
}

.timeline time {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 1rem 0;
}

.back-link:hover { color: var(--gold); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.site-footer a {
  color: var(--gold);
  margin: 0 0.85rem;
  font-weight: 500;
}

.footer-sub { margin-top: 0.5rem; font-size: 0.72rem; opacity: 0.7; }

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  grid-column: 1 / -1;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  grid-column: 1 / -1;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .container { padding: 0 1rem; }

  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.75rem 0;
  }

  .brand { width: 100%; }
  .brand-text p { max-width: none; font-size: 0.68rem; }

  .nav {
    margin-left: 0;
    justify-content: flex-start;
    gap: 1rem;
    order: 2;
    flex-wrap: wrap;
  }

  .search-box {
    width: 100%;
    order: 3;
  }

  .search-box input {
    width: 100%;
    flex: 1;
    min-width: 0;
  }

  .alert-banner,
  .status-ok-banner {
    padding: 0.85rem 1rem;
    gap: 0.65rem;
  }

  .alert-banner strong,
  .status-ok-banner strong {
    font-size: 0.82rem;
    line-height: 1.35;
  }

  .alert-banner span,
  .status-ok-banner span {
    font-size: 0.72rem;
    line-height: 1.4;
    display: block;
  }

  .main-grid {
    gap: 1.25rem;
    padding: 0.75rem 0 2rem;
  }

  .sidebar { position: static; }

  .stat-item .value { font-size: 1.45rem; }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
    margin-right: -0.5rem;
  }

  .tabs::-webkit-scrollbar { display: none; }

  .tab {
    flex-shrink: 0;
    padding: 0.45rem 0.9rem;
    font-size: 0.72rem;
  }

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

  .card { padding: 0.95rem; }

  .card-metrics {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .card-metrics > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
  }

  .card-metrics label {
    margin-bottom: 0;
    flex: 1;
  }

  .card-metrics strong {
    text-align: right;
    flex-shrink: 0;
    font-size: 0.7rem;
  }

  .site-footer a {
    display: inline-block;
    margin: 0.35rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .brand img { width: 40px; height: 40px; }
  .brand-text h1 { font-size: 1rem; }

  .card-header-top {
    flex-direction: column;
    align-items: stretch;
  }

  .badge { align-self: flex-start; }

  .card-org img { width: 36px; height: 36px; }
  .card-org h3 { font-size: 0.84rem; }

  .stat-panel { padding: 1rem; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .card-metrics strong { font-size: 0.68rem; }
  .card-metrics label { font-size: 0.58rem; }
}
