@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #14221f;
  --ink-soft: #52645e;
  --paper: #f4f7f2;
  --card: #ffffff;
  --line: #dce6df;
  --green: #166b52;
  --green-dark: #0c4938;
  --green-light: #e5f2eb;
  --lime: #c9e86b;
  --yellow: #f4d76a;
  --red: #bc3f36;
  --red-light: #fff0ed;
  --shadow: 0 16px 50px rgba(20, 50, 40, 0.08);
  --radius-lg: 22px;
  --radius-md: 14px;
  --mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html[data-font-scale="small"] {
  font-size: 15px;
}

html[data-font-scale="large"] {
  font-size: 17px;
}

html[data-font-scale="x-large"] {
  font-size: 18px;
}

#accessibility-bar {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: #eef2ef;
  color: var(--ink);
  font-size: 0.74rem;
}

.accessibility-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1240px, calc(100% - 48px));
  min-height: 38px;
  margin: 0 auto;
  gap: 16px;
}

.accessibility-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.accessibility-label {
  margin-right: 4px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.accessibility-button {
  min-width: 32px;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.accessibility-button:hover,
.accessibility-button[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green-light);
}

.accessibility-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.accessibility-contrast-button {
  padding-inline: 10px;
}

.skip-link {
  position: absolute;
  top: 5px;
  left: -9999px;
  z-index: 100;
  padding: 7px 11px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.skip-link:focus {
  left: 12px;
  outline: 3px solid var(--lime);
  outline-offset: 2px;
}

#main-content:focus {
  outline: 3px solid var(--green);
  outline-offset: 6px;
}

body.high-contrast {
  --ink: #ffffff;
  --ink-soft: #ffffff;
  --paper: #121212;
  --card: #1c1c1c;
  --line: #ffffff;
  --green: #ffff00;
  --green-dark: #ffff00;
  --green-light: #252500;
  --lime: #ffff00;
  --yellow: #ffff00;
  --red: #ff8f8f;
  --red-light: #330000;
  --shadow: none;
  background: #121212;
  color: #ffffff;
}

body.high-contrast #accessibility-bar,
body.high-contrast .site-header {
  border-color: #ffffff;
  background: #121212;
  color: #ffffff;
}

body.high-contrast a {
  color: #ffff00;
  text-decoration: underline;
}

body.high-contrast .brand,
body.high-contrast .accessibility-button,
body.high-contrast .field-label,
body.high-contrast .accessibility-label {
  color: #ffffff;
}

body.high-contrast .brand-mark,
body.high-contrast .office-tab.is-active,
body.high-contrast .primary-button {
  background: #ffff00;
  color: #000000;
}

body.high-contrast .office-tab,
body.high-contrast button,
body.high-contrast input,
body.high-contrast select {
  border-color: #ffffff;
  background: #000000;
  color: #ffffff;
}

body.high-contrast .accessibility-button:hover,
body.high-contrast .accessibility-button[aria-pressed="true"] {
  border-color: #ffff00;
  background: #252500;
  color: #ffffff;
}

body.high-contrast .control-card,
body.high-contrast .summary-card,
body.high-contrast .method-card,
body.high-contrast .candidate-row,
body.high-contrast .legend-row,
body.high-contrast .field-group,
body.high-contrast .base-readout,
body.high-contrast .scenario-panel,
body.high-contrast .history-controls-card,
body.high-contrast .history-summary-card {
  border-color: #ffffff;
  background: #1c1c1c;
  box-shadow: none;
}

body.high-contrast .quota-progress {
  border-color: #ffffff;
  background: #555555;
}

body.high-contrast .quota-progress span {
  background: #ffff00;
}

body.high-contrast input::placeholder {
  color: #ffffff;
  opacity: 1;
}

body.high-contrast .legal-disclaimer {
  border-color: #ffff00;
  background: #252500;
  color: #ffffff;
}

body.high-contrast .skip-link {
  background: #ffff00;
  color: #000000;
}

body.high-contrast .candidate-toolbar {
  background: rgba(18, 18, 18, 0.96);
}

body.high-contrast .field-group,
body.high-contrast .base-readout,
body.high-contrast .empty-state,
body.high-contrast .candidate-row,
body.high-contrast .legend-row,
body.high-contrast .result-card,
body.high-contrast .result-metric,
body.high-contrast .history-table-wrap,
body.high-contrast .history-table,
body.high-contrast .history-controls-card,
body.high-contrast .history-summary-card {
  border-color: #ffffff;
  background: #1c1c1c;
  color: #ffffff;
}

body.high-contrast .candidate-number,
body.high-contrast .lock-icon,
body.high-contrast .empty-icon,
body.high-contrast .method-tag {
  background: #ffff00;
  color: #000000;
}

body.high-contrast .candidate-party,
body.high-contrast .candidate-history,
body.high-contrast .fixed-history,
body.high-contrast .summary-description,
body.high-contrast .quota-total,
body.high-contrast .quota-meta,
body.high-contrast .scenario-panel p,
body.high-contrast .method-card p,
body.high-contrast .footer-inner,
body.high-contrast .empty-state p,
body.high-contrast .result-metric small {
  color: #ffffff;
}

body.high-contrast .vote-percentage,
body.high-contrast .header-badge,
body.high-contrast .section-kicker,
body.high-contrast .eyebrow,
body.high-contrast .fixed-votes-note,
body.high-contrast .scenario-status {
  color: #ffff00;
}

body.high-contrast .whatsapp-button,
body.high-contrast .elected-chip {
  border-color: #ffff00;
  background: #ffff00;
  color: #000000;
}

body.high-contrast .quota-alert,
body.high-contrast .vote-field input.is-blocked,
body.high-contrast .candidate-vote-field input.is-blocked {
  border-color: #ff8f8f;
  background: #330000;
  color: #ff8f8f;
}

body.high-contrast .site-footer {
  border-color: #ffffff;
  background: #121212;
}

body.high-contrast #main-content:focus {
  outline-color: #ffff00;
}

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 89% 6%, rgba(201, 232, 107, 0.17), transparent 28rem),
    var(--paper);
}

