/* ============================================================
   Design tokeny — totožné s hlavním webem
   ============================================================ */
:root {
    --color-bg: #fff8f1;
    --color-surface: rgba(255, 255, 255, 0.82);
    --color-surface-strong: #ffffff;
    --color-text: #211818;
    --color-muted: #6f625b;
    --color-accent: #f37b32;
    --color-accent-strong: #e15a20;
    --color-accent-soft: #ffe0c3;
    --color-border: rgba(169, 124, 93, 0.18);
    --color-shadow: rgba(85, 39, 23, 0.12);
    --color-hero-start: #fff3e4;
    --color-hero-end: #ffe1c8;
    --color-panel: rgba(255, 248, 241, 0.84);
    --color-header: rgba(241, 228, 216, 0.92);

    --color-success: #3dbe7c;
    --color-success-soft: rgba(61, 190, 124, 0.12);
    --color-danger: #e05050;
    --color-danger-soft: rgba(224, 80, 80, 0.10);

    --shadow-soft: 0 18px 60px var(--color-shadow);
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --container: 1180px;
}

:root[data-theme='dark'] {
    --color-bg: #181413;
    --color-surface: rgba(31, 26, 24, 0.86);
    --color-surface-strong: #231c19;
    --color-text: #f7efe8;
    --color-muted: #c9b5aa;
    --color-accent: #ff9857;
    --color-accent-strong: #ffb16f;
    --color-accent-soft: rgba(255, 152, 87, 0.16);
    --color-border: rgba(255, 196, 148, 0.16);
    --color-shadow: rgba(0, 0, 0, 0.28);
    --color-hero-start: #2f221d;
    --color-hero-end: #1d1816;
    --color-panel: rgba(35, 28, 25, 0.8);
    --color-header: rgba(29, 24, 22, 0.9);

    --color-success: #4ed98a;
    --color-success-soft: rgba(78, 217, 138, 0.12);
    --color-danger: #f07070;
    --color-danger-soft: rgba(240, 112, 112, 0.10);
}

/* ============================================================
   Reset
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0 !important;
    padding: 0 !important;
}

html {
    margin-top: 0 !important;
    color-scheme: light;
}

html[data-theme='dark'] {
    color-scheme: dark;
}

body.admin-bar,
html[style*="margin-top"] {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#wpadminbar {
    display: none !important;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(243, 123, 50, 0.12), transparent 22%),
        radial-gradient(circle at top right, rgba(255, 214, 177, 0.35), transparent 26%),
        linear-gradient(180deg, var(--color-bg) 0%, color-mix(in srgb, var(--color-bg) 85%, #ffffff 15%) 100%);
    color: var(--color-text);
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body > main {
    flex: 1;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

button {
    font: inherit;
}

/* ============================================================
   Layout
   ============================================================ */
.container {
    width: min(100% - 2rem, var(--container));
    margin: 0 auto;
}

.site-main {
    padding-top: 84px;
}

.section {
    padding: 3rem 0 4rem;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    backdrop-filter: blur(18px);
    background: var(--color-header);
    border-bottom: 1px solid color-mix(in srgb, var(--color-border) 72%, rgba(96, 59, 35, 0.22) 28%);
}

.site-header__inner,
.site-header__actions,
.site-header__controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-header__inner {
    justify-content: space-between;
    min-height: 84px;
}

.site-header__actions {
    gap: 1.25rem;
}

.site-header__controls {
    gap: 0.75rem;
}

.site-brand,
.site-brand__link,
.custom-logo-link {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
}

.site-brand__image,
.custom-logo {
    display: block;
    width: auto;
    max-height: 44px;
}

.site-brand__image--dark  { display: none; }

[data-theme="dark"] .site-brand__image--light { display: none; }
[data-theme="dark"] .site-brand__image--dark  { display: block; }

.site-brand__name {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-family: Georgia, serif;
}

.site-nav {
    display: flex;
    align-items: center;
    flex: 1;
    padding: 0 1.5rem;
}

.site-nav__menu {
    display: flex;
    gap: 1.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-nav__menu a {
    color: var(--color-muted);
    font-size: 0.96rem;
}

.site-nav__menu a:hover {
    color: var(--color-text);
}

/* ============================================================
   Logout button
   ============================================================ */
.logout-btn {
    text-decoration: none;
}

/* ============================================================
   Tlačítka
   ============================================================ */
[hidden] { display: none !important; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 48px;
    padding: 0.8rem 1.3rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.button:hover,
.button:focus-visible {
    transform: translateY(-1px);
}

.button--primary {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-strong) 100%);
    color: #fffaf6;
}

