:root {
    --ink: #1c1c1c;
    --muted: #5c6370;
    --bg: #f3f4f6;
    --card: #fff;
    --line: #e6e8eb;
    --accent: #128a5c;
    --price: #0b6b45;
    --mark: #128a5c;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.45;
}

a { color: var(--accent); }

.wrap {
    width: min(960px, calc(100% - 32px));
    margin-inline: auto;
}

.site-header, .topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.site-header a, .topbar a { color: inherit; }

.site-header nav a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
}

.site-header nav a:hover { color: var(--accent); }

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
}

.logo {
    font-weight: 700;
    text-decoration: none;
    color: var(--ink);
    font-size: 1.05rem;
    white-space: nowrap;
}

.site-footer {
    padding: 20px 0;
    margin-top: 32px;
    color: var(--muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--line);
    background: #fff;
}

.detail {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    margin: 20px 0 40px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}

.detail h1 {
    margin: 0 0 8px;
    font-size: 1.6rem;
    font-weight: 700;
}

.tag {
    display: inline-block;
    margin: 0 0 10px;
    padding: 3px 8px;
    background: #e8f6ef;
    color: var(--price);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.meta { color: var(--muted); margin: 0 0 16px; }

.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--price);
}

.dates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 20px 0;
    padding: 16px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.dates dt {
    font-size: 0.75rem;
    color: var(--muted);
}

.dates dd { margin: 2px 0 0; font-weight: 600; }

.btn {
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    padding: 12px 16px;
    margin-top: 8px;
    font-weight: 600;
}

