:root {
    --obras-green: #078a31;
    --obras-green-dark: #03501d;
    --obras-lime: #d8ff76;
    --obras-ink: #0c1720;
    --obras-slate: #74818d;
    --obras-white: #ffffff;
    --shadow-card: 0 24px 50px rgba(7, 31, 18, 0.12);
    --radius-xl: 24px;
    --radius-lg: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Barlow', sans-serif;
    color: var(--obras-ink);
    background:
        radial-gradient(circle at top left, rgba(216, 255, 118, 0.6), transparent 28%),
        linear-gradient(135deg, #eef5ec 0%, #f9fbf8 45%, #eef7f0 100%);
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

.login-body { min-height: 100vh; }
.login-wrapper { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
    width: min(520px, 100%);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    border-radius: 32px;
    padding: 36px;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(7, 138, 49, 0.12);
}
.login-brand { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.login-logo {
    max-width: 170px;
    max-height: 82px;
    object-fit: contain;
}
.brand-outline, .brand-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.brand-outline {
    color: var(--obras-white);
    background: linear-gradient(135deg, var(--obras-green-dark), var(--obras-green));
    border-radius: 18px;
    padding: 12px 18px;
    box-shadow: 0 12px 24px rgba(7, 138, 49, 0.25);
}
.login-copy h1, .topbar h1, .section-heading h2, .dashboard-hero h2 { margin: 0; font-weight: 800; }
.login-copy p, .topbar p, .dashboard-hero p, .subtle, .login-note, .empty-state { color: var(--obras-slate); }
.login-form { display: grid; gap: 18px; margin-top: 28px; }
.btn-login, .btn-save {
    background: linear-gradient(135deg, var(--obras-green-dark), var(--obras-green));
    color: var(--obras-white);
    border: 0;
    border-radius: 16px;
    padding: 14px 18px;
    font-weight: 700;
}
.btn { touch-action: manipulation; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 300px;
    background: linear-gradient(180deg, rgba(3, 80, 29, 0.98), rgba(12, 23, 32, 0.98));
    color: var(--obras-white);
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    transform: translateX(0);
    transition: transform 0.25s ease;
}
.sidebar-brand, .sidebar-user, .topbar, .section-heading, .party-row, .capture-actions, .dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.sidebar-user {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 14px;
    align-items: center;
}
.user-badge {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--obras-lime);
    color: var(--obras-green-dark);
    font-weight: 800;
}
.sidebar-nav { display: grid; gap: 8px; }
.sidebar-nav a {
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-nav a.active, .sidebar-nav a:hover { background: rgba(216, 255, 118, 0.14); color: var(--obras-white); }
.sidebar-logout { margin-top: auto; }
.main-content { margin-left: 300px; width: calc(100% - 300px); padding: 26px; }
.content-area { overflow: hidden; }
.topbar { margin-bottom: 22px; }
.topbar p { margin: 4px 0 0; }
.app-role-personero .topbar {
    justify-content: flex-start;
    margin-bottom: 12px;
}
.content-area, .filter-card, .tables-card, .capture-card, .info-card {
    background: rgba(255, 255, 255, 0.88);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(12, 23, 32, 0.06);
}
.dashboard-hero {
    padding: 28px;
    background: linear-gradient(135deg, rgba(3, 80, 29, 0.96), rgba(7, 138, 49, 0.9));
    color: var(--obras-white);
    border-radius: 28px;
    margin-bottom: 22px;
}
.app-role-personero .dashboard-hero {
    padding: 20px 22px;
    margin-bottom: 16px;
    border-radius: 22px;
}
.app-role-personero .dashboard-hero h2 {
    font-size: 1.5rem;
    line-height: 1.05;
}
.app-role-personero .dashboard-hero p {
    margin: 6px 0 0;
    font-size: 0.98rem;
}
.app-role-personero .hero-badge {
    padding: 12px 16px;
    min-width: 132px;
}
.app-role-personero .hero-badge strong {
    font-size: 1.7rem;
}
.app-role-personero .tables-card {
    padding: 18px;
}
.app-role-personero .local-table th,
.app-role-personero .local-table td {
    padding: 8px 10px;
}
.dashboard-hero p, .dashboard-hero .eyebrow { color: rgba(255, 255, 255, 0.8); }
.hero-badge { background: rgba(255, 255, 255, 0.12); border-radius: 22px; padding: 16px 20px; text-align: center; }
.hero-badge strong { display: block; font-size: 2rem; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 22px; }
.module-card, .table-chip { text-decoration: none; color: inherit; }
.module-card {
    display: block;
    padding: 22px;
    background: linear-gradient(180deg, #ffffff, #eff8f1);
    border-radius: 22px;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(7, 138, 49, 0.1);
}
.module-index, .party-number {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--obras-lime);
    color: var(--obras-green-dark);
    font-weight: 800;
}
.info-card, .filter-card, .tables-card, .capture-card { padding: 24px; }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--obras-green);
}
.vote-layout { display: grid; gap: 18px; }
.personero-layout { display: grid; gap: 18px; }
.field-layout { display: grid; gap: 18px; }
.readonly-assignment p { margin-bottom: 8px; }
.mesa-item { display: flex; flex-direction: column; align-items: flex-start; }
.filter-grid, .summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.personero-grid { display: grid; grid-template-columns: 1.4fr auto; gap: 14px; align-items: end; }
.personero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.locals-toolbar {
    display: flex;
    gap: 14px;
    align-items: end;
    flex-wrap: wrap;
}
.locals-batch {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}
.locals-batch-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto;
    gap: 14px;
    align-items: end;
}
.local-row-buttons {
    min-width: 56px;
}
.local-row-actions-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}
.icon-add-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    line-height: 1;
}
.locals-search {
    flex: 1 1 320px;
}
.locals-toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.locals-list {
    display: grid;
    gap: 12px;
}
.compact-heading h2 {
    font-size: 1.45rem;
}
.local-table-wrap {
    overflow-x: auto;
}
.local-table {
    margin-bottom: 0;
    font-size: 0.9rem;
    line-height: 1.15;
}
.local-table th,
.local-table td {
    vertical-align: middle;
    padding: 6px 10px;
}
.local-table th {
    font-size: 0.8rem;
    letter-spacing: 0.04em;
}
.local-table td strong {
    font-size: 0.92rem;
    line-height: 1.1;
}
.icon-actions {
    display: inline-flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
}
.icon-actions form {
    margin: 0;
}
.icon-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    font-size: 0.74rem;
    line-height: 1;
}
.pagination-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.pagination-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.pagination-page {
    font-weight: 700;
    color: var(--obras-green-dark);
}
.local-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 18px;
    border: 1px solid rgba(12, 23, 32, 0.08);
    border-radius: 18px;
    background: #fcfffd;
}
.local-card h3 {
    margin: 0 0 8px;
    font-size: 1.2rem;
    font-weight: 800;
}
.local-card p {
    margin: 0 0 6px;
    color: var(--obras-slate);
}
.local-card-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.local-card-actions form {
    margin: 0;
}
.reniec-preview {
    margin-top: 16px;
    border: 1px dashed rgba(7, 138, 49, 0.3);
    border-radius: 16px;
    padding: 16px;
    background: #fbfefb;
}
.reniec-preview strong,
.reniec-preview span { display: block; }
.personero-table-wrap { overflow-x: auto; }
.personero-table { margin-bottom: 0; }
.personero-row-actions { display: flex; gap: 8px; align-items: center; }
.personero-row-actions form { margin: 0; }
.modal-shell[hidden] { display: none !important; }
.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: grid;
    place-items: center;
    padding: 20px;
    isolation: isolate;
    pointer-events: none;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 20, 13, 0.45);
    z-index: 0;
    pointer-events: auto;
}
.modal-card {
    position: relative;
    width: min(760px, 100%);
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    padding: 24px;
    z-index: 1;
    pointer-events: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.modal-card-wide { width: min(1040px, 100%); }
.modal-card-register-votes {
    padding-bottom: 260px;
}
.district-search-wrap { position: relative; }
.district-search-results {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid rgba(12, 23, 32, 0.08);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    max-height: 260px;
    overflow-y: auto;
    z-index: 5;
}
.district-search-results.open { display: block; }
.district-option {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 12px 14px;
}
.district-option:hover { background: #f3f8f4; }
.district-option strong,
.district-option small { display: block; }
.cartel-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.cartel-row { align-items: center; }
.cartel-meta { flex: 1; min-width: 0; }
.cartel-input { max-width: 96px; }
.party-logo-box {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid rgba(12, 23, 32, 0.08);
    padding: 3px;
    flex: 0 0 40px;
}
.party-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.party-logo-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.party-logo-placeholder {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--obras-green-dark);
}
.table-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.mesa-grid-wrap {
    display: grid;
    gap: 10px;
    overflow-x: auto;
}
.mesa-grid-header,
.mesa-grid-row {
    display: grid;
    grid-template-columns: minmax(100px, 120px) repeat(5, minmax(120px, 1fr)) minmax(110px, 140px);
    gap: 10px;
    align-items: center;
}
.mesa-grid-header {
    font-size: 0.84rem;
    font-weight: 800;
    color: var(--obras-green-dark);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 8px;
}
.mesa-grid-row {
    border: 1px solid rgba(12, 23, 32, 0.08);
    border-radius: 18px;
    padding: 12px;
    background: #fcfffd;
}
.mesa-cell { min-width: 0; }
.mesa-status {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
}
.mesa-status.done {
    background: rgba(7, 138, 49, 0.12);
    color: var(--obras-green-dark);
}
.mesa-status.pending {
    background: rgba(116, 129, 141, 0.12);
    color: var(--obras-slate);
}
.table-chip {
    border: 1px solid rgba(7, 138, 49, 0.18);
    background: #f9fcf8;
    border-radius: 16px;
    padding: 14px;
    cursor: pointer;
}
.table-chip.active { background: linear-gradient(135deg, var(--obras-green-dark), var(--obras-green)); color: var(--obras-white); }
.capture-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.party-row {
    border: 1px solid rgba(12, 23, 32, 0.08);
    border-radius: 16px;
    padding: 12px 14px;
    background: #fcfffd;
}
.party-meta { display: flex; align-items: center; gap: 12px; min-width: 0; }
.party-meta strong, .party-meta small { display: block; }
.vote-input { max-width: 120px; text-align: center; font-weight: 700; }
.summary-grid { margin-top: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)) 2fr; }
.rubros-top { grid-template-columns: minmax(120px, 180px) 1fr; }
.rubros-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}
.rubros-head h3 { margin: 4px 0 0; font-size: 1.5rem; font-weight: 800; }
.register-form-header {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #fff;
    isolation: isolate;
    padding-bottom: 12px;
    margin-bottom: 14px;
    box-shadow: none;
}
.register-form-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -14px;
    height: 18px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0));
}
.register-form-summary {
    margin-top: 4px;
    font-size: 0.92rem;
    line-height: 1.35;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--obras-green-dark);
}
.register-form-toolbar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    margin: 0 0 14px;
}
.register-form-toolbar-actions {
    justify-content: space-between;
    width: 100%;
    flex-wrap: nowrap;
}
.register-toolbar-back,
.register-toolbar-close {
    min-height: 46px;
    padding: 0.72rem 1rem;
    border-radius: 14px;
    font-weight: 800;
    border: 1px solid transparent;
}
.register-toolbar-back {
    background: var(--obras-green);
    border-color: var(--obras-green);
    color: #fff;
}
.register-toolbar-back:hover,
.register-toolbar-back:focus {
    background: #0b6930;
    border-color: #0b6930;
    color: #fff;
}
.register-toolbar-close {
    background: #111827;
    border-color: #111827;
    color: #fff;
}
.register-toolbar-close:hover,
.register-toolbar-close:focus {
    background: #000;
    border-color: #000;
    color: #fff;
}
.keypad-target {
    caret-color: transparent;
    cursor: pointer;
    user-select: none;
    scroll-margin-bottom: 320px;
}
.keypad-target.active {
    border-color: var(--obras-green);
    box-shadow: 0 0 0 0.2rem rgba(7, 138, 49, 0.16);
    background: #fbfff5;
}
.keypad-panel {
    display: none;
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(1040px, calc(100vw - 16px));
    z-index: 1085;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), #ffffff 24%);
    border: 1px solid rgba(12, 23, 32, 0.08);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -16px 32px rgba(12, 23, 32, 0.12);
}
.keypad-panel:not([hidden]) {
    display: block;
}
.keypad-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}
.keypad-btn {
    min-height: 48px;
    font-weight: 800;
    border-radius: 14px;
}
.keypad-btn.keypad-action {
    font-size: 0.92rem;
}
.keypad-btn.keypad-zero {
    grid-column: span 3;
}
.rubros-note {
    padding: 12px 16px;
    border-radius: 14px;
    background: #f4f8f5;
    min-height: 48px;
}
.rubros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.rubro-card {
    border: 1px solid rgba(7, 138, 49, 0.16);
    background: linear-gradient(180deg, #ffffff, #eef8f0);
    border-radius: 20px;
    padding: 18px;
    text-align: left;
    min-height: 132px;
    display: grid;
    gap: 12px;
}
.rubro-card strong {
    display: inline-flex;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    background: var(--obras-lime);
    color: var(--obras-green-dark);
    font-size: 1.1rem;
}
.rubro-card span {
    font-weight: 700;
    line-height: 1.3;
}
.rubro-card.secondary {
    background: linear-gradient(180deg, #ffffff, #f4f7f5);
}
.preview-list {
    display: grid;
    gap: 8px;
}
.preview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(12, 23, 32, 0.08);
    background: #fcfffd;
}
.preview-row.total {
    background: #f5f8f6;
}
.preview-row.strong {
    border-color: rgba(7, 138, 49, 0.2);
    font-size: 1rem;
}
.capture-actions { margin-top: 18px; }
.capture-actions .btn { min-height: 48px; }
.personero-register-actions {
    align-items: center;
    margin-bottom: 24px;
}
.personero-register-actions .btn {
    min-width: 240px;
}
.save-status { font-size: 0.95rem; color: var(--obras-slate); }
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1030;
}
.toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1060;
    display: grid;
    gap: 10px;
}
.toast-card { padding: 14px 16px; border-radius: 14px; color: var(--obras-white); box-shadow: var(--shadow-card); }
.toast-success { background: linear-gradient(135deg, #0b6930, #12a045); }
.toast-error { background: linear-gradient(135deg, #861d1d, #b63c3c); }
.table-actions-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.table-actions-inline .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.personero-mesas-table {
    table-layout: fixed;
}
.personero-mesas-table th:nth-child(1),
.personero-mesas-table td:nth-child(1) {
    width: 88px;
}
.personero-mesas-table th:nth-child(3),
.personero-mesas-table td:nth-child(3) {
    width: 250px;
}
.personero-mesas-table .table-actions-inline {
    flex-wrap: nowrap;
    justify-content: flex-end;
}
.personero-mesas-table .table-actions-inline .btn {
    white-space: nowrap;
}
@media (min-width: 768px) {
    .app-role-personero .local-table-wrap {
        overflow-x: visible;
    }
    .app-role-personero .personero-mesas-table {
        table-layout: auto;
    }
}
.form-hint-error {
    margin-top: 6px;
    font-size: 0.82rem;
    line-height: 1.25;
    color: #b42318;
}
.chart-panel {
    position: relative;
    min-height: 420px;
}
@media (max-width: 1199px) {
    .capture-grid { grid-template-columns: 1fr; }
    .filter-grid, .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-panel { min-height: 360px; }
    .mesa-grid-header,
    .mesa-grid-row { min-width: 920px; }
}
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    .main-content { width: 100%; margin-left: 0; padding: 18px; }
    .topbar { align-items: flex-start; }
    .topbar > div:last-child { flex: 1; min-width: 0; }
}
@media (max-width: 767px) {
    .login-wrapper { padding: 14px; }
    .login-card, .filter-card, .tables-card, .capture-card, .info-card, .content-area { padding: 16px; border-radius: 18px; }
    .filter-grid, .summary-grid { grid-template-columns: 1fr; }
    .personero-grid { grid-template-columns: 1fr; }
    .dashboard-hero, .topbar { align-items: flex-start; flex-direction: column; }
    .topbar { gap: 10px; margin-bottom: 16px; }
    .topbar h1 { font-size: 2rem; line-height: 1.05; }
    .topbar p { font-size: 0.95rem; }
    .app-role-personero .topbar {
        margin-bottom: 10px;
    }
    .app-role-personero .main-content {
        padding-top: 10px;
    }
    .app-role-personero .content-area {
        padding-top: 6px;
    }
    .sidebar { width: min(88vw, 320px); padding: 18px 14px; }
    .sidebar-nav a { min-height: 48px; padding: 12px; }
    .brand-pill, .brand-outline { font-size: 0.95rem; letter-spacing: 0.1em; }
    .dashboard-hero { padding: 20px; border-radius: 20px; }
    .dashboard-hero h2 { font-size: 1.7rem; }
    .hero-badge { width: 100%; }
    .app-role-personero .dashboard-hero {
        padding: 16px;
        margin-bottom: 12px;
    }
    .app-role-personero .dashboard-hero h2 {
        font-size: 1.35rem;
    }
    .app-role-personero .dashboard-hero p {
        font-size: 0.92rem;
    }
    .module-grid { grid-template-columns: 1fr; }
    .module-card { padding: 18px; }
    .section-heading { flex-direction: column; align-items: stretch; gap: 10px; }
    .section-heading h2 { font-size: 1.9rem; line-height: 1.05; }
    .app-role-personero .section-heading h2 {
        font-size: 1.55rem;
    }
    .subtle { font-size: 0.92rem; }
    .personero-actions,
    .locals-toolbar,
    .locals-batch-row,
    .locals-toolbar-actions,
    .local-card,
    .local-card-actions,
    .personero-row-actions,
    .capture-actions { flex-direction: column; align-items: stretch; }
    .personero-actions .btn,
    .locals-toolbar-actions .btn,
    .local-row-actions-inline .btn,
    .table-actions-inline .btn,
    .local-card-actions .btn,
    .personero-row-actions .btn,
    .capture-actions .btn,
    .local-card-actions form,
    .local-card-actions form .btn,
    .personero-row-actions form,
    .personero-row-actions form .btn { width: 100%; }
    .local-row-buttons,
    .local-row-actions-inline { width: 100%; }
    .personero-table thead { display: none; }
    .local-table thead { display: none; }
    .personero-table,
    .personero-table tbody,
    .personero-table tr,
    .personero-table td,
    .local-table,
    .local-table tbody,
    .local-table tr,
    .local-table td { display: block; width: 100%; }
    .personero-table tr {
        border: 1px solid rgba(12, 23, 32, 0.08);
        border-radius: 16px;
        padding: 12px;
        margin-bottom: 12px;
        background: #fcfffd;
    }
    .local-table tr {
        border: 1px solid rgba(12, 23, 32, 0.08);
        border-radius: 16px;
        padding: 12px;
        margin-bottom: 12px;
        background: #fcfffd;
    }
    .personero-table td { border: 0; padding: 8px 0; }
    .local-table td { border: 0; padding: 8px 0; text-align: left !important; }
    .app-role-personero .tables-card {
        padding: 14px;
    }
    .personero-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        font-size: 0.78rem;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--obras-green-dark);
    }
    .local-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        font-size: 0.78rem;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--obras-green-dark);
    }
    .icon-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .mesa-grid-wrap { overflow: visible; }
    .mesa-grid-header { display: none; }
    .mesa-grid-row { grid-template-columns: 1fr; gap: 8px; padding: 14px; }
    .mesa-cell { width: 100%; }
    .mesa-cell:not(.mesa-cell--mesa)::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        font-size: 0.76rem;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--obras-green-dark);
    }
    .mesa-cell--mesa { font-size: 1.05rem; }
    .mesa-cell--actions { width: 100%; }
    .mesa-cell--actions.btn { min-height: 46px; }
    .mesa-status { justify-content: flex-start; padding: 10px 12px; }
    .rubros-head { flex-direction: column; align-items: stretch; }
    .register-form-header {
        top: -16px;
        margin: -2px -16px 0;
        padding: 0 16px 12px;
        box-shadow: none;
    }
    .rubros-top { grid-template-columns: 1fr; }
    .register-form-summary {
        font-size: 0.88rem;
    }
    .register-form-toolbar {
        margin: 0 0 12px;
    }
    .register-form-toolbar-actions {
        justify-content: space-between;
        align-items: flex-start;
    }
    .register-form-toolbar-actions .btn {
        width: auto;
    }
    .register-toolbar-back {
        min-height: 40px;
        padding: 0.48rem 0.82rem;
        font-size: 0.92rem;
        border-radius: 12px;
    }
    .register-toolbar-close {
        min-height: 40px;
        padding: 0.48rem 0.92rem;
        font-size: 0.92rem;
        border-radius: 12px;
    }
    .keypad-panel {
        width: calc(100vw - 12px);
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    }
    .rubros-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rubro-card { min-height: 110px; padding: 14px; border-radius: 16px; }
    .rubro-card strong { width: 44px; height: 44px; font-size: 1rem; }
    .modal-shell { padding: 8px; align-items: stretch; }
    .modal-card,
    .modal-card-wide {
        width: 100%;
        max-height: calc(100vh - 16px);
        padding: 16px;
        border-radius: 18px;
    }
    .modal-card-register-votes {
        padding-bottom: 300px;
    }
    .personero-register-actions {
        margin-bottom: 28px;
    }
    .keypad-target {
        scroll-margin-bottom: 360px;
    }
    .modal-card .section-heading h2,
    .modal-card .rubros-head h3 { font-size: 1.8rem; }
    .chart-panel { min-height: 300px; }
    .party-row,
    .cartel-row {
        display: grid;
        grid-template-columns: 1fr 88px;
        gap: 10px;
        align-items: center;
        padding: 10px 12px;
    }
    .party-meta,
    .cartel-meta { min-width: 0; gap: 10px; }
    .party-meta strong { font-size: 0.98rem; line-height: 1.15; }
    .party-meta small { font-size: 0.84rem; }
    .party-number { min-width: 34px; height: 34px; border-radius: 10px; font-size: 0.92rem; }
    .party-logo-box { width: 32px; height: 32px; border-radius: 10px; flex: 0 0 32px; padding: 2px; }
    .cartel-input,
    .vote-input {
        width: 100%;
        max-width: 100%;
        min-height: 44px;
        font-size: 1rem;
    }
    .preview-row { align-items: flex-start; flex-direction: column; gap: 4px; }
    .preview-row strong { font-size: 1rem; }
    .personero-register-actions .btn {
        min-width: 0;
    }
    .pagination-wrap,
    .pagination-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .pagination-controls .btn,
    .pagination-page {
        width: 100%;
        text-align: center;
    }
    .app-role-personero .personero-mesas-heading {
        gap: 14px;
        margin-bottom: 10px;
    }
    .app-role-personero .personero-mesas-heading .btn {
        margin-top: 2px;
    }
    .app-role-personero .personero-mesas-table {
        display: table;
        width: 100%;
        table-layout: fixed;
    }
    .app-role-personero .personero-mesas-table tbody {
        display: table-row-group;
        width: auto;
    }
    .app-role-personero .personero-mesas-table tr {
        display: table-row;
        width: auto;
        border: 0;
        border-radius: 0;
        padding: 0;
        margin-bottom: 0;
        background: transparent;
    }
    .app-role-personero .personero-mesas-table td {
        display: table-cell;
        width: auto;
        border: 0;
        border-bottom: 1px solid rgba(12, 23, 32, 0.08);
        padding: 9px 6px;
        vertical-align: middle;
        white-space: nowrap;
    }
    .app-role-personero .personero-mesas-table td:nth-child(2) {
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.84rem;
    }
    .app-role-personero .personero-mesas-table td::before {
        display: none;
        content: none;
    }
    .app-role-personero .personero-mesas-table .table-actions-inline {
        width: auto;
        gap: 4px;
        flex-wrap: nowrap;
        justify-content: flex-end;
    }
    .app-role-personero .personero-mesas-table .table-actions-inline .btn {
        width: 34px;
        min-width: 34px;
        min-height: 34px;
        padding: 0;
        border-radius: 10px;
        gap: 0;
    }
    .app-role-personero .personero-mesas-table .table-actions-inline .action-text {
        display: none;
    }
    .app-role-personero .personero-mesas-table .table-actions-inline .btn i {
        font-size: 0.92rem;
    }
}
.personero-register-modal {
    max-width: 860px;
}

