@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-color: #f9fafb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --radius: 8px;
  
  --color-cold: #3b82f6;
  --color-hot: #f97316;
  --color-normal: #10b981;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  padding: 2rem;
  line-height: 1.5;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--card-border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.dashboard-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: #ffffff;
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  border: 1px solid var(--card-border);
  font-size: 0.875rem;
}

.nav-link:hover {
  background: #f3f4f6;
}

.nav-link.active {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: var(--primary);
}

.controls-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls-form label {
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 0.5rem;
}

.time-btn {
  background: #ffffff;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
}

.time-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.kpi-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

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

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

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(450px, 100%), 1fr));
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.chart-header {
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.chart-container {
  width: 100%;
  height: 350px;
  position: relative;
}

/* Electricity price (smartCONTROL / EPEX spot) card */
.price-card {
  margin-bottom: 2rem;
}

.price-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.price-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 1rem 0;
}

.price-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.price-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.price-stat-val {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-main);
}

.price-legend {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.price-key {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.price-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  display: inline-block;
}

.price-swatch-now {
  background: #fff;
  border: 2px solid #111827;
}

@media (max-width: 640px) {
  .price-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Pufferspeicher state-of-charge card */
.puffer-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.puffer-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.puffer-title {
  font-weight: 600;
  color: var(--text-main);
}

.puffer-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.puffer-body {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: center;
}

.puffer-gauge {
  width: 220px;
  flex: 0 0 220px;
  margin: 0 auto;
}

.puffer-gauge svg {
  display: block;
  width: 100%;
  height: auto;
}

.puffer-track {
  fill: none;
  stroke: #eceef1;
  stroke-width: 18;
  stroke-linecap: round;
}

.puffer-fill {
  fill: none;
  stroke: var(--color-normal);
  stroke-width: 18;
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s ease, stroke 0.3s ease;
}

.puffer-num {
  fill: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 46px;
  font-weight: 700;
}

.puffer-sign {
  fill: var(--text-muted);
  font-size: 22px;
}

.puffer-lbl {
  fill: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
}

.puffer-right {
  flex: 1 1 260px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.puffer-strat {
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.puffer-layer {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.puffer-layer span:last-child {
  font-weight: 600;
  color: var(--text-main);
}

.strat-hot { background: #fff7ed; }
.strat-hot span:last-child { color: #c2410c; }
.strat-warm { background: #fef3c7; }
.strat-warm span:last-child { color: #b45309; }
.strat-mid { background: #fffbeb; }
.strat-mid span:last-child { color: #b45309; }
.strat-cool { background: #eff6ff; }
.strat-cool span:last-child { color: #1d4ed8; }

.puffer-stats {
  display: flex;
  gap: 1rem;
}

.puffer-stat {
  flex: 1;
  background: #f9fafb;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}

.puffer-stat .k {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.puffer-stat .v {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.2rem;
}

/* Generic radial gauge (shared by the buffer and climate cards) */
.gauge {
  width: 200px;
  max-width: 100%;
}

.gauge svg {
  display: block;
  width: 100%;
  height: auto;
}

.gauge-track {
  fill: none;
  stroke: #eceef1;
  stroke-width: 18;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke: var(--color-normal);
  stroke-width: 18;
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s ease, stroke 0.3s ease;
}

.gauge-num {
  fill: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 42px;
  font-weight: 700;
}

.gauge-sign {
  fill: var(--text-muted);
  font-size: 20px;
}

.gauge-lbl {
  fill: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

/* Climate / mould-risk card (ACG) */
.climate-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.climate-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.climate-title {
  font-weight: 600;
  color: var(--text-main);
}

.climate-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.climate-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.climate-room {
  flex: 1 1 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.climate-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.climate-room-name {
  font-weight: 600;
  color: var(--text-main);
}

.climate-temp {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.climate-risk {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.risk-good { background: #ecfdf5; color: #047857; }
.risk-warn { background: #fffbeb; color: #b45309; }
.risk-crit { background: #fef2f2; color: #b91c1c; }

/* History table */
.history-table-container {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.history-table th, .history-table td {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
}

.history-table th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.history-table tr:last-child td {
  border-bottom: none;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper {
  width: 100%;
  max-width: 380px;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.925rem;
  margin-bottom: 1.5rem;
}

.login-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.login-card input[type="email"],
.login-card input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.925rem;
  color: var(--text-main);
}

.login-card input[type="email"]:focus,
.login-card input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-main);
  cursor: pointer;
}

.remember-row input {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.login-btn {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.login-btn:hover {
  background: var(--primary-hover);
}

.errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.errors ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Responsive: stack the header and wrap the navigation on small screens */
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
  }

  .nav-links {
    flex-wrap: wrap;
    width: 100%;
  }

  .controls-form {
    flex-wrap: wrap;
    width: 100%;
  }
}
