.bar-right { display: flex; align-items: center; gap: 10px; }

.badge {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 5px 9px;
  border-radius: 8px;
  text-transform: uppercase;
}
.badge--test { background: #f4b400; color: #1a1400; }
.badge--offline { background: #e5484d; color: #fff; }

.dash { max-width: 1480px; margin: 0 auto; padding: 8px 18px 40px; width: 100%; flex: 1; }
.head h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 6px 0 4px; letter-spacing: -.02em; }
.updated { color: var(--muted); margin: 0 0 18px; font-size: .9rem; }
.muted { color: var(--muted); }

/* Prominent counted-districts bar at the top. */
.count-hero {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.count-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.count-num { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.count-of { color: var(--muted); font-size: .95rem; }
.count-pct { margin-left: auto; font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; box-shadow: var(--shadow);
}
.stat-num { display: block; font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-lbl { display: block; margin-top: 4px; font-size: .8rem; color: var(--muted); }
.progress { height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; }
.progress--lg { height: 16px; border-radius: 8px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .5s; }
.stat-progress { margin-top: 10px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card h2 { font-size: 1.05rem; margin: 0 0 16px; }

/* Column chart, bars sized from JS (no inline styles). */
.chart { display: flex; align-items: flex-end; gap: 2%; height: 240px; margin-bottom: 26px; position: relative; }
.chart::before {
  /* 4 % threshold line, positioned by --threshold from JS */
  content: ""; position: absolute; left: 0; right: 0;
  bottom: var(--threshold, 0%); border-top: 2px dashed var(--muted); opacity: .6;
}
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; position: relative; }
.col-pct { font-size: .8rem; font-weight: 700; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.col-bar { width: 78%; border-radius: 5px 5px 0 0; position: relative; min-height: 2px; transition: height .4s; }
.col-prev { position: absolute; left: -6px; right: -6px; height: 2px; background: var(--text); opacity: .55; }
.col-abbr { position: absolute; top: 100%; left: 0; right: 0; text-align: center; margin-top: 6px; font-size: .78rem; font-weight: 700; }
.chart-note { color: var(--muted); font-size: .78rem; margin: 12px 0 0; }

/* Seat bar */
.seatbar { display: flex; height: 34px; border-radius: 8px; overflow: hidden; position: relative; background: var(--border); }
.seat-seg { height: 100%; transition: width .4s; }
.seatbar::after {
  content: ""; position: absolute; top: -4px; bottom: -4px; left: 50%;
  width: 2px; background: var(--text);
}
.blocs { display: flex; margin-top: 10px; font-size: .85rem; gap: 12px; }
.bloc { flex: 1; min-width: 0; }
.bloc b { font-variant-numeric: tabular-nums; }
.bloc-left { text-align: left; }
.bloc-mid { text-align: center; color: var(--muted); }
.bloc-right { text-align: right; }

/* Graphs + map zone. Narrow: single column, map falls below "Mandat i riksdagen".
   Wide: chart over seats on the left, map spanning both on the right. */
.graphs .card { margin-bottom: 18px; }
@media (min-width: 900px) {
  .graphs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 420px);
    grid-template-areas: "chart map" "seats map" "detail map";
    gap: 18px;
    align-items: start;
    margin-bottom: 18px;
  }
  .graphs .card { margin-bottom: 0; }
  .g-chart { grid-area: chart; }
  .g-seats { grid-area: seats; }
  .g-detail { grid-area: detail; }
  .g-map { grid-area: map; position: sticky; top: 12px; }
}

.map-modes { display: flex; gap: 14px; margin-bottom: 12px; font-size: .85rem; }
.map-mode { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.map-mode input { accent-color: var(--accent); }
.map-wrap { display: flex; justify-content: center; }
#se-map { width: 100%; height: auto; max-height: 67vh; display: block; }
#se-map path {
  fill: var(--border); stroke: var(--card); stroke-width: 1;
  transition: fill .4s; cursor: pointer; outline: none;
}
#se-map path:hover, #se-map path:focus { stroke: var(--text); stroke-width: 1.5; }
#se-map circle.city {
  fill: var(--border); stroke: var(--card); stroke-width: 1.4;
  transition: fill .4s; cursor: pointer; outline: none;
}
#se-map circle.city:hover, #se-map circle.city:focus { stroke: var(--text); stroke-width: 2; }
.map-tip { color: var(--muted); font-size: .82rem; margin: 10px 0 0; min-height: 1.2em; text-align: center; }
.map-tip b { color: var(--text); }
.map-legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 12px; font-size: .78rem; color: var(--muted); align-items: center; justify-content: center; }
.map-legend .lg-item { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .lg-sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(128,128,128,.35); }
.map-legend .lg-grad { width: 90px; height: 12px; border-radius: 3px; border: 1px solid rgba(128,128,128,.35); }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: middle; border: 1px solid rgba(128,128,128,.35); }
.up { color: #2ea043; } .down { color: #e5484d; }
.counted-cell { min-width: 140px; }
.counted-bar {
  position: relative; height: 18px; border-radius: 5px;
  background: var(--border); overflow: hidden;
}
.counted-fill { height: 100%; background: var(--accent); transition: width .5s; }
.counted-lbl {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 6px; font-size: .74rem; font-variant-numeric: tabular-nums; color: var(--text);
}
.vk-row { cursor: pointer; }
.vk-row:hover { background: var(--bg-soft); }
.vk-detail td { background: var(--bg-soft); font-size: .82rem; color: var(--muted); white-space: normal; }

.waiting {
  margin: 10px auto 0; max-width: 640px; padding: 8px 14px; text-align: center;
  font-size: .9rem; color: var(--muted);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .col-abbr { font-size: .68rem; }
  .col-pct { font-size: .66rem; }
}