.back { margin: 16px 0 0; }
.lead { max-width: 68ch; color: #333; }

body.map-app {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    align-items: center;
    padding: 10px 16px;
    z-index: 800;
}

.topbar-search { position: relative; flex: 1 1 220px; min-width: 160px; }

.topbar-search input {
    width: 100%;
    font: inherit;
    padding: 10px 42px 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
}

.topbar-search input[type="search"]::-webkit-search-decoration,
.topbar-search input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.locate-btn {
    position: absolute;
    right: 6px;
    top: 6px;
    transform: none;
    z-index: 2;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.locate-btn:hover,
.locate-btn.is-on { color: var(--accent); }

.locate-btn.is-busy { opacity: 0.45; pointer-events: none; }

.locate-status {
    display: none;
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    z-index: 802;
    padding: 4px 8px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid var(--line);
    color: #8a2b2b;
    font-size: 0.75rem;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.locate-status.is-on { display: block; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: #fff;
    font-size: 0.88rem;
    cursor: pointer;
    user-select: none;
}

.chip input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.chip:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.chip:has(input:checked) {
    border-color: var(--accent);
    background: #e8f6ef;
    color: var(--price);
}

.topbar-count {
    margin: 0 0 0 auto;
    color: var(--muted);
    font-size: 0.9rem;
}

.workspace {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.panel {
    width: 400px;
    flex: 0 0 400px;
    background: var(--bg);
    border-right: 1px solid var(--line);
    overflow: auto;
    display: none;
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
}

body.panel-open .panel {
    display: block;
    pointer-events: auto;
}

.sheet-handle { display: none; }

.panel-head {
    position: sticky;
    top: 0;
    background: var(--bg);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 14px 8px;
    z-index: 2;
}

.panel-head h1 {
    margin: 0;
    font-size: 1.15rem;
}

.panel-close {
    display: none;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.2rem;
}

.crawl-meta {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.8rem;
}

.list { display: grid; gap: 8px; padding: 0 14px 24px; }

.list .empty {
    margin: 12px 2px;
    color: var(--muted);
}

.list .offer {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.list .offer > a {
    display: block;
    padding: 12px 92px 12px 14px;
    text-decoration: none;
    color: inherit;
}

.list .offer:hover, .list .offer.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.show-on-map {
    position: absolute;
    top: 10px;
    right: 10px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 16px;
    padding: 6px 10px;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}

.show-on-map:hover {
    border-color: var(--accent);
    color: var(--price);
}

.list .price {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--price);
}

.list .place { margin-top: 2px; font-weight: 600; }
.list .specs, .list .when { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.list .fresh { color: var(--accent); font-weight: 600; }

.source-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
}

.badge-src,
.badge-trust {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 4px;
    border: 1px solid var(--line);
    background: #f7f8fa;
    color: #334155;
}

.badge-src i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    font-style: normal;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: #64748b;
}

.badge-src.badge-edesky i { background: #0f766e; }
.badge-src.badge-obec i { background: #1d4ed8; }
.badge-src.badge-seed i { background: #a16207; }
.badge-src.badge-search i { background: #9333ea; }
.badge-src.badge-edesky { border-color: #99f6e4; background: #f0fdfa; }
.badge-src.badge-obec { border-color: #bfdbfe; background: #eff6ff; }
.badge-src.badge-seed { border-color: #fde68a; background: #fffbeb; }
.badge-src.badge-search { border-color: #e9d5ff; background: #faf5ff; }

.badge-trust.trust-3 { color: #0f766e; border-color: #99f6e4; background: #f0fdfa; }
.badge-trust.trust-2 { color: #a16207; border-color: #fde68a; background: #fffbeb; }
.badge-trust.trust-1 { color: #7c3aed; border-color: #e9d5ff; background: #faf5ff; }

.score-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 7px;
}

.score-bar {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: #e8ebef;
    overflow: hidden;
}

.score-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #94a3b8, #0f766e);
}

.score-num {
    min-width: 1.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-align: right;
}

.detail-source { margin: 0 0 8px; }
.detail-score { max-width: 220px; margin: 0 0 12px; }

.leaflet-popup-content .source-row { margin-top: 6px; }
.leaflet-popup-content .score-row { margin-top: 5px; margin-bottom: 4px; }

.map-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

#map { position: absolute; inset: 0; }

.panel-toggle {
    position: absolute;
    z-index: 500;
    left: 12px;
    top: 12px;
    padding: 10px 14px;
    border: 0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.16);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

body.panel-open .panel-toggle { display: none; }

.map-type {
    position: absolute;
    z-index: 500;
    left: 12px;
    bottom: 28px;
    display: flex;
    overflow: hidden;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.16);
}

.map-type button {
    border: 0;
    background: #fff;
    padding: 8px 12px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.map-type button.is-on {
    background: var(--accent);
    color: #fff;
}

.mobile-dock { display: none; }

.leaflet-div-icon.plot-mark,
.leaflet-div-icon.price-mark {
    background: transparent;
    border: none;
}

.plot-mark {
    width: 12px;
    height: 12px;
    background: var(--mark);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.price-mark span {
    display: inline-block;
    background: #fff;
    color: var(--price);
    border: 1px solid #d7ebe1;
    border-radius: 12px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.18);
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16);
}

.leaflet-popup-content { margin: 12px 14px; }
.popup-facts { margin: 6px 0; font-weight: 700; color: var(--price); }
.popup-when { color: var(--muted); font-size: 0.8rem; }

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large { background: rgba(18, 138, 92, 0.2); }
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: var(--accent);
    color: #fff;
}

.leaflet-top { top: 8px; }

code { font-size: 0.86em; }

@media (max-width: 899px) {
    .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
    }
    .logo { grid-column: 1; grid-row: 1; }
    .topbar-count {
        display: block;
        margin: 0;
        font-size: 0.8rem;
        grid-column: 2;
        grid-row: 1;
    }
    .topbar-search { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
    .filters { grid-column: 1 / -1; grid-row: 3; }
    .topbar-search input { padding: 11px 42px 11px 12px; }
    .workspace { display: block; }
    .map-wrap {
        position: absolute;
        inset: 0;
    }
    .sheet-handle {
        display: block;
        width: 36px;
        height: 4px;
        margin: 8px auto 0;
        background: #d0d4d9;
        border-radius: 2px;
    }
    .panel {
        display: block;
        position: absolute;
        z-index: 600;
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        height: min(68vh, 560px, calc(100% - 12px));
        max-height: calc(100% - 12px);
        flex: none;
        border-right: 0;
        border-top: 1px solid var(--line);
        border-radius: 16px 16px 0 0;
        transform: translateY(110%);
        transition: transform 0.22s ease;
        box-shadow: 0 -8px 24px rgba(16, 24, 40, 0.12);
    }
    body.panel-open .panel { transform: translateY(0); }
    .panel-close { display: block; }
    .panel-toggle { display: none; }
    .map-type { bottom: 12px; }
    .map-type button { min-height: 36px; }
    .list .offer > a { padding-right: 14px; padding-bottom: 44px; }
    .show-on-map {
        top: auto;
        bottom: 10px;
        right: 10px;
        min-height: 36px;
    }
    .mobile-dock {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid var(--line);
        z-index: 850;
    }
    .mobile-dock button {
        min-height: 44px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: #fff;
        font: inherit;
        font-weight: 600;
        cursor: pointer;
        touch-action: manipulation;
    }
    .mobile-dock button.is-on {
        background: var(--accent);
        border-color: var(--accent);
        color: #fff;
    }
    .leaflet-top { top: 4px; }
    .topbar-count { white-space: nowrap; }
    .facts { font-size: 1.1rem; gap: 6px 14px; }
    .detail { padding: 16px; margin: 12px 0 28px; }
    .lead { overflow-wrap: anywhere; }
}

@media (min-width: 900px) {
    .panel-close { display: none; }
    body.panel-open .panel-close { display: block; }
}
