:root {
    --bg: #f4f7fa;
    --surface: #ffffff;
    --border: #dce3ec;
    --text: #16202b;
    --muted: #5b6b7c;
    --brand: #0c5c9e;
    --brand-ink: #ffffff;
    --ok: #0f7a43;
    --warn: #8a5a00;
    --error: #b3261e;
    /* Odznak poruchy má vlastní dvojici barev, aby držel kontrast
       v obou režimech – --error se v tmavém přepíná na světlou. */
    --fault-bg: #b3261e;
    --fault-ink: #ffffff;
    --accent-bg: #e8f1fa;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 8px 24px rgba(16, 32, 48, .06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111820;
        --surface: #19222c;
        --border: #2b3846;
        --text: #e8eef5;
        --muted: #9dadbd;
        --brand: #4ea3e8;
        --brand-ink: #06131f;
        --ok: #5cc98d;
        --warn: #e5b45c;
        --error: #ff8a80;
        --fault-bg: #ff8a80;
        --fault-ink: #3b0906;
        --accent-bg: #1d2b3a;
        --shadow: none;
    }
}

* { box-sizing: border-box; }

/* Musí přebít display u .btn – jinak by atribut hidden nic neskryl
   a tlačítka pro uložení a vypnutí by svítila i bez zapnutého odběru. */
[hidden] { display: none !important; }

body {
    margin: 0;
    padding: 0 1rem 3rem;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    -webkit-text-size-adjust: 100%;
}

main, .masthead, .footer { max-width: 46rem; margin-inline: auto; }

