:root {
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --brand: #1d4ed8;
  --brand-soft: #dbeafe;
  --ok: #10b981;
  --ok-soft: #d1fae5;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --bad: #ef4444;
  --bad-soft: #fee2e2;
  --unknown: #cbd5e1;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px -12px rgba(15, 23, 42, .18);
  --page-max: 880px;
  --bar-w: 6px;
  --bar-gap: 3px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-alt: #0f1a2e;
    --surface: #111a2e;
    --border: #1e293b;
    --border-strong: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-soft: #64748b;
    --brand: #60a5fa;
    --brand-soft: #1e3a8a;
    --ok-soft: rgba(16, 185, 129, .18);
    --warn-soft: rgba(245, 158, 11, .18);
    --bad-soft: rgba(239, 68, 68, .2);
    --unknown: #334155;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 10px 30px -12px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.page-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.page-header__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__logo { height: 28px; width: auto; display: block; }
.brand__sub {
  color: var(--text-muted); font-weight: 500; font-size: 13px;
  padding-left: 10px; border-left: 1px solid var(--border);
  line-height: 1;
}
.header-nav { display: flex; gap: 22px; align-items: center; }
.header-nav__link {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}
.header-nav__link:hover { color: var(--text); text-decoration: none; }
@media (max-width: 640px) { .header-nav { gap: 14px; } .header-nav__link { font-size: 12px; } }

.page-intro { margin-bottom: 18px; }
.lede {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 620px;
}
.lede a { color: var(--text); border-bottom: 1px dotted var(--text-muted); }
.lede a:hover { color: var(--brand); text-decoration: none; border-bottom-color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer; user-select: none;
}
.btn--ghost {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--surface);
}
.btn--ghost:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }

.page {
  max-width: var(--page-max);
  margin: 32px auto 48px;
  padding: 0 24px;
}

