/* Ecodan Cloud – one stylesheet for the whole app. Mobile first, no
   external dependencies. One colour scheme for everyone: light blue-grey
   ("Modrá", Jirka 2026-10-03), not following the system setting, with
   3D depth: shadows and soft gradients (Jirka 2026-10-20). */

:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --fg: #1c2530;
  --muted: #5e6b78;
  --faint: #8d98a5;
  --border: #e1e6ec;
  --border-strong: #c9d1da;
  --accent: #1f6fd1;
  --accent-soft: #e5effb;
  --on-accent: #ffffff;
  --heat: #e0663a;
  --water: #3a8ee6;
  --ok: #2e8540;
  --ok-soft: #e4f3e7;
  --bad: #c9372c;
  --bad-soft: #fbe9e7;
  --bad-faint: #fdf3f1; /* background of an installation card with a heat pump fault */
  --idle: #8d98a5;
  --idle-soft: #eef1f4;
  /* Charts: colours of text states on the timeline. */
  --c1: #1f6fd1;
  --c2: #e0663a;
  --c3: #2e8540;
  --c4: #8a5cc7;
  --c5: #d4a017;
  --c6: #3aa6a0;
  /* 3D depth: raised cards and buttons, sunken inputs and switch tracks. */
  --grad-surface: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
  --grad-bar: linear-gradient(180deg, #ffffff, #f7f9fc);
  --grad-accent: linear-gradient(180deg, #3483e3, #1a63c0);
  --grad-raised: linear-gradient(180deg, #ffffff, #eef2f7);
  --shadow-card: inset 0 1px 0 #ffffff, 0 2px 4px rgb(22 40 70 / 0.06), 0 8px 22px rgb(22 40 70 / 0.09);
  --shadow-bar: 0 2px 10px rgb(22 40 70 / 0.08);
  --shadow-button: inset 0 1px 0 rgb(255 255 255 / 0.25), 0 2px 5px rgb(22 40 70 / 0.28);
  --shadow-raised: inset 0 1px 0 #ffffff, 0 1px 3px rgb(22 40 70 / 0.14);
  --shadow-sunken: inset 0 1px 3px rgb(22 40 70 / 0.1);
  --shadow-track: inset 0 1px 3px rgb(22 40 70 / 0.25);
  --shadow-knob: 0 1px 3px rgb(22 40 70 / 0.4);
  --shadow-pill: 0 1px 2px rgb(22 40 70 / 0.08);
  --shadow-dot: drop-shadow(0 1px 2px rgb(22 40 70 / 0.35));
  --shadow-track-svg: drop-shadow(0 1px 1px rgb(22 40 70 / 0.12));
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.45rem; font-weight: 600; margin: 0; }
h2 { font-size: 1rem; font-weight: 600; margin: 0 0 0.6rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--bad); }

.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }

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

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--grad-bar);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-bar);
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 750; font-size: 1.15rem; letter-spacing: -0.01em; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand .logo { width: 2rem; height: 2rem; }
.topbar nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; font-size: 0.95rem; }
.topbar nav form { margin: 0; }
.user { color: var(--muted); }
a.user:hover { color: var(--fg); }

main { padding: 1rem; max-width: 72rem; margin: 0 auto; }
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin: 0.25rem 0 1rem;
}
.page-head .title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.back { display: inline-block; margin-bottom: 0.5rem; font-size: 0.95rem; }

.grid { display: grid; gap: 0.75rem; margin-bottom: 0.75rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.grid-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 48rem) {
  .grid-tiles { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1rem 1.15rem;
}
.card.narrow { max-width: 24rem; margin: 2.5rem auto; }
.card-title { display: flex; align-items: center; gap: 0.45rem; margin: 0 0 0.6rem; color: var(--muted); font-size: 0.9rem; font-weight: 500; }

.tile {
  background: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 0.85rem 1rem;
}
.tile .label { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.85rem; }
.tile .value { font-size: 1.6rem; font-weight: 600; margin-top: 0.15rem; white-space: nowrap; }
.tile .value small { font-size: 0.95rem; font-weight: 500; color: var(--muted); }

/* ---------------------------------------------------------------- status */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-pill);
}
.pill::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.pill.online, .badge.online { background: var(--ok-soft); color: var(--ok); }
.pill.lost, .badge.lost { background: var(--bad-soft); color: var(--bad); }
.pill.never, .badge.never { background: var(--idle-soft); color: var(--idle); }

/* Older name used on the service pages. */
.badge { display: inline-flex; align-items: center; padding: 0.15rem 0.7rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600; box-shadow: var(--shadow-pill); }

