:root {
  color-scheme: dark;
  --bg-dark: #0d1117;
  --bg-darker: #010409;
  --panel-dark: rgba(13, 17, 23, 0.95);
  --panel-light: rgba(22, 27, 34, 0.9);
  --border: rgba(48, 54, 61, 0.5);
  --text: #e6edf3;
  --text-muted: #7d8590;
  --accent-cyan: #3fb8af;
  --accent-green: #7fc29b;
  --accent-yellow: #f5d76e;
  --accent-purple: #c792ea;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
}

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

body {
  background: var(--bg-darker);
  color: var(--text);
  min-height: 100vh;
  padding: 0;
  overflow-x: hidden;
}

.dashboard {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  padding: 0;
}

/* Header */
.dashboard__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--panel-dark);
  border-bottom: 1px solid var(--border);
}

.dashboard__logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.dashboard__timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.refresh-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s;
}

.refresh-btn:hover {
  background: var(--panel-light);
}

.refresh-btn span {
  font-size: 1rem;
}

/* Main Grid Layout */
.dashboard__grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  height: 100%;
  overflow: hidden;
}

@media (max-width: 1200px) {
  .dashboard__grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
}

/* Sidebar */
.dashboard__sidebar {
  background: var(--panel-dark);
  border-right: 1px solid var(--border);
  padding: 2rem 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.sidebar__title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.stat-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stat-section h3 {
  font-size: 0.9rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.stat-value {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.stat-icon {
  font-size: 1.75rem;
}

.system-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.system-info__item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.system-info__label {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.system-info__value {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.system-info__icon {
  font-size: 1.25rem;
}

/* Installer Info */
.installer-info {
  margin-top: auto;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.installer-info__text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
}

.installer-info__link {
  display: block;
  transition: opacity 0.2s;
}

.installer-info__link:hover {
  opacity: 0.8;
}

.installer-info__logo {
  width: 100%;
  max-width: 200px;
  height: auto;
  margin: 0 auto;
  display: block;
}

/* Hide mobile footer on desktop */
.installer-info--mobile {
  display: none;
}

/* Center: Energy Visualization */
.dashboard__center {
  background: radial-gradient(ellipse at center, rgba(63, 184, 175, 0.15) 0%, var(--bg-darker) 70%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.energy-visual {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.energy-visual__house {
  position: relative;
  z-index: 1;
}

/* House Image */
.house-image {
  width: clamp(300px, 40vw, 500px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 20px 60px rgba(0, 0, 0, 0.6));
}

/* Energy Values */
.energy-value {
  position: absolute;
  background: rgba(13, 17, 23, 0.95);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 100px;
  backdrop-filter: blur(10px);
}

.energy-value__amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.energy-value__label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
}

.energy-value--pv {
  top: clamp(80px, 18%, 150px);
  left: 46%;
  transform: translateX(-50%);
}

.energy-value--pv .energy-value__amount {
  color: var(--accent-yellow);
}

.energy-value--load {
  top: clamp(100px, 22%, 180px);
  right: clamp(200px, 36%, 400px);
}

.energy-value--load .energy-value__amount {
  color: var(--accent-cyan);
}

.energy-value--battery {
  bottom: clamp(80px, 18%, 150px);
  left: clamp(200px, 40%, 400px);
}

.energy-value--battery .energy-value__amount {
  color: var(--accent-green);
}

.energy-value--grid {
  bottom: clamp(80px, 18%, 150px);
  right: clamp(180px, 32%, 350px);
}

.energy-value--grid .energy-value__amount {
  color: var(--accent-purple);
}

/* Charts */
.chart-stats {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chart-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.chart-stat:last-child {
  border-bottom: none;
}

.chart-stat__label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chart-stat__value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.chart-placeholder {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 17, 23, 0.5);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.chart-placeholder__text {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Footer (Mobile only) */
.dashboard__footer {
  display: none; /* Hidden on desktop */
  text-align: center;
  padding: 1.5rem;
  background: var(--panel-dark);
  border-top: 1px solid var(--border);
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  /* Hide desktop installer info, show mobile footer */
  .installer-info--desktop {
    display: none;
  }

  .installer-info--mobile {
    display: flex;
  }

  .dashboard__header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .dashboard__logo h1 {
    font-size: 1.2rem;
  }

  .dashboard__timestamp {
    font-size: 0.75rem;
  }

  .dashboard__grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    overflow: visible;
  }

  .dashboard__sidebar {
    padding: 1rem;
    gap: 1rem;
    max-height: none;
    overflow: visible;
    height: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .stat-section {
    gap: 0.5rem;
  }

  .stat-section h3 {
    font-size: 0.75rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-icon {
    font-size: 1.25rem;
  }

  /* Heutige Produktion: Links oben */
  .stat-section:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  /* Gesamtproduktion: Links unten */
  .stat-section:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  /* Systemübersicht: Rechts, über 2 Zeilen */
  .stat-section:nth-child(3) {
    grid-column: 2;
    grid-row: 1 / 3;
  }

  .system-info {
    gap: 1rem;
  }

  .system-info__label {
    font-size: 0.7rem;
  }

  .system-info__value {
    font-size: 0.9rem;
  }

  .system-info__icon {
    font-size: 1rem;
  }

  .installer-info__logo {
    max-width: 150px;
  }

  .dashboard__center {
    min-height: 50vh;
    height: auto;
    overflow: visible;
  }

  .energy-visual {
    width: 100%;
    height: 100%;
    padding: 1rem;
  }

  .house-image {
    width: clamp(200px, 50vw, 350px);
  }

  .energy-value {
    padding: 0.3rem 0.5rem;
    min-width: 70px;
  }

  .energy-value__amount {
    font-size: 0.75rem;
  }

  .energy-value__label {
    font-size: 0.55rem;
  }

  .energy-value--pv {
    top: 5%;
    left: 50%;
  }

  .energy-value--load {
    top: 15%;
    right: 5%;
  }

  .energy-value--battery {
    bottom: 15%;
    left: 5%;
  }

  .energy-value--grid {
    bottom: 5%;
    right: 5%;
  }
}

@media (max-width: 480px) {
  .dashboard__logo h1 {
    font-size: 1rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .house-image {
    width: clamp(200px, 80vw, 300px);
  }

  .energy-value {
    padding: 0.3rem 0.5rem;
    min-width: 70px;
  }

  .energy-value__amount {
    font-size: 0.8rem;
  }

  .energy-value__label {
    font-size: 0.55rem;
  }
}
