:root {
  --bg-base:     #111111;
  --bg-card:     #1e1e1e;
  --bg-inner:    #2a2a2a;
  --bg-btn:      #333333;
  --text-primary:#ffffff;
  --text-muted:  #9a9a9a;
  --text-label:  #bbbbbb;
  --accent-entry:#4ade80;
  --accent-denied:#9a9a9a;
  --accent-exit: #f87171;
  --border-subtle:#3a3a3a;
  --radius-card: 16px;
  --radius-inner:10px;
}

* { box-sizing: border-box; }

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  padding-bottom: 2rem;
}

/* ── Greeting ── */
.greeting-section { padding: 2rem 1.25rem 1rem; }
.greeting-time    { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.greeting-label   { font-size: 1.85rem; font-weight: 700; line-height: 1.1; }
.greeting-name    { font-size: 1.5rem; font-weight: 400; color: var(--text-muted); }

/* ── Panel card ── */
.panel-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.panel-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 1rem; }

/* ── KwH chart ── */
.chart-wrap {
  background: var(--bg-inner);
  border-radius: var(--radius-inner);
  padding: 0.75rem 1rem 0.5rem;
  margin-bottom: 1rem;
}
.chart-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-label);
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
}
canvas#energyChart { width: 100% !important; height: 110px !important; }
canvas#billChart   { width: 100% !important; height: 130px !important; }

/* ── Compact stat boxes ── */
.stat-box { background: var(--bg-inner); border-radius: var(--radius-inner); padding: 0.65rem 0.85rem; }
.stat-label { font-size: 0.68rem; color: var(--text-label); font-weight: 600; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.25rem; font-weight: 700; line-height: 1.1; }

/* ── Detail button ── */
.btn-detail {
  background: var(--bg-inner);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-inner);
  width: 100%;
  padding: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  transition: background 0.15s;
  margin-bottom: 0;
}
.btn-detail:hover { background: #383838; color: var(--text-primary); }

/* ── Expanded detail panel ── */
.energy-detail-panel { margin-top: 0.75rem; }

/* ── Sparkline rows ── */
.stat-row-detail {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.65rem;
  background: var(--bg-inner);
  border-radius: var(--radius-inner);
  padding: 0.55rem 0.85rem;
}
.stat-row-left  { min-width: 90px; flex-shrink: 0; }
.stat-row-label { font-size: 0.7rem; font-weight: 600; color: var(--text-label); display: block; margin-bottom: 0.1rem; }
.stat-row-value { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.stat-row-box {
  flex: 1;
  border: 1px solid #444444;
  border-radius: var(--radius-inner);
  height: 56px;
  overflow: hidden;
  padding: 4px 6px;
}
.stat-row-box canvas { width: 100% !important; height: 100% !important; }

/* ── Monthly summary ── */
.monthly-summary-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.summary-box {
  background: var(--bg-inner);
  border-radius: var(--radius-inner);
  padding: 0.9rem 1rem;
}
.summary-label { font-size: 0.72rem; font-weight: 600; color: var(--text-label); margin-bottom: 0.4rem; }
.summary-value { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.summary-kwh   { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ── Door status ── */
.door-status-box { background: var(--bg-inner); border-radius: var(--radius-inner); padding: 0.75rem 1rem; height: 100%; }
.door-label      { font-size: 0.68rem; color: var(--text-label); font-weight: 600; }
.door-value      { font-size: 1.4rem; font-weight: 700; margin-top: 0.2rem; }

/* ── Now playing ── */
.spotify-box {
  background: var(--bg-inner);
  border-radius: var(--radius-inner);
  padding: 0.75rem 1rem;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.spotify-label  { font-size: 0.68rem; color: var(--text-label); font-weight: 600; margin-bottom: 0.2rem; }
.spotify-track  { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.spotify-artist { font-size: 0.8rem; color: var(--text-muted); }
.spotify-art {
  width: 52px; height: 52px;
  border-radius: 8px;
  flex-shrink: 0;
  background: #444;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.4rem;
  overflow: hidden;
}

.spotify-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.spotify-ctrl-btn {
  background: var(--bg-btn);
  color: var(--text-primary);
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  padding: 0;
  transition: background 0.15s;
}
.spotify-ctrl-btn:hover { background: #444; }
#playPauseBtn { width: 30px; height: 30px; font-size: 0.95rem; }

/* ── Access log ── */
.access-log-box { background: var(--bg-inner); border-radius: var(--radius-inner); padding: 0.85rem 1rem; }
.log-label { font-size: 0.68rem; color: var(--text-label); font-weight: 600; margin-bottom: 0.65rem; }
.log-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.4rem 0.6rem;
  align-items: center;
  font-size: 0.7rem;
  padding: 0.3rem 0;
  border-top: 1px solid var(--border-subtle);
}
.log-row:first-of-type { border-top: none; padding-top: 0; }
.log-time          { color: var(--text-muted); white-space: nowrap; }
.log-uid           { color: var(--text-muted); }
.log-name          { color: var(--text-primary); font-weight: 500; }
.log-status-entry  { color: var(--accent-entry);  font-weight: 700; text-align: right; }
.log-status-exit   { color: var(--accent-exit);   font-weight: 700; text-align: right; }
.log-status-denied { color: var(--accent-denied); font-weight: 700; text-align: right; }

/* ── Controls ── */
.controls-box   { background: var(--bg-inner); border-radius: var(--radius-inner); padding: 0.85rem 1rem; }
.controls-label { font-size: 0.68rem; color: var(--text-label); font-weight: 600; margin-bottom: 0.65rem; }
.btn-ctrl {
  background: var(--bg-btn);
  color: var(--text-primary);
  border: none;
  border-radius: 10px;
  padding: 0.9rem 0.5rem;
  font-weight: 700;
  font-size: 0.85rem;
  width: 100%;
  line-height: 1.3;
  transition: background 0.15s;
}
.btn-ctrl:hover { background: #444; color: var(--text-primary); }
.btn-ctrl.active { background: #f59e0b; color: #111111; }
.btn-ctrl.active:hover { background: #f59e0b; }

/* ── Recent access ── */
.recent-access-box { background: var(--bg-inner); border-radius: var(--radius-inner); padding: 0.85rem 1rem; }
.recent-label      { font-size: 0.68rem; color: var(--text-label); font-weight: 600; margin-bottom: 0.5rem; }
.recent-name       { font-size: 1rem; font-weight: 700; }
.recent-method     { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.recent-status-row { display: flex; justify-content: space-between; align-items: center; margin-top: 0.6rem; }
.recent-entry-badge { font-size: 0.85rem; font-weight: 800; color: var(--accent-entry); letter-spacing: 0.05em; }
.recent-datetime   { font-size: 0.75rem; color: var(--text-primary); font-weight: 500; }

/* ── Status dot pulse ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-entry);
  animation: pulse 2s infinite;
  margin-right: 5px;
  vertical-align: middle;
}

/* ── Door indicator ── */
.door-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}
.door-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ef4444;
  transition: background 0.4s;
  flex-shrink: 0;
}
.door-indicator.state-unlocked { background: #4ade80; }
.door-indicator.state-dnd      { background: #f59e0b; }
.door-indicator.state-locked   { background: #ef4444; }

/* ── Responsive ── */
@media (max-width: 576px) {
  .greeting-label { font-size: 1.5rem; }
  .greeting-name  { font-size: 1.2rem; }
  .stat-value     { font-size: 1.1rem; }
  .log-row        { font-size: 0.62rem; }
}
