:root {
  --bg: #0a0f14;
  --surface: #111820;
  --surface-2: #161f2a;
  --border: rgba(255, 255, 255, 0.06);
  --text: #e8edf2;
  --muted: #6b7d8f;
  --accent: #2dd4bf;
  --accent-dim: rgba(45, 212, 191, 0.15);
  --up: #34d399;
  --down: #f87171;
  --stable: #94a3b8;
  --ring-size: 180px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-height: 100%;
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overflow-y: auto;
}

.bg-glow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% -10%, rgba(45, 212, 191, 0.12), transparent),
    radial-gradient(ellipse 40% 30% at 80% 100%, rgba(56, 189, 248, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ── Dashboard shell ── */

.dashboard {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 1rem;
  min-height: 100dvh;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 1.5rem;
}

/* ── Top bar ── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.topbar-brand h1 {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  animation: pulse 2.5s ease-in-out infinite;
}

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

.updated {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Grid ── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  grid-template-areas:
    "current today"
    "trend   hourly";
  gap: 1rem;
  align-content: start;
  min-width: 0;
}

.dashboard-grid > .panel {
  min-width: 0;
}

.panel-current { grid-area: current; }
.panel-today { grid-area: today; }
.panel-trend   { grid-area: trend; }
.panel-hourly  { grid-area: hourly; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
}

.panel-today,
.panel-trend,
.panel-hourly {
  min-height: 220px;
}

.panel-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel-hint {
  font-size: 0.68rem;
  color: var(--muted);
  flex-shrink: 0;
}

.panel-warning {
  font-size: 0.68rem;
  line-height: 1.4;
  color: #d4a574;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.15);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}

/* ── Current occupancy ── */

.panel-current {
  --ring-size: 128px;
  align-items: center;
  justify-content: center;
  overflow: visible;
  min-height: auto;
}

.panel-current-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 1rem;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  align-items: center;
  justify-content: center;
  place-content: center;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding-top: 0.15rem;
}

.ring-wrap {
  position: relative;
  width: var(--ring-size);
  height: var(--ring-size);
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 6;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s;
}

.count-block {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.count {
  font-size: 2.25rem;
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.count-closed {
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  font-variant-numeric: normal;
}

.count-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
}

.status {
  font-size: 0.85rem;
  font-weight: 500;
}

.status-low { color: var(--accent); }
.status-medium { color: #fbbf24; }
.status-high { color: var(--down); }
.status-closed { color: var(--muted); }

.hero-today-hours {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}

.hero-best-slot {
  font-size: 0.72rem;
  color: var(--accent);
  line-height: 1.35;
  max-width: 16rem;
}

.hero-best-slot[hidden] {
  display: none;
}

.capacity {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
  max-width: 14rem;
}

.schedule-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  width: 100%;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
  text-align: center;
}

.schedule-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  margin-bottom: 0.55rem;
  flex-shrink: 0;
  width: 100%;
  max-width: 16rem;
}

.schedule-title {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.schedule-week {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
}

.schedule-days {
  list-style: none;
  display: grid;
  gap: 0.28rem;
  overflow-y: auto;
  min-height: 0;
  width: 100%;
  max-width: 14rem;
  margin: 0 auto;
  padding: 0 0.15rem;
}

.schedule-day {
  display: grid;
  grid-template-columns: 4.75rem 5.5rem;
  gap: 0.5rem;
  align-items: baseline;
  justify-content: center;
  font-size: 0.74rem;
}

.schedule-day-name {
  color: var(--text);
  text-transform: capitalize;
}

.schedule-day-hours {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: left;
  white-space: nowrap;
}

.schedule-day-hours.schedule-day-closed {
  color: var(--muted);
}

.schedule-day-today .schedule-day-name,
.schedule-day-today .schedule-day-hours {
  font-weight: 600;
}

.schedule-day-today .schedule-day-hours:not(.schedule-day-closed) {
  color: #5eead4;
}

/* ── Trend & charts ── */

.panel-trend {
  min-height: 0;
  overflow: visible;
}

.panel-today,
.panel-hourly {
  min-height: 0;
}

.today-comparison {
  font-size: 0.85rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.today-comparison.quiet { color: var(--stable); }
.today-comparison.normal { color: var(--muted); }
.today-comparison.busy { color: var(--up); }

.today-unavailable {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  padding: 0.75rem 0.5rem;
  margin: 0;
}

.today-unavailable[hidden],
#today-chart[hidden] {
  display: none;
}

.panel-today .chart-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.panel-today .today-unavailable:not([hidden]) {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.panel-today #today-chart:not([hidden]) {
  flex: 1;
  align-self: stretch;
  width: 100%;
  min-height: 0;
}

.trend-delta {
  font-size: 0.8rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.trend-delta.up { color: var(--up); }
.trend-delta.down { color: var(--down); }
.trend-delta.stable { color: var(--stable); }

.spark-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: visible;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.trend-unavailable {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  padding: 0.75rem 0.5rem;
  margin: 0;
}

.trend-unavailable[hidden],
#spark-chart[hidden] {
  display: none;
}

.chart-wrap {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
  width: 100%;
  max-width: 100%;
}

.range-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 8px;
  flex-shrink: 0;
}

.range-btn {
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.range-btn:hover {
  color: var(--text);
}

.range-btn.active {
  color: var(--text);
  background: var(--surface);
}

.day-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}

.day-btn {
  flex: 1;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0.35rem 0;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.day-btn:hover {
  color: var(--text);
}

.day-btn.active {
  color: var(--text);
  background: var(--surface);
}

/* ── Footer ── */

.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
  flex-shrink: 0;
}

.credits a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.credits a:hover {
  color: var(--accent);
}

.error-banner {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--down);
  font-size: 0.8rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Mobile: stacked, scrollable ── */

@media (max-width: 768px) {
  .dashboard {
    width: 100%;
    max-width: 100%;
    padding: 1rem 0.875rem 2rem;
    gap: 0.875rem;
    overflow-x: hidden;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    width: 100%;
  }

  .topbar-status {
    flex-wrap: wrap;
    width: 100%;
  }

  .updated {
    white-space: normal;
  }

  .dashboard-grid {
    width: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "current"
      "today"
      "trend"
      "hourly";
    gap: 0.875rem;
  }

  .panel {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
  }

  .panel-header {
    flex-wrap: wrap;
    min-width: 0;
  }

  .panel-current {
    min-height: auto;
    --ring-size: 148px;
  }

  .panel-current-content {
    grid-template-columns: 1fr;
    gap: 0.875rem;
    place-content: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .hero-best-slot,
  .hero-today-hours,
  .capacity {
    max-width: 100%;
  }

  .schedule-panel {
    width: 100%;
    max-width: 100%;
    padding-left: 0;
    padding-top: 0.875rem;
    border-left: none;
    border-top: 1px solid var(--border);
    align-items: center;
  }

  .schedule-days {
    max-height: none;
    max-width: 100%;
    width: 100%;
    overflow: visible;
  }

  .schedule-day {
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
    max-width: 100%;
  }

  .schedule-day-hours {
    white-space: normal;
  }

  .day-tabs {
    width: 100%;
    min-width: 0;
  }

  .spark-wrap {
    min-height: 80px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .chart-wrap {
    min-height: 200px;
    overflow: hidden;
  }

  .count {
    font-size: 2.5rem;
  }
}

@media (max-width: 400px) {
  .panel-current {
    --ring-size: 132px;
  }

  .count {
    font-size: 2.25rem;
  }
}