.personero-photo-preview {
    align-items: center;
    background: #f6faf7;
    border: 1px solid rgba(11, 105, 48, 0.14);
    border-radius: 12px;
    display: flex;
    gap: 12px;
    min-height: 88px;
    padding: 10px;
}

.personero-photo-preview img {
    aspect-ratio: 3 / 4;
    background: #fff;
    border: 1px solid rgba(12, 23, 32, 0.12);
    border-radius: 6px;
    height: 76px;
    object-fit: cover;
    width: 57px;
}

.personero-crop-modal {
    max-width: 620px;
}

.personero-crop-stage {
    aspect-ratio: 16 / 10;
    background: #111827;
    border-radius: 12px;
    cursor: grab;
    overflow: hidden;
    position: relative;
    touch-action: none;
    width: 100%;
}

.personero-crop-stage:active {
    cursor: grabbing;
}

.personero-crop-stage img {
    left: 50%;
    max-width: none;
    position: absolute;
    top: 50%;
    transform-origin: center;
    user-select: none;
    width: 100%;
    height: auto;
    min-width: 100%;
    min-height: 100%;
}

.personero-crop-frame {
    aspect-ratio: 3 / 4;
    border: 2px solid #ffd54a;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.48);
    left: 50%;
    max-height: 86%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(48%, 260px);
}