.alert {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-weight: 500;
  margin: 0 0 0.75rem;
}

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

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--grad-accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-button);
}
button.link { margin: 0; padding: 0; background: none; color: var(--accent); font-weight: normal; box-shadow: none; }
button.round {
  margin: 0;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border-radius: 50%;
  background: var(--grad-raised);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-raised);
}
button[disabled] { cursor: not-allowed; opacity: 0.55; }

.switch {
  position: relative;
  display: inline-block;
  width: 2.6rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--border-strong);
  flex: none;
  box-shadow: var(--shadow-track);
}
.switch::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-knob);
  transition: left 0.15s;
}
.switch.on { background: var(--accent); }
.switch.on::after { left: 1.3rem; }
button.switch { margin: 0; padding: 0; border: 0; cursor: pointer; }
button.switch[disabled] { opacity: 0.55; cursor: not-allowed; }
/* Waiting for the unit to confirm a change: spinning knob, pulsing target. */
.switch.pending { opacity: 0.7; cursor: progress; }
.switch.pending::after {
  box-sizing: border-box; border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}
/* Thermostat ring that sets the target by click or drag; title opens the chart. */
.dial.draggable { cursor: pointer; touch-action: none; }
.chart-link { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; }
.chart-link:hover { color: var(--fg); }
.thermostat:has(.controls.pending) .target { animation: pulse 1.2s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ----------------------------------------------------------------- forms */

label { display: block; margin-top: 0.75rem; font-weight: 500; }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=number], select, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  margin-top: 0.25rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  box-shadow: var(--shadow-sunken);
}

fieldset.wifi, fieldset.setup { margin: 1rem 0 0; padding: 0.2rem 0.9rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
fieldset.wifi legend, fieldset.setup legend { padding: 0 0.3rem; font-weight: 600; }

/* ------------------------------------------------------------ thermostat */

.thermostat { text-align: center; }
/* Half-circle dial (variant D, 2026-10-19): arc = current temperature, dot = target. */
.thermostat svg.dial { width: 100%; max-width: 15rem; height: auto; display: block; margin: 0 auto; }
.thermostat .track { fill: none; stroke: var(--border); stroke-width: 11; stroke-linecap: round; }
.thermostat .arc { fill: none; stroke-width: 11; stroke-linecap: round; }
.thermostat .track { filter: var(--shadow-track-svg); }
.thermostat .dot { fill: var(--surface); stroke-width: 3.5; filter: var(--shadow-dot); }
.thermostat.heating .arc, .thermostat.heating .dot { stroke: var(--heat); }
.thermostat.dhw .arc, .thermostat.dhw .dot { stroke: var(--water); }
.thermostat .now { font-size: 32px; font-weight: 600; fill: var(--fg); }
.thermostat .now-label { font-size: 13px; fill: var(--muted); }
.thermostat .scale-label { font-size: 12px; fill: var(--faint); }
.thermostat .shift-value { font-size: 32px; font-weight: 600; fill: var(--heat); }
.thermostat .dial-note { margin: 0.5rem 0 0; }
/* Target with − / + below the dial. */
.thermostat .controls {
  display: inline-flex; align-items: center; gap: 0.2rem; margin-top: 0.3rem; padding: 0.25rem;
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: 999px;
}
.thermostat .controls button.round { width: 2.4rem; height: 2.4rem; }
.thermostat .target { display: flex; flex-direction: column; min-width: 4.6rem; padding: 0 0.3rem; line-height: 1.15; }
.thermostat .target-value { font-size: 1.45rem; font-weight: 600; }
.thermostat .target-label { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.thermostat.heating .target-value { color: var(--heat); }
.thermostat.dhw .target-value { color: var(--water); }

/* ----------------------------------------------------------- energy bars */

.bar-row { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.95rem; }
.bar { height: 0.55rem; background: var(--surface-soft); border-radius: 999px; margin: 0.35rem 0 0.85rem; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; }
.bar .heat { background: var(--heat); }
.bar .power { background: var(--water); }

/* ----------------------------------------------------------------- lists */

.rows { list-style: none; margin: 0; padding: 0; }
.rows li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
}
.rows li:first-child { border-top: 0; }
.rows .name { display: flex; align-items: center; gap: 0.5rem; }
.good { color: var(--ok); }
.bad { color: var(--bad); }

/* Installation cards (overview). */
.installation { display: block; color: inherit; }
.installation:hover { text-decoration: none; border-color: var(--border-strong); }
.installation.problem { border-color: var(--bad); }
.installation.fault { background: var(--bad-faint); }
.installation .head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.installation .head h2 { margin: 0; }

.units { list-style: none; margin: 0; padding: 0; }
.unit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}
.unit:first-child { border-top: 0; }
.uid { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 0.88rem; }

/* --------------------------------------------------- service unit detail */

.unit-head h1 { margin-bottom: 0.5rem; }
.unit-head p { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin: 0 0 0.75rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

main > div > .card, main > div > details.card { margin-bottom: 0.75rem; }
details.card summary { cursor: pointer; list-style: revert; }
details.card summary h2 { display: inline; }

table.values { width: 100%; border-collapse: collapse; }
table.values th, table.values td { padding: 0.4rem 0.25rem; border-top: 1px solid var(--border); vertical-align: top; }
table.values tr:first-child th, table.values tr:first-child td { border-top: 0; }
table.values th { text-align: left; font-weight: normal; }
table.values td.value { text-align: right; font-weight: 600; white-space: nowrap; }
table.values td.small { text-align: right; width: 5rem; }

/* History of changes (staff). */
.table-scroll { overflow-x: auto; }
table.history { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.history th { text-align: left; font-weight: 600; color: var(--muted); padding: 0 0.5rem 0.4rem; }
table.history td { padding: 0.45rem 0.5rem; border-top: 1px solid var(--border); vertical-align: top; }
table.history .nowrap { white-space: nowrap; }
.pager { display: flex; gap: 0.5rem; justify-content: center; }
@media (max-width: 640px) {
  /* One block per change: when + who, what, change + result. */
  table.history, table.history tbody { display: block; }
  table.history thead { display: none; }
  table.history tr { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.75rem; padding: 0.55rem 0; border-top: 1px solid var(--border); }
  table.history tbody tr:first-child { border-top: 0; }
  table.history td { padding: 0; border: 0; }
  table.history td.who, table.history td.result { text-align: right; }
  table.history td.what { grid-column: 1 / -1; font-weight: 600; }
  table.history td.uid { grid-column: 1 / -1; }
}
@media (max-width: 30rem) {
  table.values td.small { display: none; }
}

/* ------------------------------------------------------------ management */

.grid-3 { grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.toolbar .search input { width: 16rem; margin: 0; }
.toolbar .button { margin: 0; }

.button.secondary, button.secondary {
  background: var(--grad-raised);
  box-shadow: var(--shadow-raised);
  color: var(--fg);
  border: 1px solid var(--border-strong);
}
.button:hover { text-decoration: none; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.icon-button { margin: 0; padding: 0.3rem; line-height: 0; color: var(--muted); }
.alert .text { flex: 1 1 auto; }
.alert .small-button { flex: none; }
.alert form { flex: none; margin: 0; }
.installation .stuck { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0 0; }
button.icon-button:hover { color: var(--bad); }
button.small-button { margin: 0; padding: 0.3rem 0.75rem; font-size: 0.85rem; }

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  margin: 0 0 0.75rem;
}
.unassigned { border-color: var(--accent); margin-bottom: 0.75rem; }
.unassigned .unit form { margin: 0; }
.banner .text { flex: 1 1 18rem; color: var(--fg); }
.banner .button { margin: 0; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0; }
.inline-form select { width: auto; margin: 0; }
.inline-form button, .inline-form .button { margin: 0; padding: 0.45rem 0.9rem; }

.installation h2 a { color: var(--fg); }
.installation .subtitle { margin: 0 0 0.4rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--border); font-size: 0.92rem; }

.form-page { display: grid; gap: 0.75rem; max-width: 34rem; }
.form-title { font-size: 1.2rem; margin-bottom: 0.25rem; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: normal; margin-top: 1rem; }
label.check input { width: 1.1rem; height: 1.1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
.form-actions .button, .form-actions button { margin: 0; }
.note { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; margin: 0.5rem 0 0; }
.unit .grow { flex: 1; }
.unit form { margin: 0; }
.add-unit { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.9rem 0 0.4rem; }
.add-unit select { flex: 1 1 10rem; width: auto; margin: 0; }
.add-unit button { margin: 0; }
.service-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.service-head .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.service-head .button { margin: 0 0 0.6rem; padding: 0.35rem 0.8rem; font-size: 0.9rem; }

.messages { margin-bottom: 0.75rem; }
.message { margin: 0 0 0.5rem; padding: 0.6rem 1rem; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.message.error { background: var(--bad-soft); color: var(--bad); }

/* --------------------------------------------------------- unit entities */

.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  padding: 0.7rem 1rem;
}
.sticky-bar input[type=search] { width: 15rem; margin: 0; }
.sticky-bar button { margin: 0; }
.grow { flex: 1; }
.entity-group { margin-bottom: 0.75rem; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.group-head h2 { margin: 0; }
.entity-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); column-gap: 1.5rem; }
label.entity {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
  font-weight: normal;
  font-size: 0.93rem;
  cursor: pointer;
}
/* All entities (staff, installation page) */
.all-entities .service-head input[type=search] { width: 15rem; margin: 0 0 0.6rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.tab {
  margin: 0;
  padding: 0.35rem 0.8rem;
  font-size: 0.9rem;
  background: var(--grad-raised);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-raised);
}
.tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.all-entities details.entity-group { border-top: 1px solid var(--border); padding: 0.5rem 0; margin: 0; }
.all-entities details.entity-group summary { cursor: pointer; }
.all-entities details.entity-group[open] summary { margin-bottom: 0.3rem; }
.entity-value {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.93rem;
}
.entity-value .value { font-weight: 600; white-space: nowrap; }
.entity-value[hidden], .entity-group[hidden] { display: none; }
@media (max-width: 30rem) {
  .all-entities .service-head input[type=search] { width: 100%; }
}

label.entity input { width: 1.05rem; height: 1.05rem; flex: none; }
label.entity .value { white-space: nowrap; }

/* Firmware page */
.steps { margin: 0.75rem 0 1rem; padding-left: 1.25rem; display: grid; gap: 0.35rem; }
pre.log { background: var(--idle-soft); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; font-size: 0.78rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.spinner { display: inline-block; width: 0.9rem; height: 0.9rem; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; vertical-align: -0.1rem; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.unit-new { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.9rem; }
.unit-new select { flex: 0 1 10rem; width: auto; margin: 0; }
.unit-new button { margin: 0; }
.unit-new .muted { flex: 1 1 100%; }
/* Until ESP Web Tools has loaded, show only the button. */
esp-web-install-button:not(:defined) [slot="unsupported"],
esp-web-install-button:not(:defined) [slot="not-allowed"] { display: none; }

/* ESPs in stock (overview) */
.stock { margin-top: 0.75rem; }
.stock .service-head form, .stock .unit form { margin: 0; }
.stock .service-head button { margin: 0 0 0.6rem; padding: 0.35rem 0.8rem; font-size: 0.9rem; }

/* Dashboard: main switch, header info, thermostat corners */
.main-switch { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.main-switch .name { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; flex: 1; }
.header-info { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; align-items: center; }
.header-info span { display: inline-flex; align-items: center; gap: 0.3rem; }
.thermostat-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; }
.thermostat-head .card-title { margin: 0; }
.thermostat-head .corner { display: inline-flex; align-items: center; gap: 0.45rem; }
/* What the heat pump runs, in the card's top right corner (animated). */
.thermostat-head .run { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 500; }
.thermostat-head .run:not(:last-child) { margin-right: 0.4rem; }
.thermostat.heating .run { color: var(--heat); }
.thermostat.dhw .run, .thermostat .run.defrost { color: var(--water); }
.run.pump .icon { animation: spin 3s linear infinite; }
.run.compressor .icon { animation: spin 1.2s linear infinite; }
.run.defrost .icon { animation: spin 6s linear infinite, pulse 2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .run .icon { animation: none; } }

/* ---------------------------------------------------------------- charts */

/* Anything with a chart behind it can be clicked. */
[data-chart] { cursor: pointer; }
.tile[data-chart]:hover, .card[data-chart]:hover { border-color: var(--border-strong); }
.rows li[data-chart]:hover .name, table.values tr[data-chart]:hover th,
.entity-value[data-chart]:hover .grow, .header-info [data-chart]:hover { color: var(--accent); }
[data-chart]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chart-dialog {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
}
.chart-dialog::backdrop { background: rgba(28, 37, 48, 0.45); }
@media (max-width: 40rem) {
  .chart-dialog { width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; margin: 0; border-radius: 0; border: 0; }
}
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; }
.chart-head h2 { display: flex; align-items: center; gap: 0.45rem; margin: 0; }
.chart-head .icon-button { background: none; padding: 0.4rem; box-shadow: none; }
.chart-head .icon-button:hover { color: var(--fg); }
.chart-periods { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chart-periods button {
  margin: 0;
  padding: 0.3rem 0.75rem;
  font-size: 0.88rem;
  background: var(--grad-raised);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-raised);
}
.chart-periods button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chart-custom { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 0.75rem; margin-top: 0.6rem; }
.chart-custom label { margin: 0; font-size: 0.88rem; }
.chart-custom input {
  display: block;
  margin-top: 0.2rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  box-shadow: var(--shadow-sunken);
}
.chart-custom button { margin: 0; padding: 0.45rem 1rem; }
.chart-custom[hidden] { display: none; }
.chart-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0.75rem 0 0.5rem; }
.chart-nav .round { width: 2.2rem; height: 2.2rem; }
.chart-range { font-size: 0.9rem; color: var(--muted); text-align: center; }
.chart-box { min-height: 2rem; }
.chart-box.loading { opacity: 0.45; }
.chart-message { text-align: center; margin: 1.5rem 0; }
.chart-stats { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 0.75rem 0 0; }
.chart-stats div { display: flex; flex-direction: column; }
.chart-stats dt { color: var(--muted); font-size: 0.82rem; }
.chart-stats dt::first-letter { text-transform: uppercase; }
.chart-stats dd { margin: 0; font-weight: 600; }
.chart-note { margin: 0.6rem 0 0; }
.chart-box .uplot { font-family: inherit; }
.chart-box .u-legend { font-size: 0.85rem; text-align: left; }

.timeline { position: relative; height: 2.2rem; margin-top: 0.5rem; border-radius: var(--radius-sm); background: var(--idle-soft); overflow: hidden; }
.timeline .segment { position: absolute; top: 0; bottom: 0; }
.timeline-axis { display: flex; justify-content: space-between; margin-top: 0.3rem; }
@media (max-width: 30rem) {
  .timeline-axis span:nth-child(2) { display: none; }
}
.timeline-info { min-height: 1.3rem; margin: 0.4rem 0; }
.timeline-legend { list-style: none; margin: 0; padding: 0; }
.timeline-legend li { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0; border-top: 1px solid var(--border); }
.timeline-legend li:first-child { border-top: 0; }
.swatch { width: 0.9rem; height: 0.9rem; border-radius: 3px; flex: none; }
.segment.c1, .swatch.c1 { background: var(--c1); }
.segment.c2, .swatch.c2 { background: var(--c2); }
.segment.c3, .swatch.c3 { background: var(--c3); }
.segment.c4, .swatch.c4 { background: var(--c4); }
.segment.c5, .swatch.c5 { background: var(--c5); }
.segment.c6, .swatch.c6 { background: var(--c6); }
.segment.bad, .swatch.bad { background: var(--bad); }
.segment.none { background: transparent; }

/* Customers of an installation, e-mail for the customer */
.customers .unit strong { font-weight: 600; }
.add-customer { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.9rem 0 0.4rem; }
.add-customer input { flex: 1 1 12rem; width: auto; margin: 0; }
.add-customer button { margin: 0; }
.mail-head { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; align-items: center; margin: 0.75rem 0; }
.mail-head dt { color: var(--muted); }
.mail-head dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; word-break: break-all; }
.invite textarea { font-family: inherit; font-size: 0.93rem; line-height: 1.45; resize: vertical; }
.forgot { margin: 1rem 0 0; }

/* Staff dashboard: checkbox "the customer sees this" at every value. */
.customer-check {
  width: 1.05rem; height: 1.05rem; margin: 0 0.4rem 0 0; padding: 0;
  flex: none; vertical-align: -0.15rem; accent-color: var(--accent); cursor: pointer;
}
.toast {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 20;
  margin: 0; padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  background: var(--bad); color: var(--on-accent); box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
}

/* Installation settings: heating curve points side by side. */
p.label { margin: 0.75rem 0 0; font-weight: 500; }
.curve-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.curve-inputs label { margin-top: 0.4rem; font-weight: normal; color: var(--muted); }
.curve-fill { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem 0.75rem; margin-top: 0.6rem; }
.ota { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.ota progress { width: 100%; height: 0.6rem; accent-color: var(--accent); }

/* A thermostat with the card of its options below it (core/_thermostat.html). */
/* Each column spans two rows of the grid (subgrid), so the thermostats and
   the option cards line up across the columns. */
.thermostat-column { display: grid; grid-row: span 2; grid-template-rows: subgrid; gap: 0.75rem; min-width: 0; }
.mode-select { width: auto; max-width: 60%; margin: 0; padding: 0.3rem 0.5rem; font-size: 0.9rem; }
.mode-select.pending { opacity: 0.7; cursor: progress; }
