:root {
  --bg: #f6f8fa;
  --card: #ffffff;
  --border: #e4e8ee;
  --text: #1a2027;
  --muted: #6b7785;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);

  --op: #1faa5e;       /* operational green */
  --op-bg: #e7f7ee;
  --deg: #e0a116;      /* degraded amber */
  --deg-bg: #fcf3da;
  --part: #e8821e;     /* partial orange */
  --part-bg: #fdeede;
  --maj: #d8442f;      /* major red */
  --maj-bg: #fbe6e2;
  --unknown: #9aa5b1;
  --unknown-bg: #eef1f4;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --card: #161b22;
  --border: #232a33;
  --text: #e6edf3;
  --muted: #8b97a5;
  --shadow: none;
  --op-bg: #0f2a1c;
  --deg-bg: #2b2410;
  --part-bg: #2e1f10;
  --maj-bg: #2c1512;
  --unknown-bg: #1c232c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 880px; margin: 0 auto; padding: 0 20px; }

/* ---- Top bar ---- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark {
  font-weight: 800; font-size: 18px; letter-spacing: -0.5px;
  background: var(--text); color: var(--card); padding: 2px 7px; border-radius: 6px;
}
.brand-name { font-weight: 600; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.topbar-link:hover { color: var(--text); }
.theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 16px;
}

/* ---- Hero ---- */
.hero {
  display: flex; align-items: center; gap: 16px;
  margin: 28px 0; padding: 24px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); box-shadow: var(--shadow);
}
.hero-icon { width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto; }
.hero h1 { margin: 0; font-size: 22px; }
.hero .muted { margin: 2px 0 0; font-size: 14px; }
.hero.op { background: var(--op-bg); border-color: var(--op); }
.hero.op .hero-icon { background: var(--op); }
.hero.deg { background: var(--deg-bg); border-color: var(--deg); }
.hero.deg .hero-icon { background: var(--deg); }
.hero.part { background: var(--part-bg); border-color: var(--part); }
.hero.part .hero-icon { background: var(--part); }
.hero.maj { background: var(--maj-bg); border-color: var(--maj); }
.hero.maj .hero-icon { background: var(--maj); }
.hero.unknown .hero-icon { background: var(--unknown); }

/* ---- Cards ---- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  margin-bottom: 24px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }

/* ---- Legend ---- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.op { background: var(--op); }
.dot.deg { background: var(--deg); }
.dot.part { background: var(--part); }
.dot.maj { background: var(--maj); }
.dot.unknown { background: var(--unknown); }

/* ---- Services ---- */
.services { display: flex; flex-direction: column; }
.svc-group-label {
  padding: 12px 20px 4px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted);
}
.svc {
  padding: 16px 20px; border-top: 1px solid var(--border);
}
.svc:first-child { border-top: none; }
.svc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.svc-name { display: flex; align-items: center; gap: 9px; font-weight: 500; font-size: 15px; }
.svc-name a { color: var(--text); text-decoration: none; }
.svc-name a:hover { text-decoration: underline; }
.svc-status { font-size: 13px; font-weight: 600; }
.svc-status.op { color: var(--op); }
.svc-status.deg { color: var(--deg); }
.svc-status.part { color: var(--part); }
.svc-status.maj { color: var(--maj); }
.svc-status.unknown { color: var(--unknown); }
.svc-meta { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px; }

/* Small "Hosted on X" chip next to a service name. */
.provider-tag {
  font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 1px 8px; letter-spacing: 0.2px;
}

/* Likely-upstream banner shown under a service when its provider is down. */
.upstream-note {
  margin: 0 0 10px; padding: 8px 12px; font-size: 13px;
  border-radius: 8px; border: 1px solid var(--part);
  background: var(--part-bg); color: var(--text);
}
.upstream-note a { color: inherit; font-weight: 600; white-space: nowrap; }