.masthead { padding: 2rem 0 1rem; display: flex; align-items: center; gap: .8rem; }
.masthead__logo { flex: 0 0 auto; border-radius: 11px; box-shadow: var(--shadow); }
.masthead h1 { margin: 0; font-size: clamp(1.5rem, 5vw, 2rem); letter-spacing: -.01em; }
.masthead__sub { margin: .35rem 0 0; color: var(--muted); font-size: .95rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.card h2 { margin: 0 0 .5rem; font-size: 1.15rem; }

.muted { color: var(--muted); font-size: .93rem; }

.field { display: block; margin: 1rem 0 .75rem; }
.field__label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: .35rem;
}
.field__opt { font-weight: 400; opacity: .8; }
input[type="text"], input[type="search"], input[type="password"], input[type="number"], textarea {
    width: 100%;
    padding: .7rem .85rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn {
    appearance: none;
    font: inherit;
    font-weight: 600;
    padding: .6rem 1.05rem;
    min-height: 44px;                      /* pohodlný cíl pro prst */
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn:hover:not(:disabled) { border-color: var(--brand); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn--quiet { background: transparent; color: var(--muted); }

/* Sbalený stav zapnutého hlídání. */
.active-state {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .4rem;
    font-size: 1rem;
}
.active-state__dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--ok);
    flex: 0 0 auto;
}
.active-state__watch { margin: 0; color: var(--muted); font-size: .93rem; }
.active-state__watch #watch-list { color: var(--text); font-weight: 600; }

.status { margin: .85rem 0 0; font-size: .93rem; min-height: 1.4em; }
.status--ok    { color: var(--ok); }
.status--warn  { color: var(--warn); }
.status--error { color: var(--error); }

.filter { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.filter .field { flex: 1 1 14rem; margin: 0; }

.outages { list-style: none; margin: .75rem 0 0; padding: 0; }
.outage {
    padding: .95rem 0;
    border-top: 1px solid var(--border);
}
.outage:first-child { border-top: none; }

.outage__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.outage__date { font-weight: 700; font-variant-numeric: tabular-nums; }
.outage__time { color: var(--muted); font-size: .9rem; }
.outage__place { margin: .2rem 0 .25rem; font-size: 1.02rem; }
.outage__reason { margin: 0; color: var(--muted); font-size: .93rem; }
.outage__note { margin: .4rem 0 0; font-size: .93rem; }

.outage--today {
    background: var(--accent-bg);
    border-radius: 10px;
    padding-inline: .75rem;
}

/* Právě probíhající odstávka – nejnaléhavější, výrazný levý pruh. */
.outage--ongoing {
    background: var(--accent-bg);
    border-radius: 10px;
    padding-inline: .75rem;
    border-left: 4px solid var(--error);
}

/* Odstávka otevřená z notifikace – krátké bliknutí, ať ji oko najde. */
.outage--flash {
    animation: outageFlash 2.4s ease-out;
}
@keyframes outageFlash {
    0%, 30%   { background: var(--brand); color: var(--brand-ink); border-radius: 10px; }
    100%      { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
    .outage--flash { animation: none; outline: 3px solid var(--brand); border-radius: 10px; }
}

/* Rada k zadání obce a rychlé přidání. */
.field-hint {
    margin: -.25rem 0 .75rem;
    font-size: .85rem;
    color: var(--muted);
    line-height: 1.5;
}
.place-add { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0 0 .85rem; }
.place-add__label { font-size: .82rem; color: var(--muted); }
.place-add__chip {
    font: inherit;
    font-size: .85rem;
    padding: .25rem .7rem;
    min-height: 34px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--brand);
    cursor: pointer;
}
.place-add__chip:hover { border-color: var(--brand); }

/* Volba hlídání zákalu. */
.check-row {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    margin: 0 0 .75rem;
    font-size: .93rem;
    cursor: pointer;
}
.check-row input { margin-top: .2rem; width: 18px; height: 18px; flex: 0 0 auto; }
.check-row__hint { display: block; color: var(--muted); font-size: .85rem; margin-top: .15rem; }

/* Historie změn odstávky. */
.history { margin-top: .5rem; font-size: .88rem; }
.history > summary { cursor: pointer; color: var(--brand); padding: .2rem 0; }
.history__list { list-style: none; margin: .4rem 0 0; padding: .4rem 0 0 .2rem; border-top: 1px dashed var(--border); }
.history__list > li { margin-bottom: .5rem; }
.history__list > li > time { color: var(--muted); font-size: .8rem; }
.history__fields { list-style: none; margin: .15rem 0 0; padding: 0; }
.history__fields li { margin: .1rem 0; }
.history__old { color: var(--muted); text-decoration: line-through; }
.history__new { color: var(--text); }

/* Zvýrazněný blok s odstávkou z upozornění. */
.card--featured { border: 2px solid var(--brand); }
.featured__label {
    margin: 0 0 .5rem;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--brand);
}
.card--featured .outage { padding-top: 0; border-top: none; }
.badge {
    background: var(--brand);
    color: var(--brand-ink);
    border-radius: 999px;
    padding: .05rem .5rem;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

/* Porucha je neplánovaná a naléhavější – musí být odlišitelná i bez čtení. */
.badge--porucha   { background: var(--fault-bg); color: var(--fault-ink); }
.badge--planovana { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.badge--neurceno  { background: transparent; color: var(--muted); border: 1px solid var(--border); }
/* Právě probíhá – tyrkysová, odlišná od červené „porucha" i modré „dnes". */
.badge--ongoing   { background: #0f766e; color: #fff; }
/* Zákal – odlišná barva od druhu i stavu. */
.badge--turbidity { background: transparent; color: var(--warn); border: 1px solid var(--warn); }

.badge--utility           { background: transparent; border: 1px solid var(--border); color: var(--text); }
.badge--utility-voda      { border-color: var(--brand); color: var(--brand); }
.badge--utility-elektrina { border-color: #b7791f; color: #b7791f; }
.badge--utility-plyn      { border-color: #2f855a; color: #2f855a; }

/* Drobné vektorové ikonky v textu — dědí barvu okolního textu,
   aby seděly do odznaků, nadpisů i tlačítek. */
.uicon {
    width: 1em;
    height: 1em;
    fill: currentColor;
    vertical-align: -0.125em;
    flex: 0 0 auto;
}
.uicon--ok { color: var(--ok); width: 1.15em; height: 1.15em; }
.settings-sub .uicon { color: var(--brand); }
.report-flow__btn .uicon { width: 15px; height: 15px; }
/* Rozsah odstávky – postihuje celou obec/město. */
.badge--area      { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
@media (prefers-color-scheme: dark) {
    .badge--ongoing { background: #2dd4bf; color: #04211d; }
}

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .75rem; }
.chip {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: .3rem .8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    font-size: .88rem;
}
.chip--on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }

/* --- sdílení --- */

.share {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: .5rem;
}
.share__btn {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    min-height: 46px;
    padding: .6rem .85rem;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--share-bg, var(--brand));
    border: 1px solid transparent;
    border-radius: 10px;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
}
.share__btn:hover { filter: brightness(1.08); }
.share__icon { width: 20px; height: 20px; fill: currentColor; flex: 0 0 auto; }

/* Značkové barvy sítí. Facebook je o odstín tmavší než oficiální #1877f2 –
   ten má s bílým textem jen 4,23:1 a nesplnil by WCAG AA. */
.share--fb   { --share-bg: #1565d8; }
.share--wa   { --share-bg: #197d53; }
.share--x    { --share-bg: #16181c; }
.share--mail { --share-bg: #55606d; }
.share--copy { --share-bg: transparent; color: var(--text); border-color: var(--border); }
.share--copy:hover { border-color: var(--brand); filter: none; }

/* --- přehled pro správce --- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: .6rem;
    margin: 1rem 0;
}
.stat {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .6rem .75rem;
}
.stat dt { font-size: .78rem; color: var(--muted); }
.stat dd { margin: .15rem 0 0; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.log { list-style: none; margin: .5rem 0 0; padding: 0; }
.log__row { padding: .6rem 0 .6rem .7rem; border-left: 3px solid var(--border); margin-bottom: .3rem; }
.log__row--error { border-left-color: var(--error); }
.log__row--warn  { border-left-color: var(--warn); }
.log__row--info  { border-left-color: var(--ok); }
.log__head { display: flex; gap: .6rem; align-items: baseline; font-size: .78rem; color: var(--muted); }
.log__level { text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.log__message { margin: .15rem 0 0; font-size: .93rem; }
.log__detail {
    margin: .2rem 0 0;
    font-size: .85rem;
    color: var(--muted);
    word-break: break-word;
}

/* Tabulka se na úzkém displeji posouvá sama, stránka se kvůli ní neroztáhne. */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.table th { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.table .btn { padding: .3rem .7rem; font-size: .82rem; }
.table form { margin: 0; }
.notice--ok { color: var(--ok); }

.empty { color: var(--muted); padding: 1rem 0; }

.more { margin: 1rem 0 0; text-align: center; }
.more .btn { display: inline-flex; }

.notice {
    margin: 0 0 1rem;
    padding: .7rem .9rem;
    border-radius: 10px;
    font-size: .93rem;
    border: 1px solid currentColor;
}
.notice--warn { color: var(--warn); }

.callout {
    margin-top: .9rem;
    padding: .85rem .95rem;
    background: var(--accent-bg);
    border-radius: 10px;
    font-size: .93rem;
}
.callout p { margin: 0 0 .5rem; }
.callout p:last-of-type { margin-bottom: .6rem; }

/* Sbalená sekce návodu – klikací nadpis. */
.guide-section { padding-block: 0; }
.guide-section > .guide-section__summary {
    cursor: pointer;
    padding: 1.25rem;
    margin: -1.25rem;               /* překryje padding karty, aby byl klikací celý */
    list-style: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.guide-section__summary::-webkit-details-marker { display: none; }
.guide-section__summary h2 { margin: 0; }
.guide-section__summary::after {
    content: '▾';
    margin-left: auto;
    color: var(--muted);
    transition: transform .2s;
}
.guide-section[open] > .guide-section__summary::after { transform: rotate(180deg); }
.guide-section[open] > .guide-section__summary { margin-bottom: 0; }
.guide-section > .guide { margin-inline: 0; }
.guide-section > .guide:first-of-type { border-top: 1px solid var(--border); margin-top: .5rem; }

.guide { border-top: 1px solid var(--border); padding: .7rem 0; }
.guide:first-of-type { border-top: none; }
/* Záměrně bez display:flex – ten by zahodil mezery mezi textovými uzly
   a nadpis by se slepil do „iPhone a iPad(iOS 16.4…)“. */
.guide summary {
    cursor: pointer;
    padding: .5rem 0;
    line-height: 1.5;
}
.guide summary::marker { color: var(--brand); }
.guide[open] summary { margin-bottom: .3rem; }
.guide p { margin: .4rem 0; }

.steps { margin: .5rem 0 .3rem; padding-left: 1.35rem; }
.steps li { margin-bottom: .4rem; }

/* --- průvodce instalací --- */

.checks { list-style: none; margin: .5rem 0 0; padding: 0; }
.check { display: flex; gap: .6rem; align-items: flex-start; padding: .35rem 0; }
.check__mark { font-weight: 700; line-height: 1.6; }
.check--ok .check__mark   { color: var(--ok); }
.check--bad .check__mark  { color: var(--error); }
.check--warn .check__mark { color: var(--warn); }

select {
    width: 100%;
    padding: .7rem .85rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}

code {
    background: var(--accent-bg);
    padding: .1rem .3rem;
    border-radius: 5px;
    font-size: .9em;
}

.code {
    background: var(--accent-bg);
    padding: .75rem .85rem;
    border-radius: 10px;
    overflow-x: auto;      /* dlouhé adresy nesmí roztáhnout stránku */
    font-size: .85rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.footer { padding-top: .5rem; color: var(--muted); font-size: .85rem; }
.footer a { color: var(--brand); }

/* Ukazatel tažení dolů pro obnovení (jen dotyková zařízení). */
.ptr {
    position: fixed;
    top: -56px;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    color: var(--muted);
    font-size: .85rem;
    pointer-events: none;
    z-index: 50;
}
.ptr--visible { opacity: 1; }
.ptr__spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
}
.ptr--loading .ptr__spinner { animation: ptrSpin .8s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
    .ptr--loading .ptr__spinner { animation: none !important; }
}

/* Tlačítko Sdílet u jednotlivé odstávky + sousedská hlášení. */
.outage__actions {
    margin-top: .5rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}
.report-flow {
    margin-right: auto;   /* hlášení vlevo, sdílení vpravo */
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.report-flow__note { font-size: .82rem; color: var(--muted); }

/* Podnadpisy v nastavení administrace. */
.settings-sub { margin: 1.4rem 0 .3rem; font-size: 1rem; }

/* Karty administrace — výraznější než filtrační chipy. */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin: 0 0 1rem;
}
.tab {
    padding: .55rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    text-decoration: none;
    font-size: .95rem;
}
.tab:hover { border-color: var(--brand); }
button.tab { font: inherit; cursor: pointer; }
.tabs--page { margin-bottom: 1.1rem; }
#watch-teaser { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab--on {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-ink);
    font-weight: 600;
}
.tab__badge {
    display: inline-block;
    min-width: 1.35em;
    padding: 0 .35em;
    border-radius: 999px;
    background: var(--error);
    color: #fff;
    font-size: .78em;
    text-align: center;
}

/* QR kód pro přenos hlídání na další zařízení. */
.transfer-qr {
    display: block;
    width: min(260px, 100%);
    image-rendering: pixelated;
    border-radius: 10px;
    margin: .6rem 0;
    background: #fff;
}

/* Statistiky: řádky s vodorovnými pruhy (<progress> nevadí CSP). */
.rank { list-style: none; margin: .5rem 0 0; padding: 0; }
.rank__row { display: flex; align-items: center; gap: .6rem; padding: .25rem 0; }
.rank__name { flex: 0 0 9.5rem; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank__count { flex: 0 0 auto; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank__bar { flex: 1 1 auto; height: 12px; accent-color: var(--brand); }
.rank__bar::-webkit-progress-bar { background: var(--border); border-radius: 6px; }
.rank__bar::-webkit-progress-value { background: var(--brand); border-radius: 6px; }
.rank__bar::-moz-progress-bar { background: var(--brand); border-radius: 6px; }

/* Neoficiální hlášení „u nás neteče“ nad formulářem. */
.dry-list { list-style: none; margin: .25rem 0 1rem; padding: 0; }
.dry-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .45rem 0;
    border-bottom: 1px dashed var(--border);
    font-size: .93rem;
}
.dry-list li:last-child { border-bottom: none; }
.dry-list__info { flex: 1 1 16rem; }
.outage__share {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .65rem;
    font: inherit;
    font-size: .82rem;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
}
.outage__share:hover { color: var(--brand); border-color: var(--brand); }
.outage__share-icon {
    width: 15px;
    height: 15px;
    fill: currentColor;
    stroke: currentColor;
    flex: 0 0 auto;
}

/* Našeptávání ulic pod polem „Konkrétní ulice“. */
.suggest {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin: .4rem 0 .2rem;
}
.suggest__item {
    padding: .3rem .7rem;
    font: inherit;
    font-size: .85rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
}
.suggest__item:hover { border-color: var(--brand); color: var(--brand); }

/* Pruh „jste offline“ – přes celou šířku nad obsahem (ruší boční odsazení body).
   Pevná barva místo var(--warn): v tmavém režimu je --warn světlá okrová
   určená pro text a bílý popisek by na ní nebyl čitelný (kontrast ~1,9:1). */
.offline-banner {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: 0 -1rem;
    padding: .55rem .9rem;
    background: #7a4f00;
    color: #fff;
    font-size: .88rem;
    text-align: center;
}
