:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #d9e2ec;
  --line-strong: #b7c6d8;
  --text: #17212b;
  --muted: #607184;
  --accent: #0b63ce;
  --accent-2: #14805e;
  --danger: #c93535;
  --shadow: 0 10px 24px rgba(20, 38, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(14px, 3vw, 34px);
  border-bottom: 1px solid #cdd9e6;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(17, 37, 61, 0.06);
  position: sticky;
  top: 0;
  z-index: 3;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 38px);
  letter-spacing: 0;
}

.status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
  flex-wrap: wrap;
}

.quick-select-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.quick-select-label select {
  width: 132px;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(20, 128, 94, 0.14);
}

.dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(201, 53, 53, 0.14);
}

main {
  padding: 16px clamp(10px, 2vw, 24px) 28px;
}

.alert {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #f0cf8a;
  color: #6f4500;
  background: #fff7e6;
  border-radius: 8px;
}

.panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.panel-actions {
  display: grid;
  gap: 8px;
  min-width: 116px;
}

.panel-actions button {
  min-height: 34px;
  padding: 6px 10px;
}

.config-button {
  background: #ffffff;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-body {
  padding: 14px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 12px;
}

.controls-wrap[hidden] {
  display: none;
}

label {
  display: grid;
  gap: 4px;
  color: #405163;
  font-size: 12px;
  font-weight: 700;
}

select,
input,
button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  width: 100%;
}

select:focus,
input:focus,
button:focus {
  outline: 3px solid rgba(11, 99, 206, 0.18);
  border-color: var(--accent);
}

button {
  cursor: pointer;
  background: #eaf2ff;
  color: #084f9f;
  border-color: #b9d3f7;
  font-weight: 800;
}

.wide {
  grid-column: 1 / -1;
}

.municipality-wrap {
  position: relative;
}

.suggestions {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.suggestions[hidden] {
  display: none;
}

.suggestions button {
  min-height: 34px;
  text-align: left;
  color: var(--text);
  background: #ffffff;
  border-color: transparent;
  font-weight: 700;
}

.suggestions button:hover {
  background: #edf5ff;
}

.progress {
  margin: 10px 0 12px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.bar {
  height: 9px;
  border-radius: 999px;
  background: #dbe5ef;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent-2);
}

.candidate {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.candidate-action {
  width: auto;
  min-height: 30px;
  margin-top: 8px;
  padding: 5px 9px;
  font-size: 12px;
}

.rank {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: #eef4fb;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-weight: 900;
  color: #24435f;
}

.candidate-photo {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef4fb;
}

.candidate-name {
  font-weight: 900;
  overflow-wrap: anywhere;
}

.candidate-meta,
.candidate-votes {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.candidate-votes strong {
  color: var(--text);
}

.tools {
  display: flex;
  gap: 8px;
  margin: 8px 0 10px;
}

.tools select {
  max-width: 112px;
}

.expanded {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: auto;
  background: rgba(230, 237, 245, 0.96);
  padding: 18px;
}

.expanded .panel {
  max-width: 1100px;
  margin: 0 auto;
}

.candidate-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(21, 34, 47, 0.42);
}

.candidate-modal[hidden] {
  display: none;
}

.candidate-dialog {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(20, 38, 58, 0.26);
}

.candidate-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.candidate-dialog-header h2 {
  margin: 0;
  font-size: 22px;
}

.candidate-dialog-header button {
  width: auto;
  align-self: flex-start;
}

.candidate-dialog-body {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  padding: 16px;
}

.candidate-dialog-photo {
  width: 96px;
  height: 128px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef4fb;
}

.candidate-dialog dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.candidate-dialog dl div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
}

.candidate-dialog dt {
  color: var(--muted);
  font-weight: 800;
}

.candidate-dialog dd {
  margin: 0;
  font-weight: 700;
}

.candidate-dialog-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
}

.candidate-dialog-actions button {
  flex: 1;
}

@media (max-width: 1050px) {
  .panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .status {
    justify-content: flex-start;
    text-align: left;
  }

  .quick-select-label {
    width: 100%;
    justify-content: space-between;
  }

  .quick-select-label select {
    width: min(180px, 58vw);
  }

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

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

  .progress-info,
  .tools {
    flex-direction: column;
  }

  .tools select {
    max-width: none;
  }

  .candidate-dialog-body,
  .candidate-dialog dl div {
    grid-template-columns: 1fr;
  }

  .candidate-dialog-photo {
    width: 88px;
    height: 118px;
  }
}
