:root {
    --ink: #121812;
    --ink-2: #243024;
    --muted: #6a7568;
    --line: rgba(26, 46, 20, .12);
    --panel: rgba(248, 250, 244, .96);
    --panel-solid: #f4f7ef;
    --map-fade: #e8efe0;
    --green: #6cbf3b;
    --green-dark: #4d9a2a;
    --green-deep: #2f5a1a;
    --green-pale: #e4f3d4;
    --warn: #c47a1a;
    --font: 'DM Sans', system-ui, sans-serif;
    --display: 'Bricolage Grotesque', 'DM Sans', sans-serif;
    --panel-w: 380px;
    --shadow: 0 18px 50px rgba(18, 24, 18, .14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%;
    overflow: hidden;
}
body {
    font-family: var(--font);
    color: var(--ink);
    background: #0f160e;
    -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* Carte = plein écran fixe ; sidebar flottante scrollable par-dessus. */
.shell {
    position: relative;
    width: 100%;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
}

.panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 5;
    width: var(--panel-w);
    max-width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(108, 191, 59, .18), transparent 55%),
        linear-gradient(180deg, #f7faF2 0%, var(--panel-solid) 40%, #eef3e8 100%);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
    transition: transform .28s ease;
}
.panel.collapsed { transform: translateX(calc(-1 * var(--panel-w) - 8px)); }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(145deg, var(--green), var(--green-deep));
    color: #fff; font-family: var(--display); font-weight: 800; font-size: 14px;
    box-shadow: 0 8px 18px rgba(77, 154, 42, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-family: var(--display); font-size: 15px; letter-spacing: -.02em; }
.brand-text em { font-style: normal; font-size: 12px; color: var(--muted); }

.icon-btn, .pill-btn, .seg-btn, .detail-close {
    border: 0; cursor: pointer; background: transparent;
}
.icon-btn {
    width: 34px; height: 34px; border-radius: 10px;
    background: rgba(255,255,255,.7); border: 1px solid var(--line);
    font-size: 20px; line-height: 1; color: var(--ink-2);
}
.icon-btn:hover { background: #fff; }

.panel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 16px 24px;
    scrollbar-width: thin;
}
.panel-head, .panel-foot { flex-shrink: 0; }
.block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }

.title {
    font-family: var(--display);
    font-size: clamp(1.55rem, 2.4vw, 1.9rem);
    line-height: 1.05;
    letter-spacing: -.03em;
    color: var(--green-deep);
}
.lead { margin-top: 8px; font-size: 13.5px; color: var(--muted); line-height: 1.45; }

