/* ── Reset & Tokens ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: .2s ease;
  --bar-up:       #22c55e;
  --bar-degraded: #f59e0b;
  --bar-down:     #ef4444;
  --bar-none:     #374151;
}

/* ── Dark theme (default) ───────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0f1117;
  --bg-card:     #161b27;
  --bg-card-2:   #1e2535;
  --border:      #ffffff0f;
  --border-hover:#ffffff1a;
  --text:        #f1f5f9;
  --text-muted:  #64748b;
  --text-sub:    #94a3b8;
  --badge-op-bg: #052e16;
  --badge-op-fg: #4ade80;
  --badge-part-bg:#451a03;
  --badge-part-fg:#fbbf24;
  --badge-maj-bg: #450a0a;
  --badge-maj-fg: #f87171;
  --inc-open-border: #ef4444;
  --inc-res-border:  #22c55e;
  --toggle-bg:   #1e2535;
  --bar-none:    #1e2535;
  --shadow:      0 1px 3px rgba(0,0,0,.5);
}

/* ── Light theme ────────────────────────────────────────── */
[data-theme="light"] {
  --bg:          #f8fafc;
  --bg-card:     #ffffff;
  --bg-card-2:   #f1f5f9;
  --border:      #e2e8f0;
  --border-hover:#cbd5e1;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --text-sub:    #475569;
  --badge-op-bg: #dcfce7;
  --badge-op-fg: #15803d;
  --badge-part-bg:#fef3c7;
  --badge-part-fg:#92400e;
  --badge-maj-bg: #fee2e2;
  --badge-maj-fg: #991b1b;
  --inc-open-border: #ef4444;
  --inc-res-border:  #22c55e;
  --toggle-bg:   #e2e8f0;
  --bar-none:    #e2e8f0;
  --shadow:      0 1px 3px rgba(0,0,0,.08);
}

/* ── Base ───────────────────────────────────────────────── */
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  line-height: 1.5;
}

/* ── Nav ────────────────────────────────────────────────── */
nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.nav-inner {
  max-width: 860px; margin: 0 auto; padding: 0 20px;
  height: 56px; display: flex; align-items: center; gap: 8px;
}
.nav-logo {
  font-weight: 700; font-size: 1rem; color: var(--text);
  text-decoration: none; margin-right: auto; display: flex; align-items: center; gap: 8px;
}
.nav-logo svg { width: 22px; height: 22px; color: #6366f1; }
.nav-links { display: flex; gap: 2px; }
.nav-links a {
  font-size: .8rem; padding: 6px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-weight: 500;
  transition: color var(--transition), background var(--transition);
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg-card-2); }
.theme-toggle {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--toggle-bg); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all var(--transition); margin-left: 8px;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-hover); }

