:root {
  color-scheme: light;
  --page-plane:     #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --border:         rgba(11, 11, 11, 0.10);
  --grid-line:      #e1e0d9;
  --baseline:       #c3c2b7;
  --accent:         #2a78d6;      /* series 1 - blue: 평일 / 시간대별 막대 / TOP10 */
  --accent-soft:    rgba(42, 120, 214, 0.32);
  --series-weekend: #eb6834;      /* series 2 - orange: 주말 */
  --status-bg:      #f0efec;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page-plane:     #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --border:         rgba(255, 255, 255, 0.10);
    --grid-line:      #2c2c2a;
    --baseline:       #383835;
    --accent:         #3987e5;
    --accent-soft:    rgba(57, 135, 229, 0.30);
    --series-weekend: #d95926;
    --status-bg:      #232322;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-plane:     #0d0d0d;
  --surface-1:      #1a1a19;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --border:         rgba(255, 255, 255, 0.10);
  --grid-line:      #2c2c2a;
  --baseline:       #383835;
  --accent:         #3987e5;
  --accent-soft:    rgba(57, 135, 229, 0.30);
  --series-weekend: #d95926;
  --status-bg:      #232322;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 32px;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
}

.page-sub {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.page-sub code {
  font-family: inherit;
  background: var(--status-bg);
  padding: 1px 6px;
  border-radius: 4px;
}

.theme-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- KPI 카드 ---------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

@media (max-width: 620px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .kpi-row { grid-template-columns: 1fr; }
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.stat-label {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.stat-value {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--accent);
  font-variant-numeric: proportional-nums;
}

.stat-tile.is-loading .stat-value {
  color: var(--text-muted);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.stat-caption {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- 차트 카드 공통 ---------- */

.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.chart-card-head { margin-bottom: 16px; }

.section-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.section-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 15px;
}

.chart-unavailable {
  margin: 0;
  padding: 20px 4px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- 시간대별 막대그래프 ---------- */

.hour-chart-plot {
  position: relative;
  height: 200px;
  margin-left: 60px;
  border-bottom: 1px solid var(--baseline);
}

.hour-gridline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--grid-line);
}

.hour-gridline-label {
  position: absolute;
  left: -60px;
  width: 52px;
  text-align: right;
  padding-right: 8px;
  font-size: 10px;
  color: var(--text-muted);
  transform: translateY(-50%);
  font-variant-numeric: tabular-nums;
}

.hour-bars-row {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  gap: 3px;
}

.hour-col {
  position: relative;
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  outline: none;
}

.hour-bar {
  width: 70%;
  max-width: 22px;
  border-radius: 4px 4px 0 0;
  background: var(--accent-soft);
  transition: background 120ms ease;
}

.hour-col.is-peak .hour-bar { background: var(--accent); }

.hour-col:hover .hour-bar,
.hour-col:focus-visible .hour-bar {
  background: var(--accent);
  filter: brightness(1.12);
}

.hour-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 11px;
  white-space: nowrap;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease;
  z-index: 5;
}

.hour-col:hover .hour-tooltip,
.hour-col:focus-visible .hour-tooltip {
  opacity: 1;
}

.hour-ticks-row {
  margin-left: 60px;
  display: flex;
  gap: 3px;
  margin-top: 6px;
}

.hour-tick-col {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 평일/주말 비중 ---------- */

.share-bar {
  display: flex;
  gap: 2px;
  height: 40px;
  background: var(--page-plane);
}

.share-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.share-seg-weekday {
  background: var(--accent);
  border-radius: 8px 0 0 8px;
}

.share-seg-weekend {
  background: var(--series-weekend);
  border-radius: 0 8px 8px 0;
}

.share-seg-label {
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}

.share-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.swatch-weekday { background: var(--accent); }
.swatch-weekend { background: var(--series-weekend); }

/* ---------- TOP 10 대여소 ---------- */

.top-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.top-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 150px) 1fr auto;
  align-items: center;
  gap: 10px;
}

.top-rank {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.top-label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-track {
  height: 16px;
  background: var(--page-plane);
  border-radius: 4px;
  overflow: hidden;
}

.top-bar {
  height: 100%;
  min-width: 3px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.top-value {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (max-width: 480px) {
  .top-row { grid-template-columns: 18px minmax(0, 96px) 1fr auto; }
  .top-value { font-size: 11px; }
}

/* ---------- 상태 표시 & 푸터 ---------- */

.status-line {
  margin: 20px 2px 0;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
}

.page-footer {
  margin-top: 40px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.page-footer p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.page-footer code {
  font-family: inherit;
}
