:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-track: #cde2fb;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --maint: #2a78d6;
  --nodata: #e1e0d9;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04);
  --tooltip-bg: #1a1a19;
  --tooltip-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-track: #1c3a5e;
    --nodata: #2c2c2a;
    --shadow: none;
    --tooltip-bg: #fcfcfb;
    --tooltip-ink: #0b0b0b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --hairline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-track: #1c3a5e;
  --nodata: #2c2c2a;
  --shadow: none;
  --tooltip-bg: #fcfcfb;
  --tooltip-ink: #0b0b0b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans KR", sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 920px; margin: 0 auto; padding: 28px 20px 56px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 18px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--st, var(--muted)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--st, var(--muted)) 22%, transparent); flex: none; }
.badge { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; padding: 2px 6px; border-radius: 4px; background: var(--warning); color: #0b0b0b; flex: none; }
.top-right { display: flex; align-items: center; gap: 10px; flex: none; }
.updated { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .moon { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .sun { display: none; }
  :root:not([data-theme="light"]) .icon-btn .moon { display: block; }
}

/* status banner */
.banner {
  --st: var(--muted);
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; border-radius: 12px; margin-bottom: 28px;
  background: color-mix(in srgb, var(--st) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--st) 40%, transparent);
}
.banner[data-status="operational"] { --st: var(--good); }
.banner[data-status="degraded"] { --st: var(--warning); }
.banner[data-status="outage"] { --st: var(--critical); }
.banner[data-status="maintenance"] { --st: var(--maint); }
.banner[data-status="unknown"] { --st: var(--muted); }
.banner-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--st); color: #fff; flex: none; }
.banner-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.banner-title { font-size: 18px; font-weight: 600; line-height: 1.3; }
.banner-sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

/* sections */
.section { margin-bottom: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); margin-bottom: 10px; }
.section-hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }

