:root {
  --bg-main: #0a0e17;
  --bg-card: rgba(18, 25, 43, 0.75);
  --bg-card-hover: rgba(23, 33, 56, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(245, 158, 11, 0.3);
  
  --color-sun: #f59e0b;
  --color-sun-glow: rgba(245, 158, 11, 0.4);
  --color-amber: #fbbf24;
  --color-foxess: #10b981;
  --color-foxess-glow: rgba(16, 185, 129, 0.25);
  --color-deye: #3b82f6;
  --color-deye-glow: rgba(59, 130, 246, 0.25);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 40px -10px rgba(245, 158, 11, 0.25);
}

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

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(245, 158, 11, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 85%, rgba(16, 185, 129, 0.05) 0%, transparent 45%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  line-height: 1.5;
}

.app-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 48px 20px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

.logo-icon svg {
  width: 26px;
  height: 26px;
  animation: rotateSun 24s linear infinite;
}

@keyframes rotateSun {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #fef3c7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.8rem;
  font-weight: 600;
  color: #34d399;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.refresh-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.refresh-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.5s ease;
}

.action-btn.spinning .refresh-icon {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.countdown-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

/* Glass Card Common */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* Hero Card */
.hero-card {
  grid-column: span 2;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(24, 33, 56, 0.85) 0%, rgba(15, 21, 37, 0.9) 100%);
  border: 1px solid rgba(245, 158, 11, 0.25);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-amber);
  margin-bottom: 4px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.hero-chip {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.hero-chip strong {
  color: var(--text-primary);
  margin-left: 4px;
}

.hero-content {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 32px;
  align-items: center;
  margin-bottom: 28px;
}

.power-display {
  display: flex;
  flex-direction: column;
}

.power-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.power-num {
  font-family: var(--font-display);
  font-size: 4.2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 30%, #fde68a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 25px rgba(245, 158, 11, 0.3));
}

.power-unit {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-amber);
}

.power-watts-sub {
  margin-top: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.power-stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.stat-value .unit {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-sun);
}

.health-stat {
  color: #34d399;
}

.sync-stat {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Ratio Bar */
.ratio-section {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.ratio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.82rem;
}

.ratio-title {
  color: var(--text-secondary);
  font-weight: 600;
}

.ratio-labels {
  display: flex;
  gap: 16px;
}

.tag-foxess, .tag-deye {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-fox {
  background: var(--color-foxess);
  box-shadow: 0 0 8px var(--color-foxess);
}

.dot-deye {
  background: var(--color-deye);
  box-shadow: 0 0 8px var(--color-deye);
}

.ratio-bar-wrapper {
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: flex;
}

.ratio-bar-foxess {
  background: linear-gradient(90deg, #059669, #10b981);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ratio-bar-deye {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Inverter Cards */
.inverter-card {
  display: flex;
  flex-direction: column;
}

.foxess-card {
  border-top: 3px solid var(--color-foxess);
}

.deye-card {
  border-top: 3px solid var(--color-deye);
}

.inverter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.inverter-badge-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.inverter-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.inverter-icon.fox-theme {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-foxess);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.inverter-icon.deye-theme {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-deye);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.inverter-icon svg {
  width: 22px;
  height: 22px;
}

.inverter-brand {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.inverter-model {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-indicator.offline {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
}

.status-indicator.offline .status-dot {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.inverter-metric-featured {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  display: block;
}

.metric-large {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.highlight-teal {
  color: #34d399;
}

.highlight-blue {
  color: #60a5fa;
}

.metric-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.inverter-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.detail-cell {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-val {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.inverter-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sn-text code {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* Chart Card */
.chart-card {
  grid-column: span 2;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.chart-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  width: 12px;
  height: 4px;
  border-radius: 2px;
}

.color-total { background: var(--color-sun); }
.color-fox { background: var(--color-foxess); }
.color-deye { background: var(--color-deye); }

.chart-canvas-wrapper {
  width: 100%;
  height: 240px;
  position: relative;
}

#solarChart {
  width: 100%;
  height: 100%;
}

/* System Architecture Card */
.system-info-card {
  grid-column: span 2;
  background: rgba(14, 20, 33, 0.5);
}

/* Footer */
.app-footer {
  margin-top: 36px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .hero-card, .chart-card {
    grid-column: span 1;
  }

  .hero-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .power-stats-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .app-container {
    padding: 12px 10px 36px 10px;
  }

  .app-header {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .brand-group {
    justify-content: space-between;
  }

  .header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .dashboard-grid {
    gap: 16px;
  }

  .card {
    padding: 18px 16px;
    border-radius: var(--radius-md);
  }

  .hero-top {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  .power-num {
    font-size: clamp(2.4rem, 10vw, 3.6rem);
  }

  .power-stats-strip {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-box {
    padding: 12px 14px;
  }

  .ratio-section {
    padding: 12px 14px;
  }

  .ratio-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .inverter-metric-featured {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
  }

  .inverter-metric-featured .text-right {
    text-align: left;
  }

  .inverter-details-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .chart-canvas-wrapper {
    height: 200px;
  }

  .chart-header {
    flex-direction: column;
    gap: 8px;
  }
}

