:root{
  --bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --panel: #f9fafb;
  --shadow: 0 10px 30px rgba(0,0,0,.08);
  --focus: 2px solid #2563eb;
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; background:var(--bg); color:var(--text); font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial; }
.wrap{ max-width:1100px; margin:0 auto; padding:0 18px; }
.site-header{ border-bottom:1px solid var(--border); background:#fff; }
.site-header .wrap{ padding:22px 18px; }
h1{ margin:0 0 6px; }
.sub{ margin:0; color:var(--muted); font-size:14px; }
.controls{
  position: sticky;
  top: 0;
  z-index: 60;
  margin:18px 0;
  padding:14px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--panel);
  box-shadow: var(--shadow);
}
.control-row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.control-row.small{
  margin-bottom:10px;
  justify-content:space-between;
}
.map-layout{
  display:grid;
  grid-template-columns: 1fr;
  gap:14px;
  margin:18px 0;
}
.map-sidebar{
  border:1px solid var(--border);
  border-radius:16px;
  background:#fff;
  box-shadow: var(--shadow);
  padding:16px;
}
.sidebar-title{
  margin:0 0 8px;
  font-size:16px;
}
.sidebar-text{
  margin:0 0 10px;
  color:var(--muted);
  font-size:13px;
  line-height:1.4;
}
.map-main{ min-width:0; }
@media (min-width: 980px){
  .map-layout{
    grid-template-columns: 2fr 3fr; /* ~25% / 75% */
    align-items:start;
  }
}
.date-control{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
}
.date-control span{ color:var(--muted); font-size:13px; }
.date-control input{
  border:0;
  font-size:14px;
  outline:none;
}
.btn{
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
}
.btn:hover{ background:#f3f4f6; }
.btn:focus{ outline: var(--focus); outline-offset:2px; }
.btn-secondary{ background:#111827; color:#fff; border-color:#111827; }
.btn-secondary:hover{ background:#0b1220; }
.summary{
  color:var(--muted);
  font-size:13px;
  padding:6px 0;
}
.legend{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.legend-item{
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:#fff;
  font-size:12px;
}
.legend-swatch{
  width:12px;
  height:12px;
  border-radius:3px;
  border:1px solid rgba(0,0,0,.12);
}
.map-card{
  border:1px solid var(--border);
  border-radius:16px;
  background:#fff;
  box-shadow: var(--shadow);
  overflow:hidden;
}
.map-frame{ padding:16px; }
#auMap{
  width:100%;
  height:auto;
  display:block;
}
.map-bg{
  fill:#f3f4f6; /* default background */
}
.map-frame-outline{
  fill: none;
  stroke: #d1d5db;
  stroke-width: 2;
}
#mapRegions > path{
  stroke: #ffffff;
  stroke-width: 2.25;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.region{
  fill:#e5e7eb; /* will be updated by JS */
  stroke:#9ca3af;
  stroke-width:2;
  cursor:pointer;
  transition: transform .08s ease, filter .08s ease, opacity .08s ease;
}
.region:hover{
  filter: brightness(1.02);
  transform: translateY(-1px);
}
.region:focus{
  outline:none;
}
.region-dot{
  stroke-width:2;
}
.map-help{
  margin-top:10px;
  color:var(--muted);
  font-size:13px;
}
.kbd{
  font-weight:600;
  color:#374151;
}
.details{
  margin:22px 0 30px;
}
.details h2{
  margin:0 0 12px;
}
.detail-grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:12px;
}
.card{
  grid-column: span 12;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fff;
  box-shadow: var(--shadow);
  overflow:hidden;
}
@media (min-width: 860px){
  .card { grid-column: span 12; }
}
.card-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  padding:14px;
  background: var(--panel);
  border-bottom:1px solid var(--border);
}
.card-title{
  margin:0;
}
.card-meta{
  margin-top:4px;
  color:var(--muted);
  font-size:12px;
}
.winner-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  font-size:12px;
  white-space:nowrap;
}
.winner-dot{
  width:12px;
  height:12px;
  border-radius:4px;
  border:1px solid rgba(0,0,0,.12);
}
.card-body{ padding:14px; }
.card-body-grid{
  display:grid;
  grid-template-columns: 160px 1fr;
  gap:14px;
  align-items:start;
}
@media (max-width: 680px){
  .card-body-grid{ grid-template-columns: 1fr; }
}
.mini-col{ }
.table-col{ }
.fed-swatch{
  width:100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border:1px solid var(--border);
}
.table{
  width:100%;
  border-collapse:collapse;
  font-size:13px;
}
.table th, .table td{
  padding:8px 10px;
  border-bottom:1px solid var(--border);
  text-align:left;
}
.table th{
  color:#374151;
  font-weight:600;
  background:#fafafa;
}
.table td:last-child, .table th:last-child{
  text-align:right;
}
.site-footer{
  border-top:1px solid var(--border);
  background:#fff;
}
.site-footer .wrap{
  padding:16px 18px;
  color:var(--muted);
  font-size:12px;
}
.region-mini{
  width: 100%;
  height: auto;
  display:block;
}
.region-mini-wrap{
  border:1px solid var(--border);
  background:#fff;
  border-radius:12px;
  padding:8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
}
.region-mini .mini-outline{
  fill:none;
  stroke:#9ca3af;
  stroke-width:2;
}
.barcell{
  width: 55%;
}
.bartrack{
  width:100%;
  height: 18px;
  position: relative;
  background:#f3f4f6;
  border:1px solid var(--border);
  border-radius: 999px;
  overflow:hidden;
}
.barfill{
  height: 100%;
  width: 0%;
}
.total-row td{
  font-weight: 400;
  background:#fafafa;
}
.barlabel{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  line-height:1;
  color:#111827;
  opacity:0.75;
  text-shadow: 0 1px 0 rgba(255,255,255,0.7);
  pointer-events:none;
}
.election-strip{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap:8px;
  margin-top:12px;
}
.election-chip{
  border-radius:10px;
  text-align:center;
  font-size:14px;
  border:1px solid rgba(0,0,0,.10);
  box-shadow: 0 6px 14px rgba(0,0,0,.06);
}
.back-to-top{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 50;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  padding:10px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor:pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.back-to-top.is-visible{
  opacity: 1;
  pointer-events: auto;
}
.back-to-top:focus{
  outline: var(--focus);
  outline-offset:2px;
}
.federal-banner{
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.federal-banner .fb-left{
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 0;
}
.federal-banner .fb-swatch{
  width:14px;height:14px;border-radius:4px;border:1px solid rgba(0,0,0,.12);
  flex: 0 0 auto;
}
.federal-banner .fb-text{
  font-size:13px;
  color: var(--text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.federal-banner .fb-meta{
  font-size:12px;
  color: var(--muted);
  white-space:nowrap;
}
.region-desc{
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.region-desc-title{
  margin: 0 0 6px;
  font-size: 14px;
}
.region-desc-body{
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.region-desc-text{
  margin: 0;
  color: var(--muted);
}
.seat-totals-chart{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
  padding: 8px;
}
.small-parties-chart{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
  padding: 8px;
}
.hc-muted{
  color:#6b7280;
  font-size:12px;
}
.election-chip{
  cursor: pointer;
  padding: 6px 10px;
  line-height: 1;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
}
.election-chip:focus{
  outline: 3px solid rgba(0,0,0,.25);
  outline-offset: 2px;
}