.button--secondary {
    border-color: var(--color-border);
    background: color-mix(in srgb, var(--color-surface-strong) 72%, transparent 28%);
    color: var(--color-text);
}

.button--sm {
    min-height: 36px;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
}

/* ============================================================
   Menu & theme toggle
   ============================================================ */
.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.7rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    font-weight: 600;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-accent);
    cursor: pointer;
    font-size: 1.05rem;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    transform: translateY(-1px);
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
}

/* Zobrazuj správnou ikonku podle aktivního tématu */
.theme-toggle__icon--dark  { display: none; }
.theme-toggle__icon--light { display: inline; }

[data-theme='dark'] .theme-toggle__icon--dark  { display: inline; }
[data-theme='dark'] .theme-toggle__icon--light { display: none; }

/* ============================================================
   Typografie sdílená
   ============================================================ */
.eyebrow,
.section-label {
    margin: 0 0 0.75rem;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.75rem;
    color: var(--color-accent-strong);
}

.content-card {
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
}

.content-card h1,
.content-card h2,
.content-card h3 {
    margin-top: 0;
}

.entry-content > * + * { margin-top: 1rem; }
.entry-content ul { padding-left: 1.25rem; }
.entry-content a {
    color: var(--color-accent-strong);
    text-decoration: underline;
    text-underline-offset: 0.16em;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
    padding: 2rem 0 3rem;
    color: var(--color-muted);
    font-size: 0.88rem;
    text-align: center;
}

/* ============================================================
   LOGIN stránka
   ============================================================ */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 84px);
    padding: 2rem 1rem;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    background: var(--color-surface-strong);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
}

.login-card__header {
    margin-bottom: 2rem;
}

.login-card__title {
    font-family: Georgia, serif;
    font-size: 1.9rem;
    margin: 0 0 0.5rem;
    line-height: 1.1;
}

.login-card__sub {
    color: var(--color-muted);
    margin: 0;
    font-size: 0.95rem;
}

.login-card__error {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--color-danger-soft);
    color: var(--color-danger);
    font-size: 0.9rem;
}

.login-card__notice {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--color-success-soft);
    color: var(--color-success);
    font-size: 0.9rem;
}

.login-card__register {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.login-card__register p {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.9rem;
}

/* Checkbox + forgot password row */
.form-group--check-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--color-muted);
    cursor: pointer;
    user-select: none;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent);
    cursor: pointer;
    flex-shrink: 0;
}

.form-forgot {
    font-size: 0.9rem;
    color: var(--color-muted);
    text-decoration: none;
    white-space: nowrap;
}

.form-forgot:hover {
    color: var(--color-accent);
}

/* ============================================================
   Registrační formulář
   ============================================================ */
#mistat-register-form p {
    margin: 0 0 1.25rem;
}

#mistat-register-form label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#mistat-register-form input[type="email"],
#mistat-register-form input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

#mistat-register-form input[type="email"]:focus,
#mistat-register-form input[type="password"]:focus {
    outline: none;
    border-color: var(--color-accent);
}

#mistat-register-form input[type="submit"] {
    width: 100%;
    min-height: 48px;
    padding: 0.8rem 1.3rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-strong) 100%);
    color: #fffaf6;
    font: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#mistat-register-form input[type="submit"]:hover {
    transform: translateY(-1px);
}

/* ============================================================
   Formuláře (párování)
   ============================================================ */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.form-input--mono {
    font-family: "Courier New", Courier, monospace;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.form-hint {
    margin: 0.4rem 0 0;
    font-size: 0.83rem;
    color: var(--color-muted);
}

.form-hint--error {
    color: var(--color-danger);
}

.form-input--error {
    border-color: var(--color-danger);
}

/* ============================================================
   Dashboard toolbar
   ============================================================ */
.dashboard-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-toolbar__title {
    font-family: Georgia, serif;
    font-size: 2rem;
    margin: 0;
    line-height: 1.1;
}

/* ============================================================
   Thermostat grid
   ============================================================ */
.thermostat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
}

/* ============================================================
   Thermostat card
   ============================================================ */
.thermostat-card {
    /* relative — z-index a stacking context pro vlastní decoration
       (badges, future overlay…). Bez něj by se utkávalo s body. */
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.thermostat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 70px var(--color-shadow);
}

/* Reorder UX: drag celou kartu, žádný viditelný handle. Na hover-capable
   zařízeních (desktop) signalizujeme tahatelnost grab kurzorem; na touch
   se drag aktivuje long-pressem (řízeno z JS), takže žádný visual hint
   nepotřebujeme — uživatel zná pattern z iOS rearrangement.
   Pozor: kurzor jen pokud má grid `data-reorder-enabled` (= 2+ zařízení),
   jinak by byl matoucí na single-card layoutu. */