html,
body {
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(22, 107, 82, 0.27);
  outline-offset: 2px;
}

.site-header {
  border-bottom: 1px solid rgba(220, 230, 223, 0.86);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(16px);
}

.header-inner,
.page-shell,
.footer-inner {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--green);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: -0.06em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.92rem;
  letter-spacing: -0.02em;
}

.brand small,
.header-badge,
.section-kicker,
.field-label,
.candidate-count,
.loading-state,
.method-tag,
.fixed-votes-note {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-badge {
  color: var(--green);
  font-size: 0.62rem;
}

.page-shell {
  padding: 46px 0 96px;
}

.intro-section {
  max-width: 920px;
  margin-bottom: 24px;
}

.eyebrow,
.section-kicker {
  color: var(--green);
  font-weight: 500;
}

.eyebrow {
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 920px;
  margin-bottom: 14px;
  font-size: clamp(2.35rem, 4.5vw, 4.35rem);
  font-weight: 700;
  letter-spacing: -0.075em;
  line-height: 0.94;
}

.intro-copy {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.45;
}

.control-card,
.summary-card,
.method-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow);
}

.control-card {
  padding: 20px 24px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 {
  margin: 5px 0 0;
  font-size: 1.25rem;
  letter-spacing: -0.045em;
}

.status-dot {
  width: 9px;
  height: 9px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 5px rgba(201, 232, 107, 0.22);
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(240px, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.field-group,
.base-readout {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 66px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fbfdfb;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.61rem;
  font-weight: 500;
}

select,
.search-field input,
.vote-field input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}

select {
  width: 100%;
  padding: 0 12px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--green) 50%), linear-gradient(135deg, var(--green) 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.base-readout strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 500;
}

.base-readout small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.office-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 22px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.office-tab {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink-soft);
  font-size: 0.77rem;
  font-weight: 700;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}

.office-tab:hover {
  border-color: rgba(22, 107, 82, 0.38);
  transform: translateY(-1px);
}

.office-tab.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.tab-number {
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.64rem;
}

.office-tab.is-active .tab-number {
  color: var(--lime);
}

.simulation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 26px;
}

.simulation-main {
  min-width: 0;
}

.results-heading {
  min-height: 55px;
}

.loading-state {
  margin-top: 10px;
  color: var(--green);
  font-size: 0.61rem;
}

.loading-state.is-error {
  color: var(--red);
}

.candidate-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 26px 0 16px;
  padding: 12px 0;
  background: rgba(244, 247, 242, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.search-field {
  position: relative;
  display: block;
  width: min(100%, 430px);
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink-soft);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  transform: translateY(-50%);
}

