:root {
  --bg: #131722; --panel: #1e222d; --line: #2a2e39; --hover: #2a2e39; --text: #d1d4dc; --muted: #787b86;
  --up: #26a69a; --down: #ef5350; --accent: #2962ff; --warn: #f7a600;
  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.45 -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.num, .cquote, .row .val, .row .chg, .legend, .heat { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; }
.brand span { color: var(--muted); font-weight: 400; margin-left: 8px; }
.stamp { color: var(--muted); font-size: 12px; text-align: right; }
.stamp.stale { color: var(--warn); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); }
.chartpane { min-width: 0; scroll-margin-top: 48px; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .watch { border-left: 1px solid var(--line); position: sticky; top: 45px; max-height: calc(100vh - 45px); overflow-y: auto; }
}

.alerts { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 0; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 4px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.chip.warn { color: var(--warn); border-color: rgba(247, 166, 0, .45); }
.chip.fail { color: var(--down); border-color: rgba(239, 83, 80, .45); }

.chead { padding: 12px 16px 2px; }
.cname { font-size: 18px; font-weight: 700; }
.cgroup { color: var(--muted); font-size: 12px; margin-left: 8px; }
.cquote { margin-top: 2px; font-size: 24px; font-weight: 700; }
.cquote .chg { font-size: 14px; font-weight: 600; margin-left: 8px; }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 16px; }
.tabs button { padding: 4px 10px; border-radius: 4px; color: var(--muted); font-size: 13px; }
.tabs button.on { background: var(--panel); color: var(--text); }

.chartbox { position: relative; height: 340px; margin: 0 8px; }
.chart { position: absolute; inset: 0; }
@media (min-width: 960px) { .chartbox { height: 480px; } }
.legend { position: absolute; left: 8px; right: 72px; top: 6px; z-index: 3; font-size: 12px; color: var(--muted); pointer-events: none; }
.legend b { font-weight: 500; margin: 0 8px 0 2px; }

.desc { margin: 12px 16px; color: var(--muted); font-size: 13px; }
details.corr { margin: 0 16px 16px; border-top: 1px solid var(--line); }
details.corr summary { padding: 10px 0; cursor: pointer; }
details.corr .tabs { padding: 0 0 6px; }
.corrrow { display: grid; grid-template-columns: 92px minmax(0, 1fr) 44px; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; cursor: pointer; }
.corrrow .num { text-align: right; }
.bar { position: relative; height: 8px; background: var(--panel); border-radius: 2px; }
.bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.muted { color: var(--muted); font-size: 12px; }

.watch .ghead { padding: 14px 16px 6px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto 72px; column-gap: 10px; row-gap: 2px; align-items: center; padding: 8px 16px; cursor: pointer; }
.row:hover { background: var(--panel); }
.row.on { background: var(--hover); box-shadow: inset 2px 0 0 var(--accent); }
.row .nm { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row .nm span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .val, .row .chg { text-align: right; }
.row .sub { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.row .sub .w { color: var(--warn); }
.pct { flex: 0 0 72px; height: 4px; background: var(--line); border-radius: 2px; position: relative; overflow: hidden; }
.pct i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--muted); }
.pct.hi i { background: var(--warn); }

.info {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted);
  font-size: 11px; font-style: italic; font-family: Georgia, serif; line-height: 16px; text-align: center;
}
.info:hover { color: var(--text); border-color: var(--text); }
.tip {
  position: fixed; z-index: 20; max-width: min(300px, calc(100vw - 16px)); padding: 8px 10px;
  background: #2a2e39; color: var(--text); border: 1px solid #434651; border-radius: 6px;
  font-size: 12px; line-height: 1.55; box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}

.heatwrap { border-top: 1px solid var(--line); padding-bottom: 12px; }
.heatwrap h2 { font-size: 15px; margin: 14px 16px 0; }
.heatwrap h2 small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.heat { overflow-x: auto; padding: 4px 16px 8px; }
.heat table { border-collapse: collapse; font-size: 11px; }
.heat th { color: var(--muted); font-weight: 400; white-space: nowrap; padding: 2px 6px; }
.heat thead th { writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; height: 76px; padding: 4px 0; }
.heat tbody th { position: sticky; left: 0; z-index: 1; background: var(--bg); text-align: right; }
.heat td { min-width: 36px; height: 26px; text-align: center; color: var(--text); }

footer {
  padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom));
  color: var(--muted); font-size: 12px; border-top: 1px solid var(--line);
}
footer a { color: var(--muted); }