@media (hover: hover) {
    [data-reorder-enabled] .thermostat-card { cursor: grab; }
    [data-reorder-enabled] .thermostat-card.is-dragging { cursor: grabbing; }
    /* Tlačítka / odkazy / inputy uvnitř karty si nárokují vlastní kurzor
       (pointer / text), ať user pozná, co je klikatelné a co tahatelné. */
    [data-reorder-enabled] .thermostat-card button,
    [data-reorder-enabled] .thermostat-card a,
    [data-reorder-enabled] .thermostat-card input,
    [data-reorder-enabled] .thermostat-card select { cursor: pointer; }
    [data-reorder-enabled] .thermostat-card input[type="text"],
    [data-reorder-enabled] .thermostat-card .rename-input { cursor: text; }
}

/* Při tažení karty (JS přidá .is-dragging) potlač hover transform —
   karta už má vlastní position:fixed + transform pro „následuj kurzor",
   hover lift by se s ním rval. Současně vypneme transition (drag musí
   reagovat real-time, ne s 200ms easingem) a nahodíme silnější shadow,
   aby karta vizuálně „vystoupila" nad ostatní. */
.thermostat-card.is-dragging {
    transition: none;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
    /* user-select během dragu — pre-empt text selection při pohybu myší. */
    user-select: none;
    -webkit-user-select: none;
}
.thermostat-card.is-dragging:hover {
    transform: none;   /* hover :hover by jinak přidalo translateY(-2px) */
}
/* Drobný „připraven k drag" stav pro touch po long-pressu — feedback
   uživateli, že přidržel dost dlouho a teď může táhnout. */
.thermostat-card.is-drag-ready {
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    transform: scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}

/* Body lock během dragu — bez tohohle by myš během dragu vybírala text
   napříč stránkou a Chrome by zobrazoval text-selection cursor. */
body.is-reordering {
    user-select: none;
    -webkit-user-select: none;
    cursor: grabbing;
}

/* Placeholder — průhledná karta, která drží gridové místo zatímco
   tažený originál letí v position:fixed nad ním. Stejné rozměry,
   jen dashed obrys aby uživatel viděl „kam to padne". */
.device-card-placeholder {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    background: rgba(0, 0, 0, 0.02);
    /* Height nastavujeme inline z JS (matchuje původní rect height).
       Width se odvodí z grid columnu, takže ho explicitně neřešíme. */
    box-sizing: border-box;
    pointer-events: none;
}

.thermostat-card__footer {
    margin-top: auto;
}

.thermostat-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.thermostat-card__identity {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.thermostat-card__name-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.thermostat-card__name {
    font-family: Georgia, serif;
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.2;
    transition: opacity 0.3s ease;
}

.thermostat-card__name.is-saving {
    opacity: 0.35;
}

.rename-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-muted);
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.rename-btn:hover {
    color: var(--color-text);
    background: var(--color-border);
}

.rename-input {
    font-family: Georgia, serif;
    font-size: 1.1rem;
    line-height: 1.2;
    padding: 0.1rem 0.35rem;
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-text);
    width: 10rem;
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb, 0,0,0), 0.12);
}

.rename-input--lg {
    font-size: 1.5rem;
    width: 14rem;
}

.rename-confirm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    background: var(--color-primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #fff;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.rename-confirm-btn:hover {
    opacity: 0.85;
}

.rename-confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.thermostat-card__id {
    font-size: 0.78rem;
    color: var(--color-muted);
    font-family: "Courier New", Courier, monospace;
    letter-spacing: 0.04em;
}

.thermostat-card__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.thermostat-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.thermostat-card__seen {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.thermostat-card__status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.thermostat-card__status--online {
    color: var(--color-success, #22c55e);
}

.thermostat-card__status--offline {
    color: var(--color-danger, #ef4444);
}

.thermostat-card__offline-note {
    font-size: 0.8rem;
    color: var(--color-muted);
    font-style: italic;
}

/* ============================================================
   Teplota
   ============================================================ */
.temp-display {
    display: flex;
    align-items: baseline;
    gap: 0.1rem;
}

.temp-display__current {
    font-family: Georgia, serif;
    font-size: 3rem;
    line-height: 1;
    font-weight: 400;
    color: var(--color-text);
}

.temp-display__unit {
    font-family: Georgia, serif;
    font-size: 1.4rem;
    color: var(--color-muted);
    align-self: flex-start;
    margin-top: 0.3rem;
}

.temp-display__target {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0;
}

/* ============================================================
   Stavové indikátory
   ============================================================ */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.status-dot--online {
    background: var(--color-success);
    box-shadow: 0 0 0 3px var(--color-success-soft);
    animation: pulse-online 2.5s ease infinite;
}

@keyframes pulse-online {
    0%, 100% { box-shadow: 0 0 0 3px var(--color-success-soft); }
    50%       { box-shadow: 0 0 0 6px transparent; }
}

.status-dot--offline {
    background: var(--color-muted);
    opacity: 0.5;
}

.status-dot--heating {
    background: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--color-accent-soft); }
    50%       { box-shadow: 0 0 0 6px transparent; }
}

.heating-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    font-size: 0.8rem;
    font-weight: 600;
}