/* ── Hero ───────────────────────────────────────────────── */
.hero { text-align: center; padding: 56px 20px 40px; max-width: 860px; margin: 0 auto; }
.hero-icon {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px; font-size: 1.5rem;
}
.hero-icon-op   { background: #052e16; }
.hero-icon-part { background: #451a03; }
.hero-icon-maj  { background: #450a0a; }
.hero h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 800; letter-spacing: -.02em; }
.hero-updated { margin-top: 10px; font-size: .8rem; color: var(--text-muted); }

/* ── Container ──────────────────────────────────────────── */
.container { max-width: 860px; margin: 0 auto; padding: 0 20px 80px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-label  { font-size: .8rem; font-weight: 600; color: var(--text-muted); }

/* ── Overall badge ──────────────────────────────────────── */
.overall-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 600;
}
.badge-op   { background: var(--badge-op-bg);   color: var(--badge-op-fg); }
.badge-part { background: var(--badge-part-bg); color: var(--badge-part-fg); }
.badge-maj  { background: var(--badge-maj-bg);  color: var(--badge-maj-fg); }
.badge-dot  { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ── Monitor card ───────────────────────────────────────── */
.monitors-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.monitor-row { padding: 16px 20px 0; border-bottom: 1px solid var(--border); }
.monitor-row:last-child { border-bottom: none; padding-bottom: 16px; }
.monitor-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.status-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-up       { background: var(--bar-up);       box-shadow: 0 0 0 3px #16a34a22; }
.dot-degraded { background: var(--bar-degraded); box-shadow: 0 0 0 3px #d9770622; }
.dot-down     { background: var(--bar-down);     box-shadow: 0 0 0 3px #dc262622; }
.dot-unknown  { background: var(--text-muted); }
.monitor-name   { font-weight: 600; font-size: .9rem; flex: 1; }
.monitor-uptime { font-size: .8rem; font-weight: 600; color: var(--bar-up); }
.monitor-uptime.warn { color: var(--bar-degraded); }
.monitor-uptime.bad  { color: var(--bar-down); }
.monitor-meta { font-size: .75rem; color: var(--text-muted); display: flex; gap: 16px; flex-wrap: wrap; padding-bottom: 14px; }

/* ── Uptime bars ────────────────────────────────────────── */
.bars-wrap { margin-bottom: 8px; }
.bars-row  { display: flex; gap: 2px; height: 32px; align-items: stretch; }
.bar { flex: 1; border-radius: 3px; cursor: default; position: relative; transition: opacity .15s; min-width: 0; }
.bar:hover   { opacity: .75; }
.bar-up      { background: var(--bar-up); }
.bar-degraded{ background: var(--bar-degraded); }
.bar-down    { background: var(--bar-down); }
.bar-none    { background: var(--bar-none); }
.bars-label  { display: flex; justify-content: space-between; font-size: .7rem; color: var(--text-muted); padding-top: 4px; margin-bottom: 10px; }

/* ── Tooltip global ─────────────────────────────────────── */
#bar-tooltip {
  position: fixed; display: none;
  background: var(--bg-card); border: 1px solid var(--border-hover);
  border-radius: var(--radius-md); padding: 12px 16px;
  min-width: 170px; max-width: 260px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  z-index: 9999; pointer-events: none;
}
#bar-tooltip::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--border-hover);
}
.tt-date     { font-size: .78rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.tt-incident { font-size: .8rem; color: var(--bar-down); font-weight: 600; white-space: normal; line-height: 1.4; margin-bottom: 6px; }
.tt-incident.degraded { color: var(--bar-degraded); }
.tt-dur-label { font-size: .75rem; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 7px; margin-top: 2px; }
.tt-dur-label strong { color: var(--text); }
.tt-ok   { font-size: .78rem; color: var(--bar-up); font-weight: 500; }
.tt-none { font-size: .78rem; color: var(--text-muted); }

/* ── Incidents ──────────────────────────────────────────── */
.section-gap { margin-top: 32px; }
.incident-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--inc-open-border);
  border-radius: var(--radius-md); padding: 14px 18px;
  margin-bottom: 8px; box-shadow: var(--shadow);
}
.incident-item.resolved { border-left-color: var(--inc-res-border); }
.incident-title { font-weight: 600; font-size: .875rem; margin-bottom: 5px; display: flex; align-items: center; gap: 8px; }
.incident-meta  { font-size: .775rem; color: var(--text-muted); }

/* ── Password gate ──────────────────────────────────────── */
.gate-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 20px;
}
.gate-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 36px;
  width: 100%; max-width: 380px; box-shadow: 0 4px 32px rgba(0,0,0,.3);
  text-align: center;
}
.gate-card h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.gate-card p  { font-size: .875rem; color: var(--text-muted); margin-bottom: 24px; }
.gate-input-wrap { position: relative; margin-bottom: 12px; }
.gate-input {
  width: 100%; padding: 11px 42px 11px 14px;
  background: var(--bg-card-2); border: 1px solid var(--border);
  border-radius: 8px; font-size: .95rem; color: var(--text);
  outline: none; transition: border .2s; font-family: inherit;
}
.gate-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
.gate-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
}
.gate-eye:hover { color: var(--text); }
.gate-btn {
  width: 100%; padding: 11px; background: #6366f1; color: #fff;
  border: none; border-radius: 8px; font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: opacity .2s; font-family: inherit;
}
.gate-btn:hover { opacity: .85; }
.gate-error { color: var(--bar-down); font-size: .82rem; margin-bottom: 10px; }

/* ── Footer ─────────────────────────────────────────────── */
footer { text-align: center; padding: 32px 20px; border-top: 1px solid var(--border); font-size: .78rem; color: var(--text-muted); }
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text); }
.refresh-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: .78rem; font-family: inherit; text-decoration: underline; }
.refresh-btn:hover { color: var(--text); }

/* ── Empty ──────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); font-size: .9rem; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav-links { display: none; }
  .hero { padding: 40px 20px 28px; }
  .monitor-meta { gap: 10px; }
}
