:root {
  --bg: transparent;
  --card: transparent;
  --card-2: transparent;
  --border: rgba(127, 127, 127, 0.28);
  --shadow: none;
  --turnout-fill: #4a607a;
  --selected: #157efc; /*currentColor;*/
  --map-stroke: rgba(255, 255, 255, 0.9);
  --danger: #b3261e;
  --ok: #167c48;
  --chart-grid: rgba(127, 127, 127, 0.18);
  --chart-axis: rgba(127, 127, 127, 0.45);
}
body:not(.dark) {
  --map-stroke: rgba(40, 40, 40, 0.55);
}

body.dark {
  --map-stroke: rgba(255, 255, 255, 0.9) !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: transparent;
  font-family: Arial, Helvetica, sans-serif;
}

body .election-wrap {
  padding: 16px;
}

.election-wrap {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
}

.election-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.election-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.election-header p {
  margin: 6px 0 0 0;
  font-size: 14px;
}

.election-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
#party-legend {
  padding: 5px;
}
#election-grid .legend {
  padding: 5px;
}
.status-pill p {
  margin: 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  flex: 0 0 10px;
}

.status-dot.is-processing {
  background: #d29200;
}
.status-dot.is-error {
  background: var(--danger);
}

.election-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-head {
  padding: 16px 16px 10px 16px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.card-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.card-head p {
  margin: 6px 0 0 0;
  font-size: 13px;
}

.card-body {
  padding: 14px 16px 16px 16px;
}

.meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  margin-bottom: 10px;
}

.meta-line p {
  margin: 0;
}

.meta-strong {
  font-weight: 700;
}

.progress {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.12);
  overflow: hidden;
  margin-top: 8px;
  margin-bottom: 14px;
}

.progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: #bbbbbb;
  opacity: 0.5;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.map-box,
.chart-box {
  position: relative;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.chart-box {
  min-height: 280px;
  padding: 8px;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.map-box {
  min-height: 360px;
  padding: 10px;
}

.map-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.map-toolbar button {
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  border-radius: 10px;
  min-width: 36px;
  height: 36px;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 16px;
  line-height: 1;
}

.map-stage {
  position: relative;
  width: 100%;
  min-height: 300px;
  overflow: hidden;
  border-radius: 12px;
  /*background: transparent;*/
  background-color: rgba(255, 255, 255, 0.7);
  touch-action: none;
  cursor: grab;
}

.map-stage.is-dragging,
.map-stage.is-dragging .election-map,
.map-stage.is-dragging .election-map svg {
  cursor: grabbing;
}

.election-map {
  position: absolute;
  inset: 0;
  cursor: grab;
}

.election-map svg {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  cursor: grab;
}

.election-map [id^="oevk-"] {
  cursor: pointer;
  stroke: var(--map-stroke);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
  pointer-events: auto;
  transition:
    opacity 0.18s ease,
    fill 0.18s ease,
    stroke 0.18s ease,
    stroke-width 0.18s ease,
    filter 0.18s ease;
}

.election-map [id^="oevk-"]:hover {
  stroke: currentColor;
  stroke-width: 1.2;
  filter: brightness(1.04);
}

.election-map [id^="oevk-"].is-selected {
  stroke: var(--selected);
  stroke-width: 3.5;
  filter: brightness(1.06);
}

/* anchor */
html {
  scroll-behavior: smooth;
}

.anchor-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  border-radius: 999px;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
  z-index: 30;
}

.anchor-btn:hover {
  transform: translateY(-1px);
}

.anchor-btn-icon {
  font-size: 16px;
  line-height: 1;
}

.anchor-btn-desktop {
  margin-left: 8px;
}

.mobile-anchor-sticky {
  position: absolute;
  top: 40px;
  right: 10px;
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  padding: 0 12px;
}

.anchor-btn-mobile {
  position: static;
}

@media (min-width: 821px) {
  .anchor-btn-mobile,
  .mobile-anchor-sticky {
    display: none;
  }
}
@media (max-width: 820px) {
  .anchor-btn-desktop {
    display: none;
  }
}
/* note-box */
.note-box {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 16px;
  background: linear-gradient(
    180deg,
    rgba(248, 250, 252, 0.96) 0%,
    rgba(255, 255, 255, 1) 100%
  );
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  color: #1f2937;
}

.note-box table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.note-box tbody {
  display: grid;
  gap: 10px;
}

.note-box tr {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  /* background: #f8fafc; */
  border: 1px solid rgba(148, 163, 184, 0.18);
}
.note-box tr.article {
  display: flex;
}
.note-box tr.article td {
  text-align: left;
}
.note-box td {
  padding: 0;
  border: 0;
  vertical-align: middle;
}

.note-box td:first-child p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: #475569;
}

