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

/* Shared editorial navigation; preserve the established ranking interactions. */
.ranking-main { padding-bottom: 36px; }
.ranking-intro { position: relative; padding-bottom: 24px !important; }
.ranking-intro .page-intro { padding-bottom: 18px; }
.ranking-intro .page-intro h1 { font-size: clamp(2rem, 3.6vw, 3rem); }
.ranking-share { font-size: .875rem !important; }
.ranking-guide { margin: 36px auto 20px; }
.ranking-main #flikar-wrapper { border-top: 1px solid var(--line); border-bottom-color: var(--line); background: var(--paper); }
.ranking-main .flik { min-height: 44px; border-radius: 7px; background: var(--wash); color: var(--ink); }
.ranking-main .flik.aktiv { background: var(--navy); color: #fff; }
.ranking-main #sok-sektion, .ranking-main #ranking-grid, .ranking-main #hela-listan-sektion, .ranking-main #attribution { max-width: 1144px; padding-left: 28px; padding-right: 28px; }
.ranking-main .ranking-kolumn { border: 1px solid var(--line); box-shadow: none; }
.ranking-main .ranking-item { min-height: 55px; }
.ranking-main #attribution { color: var(--muted); font-size: .875rem; line-height: 1.65; }
.ranking-main .ranking-underrubrik { text-align: left; }
.ranking-main #kommunsok { border-width: 1px; border-color: #aebfc9; }
@media(max-width:640px) { .ranking-main #sok-sektion, .ranking-main #ranking-grid, .ranking-main #hela-listan-sektion, .ranking-main #attribution { padding-left:20px; padding-right:20px; } }

        body {
            margin: 0;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #f4f4f9;
            color: #333;
            min-height: 100vh;
        }

        /* ── Header ── */
        #toppen {
            background: #2c3e50;
            color: white;
            padding: 18px 24px 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 16px;
            text-align: center;
        }
        #tillbaka-karta {
            color: rgba(255,255,255,0.75);
            text-decoration: none;
            font-size: 0.88rem;
            display: flex;
            align-items: center;
            gap: 5px;
            white-space: nowrap;
            transition: color 0.15s;
        }
        #tillbaka-karta:hover { color: white; }
        .tillbaka-kort { display: none; }
        .h1-kort { display: none; }
        #toppen h1 {
            margin: 0;
            font-size: 1.25rem;
            font-weight: 700;
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }
        #toppen p {
            margin: 0;
            font-size: 0.82rem;
            color: rgba(255,255,255,0.65);
            white-space: nowrap;
        }

        /* ── Kategori-flikar ── */
        #flikar-wrapper {
            background: white;
            border-bottom: 1px solid #e2e8f0;
            padding: 0 16px;
            overflow-x: auto;
            scrollbar-width: none;
            -webkit-overflow-scrolling: touch;
            display: flex;
            /* OBS: ingen justify-content:center här — det klipper vänstra fliken
               vid overflow. margin:auto på #flikar centrerar när det finns plats. */
            position: sticky;
            top: 0;
            z-index: 200;
        }
        #flikar-wrapper::-webkit-scrollbar { display: none; }
        #flikar {
            display: flex;
            gap: 4px;
            padding: 10px 0;
            margin: 0 auto;
        }
        .flik {
            padding: 8px 16px;
            border: none;
            border-radius: 20px;
            font-size: 0.88rem;
            font-weight: 600;
            cursor: pointer;
            background: #eef2f7;
            color: #2c3e50;
            transition: background 0.15s, color 0.15s;
            white-space: nowrap;
            font-family: inherit;
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 5px;
        }
        .flik:hover { background: #dde4ee; }
        .flik.aktiv { background: #2c3e50; color: white; }

        /* ── Sök-sektion ── */
        #sok-sektion {
            max-width: 900px;
            margin: 20px auto 0;
            padding: 0 16px;
        }
        #sok-wrapper {
            position: relative;
        }
        #kommunsok {
            width: 100%;
            padding: 13px 16px 13px 42px;
            border: 2px solid #e2e8f0;
            border-radius: 10px;
            font-size: 1rem;
            font-family: inherit;
            outline: none;
            transition: border-color 0.2s;
            background: white;
        }
        #kommunsok:focus { border-color: #2c3e50; }
        #kommunsok { padding-right: 38px; }
        #sok-ikon {
            position: absolute;
            left: 14px;
            top: 50%;
            transform: translateY(-50%);
            color: #94a3b8;
            pointer-events: none;
            font-size: 1rem;
        }
        #sok-rensa {
            display: none;
            position: absolute;
            right: 12px;
            top: 50%;
            transform: translateY(-50%);
            border: none;
            background: none;
            font-size: 1rem;
            cursor: pointer;
            color: #94a3b8;
            padding: 4px;
            line-height: 1;
            z-index: 101;
        }
        #sok-rensa:hover { color: #475569; }
        #sok-dropdown {
            display: none;
            position: absolute;
            width: 100%;
            background: white;
            border: 1px solid #cbd5e1;
            border-top: none;
            border-radius: 0 0 10px 10px;
            max-height: 320px;
            overflow-y: auto;
            z-index: 100;
            box-shadow: 0 8px 20px -4px rgba(0,0,0,0.12);
        }
        .sok-item {
            padding: 11px 16px;
            cursor: pointer;
            border-bottom: 1px solid #f1f5f9;
            font-size: 0.95rem;
            transition: background 0.1s;
        }
        .sok-item:last-child { border-bottom: none; }
        .sok-item:hover, .sok-item.aktiv { background: #f8fafc; }
        #sok-resultat {
            margin-top: 12px;
            display: none;
        }
        .resultat-kort {
            background: white;
            border-radius: 10px;
            border-left: 4px solid #2c3e50;
            padding: 14px 18px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.07);
        }
        .resultat-huvud { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
        .resultat-namn { font-weight: 700; font-size: 1.05rem; color: #1e293b; }
        .resultat-kategori { font-size: 0.82rem; color: #64748b; margin-top: 2px; }
        .resultat-pct-badge { font-size: 0.75rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; flex-shrink: 0; }
        .resultat-progress-wrap { margin: 10px 0 4px; height: 6px; background: #f1f5f9; border-radius: 3px; overflow: visible; position: relative; }
        .resultat-progress-fill { height: 100%; border-radius: 3px; }
        .resultat-progress-dot { position: absolute; top: 50%; transform: translate(-50%,-50%); width: 12px; height: 12px; border-radius: 50%; border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
        .resultat-hint { font-size: 0.75rem; color: #94a3b8; margin-bottom: 10px; }
        /* ── Sparkline-trend i stat-boxar ── */
        .trend-svg { overflow: visible; flex-shrink: 0; }
        .stat-trend-col { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; padding-left: 8px; border-left: 1px solid #e2e8f0; }
        .stat-trend-period { font-size: 0.62rem; color: #94a3b8; font-weight: 600; white-space: nowrap; }
        .stat-trend-change { font-size: 0.73rem; font-weight: 700; white-space: nowrap; }
        .stat-trend-sub { font-size: 0.62rem; color: #94a3b8; white-space: nowrap; }
        .resultat-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
        .resultat-stat-box { background: #f8fafc; border-radius: 8px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
        .resultat-faq { margin-top: 12px; border-top: 1px solid #f1f5f9; padding-top: 8px; }
        .resultat-faq summary { cursor: pointer; font-weight: 700; color: #2c3e50; font-size: 0.85rem; list-style: none; }
        .resultat-faq summary::-webkit-details-marker { display: none; }
        .resultat-faq summary::before { content: '\25B8  '; }
        .resultat-faq[open] summary::before { content: '\25BE  '; }
        .resultat-faq p { margin: 6px 0; font-size: 0.82rem; color: #475569; line-height: 1.5; }
        .resultat-faq-q { margin: 8px 0 2px !important; color: #1e293b !important; }
        .parti-pill{display:inline-block;padding:2px 9px;margin:2px 3px 3px 0;border-radius:20px;font-size:0.72rem;font-weight:700;line-height:1.6;white-space:nowrap;vertical-align:middle}.pp-S{background:#E8112d;color:#fff}.pp-M{background:#52BDEC;color:#08334d}.pp-SD{background:#F6D64A;color:#222}.pp-C{background:#009A44;color:#fff}.pp-V{background:#AF0000;color:#fff}.pp-KD{background:#173B7A;color:#fff}.pp-L{background:#1B75BB;color:#fff}.pp-MP{background:#83CF39;color:#14400a}.pp-lokal{background:#64748b;color:#fff}.styre-kalla{color:#64748b;font-size:0.9em}
        html.tema-mork .resultat-faq { border-top-color: #334155; }
        html.tema-mork .resultat-faq summary { color: #e2e8f0; }
        html.tema-mork .resultat-faq p { color: #cbd5e1; }
        html.tema-mork .resultat-faq-q { color: #e2e8f0 !important; }
        .stat-info { flex: 1; min-width: 0; }
        .resultat-stat-label { font-size: 0.72rem; color: #64748b; margin-bottom: 2px; }
        .resultat-stat-val { font-size: 0.88rem; font-weight: 700; color: #1e293b; }
        .resultat-stat-rank { font-size: 0.72rem; margin-top: 1px; }
        .resultat-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
        @media (max-width: 420px) { .resultat-stats-grid { grid-template-columns: 1fr; } }
        .resultat-lankknapp {
            text-decoration: none;
            background: #eef2f7;
            color: #2c3e50;
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 0.85rem;
            font-weight: 600;
            white-space: nowrap;
            transition: background 0.15s;
        }
        .resultat-lankknapp:hover { background: #dde4ee; }

        /* ── Ranking-grid ── */
        #ranking-grid {
            max-width: 900px;
            margin: 20px auto 40px;
            padding: 0 16px;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
        }
        .ranking-kolumn {
            background: white;
            border-radius: 12px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.07);
            overflow: hidden;
        }
        .ranking-rubrik {
            padding: 14px 20px;
            font-size: 1rem;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .rubrik-topp { background: #f0fdf4; color: #166534; border-bottom: 1px solid #dcfce7; }
        .rubrik-botten { background: #fff7ed; color: #9a3412; border-bottom: 1px solid #fed7aa; }
        .ranking-underrubrik {
            font-size: 0.84rem;
            font-weight: 600;
            color: #475569;
            padding: 10px 20px 12px;
            border-bottom: 1px solid #f1f5f9;
            text-align: center;
        }
        .ranking-lista { list-style: none; margin: 0; padding: 0; }
        .ranking-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 11px 16px 11px 13px;
            border-bottom: 1px solid #f8fafc;
            border-left: 3px solid transparent;
            text-decoration: none;
            color: inherit;
            transition: background 0.1s;
            cursor: pointer;
        }
        .ranking-item:last-child { border-bottom: none; }
        .ranking-item:hover { background: #f8fafc; }
        .plats-nr {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.82rem;
            font-weight: 700;
            flex-shrink: 0;
            background: #f1f5f9;
            color: #64748b;
        }
        .plats-1 { background: #ffd700; color: #78350f; }
        .plats-2 { background: #c0c0c0; color: #334155; }
        .plats-3 { background: #cd7f32; color: #fff; }
        .plats-botten-1 { background: #fecaca; color: #991b1b; }
        .plats-botten-2 { background: #fed7aa; color: #9a3412; }
        .plats-botten-3 { background: #fef08a; color: #713f12; }
        .item-info { flex: 1; min-width: 0; }
        .item-namn {
            flex: 1;
            font-weight: 600;
            font-size: 0.95rem;
            color: #1e293b;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            min-width: 0;
        }
        .item-varde {
            font-size: 0.82rem;
            color: #64748b;
            white-space: nowrap;
            flex-shrink: 0;
        }
        .item-pil { color: #cbd5e1; font-size: 0.9rem; }

        /* ── Hela listan ── */
        #hela-listan-sektion {
            max-width: 900px;
            margin: 0 auto 40px;
            padding: 0 16px;
            text-align: center;
        }
        #hela-listan-knapp {
            border: 2px solid #2c3e50;
            background: white;
            color: #2c3e50;
            border-radius: 10px;
            padding: 11px 22px;
            font-size: 0.92rem;
            font-weight: 700;
            cursor: pointer;
            font-family: inherit;
            transition: background 0.15s, color 0.15s;
        }
        #hela-listan-knapp:hover { background: #2c3e50; color: white; }
        #hela-listan {
            display: none;
            text-align: left;
            background: white;
            border-radius: 12px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.07);
            margin-top: 14px;
            overflow: hidden;
        }

        /* ── Laddning ── */
        #laddning {
            text-align: center;
            padding: 60px 20px;
            color: #64748b;
            font-size: 1rem;
        }
        .spinner {
            display: inline-block;
            width: 20px; height: 20px;
            border: 3px solid #e2e8f0;
            border-top-color: #2c3e50;
            border-radius: 50%;
            animation: snurr 0.7s linear infinite;
            vertical-align: middle;
            margin-right: 10px;
        }
        @keyframes snurr { to { transform: rotate(360deg); } }

        /* ── Attribution ── */
        #attribution {
            text-align: center;
            font-size: 0.78rem;
            color: #94a3b8;
            padding: 0 16px 32px;
            max-width: 900px;
            margin: 0 auto;
        }

        /* ── Mörkt läge: aktiveras av html.tema-mork (head-skriptet läser
              🌗-knappens val från localStorage — samma val som på kartan).
              Mörk sida, ljusa innehållskort med hårdkodade färger. ── */
        html.tema-mork body { background: #0f172a; color: #e2e8f0; }
        html.tema-mork .ranking-kolumn, html.tema-mork .resultat-kort,
        html.tema-mork #hela-listan, html.tema-mork #sok-resultat { color: #333; }
        html.tema-mork #flikar-wrapper { background: #1e293b; border-bottom-color: #334155; }
        html.tema-mork .flik { background: #334155; color: #e2e8f0; }
        html.tema-mork .flik:hover { background: #475569; }
        html.tema-mork .flik.aktiv { background: #e2e8f0; color: #0f172a; }
        html.tema-mork #kommunsok { background: #1e293b; color: #e2e8f0; border-color: #334155; }
        html.tema-mork #kommunsok::placeholder { color: #64748b; }
        html.tema-mork #kommunsok:focus { border-color: #94a3b8; }
        html.tema-mork #sok-dropdown { background: #1e293b; border-color: #334155; }
        html.tema-mork .sok-item { border-bottom-color: #334155; }
        html.tema-mork .sok-item:hover, html.tema-mork .sok-item.aktiv { background: #334155; }
        html.tema-mork #laddning { color: #94a3b8; }
        html.tema-mork #attribution { color: #64748b; }
        html.tema-mork #hela-listan-knapp { background: #1e293b; color: #e2e8f0; border-color: #64748b; }
        html.tema-mork #hela-listan-knapp:hover { background: #e2e8f0; color: #0f172a; }

        /* ── Mobil ── */
        @media (max-width: 640px) {
            #toppen { padding: 14px 16px 12px; gap: 10px; }
            #toppen h1 { font-size: 1.05rem; }
            #ranking-grid { grid-template-columns: 1fr; gap: 14px; }
            .flik { font-size: 0.8rem; padding: 7px 13px; }
            #toppen-dela-text { display: inline; }
            #toppen-dela { padding: 10px 16px; }
            .tillbaka-full { display: none; }
            .tillbaka-kort { display: inline; }
            .h1-full { display: none; }
            .h1-kort { display: inline; }
            .flik { flex-direction: column; gap: 2px; padding: 6px 10px; font-size: 0.72rem; }
            .flik-ikon { font-size: 1.1rem; line-height: 1; }
            /* Horisontell, dragbar flikrad på mobil: vänsterställd så alla fem (inkl.
               Arbetslöshet) nås genom att svepa i sidled; sista fliken "kikar" fram. */
            #flikar-wrapper { overflow-x: auto; padding: 0; scroll-snap-type: x proximity; }
            #flikar { flex-wrap: nowrap; justify-content: flex-start; margin: 0; padding: 10px 12px; }
            .flik { flex: 0 0 auto; scroll-snap-align: start; }
        }
    /* Gemensam footer (samma som övriga sidor) */
    .bk-footer{max-width:960px;margin:28px auto 0;padding:20px 16px 40px;text-align:center;color:#64748b;font-size:0.9rem;border-top:1px solid #e2e8f0}
    .bk-footer a{color:#64748b;text-decoration:none}
    .bk-footer a:hover{text-decoration:underline}
    html.tema-mork .bk-footer{color:#94a3b8;border-top-color:#334155}