.heating-badge::before {
    content: '●';
    font-size: 0.55rem;
    animation: pulse-opacity 1.5s ease infinite;
}

@keyframes pulse-opacity {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ============================================================
   Mode badge
   ============================================================ */
.mode-badge {
    display: inline-flex;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--color-surface-strong);
    border: 1px solid var(--color-border);
    color: var(--color-muted);
}

.mode-badge--auto {
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    border-color: transparent;
}

/* ============================================================
   Device grid + per-type cards (multi-device-type podpora)
   ============================================================ */
/* `.device-grid` je alias na thermostat-grid — používá se ve sjednoceném
   markupu, kde karta může být buď thermostat (TOPITO) nebo sensor (MERITO). */
.device-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
}

@media (max-width: 900px) {
    .device-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 600px) {
    .device-grid {
        grid-template-columns: 1fr;
    }
}

/* Type badge — drobný štítek vedle Device ID, signalizuje typ. */
.device-card__type-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--color-surface-strong);
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    vertical-align: middle;
}
.device-card__type-badge--topito {
    color: var(--color-accent-strong);
    background: var(--color-accent-soft);
    border-color: transparent;
}
.device-card__type-badge--merito {
    color: #2563eb;             /* informativní modrá pro čidlo */
    background: rgba(37, 99, 235, 0.1);
    border-color: transparent;
}

/* ============================================================
   Sensor card (MERITO) — meta řádek pod hlavní teplotou
   ============================================================
   Tělo karty MERITO sdílí .thermostat-card__body + .temp-display
   markup s TOPITO (Georgia serif teplota) — to jsou společné třídy,
   ať uživatel vidí stejný „rytmus" karet napříč typy. Sensor-specific
   je jen tenhle meta řádek s vlhkostí a baterií, který u TOPITO
   nahrazuje mode-badge. Pozici drží na druhém řádku flex-column body,
   stejně jako mode-badge u termostatu. */
.sensor-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.15rem;     /* malý odstup od velké teploty, aby nelepilo */
}

.sensor-card__chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: var(--color-surface-strong);
    border: 1px solid var(--color-border);
    font-size: 0.85rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.sensor-card__chip > span:last-child,
.sensor-card__chip [data-humidity],
.sensor-card__chip [data-battery] {
    /* První span je emoji ikona (stays muted), value span ujmeme barvou
       textu, ať číslo má kontrast a emoji zůstane „dekorací". */
    color: var(--color-text);
    font-weight: 600;
}
.sensor-card__chip--humidity [data-humidity] {
    color: #2563eb;          /* humidity blue — drží sémantiku napříč detailem i kartou */
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    border: 2px dashed var(--color-border);
    gap: 1rem;
}

.empty-state__icon {
    font-size: 3rem;
    color: var(--color-accent-soft);
    line-height: 1;
}

.empty-state__title {
    font-family: Georgia, serif;
    font-size: 1.4rem;
    margin: 0;
}

.empty-state__text {
    color: var(--color-muted);
    max-width: 34ch;
    margin: 0;
}

/* ============================================================
   Párování
   ============================================================ */
.pairing-wrap {
    max-width: 640px;
}

.pairing-steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 2.5rem;
}

.pairing-step {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    opacity: 0.4;
    transition: opacity 0.2s ease;
}

.pairing-step--active {
    opacity: 1;
}

.pairing-step--done {
    opacity: 0.65;
}

.pairing-step__num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.pairing-step--active .pairing-step__num {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.pairing-step--done .pairing-step__num {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
}

.pairing-step__label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-muted);
    white-space: nowrap;
}

.pairing-step--active .pairing-step__label {
    color: var(--color-text);
}

.pairing-step__divider {
    flex: 1;
    height: 2px;
    background: var(--color-border);
    margin: 0 0.75rem;
    min-width: 24px;
}

.pairing-card {
    padding: 2rem;
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
}