.note-box td:last-child {
  text-align: right;
}

.note-box td:last-child p {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  color: #0f172a;
}

.note-box-number {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.note-box tr:hover {
  background: #f1f5f9;
  transition: background 0.2s ease;
}

.note-box p:empty {
  display: none;
}
body.dark .note-box span {
  color: #fff;
}
body.dark .note-box tr:hover {
  background: rgba(0, 0, 0, 0.25);
  color: #212121;
  transition: background 0.2s ease;
}
@media (max-width: 820px) {
  .note-box {
    padding: 14px;
    border-radius: 14px;
  }

  .note-box tr {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px;
  }

  .note-box td:last-child {
    text-align: left;
  }

  .note-box td:first-child p {
    font-size: 13px;
  }

  .note-box td:last-child p {
    font-size: 15px;
  }
}
/* note-box end */
#county-borders path {
  fill: transparent;
  stroke: var(--map-stroke);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 12px;
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  flex: 0 0 16px;
}

.control-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.control-row p {
  margin: 0;
  font-size: 13px;
}

select {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

.oevk-name {
  margin: 0 0 8px 0;
  font-size: 18px;
  line-height: 1.25;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
}

.stat p {
  margin: 0 0 4px 0;
  font-size: 12px;
}

.stat strong {
  display: block;
  font-size: 20px;
  line-height: 1.1;
}

.stat strong.small {
  font-size: 16px;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.party-row,
.candidate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 14px;
}

.row-left {
  min-width: 0;
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 7px;
}

.row-top h3,
.row-top h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
  min-width: 0;
  word-break: break-word;
}

.row-left p {
  margin: 0 0 7px 0;
  font-size: 12px;
}

.row-right {
  text-align: right;
  white-space: nowrap;
}

.row-right strong {
  font-size: 16px;
}

.row-right p {
  margin: 2px 0 0 0;
  font-size: 12px;
}

.mini-bar {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.12);
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.note-box {
  margin-top: 14px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 13px;
  line-height: 1.45;
}

.note-box p {
  margin: 0;
}

.note-box-number {
  font-weight: bold;
}

.tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  min-width: 180px;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(17, 22, 31, 0.94);
  color: #fff;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}

.tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip h4 {
  font-size: 13px;
  margin: 0 0 5px 0;
}

.tooltip p {
  margin: 0;
}

.tooltip p + p {
  margin-top: 2px;
}

.error-box {
  padding: 16px;
  border-radius: 16px;
  background: transparent;
  border: 1px solid rgba(179, 38, 30, 0.35);
  color: var(--danger);
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1200px) {
  .election-grid {
    grid-template-columns: 1fr 1fr;
  }

  .col.col-3 {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  /* body { padding: 10px; } */
  body .election-wrap {
    padding: 10px;
  }

  .election-grid {
    grid-template-columns: 1fr;
  }

  .col.col-3 {
    grid-column: auto;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .election-header h1 {
    font-size: 24px;
    padding-top: 30px;
  }

  .map-box {
    min-height: 280px;
  }
  .chart-box {
    min-height: 240px;
  }
  .map-stage {
    min-height: 250px;
  }
}

@media (hover: none), (pointer: coarse) {
  .tooltip {
    max-width: min(280px, calc(100vw - 24px));
    font-size: 13px;
  }
}

.collapsible-card summary {
  list-style: none;
  cursor: pointer;
}

.collapsible-card summary::-webkit-details-marker {
  display: none;
}

.collapsible-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.collapsible-head-text {
  min-width: 0;
}

.collapse-icon {
  margin: 0;
  flex: 0 0 auto;
  font-size: 24px;
  line-height: 1;
}

@media (min-width: 821px) {
  .collapse-icon {
    display: none;
  }
}

.party-chip {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  min-width: 0.8em;
  border-radius: 2px;
  margin-right: 0.45em;
  vertical-align: -0.08em;
  background: currentColor;
  opacity: 0.95;
}

.party-label {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