/* ---- 90-day uptime bars ---- */
.bars { display: flex; gap: 2px; height: 34px; align-items: stretch; }
.bar {
  flex: 1 1 0; border-radius: 2px; min-width: 2px;
  background: var(--unknown-bg);
}
.bar.op { background: var(--op); }
.bar.deg { background: var(--deg); }
.bar.part { background: var(--part); }
.bar.maj { background: var(--maj); }
.bar.unknown { background: var(--unknown-bg); }
.bar:hover { filter: brightness(1.1); outline: 1px solid var(--text); }

.uptime-scale {
  display: flex; justify-content: space-between;
  padding: 8px 20px 16px; font-size: 11px; margin: 0;
}
.uptime-scale span:nth-child(2) { font-weight: 600; }

/* ---- Incidents ---- */
.active-incidents { margin-bottom: 24px; display: flex; flex-direction: column; gap: 12px; }
.incident-banner {
  border-radius: 12px; padding: 16px 20px; border: 1px solid;
}
.incident-banner.deg { background: var(--deg-bg); border-color: var(--deg); }
.incident-banner.part { background: var(--part-bg); border-color: var(--part); }
.incident-banner.maj { background: var(--maj-bg); border-color: var(--maj); }
.incident-banner h3 { margin: 0 0 4px; font-size: 16px; }
.incident-banner .ib-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.incident-banner .ib-meta a { color: inherit; font-weight: 600; }

/* "Auto-detected" chip on machine-generated incidents. */
.auto-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); border: 1px solid var(--border); border-radius: 20px;
  padding: 1px 7px; vertical-align: middle; white-space: nowrap;
}

.incident-history { padding: 4px 20px 12px; }
.incident-item { padding: 16px 0; border-bottom: 1px solid var(--border); }
.incident-item:last-child { border-bottom: none; }
.incident-item h4 { margin: 0 0 4px; font-size: 15px; }
.incident-date { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.update { display: flex; gap: 10px; padding: 6px 0; font-size: 13px; }
.update-badge {
  flex: 0 0 auto; font-size: 11px; font-weight: 700; text-transform: uppercase;
  padding: 1px 8px; border-radius: 20px; height: fit-content; letter-spacing: 0.4px;
}
.update-badge.investigating { background: var(--maj-bg); color: var(--maj); }
.update-badge.identified { background: var(--part-bg); color: var(--part); }
.update-badge.monitoring { background: var(--deg-bg); color: var(--deg); }
.update-badge.resolved { background: var(--op-bg); color: var(--op); }
.update-body { flex: 1; }
.update-time { color: var(--muted); font-size: 12px; }
.empty { padding: 20px; color: var(--muted); text-align: center; font-size: 14px; }

/* ---- Past incidents (day-grouped history) ---- */
.incident-day { padding: 16px 20px; border-top: 1px solid var(--border); }
.incident-day:first-child { border-top: none; }
.incident-day-head {
  margin: 0 0 12px; padding-bottom: 10px;
  font-size: 15px; font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.empty-day { margin: 0; font-size: 14px; color: var(--muted); }
.past-incident { padding-bottom: 4px; }
.past-incident + .past-incident {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.incident-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.incident-title.op { color: var(--op); }
.incident-title.deg { color: var(--deg); }
.incident-title.part { color: var(--part); }
.incident-title.maj { color: var(--maj); }
.incident-update { padding: 5px 0; font-size: 14px; }
.incident-update .u-status { font-weight: 700; }
.incident-update .update-time { margin-top: 2px; }
.show-more-wrap { padding: 16px 20px; text-align: center; border-top: 1px solid var(--border); }
.show-more {
  background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.show-more:hover { background: var(--bg); }

.muted { color: var(--muted); }
.footer {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 0 48px; font-size: 12px; text-align: center; align-items: center;
}

@media (max-width: 560px) {
  .legend { display: none; }
  .bars { height: 28px; }
  .svc-top { flex-wrap: wrap; gap: 4px; }
}
