/* Weinberghaus dashboard — light theme, Weinberg red-wine palette */

:root {
  --bg: #faf5f1;
  --card: #ffffff;
  --ink: #2f2326;
  --muted: #8a7679;
  --line: #eddfd8;
  --accent: #8e3b46;        /* Weinberg wine */
  --accent-soft: #f6e8e6;
  --accent-2: #c2703d;      /* terracotta */
  --green: #3f7d54;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(142, 59, 70, 0.06), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

/* ---- header ---- */

.topbar {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.4rem;
  background: var(--card);
  border-bottom: 3px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 0.7rem; }
.brand h1 {
  font-size: 1.25rem;
  margin: 0;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.02em;
}
.brand h1::before { content: "🍷 "; font-size: 1.05rem; }
.subtitle { color: var(--muted); font-size: 0.85rem; }

.status { display: flex; align-items: center; gap: 0.35rem; color: var(--muted); }
.status label { font-size: 0.75rem; margin-right: 0.5rem; }
.st {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; background: #d8c7c2;
}
.st-green { background: var(--green); }
.st-amber { background: #d99a2b; }
.st-red { background: #c0392b; }
.st-gray { background: #d8c7c2; }

.updated { margin-left: auto; color: var(--muted); font-size: 0.8rem; }

/* ---- layout ---- */

main { max-width: 1220px; margin: 1rem auto; padding: 0 1rem 2rem; display: grid; gap: 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
  box-shadow: 0 1px 3px rgba(94, 44, 51, 0.06);
  min-width: 0; /* allow shrinking below canvas min-content (grid item) */
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }

.card h3 { margin: 0 0 0.4rem; font-size: 0.9rem; font-weight: 700; color: var(--accent); }
.chart-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.chart-hint { margin: -0.2rem 0 0.4rem; font-size: 0.72rem; color: var(--muted); }

.card-sub { color: var(--muted); font-size: 0.74rem; margin: -0.2rem 0 0.4rem; }

.big { font-size: 1.7rem; font-weight: 700; }
.big-sm { font-size: 1.15rem; font-weight: 700; display: block; }
.sub { color: var(--muted); font-size: 0.8rem; }
.muted { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }

.pill {
  font-size: 0.72rem; font-weight: 600; padding: 0.1rem 0.55rem;
  border-radius: 999px; vertical-align: middle; margin-left: 0.4rem;
}
.pill-on { background: #e2efe4; color: var(--green); }
.pill-off { background: #f4ece9; color: var(--muted); }

.pv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; }
.pv-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.fc-row { display: flex; align-items: baseline; gap: 0.8rem; }

.spark { margin-top: 0.4rem; }
.spark .uplot { width: 100%; }

/* compact chart legends (esp. mobile): flow inline instead of one per row */
.u-legend { font-size: 11px; }
.u-legend tr { display: inline-block; margin-right: 12px; }
.u-legend th { font-weight: 500; padding: 0 2px; }
.u-legend td { padding: 0 2px; }

/* ---- range buttons ---- */

.range { display: flex; gap: 0.3rem; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 9px; padding: 0.25rem 0.7rem; font-size: 0.78rem; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- diagram ---- */

.diagram-wrap { padding: 0.6rem; }
#diagram svg { width: 100%; height: auto; display: block; }

.diagram .d-box { fill: #fffdfa; stroke: #e8d8d0; stroke-width: 1.5; }
.diagram .d-house { fill: #fdf8f4; stroke: #dcc4bb; stroke-width: 2; }
.diagram .d-outside { fill: #f4ede8; }
.diagram .d-panel { fill: #fcf7f3; }
.diagram .d-boiler { fill: #fdf0ea; stroke: #f0cfc0; }
.diagram .d-wp { fill: #fdf0ea; stroke: #f0cfc0; }
.diagram .d-hk1 { fill: #f8eeec; stroke: #e3c2ba; }
.diagram .d-tank { fill: #f9f0f0; stroke: #c98d95; stroke-width: 2; }
.diagram .d-fwm { fill: #f7eff4; stroke: #d5bcca; }

.diagram .d-txt { font-family: inherit; }
.diagram .d-house-label {
  font-size: 14px; font-weight: 600; fill: #b08d85; letter-spacing: 0.06em;
  font-family: Georgia, "Times New Roman", serif;
}
.diagram .d-title { font-size: 14px; font-weight: 600; fill: #6d4a44; }
.diagram .d-sub { font-size: 11px; fill: #9c8480; }
.diagram .d-room-label { font-size: 12px; font-weight: 500; fill: #5d4640; }
.diagram .d-big { font-size: 21px; font-weight: 700; fill: #3c2529; }
.diagram .d-foot { font-size: 11px; fill: #a68f8a; }

/* temperature chips: tappable → detail chart */
.diagram .d-chip { cursor: pointer; }
.diagram .d-chip:hover [data-bg] { stroke: var(--accent); stroke-width: 2; }
.diagram .d-chip-val { font-size: 13.5px; font-weight: 700; fill: #fff; }
.diagram .d-chip-bg { stroke: rgba(0, 0, 0, 0.15); transition: stroke 0.15s; }
.diagram .d-chip-label { font-size: 10px; font-weight: 600; fill: #8a7679; }

.diagram .d-pill { stroke: #d8c7c2; stroke-width: 1; }
.diagram .d-pill-txt { font-size: 11.5px; font-weight: 700; fill: #8a7679; }

.diagram .d-pipe {
  fill: none;
  stroke: #c6ada6;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.diagram .d-pipe-dashed { stroke-dasharray: 3 7; stroke-width: 3; }
.diagram .d-pipe.flow {
  stroke: var(--accent);
  stroke-dasharray: 11 9;
  animation: pipedash 0.9s linear infinite;
}
@keyframes pipedash { to { stroke-dashoffset: -20; } }

/* ---- detail modal ---- */

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(47, 35, 38, 0.45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-card {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(47, 35, 38, 0.25);
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 1rem 1.2rem 1.2rem;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.modal-head h3 { margin: 0; }
.modal-close {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: 0.85rem;
  line-height: 1;
}
.modal-close:hover { border-color: var(--accent); color: var(--accent); }
.modal-sub { margin: 0 0 0.5rem; font-size: 0.76rem; }
.modal[hidden] { display: none; }

/* ---- footer ---- */
.foot { color: var(--muted); font-size: 0.75rem; text-align: center; padding: 0.5rem; }
.foot code { background: #f1e6e0; padding: 0 0.3rem; border-radius: 4px; }