.personero-crop-frame span {
    background: #ffd54a;
    border: 2px solid #111827;
    height: 16px;
    position: absolute;
    width: 16px;
}

.personero-crop-frame span:nth-child(1) { left: -9px; top: -9px; }
.personero-crop-frame span:nth-child(2) { right: -9px; top: -9px; }
.personero-crop-frame span:nth-child(3) { bottom: -9px; left: -9px; }
.personero-crop-frame span:nth-child(4) { bottom: -9px; right: -9px; }

@media (max-width: 420px) {
    .main-content { padding: 12px; }
    .content-area,
    .filter-card,
    .tables-card,
    .capture-card,
    .info-card {
        padding: 14px;
        border-radius: 16px;
    }
    .topbar h1,
    .section-heading h2 { font-size: 1.7rem; }
    .rubros-grid { grid-template-columns: 1fr; }
    .party-row,
    .cartel-row { grid-template-columns: 1fr 76px; }
    .modal-card,
    .modal-card-wide { padding: 14px; }
    .modal-card-register-votes {
        padding-bottom: 290px;
    }
    .personero-register-actions {
        margin-bottom: 24px;
    }
    .keypad-target {
        scroll-margin-bottom: 340px;
    }
    .register-form-header {
        top: -14px;
        margin: -2px -14px 0;
        padding: 0 14px 10px;
    }
    .keypad-panel {
        width: calc(100vw - 8px);
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    }
    .keypad-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }
    .keypad-btn {
        min-height: 44px;
        font-size: 0.95rem;
    }
}
