/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark:       #060b18;
  --bg-surface:    #0d1526;
  --bg-card:       #111d35;
  --bg-card-hover: #152040;
  --border:        rgba(148, 163, 184, 0.1);
  --border-glow:   rgba(148, 163, 184, 0.2);

  --ch1: #a78bfa;
  --ch2: #38bdf8;
  --ch3: #34d399;
  --ch4: #fb923c;

  --ch1-glow: rgba(167, 139, 250, 0.2);
  --ch2-glow: rgba(56, 189, 248, 0.2);
  --ch3-glow: rgba(52, 211, 153, 0.2);
  --ch4-glow: rgba(251, 146, 60, 0.2);

  --text-primary:   #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted:     #94a3b8;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --font-body: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* =============================================
   ANIMATED BACKGROUND
   ============================================= */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(148,163,184,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
  animation: floatGlow 8s ease-in-out infinite alternate;
}

.glow-1 { width: 600px; height: 600px; background: var(--ch1); top: -150px; left: -150px; animation-delay: 0s; }
.glow-2 { width: 500px; height: 500px; background: var(--ch2); top: 20%; right: -100px; animation-delay: -3s; }
.glow-3 { width: 400px; height: 400px; background: var(--ch3); bottom: -100px; left: 30%; animation-delay: -5s; }

@keyframes floatGlow {
  0%   { transform: translate(0, 0) scale(1); opacity: 0.1; }
  100% { transform: translate(30px, 30px) scale(1.1); opacity: 0.18; }
}

/* =============================================
   APP WRAPPER
   ============================================= */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* =============================================
   HEADER
   ============================================= */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 20px 28px;
  background: rgba(13, 21, 38, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, rgba(167,139,250,0.2), rgba(56,189,248,0.2));
  border: 1px solid rgba(167,139,250,0.3);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  padding: 10px; flex-shrink: 0;
}
.logo-icon svg { width: 28px; height: 28px; }

.header-title h1 {
  font-size: 1.5rem; font-weight: 700;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; line-height: 1.2;
}
.header-subtitle {
  font-size: 0.78rem; color: var(--text-secondary);
  font-weight: 400; letter-spacing: 0.05em; text-transform: uppercase;
}

