:root {
  color-scheme: dark;
  --bg: #080d19;
  --bg-secondary: #111a2c;
  --panel: rgba(15, 23, 40, 0.78);
  --panel-solid: #10192b;
  --border: rgba(155, 176, 219, 0.15);
  --border-strong: rgba(155, 176, 219, 0.3);
  --text: #edf2ff;
  --muted: #96a5c3;
  --accent: #7f9cff;
  --accent-soft: rgba(127, 156, 255, 0.12);
  --success: #5bd8aa;
  --danger: #ff8091;
  --series-5h: #8aa3ff;
  --series-week: #59d5ab;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.25);
  --radius: 19px;
}

:root[data-theme="ocean"] {
  color-scheme: light;
  --bg: #edf9fb;
  --bg-secondary: #d9f1f4;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #f7ffff;
  --border: rgba(62, 112, 128, 0.16);
  --border-strong: rgba(62, 112, 128, 0.3);
  --text: #183942;
  --muted: #6d8b93;
  --accent: #078ab8;
  --accent-soft: rgba(7, 138, 184, 0.1);
  --success: #168d69;
  --danger: #ce5368;
  --series-5h: #2c7fe5;
  --series-week: #12a578;
  --shadow: 0 22px 70px rgba(46, 105, 119, 0.13);
}

:root[data-theme="forest"] {
  color-scheme: light;
  --bg: #f3f5ed;
  --bg-secondary: #e5ead9;
  --panel: rgba(255, 255, 250, 0.82);
  --panel-solid: #fffef7;
  --border: rgba(88, 109, 77, 0.17);
  --border-strong: rgba(88, 109, 77, 0.32);
  --text: #2c3a2b;
  --muted: #778171;
  --accent: #5f8c66;
  --accent-soft: rgba(95, 140, 102, 0.12);
  --success: #45855d;
  --danger: #bd6170;
  --series-5h: #758fd5;
  --series-week: #5a9c6a;
  --shadow: 0 22px 70px rgba(74, 88, 64, 0.13);
}

:root[data-theme="rose"] {
  color-scheme: light;
  --bg: #fbf1f2;
  --bg-secondary: #f2e1e5;
  --panel: rgba(255, 250, 249, 0.83);
  --panel-solid: #fff9f7;
  --border: rgba(135, 90, 104, 0.16);
  --border-strong: rgba(135, 90, 104, 0.3);
  --text: #493139;
  --muted: #947982;
  --accent: #c36f91;
  --accent-soft: rgba(195, 111, 145, 0.12);
  --success: #408b70;
  --danger: #c9556d;
  --series-5h: #7b8fd7;
  --series-week: #3e9a79;
  --shadow: 0 22px 70px rgba(112, 72, 84, 0.13);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 36%),
    linear-gradient(145deg, var(--bg), var(--bg-secondary));
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(90px);
  opacity: 0.13;
}

.ambient-one { top: -160px; right: -100px; background: var(--series-5h); }
.ambient-two { bottom: -200px; left: -120px; background: var(--series-week); }

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.eyebrow, .section-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.16em;
}

h1, h2, p { margin-top: 0; }
h1 { margin: 8px 0 6px; font-size: clamp(2.1rem, 6vw, 4.5rem); line-height: 0.98; letter-spacing: -0.055em; }
h2 { margin: 5px 0 7px; font-size: clamp(1.15rem, 2.3vw, 1.52rem); letter-spacing: -0.025em; }

.page-description, .panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.65;
}

.theme-selector {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 750;
}

select, .button, .icon-button, .scale-selector button, .legend-button, .icon-text-button {
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: color-mix(in srgb, var(--panel-solid) 72%, transparent);
}

select { min-height: 40px; padding: 0 34px 0 12px; cursor: pointer; }
button { cursor: pointer; transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, opacity 140ms ease; }
button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--border-strong); }
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: 0.38; }

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0;
}
.status-loading { color: var(--muted); }
.status-ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: color-mix(in srgb, var(--success) 9%, transparent); }
.status-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

.snapshot-strip, .range-panel, .panel, .summary-card {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.snapshot-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: var(--radius);
}

.snapshot-strip > div { padding: 14px 18px; background: color-mix(in srgb, var(--panel-solid) 28%, transparent); }
.snapshot-strip span, .snapshot-strip strong { display: block; }
.snapshot-strip span { margin-bottom: 5px; color: var(--muted); font-size: 0.67rem; }
.snapshot-strip strong { font-size: 0.81rem; }