.pairing-card h2 {
    font-family: Georgia, serif;
    font-size: 1.5rem;
    margin: 0 0 0.75rem;
    line-height: 1.2;
}

.pairing-help {
    color: var(--color-muted);
    font-size: 0.95rem;
    margin: 0 0 1.75rem;
    line-height: 1.6;
}

.pairing-error {
    color: #e05252;
    font-size: 0.9rem;
    margin: 0.5rem 0 1rem;
    padding: 0.6rem 0.9rem;
    background: rgba(224, 82, 82, 0.08);
    border-left: 3px solid #e05252;
    border-radius: 4px;
}

.pairing-waiting {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.pairing-waiting__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent);
    flex-shrink: 0;
    animation: pulse-opacity 1.2s ease infinite;
}

/* ============================================================
   Tlačítka — danger varianta
   ============================================================ */
.button--danger {
    background: var(--color-danger-soft);
    border-color: transparent;
    color: var(--color-danger);
}

.button--danger:hover,
.button--danger:focus-visible {
    background: var(--color-danger);
    color: #fff;
}

/* ============================================================
   Nastavení — settings-card
   ============================================================ */
.settings-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}

.settings-card--danger {
    border-color: var(--color-danger-soft);
}

.settings-card__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
    color: var(--color-text);
}

.settings-card__title--danger {
    color: var(--color-danger);
}

.settings-card__desc {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin: 0 0 1.4rem;
    line-height: 1.55;
}

/* ============================================================
   Alert — success / error
   ============================================================ */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.alert--success {
    background: rgba(59, 185, 80, 0.1);
    border: 1px solid rgba(59, 185, 80, 0.3);
    color: #2a9140;
}

.alert--error {
    background: rgba(224, 82, 82, 0.08);
    border: 1px solid rgba(224, 82, 82, 0.3);
    color: var(--color-danger);
}

/* ============================================================
   Thermostat detail — layout stránky
   ============================================================ */
.thermostat-detail-page {
    padding-top: 1rem;
}

.thermostat-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.thermostat-detail-back {
    color: var(--color-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.thermostat-detail-back:hover { color: var(--color-accent); }

.thermostat-detail-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.thermostat-detail-name {
    font-family: Georgia, serif;
    font-size: 1.8rem;
    margin: 0;
    line-height: 1.1;
}

.thermostat-detail-id {
    font-size: 0.8rem;
    color: var(--color-muted);
    font-family: "Courier New", Courier, monospace;
    letter-spacing: 0.04em;
}

.thermostat-controls-disabled {
    opacity: 0.4;
    pointer-events: none;
    user-select: none;
}

.thermostat-detail-offline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem 1.5rem;
    border-radius: var(--radius-md);
    background: var(--color-danger-soft);
    color: var(--color-danger);
    font-size: 0.92rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.thermostat-offline-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.thermostat-detail-offline strong {
    font-size: 1.05rem;
}

.thermostat-detail-offline p {
    margin: 0;
    opacity: 0.85;
}

/* ── Skeleton — aplikuje se na reálné elementy ───────────── */
@keyframes skeleton-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#thermostatControls.is-skeleton {
    pointer-events: none;
}

/* Shimmer helper — přidáme na konkrétní elementy */
#thermostatControls.is-skeleton .thermostat-dial-wrap,
#thermostatControls.is-skeleton .thermostat-heating-state,
#thermostatControls.is-skeleton .thermostat-mode-btn,
#thermostatControls.is-skeleton .thermostat-last-seen,
#thermostatControls.is-skeleton .settings-group-title,
#thermostatControls.is-skeleton .settings-row {
    position: relative;
    overflow: hidden;
}

#thermostatControls.is-skeleton .thermostat-dial-wrap::after,
#thermostatControls.is-skeleton .thermostat-heating-state::after,
#thermostatControls.is-skeleton .thermostat-mode-btn::after,
#thermostatControls.is-skeleton .thermostat-last-seen::after,
#thermostatControls.is-skeleton .settings-group-title::after,
#thermostatControls.is-skeleton .settings-row::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, var(--color-border) 50%, transparent 100%);
    animation: skeleton-shimmer 1.4s ease infinite;
    z-index: 1;
}

/* Dial → shimmer kruh */
#thermostatControls.is-skeleton .thermostat-dial-wrap {
    border-radius: 50%;
    background: var(--color-surface-strong);
}
#thermostatControls.is-skeleton .thermostat-dial {
    opacity: 0;
}

/* Heating state → shimmer blok */
#thermostatControls.is-skeleton .thermostat-heating-state {
    color: transparent !important;
    background: var(--color-surface-strong) !important;
    border-color: transparent !important;
}

