:root {
  --bg: #fafafa; --card: #ffffff; --border: #e9e9ee; --text: #111114; --muted: #676772; --faint: #9a9aa6;
  --ok: #22a55b; --ok-soft: #7fcf9d; --warn: #e5a00d; --bad: #e5484d; --info: #3e63dd; --power: #f76b15;
  --empty: #e7e7ec; --hover: #f4f4f6; --shadow: 0 1px 2px rgba(16, 16, 20, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0d; --card: #131316; --border: #24242a; --text: #ededf0; --muted: #a0a0ab; --faint: #6e6e7a;
    --ok: #30b867; --ok-soft: #2c7a4c; --warn: #f0b429; --bad: #f2555a; --info: #6e8bff; --power: #ff8a3d;
    --empty: #25252b; --hover: #1a1a1f; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0d; --card: #131316; --border: #24242a; --text: #ededf0; --muted: #a0a0ab; --faint: #6e6e7a;
  --ok: #30b867; --ok-soft: #2c7a4c; --warn: #f0b429; --bad: #f2555a; --info: #6e8bff; --power: #ff8a3d;
  --empty: #25252b; --hover: #1a1a1f; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand .sep { color: var(--faint); font-weight: 400; }
.brand .muted { font-weight: 500; }
.mark { width: 18px; height: 18px; border-radius: 5px; background: var(--text); position: relative; }
.mark::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--bg); }
.top-right { display: flex; align-items: center; gap: 12px; }
.updated { font-size: 12px; color: var(--faint); }
.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: var(--hover); }

.notice {
  border: 1px solid var(--border); border-left: 3px solid var(--warn); background: var(--card);
  padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13px;
}

/* hero */
.hero {
  --c: var(--faint);
  display: flex; gap: 16px; align-items: center; padding: 20px; margin-bottom: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.hero[data-state="operational"] { --c: var(--ok); }
.hero[data-state="degraded"] { --c: var(--warn); }
.hero[data-state="unreachable"], .hero[data-state="down"] { --c: var(--bad); }
.hero[data-state="power_cut"] { --c: var(--power); }
.hero[data-state="planned"], .hero[data-state="maintenance"] { --c: var(--info); }
.hero p { margin: 2px 0 0; font-size: 13px; }
.hero-dot { position: relative; width: 36px; height: 36px; flex: none; display: grid; place-items: center; }
.hero-dot::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--c); opacity: .14; }
.hero-dot span { width: 12px; height: 12px; border-radius: 50%; background: var(--c); position: relative; }
.hero-dot span::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--c);
  animation: ping 2.4s cubic-bezier(0, 0, .2, 1) infinite;
}
.hero[data-state="loading"] .hero-dot span::after { animation: none; }
@keyframes ping { 75%, 100% { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .hero-dot span::after { animation: none; } }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; gap: 12px; }

/* components + uptime bars */
.comp { padding: 12px 0; border-top: 1px solid var(--border); }
.comp:first-child { border-top: 0; padding-top: 0; }
.comp-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.comp-name { display: flex; align-items: center; gap: 8px; font-weight: 500; min-width: 0; }
.comp-name .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.comp-name .sub { color: var(--faint); font-weight: 400; font-size: 12px; white-space: nowrap; }
.comp-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.pct { font-size: 12px; color: var(--muted); }
.pill { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 99px; background: var(--hover); color: var(--muted); }
.pill.up { color: var(--ok); } .pill.down, .pill.unreachable { color: var(--bad); }
.pill.power_cut { color: var(--power); } .pill.planned, .pill.maintenance { color: var(--info); }
.bars { display: flex; gap: 2px; height: 30px; }
.bar { flex: 1; min-width: 2px; border-radius: 2px; background: var(--empty); cursor: default; outline: none; transition: opacity .1s; }
.bar.ok { background: var(--ok); } .bar.ok2 { background: var(--ok-soft); }
.bar.warn { background: var(--warn); } .bar.bad { background: var(--bad); }
.bars:hover .bar { opacity: .55; } .bars .bar:hover, .bars .bar:focus-visible { opacity: 1; }
.legend { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 8px; }
.legend-keys { display: flex; align-items: center; gap: 4px; }
.k { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin: 0 2px 0 8px; }
.k-ok { background: var(--ok); } .k-warn { background: var(--warn); } .k-bad { background: var(--bad); } .k-empty { background: var(--empty); }

/* metrics */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric.hot { border-color: var(--warn); }
.metric.hot .val { color: var(--warn); }
.hot-tag { font-size: 10px; font-weight: 600; color: var(--warn); text-transform: uppercase; letter-spacing: .04em; margin-left: 4px; }
.lat { display: inline-block; width: 64px; height: 18px; margin-right: 10px; vertical-align: middle; opacity: .8; }
.lat svg { display: block; width: 100%; height: 100%; overflow: visible; }
.metric { border: 1px solid var(--border); border-radius: 10px; padding: 12px 12px 8px; min-width: 0; }
.metric .label { font-size: 12px; color: var(--muted); }
.metric .val { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin: 2px 0 4px; }
.metric .val small { font-size: 12px; font-weight: 500; color: var(--faint); margin-left: 2px; }
.metric svg { display: block; width: 100%; height: 34px; overflow: visible; }
.metric .range { font-size: 11px; color: var(--faint); display: flex; justify-content: space-between; }
.spark-line { fill: none; stroke: var(--text); stroke-width: 1.4; vector-effect: non-scaling-stroke; opacity: .75; }
.spark-area { fill: var(--text); opacity: .06; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; }
.facts span { white-space: nowrap; }
.facts b { color: var(--text); font-weight: 500; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-day { font-size: 12px; color: var(--faint); font-weight: 500; padding: 12px 0 6px; }
.tl-day:first-child { padding-top: 0; }
.tl-item { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; padding: 6px 0; }
.tl-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--c, var(--muted)); position: relative; }
.tl-ico::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor; opacity: .12; }
.tl-ico svg { width: 12px; height: 12px; position: relative; }
.tl-msg { font-size: 13px; }
.tl-msg .sub { display: block; color: var(--faint); font-size: 12px; }
.tl-time { font-size: 12px; color: var(--faint); white-space: nowrap; padding-top: 2px; }
.more {
  margin-top: 10px; width: 100%; padding: 8px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
}
.more:hover { background: var(--hover); color: var(--text); }
.empty { color: var(--faint); font-size: 13px; padding: 8px 0; }

footer { margin-top: 24px; text-align: center; line-height: 1.7; }

/* tooltip */
.tip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 240px;
  background: var(--text); color: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
.tip b { display: block; font-weight: 600; margin-bottom: 2px; }
.tip .ev { opacity: .75; margin-top: 4px; }

@media (max-width: 640px) {
  .lat { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .bars .bar:nth-child(-n+45) { display: none; }
  .legend-keys { display: none; }
  .comp-name .sub { display: none; }
  .hero { padding: 16px; }
  .card { padding: 16px; }
}