.header-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.status-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 100px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  font-size: 0.85rem; font-weight: 500; color: var(--text-secondary);
  transition: var(--transition);
}
.status-badge.connected { border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.08); color: #34d399; }
.status-badge.error     { border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.08); color: #f87171; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0; transition: var(--transition);
}
.status-badge.connected .status-dot { background: #34d399; box-shadow: 0 0 8px #34d399; animation: pulseGreen 2s infinite; }
.status-badge.error     .status-dot { background: #f87171; box-shadow: 0 0 8px #f87171; }

@keyframes pulseGreen {
  0%,100% { opacity:1; box-shadow: 0 0 8px #34d399; }
  50%      { opacity:0.6; box-shadow: 0 0 16px #34d399; }
}

.timestamp-box {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  padding: 8px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.timestamp-box:hover {
  border-color: rgba(167,139,250,0.4);
  background: rgba(167,139,250,0.08);
}
.timestamp-box:hover .timestamp-value { color: var(--ch1); }
.timestamp-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.timestamp-value { font-family: var(--font-mono); font-size: 0.9rem; color: var(--text-secondary); font-weight: 600; }

/* =============================================
   STATS BAR
   ============================================= */
.stats-bar {
  display: flex; align-items: center;
  padding: 14px 28px; margin-bottom: 24px;
  background: rgba(13,21,38,0.5); border: 1px solid var(--border);
  border-radius: var(--radius-lg); backdrop-filter: blur(12px);
  flex-wrap: wrap; gap: 16px;
}
.stat-item { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 100px; }
.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); font-weight: 500; }
.stat-value { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 600; color: var(--text-primary); }
.stat-divider { width: 1px; height: 36px; background: var(--border); flex-shrink: 0; }

/* =============================================
   CARDS GRID
   ============================================= */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 900px) { .cards-grid { grid-template-columns: 1fr; } }

/* =============================================
   VOLTAGE CARD
   ============================================= */
.voltage-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px 16px;
  display: flex; flex-direction: column; gap: 14px;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  animation: cardIn 0.5s ease both;
}

.voltage-card::before {
  content: ''; position: absolute; inset: 0;
  border-radius: var(--radius-lg); opacity: 0;
  transition: opacity var(--transition); pointer-events: none;
}
#card-v1::before { background: radial-gradient(ellipse at top left, var(--ch1-glow), transparent 60%); }
#card-v2::before { background: radial-gradient(ellipse at top left, var(--ch2-glow), transparent 60%); }
#card-v3::before { background: radial-gradient(ellipse at top left, var(--ch3-glow), transparent 60%); }
#card-v4::before { background: radial-gradient(ellipse at top left, var(--ch4-glow), transparent 60%); }

.voltage-card:hover::before { opacity: 1; }
.voltage-card:hover { transform: translateY(-3px); }
#card-v1:hover { box-shadow: 0 16px 40px rgba(167,139,250,0.15); border-color: rgba(167,139,250,0.35); }
#card-v2:hover { box-shadow: 0 16px 40px rgba(56,189,248,0.15);  border-color: rgba(56,189,248,0.35); }
#card-v3:hover { box-shadow: 0 16px 40px rgba(52,211,153,0.15);  border-color: rgba(52,211,153,0.35); }
#card-v4:hover { box-shadow: 0 16px 40px rgba(251,146,60,0.15);  border-color: rgba(251,146,60,0.35); }

.voltage-card.updated { animation: cardFlash 0.5s ease; }
@keyframes cardFlash {
  0%   { background: var(--bg-card); }
  30%  { background: var(--bg-card-hover); }
  100% { background: var(--bg-card); }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
#card-v1 { animation-delay: 0.05s; }
#card-v2 { animation-delay: 0.1s;  }
#card-v3 { animation-delay: 0.15s; }
#card-v4 { animation-delay: 0.2s;  }

/* Card Header */
.card-header {
  display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
}
.card-header-right {
  display: flex; align-items: center; gap: 10px;
}
.card-label {
  font-size: 0.82rem; font-weight: 500;
  color: var(--text-secondary); letter-spacing: 0.03em;
}

.channel-badge {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em;
  padding: 4px 10px; border-radius: 100px; text-transform: uppercase;
  flex-shrink: 0;
}
.channel-1 { background: rgba(167,139,250,0.15); color: var(--ch1); border: 1px solid rgba(167,139,250,0.3); }
.channel-2 { background: rgba(56,189,248,0.15);  color: var(--ch2); border: 1px solid rgba(56,189,248,0.3); }
.channel-3 { background: rgba(52,211,153,0.15);  color: var(--ch3); border: 1px solid rgba(52,211,153,0.3); }
.channel-4 { background: rgba(251,146,60,0.15);  color: var(--ch4); border: 1px solid rgba(251,146,60,0.3); }

.card-status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block; background: var(--text-muted);
  transition: var(--transition); flex-shrink: 0;
}
#card-v1 .card-status-dot.live { background: var(--ch1); box-shadow: 0 0 8px var(--ch1); animation: pulseCh1 2s infinite; }
#card-v2 .card-status-dot.live { background: var(--ch2); box-shadow: 0 0 8px var(--ch2); animation: pulseCh2 2s infinite; }
#card-v3 .card-status-dot.live { background: var(--ch3); box-shadow: 0 0 8px var(--ch3); animation: pulseCh3 2s infinite; }
#card-v4 .card-status-dot.live { background: var(--ch4); box-shadow: 0 0 8px var(--ch4); animation: pulseCh4 2s infinite; }
@keyframes pulseCh1 { 0%,100% { box-shadow: 0 0 6px var(--ch1); } 50% { box-shadow: 0 0 16px var(--ch1); } }
@keyframes pulseCh2 { 0%,100% { box-shadow: 0 0 6px var(--ch2); } 50% { box-shadow: 0 0 16px var(--ch2); } }
@keyframes pulseCh3 { 0%,100% { box-shadow: 0 0 6px var(--ch3); } 50% { box-shadow: 0 0 16px var(--ch3); } }
@keyframes pulseCh4 { 0%,100% { box-shadow: 0 0 6px var(--ch4); } 50% { box-shadow: 0 0 16px var(--ch4); } }

/* =============================================
   CARD BODY — gauge + chart side-by-side
   ============================================= */
.card-body {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex: 1;
  min-height: 140px;
}

/* =============================================
   ARC GAUGE (SVG semicircular)
   ============================================= */
.arc-wrapper {
  flex: 0 0 42%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arc-gauge {
  width: 100%; display: block;
  overflow: visible;
}

/* Background dashed ring */
.arc-ticks {
  fill: none;
  stroke: rgba(255,255,255,0.04);
  stroke-width: 18;
  stroke-linecap: round;
  stroke-dasharray: 4 8;
}

/* Track */
.arc-bg {
  fill: none;
  stroke: rgba(255,255,255,0.07);
  stroke-width: 14;
  stroke-linecap: round;
}

/* Value fill — animated */
.arc-fill {
  fill: none;
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dasharray 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.arc-fill-1 { stroke: var(--ch1); filter: drop-shadow(0 0 8px rgba(167,139,250,0.7)); }
.arc-fill-2 { stroke: var(--ch2); filter: drop-shadow(0 0 8px rgba(56,189,248,0.7));  }
.arc-fill-3 { stroke: var(--ch3); filter: drop-shadow(0 0 8px rgba(52,211,153,0.7));  }
.arc-fill-4 { stroke: var(--ch4); filter: drop-shadow(0 0 8px rgba(251,146,60,0.7));  }

/* SVG text elements */
.arc-label {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--text-muted);
  text-anchor: start;
}
.arc-right { text-anchor: end; }

.arc-center-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: auto;
}
.arc-color-1 { fill: var(--ch1); }
.arc-color-2 { fill: var(--ch2); }
.arc-color-3 { fill: var(--ch3); }
.arc-color-4 { fill: var(--ch4); }

.arc-center-unit {
  font-family: var(--font-body);
  font-size: 10px;
  fill: var(--text-muted);
  text-anchor: middle;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* =============================================
   BAR CHART
   ============================================= */
.chart-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  justify-content: center;
}

.chart-title {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bar-canvas {
  width: 100%;
  height: 110px;
  display: block;
  border-radius: var(--radius-sm);
}

.chart-axis-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  display: flex; justify-content: space-between;
  height: 14px; overflow: hidden;
}

/* =============================================
   CARD FOOTER
   ============================================= */
.card-footer {
  display: flex; align-items: center;
  gap: 8px; padding-top: 12px;
  border-top: 1px solid var(--border);
}

.footer-stat {
  flex: 1; display: flex; align-items: baseline; gap: 5px;
  justify-content: center;
}

.footer-label {
  font-size: 0.68rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em;
}

.footer-val {
  font-family: var(--font-mono); font-size: 1rem; font-weight: 700;
}
.footer-color-1 { color: var(--ch1); }
.footer-color-2 { color: var(--ch2); }
.footer-color-3 { color: var(--ch3); }
.footer-color-4 { color: var(--ch4); }

.footer-unit {
  font-size: 0.72rem; color: var(--text-muted);
  font-family: var(--font-mono);
}

.footer-sep {
  width: 1px; height: 28px; background: var(--border); flex-shrink: 0;
}

/* =============================================
   HISTORY MODAL
   ============================================= */

/* Overlay */
.hist-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.hist-modal[hidden] { display: none; }

.hist-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 11, 24, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

/* Panel */
.hist-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  max-height: 88vh;
  background: rgba(13, 21, 38, 0.97);
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: var(--radius-xl);
  box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(167,139,250,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panelIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes panelIn {
  from { opacity: 0; transform: scale(0.94) translateY(16px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* Panel Header */
.hist-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.hist-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hist-panel-title svg {
  color: var(--ch1);
  flex-shrink: 0;
}

.hist-close-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.hist-close-btn:hover {
  background: rgba(248,113,113,0.15);
  border-color: rgba(248,113,113,0.4);
  color: #f87171;
}

/* Month Tabs Bar */
.hist-months-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.hist-loading {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

.month-btn {
  padding: 7px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.month-btn:hover {
  border-color: rgba(167,139,250,0.4);
  background: rgba(167,139,250,0.1);
  color: var(--ch1);
}
.month-btn.active {
  background: rgba(167,139,250,0.18);
  border-color: rgba(167,139,250,0.5);
  color: var(--ch1);
  box-shadow: 0 0 12px rgba(167,139,250,0.2);
}

/* Body layout */
.hist-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Days column */
.hist-days-col {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
}

.day-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  cursor: pointer;
  transition: background var(--transition);
  border-left: 3px solid transparent;
}
.day-item:hover {
  background: rgba(255,255,255,0.04);
}
.day-item.active {
  background: rgba(167,139,250,0.1);
  border-left-color: var(--ch1);
}

.day-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.day-number {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  width: 32px;
  text-align: center;
}
.day-item.active .day-number { color: var(--ch1); }

.day-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: capitalize;
}
.day-item.active .day-name { color: var(--text-primary); }

.day-count {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.day-arrow {
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: var(--transition);
}
.day-item.active .day-arrow, .day-item:hover .day-arrow { color: var(--ch1); }

/* Records column */
.hist-records-col {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  min-width: 0;
}

.hist-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 16px 18px;
  font-style: italic;
}
.hist-empty-center {
  text-align: center;
  padding: 40px 24px;
}

/* Records Table */
.records-table-header {
  display: grid;
  grid-template-columns: 90px repeat(4, 1fr);
  gap: 8px;
  padding: 8px 18px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(13,21,38,0.97);
  z-index: 1;
}
.records-table-header .col-ch1 { color: var(--ch1); }
.records-table-header .col-ch2 { color: var(--ch2); }
.records-table-header .col-ch3 { color: var(--ch3); }
.records-table-header .col-ch4 { color: var(--ch4); }

.record-row {
  display: grid;
  grid-template-columns: 90px repeat(4, 1fr);
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background var(--transition);
  align-items: center;
}
.record-row:hover {
  background: rgba(167,139,250,0.08);
}
.record-row:last-child { border-bottom: none; }

.record-time {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.record-v {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
}
.record-v.v1 { color: var(--ch1); }
.record-v.v2 { color: var(--ch2); }
.record-v.v3 { color: var(--ch3); }
.record-v.v4 { color: var(--ch4); }

.record-row-hint {
  font-size: 0.62rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
  text-align: right;
  padding-bottom: 4px;
}

/* Scrollbar styling */
.hist-days-col::-webkit-scrollbar,
.hist-records-col::-webkit-scrollbar,
.hist-months-bar::-webkit-scrollbar { width: 4px; height: 4px; }
.hist-days-col::-webkit-scrollbar-track,
.hist-records-col::-webkit-scrollbar-track { background: transparent; }
.hist-days-col::-webkit-scrollbar-thumb,
.hist-records-col::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Mobile adjustments */
@media (max-width: 600px) {
  .hist-panel { max-height: 95vh; }
  .hist-body { flex-direction: column; }
  .hist-days-col { width: 100%; height: 180px; border-right: none; border-bottom: 1px solid var(--border); }
  .hist-records-col { overflow-x: auto; }
  .records-table-header, .record-row { 
    grid-template-columns: 70px repeat(4, minmax(60px, 1fr)); 
    gap: 4px; padding: 8px 12px; 
    min-width: 360px; /* Evita que se aplaste en celulares muy pequeños */
  }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .app-wrapper { padding: 14px 14px 36px; }
  .header { padding: 14px 18px; flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-right { width: 100%; justify-content: flex-end; }
  .header-title h1 { font-size: 1.2rem; }
  .cards-grid { grid-template-columns: 1fr; gap: 16px; }
  .footer-sep { display: none; }
  .card-footer { flex-wrap: wrap; justify-content: space-between; gap: 12px 8px; padding-bottom: 8px; }
  .footer-stat { flex: 1 1 45%; justify-content: center; }
  .footer-stat:last-child { flex: 1 1 100%; margin-top: 4px; }
  .card-body { flex-direction: column; align-items: stretch; min-height: unset; }
  .arc-wrapper { flex: none; width: 100%; max-width: 220px; margin: 0 auto; }
  .bar-canvas { height: 80px; }
}

@media (max-width: 480px) {
  .footer-val { font-size: 0.88rem; }
  .status-text { font-size: 0.75rem; }
}

/* --- Purge Progress Bar --- */
.purge-progress-container {
  padding: 0 4px 6px;
}
.purge-text {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-align: right;
  letter-spacing: 0.05em;
}
.purge-bar-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}
.purge-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ch2), var(--ch1));
  border-radius: 2px;
  width: 0%;
  transition: width 1s ease-out;
}

/* --- Export Button --- */
.hist-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hist-export-btn {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: #34d399;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.hist-export-btn:hover {
  background: rgba(52, 211, 153, 0.25);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.2);
}