/* Last seen → tenká čára */
#thermostatControls.is-skeleton .thermostat-last-seen {
    background: var(--color-surface-strong);
    border-radius: 4px;
    height: 12px;
    width: 80px;
    color: transparent;
}

/* Mode buttons → shimmer bloky */
#thermostatControls.is-skeleton .thermostat-mode-btn {
    color: transparent !important;
    background: var(--color-surface-strong) !important;
    border-color: transparent !important;
}

/* Settings titulky → shimmer */
#thermostatControls.is-skeleton .settings-group-title {
    background: var(--color-surface-strong);
    border-radius: 4px;
    color: transparent;
    min-width: 100px;
}

/* Settings řádky → shimmer bloky */
#thermostatControls.is-skeleton .settings-row {
    background: var(--color-surface-strong);
    border-radius: var(--radius-md);
    border-top-color: transparent !important;
    height: 44px;
}
#thermostatControls.is-skeleton .settings-row > * {
    opacity: 0;
}

/* Tlačítko uložit + jeho separator → schovat */
#thermostatControls.is-skeleton .settings-save-row {
    visibility: hidden;
    border-top-color: transparent !important;
}

/* ::before kryt — zakryje emoji (ignorují color: transparent) */
#thermostatControls.is-skeleton .thermostat-mode-btn::before,
#thermostatControls.is-skeleton .thermostat-heating-state::before,
#thermostatControls.is-skeleton .settings-group-title::before {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    z-index: 0;
}

.thermostat-page-layout {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2rem;
    align-items: stretch;
}
/* Druhá a další řádka (Dnes, Historie, Provozní) jsou `grid-column: 1/-1`
   a nesmí dědit stretch výšku — jinak by se první-row stretch zbytečně
   přenesl a karty by měly nesmyslně prázdné místo. Pinneme je na start. */
.thermostat-page-layout > .thermostat-stats-widget,
.thermostat-page-layout > .thermostat-today-box {
    align-self: start;
}

/* Save row sedí pod sloupcem s nastavením (col 2), ne pod dialem.
   Tím pádem se do stretch výšky první řádky (dial ↔ settings) nezapočítá
   a dial karta je přesně zarovnaná s dolní hranou „hystereze". */
.settings-save-row--grid {
    grid-column: 2;
    align-self: start;
    margin-top: 0;
}

/* „Dnes" box — full-width nad historií, 3 statistiky vedle sebe.
   Dědí .thermostat-stats-widget kartu (padding, border, title),
   jen layout obsahu je horizontální. */
.thermostat-today-box__row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem 2rem;
    align-items: flex-start;
    justify-content: space-around;
}
.thermostat-today-box__row .today-stat {
    flex: 1 1 0;
    min-width: 140px;
    text-align: center;
    align-items: center;
}

@media (max-width: 520px) {
    .thermostat-today-box__row {
        gap: 1rem 1.5rem;
    }
}

/* Grid se třemi řádky (1fr / obsah / 1fr) vycentruje celý blok vertikálně
   v kartě. V obsahové řádce je dial-col (vyšší) určující výšku řádky,
   mode-panel má `align-self: end` → jeho spodek lícuje se spodkem dial-col,
   takže „Vypnout" sedí přesně s „Topení vypnuto". */
.thermostat-detail-body {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: 1fr auto 1fr;
    column-gap: 2rem;
    justify-content: center;
    padding: 2rem;
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
    transition: opacity 0.3s ease;
    height: 100%;
}
.thermostat-detail-body .thermostat-dial-col {
    grid-row: 2;
    grid-column: 1;
    justify-content: flex-start;
    padding-top: 2.5rem;      /* dial posunutý níž, aby vizuálně zapadl
                                 mezi Denní a „před Xs" */
}
.thermostat-detail-body .thermostat-mode-panel {
    grid-row: 2;
    grid-column: 2;
    align-self: end;          /* spodek mode-panel = spodek dial-col */
}

.thermostat-detail-body--offline {
    opacity: 0.45;
    pointer-events: none;
}

/* ============================================================
   Dial
   ============================================================ */
.thermostat-dial-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.thermostat-dial-wrap {
    flex-shrink: 0;
}