.search-field input {
  width: 100%;
  padding: 0 14px 0 42px;
}

.candidate-count {
  flex: 0 0 auto;
  font-size: 0.61rem;
}

.candidate-list {
  display: grid;
  gap: 10px;
}

.candidate-row {
  display: grid;
  grid-template-columns: 50px 54px minmax(0, 1fr) minmax(220px, 1.35fr);
  align-items: center;
  gap: 15px;
  min-width: 0;
  max-width: 100%;
  min-height: 88px;
  padding: 15px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  box-sizing: border-box;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.candidate-row:focus-within,
.candidate-row:hover {
  border-color: rgba(22, 107, 82, 0.38);
  box-shadow: 0 8px 26px rgba(20, 50, 40, 0.07);
}

.candidate-number {
  display: grid;
  width: 47px;
  height: 47px;
  place-items: center;
  border-radius: 12px;
  background: var(--green-light);
  color: var(--green-dark);
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 500;
}

.candidate-info {
  min-width: 0;
}

.candidate-name,
.candidate-party {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-name {
  margin-bottom: 5px;
  font-size: 0.93rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.candidate-party {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.63rem;
  text-transform: uppercase;
}

.candidate-vote-field {
  display: grid;
  grid-template-columns: minmax(max-content, 108px) minmax(180px, 1fr);
  grid-template-rows: auto;
  grid-template-areas: "label stack";
  align-items: center;
  justify-self: stretch;
  gap: 3px 9px;
  min-width: 0;
  padding-right: 6px;
}

.candidate-vote-label {
  grid-area: label;
  min-width: max-content;
  overflow: visible;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.61rem;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.candidate-vote-stack {
  display: flex;
  grid-area: stack;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.candidate-vote-field input {
  width: 100%;
  min-width: 120px;
  max-width: 100%;
  padding: 0 11px;
  box-sizing: border-box;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.vote-percentage {
  display: block;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.candidate-history {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vote-field input.is-blocked,
.candidate-vote-field input.is-blocked {
  border-color: var(--red);
  background: var(--red-light);
  color: var(--red);
}

.empty-state {
  display: grid;
  min-height: 250px;
  place-items: center;
  align-content: center;
  padding: 32px;
  border: 1px dashed #cbd9d0;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.5);
  text-align: center;
}

.empty-state strong {
  margin-top: 10px;
  font-size: 0.95rem;
}

.empty-state p {
  max-width: 360px;
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.empty-icon {
  display: grid;
  width: 52px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: var(--green-light);
  color: var(--green);
  font-family: var(--mono);
  letter-spacing: 0.14em;
}

.simulation-sidebar {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 14px;
}

.summary-card {
  padding: 24px;
}

.control-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.control-action-row .secondary-button {
  width: 100%;
}

.summary-card-header,
.quota-meta,
.fixed-votes-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lock-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: var(--green-light);
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.9rem;
  transform: rotate(-25deg);
}

.summary-card h2 {
  margin: 18px 0 6px;
  font-size: 1.55rem;
  letter-spacing: -0.06em;
}

.summary-description {
  margin-bottom: 22px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.quota-total {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.64rem;
  text-transform: uppercase;
}

.quota-total strong {
  color: var(--ink);
  font-size: 1.03rem;
  font-weight: 500;
}

.quota-progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9f0eb;
}

.quota-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease, background 180ms ease;
}

.quota-progress span.is-warning {
  background: var(--yellow);
}

.quota-progress span.is-error {
  background: var(--red);
}

.quota-meta {
  margin-top: 9px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.61rem;
}

.quota-meta strong {
  color: var(--green);
  font-weight: 500;
}

.quota-meta strong.is-error {
  color: var(--red);
}

.quota-alert {
  margin: 16px 0 0;
  padding: 11px 12px;
  border: 1px solid #edc1ba;
  border-radius: 10px;
  background: var(--red-light);
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 700;
}

.fixed-votes {
  display: grid;
  gap: 9px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.fixed-votes-note {
  color: var(--green);
  font-size: 0.55rem;
}

.vote-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 45px;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.vote-field-label {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.fixed-history {
  display: block;
  max-width: 100%;
  margin-top: 2px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.56rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}

.fixed-vote-stack,
.legend-vote-stack {
  display: grid;
  min-width: 98px;
  justify-items: stretch;
  gap: 3px;
}

.fixed-vote-stack {
  flex: 0 0 128px;
}

.vote-field .fixed-vote-stack input {
  width: 128px;
}

.vote-field input {
  flex: 0 0 128px;
  width: 128px;
  padding: 0 10px;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.77rem;
}

.secondary-button {
  width: 100%;
  min-height: 43px;
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 800;
  transition: background 150ms ease, border-color 150ms ease;
}

.secondary-button:hover {
  border-color: rgba(22, 107, 82, 0.38);
  background: var(--green-light);
}

.scenario-panel {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.scenario-panel h3 {
  margin: 10px 0 5px;
  font-size: 0.98rem;
  letter-spacing: -0.03em;
}

.scenario-panel p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.45;
}

.scenario-fields {
  display: grid;
  gap: 7px;
  margin-top: 13px;
}

.scenario-text-input {
  width: 100%;
  min-width: 0;
  min-height: 43px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font-family: var(--sans);
  font-size: 0.72rem;
}

.scenario-text-input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(22, 107, 82, 0.14);
}

.scenario-save-button {
  margin-top: 8px;
}

.scenario-update-button {
  margin-top: 8px;
  border-color: var(--green);
  color: var(--green);
}

.whatsapp-button {
  width: 100%;
  min-height: 43px;
  margin-top: 8px;
  padding: 0 12px;
  border: none;
  border-radius: 10px;
  color: #ffffff;
  background-color: #25D366;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 150ms ease;
}

.whatsapp-button:hover {
  background-color: #128C7E;
}

.whatsapp-button:focus-visible {
  outline: 3px solid rgba(37, 211, 102, 0.32);
  outline-offset: 2px;
}

.scenario-load-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 8px;
}

.scenario-load-row input {
  width: 100%;
  min-width: 0;
  padding: 0 10px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scenario-load-row .secondary-button {
  width: auto;
  min-width: 76px;
  margin-top: 0;
  padding: 0 12px;
}

.scenario-status {
  display: block;
  min-height: 1.2em;
  margin-top: 8px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.6rem;
  line-height: 1.35;
}

.scenario-status.is-error {
  color: var(--red);
}

.method-card {
  padding: 19px 21px;
  box-shadow: none;
}

.method-card p {
  margin: 12px 0 15px;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.method-tag {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--green-light);
  color: var(--green);
  font-size: 0.55rem;
}

.legal-disclaimer {
  margin: 16px 0 0;
  padding: 13px 14px;
  border-left: 4px solid #cc0000;
  border-radius: 0 8px 8px 0;
  background-color: #fff9f9;
  color: #5f2727;
  font-size: 0.8rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: #eaf1eb;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .simulation-layout {
    grid-template-columns: 1fr;
  }

  .simulation-sidebar {
    position: static;
    grid-template-columns: minmax(0, 1fr) minmax(210px, 0.65fr);
  }
}

@media (max-width: 680px) {
  .accessibility-inner,
  .header-inner,
  .page-shell,
  .footer-inner {
    width: min(100% - 30px, 1240px);
  }

  .accessibility-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding: 6px 0;
  }

  .accessibility-controls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .accessibility-label {
    margin-right: auto;
  }

  .page-shell {
    padding: 32px 0 64px;
  }

  .header-inner {
    min-height: 68px;
  }

  .header-badge {
    display: none;
  }

  h1 {
    font-size: clamp(2.25rem, 12vw, 3.4rem);
    line-height: 0.98;
  }

  .control-card {
    padding: 18px;
  }

  .control-grid,
  .simulation-sidebar {
    grid-template-columns: 1fr;
  }

  .office-tabs {
    margin: 16px 0 18px;
  }

  .candidate-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
    padding: 10px 0;
  }

  .search-field {
    width: 100%;
  }

  .candidate-row {
    grid-template-columns: 47px 47px minmax(0, 1fr);
    gap: 12px;
    padding: 13px;
  }

  .candidate-vote-field {
    grid-column: 1 / -1;
    padding-top: 5px;
  }

  .control-action-row {
    grid-template-columns: 1fr;
  }

  .scenario-load-row {
    grid-template-columns: 1fr;
  }

  .scenario-load-row .secondary-button,
  .scenario-update-button,
  .scenario-save-button {
    width: 100%;
  }

  .scenario-load-row .secondary-button {
    width: 100%;
  }

  .candidate-vote-field {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas:
      "label"
      "stack";
    padding-right: 0;
  }

  .fixed-vote-stack,
  .legend-vote-stack {
    min-width: 82px;
  }

  .fixed-vote-stack {
    flex-basis: 112px;
  }

  .vote-field .fixed-vote-stack input {
    width: 112px;
  }

  .legend-vote-stack {
    flex-basis: 82px;
  }

  .legend-row input {
    width: 82px;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    min-height: 88px;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}


/* Motor de resultados */
.legend-votes-panel,
.results-panel {
  margin-top: 22px;
  padding: 23px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow);
}

.legend-heading,
.results-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.legend-heading h3 {
  margin: 5px 0 0;
  font-size: 1.05rem;
  letter-spacing: -0.04em;
}

.legend-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 18px;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 51px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdfb;
}

.legend-party {
  min-width: 0;
}

.legend-party strong,
.legend-party small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-party strong {
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 500;
}

.legend-party small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.68rem;
}

.legend-vote-stack {
  flex: 0 0 98px;
}

.legend-row input {
  width: 98px;
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.vote-input-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

.vote-input-wrapper > input {
  flex: 1 1 auto;
  width: auto !important;
  min-width: 120px;
}

.vote-input-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
}

.clear-single-vote,
.lock-single-vote {
  display: inline-grid;
  width: 24px;
  height: 28px;
  flex: 0 0 24px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.clear-single-vote:hover,
.lock-single-vote:hover {
  border-color: var(--line);
  background: var(--paper);
  color: var(--green-dark);
}

.clear-single-vote:active,
.lock-single-vote:active {
  transform: scale(0.94);
}

.vote-input-wrapper[data-locked="true"] > input {
  border-color: rgba(22, 107, 82, 0.55);
  background: var(--green-light);
}

.vote-input-wrapper[data-locked="true"] .lock-single-vote {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.legend-vote-stack {
  flex: 0 1 178px;
  min-width: 0;
}

.legend-vote-stack .vote-input-wrapper {
  width: 100%;
}

.simulate-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-width: 220px;
  min-height: 48px;
  padding: 0 17px 0 19px;
  border: 0;
  border-radius: 11px;
  background: var(--green);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  transition: background 150ms ease, opacity 150ms ease, transform 150ms ease;
}

.primary-button:not(:disabled):hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.43;
}

.primary-button span:last-child {
  color: var(--lime);
  font-size: 1.12rem;
}

.action-hint {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.6rem;
}

.results-panel-header h2 {
  margin: 5px 0 0;
  font-size: 1.35rem;
  letter-spacing: -0.05em;
}

.results-status {
  max-width: 50%;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--green-light);
  color: var(--green-dark);
  font-family: var(--mono);
  font-size: 0.6rem;
  line-height: 1.35;
  text-align: right;
  text-transform: uppercase;
}

.results-status.is-alert {
  background: var(--red-light);
  color: var(--red);
}

.results-content {
  margin-top: 23px;
}

.result-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.result-metric {
  min-height: 92px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfdfb;
}

.result-metric span,
.result-metric strong {
  display: block;
}

.result-metric span {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.59rem;
  text-transform: uppercase;
}

.result-metric strong {
  margin-top: 8px;
  color: var(--ink-dark);
  font-family: var(--mono);
  font-size: clamp(1.15rem, 2vw, 1.42rem);
  font-weight: 800;
  letter-spacing: -0.045em;
}

.result-metric small {
  display: block;
  margin-top: 5px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.59rem;
  line-height: 1.25;
  text-transform: uppercase;
}

.result-alert {
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid #edc1ba;
  border-radius: 10px;
  background: var(--red-light);
  color: var(--red);
  font-size: 0.79rem;
  font-weight: 700;
}

.result-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 10px;
}

.result-section-title h3 {
  margin: 0;
  font-size: 0.83rem;
  letter-spacing: -0.025em;
}

.result-section-title span {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.59rem;
  text-transform: uppercase;
}

.result-ranking,
.party-result-list {
  display: grid;
  gap: 7px;
}

.ranking-row,
.party-result {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.ranking-row:hover,
.party-result:hover {
  border-color: rgba(22, 107, 82, 0.36);
  box-shadow: 0 6px 18px rgba(20, 50, 40, 0.06);
}

.ranking-row.is-second-round {
  border-color: rgba(171, 199, 45, 0.9);
  border-left: 5px solid var(--lime);
  background: linear-gradient(90deg, #f4f8df 0%, #ffffff 72%);
  box-shadow: 0 7px 20px rgba(116, 138, 27, 0.12);
}

.ranking-position {
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-align: center;
}

.ranking-candidate strong,
.ranking-candidate small,
.party-result-info strong,
.party-result-info small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-candidate,
.party-result-info {
  min-width: 0;
}

.ranking-candidate strong,
.party-result-info strong {
  font-size: 0.77rem;
}

.ranking-candidate small,
.party-result-info small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.65rem;
}

.ranking-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--lime);
  color: var(--ink-dark);
  font-family: var(--mono);
  font-size: 0.54rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.ranking-votes,
.party-seat-summary {
  display: grid;
  min-width: 108px;
  justify-items: stretch;
  gap: 6px;
}

.party-seats {
  color: var(--ink-dark);
  font-family: var(--mono);
  font-size: 0.69rem;
  text-align: right;
}

.party-seat-visual {
  width: 108px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(22, 107, 82, 0.13);
}

.party-seat-visual-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--lime));
  transition: width 240ms ease;
}

