:root {
    --bg: #eef7fb;
    --panel: #ffffff;
    --text: #122736;
    --muted: #5f7382;
    --line: #c8dce8;
    --accent: #00a8df;
    --accent-strong: #0077a6;
    --nav: #053b64;
    --nav-2: #075b8f;
    --danger: #b42318;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: inherit; text-decoration: none; }
input, select, button {
    font: inherit;
}
input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    background: #fff;
}
label {
    display: grid;
    gap: 6px;
    color: #394150;
    font-size: 14px;
}
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}
.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-strong);
}
.topbar {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    background: linear-gradient(90deg, var(--nav), var(--nav-2));
    color: #fff;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
}
.brand img {
    width: 92px;
    height: auto;
    display: block;
}
.topbar nav {
    display: flex;
    gap: 14px;
    align-items: center;
}
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-panel {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
}
.login-panel h1 { margin: 0 0 4px; }
.login-panel p { margin: 0 0 22px; color: var(--muted); }
.login-logo {
    width: 170px;
    max-width: 80%;
    display: block;
    margin-bottom: 18px;
}
.login-logo.centered {
    margin-left: auto;
    margin-right: auto;
}
.compact-logo {
    width: 150px;
}
.centered-auth {
    text-align: center;
}
.centered-auth form {
    text-align: left;
}
.auth-link {
    margin: 16px 0 0;
    text-align: center;
}
.auth-link a {
    color: var(--accent-strong);
    font-weight: 700;
}
.app-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    min-height: calc(100vh - 52px);
}
.single-shell {
    display: block;
    min-height: calc(100vh - 52px);
}
.single-shell .content {
    max-width: none;
}
.sidebar {
    background: #062f4f;
    color: #dfe7ef;
    padding: 16px;
}
.sidebar nav {
    display: grid;
    gap: 6px;
}
.sidebar a {
    padding: 10px 12px;
    border-radius: 6px;
}
.sidebar a.active, .sidebar a:hover {
    background: rgba(255,255,255,.12);
}
.content {
    padding: 24px;
    min-width: 0;
}
.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}
.page-title h1 { margin: 0 0 4px; }
.page-title p { margin: 0; color: var(--muted); }
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 12px;
}
.metric-grid article, .panel, .empty {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}
.metric-grid strong {
    display: block;
    font-size: 28px;
}
.metric-grid span { color: var(--muted); }
.actions-row {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}
.result-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) auto;
    gap: 12px;
    align-items: end;
}
.stack {
    display: grid;
    gap: 12px;
}
.panel h2 {
    margin: 0;
    font-size: 18px;
}
.wide-panel {
    margin-top: 16px;
}
.narrow-panel {
    max-width: 520px;
}
.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 8px;
}
.help-grid span {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    background: #f8fcff;
}
.help-grid strong {
    display: block;
    color: var(--accent-strong);
}
.rules-table, .table-wrap {
    overflow: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    border-bottom: 1px solid var(--line);
    padding: 9px;
    text-align: left;
    vertical-align: top;
}
th {
    background: #eef1f5;
    font-weight: 700;
}
.results-matrix th,
.results-matrix td {
    text-align: right;
}
.results-matrix th:first-child,
.results-matrix td:first-child {
    text-align: left;
    min-width: 260px;
}
.results-matrix td strong {
    display: block;
}
.result-cell {
    display: grid;
    grid-template-columns: minmax(74px, auto) minmax(74px, auto);
    gap: 8px;
    justify-content: end;
    align-items: center;
}
.result-votes,
.result-percent {
    display: inline-flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 28px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #f8fcff;
    font-variant-numeric: tabular-nums;
}
.result-votes {
    color: var(--text);
    font-weight: 700;
    border-right: 2px solid var(--accent);
}
.result-percent {
    color: var(--muted);
    background: #ffffff;
}
.result-cell.compact {
    grid-template-columns: minmax(42px, auto) minmax(54px, auto);
    gap: 4px;
}
.result-cell.compact .result-votes,
.result-cell.compact .result-percent {
    min-height: 22px;
    padding: 2px 5px;
    font-size: 13px;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.dashboard-panel {
    padding: 12px;
}
.compact-results .page-title {
    margin-bottom: 12px;
}
.compact-metrics {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
}
.compact-metrics article {
    padding: 12px;
}
.compact-metrics strong {
    font-size: 22px;
}
.compact-table th,
.compact-table td {
    padding: 5px 7px;
    font-size: 13px;
}
.compact-table th:first-child,
.compact-table td:first-child {
    min-width: 190px;
}
.check {
    display: flex;
    align-items: center;
    gap: 8px;
}
.check input {
    width: auto;
}
.alert {
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 14px;
}
.alert.ok { background: #e8f6ef; color: #14532d; }
.alert.error { background: #fee4e2; color: var(--danger); }
.danger {
    color: #fff;
    background: var(--danger);
    border-color: #8f1d14;
}
.danger-zone {
    border-color: #f0a6a0;
    background: #fffafa;
}
.load-header {
    display: grid;
    grid-template-columns: 120px repeat(2, minmax(180px, 1fr));
    gap: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}
.fixed-field {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fcff;
    padding: 8px 10px;
}
.fixed-field span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}
.fixed-field strong {
    display: block;
    font-size: 22px;
    line-height: 1.1;
}
.mesa-check {
    display: grid;
    grid-template-columns: minmax(160px, 240px) auto;
    gap: 10px;
    align-items: end;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}
.mesa-check input {
    font-size: 24px;
    font-weight: 700;
}
.padron-search {
    display: grid;
    grid-template-columns: minmax(220px, 340px) auto;
    gap: 10px;
    align-items: end;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}
.padron-search input {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.registry-total {
    display: grid;
    text-align: right;
}
.registry-total strong {
    font-size: 24px;
}
.registry-total span,
.padron-result-title span,
.padron-result-grid span {
    color: var(--muted);
}
.padron-result-title {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 18px;
    align-items: end;
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
}
.padron-result-title strong {
    display: block;
    font-size: 36px;
    line-height: 1;
}
.padron-result-title h2 {
    margin: 3px 0 0;
    font-size: 22px;
}
.padron-result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
}
.padron-result-grid article {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fcff;
    padding: 10px;
}
.padron-result-grid span,
.padron-result-grid strong {
    display: block;
}
.padron-results-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin: 18px 0 10px;
}
.padron-results-heading h2 { margin: 0; }
.padron-results-heading span { color: var(--muted); }
.padron-results {
    display: grid;
    gap: 14px;
}
.padron-match {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.padron-match-head {
    display: grid;
    grid-template-columns: 135px 150px minmax(260px, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: #f8fcff;
}
.padron-logo {
    display: block;
    width: 125px;
    height: auto;
}
.padron-mesa span,
.padron-person span {
    display: block;
    color: var(--muted);
    font-weight: 700;
}
.padron-mesa strong {
    display: block;
    margin-top: 2px;
    font-size: 42px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.padron-person h2 {
    margin: 3px 0 0;
    font-size: 24px;
}
.whatsapp-share {
    white-space: nowrap;
    background: #167d45;
    border-color: #167d45;
    color: #fff;
}
.padron-data {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0;
    margin: 0;
    padding: 8px 18px 16px;
}
.padron-data div {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 8px;
    padding: 10px 12px 10px 0;
    border-bottom: 1px solid #e7eef3;
}
.padron-data dt { color: var(--muted); }
.padron-data dd {
    margin: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.mini-list {
    display: grid;
    gap: 8px;
}
.mini-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
    background: #f8fcff;
}
.entry-table {
    table-layout: fixed;
    min-width: 760px;
}
.entry-table .entry-col-number { width: 58px; }
.entry-table .entry-col-party { width: auto; }
.entry-table .entry-col-votes { width: 150px; }
.entry-table th:nth-child(n+3),
.entry-table td:nth-child(n+3) {
    text-align: center;
    vertical-align: middle;
    border-left: 1px solid var(--line);
}
.entry-table td {
    height: 58px;
}
.entry-table .vote-input,
.entry-table .disabled-vote-box {
    width: 96px;
    height: 42px;
}
.entry-table .vote-input {
    display: inline-block;
    min-width: 0;
    padding: 7px 9px;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
}
.entry-table td.disabled-vote-cell {
    text-align: center;
    background: transparent;
}
.entry-table .disabled-vote-box {
    display: inline-block;
    vertical-align: middle;
    border: 1px solid #111111;
    border-radius: 6px;
    background: #111111;
}
.numeric-input {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.entry-table .special td {
    background: #fbfbfc;
    font-weight: 700;
}
.muted { color: var(--muted); }
.fiscal-public {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 14px;
    background: #eef7fb;
}
.fiscal-card {
    width: min(100%, 680px);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 40px rgba(18, 39, 54, .1);
}
.fiscal-logo { display: block; width: 210px; height: auto; margin: 0 auto 16px; }
.fiscal-title { text-align: center; margin-bottom: 20px; }
.fiscal-title h1 { margin: 0; font-size: 30px; }
.fiscal-title p { margin: 5px 0 0; color: var(--muted); }
.fiscal-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    margin: 0 0 22px;
    padding: 0;
    list-style: none;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}
.fiscal-steps li { padding: 10px 6px; text-align: center; background: #f6f9fb; color: var(--muted); font-weight: 700; }
.fiscal-steps li.active { background: #dff4fc; color: #0077a6; }
.fiscal-steps li.done { background: #e6f5ec; color: #146b3a; }
.fiscal-name-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fiscal-contact-grid { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; }
.form-note { margin: -2px 0 4px; color: var(--muted); font-size: 14px; }
.form-note.warning { color: #7b5700; }
.verified-contact { display: grid; gap: 3px; padding: 13px; margin-bottom: 14px; border: 1px solid #9fd5b6; border-radius: 6px; background: #edf9f2; }
.verified-contact.pending { border-color: #b9d9e8; background: #f1f9fc; }
.verified-contact span, .verified-contact small { color: var(--muted); }
.verified-contact strong { overflow-wrap: anywhere; }
.otp-form { display: grid; grid-template-columns: minmax(190px, 1fr) auto; gap: 12px; align-items: end; }
.otp-input { font-size: 26px; font-weight: 700; letter-spacing: 4px; font-variant-numeric: tabular-nums; }
.resend-form { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.resend-form span { color: var(--muted); font-size: 13px; }
.change-phone-form { margin-top: 10px; }
.fiscal-success { padding: 24px; margin-bottom: 14px; text-align: center; border: 1px solid #9fd5b6; border-radius: 6px; background: #edf9f2; }
.fiscal-success strong { display: block; font-size: 25px; color: #146b3a; }
.fiscal-metrics { margin-bottom: 14px; }
.fiscal-import-panel { margin-bottom: 14px; }
.fiscal-import-panel h2 { margin: 0; }
.import-inline { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 12px; align-items: end; }
.dni-inline-form { display: grid; grid-template-columns: 110px auto; gap: 6px; align-items: center; }
.dni-inline-form input { min-width: 0; padding: 7px; }
.dni-inline-form .button { padding: 7px 9px; }
.fiscal-delete-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.fiscal-delete-toolbar form { display: flex; gap: 8px; }
.fiscal-delete-toolbar span { color: var(--muted); font-size: 13px; }
.select-column { width: 38px; text-align: center; }
.button.danger { color: #fff; border-color: #b42331; background: #b42331; }
.button.danger-outline { color: #9c1c2a; border-color: #d9a6ac; background: #fff; }
.delete-one-fiscal-form { margin: 0; }
.user-edit-actions, .user-row-actions { display: flex; align-items: center; gap: 8px; }
.user-edit-actions { align-self: end; }
.user-row-actions form { margin: 0; }
.ballot-results-panel { overflow: hidden; }
.ballot-result-editor { display: grid; }
.ballot-result-head, .ballot-result-row { display: grid; grid-template-columns: minmax(300px, 1fr) 72px 100px 72px 88px 88px; gap: 10px; align-items: center; }
.ballot-result-head { padding: 8px 10px; background: #eef1f5; font-size: 13px; font-weight: 700; }
.ballot-result-row { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.ballot-result-row:last-child { border-bottom: 0; }
.ballot-result-row label { margin: 0; }
.ballot-result-row input { min-height: 38px; padding: 6px 8px; }
.ballot-result-row input[type="color"] { width: 58px; height: 38px; padding: 3px; }
.ballot-result-row button { min-height: 38px; padding: 6px 10px; }
.ballot-result-name { min-width: 0; overflow-wrap: anywhere; }
.ballot-highlight-check { justify-content: center; font-size: 13px; }
.mobile-field-label { display: none; }
.loader-contact { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; }
.loader-contact div { padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; background: #f8fcff; }
.loader-contact span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; }
.highlighted-vote-row { background: color-mix(in srgb, var(--list-highlight) 12%, white); }
.highlighted-vote-row td:first-child { border-left: 6px solid var(--list-highlight); font-weight: 700; }
.clickable-table-row { cursor: pointer; }
.clickable-table-row:hover, .clickable-table-row:focus { background: #edf8fc; outline: none; }
.mesa-number-link { display: inline-block; min-width: 64px; font-size: 20px; font-weight: 800; color: var(--accent-strong); }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pagination a, .pagination span { min-width: 36px; padding: 7px 9px; text-align: center; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.pagination .active { color: #fff; border-color: var(--accent-strong); background: var(--accent-strong); font-weight: 700; }
.pagination .ellipsis { border-color: transparent; background: transparent; }
.result-name { display: inline-flex; align-items: center; gap: 9px; }
.result-color { display: inline-block; width: 10px; height: 28px; flex: 0 0 10px; border-radius: 2px; border: 1px solid rgba(0, 0, 0, .12); }
.status-text { font-size: 12px; font-weight: 700; }
.status-text.ok { color: #146b3a; }
.status-text.pending { color: #8a6400; }
.status-badge { display: inline-block; padding: 5px 8px; border-radius: 5px; font-size: 12px; font-weight: 700; }
.status-badge.ok { color: #146b3a; background: #e6f5ec; }
.status-badge.warning { color: #714f00; background: #fff4d6; }
.status-badge.pending { color: #7a3940; background: #fdebed; }
@media (max-width: 800px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .sidebar nav { grid-template-columns: repeat(5, 1fr); }
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .load-header, .mesa-check, .padron-search, .padron-result-title, .padron-match-head { grid-template-columns: 1fr; }
    .padron-match-head { gap: 10px; }
    .padron-logo { width: 145px; margin-inline: auto; }
    .padron-mesa, .padron-person { text-align: center; }
    .padron-mesa strong { font-size: 48px; }
    .whatsapp-share { width: 100%; }
    .padron-results-heading { display: grid; }
    .brand img { width: 74px; }
    .fiscal-card { padding: 20px 16px; }
    .fiscal-name-grid, .fiscal-contact-grid, .otp-form, .import-inline { grid-template-columns: 1fr; }
    .resend-form { align-items: stretch; flex-direction: column; }
    .fiscal-delete-toolbar { align-items: stretch; flex-direction: column; }
    .fiscal-delete-toolbar form { display: grid; grid-template-columns: 1fr 1fr; }
    .ballot-result-head { display: none; }
    .ballot-result-row { grid-template-columns: 72px minmax(100px, 1fr) 72px 1fr 1fr; padding: 12px 0; }
    .ballot-result-name { grid-column: 1 / -1; }
    .mobile-field-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
    .loader-contact { grid-template-columns: 1fr; }
}