.thermostat-dial {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.thermostat-dial:active { cursor: grabbing; }

.dial-svg {
    width: 260px;
    height: 260px;
    display: block;
    overflow: visible;
}

/* Šedá stopa oblouku 270° — rotace aby začínal vlevo-dole */
.dial-track {
    fill: none;
    stroke: var(--color-border);
    stroke-width: 14;
    stroke-linecap: round;
    stroke-dasharray: calc(2 * 3.14159265 * 110 * 270 / 360) calc(2 * 3.14159265 * 110);
    transform-origin: 130px 130px;
    transform: rotate(135deg);
}

.dial-progress {
    fill: none;
    stroke: var(--color-success);
    stroke-width: 14;
    stroke-linecap: round;
    transform-origin: 130px 130px;
    transform: rotate(135deg);
    transition: stroke 0.4s ease, stroke-dashoffset 0.12s ease;
}

.dial-handle {
    fill: var(--color-success);
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.2));
    transition: fill 0.4s ease;
}

.dial-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
    gap: 0.1rem;
}

.dial-target-label {
    font-size: 0.72rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.dial-target-value {
    display: flex;
    align-items: baseline;
    gap: 0.1rem;
    line-height: 1;
}

.dial-target-value span:first-child {
    font-family: Georgia, serif;
    font-size: 3.2rem;
    color: var(--color-text);
}

.dial-unit {
    font-family: Georgia, serif;
    font-size: 1.3rem;
    color: var(--color-muted);
    margin-top: 0.4rem;
}

.dial-current-row {
    font-size: 0.84rem;
    color: var(--color-muted);
}

.dial-saving {
    font-size: 0.75rem;
    color: var(--color-accent);
    margin-top: 0.15rem;
}

/* ============================================================
   Thermostat detail — side panel
   ============================================================ */
.thermostat-mode-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.thermostat-heating-state {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    background: var(--color-surface-strong);
    border: 1px solid var(--color-border);
    transition: background 0.3s ease, color 0.3s ease;
    text-align: center;
    width: 100%;
}

.thermostat-heating-state--on {
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    border-color: transparent;
}

.thermostat-mode-btns {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.thermostat-mode-btn {
    justify-content: flex-start;
}

.thermostat-mode-btn.active {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    color: var(--color-accent-strong);
}

.thermostat-last-seen {
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* ============================================================
   Thermostat — nastavení
   ============================================================ */

.thermostat-settings {
    min-width: 0;
}

.thermostat-settings-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0 0 1.5rem;
    color: var(--color-text);
}

.settings-groups {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.settings-group {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.25rem 1.25rem 1rem;
}

.settings-group-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin: 0 0 1rem;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--color-border);
}

.settings-row:first-of-type {
    border-top: none;
}

.settings-label {
    font-size: 0.875rem;
    color: var(--color-text);
    flex: 1;
    min-width: 0;
}

.settings-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.settings-control--wide {
    flex: 1;
    max-width: 180px;
}

.settings-step-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    padding: 0;
}

.settings-step-btn:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.settings-value-display {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-accent);
    min-width: 54px;
    text-align: center;
}

.settings-toggle-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-muted);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.settings-toggle-btn.active {
    border-color: var(--color-accent);
    background: rgba(255, 120, 50, 0.12);
    color: var(--color-accent);
}

.settings-range {
    flex: 1;
    accent-color: var(--color-accent);
    cursor: pointer;
}

/* iOS-style toggle switch */
.ios-toggle {
    position: relative;
    display: inline-block;
    cursor: pointer;
    flex-shrink: 0;
}

.ios-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.ios-toggle__track {
    display: block;
    width: 46px;
    height: 26px;
    background: var(--color-border);
    border-radius: 13px;
    transition: background 0.25s ease;
    position: relative;
}

.ios-toggle input:checked ~ .ios-toggle__track {
    background: var(--color-accent);
}

.ios-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.ios-toggle input:checked ~ .ios-toggle__track .ios-toggle__thumb {
    transform: translateX(20px);
}

/* Hystereze — manuální řádky (skrytelné) */
.settings-hyst-manual {
    overflow: hidden;
    max-height: 200px;
    opacity: 1;
    transition: max-height 0.35s ease, opacity 0.25s ease;
}

.settings-hyst-manual--hidden {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

/* Řádek se save tlačítkem */
.settings-save-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.settings-save-btn {
    margin-left: auto;
    flex-shrink: 0;
    min-width: 160px;
    transition: opacity 0.15s;
}

.settings-save-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.settings-save-btn--dirty {
    box-shadow: 0 0 0 2px var(--color-accent);
}

.settings-saved-msg {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-success);
}

