:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #5b6577;
  --border: #e2e6ee;
  --header: #0b1324;
  --accent: #84cc16;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --minor: #eab308;
  --minor-soft: #fef9c3;
  --major: #f97316;
  --down: #dc2626;
  --down-soft: #fee2e2;
  --none: #d5dae3;
  --chart: #2563eb;
  --chart-soft: rgba(37, 99, 235, 0.12);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --card: #131b2e;
    --text: #e6ebf4;
    --muted: #94a0b8;
    --border: #243049;
    --header: #070c18;
    --ok: #22c55e;
    --ok-soft: rgba(34, 197, 94, 0.14);
    --minor: #facc15;
    --minor-soft: rgba(250, 204, 21, 0.14);
    --major: #fb923c;
    --down: #f87171;
    --down-soft: rgba(248, 113, 113, 0.14);
    --none: #2c3850;
    --chart: #60a5fa;
    --chart-soft: rgba(96, 165, 250, 0.16);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3, p { margin: 0; }
ul, dl, dd { margin: 0; padding: 0; list-style: none; }
.muted { color: var(--muted); font-weight: 400; }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { background: var(--header); border-bottom: 3px solid var(--accent); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { height: 52px; width: auto; display: block; }
.brand-sub { font-size: 15px; font-weight: 600; color: #cbd5e1; border-left: 1px solid #334155; padding-left: 12px; }
.updated { color: #94a3b8; font-size: 13px; text-align: right; }

main.wrap { padding-top: 24px; padding-bottom: 40px; }

/* banner */
.banner {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 22px; border-radius: 14px; color: #fff;
  background: var(--muted); box-shadow: var(--shadow);
}
/* Fixed shades, not the theme tokens: white text needs the darker tone in both themes. */
.banner.up { background: #15803d; }
.banner.degraded { background: #a16207; }
.banner.down { background: #b91c1c; }
.banner h1 { font-size: 21px; line-height: 1.3; }
.banner p { opacity: 0.92; font-size: 14px; margin-top: 2px; }
.banner-icon {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.22); display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
}
.banner.up .banner-icon::before { content: "✓"; }
.banner.degraded .banner-icon::before { content: "!"; }
.banner.down .banner-icon::before { content: "✕"; }
.banner.unknown .banner-icon::before { content: "?"; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat-sub { font-size: 12px; color: var(--muted); }

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

.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 5px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* components */
.comp { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.comp:last-child { border-bottom: 0; }
.comp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.comp h3 { font-size: 15px; }
.comp-desc { font-size: 13px; color: var(--muted); }
.comp-right { display: flex; align-items: center; gap: 10px; flex: none; }
.comp-ms { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pill {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--none); color: var(--text);
}
.pill.up { background: var(--ok-soft); color: var(--ok); }
.pill.degraded { background: var(--minor-soft); color: #a16207; }
.pill.down { background: var(--down-soft); color: var(--down); }
@media (prefers-color-scheme: dark) { .pill.degraded { color: var(--minor); } }
.comp-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.comp-meta b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.bars { display: flex; gap: 2px; height: 34px; margin-top: 12px; }
.bar {
  flex: 1 1 0; min-width: 0; border-radius: 2px; background: var(--none); cursor: default;
  transition: opacity 0.15s;
}
.bar:hover, .bar:focus-visible { opacity: 0.7; outline: none; }
.bar:focus-visible { box-shadow: 0 0 0 2px var(--text); }
.lvl-ok { background: var(--ok); }
.lvl-minor { background: var(--minor); }
.lvl-major { background: var(--major); }
.lvl-down { background: var(--down); }
.lvl-none { background: var(--none); }
.bars-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.bars-foot .rule { flex: 1; height: 1px; background: var(--border); }
.short { display: none; }

/* chart */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg); padding: 3px; border-radius: 9px; }
.tab {
  font: inherit; font-size: 13px; font-weight: 600; border: 0; border-radius: 7px; padding: 5px 11px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.tab:focus-visible { outline: 2px solid var(--chart); outline-offset: 1px; }
.chart-stats { display: flex; flex-wrap: wrap; gap: 6px 28px; padding: 14px 20px 0; }
.chart-stats div { display: flex; flex-direction: column; }
.chart-stats dt { font-size: 12px; color: var(--muted); }
.chart-stats dd { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart { padding: 8px 12px 14px 8px; position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--chart-soft); stroke: none; }
.chart .cross { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .dot { fill: var(--chart); stroke: var(--card); stroke-width: 2; }
.chart .gap { fill: var(--down-soft); }
.chart-empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* incidents */
.incidents li { display: flex; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.incidents li:last-child { border-bottom: 0; }
.inc-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--down); margin-top: 6px; }
.inc-dot.resolved { background: var(--muted); }
.inc-title { font-weight: 600; font-size: 14px; }
.inc-meta { font-size: 13px; color: var(--muted); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  margin-left: 6px; vertical-align: 1px;
}
.badge.live { background: var(--down-soft); color: var(--down); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.incidents .empty { color: var(--muted); font-size: 14px; display: block; }

.foot { color: var(--muted); font-size: 13px; text-align: center; margin-top: 24px; }

/* tooltip */
.tip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 240px;
  background: var(--header); color: #e2e8f0; border-radius: 8px; padding: 8px 10px;
  font-size: 12px; line-height: 1.45; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.tip strong { color: #fff; display: block; font-size: 13px; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 22px; }
}
@media (max-width: 560px) {
  .top-in { min-height: 60px; }
  .brand img { height: 40px; }
  .brand-sub { font-size: 13px; padding-left: 10px; }
  .updated { display: none; }
  .banner { padding: 16px; gap: 12px; }
  .banner h1 { font-size: 18px; }
  .comp, .card-head, .incidents li { padding-left: 16px; padding-right: 16px; }
  .comp-head { flex-direction: column; gap: 6px; }
  /* 30 days on a phone: 90 bars would be hairlines. */
  .bar:nth-child(-n+60) { display: none; }
  .long { display: none; }
  .short { display: inline; }
}
@media (prefers-reduced-motion: reduce) { .bar { transition: none; } }
