:root {
    color-scheme: light;
    --bg: #f4f8f5;
    --card: #ffffff;
    --text: #17201b;
    --muted: #6b746e;
    --border: #e1e8e3;
    --accent: #20996b;
    --accent-soft: #dff4ea;
    --danger: #b64242;
    --shadow: 0 12px 32px rgba(25, 58, 41, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.page {
    width: min(680px, calc(100% - 28px));
    margin: 0 auto;
    padding: max(28px, env(safe-area-inset-top)) 0 max(34px, env(safe-area-inset-bottom));
}

.hero {
    display: flex;
    gap: 16px;
    align-items: center;
    margin: 8px 4px 24px;
}

.hero-icon {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 30px;
    background: var(--accent-soft);
}

h1 { margin: 0; font-size: clamp(26px, 5vw, 34px); }
h2 { margin: 0 0 5px; font-size: 19px; }
.hero p, .muted, .hint { color: var(--muted); }
.hero p, .muted { margin: 0; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.row, .field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.primary-row { min-height: 64px; }

.settings { padding: 8px 20px; }
.field-row { min-height: 88px; }
.field-row label { display: flex; flex-direction: column; gap: 5px; }
.label { font-size: 17px; font-weight: 650; }
.hint { font-size: 13px; }

.divider { height: 1px; background: var(--border); }

input[type="time"], input[type="number"] {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fafcfb;
    color: var(--text);
    padding: 11px 12px;
    font: inherit;
    font-size: 18px;
}

input[type="time"] { width: 132px; }
.number-wrap { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.number-wrap input { width: 88px; text-align: right; }

.next-card .row { align-items: flex-start; }
.next-value {
    margin: 4px 0 0;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
}

.switch { position: relative; display: inline-block; width: 62px; height: 36px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0;
    cursor: pointer;
    background: #c9d0cc;
    border-radius: 999px;
    transition: .2s;
}
.slider::before {
    content: "";
    position: absolute;
    width: 28px; height: 28px;
    left: 4px; top: 4px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    transition: .2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(26px); }
.switch input:focus-visible + .slider { outline: 3px solid rgba(32,153,107,.25); outline-offset: 3px; }

.badge {
    border-radius: 999px;
    padding: 9px 13px;
    font-weight: 700;
    white-space: nowrap;
}
.badge.open { background: var(--accent-soft); color: #15724f; }
.badge.closed { background: #eef1ef; color: #4e5752; }
.badge.unknown { background: #fff1d7; color: #8a6117; }

.message {
    min-height: 24px;
    margin: 12px 4px 4px;
    font-size: 14px;
    color: var(--muted);
}
.message.error { color: var(--danger); }
.message.ok { color: #15724f; }

.footer-status {
    margin: 10px 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}
.dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #aeb5b1;
}
.dot.ok { background: var(--accent); }
.dot.error { background: var(--danger); }

@media (max-width: 520px) {
    .page { width: min(100% - 20px, 680px); }
    .card { border-radius: 18px; padding: 18px; }
    .settings { padding: 4px 16px; }
    .field-row { gap: 10px; align-items: flex-start; }
    .hint { max-width: 190px; }
    .next-card .row,
    .valve-card .row {
        align-items: flex-start;
    }
    .next-value {
        font-size: 17px;
    }
}