.ranking-votes strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.ranking-votes small {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: 0.59rem;
  white-space: nowrap;
}

.party-result {
  grid-template-columns: minmax(0, 1fr) auto;
}

.party-result.is-selected {
  border-color: rgba(22, 107, 82, 0.35);
  background: var(--green-light);
}

.party-result-info small {
  color: var(--green);
  font-family: var(--mono);
  line-height: 1.35;
  text-transform: uppercase;
  white-space: normal;
}

.party-seat-detail {
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 0.67rem;
}

.elected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.second-round-callout {
  margin-bottom: 17px;
  padding: 12px 14px;
  border: 1px solid rgba(171, 199, 45, 0.75);
  border-radius: 10px;
  background: #f6f9e6;
}

.second-round-callout > strong {
  color: var(--ink-dark);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.elected-chip,
.blocked-chip {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.59rem;
}

.elected-chip {
  background: #fff;
  color: var(--green-dark);
}

.second-round-chip {
  border: 1px solid rgba(171, 199, 45, 0.7);
  font-weight: 800;
}

.party-candidate-ranking {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(22, 107, 82, 0.12);
}

.party-candidate-ranking-title {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.56rem;
  text-transform: uppercase;
}

.party-candidate-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.7);
}

.party-candidate-row.is-blocked {
  background: rgba(255, 244, 242, 0.8);
}