/* host tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
/* disks (SMART) card */
.disk { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; grid-template-areas: "ic name temp life"; align-items: center; gap: 2px 14px; padding: 13px 16px; border-top: 1px solid var(--hairline); }
.disk:first-child { border-top: 0; }
.disk .ic { grid-area: ic; display: grid; place-items: center; width: 26px; height: 26px; color: var(--muted); }
.disk .ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.disk .name { grid-area: name; min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.disk .name b { font-weight: 600; font-size: 14px; }
.disk .name .meta-txt { font-size: 12px; color: var(--muted); white-space: nowrap; }
.disk .name .pill { font-size: 12px; }
.disk .metric { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.disk .metric .n { font-size: 14px; font-weight: 600; }
.disk .metric .k { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.disk .temp { grid-area: temp; }
.disk .life { grid-area: life; min-width: 3.4em; }
.disk .metric.warning .n { color: var(--warning); }
.disk .metric.critical .n { color: var(--critical); }
.disk-toggle { display: block; width: 100%; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 12px; cursor: pointer; }
.disk-toggle:hover, .disk-toggle:focus-visible { color: var(--ink); border-color: var(--muted); outline: none; }
@media (max-width: 640px) {
  .disk { grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 2px 10px; }
  .disk .life { min-width: 2.8em; }
}
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile .label { font-size: 12px; color: var(--ink-2); }
.tile .value { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .value small { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.meta b { font-weight: 500; color: var(--ink-2); }

/* meters */
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.meter { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.meter-head .label { font-size: 12px; color: var(--ink-2); }
.meter-head .value { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.meter-head .value small { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.track { height: 6px; border-radius: 3px; background: var(--accent-track); margin-top: 10px; overflow: hidden; }
.fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width 600ms ease; }
.meter[data-sev="warning"] .track { background: color-mix(in srgb, var(--warning) 25%, var(--surface)); }
.meter[data-sev="warning"] .fill { background: var(--warning); }
.meter[data-sev="critical"] .track { background: color-mix(in srgb, var(--critical) 25%, var(--surface)); }
.meter[data-sev="critical"] .fill { background: var(--critical); }
.meter .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.spark { position: relative; height: 56px; margin-top: 10px; }
.spark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.spark .area { fill: var(--accent); opacity: 0.10; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .end { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.spark .cross { stroke: var(--muted); stroke-width: 1; opacity: 0; }
.spark .hover-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; opacity: 0; }
.spark.active .cross, .spark.active .hover-dot { opacity: 1; }
.spark .grid { stroke: var(--hairline); stroke-width: 1; }
.spark-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* services */
.service { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name status" "days days" "foot foot"; gap: 6px 16px; padding: 16px 18px; border-top: 1px solid var(--hairline); }
.service:first-child { border-top: 0; }
.service .name { grid-area: name; min-width: 0; }
.service .name b { font-weight: 600; font-size: 15px; }
.service .name span { display: block; font-size: 12px; color: var(--muted); }
.service .status { grid-area: status; }
.service .days { grid-area: days; }
.service .foot { grid-area: foot; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.pill svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--st); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pill[data-s="operational"] { --st: var(--good); }
.pill[data-s="degraded"] { --st: var(--warning); }
.pill[data-s="outage"] { --st: var(--critical); }
.pill[data-s="maintenance"] { --st: var(--maint); }
.pill[data-s="unknown"] { --st: var(--muted); }
.pill .sub { font-weight: 400; color: var(--muted); }
.days { display: flex; gap: 3px; height: 30px; margin-top: 6px; }
.day { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--nodata); cursor: default; }
.day[data-s="operational"] { background: var(--good); }
.day[data-s="degraded"] { background: var(--warning); }
.day[data-s="outage"] { background: var(--critical); }
.day:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--nodata); }
.sw[data-s="operational"] { background: var(--good); }
.sw[data-s="degraded"] { background: var(--warning); }
.sw[data-s="outage"] { background: var(--critical); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.guests { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.chip b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* prometheus tiles */
.meter .value.num { font-size: 20px; }
.meter .unit { font-size: 12px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }

/* grafana embed */
.section-link { font-size: 12px; color: var(--accent); text-decoration: none; margin-bottom: 10px; }
.section-link:hover { text-decoration: underline; }
.embed { background: var(--surface); }
.embed iframe { display: block; width: 100%; border: 0; height: var(--h, 520px); }
.foot a { color: inherit; }

/* incidents */
.incident { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; box-shadow: var(--shadow); }
.incident-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.incident-head b { font-size: 15px; font-weight: 600; }
.incident-head .date { font-size: 12px; color: var(--muted); }
.incident ul { list-style: none; margin: 8px 0 0; padding: 0; }
.incident li { display: grid; grid-template-columns: 5.5em 1fr; gap: 10px; font-size: 13px; padding: 4px 0; color: var(--ink-2); }
.incident li time { color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--st) 15%, var(--surface)); color: var(--ink); --st: var(--muted); }
.tag[data-s="resolved"] { --st: var(--good); }
.tag[data-s="monitoring"] { --st: var(--accent); }
.tag[data-s="investigating"], .tag[data-s="identified"] { --st: var(--warning); }

/* footer & misc */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--hairline); padding-top: 16px; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }
.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--tooltip-bg); color: var(--tooltip-ink);
  font-size: 12px; line-height: 1.4; padding: 6px 9px; border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); max-width: 240px; white-space: nowrap;
}
.tooltip b { font-weight: 600; }
.tooltip .dim { opacity: 0.7; }

@media (max-width: 640px) {
  .wrap { padding: 20px 14px 40px; }
  .top { flex-wrap: wrap; }
  .brand { flex: 1 1 100%; }
  .brand h1 { white-space: normal; }
  .top-right { margin-left: auto; }
  .banner-title { font-size: 16px; }
  .day:nth-child(-n+30) { display: none; }   /* 60 days on phones */
}
@media (max-width: 420px) {
  .day:nth-child(-n+60) { display: none; }   /* 30 days on small phones */
}
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }
