/* ---------- design tokens ---------- */
:root {
  --bg: #000000;           /* pure black */
  --card-bg: #0d0d0d;      /* near-black, barely lighter than bg for depth */
  --sidebar-bg: #000000;
  --text: #17c3b2;         /* turquoise — primary text color everywhere */
  --muted: #0e8074;        /* darker turquoise, secondary/caption text */
  --accent: #17c3b2;       /* turquoise, unchanged */
  --accent-danger: #e5484d; /* red, VT-active / offline / alert states */
  --border: #e5484d;       /* red borders everywhere by default */
  /* Klima's temperature color scale (see dashboard.js's formatClimateTempColor) — a
     fixed blue, not palette-varied like --accent/--accent-danger: none of the
     selectable palettes have a "cold" concept of their own, and this only ever needs
     to mean one thing (a cold room) regardless of which palette is active. */
  --temp-cold: #3b82f6;
  /* On/off state colors (appliance power buttons, integration status dots) — fixed,
     not palette-varied, same reasoning as --temp-cold: "is this on" is a universal
     signal, not a style choice, and using --accent for it broke the moment a palette's
     accent happened to be black (the default day palette, after an earlier request) —
     an "on" button rendering as a plain black circle conveys nothing. Muted/calm on
     purpose, not a loud saturated red/green, per explicit request. */
  --power-on: #4f9d6e;
  --power-off: #b5555a;
  /* Náklady tile's per-phase chart line colors — fixed, not palette-varied, same
     reasoning as --temp-cold: which phase is which needs to stay visually consistent
     regardless of the active palette. Deliberately not red/green so they never read as
     the on/off or hot/cold semantic colors used elsewhere. */
  --phase-a: #f59e0b;
  --phase-b: #6366f1;
  --phase-c: #ec4899;
  /* Text/icon color for content placed directly on an --accent background (e.g.
     .auth-form button) — palette-varied, unlike --power-on/--power-off above, because
     "readable on top of this specific accent" genuinely depends on how bright that
     accent is: dark text works here since every night palette's accent is a bright
     color on a near-black background. Day mode overrides this per palette below,
     since day accents range from pure black to bright cyan and one fixed value can't
     stay readable across all of them. */
  --accent-ink: #05100f;
  /* Dashboard-tile typography, consolidated to exactly three sizes on request (tiles
     had drifted to ~10 distinct font-sizes across Energie/Počasí/Klima/widget-card
     generics, which is what made Klima's 1.3rem temperature read as mismatched next to
     Energie's 1rem phase wattage). Not palette-varied — typography doesn't change with
     the selected color palette, only with light/dark or icon-set choices, neither of
     which affects size. */
  --fs-tile-title: 0.85rem;  /* card/section titles: .widget-card-title */
  --fs-tile-value: 1.15rem; /* emphasized numeric readouts: totals, per-phase watts,
                                per-period totals, per-room temperature — always paired
                                with font-weight: 700 wherever used, so every value-tier
                                number carries the same weight, not just Klima's */
  --fs-tile-label: 0.72rem;  /* everything else: captions, units, small labels */
  /* Default background photo for the night "default" palette — see the day-mode
     :root[data-theme="light"] block below for the matching day default, and the
     Nastavení → Vzhled entry in CLAUDE.md for the full fallback-chain mechanism. */
  --default-page-bg-image: url("/static/img/backgrounds/default-night.jpg");
}

/* Day mode — toggled on <html data-theme="light"> from the Settings page. Softer
   borders/background than the night theme's full black/red look, since a red border
   around every card reads as harsh on a bright background; the badge/status uses of
   turquoise=good / red=alert are kept as-is (see the badge rules further down). */
:root[data-theme="light"] {
  --bg: #eef2f2;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --text: #123832;
  --muted: #5b7d78;
  --accent: #000000;
  --accent-danger: #c73338;
  --border: #d8dede;
  /* Day accents are dark-to-mid across every palette except chladna-tyrkys (bright
     cyan, overridden back to dark ink below) — white text/icons on --accent read
     correctly here, whereas the base (night-mode) dark --accent-ink was invisible on
     this palette's pure black accent (reported live: "Uložit"/"Přidat" buttons were
     black-on-black). */
  --accent-ink: #ffffff;
  /* Default background photo shown behind every page when the user hasn't uploaded
     their own (Nastavení → Vzhled) — one per day palette, see the --default-page-bg-
     image declarations below and body/::before's fallback chain. No entry exists here
     for night palettes yet: a busy photo behind a dark theme needs separate curation
     to not hurt legibility, not attempted in this pass. */
  --default-page-bg-image: url("/static/img/backgrounds/default.jpg");
}

/* ---------- selectable color palettes (Nastavení → Barevná paleta) ---------- */
/* "default" (the blocks above) needs no entry here — see theme.js. Each palette below
   is a full token override, not a partial one, so nothing here depends on cascade
   order relative to the base blocks above. Night palettes reuse their own accent-danger
   as the border, matching the default night theme's pattern.

   Day palettes originally kept --card-bg literal white and near-white borders across
   every palette (matching the default theme's "soft, not harsh" reasoning) — but since
   cards are almost the entire visible surface and the sidebar was white too, that left
   only a thin strip of pastel page-background to tell palettes apart, and the user
   correctly couldn't distinguish them. Card backgrounds, the sidebar, and borders now
   all carry a visible (if still light) tint per palette instead of staying near-white,
   while keeping day palettes lighter/lower-contrast than night ones by design. */
:root[data-theme="light"][data-palette="minimal-seda"] {
  --bg: #eef1f5;
  --card-bg: #f7f9fb;
  --sidebar-bg: #e3e8ee;
  --text: #1f2937;
  --muted: #64748b;
  --accent: #475569;
  --accent-danger: #ca8a04;
  --border: #b8c4d6;
  --default-page-bg-image: url("/static/img/backgrounds/minimal-seda.jpg");
}

:root[data-theme="light"][data-palette="teply-pisek"] {
  --bg: #f2e4cd;
  --card-bg: #faf3e6;
  --sidebar-bg: #e8d5b5;
  --text: #4a2e1a;
  --muted: #8a6a4d;
  --accent: #b5541f;
  --accent-danger: #7d7f4f;
  --border: #d9b98a;
  --default-page-bg-image: url("/static/img/backgrounds/teply-pisek.jpg");
}

:root[data-theme="light"][data-palette="prirodni-zelena"] {
  --bg: #e0ede0;
  --card-bg: #f0f7ef;
  --sidebar-bg: #cfe3cf;
  --text: #1f3d28;
  --muted: #5c7a63;
  --accent: #2f7d4f;
  --accent-danger: #d97706;
  --border: #a8cbaa;
  --default-page-bg-image: url("/static/img/backgrounds/prirodni-zelena.jpg");
}

:root[data-theme="light"][data-palette="ruzova-magenta"] {
  --bg: #f7dced;
  --card-bg: #fcf0f7;
  --sidebar-bg: #f0c9e2;
  --text: #4a1030;
  --muted: #8a5a72;
  --accent: #c2247a;
  --accent-danger: #8b5cf6;
  --border: #e3a8cd;
  --default-page-bg-image: url("/static/img/backgrounds/ruzova-magenta.jpg");
}

:root[data-theme="light"][data-palette="chladna-tyrkys"] {
  --bg: #d9f0ec;
  --card-bg: #eefaf8;
  --sidebar-bg: #c2e6e0;
  --text: #123832;
  --muted: #5b7d78;
  --accent: #00b8c4;
  --accent-danger: #caa03c;
  --border: #9ed4cb;
  /* Exception to the day-mode white default above: this accent is a bright cyan, not
     dark like every other day palette's, so white text on it reads poorly — dark ink
     (the base/night default) is the readable choice here instead. */
  --accent-ink: #05100f;
  --default-page-bg-image: url("/static/img/backgrounds/chladna-tyrkys.jpg");
}

:root[data-theme="dark"][data-palette="jantarova-tma"] {
  --bg: #120f0d;
  --card-bg: #1e1815;
  --sidebar-bg: #120f0d;
  --text: #e08830;
  --muted: #a8663a;
  --accent: #e08830;
  --accent-danger: #c0392b;
  --border: #c0392b;
  --default-page-bg-image: url("/static/img/backgrounds/jantarova-tma.jpg");
}

:root[data-theme="dark"][data-palette="pulnocni-modra"] {
  --bg: #0a0e14;
  --card-bg: #131a24;
  --sidebar-bg: #0a0e14;
  --text: #4f8ff0;
  --muted: #3d6099;
  --accent: #4f8ff0;
  --accent-danger: #8b5cf6;
  --border: #8b5cf6;
  --default-page-bg-image: url("/static/img/backgrounds/pulnocni-modra.jpg");
}

:root[data-theme="dark"][data-palette="uhlova-med"] {
  --bg: #100f0c;
  --card-bg: #1a1712;
  --sidebar-bg: #100f0c;
  --text: #c07830;
  --muted: #8a5c30;
  --accent: #c07830;
  --accent-danger: #7d7f4f;
  --border: #7d7f4f;
  --default-page-bg-image: url("/static/img/backgrounds/uhlova-med.jpg");
}

:root[data-theme="dark"][data-palette="magenta-noc"] {
  --bg: #150a18;
  --card-bg: #1f1024;
  --sidebar-bg: #150a18;
  --text: #d1329b;
  --muted: #8a4d72;
  --accent: #d1329b;
  --accent-danger: #9c5fd6;
  --border: #9c5fd6;
  --default-page-bg-image: url("/static/img/backgrounds/magenta-noc.jpg");
}

:root[data-theme="dark"][data-palette="lesni-noc"] {
  --bg: #0a120d;
  --card-bg: #142218;
  --sidebar-bg: #0a120d;
  --text: #43a05e;
  --muted: #2d6d40;
  --accent: #43a05e;
  --accent-danger: #caa03c;
  --border: #caa03c;
  --default-page-bg-image: url("/static/img/backgrounds/lesni-noc.jpg");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  position: relative;
}

/* Background photo sits fixed behind everything, dimmed so text stays legible. A
   user's own uploaded photo (Nastavení → Vzhled, --page-bg-image set inline per-request
   by base.html) always wins; otherwise falls back to the active day palette's own
   --default-page-bg-image. Night palettes define neither today, so this layer is simply
   blank for them — same as before this feature existed. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--page-bg-image, var(--default-page-bg-image));
  background-size: cover;
  background-position: center;
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--page-bg-overlay, rgba(0, 0, 0, 0.75));
  z-index: -1;
}

/* Nastavení → Vzhled → "Použít výchozí pozadí" — lets the active palette's own default
   photo show even when a custom one is uploaded, without deleting/replacing that photo.
   Deliberately outranks the body::before rule above on specificity alone (two attribute/
   pseudo-class selectors vs. one type+pseudo-element), not source order or !important,
   same technique already used for [data-icons-disabled] in icons.py. */
:root[data-force-default-bg] body::before {
  background-image: var(--default-page-bg-image);
}

/* Day mode needs a light dimming overlay, not the night theme's black one — otherwise
   the uploaded photo (and everything behind it) reads as dark regardless of theme. */
:root[data-theme="light"] {
  --page-bg-overlay: rgba(255, 255, 255, 0.82);
}

/* ---------- layout / nav ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  /* Sticky, not the old min-height: 100vh flowing away with the page — stays put
     while .content scrolls, own overflow-y so a taller-than-viewport nav list (more
     items than fit) scrolls internally instead of pushing the sidebar off-screen. */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.nav-list-secondary {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
}

.sidebar-brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.3;
  padding: 2px 12px 20px 20px;
  color: var(--accent);
}

.sidebar-brand-text {
  min-width: 0;
}

.sidebar-icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.92rem;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
}

.sidebar-icon-btn:hover,
.sidebar-icon-btn.active {
  color: var(--text);
  background: rgba(23, 195, 178, 0.12);
}

.nav-list-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 0 12px 4px 0;
}

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

.nav-list a {
  display: block;
  padding: 10px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}

#main-nav-list li {
  display: flex;
  align-items: stretch;
}

#main-nav-list li a {
  flex: 1;
  min-width: 0;
}

.nav-drag-handle {
  display: none;
  align-items: center;
  padding-left: 12px;
  color: var(--muted);
  cursor: grab;
  user-select: none;
}

#main-nav-list.reordering .nav-drag-handle {
  display: flex;
}

#main-nav-list.reordering li a {
  pointer-events: none;
}

#main-nav-list li.dragging {
  opacity: 0.4;
}

/* Dashboard is pinned — always first, never draggable (see sidebar.js) — and gets a
 * bit of visual emphasis over the reorderable items below it, plus a divider so the
 * two groups read as distinct.
 */
#main-nav-list li.nav-pinned a {
  font-weight: 700;
  background: rgba(23, 195, 178, 0.06);
}

#main-nav-list li.nav-pinned {
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

#main-nav-list.reordering li.nav-pinned .nav-drag-handle {
  display: none;
}

#main-nav-list.reordering li.nav-pinned a {
  pointer-events: auto;
}

.nav-icon {
  display: inline-flex;
  flex-shrink: 0;
}

/* The actual glyph/SVG per icon_key comes from generated rules (see web/icons.py's
 * generate_icon_css(), embedded per-page in base.html's <head>) driven by the
 * data-icon-set/data-icons-disabled attributes on <html> — these are just the static,
 * set-independent sizing/spacing rules. Any element anywhere (server-rendered or
 * created later by JS) that carries data-icon-key picks up the right icon automatically.
 */
[data-icon-key]::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  line-height: 1;
}

:root:not([data-icons-disabled]) [data-icon-key] {
  margin-right: 0.35em;
}

/* #nav-edit-toggle's icon has no trailing label (icon-only button, tooltip carries the
   label instead) — the default margin-right above exists for icon+text pairs and would
   just add lopsided padding here. #id beats the :root[attr] rule above on specificity
   regardless of source order. */
#nav-edit-toggle .nav-icon {
  margin-right: 0;
}

.sidebar-reopen-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  align-items: center;
  justify-content: center;
}

:root[data-sidebar-hidden] .sidebar {
  display: none;
}

:root[data-sidebar-hidden] .sidebar-reopen-btn {
  display: flex;
}

/* Only rendered at all on non-Dashboard pages (see base.html) and only shown once the
 * sidebar is hidden — with the sidebar visible, the pinned "Dashboard" nav item is
 * already the way back, so a second control here would just be redundant clutter.
 */
.back-to-dashboard-btn {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 20;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  align-items: center;
  justify-content: center;
}

:root[data-sidebar-hidden] .back-to-dashboard-btn {
  display: flex;
}

.nav-list a:hover {
  color: var(--text);
  background: rgba(23, 195, 178, 0.08);
}

.nav-list a.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: rgba(23, 195, 178, 0.12);
}

.content {
  position: relative;
  flex: 1;
  padding: 24px;
  min-width: 0;
}

/* Specificity note: plain `.sidebar-profile-link` (class only) loses its `display: flex`
 * to `.nav-list a`'s `display: block` (class + element = higher specificity) even
 * though this rule comes later — same "author rule beats intent silently" class of bug
 * already hit a few times in this project. The `.nav-list a.` prefix here isn't just
 * cosmetic scoping, it's what actually makes flex win.
 */
.nav-list a.sidebar-profile-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}

.sidebar-profile-link:hover {
  color: var(--text);
  background: rgba(23, 195, 178, 0.08);
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background-color: var(--border);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.sidebar-profile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bg-upload-form {
  margin-top: 24px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 320px;
}

.bg-upload-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.bg-upload-form input[type="file"] {
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 100%;
}

.bg-upload-form button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.bg-upload-form button:hover {
  border-color: var(--accent);
}

.theme-mode-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 14px;
}

.theme-switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Sliding pill toggle for the day/night switch. */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  transition: background-color 0.2s;
  border-radius: 999px;
  cursor: pointer;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  /* Theme-aware, not a hardcoded white — --card-bg is already #ffffff in day mode (so
     day mode looks unchanged), but is near-black in night mode, matching the app's
     dark surfaces instead of a stray white circle. */
  background: var(--card-bg);
  transition: transform 0.2s, background-color 0.2s;
  border-radius: 50%;
}

.switch input:checked + .switch-slider {
  background: var(--accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(22px);
}

.switch input:disabled + .switch-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- color palette picker (Nastavení) ---------- */
.palette-group {
  margin-bottom: 18px;
}

.palette-group-title {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.palette-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}

.palette-card.selected {
  border-color: var(--accent);
  border-width: 2px;
}

.palette-swatches {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.palette-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(127, 163, 156, 0.3);
}

.palette-card-name {
  font-size: 0.8rem;
  font-weight: 600;
}

.palette-card-desc {
  font-size: 0.7rem;
  color: var(--muted);
}

.page-header h1 {
  margin: 0 0 20px;
  font-size: 1.5rem;
}

/* ---------- tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}

.tile-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.tile-value {
  font-size: 1.6rem;
  font-weight: 600;
}

/* Settings' chart-sections hold short forms/lists, not wide charts (unlike every
 * other page's chart-section, which does need the full content width) — capped so
 * they don't stretch edge-to-edge on a wide window.
 */
.settings-page {
  max-width: 480px;
}

/* ---------- charts ---------- */
.chart-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chart-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

/* Klima's own .chart-header uses CSS Grid instead of the base flex layout — a real
 * bug, confirmed live (user circled the empty gap where this was supposed to be):
 * putting the current-stats block in a flex row alongside the title/select meant its
 * own width (which changes depending on whether it holds 1 or 2 stacked lines)
 * affected how much space was left for flex-grow/wrap to distribute, visibly moving
 * the title/select around depending on what was inside it. Grid's outer two 1fr
 * columns reserve equal space for title/select unconditionally, regardless of
 * what the middle "auto" column contains or how tall it is — the middle column's
 * content (temperature stacked above humidity) can change all it wants without ever
 * affecting the title's or select's position again. */
.climate-chart-section .chart-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 12px;
  margin-bottom: 4px;
}

.climate-chart-section .chart-header h2 {
  justify-self: start;
}

.climate-chart-section .chart-header .climate-history-range-select {
  justify-self: end;
}

/* Theme-aware select, same pattern as .sidebar-add-widget-row select — plain
 * <select> elements otherwise render with the browser's own default (white
 * background, black text) regardless of the active palette, which read as a stray
 * white block against the dark theme (caught from a live screenshot). */
.climate-history-range-select {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
}

.range-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.range-buttons button {
  background: none;
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
}

.range-buttons button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.custom-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Real, pre-existing bug caught from a live Klima screenshot but not actually
   Klima-specific — affects every .custom-range-row usage (Spotřebiče included):
   [hidden]'s UA-stylesheet `display: none` and this class's own `display: flex`
   above are the same specificity tier, and the author stylesheet loads after the UA
   one, so `display: flex` was silently winning — the row stayed visible even while
   `hidden` was set, regardless of which range preset was actually selected. Same bug
   class already documented elsewhere in this project for any element that pairs its
   own `display` with hide/show — needs an explicit, higher-specificity override. */
.custom-range-row[hidden] {
  display: none;
}

/* Klima's own custom-range-row sits directly under its range select, which (like the
   room title) lives in .chart-header, pushed to the right edge — so this row is
   right-aligned too (unlike the base rule above, left-aligned by default), to
   actually land underneath it instead of starting from the left. Stacked vertically
   per explicit request: the from/to inputs (.climate-custom-range-inputs) on their
   own line, the "Zobrazit" button on the line below — not all one row, unlike the
   base .custom-range-row layout. Scoped to .climate-chart-section specifically —
   Spotřebiče's own custom-range-row (a full-width single row below a separate
   button-row range picker, not a header select) is untouched. */
.climate-chart-section .custom-range-row {
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.climate-custom-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-range-row input[type="date"] {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
}

.custom-range-row button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}

.history-chart-wrap {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Klima's per-room history charts (one per measurement, not one shared chart with a
   room picker) — a fixed height like .history-chart-wrap above, just a little
   shorter since there are 7 of these stacked on one page instead of one. */
.climate-chart-wrap {
  position: relative;
  height: 220px;
  width: 100%;
}

/* Caps how wide each per-room chart card can stretch (explicit request — an
   ultrawide monitor otherwise stretches .chart-section, and so the chart, edge to
   edge) and centers it in the remaining space, rather than leaving it pinned left.
   Padding/margin also tightened well below the shared .chart-section defaults
   (16px/20px padding, 24px margin-bottom) — with 7 of these stacked on one page, that
   spacing added up to a lot of the "takes way too much room" complaint this was
   built to fix. The chart itself (.climate-chart-wrap) is deliberately NOT part of
   this space-saving — explicitly asked to stay at its original 220px: the header/
   padding were the actual excess, not the chart, so only those got trimmed. */
.climate-chart-section {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 10px;
  padding: 10px 16px;
}

/* ---------- status badges (VT/NT, online/offline, coming-soon/blocked) ---------- */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-nt, .badge-online {
  background: rgba(23, 195, 178, 0.15);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.badge-vt, .badge-blocked {
  background: rgba(229, 72, 77, 0.15);
  color: var(--accent-danger);
  border: 1px solid var(--accent-danger);
}

.badge-planned {
  background: rgba(127, 163, 156, 0.15);
  color: var(--muted);
  border: 1px solid var(--muted);
}

/* ---------- widget grid (dense, resizable card layout) ---------- */
/* CSS Grid, not multi-column masonry: per-card size control (sm/md/lg) requires
   explicit grid-column/grid-row spans, which multi-column layout cannot do per-item.
   Trade-off: no perfect masonry packing, same as Home Assistant's Lovelace grid view. */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  grid-auto-rows: minmax(90px, auto);
  gap: 16px;
  /* Without this, a card's row-tracks get sized to fit whatever's tallest among every
     card sharing those tracks (e.g. two "lg" cards side by side) — CSS Grid then
     stretches every occupant of those tracks to that same height by default, leaving a
     short card's box mostly empty. `start` makes each card size to its own content and
     just leaves the leftover track space as background, not as empty card interior. */
  align-items: start;
}

/* The Dashboard's own grid holds NUM_COLUMNS (dashboard.js) independent column
   containers as its direct children — not individual cards. A shared CSS Grid row
   couples every column's row-track heights together (a tall card in one column forces
   a tall shared row for ALL columns touching it, even ones with short content), which
   showed up as both a stretched-empty-card bug and, after that fix, big dead gaps
   between short cards stacked below a tall neighboring column. Genuinely independent
   flex containers have no shared row concept at all, so neither can happen. Trade-off
   the user explicitly accepted: a card's size (sm/md/lg) no longer widens it past its
   own column — only its height/content varies now, since a card can't reach into a
   neighboring column's independent box. */
#dashboard-grid {
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  align-items: start;
}

.widget-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.widget-column-slot {
  border: 1px dashed var(--border);
  border-radius: 10px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.6;
}

.widget-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  position: relative;
}

/* size (sm/md/lg) no longer widens/heightens a card via grid spans — cards live inside
   an independent per-column flex container now (see #dashboard-grid above), so there's
   no neighboring grid track left to reach into. Size still exists as a field (and the
   resize button still cycles it) purely for potential future use; today it has no
   visual effect. Height comes entirely from a card's own content. */

a.widget-card:hover {
  border-color: var(--accent);
}

.widget-card.dragging {
  opacity: 0.4;
}

/* ---------- dashboard edit mode ---------- */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* Groups the clock/date/weather bar and the connector dots into one row, rendered once
 * in base.html above every page's own content (not just the Dashboard's own header,
 * where this originally lived — per explicit request, this is now the same on every
 * page). Real bug, caught live: as a normal (in-flow) block, this pushed every page's
 * own <h1> down by its own height — visibly, awkwardly lower than before, since it
 * used to share one row with the Dashboard's title rather than sitting above it.
 * Absolutely positioned instead, pinned to .content's own top-right padding corner
 * (see .content's `position: relative` above) — completely out of the document flow,
 * so no page's title moves at all, while still landing in the same visual top-right
 * corner this occupied when it shared a row with the Dashboard's own title. */
.page-status-row {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Clock/date/outdoor-weather glance, deliberately small and quiet — same "corner of the
 * page, not a headline" spirit as the connector dots next to it. Temperature comes
 * from the Venkovní čidlo Shelly BLU H&T sensor (see /api/climate), not the ČHMÚ/
 * Open-Meteo reading used on the Weather tile — the physical sensor at the cottage is
 * what's actually accurate for "what's it like outside right now here", per explicit
 * request; only the condition icon/description still comes from the Weather API, since
 * the sensor has no notion of "cloudy"/"rain".
 */
.page-status-bar {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--muted);
}

.page-status-time {
  font-size: var(--fs-tile-title);
  font-weight: 700;
  color: var(--text);
}

.page-status-date,
.page-status-weather {
  font-size: var(--fs-tile-label);
}

.page-status-weather .nav-icon {
  color: var(--text);
}

/* Small, deliberately understated glance-status for the Shelly/Gardena/Počasí
 * connectors — a dot per integration, colored by its own last poll_log row (see
 * /api/integration-status), with the actual detail (status + last-successful time)
 * only in the title tooltip so this stays a quiet corner of the header, not a
 * competing headline. Dashboard-only by design — this is a "how's the plumbing doing"
 * glance, not something that needs to follow you to every page.
 */
.integration-status-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Icon + dot paired per connector — the dot alone was indistinguishable between
 * Shelly/Gardena/Počasí without hovering for the tooltip, per explicit request.
 * Icon-to-dot spacing comes from [data-icon-key]'s own global margin-right, same
 * convention as every nav-icon usage elsewhere — no separate gap needed here. */
.integration-status-item {
  display: inline-flex;
  align-items: center;
}

.integration-status-icon {
  font-size: 0.85rem;
  color: var(--muted);
}

.integration-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--muted);
}

.integration-status-dot.ok {
  background: var(--power-on);
}

.integration-status-dot.fail {
  background: var(--power-off);
}

/* When the sidebar is hidden, the fixed top-left reopen button (☰, 36px wide, 12px
 * inset — see .sidebar-reopen-btn) floats directly over the Dashboard's own page
 * title, which otherwise starts right at the content area's edge. Nudge just this
 * heading right so the two never overlap; every other page's shorter, differently-
 * positioned header isn't affected.
 */
:root[data-sidebar-hidden] .dashboard-header h1 {
  margin-left: 48px;
}

.sidebar-edit-toggle {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  padding: 10px 20px;
  color: var(--muted);
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
}

.sidebar-edit-toggle:hover {
  color: var(--text);
  background: rgba(23, 195, 178, 0.08);
}

.sidebar-add-widget-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 20px;
}

.sidebar-add-widget-row select {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.76rem;
}

.sidebar-add-widget-row button {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.76rem;
  cursor: pointer;
}

.sidebar-add-widget-row button:hover {
  border-color: var(--accent);
}

/* Author rules always beat the browser's built-in [hidden]{display:none} regardless of
 * specificity — the same lesson already learned for .energy-phases etc. earlier this
 * project. Without this override, dashboard.js's `wrap.hidden = true` (outside edit
 * mode, or when there's nothing available to add) has no visual effect at all: the row
 * stays permanently visible, just empty and non-functional.
 */
.sidebar-add-widget-row[hidden] {
  display: none;
}

.widget-edit-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
}

.widget-edit-controls button {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}

.widget-edit-controls button:hover {
  border-color: var(--accent);
}

.widget-fields-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.widget-fields-toggle label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
}

.widget-fields-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.widget-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.widget-card-title {
  font-size: var(--fs-tile-title);
  color: var(--muted);
  font-weight: 600;
}

.widget-card-caption {
  font-size: var(--fs-tile-label);
  color: var(--muted);
  opacity: 0.8;
}

.widget-card-value {
  font-size: var(--fs-tile-value);
  font-weight: 700;
  margin-bottom: 6px;
}

.widget-card-link {
  font-size: var(--fs-tile-label);
  color: var(--accent);
  margin-top: 8px;
  display: inline-block;
}

/* Chart.js's responsive resize measures the canvas's *parent* box, not the canvas
   element's own CSS size — a class on the <canvas> itself (the old approach here) left
   that parent (.widget-card, now auto-sizing to content) unconstrained, causing a real
   resize feedback loop: card grows to fit the chart -> chart grows to fill the now-
   taller card -> card grows again, forever. A dedicated wrapper with a fixed height
   gives Chart.js's ResizeObserver something stable to lock onto instead. */
.widget-sparkline-wrap {
  position: relative;
  height: 54px;
  width: 100%;
}

/* A chart with visible axes (Náklady's, Weather's) needs far more room than the
 * glance-only sparklines above — reported as hard to read at 54px. Shared by any
 * Dashboard-tile chart that uses renderHistoryChart/renderMultiSeriesChart rather
 * than the axis-less renderSparkline; not the same as .history-chart-wrap (280px),
 * which is sized for a dedicated full-page chart (Spotřebiče), not a tile. */
.tile-chart-wrap {
  position: relative;
  height: 180px;
  width: 100%;
}

.widget-gauge-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 4px auto;
}

/* No top border/gap here on purpose — the phase watts belong visually with the big
   total right above them, not set apart as a separate section. */
.energy-phases {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 2px;
}

/* Voltage and current are now two independently hideable rows rather than one combined
   block — each carries its own half of the divider so hiding one doesn't leave an
   orphaned border around nothing. */
.phase-vi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.phase-vi-voltage {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 6px;
}

.phase-vi-current,
.phase-vi-pf {
  margin-top: 4px;
}

.phase-vi-apparent {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-top: 4px;
  margin-bottom: 4px;
}

.phase-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: var(--fs-tile-label);
}

.phase-power {
  color: var(--text);
  font-size: var(--fs-tile-value);
  font-weight: 700;
}

.phase-vi-row .phase-col {
  color: var(--muted);
  font-size: var(--fs-tile-label);
}

.phase-label {
  color: var(--muted);
  font-size: var(--fs-tile-label);
  margin-bottom: 2px;
}

.energy-periods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 4px;
}

/* Author `display: grid` above otherwise beats the browser's default
   `[hidden] { display: none }` rule regardless of selector specificity — without this,
   toggling a field checkbox sets the `hidden` attribute but the block stays visible. */
.energy-phases[hidden],
.phase-vi-row[hidden],
.energy-periods[hidden] {
  display: none;
}

.period-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: var(--fs-tile-value);
  font-weight: 700;
}

/* Declaring `display` above otherwise beats the browser's default
   `[hidden]{display:none}` rule regardless of specificity — same recurring fix as
   .energy-phases/.switch-row. Needed now that Náklady hides day/month/year
   individually (unlike Energie's own .period-col usage, which only ever hides the
   whole .energy-periods wrapper, never one column alone). */
.period-col[hidden] {
  display: none;
}

.period-label {
  color: var(--muted);
  font-size: var(--fs-tile-label);
  font-weight: 400;
  margin-bottom: 2px;
}

/* ---------- weather tile: hourly strip, daily grid, alerts ---------- */
/* Each lives inside a plain .wx-section wrapper (no author `display` of its own), so
   the [hidden] attribute the field-toggle checkboxes set works natively — no override
   needed here the way .phase-vi-row/.energy-phases needed one above. */
.wx-section {
  margin-top: 10px;
}

.wx-section-title {
  font-size: var(--fs-tile-label);
  color: var(--muted);
  margin-bottom: 6px;
}

.wx-hourly-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  /* Firefox: themed scrollbar via these two properties (thumb, track). */
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}

/* Chrome/Edge/Safari: the scrollbar-width/-color pair above doesn't apply, hence the
   separate ::-webkit-scrollbar rules — otherwise this strip's scrollbar stayed the
   browser's plain light-gray default regardless of theme. */
.wx-hourly-strip::-webkit-scrollbar {
  height: 6px;
}

.wx-hourly-strip::-webkit-scrollbar-track {
  background: transparent;
}

.wx-hourly-strip::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 999px;
}

.wx-hourly-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: var(--fs-tile-label);
  flex: 0 0 auto;
  min-width: 44px;
}

.wx-daily-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.wx-daily-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: var(--fs-tile-label);
  background: rgba(127, 163, 156, 0.08);
  border-radius: 8px;
  padding: 6px 4px;
}

/* Klima: one card per room, grid of small stat blocks. Deliberately no `display` on
 * `.climate-room` itself (unlike e.g. `.climate-room-header` below, which needs flex
 * for icon+name alignment) — a room can be individually hidden via the native
 * `hidden` attribute (see widgets.js's renderClimateRooms), and giving this element
 * its own `display` value would silently defeat that, the same class of bug already
 * hit a few times in this project.
 */
.climate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

/* Real bug, caught live: this used to be a fixed rgba(127, 163, 156, 0.08) — a
   near-invisible fixed tint that never adapted to the active palette (unlike every
   other card in the app, which uses --card-bg/--border) and read as an odd, barely-
   there box against a light palette's own background. Themed like every other card
   instead. */
.climate-room {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
}

.climate-room-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: var(--fs-tile-label);
  color: var(--muted);
  margin-bottom: 4px;
}

.climate-room-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Temperature is the visually dominant value — bolder than humidity, per request —
 * and gets its color set inline per-room by formatClimateTempColor()/
 * renderClimateRooms() (widgets.js), not from CSS. Same --fs-tile-value size as every
 * other emphasized tile number (phase watts, period totals) rather than its own larger
 * size, which is what made it look mismatched next to Weather/Energie. */
.climate-room-temp {
  font-size: var(--fs-tile-value);
  font-weight: 700;
}

.climate-room-humidity {
  font-size: var(--fs-tile-label);
  color: var(--muted);
}

/* Current temperature + humidity readout — the middle ("auto") column of
   .chart-header's grid (see that rule above), between the room title and the range
   select, exactly where the user pointed on a live screenshot. Safe to stack both
   here now (temperature above humidity) without repeating the earlier bug where
   humidity's presence visibly shifted temperature: that bug came from sharing a FLEX
   row with the title/select, where this block's own width affected how much space
   flex-grow/wrap left for everything else. A CSS Grid column is sized independently
   of its content's height, so stacking 1 or 2 lines in here can never again move the
   title or select. Label/value/minmax sit inline on ONE line per stat (baseline-
   aligned) — see .climate-current-stat below — not stacked in 3 lines like an early
   version of this, which made the whole card needlessly tall. The value stays
   visibly bigger than plain body text (still a real "enlarge the number", per the
   original request). */
.climate-current-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.climate-current-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.climate-current-label {
  font-size: var(--fs-tile-label);
  color: var(--muted);
}

.climate-current-value {
  font-size: 1.3rem;
  font-weight: 700;
}

.climate-current-minmax {
  font-size: var(--fs-tile-label);
  color: var(--muted);
}

.climate-room-battery {
  font-size: var(--fs-tile-label);
  color: var(--muted);
  margin-top: 2px;
}

/* Klima page's "Přehled" overview — one row per room (name, temperature, humidity,
   battery), replacing the small per-room grid cards on this page specifically (the
   Dashboard tile's own compact grid, .climate-grid/.climate-room above, is untouched
   — this is a page-only redesign). "A table without cells", per explicit request:
   climate.js emits 4 items per room as plain flat siblings (no per-row wrapper), and
   this single CSS Grid with 4 columns auto-flows them into aligned rows — real
   column alignment, no drawn table/cell borders anywhere. */
.climate-overview-table {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  column-gap: 24px;
  row-gap: 8px;
  align-items: center;
}

.climate-overview-label {
  font-size: var(--fs-tile-label);
  color: var(--muted);
}

/* Same size as .chart-header h2 below it, per explicit request — "ať jsou ty jména
   místností na pohled stejné" (so the room names look the same at a glance). */
.climate-overview-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.1rem;
  font-weight: 700;
}

.climate-overview-value {
  font-size: var(--fs-tile-value);
  font-weight: 700;
  text-align: right;
  min-width: 60px;
}

/* Zavlažování tile: a single greenhouse-sensor row (icon + temperature + humidity),
 * reusing .climate-room-temp/.climate-room-humidity verbatim so it shares the exact
 * same size/color-coding conventions as the Klima tile — just one room here instead
 * of a grid of seven, so no .climate-room/.climate-grid wrapper needed. */
.watering-sensor-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

/* Duration picker revealed by clicking the (off) watering button — reuses
 * .appliance-timer-btn's pill styling verbatim for the individual buttons (same look
 * as the Spotřebiče page's "Zapnout na čas" presets). Needs the explicit [hidden]
 * override below because it declares its own `display`, which otherwise beats the
 * browser's default `[hidden]{display:none}` rule regardless of specificity — same
 * fix already applied to .energy-phases/.phase-vi-row/.energy-periods. */
.watering-duration-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.watering-duration-row[hidden] {
  display: none;
}

.wx-alert {
  border: 1px solid var(--accent-danger);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 6px;
}

.wx-alert .badge {
  margin-bottom: 4px;
}

/* ---------- standalone /weather page: alert banner, hero, hourly/daily image
   cards, history charts ---------- */
/* Only ever rendered at all when data.alerts is non-empty (weather.js sets
   `hidden` otherwise) — no "žádné výstrahy" filler taking up space at the top of
   the page, unlike the Dashboard tile's own always-present alerts list. */
.wx-alert-banner {
  margin-bottom: 20px;
}

.wx-alert-banner-item {
  margin-top: 0;
  margin-bottom: 10px;
}

.wx-hero {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

.wx-hero-main {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.wx-hero-icon img {
  display: block;
}

/* Fills the space next to the icon+text that was otherwise empty on anything wider
   than a narrow phone — a wide photo reflecting the current sky condition (one of
   10, keyed by the same WMO icon-bucket grouping used for the pictogram; day/night
   is a CSS overlay tint on the same photo, not a separate photo per condition, see
   weather.js's renderHeroBanner). flex: 1 so it absorbs whatever width is left;
   min-width keeps it from vanishing on a narrower viewport before the mobile
   breakpoint's own layout takes over. */
.wx-hero-banner {
  position: relative;
  flex: 1;
  min-width: 160px;
  height: 140px;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
}

.wx-hero-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, 0.12);
}

.wx-hero-banner--night::after {
  background: rgba(10, 15, 30, 0.55);
}

.wx-icon-img-sm {
  vertical-align: middle;
  margin-right: 4px;
}

.wx-sun-moon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.wx-sun-moon-item {
  display: inline-flex;
  align-items: center;
}

.wx-hero-temp {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
}

.wx-hero-desc {
  font-size: 1.2rem;
  color: var(--text);
}

.wx-hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.wx-hero-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--fs-tile-value);
  font-weight: 700;
}

/* Bigger than the Dashboard tile's compact .wx-hourly-item/.wx-daily-card (those
   stay completely untouched) — this is a dedicated page, not a cramped tile, so
   there's room for the real weather image plus more breathing space per card. */
.wx-hourly-strip-page {
  gap: 14px;
  margin-bottom: 24px;
}

.wx-hourly-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 72px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.wx-hourly-card-hour {
  font-size: var(--fs-tile-label);
  color: var(--muted);
}

.wx-hourly-card-temp {
  font-size: var(--fs-tile-value);
  font-weight: 700;
}

.wx-hourly-card-precip {
  font-size: var(--fs-tile-label);
  color: var(--muted);
}

.wx-daily-grid-page {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.wx-daily-card-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 10px;
}

.wx-daily-card-page-day {
  font-size: var(--fs-tile-value);
  font-weight: 700;
}

/* Bumped up from --fs-tile-label (the smallest of this app's 3 tile font tokens) —
   this is a full page, not a cramped tile, and the condition text/temps were the
   two things specifically asked to be made bigger here. */
.wx-daily-card-page-desc {
  font-size: var(--fs-tile-value);
  color: var(--muted);
  text-align: center;
}

.wx-daily-card-page-temps {
  font-size: 1.1rem;
}

.wx-daily-card-page-detail {
  font-size: var(--fs-tile-label);
  color: var(--muted);
}

/* Meteoradar: Windy's public embed widget (no API key), centered on Vysoká Jedle's
   already-geocoded coordinates — chosen over reproducing ČHMÚ's raw radar tiles
   ourselves, since no documented bounding box was found for correctly georeferencing
   those, and a wrong guess would silently show the radar over the wrong location. */
.wx-radar-wrap {
  position: relative;
  height: 450px;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}

.wx-radar-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.widget-gauge-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
}

/* ---------- switch/appliance rows ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.switch-row:last-child {
  border-bottom: none;
}

/* Declaring `display` above otherwise beats the browser's default
   `[hidden]{display:none}` rule regardless of selector specificity — same fix already
   needed for .energy-phases/.phase-vi-row/.energy-periods/.watering-duration-row.
   Needed now that the Dashboard's Spotřebiče tile can hide individual appliance rows
   (see dashboard.js's renderAppliances()); the full Spotřebiče page never hides rows,
   so this was never needed there. */
.switch-row[hidden] {
  display: none;
}

.switch-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.switch-dot.on {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.switch-row-value {
  color: var(--muted);
  font-size: 0.82rem;
  /* Without this, a 3-digit value ("110 W") could wrap at the space before the unit
     once the row got tight (e.g. next to a long room name) — "W" dropping to its own
     line, reported as looking broken. */
  white-space: nowrap;
}

.switch-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Never let the value+button shrink to make room for a long room name — the label
     side truncates instead (see .switch-row-label below). */
  flex-shrink: 0;
}

/* ---------- appliance power button (Spotřebiče) ---------- */
/* Colors deliberately come from the fixed --power-on/--power-off tokens, not
   --accent/--border — those vary per selected palette (and once even landed on
   plain black), so a button meant to say "this is on" or "this is off" needs a
   color that always means that, not whatever the current aesthetic happens to be. */
.appliance-power-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--power-off);
  background: var(--card-bg);
  color: var(--power-off);
  font-size: 1.4rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.appliance-power-btn.on {
  background: var(--power-on);
  border-color: var(--power-on);
  color: #f2f7f4;
}

/* Plain-text on/off status (e.g. the Bojler tile's status line) — same fixed
   --power-on/--power-off tokens as .appliance-power-btn.on above, just applied to
   text color instead of a button's background, for a widget that doesn't have its own
   toggle control. */
.status-badge.on {
  color: var(--power-on);
}

.status-badge.off {
  color: var(--power-off);
}

.appliance-power-btn.sm {
  width: 30px;
  height: 30px;
  font-size: 0.85rem;
  border-width: 1px;
}

.appliance-power-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.appliance-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.appliance-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.appliance-stats {
  display: flex;
  gap: 28px;
  margin-bottom: 12px;
}

.appliance-timer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.72rem;
}

.appliance-timer-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 0.72rem;
}

.appliance-timer-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.appliance-timer-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* Persisted "currently selected" state (e.g. Náklady's Celkem/Fáze chart toggle) —
 * same colors as :hover above, just not dependent on the pointer still being there. */
.appliance-timer-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Náklady tile: editable prices + chart view toggle ---------- */
/* Both rates always visible, per explicit request — only the currently active one
 * (VT or NT, see renderTariffStatus in dashboard.js) is highlighted, the other stays
 * muted. Reuses the app's existing VT=danger/NT=accent color association (already
 * established by .badge-vt/.badge-nt elsewhere) rather than inventing a new pairing. */
.costs-tariff-rate {
  color: var(--muted);
}

.costs-tariff-vt.active {
  color: var(--accent-danger);
  font-weight: 700;
}

.costs-tariff-nt.active {
  color: var(--accent);
  font-weight: 700;
}

.costs-edit-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: var(--fs-tile-label);
  cursor: pointer;
  padding: 0;
  margin-top: 4px;
}

.costs-price-edit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.costs-price-edit-row[hidden] {
  display: none;
}

.costs-price-edit-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-tile-label);
  color: var(--muted);
}

.costs-price-edit-row input {
  width: 70px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: var(--fs-tile-label);
}

.costs-chart-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

/* Secondary row below the big "today" cost — deliberately its own smaller size
 * (--fs-tile-label, not --fs-tile-value) rather than reusing .period-col verbatim,
 * per explicit request to de-emphasize week/month/year relative to today. */
.costs-periods-row {
  display: flex;
  gap: 16px;
  margin: 10px 0;
}

.costs-period-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: var(--fs-tile-label);
  font-weight: 600;
}

.costs-period-col[hidden] {
  display: none;
}

.appliance-schedules {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.appliance-schedule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  padding: 5px 0;
  color: var(--muted);
}

.appliance-schedule-row button {
  background: none;
  border: none;
  color: var(--accent-danger);
  cursor: pointer;
  font-size: 0.85rem;
}

.appliance-schedule-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.75rem;
}

.appliance-schedule-form .day-checks {
  display: flex;
  gap: 3px;
}

.appliance-schedule-form .day-checks label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.68rem;
  cursor: pointer;
  color: var(--muted);
}

.appliance-schedule-form .day-checks input {
  display: none;
}

.appliance-schedule-form .day-checks input:checked + span {
  color: var(--accent);
  font-weight: 700;
}

.appliance-schedule-form input[type="time"],
.appliance-schedule-form input[type="number"] {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 0.75rem;
  width: 70px;
}

.appliance-schedule-form button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 0.75rem;
}

/* ---------- placeholder pages ---------- */
.placeholder-section {
  text-align: center;
  padding: 48px 24px;
}

.placeholder-message {
  color: var(--muted);
  margin-top: 16px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* ---------- mobile layout (phones/small tablets) ---------- */
/* Two things were making every page unreadable on a phone: the sidebar was a fixed
   220px-wide permanent column (a huge chunk of a ~375px viewport), and the Dashboard's
   grid forced 5 side-by-side columns (see #dashboard-grid, repeat(5, minmax(240px,
   1fr))) regardless of viewport width, so cards either overlapped or forced horizontal
   scrolling. Below this breakpoint: the sidebar becomes a horizontally-scrollable top
   bar instead of a side column, and every multi-column grid collapses to one column. */
@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }

  .sidebar-brand {
    padding: 0 16px 0 0;
    flex-shrink: 0;
  }

  .nav-list-toolbar {
    flex-shrink: 0;
    padding: 0 8px;
  }

  .nav-list {
    display: flex;
  }

  .nav-list a {
    padding: 8px 12px;
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
  }

  .nav-list a.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .nav-list-secondary {
    margin-left: auto;
    flex-shrink: 0;
  }

  .sidebar-profile-link {
    padding: 8px 12px;
    white-space: nowrap;
  }

  .sidebar-profile-name {
    max-width: 80px;
  }

  .content {
    padding: 14px;
  }

  .page-status-row {
    top: 14px;
    right: 14px;
  }

  #dashboard-grid {
    grid-template-columns: 1fr;
  }

  .widget-grid {
    grid-template-columns: 1fr;
  }

  .appliance-stats {
    flex-wrap: wrap;
    gap: 16px;
  }

  /* The banner exists to fill space that's only actually empty on a wide screen —
     on a narrow phone .wx-hero-main's icon+text already fill the width, so the
     banner is just hidden rather than trying to fit a 3rd flex item in. */
  .wx-hero-banner {
    display: none;
  }
}

/* ---------- auth pages (setup / login / 2FA) — no sidebar, see auth_base.html ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
  max-width: 320px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.auth-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.95rem;
}

.auth-form button {
  background: var(--accent);
  border: none;
  color: var(--accent-ink);
  border-radius: 6px;
  padding: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

.auth-error {
  color: var(--accent-danger);
  font-size: 0.85rem;
  margin: 12px 0 0;
}

.auth-qr {
  display: block;
  margin: 16px auto;
  width: 200px;
  height: 200px;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.auth-secret {
  text-align: center;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  word-break: break-all;
}