.party-candidate-name,
.party-candidate-votes {
  min-width: 0;
}

.party-candidate-name strong,
.party-candidate-name small,
.party-candidate-votes strong,
.party-candidate-votes small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-candidate-name strong {
  font-size: 0.68rem;
}

.party-candidate-name small,
.party-candidate-votes small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.55rem;
}

.party-candidate-votes {
  text-align: right;
}

.party-candidate-votes strong {
  color: var(--ink-dark);
  font-family: var(--mono);
  font-size: 0.65rem;
}

.party-candidate-votes small {
  color: var(--green);
}

.blocked-chip {
  background: var(--red-light);
  color: var(--red);
}

.no-result {
  padding: 16px;
  border: 1px dashed #cbd9d0;
  border-radius: 9px;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

@media (max-width: 680px) {
  .legend-list,
  .result-summary-grid {
    grid-template-columns: 1fr;
  }

  .simulate-action {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }

  .results-status {
    max-width: 100%;
    text-align: left;
  }

  .ranking-row,
  .party-result {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 9px;
  }

  .party-candidate-row {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }

  .party-seat-summary {
    min-width: 76px;
  }

  .party-seat-visual {
    width: 76px;
  }
}


.results-method-note {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.results-disclaimer {
  max-width: 720px;
  margin: 18px auto 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-style: italic;
  line-height: 1.45;
  text-align: center;
}


/* Integração oficial TSE e exportação */
.candidate-avatar {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #cfe0d5;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-dark);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.candidate-avatar img,
.candidate-avatar-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
}

.candidate-avatar img {
  object-fit: cover;
}

.candidate-official {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
}

.candidate-info {
  min-width: 0;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.59rem;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.candidate-link:hover {
  color: var(--green-dark);
  text-decoration: underline;
}

.candidate-link.is-disabled {
  color: var(--ink-soft);
  cursor: not-allowed;
}

.candidate-tse-id {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.56rem;
}

.export-actions {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.export-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.export-heading strong,
.export-heading span {
  display: block;
}

.export-heading strong {
  font-size: 0.78rem;
}

.export-heading span:not(.export-status) {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.67rem;
}

.export-status {
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.59rem;
  text-align: right;
}

.export-status.is-error {
  color: var(--red);
}

.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.secondary-button {
  min-height: 37px;
  padding: 0 13px;
  border: 1px solid #b9cdc1;
  border-radius: 8px;
  background: #fff;
  color: var(--green-dark);
  font-family: var(--mono);
  font-size: 0.63rem;
  font-weight: 700;
  transition: border-color 150ms ease, background 150ms ease, opacity 150ms ease;
}

.secondary-button:not(:disabled):hover {
  border-color: var(--green);
  background: var(--green-light);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

@media (max-width: 680px) {
  .candidate-avatar {
    width: 43px;
    height: 43px;
  }

  .export-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .export-status {
    text-align: left;
  }

  .export-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }

  .secondary-button {
    width: 100%;
  }
}


/* Dashboard histórico 2018 × 2022 */
.history-toggle-button {
  display: block;
  width: 100%;
  min-height: 43px;
  margin-top: 32px;
  padding: 0 16px;
  text-align: left;
}

.historical-dashboard {
  min-width: 0;
  max-width: 100%;
  margin-top: 14px;
  padding: 32px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.history-header {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  justify-content: space-between;
  gap: 24px;
}

.history-header h2 {
  margin: 7px 0 10px;
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  letter-spacing: -0.065em;
  line-height: 1.02;
}

.history-intro {
  max-width: 690px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.history-data-status {
  flex: 0 0 auto;
  margin-top: 7px;
}

.history-tabs {
  display: flex;
  gap: 8px;
  margin: 30px 0 20px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.history-tab,
.history-sort-button {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.history-tab {
  min-height: 42px;
  padding: 0 14px;
}

.history-tab:hover,
.history-sort-button:hover {
  border-color: rgba(22, 107, 82, 0.4);
  color: var(--green-dark);
  transform: translateY(-1px);
}

.history-tab.is-active,
.history-sort-button.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.history-summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.history-summary-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.history-summary-card .field-label {
  margin-bottom: 10px;
}

.history-summary-card strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-summary-card small {
  display: block;
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.67rem;
}

.history-controls-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfb;
}

.history-controls-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(150px, 0.8fr) minmax(180px, 0.9fr) minmax(190px, 1fr);
  gap: 10px;
  align-items: start;
}

.history-control {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.history-control .field-label {
  margin-bottom: 0;
}

.history-control input,
.history-control select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 0.76rem;
}

.history-control input {
  padding-left: 12px;
}

.history-control select[multiple] {
  height: 112px;
  padding: 7px;
  background-image: none;
  font-size: 0.68rem;
}

.history-control select[multiple] option {
  padding: 4px 6px;
  border-radius: 5px;
}

.history-control select[multiple] option:checked {
  background: var(--green);
  color: #fff;
}

.history-control-hint {
  min-height: 1.2em;
  color: var(--ink-soft);
  font-size: 0.62rem;
  line-height: 1.25;
}

.history-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.history-sort-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.history-sort-buttons .field-label {
  width: 100%;
  margin-bottom: 2px;
}

.history-sort-button {
  min-height: 32px;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
}

.history-reset-button {
  width: auto;
  min-width: 126px;
  margin-top: 0;
}

.history-table-wrap {
  display: block;
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.history-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 0.72rem;
}

.history-table th,
.history-table td {
  padding: 12px 13px;
  border-bottom: 1px solid #edf2ee;
  text-align: left;
  vertical-align: middle;
}

.history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f7f2;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.history-table th button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
}

.history-table th button:hover {
  color: var(--green);
}

.history-table tbody tr:last-child td {
  border-bottom: 0;
}

.history-table tbody tr:hover {
  background: #fbfdfb;
}

.history-table .history-number,
.history-table .history-vote,
.history-table .history-variation {
  font-family: var(--mono);
  white-space: nowrap;
}

.history-table .history-number {
  color: var(--green-dark);
  font-weight: 500;
}

.history-table .history-candidate {
  min-width: 200px;
  font-weight: 800;
}

.history-table .history-party {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.64rem;
  text-transform: uppercase;
}

.history-table .history-vote {
  text-align: right;
}

.history-table .history-variation {
  text-align: right;
  font-weight: 700;
}

.history-variation.is-positive {
  color: var(--green);
}

.history-variation.is-negative {
  color: var(--red);
}

.history-variation.is-neutral {
  color: var(--ink-soft);
}

.history-empty-state {
  margin-top: 18px;
  padding: 30px 18px;
  border: 1px dashed #cbd9d0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
  text-align: center;
}

.history-empty-state strong {
  display: block;
  font-size: 0.92rem;
}

.history-empty-state p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
}

.history-page-status {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.63rem;
}

.history-page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.history-page-actions .secondary-button {
  width: auto;
  min-height: 34px;
  min-width: 70px;
  margin-top: 0;
  padding: 0 9px;
  font-size: 0.64rem;
}

.history-page-size select {
  min-height: 34px;
  padding: 0 25px 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background-color: #fff;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.61rem;
}

.history-footnote {
  max-width: 930px;
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 0.66rem;
  line-height: 1.5;
}

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

  .history-search-field,
  .history-party-control {
    grid-column: 1 / -1;
  }

  .history-summary-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .history-toggle-button {
    width: 100%;
    margin-top: 28px;
  }

  .historical-dashboard {
    margin-top: 12px;
    padding: 20px 15px;
    border-radius: var(--radius-md);
  }

  .history-header {
    flex-direction: column;
    gap: 9px;
  }

  .history-data-status {
    margin-top: 0;
  }

  .history-tabs {
    margin-top: 23px;
  }

  .history-controls-grid,
  .history-summary-cards {
    grid-template-columns: 1fr;
  }

  .history-search-field,
  .history-party-control {
    grid-column: auto;
  }

  .history-toolbar,
  .history-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .history-reset-button {
    width: 100%;
  }

  .history-page-actions {
    justify-content: flex-start;
  }

  .history-page-actions .secondary-button {
    flex: 1 1 calc(50% - 6px);
  }

  .history-page-size {
    flex: 1 1 100%;
  }

  .history-page-size select {
    width: 100%;
  }
}


/* Ordenação rápida da lista principal de candidaturas */
.candidate-toolbar {
  align-items: flex-end;
}

.candidate-sort-field {
  display: grid;
  flex: 0 1 270px;
  min-width: 220px;
  gap: 9px;
}

.candidate-sort-field .field-label {
  margin-bottom: 0;
}

.candidate-sort-field select {
  width: 100%;
  min-height: 42px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background-color: #fff;
  color: var(--ink);
  font-size: 0.72rem;
}

.candidate-count {
  margin-bottom: 12px;
}

.candidate-history {
  letter-spacing: -0.02em;
}

@media (max-width: 680px) {
  .candidate-sort-field {
    width: 100%;
    min-width: 0;
    flex-basis: auto;
  }

  .candidate-count {
    margin-bottom: 0;
  }
}


/* Polimento analítico do painel de resultados */
.result-metric-detail {
  color: var(--ink-soft) !important;
  font-size: 0.6rem !important;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none !important;
}

.percentage {
  color: var(--green);
  font-family: var(--mono);
  font-weight: 700;
}

.elected-chip,
.blocked-chip {
  gap: 4px;
  max-width: 100%;
  white-space: normal;
}

.elected-chip .percentage,
.blocked-chip .percentage {
  color: var(--ink-soft);
  font-size: 0.56rem;
  font-weight: 700;
}

.blocked-chip .percentage {
  color: var(--red);
}

@media (max-width: 680px) {
  .result-metric strong {
    font-size: 1.12rem;
  }

  .ranking-votes strong {
    font-size: 0.72rem;
  }

  .ranking-votes small {
    font-size: 0.55rem;
  }

  .ranking-badge {
    margin-top: 4px;
    font-size: 0.5rem;
  }

  .elected-chip,
  .blocked-chip {
    align-items: flex-start;
    line-height: 1.35;
  }
}


@media (max-width: 680px) {
  .legal-disclaimer {
    margin-top: 14px;
    padding: 12px;
    font-size: 0.76rem;
    line-height: 1.5;
  }

  .results-disclaimer {
    margin-top: 16px;
    padding: 0 4px;
    font-size: 0.72rem;
  }
}