.status-hero {
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.status-hero[data-state="operational"] { background: linear-gradient(180deg, var(--ok-soft), var(--surface)); }
.status-hero[data-state="partial_outage"] { background: linear-gradient(180deg, var(--warn-soft), var(--surface)); }
.status-hero[data-state="major_outage"] { background: linear-gradient(180deg, var(--bad-soft), var(--surface)); }

.status-hero__pill { display: flex; align-items: center; gap: 12px; }
.status-hero__dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--unknown);
  box-shadow: 0 0 0 4px rgba(148, 163, 184, .18);
}
.status-hero__dot[data-state="operational"]    { background: var(--ok);   box-shadow: 0 0 0 5px rgba(16,185,129,.18); }
.status-hero__dot[data-state="partial_outage"] { background: var(--warn); box-shadow: 0 0 0 5px rgba(245,158,11,.2); }
.status-hero__dot[data-state="major_outage"]   { background: var(--bad);  box-shadow: 0 0 0 5px rgba(239,68,68,.2); }
.status-hero__label { font-size: 18px; font-weight: 600; }
.status-hero__meta { margin: 0; color: var(--text-muted); font-size: 13px; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.groups { display: flex; flex-direction: column; gap: 18px; }
.group {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.group__header {
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.group__title { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.group__uptime { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.group__services { list-style: none; padding: 0; margin: 0; }
.svc { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.svc:last-child { border-bottom: 0; }

.svc__head {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.svc__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--unknown);
}
.svc__dot[data-state="operational"] { background: var(--ok); }
.svc__dot[data-state="degraded"], .svc__dot[data-state="minor"] { background: var(--warn); }
.svc__dot[data-state="down"], .svc__dot[data-state="major"] { background: var(--bad); }
.svc__dot[data-state="maintenance"] { background: var(--brand); }
.svc__status[data-state="maintenance"] { color: var(--brand); border-color: rgba(29,78,216,.4); }

.maint-banner {
  border: 1px solid var(--border);
  background: var(--brand-soft);
  color: var(--text);
  padding: 14px 18px;
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}
.maint-banner__title { font-weight: 600; display: block; margin-bottom: 4px; }
.maint-banner__meta { color: var(--text-muted); font-size: 12px; margin-top: 6px; }
.maint-banner + .maint-banner { margin-top: -8px; }

.svc__name { font-size: 14px; font-weight: 500; }
.svc__status {
  font-size: 12px; color: var(--text-muted);
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border);
}
.svc__status[data-state="operational"] { color: var(--ok);   border-color: rgba(16,185,129,.35); }
.svc__status[data-state="degraded"], .svc__status[data-state="minor"] { color: var(--warn); border-color: rgba(245,158,11,.4); }
.svc__status[data-state="down"], .svc__status[data-state="major"] { color: var(--bad); border-color: rgba(239,68,68,.4); }
.svc__uptime { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.svc__bars {
  display: grid;
  grid-template-columns: repeat(90, var(--bar-w));
  gap: var(--bar-gap);
  justify-content: space-between;
  width: 100%;
  height: 34px;
  padding: 4px 0;
}
.bar {
  width: var(--bar-w);
  height: 100%;
  border-radius: 2px;
  background: var(--unknown);
  cursor: pointer;
  transition: transform 80ms ease;
}
.bar:hover { transform: scaleY(1.15); }
.bar[data-tier="0"] { background: var(--unknown); }
.bar[data-tier="1"] { background: var(--ok); }
.bar[data-tier="2"] { background: var(--warn); }
.bar[data-tier="3"] { background: #fb923c; }
.bar[data-tier="4"] { background: var(--bad); }

.svc__axis {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-soft);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.incidents { margin-top: 40px; }
.incident-list { list-style: none; padding: 0; margin: 0; }
.incident {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 14px;
  align-items: baseline;
}
.incident:last-child { border-bottom: 0; }
.incident__date { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.incident__title { font-size: 14px; color: var(--text); }
.incident__badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border);
}
.incident__badge[data-status="open"] { color: var(--bad); border-color: rgba(239,68,68,.4); background: var(--bad-soft); }
.incident__badge[data-status="resolved"] { color: var(--ok); border-color: rgba(16,185,129,.35); background: var(--ok-soft); }

.incident-empty { color: var(--text-muted); font-size: 13px; padding: 12px 0; }

.incident-list a.incident { color: inherit; text-decoration: none; }
.incident-list a.incident:hover .incident__title { color: var(--brand); }
.incident-loading { color: var(--text-muted); }

.back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--text-muted);
  font-size: 13px;
}
.back-link:hover { color: var(--brand); text-decoration: none; }

.incident-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  box-shadow: var(--shadow);
}
.incident-detail__head { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.incident-detail__title { margin: 10px 0 6px; font-size: 22px; letter-spacing: -0.01em; }
.incident-detail__meta { margin: 0; font-size: 13px; color: var(--text-muted); }
.incident-detail__meta strong { color: var(--text); font-weight: 600; }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--border);
}
.timeline__item { position: relative; padding: 4px 0 22px 30px; }
.timeline__marker {
  position: absolute;
  left: 0; top: 6px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--text-soft);
}
.timeline__item[data-status="INVESTIGATING"] .timeline__marker { border-color: var(--bad); }
.timeline__item[data-status="IDENTIFIED"]    .timeline__marker { border-color: var(--warn); }
.timeline__item[data-status="MONITORING"]    .timeline__marker { border-color: var(--brand); }
.timeline__item[data-status="RESOLVED"]      .timeline__marker { border-color: var(--ok); }
.timeline__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.timeline__status { font-weight: 600; font-size: 14px; }
.timeline__item[data-status="INVESTIGATING"] .timeline__status { color: var(--bad); }
.timeline__item[data-status="IDENTIFIED"]    .timeline__status { color: var(--warn); }
.timeline__item[data-status="MONITORING"]    .timeline__status { color: var(--brand); }
.timeline__item[data-status="RESOLVED"]      .timeline__status { color: var(--ok); }
.timeline__time { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.timeline__body { font-size: 14px; color: var(--text); line-height: 1.55; }
.timeline__body code { background: var(--bg-alt); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12.5px; }

.page-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.page-footer__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 24px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.page-footer .dot { color: var(--text-soft); }
.page-footer a { color: var(--text-muted); }
.page-footer a:hover { color: var(--text); }

.tooltip {
  position: fixed;
  z-index: 30;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
  transform: translate(-50%, -110%);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}

@media (max-width: 640px) {
  :root { --bar-w: 4px; --bar-gap: 2px; }
  .page { padding: 0 14px; }
  .status-hero { flex-direction: column; align-items: flex-start; padding: 18px; }
  .svc__head { grid-template-columns: 10px 1fr auto; }
  .svc__status { display: none; }
  .svc__bars { grid-template-columns: repeat(90, minmax(0, 1fr)); }
}