.settings-saved-msg--error {
    color: var(--color-error, #e05555);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
    .site-main {
        padding-top: 96px;
    }

    .site-header__inner {
        flex-wrap: wrap;
        align-items: center;
        min-height: auto;
        padding: 0.75rem 0;
        gap: 0;
    }

    .site-header__actions {
        margin-left: auto;
    }

    .site-header__controls {
        gap: 0.5rem;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .site-nav {
        display: none;
        order: 10;
        width: 100%;
        flex: none;
        padding: 0 0 0.75rem;
    }

    body.menu-open .site-nav {
        display: block;
    }

    .site-nav__menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
        width: 100%;
        margin: 0;
        padding: 0.75rem 0 0;
        border-top: 1px solid var(--color-border);
    }

    body.menu-open .menu-toggle__label::after {
        content: ' ×';
    }

    .thermostat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-groups {
        grid-template-columns: 1fr;
    }

    .thermostat-page-layout {
        grid-template-columns: 1fr;
    }

    .thermostat-settings {
        padding-top: 1.5rem;
        border-top: 1px solid var(--color-border);
    }

    /* Na mobilu je grid jednosloupcový, save-row zarovnáme pod settings. */
    .settings-save-row--grid {
        grid-column: 1;
    }
}

@media (max-width: 600px) {
    .thermostat-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 1.75rem;
    }

    .pairing-card {
        padding: 1.5rem;
    }

    .pairing-steps {
        gap: 0;
    }

    .pairing-step__label {
        display: none;
    }
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--color-surface-strong);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-soft);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s ease;
}

.modal-overlay.is-open .modal {
    transform: translateY(0) scale(1);
}

.modal__title {
    font-family: Georgia, serif;
    font-size: 1.4rem;
    margin: 0 0 0.75rem;
}

.modal__desc {
    color: var(--color-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0 0 1.75rem;
}

.modal__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ── Provozní statistiky widget (page-termostat.php) ─────────
   Skládá se ze stejných primitiv jako .settings-group nahoře —
   stejné border, background, radius a barevné tokeny, aby widget
   zapadl do light i dark režimu beze změny. */
.thermostat-stats-widget {

    padding: 1.25rem 1.25rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    /* Widget je přímý potomek .thermostat-page-layout (grid auto 1fr) —
       přes `1 / -1` přemostí oba sloupce a dostane plnou šířku. */
    grid-column: 1 / -1;
    min-width: 0;
}
.thermostat-stats-widget__title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin: 0 0 1rem;
}
.thermostat-stats-widget__kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.kpi-card {
    display: flex;
    flex-direction: column;
    padding: 0.85rem 1rem;
    background: color-mix(in srgb, var(--color-surface-strong) 60%, transparent 40%);
    border: 1px solid var(--color-border);
    border-radius: 10px;
}
.kpi-card__label {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.kpi-card__value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-accent-strong);
    line-height: 1.1;
}
.kpi-card__unit {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-muted);
    margin-left: 0.2rem;
}
.thermostat-stats-widget__chart {
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}
.thermostat-stats-widget__chart-title {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin: 0 0 0.5rem;
    font-weight: 500;
}
.thermostat-stats-widget__chart svg {
    display: block;
    width: 100%;
    height: auto;
}
.thermostat-stats-widget__chart .stats-bar {
    fill: var(--color-accent-strong);
    opacity: 0.65;
}
.thermostat-stats-widget__chart .stats-bar:hover { opacity: 1; }
.thermostat-stats-widget__chart .stats-axis {
    stroke: var(--color-border);
    stroke-width: 0.5;
}
.thermostat-stats-widget__chart .stats-axis-label {
    font-size: 8px;
    fill: var(--color-muted);
    font-family: inherit;
}
.thermostat-stats-widget__hint {
    margin: 6px 0 0;
    font-size: 0.78rem;
    color: var(--color-muted);
    font-style: italic;
}
.thermostat-stats-widget__empty {
    color: var(--color-muted);
    font-size: 0.875rem;
    margin: 0;
    font-style: italic;
}
@media (max-width: 520px) {
    .thermostat-stats-widget__kpis {
        grid-template-columns: 1fr;
    }
}

/* ── Historie widget (12h Chart.js graf) ───────────────────── */
/* Heating barvy — oranžová když topí, modrá když ne. Matchuje
   lokální RPi verzi; přepíšitelné per-theme přes :root nebo body. */
:root {
    --color-heating-on:  #ff7a00;
    --color-heating-off: #4aa3ff;
}
/* Chart.js kontejner — vyžaduje fixní height, jinak roste nad kontrolu
   kvůli responsive: true. 350px je stejný rozměr jako v RPi řešení. */
.mistat-chart-container {
    position: relative;
    width: 100%;
    height: 350px;
    touch-action: none;
    user-select: none;
}
.mistat-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── „Dnes" box pod dialem ─────────────────────────────────── */
.today-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.today-stat__label {
    font-size: 0.72rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.today-stat__value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-accent-strong);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