.controls { display: grid; gap: 12px; }
.seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(255,255,255,.65);
    border: 1px solid var(--line);
}
.seg-3 { grid-template-columns: 1fr 1fr 1fr; }
.seg-btn {
    padding: 9px 8px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    transition: .16s ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active {
    background: var(--green);
    color: #fff;
    box-shadow: 0 6px 16px rgba(77, 154, 42, .28);
}

.field { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.field select, .field input {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    outline: none;
}
.field select:focus, .field input:focus {
    border-color: rgba(108, 191, 59, .55);
    box-shadow: 0 0 0 3px rgba(108, 191, 59, .18);
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    border-bottom: 0 !important;
}
.stat {
    background: rgba(255,255,255,.72);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 8px;
    text-align: center;
}
.stat-k { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.stat-v { display: block; margin-top: 4px; font-family: var(--display); font-size: 15px; letter-spacing: -.02em; }

.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.list-head h2 { font-family: var(--display); font-size: 15px; }
.muted { color: var(--muted); font-size: 12px; font-weight: 500; }

.zone-list { display: grid; gap: 6px; }
.zone-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: rgba(255,255,255,.55);
    cursor: pointer;
    text-align: left;
    transition: .15s ease;
}
.zone-row:hover, .zone-row.active {
    background: #fff;
    border-color: rgba(108, 191, 59, .35);
    box-shadow: 0 8px 20px rgba(18, 24, 18, .06);
}
.zone-row.active { outline: 2px solid rgba(108, 191, 59, .35); }
.zone-name { font-weight: 650; font-size: 14px; }
.zone-sub { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.zone-val { font-family: var(--display); font-weight: 700; font-size: 14px; text-align: right; white-space: nowrap; }
.zone-bar {
    grid-column: 1 / -1;
    height: 4px;
    border-radius: 99px;
    background: rgba(18, 24, 18, .06);
    overflow: hidden;
}
.zone-bar > i {
    display: block; height: 100%; border-radius: inherit;
    background: var(--green);
}

.skel {
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(90deg, rgba(255,255,255,.4), rgba(255,255,255,.85), rgba(255,255,255,.4));
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.panel-foot {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--line);
    font-size: 12px;
}
.panel-foot a { font-weight: 650; color: var(--green-deep); }

.map-wrap {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: var(--map-fade);
}
#map { position: absolute; inset: 0; z-index: 1; background: #dfe8d6; width: 100%; height: 100%; }

.map-overlay.top {
    position: absolute;
    z-index: 4;
    top: 14px;
    left: calc(var(--panel-w) + 14px);
    right: 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
    transition: left .28s ease;
}
.panel.collapsed ~ .map-wrap .map-overlay.top,
.shell:has(.panel.collapsed) .map-overlay.top { left: 14px; }
.map-overlay.top > * { pointer-events: auto; }

.pill-btn {
    display: none;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(248, 250, 244, .94);
    border: 1px solid var(--line);
    font-weight: 700;
    font-size: 13px;
    box-shadow: var(--shadow);
}

.legend {
    margin-left: auto;
    min-width: 160px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(248, 250, 244, .94);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.legend-title { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.legend-bar {
    height: 8px;
    border-radius: 99px;
    background: linear-gradient(90deg, #8fd35a, #f0c14a, #e07a3a);
}
.legend-scale { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11px; font-weight: 600; color: var(--ink-2); }

.map-hint {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(18, 24, 18, .78);
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity .35s ease;
    white-space: nowrap;
}
.map-hint.show { opacity: 1; }

.detail {
    position: absolute;
    z-index: 5;
    right: 16px;
    bottom: 16px;
    width: min(360px, calc(100% - 32px));
    background: rgba(248, 250, 244, .97);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 16px 16px 14px;
    animation: rise .28s ease;
}
@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.detail-close {
    position: absolute;
    top: 8px; right: 10px;
    width: 30px; height: 30px;
    border-radius: 10px;
    font-size: 20px;
    color: var(--muted);
}
.detail-close:hover { background: rgba(0,0,0,.05); color: var(--ink); }
.detail-kicker { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--green-dark); }
.detail-title { font-family: var(--display); font-size: 1.35rem; letter-spacing: -.02em; margin: 4px 0 2px; line-height: 1.1; }
.detail-sub { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.detail-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
}
.detail-card span { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.detail-card strong { display: block; margin-top: 3px; font-family: var(--display); font-size: 15px; }
.detail-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.detail-actions a, .detail-actions button {
    flex: 1;
    min-width: 120px;
    text-align: center;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 13px;
    border: 0;
    cursor: pointer;
}
.btn-main { background: var(--green); color: #fff; }
.btn-ghost { background: rgba(18,24,18,.06); color: var(--ink); }

.leaflet-container { font: inherit; background: #b8bcc2; }
/* Monde / voisins en gris ; la Suisse colorée est un calque vectoriel au-dessus. */
.leaflet-tile-pane {
    filter: grayscale(1) saturate(0) brightness(1.02) contrast(0.9);
}
.leaflet-control-attribution { font-size: 10px !important; background: rgba(255,255,255,.7) !important; }
.price-tip {
    background: transparent; border: 0; box-shadow: none;
}
.price-tip-inner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    white-space: nowrap;
    border: 2px solid #fff;
    box-shadow: 0 6px 16px rgba(0,0,0,.28);
    transform: translate(-50%, -50%);
}

@media (max-width: 920px) {
    .panel {
        width: min(var(--panel-w), 92vw);
        transform: translateX(calc(-100% - 8px));
    }
    .panel.open { transform: translateX(0); }
    .panel.collapsed { transform: translateX(calc(-100% - 8px)); }
    .map-overlay.top,
    .shell:has(.panel.collapsed) .map-overlay.top { left: 14px; }
    .pill-btn { display: inline-flex; }
    .map-hint { bottom: 72px; font-size: 12px; max-width: 90vw; white-space: normal; text-align: center; }
    .detail { left: 12px; right: 12px; width: auto; bottom: 12px; max-height: 45dvh; overflow: auto; }
}
