:root {
  --ink: #111;
  --ink-2: #666;
  --ink-3: #9a9a9a;
  --block: #f4f4f2;
  --line: #e2e2df;
  --wait: #b25e00;
  --err: #c62828;
  --up: #1b3be6;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: var(--ink-2); }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; }

main {
  max-width: 960px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
}
.bar { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; font-size: 14px; color: var(--ink-2); flex-wrap: wrap; }
.clock { font-weight: 600; color: var(--ink); font-size: 16px; }
.bar-actions { margin-left: auto; display: flex; gap: 8px; }
.btn { background: var(--ink); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #333; }
.btn-ghost { background: var(--block); color: var(--ink); }
.btn-ghost:hover { background: #e6e6e3; }
.btn-ghost.on { background: #e3e8ff; color: var(--up); }
.hint { margin: -10px 0 18px; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.hint.error { color: var(--err); }
.btn:disabled { opacity: 0.5; cursor: progress; }
.btn:focus-visible { outline: 2px solid var(--up); outline-offset: 2px; }
.board {
  list-style: none;
  margin: auto 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(296px, 1fr));
  gap: 16px;
}
.card { background: var(--block); border-radius: 14px; overflow: hidden; }

.card-main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 22px 22px 18px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
}
.card-main:focus-visible { outline: 2px solid var(--up); outline-offset: -4px; border-radius: 14px; }

.univ { font-size: 20px; font-weight: 700; line-height: 1.2; }
.unit { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.ratio { margin-top: 18px; white-space: nowrap; }
.ratio .num { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.ratio .per { font-size: 16px; color: var(--ink-3); }
.count { margin-top: 6px; color: var(--ink-2); }
.count b { color: var(--ink); font-weight: 600; }
.count .delta { color: var(--up); font-weight: 600; margin-left: 6px; }
.state { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }
.card[data-status="waiting"] .state { color: var(--wait); }
.card[data-status="error"] .state { color: var(--err); }
.card[data-status="init"] .num, .card[data-status="error"] .num { color: var(--ink-3); }

.last {
  width: 100%;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: baseline;
  font-size: 13.5px;
  color: var(--ink-2);
}
.last-label { color: var(--ink-3); }
.last-ratio { font-weight: 600; color: var(--ink); text-align: right; white-space: nowrap; }
.last-count { grid-column: 1 / -1; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.last[hidden] { display: none; }

.card.flash .card-main { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #e6eaff; } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .card.flash .card-main { animation: none; } }

.detail { padding: 0 22px 18px; font-size: 13px; }
.hist { border-collapse: collapse; width: 100%; margin-bottom: 8px; }
.hist td { padding: 4px 0; color: var(--ink-2); border-top: 1px dashed var(--line); }
.hist td + td { text-align: right; }
.hist tr:first-child td { border-top: 0; }
.hist .up { color: var(--up); }
.offline { margin: 24px 0 0; color: var(--err); font-size: 13px; }