.range-panel { display: grid; gap: 11px; padding: 11px 13px; border-radius: var(--radius); }
.scale-selector { display: grid; grid-template-columns: repeat(8, minmax(58px, 74px)); justify-content: center; gap: 5px; overflow-x: auto; }
.scale-selector button { min-height: 33px; padding: 0 8px; color: var(--muted); font-size: 0.73rem; font-weight: 780; }
.scale-selector button.active { color: var(--text); border-color: var(--border-strong); background: var(--accent-soft); }
.range-navigation { display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 9px; }
.icon-button { width: 38px; height: 38px; font-size: 1rem; }
.range-title-wrap { min-width: 0; text-align: center; }
.range-title-wrap strong, .range-title-wrap span { display: block; }
.range-title-wrap strong { font-size: clamp(0.78rem, 2vw, 0.98rem); }
.range-title-wrap span { margin-top: 3px; color: var(--muted); font-size: 0.65rem; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.summary-card { position: relative; min-width: 0; padding: 18px; overflow: hidden; border-radius: 16px; }
.summary-card::after { position: absolute; top: -34px; right: -25px; width: 90px; height: 90px; border-radius: 999px; content: ""; opacity: 0.12; }
.summary-card-5h::after { background: var(--series-5h); }
.summary-card-week::after { background: var(--series-week); }
.summary-card span, .summary-card small { display: block; color: var(--muted); }
.summary-card span { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 0.73rem; font-weight: 720; }
.summary-card strong { display: block; margin-bottom: 7px; overflow: hidden; font-size: clamp(1.35rem, 3vw, 1.9rem); text-overflow: ellipsis; white-space: nowrap; }
.summary-card small { overflow: hidden; font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }

.series-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 999px; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 10%, transparent); }
.dot-5h { background: var(--series-5h); }
.dot-week { background: var(--series-week); }

.panel { margin-top: 12px; padding: 20px; border-radius: var(--radius); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.chart-actions, .series-legend, .table-actions, .table-pagination { display: flex; align-items: center; gap: 8px; }
.chart-actions { flex-wrap: wrap; justify-content: flex-end; }
.legend-button, .icon-text-button, .button { min-height: 39px; padding: 0 13px; font-size: 0.72rem; font-weight: 760; }
.legend-button { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.legend-button.active { color: var(--text); background: var(--accent-soft); }
.legend-button:not(.active) { opacity: 0.45; }
.icon-text-button { color: var(--muted); }
.button-ghost { color: var(--muted); }

.chart-wrap { position: relative; min-height: 340px; user-select: none; touch-action: pan-y; }
#usage-chart { display: block; width: 100%; min-height: 290px; overflow: visible; }
.chart-grid { stroke: color-mix(in srgb, var(--muted) 18%, transparent); stroke-width: 1; }
.chart-grid-vertical { opacity: 0.55; }
.chart-axis-label { fill: var(--muted); font-size: 11px; }
.chart-line { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.chart-line-5h { stroke: var(--series-5h); stroke-width: 1.4; opacity: 0.7; }
.chart-line-week { stroke: var(--series-week); filter: drop-shadow(0 7px 12px color-mix(in srgb, var(--series-week) 24%, transparent)); }
.chart-event-dot { stroke: var(--panel-solid); stroke-width: 1.2; }
.chart-event-dot-5h { fill: var(--series-5h); }
.chart-event-dot-week { fill: var(--series-week); }
.chart-hover-line { stroke: color-mix(in srgb, var(--text) 36%, transparent); stroke-width: 1; stroke-dasharray: 4 4; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 0.85rem; }
.chart-tooltip { position: absolute; z-index: 3; min-width: 190px; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 12px; pointer-events: none; background: color-mix(in srgb, var(--panel-solid) 96%, transparent); box-shadow: var(--shadow); font-size: 0.72rem; }
.chart-tooltip time { display: block; margin-bottom: 7px; color: var(--muted); }
.tooltip-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 4px 0; }
.tooltip-row span { display: inline-flex; align-items: center; gap: 7px; }

.table-heading { align-items: center; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: right; font-size: 0.74rem; }
th { color: var(--muted); font-size: 0.66rem; font-weight: 760; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2), th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5) { text-align: left; }
.usage-badge { display: inline-flex; align-items: center; gap: 7px; min-height: 26px; padding: 0 9px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.67rem; font-weight: 780; }
.usage-badge-5h { color: var(--series-5h); border-color: color-mix(in srgb, var(--series-5h) 34%, transparent); background: color-mix(in srgb, var(--series-5h) 8%, transparent); }
.usage-badge-week { color: var(--series-week); border-color: color-mix(in srgb, var(--series-week) 34%, transparent); background: color-mix(in srgb, var(--series-week) 8%, transparent); }
.note-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.empty-row td { padding: 44px 12px; color: var(--muted); text-align: center !important; }
.table-pagination { justify-content: center; margin-top: 15px; }
.table-pagination span { min-width: 70px; color: var(--muted); text-align: center; font-size: 0.72rem; }

footer { display: flex; justify-content: center; gap: 8px; padding: 22px 0 4px; color: var(--muted); font-size: 0.68rem; }
.toast { position: fixed; z-index: 5; right: 18px; bottom: 18px; max-width: calc(100vw - 36px); padding: 12px 15px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--panel-solid); box-shadow: var(--shadow); font-size: 0.75rem; }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .chart-actions { justify-content: space-between; }
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 20px, 1240px); padding-top: 22px; }
  .topbar { flex-direction: column; }
  .theme-selector { width: 100%; }
  .theme-selector select { width: 100%; }
  .snapshot-strip { grid-template-columns: 1fr; }
  .snapshot-strip > div + div { border-top: 1px solid var(--border); }
  .scale-selector { justify-content: start; }
  .range-title-wrap span { display: none; }
  .summary-grid { gap: 8px; }
  .summary-card { padding: 15px; }
  .summary-card small { font-size: 0.63rem; }
  .panel { padding: 15px; }
  .chart-actions { align-items: stretch; flex-direction: column; }
  .series-legend { display: grid; grid-template-columns: 1fr 1fr; }
  .legend-button { justify-content: center; }
  .table-actions { width: 100%; }
  .table-actions .button { flex: 1; }
  #usage-chart { min-height: 250px; }
}
