:root {
  color-scheme: dark;
  --bg: #07080d;
  --panel: #10131c;
  --panel-2: #171b27;
  --ink: #f8fafc;
  --muted: #aeb7c8;
  --line: #2d3444;
  --soft: #202637;
  --green: #35d07f;
  --green-dark: #16845b;
  --red: #ef4444;
  --red-soft: #30161b;
  --violet: #a78bfa;
  --rose: #f43f8f;
  --gold: #f59e0b;
  --gray: #9ca3af;
}

* {
  box-sizing: border-box;
}

body {
  background:
    linear-gradient(180deg, rgba(18, 24, 38, 0.92), rgba(7, 8, 13, 0.98) 360px),
    radial-gradient(circle at 12% 0%, rgba(53, 208, 127, 0.18), transparent 26%),
    radial-gradient(circle at 55% 0%, rgba(244, 63, 143, 0.16), transparent 26%),
    radial-gradient(circle at 100% 0%, rgba(167, 139, 250, 0.16), transparent 26%),
    var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
}

button,
input {
  font: inherit;
}

button,
.file-button {
  align-items: center;
  background: linear-gradient(135deg, #16845b, #35d07f);
  border: 1px solid var(--green);
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
}

button:hover,
.file-button:hover {
  background: var(--green-dark);
}

button.secondary,
.file-button {
  background: #111119;
  border-color: var(--line);
  color: #f8fafc;
}

button.secondary:hover,
.file-button:hover {
  background: var(--soft);
}

button.danger {
  background: var(--red-soft);
  border-color: #7f1d1d;
  color: #fecaca;
}

button.danger:hover {
  background: #fee4e2;
}

.file-button input {
  display: none;
}

.app-header {
  align-items: center;
  background: rgba(7, 8, 13, 0.94);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.38);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px clamp(16px, 3vw, 34px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header::before {
  background: linear-gradient(90deg, #35d07f, #7c2d12, #f43f8f, #ef4444, #a78bfa, #9ca3af);
  bottom: -1px;
  content: "";
  height: 3px;
  left: 0;
  position: absolute;
  right: 0;
}

.title-block {
  display: grid;
  gap: 5px;
}

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

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

h1 {
  font-size: clamp(22px, 2.8vw, 34px);
  line-height: 1.1;
  margin-bottom: 0;
  text-shadow: 0 0 24px rgba(244, 63, 143, 0.25);
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-line span {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  color: #d9dee9;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

h2 {
  font-size: 20px;
  margin-bottom: 0;
}

h3 {
  font-size: 16px;
  margin-bottom: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.page {
  display: grid;
  gap: 18px;
  padding: 18px clamp(16px, 3vw, 34px) 34px;
}

.workbench {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(500px, 34vw);
}

.summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary div,
.sheet-block,
.results {
  background: rgba(16, 19, 28, 0.95);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}

.summary div {
  border-top: 4px solid var(--green);
  min-height: 82px;
  padding: 14px;
}

.summary div:nth-child(2) {
  border-top-color: var(--rose);
}

.summary div:nth-child(3) {
  border-top-color: var(--violet);
}

.summary div:nth-child(4) {
  border-top-color: var(--gold);
}

.summary span,
.section-title span,
.totals-list span,
.chart-label,
.chart-value {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary strong {
  display: block;
  font-size: 28px;
  margin-top: 8px;
  color: #ffffff;
}

.section-title {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 66px;
  padding: 14px 16px;
}

.section-kicker {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.table-scroll {
  background:
    linear-gradient(#0c0c13, #0c0c13) padding-box,
    repeating-linear-gradient(90deg, #343446 0, #343446 1px, transparent 1px, transparent 80px);
  overflow: auto;
  width: 100%;
}

.load-status {
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  color: #9a3412;
  font-weight: 800;
  padding: 12px 14px;
}

.load-status.is-hidden {
  display: none;
}

.data-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1700px;
  table-layout: fixed;
  width: 100%;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #3f3f52;
  border-right: 1px solid #3f3f52;
  padding: 5px;
  vertical-align: middle;
}

.data-table th {
  background: #161b28;
  color: #d7dbe6;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  position: sticky;
  text-align: center;
  top: 0;
  z-index: 2;
}

.data-table th.group {
  color: #fff;
  font-size: 13px;
}

.data-table th.provincial-group {
  background: linear-gradient(90deg, #16845b, #35d07f, #f43f8f);
}

.data-table th.seccional-group {
  background: linear-gradient(90deg, #f59e0b, #ef4444, #a78bfa);
}

.data-table th:first-child,
.data-table td:first-child {
  border-left: 1px solid #3f3f52;
  left: 0;
  position: sticky;
  text-align: center;
  width: 92px;
  z-index: 3;
}

.data-table th:first-child {
  background: #1d2638;
}

.data-table td:first-child {
  background: #151b28;
  color: #ffffff;
  font-weight: 900;
}

.data-table tbody tr:nth-child(even) td {
  background: #0f1420;
}

.data-table tbody tr:nth-child(even) td:first-child {
  background: #1b2232;
}

.data-table tfoot td {
  background: #173322;
  color: #b9ffd6;
  font-size: 15px;
  font-weight: 900;
  position: sticky;
  bottom: 0;
  z-index: 4;
}

.data-table input {
  background: #050509;
  border: 1px solid #4b5563;
  border-radius: 3px;
  color: #ffffff;
  font-weight: 800;
  min-height: 32px;
  padding: 5px 7px;
  text-align: right;
  width: 100%;
}

.data-table input:hover {
  background: #161621;
}

.data-table input:focus {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(53, 208, 127, 0.35);
  outline: 3px solid rgba(53, 208, 127, 0.15);
}

.row-total {
  background: #1b1b28;
  color: #e5e7eb;
  font-weight: 900;
  text-align: right;
}

.mesa-col {
  width: 92px;
}

.padron-col,
.total-col {
  width: 88px;
}

.vote-col {
  width: 108px;
}

.results {
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding-bottom: 16px;
  position: sticky;
  top: 96px;
}

.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 16px;
  padding: 14px;
  background: rgba(7, 8, 13, 0.5);
}

.result-panel h3 {
  align-items: center;
  display: flex;
  gap: 8px;
}

.result-panel h3::before {
  background: linear-gradient(135deg, var(--green), var(--rose));
  border-radius: 50%;
  content: "";
  height: 10px;
  width: 10px;
}

.result-panel + .result-panel {
  margin-top: 0;
}

.totals-list {
  border-top: 1px solid var(--line);
  margin-bottom: 18px;
}

.total-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 104px;
  padding: 9px 0;
}

.total-row.is-leading {
  background: linear-gradient(90deg, rgba(53, 208, 127, 0.22), rgba(244, 63, 143, 0.12));
  border: 1px solid rgba(53, 208, 127, 0.48);
  box-shadow: 0 0 24px rgba(53, 208, 127, 0.12);
  padding: 10px 9px;
}

.total-row.is-leading span::before {
  color: var(--green);
  content: "1° ";
  font-weight: 900;
}

.total-row strong {
  font-size: 17px;
  text-align: right;
}

.pie-chart {
  align-items: center;
  display: grid;
  gap: 18px;
  grid-template-columns: 158px minmax(0, 1fr);
}

.pie {
  align-items: center;
  aspect-ratio: 1;
  border: 1px solid #3f3f52;
  border-radius: 50%;
  box-shadow: 0 0 34px rgba(244, 63, 143, 0.18);
  display: grid;
  justify-items: center;
  position: relative;
}

.pie::after {
  background: #0b0b12;
  border: 1px solid #343446;
  border-radius: 50%;
  content: "";
  height: 58%;
  position: absolute;
  width: 58%;
}

.pie span {
  color: #ffffff;
  font-size: 18px;
  font-weight: 900;
  position: relative;
  z-index: 1;
}

.pie-legend {
  display: grid;
  gap: 8px;
}

.legend-row {
  align-items: center;
  border-radius: 7px;
  display: grid;
  gap: 8px;
  grid-template-columns: 12px minmax(0, 1fr) 92px;
  padding: 4px 0;
}

.legend-row.is-leading {
  background: rgba(53, 208, 127, 0.14);
  border: 1px solid rgba(53, 208, 127, 0.38);
  grid-template-columns: 12px minmax(0, 1fr) 92px;
  padding: 7px;
}

.legend-row.is-leading .legend-label {
  color: #ffffff;
}

.legend-row.is-leading .legend-label::before {
  color: var(--green);
  content: "GANANDO · ";
  font-weight: 900;
}

.legend-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
}

.legend-row strong {
  color: #ffffff;
  font-size: 12px;
  text-align: right;
}

.swatch {
  border-radius: 50%;
  height: 12px;
  width: 12px;
}

@media (max-width: 980px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

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

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

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

  .results {
    max-height: none;
    position: static;
  }
}

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

  button,
  .file-button {
    flex: 1 1 auto;
  }
}
