:root {
    --bg: #f7f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --success: #166534;
    --warning: #92400e;
    --danger: #991b1b;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: #111827;
    color: white;
    flex-wrap: wrap;
}
.topbar a { color: white; }
.brand a {
    font-weight: 800;
    font-size: 1.1rem;
}
.navlinks {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.5rem;
}
.narrow {
    max-width: 780px;
}
.hero {
    margin-bottom: 1rem;
}
.page-header {
    margin-bottom: 1rem;
}
.cards, .grid-2, .grid-3 {
    display: grid;
    gap: 1rem;
}
.cards {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 1rem;
}
.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    margin-bottom: 1rem;
}
.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.card, .login-card, .receipt, .card-light {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem 1.2rem;
    box-shadow: 0 10px 30px rgba(17, 24, 39, 0.04);
}
.card { margin-bottom: 1rem; }
.card-light {
    background: #f9fafb;
    margin-top: 0.75rem;
}
.list-item {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
}
.list-item:first-of-type {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}
.list-item.compact {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}
.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}
.title-line {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}
.meta {
    font-size: 0.92rem;
    color: var(--muted);
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.muted {
    color: var(--muted);
}
.badge {
    display: inline-flex;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: #e0e7ff;
    color: #312e81;
    font-size: 0.85rem;
    font-weight: 700;
}
.badge.highlight {
    background: #dbeafe;
    color: #1e3a8a;
}
.form-stack {
    display: grid;
    gap: 0.85rem;
}
.inline-form {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    flex-wrap: wrap;
}
label {
    display: grid;
    gap: 0.35rem;
    font-weight: 600;
}
.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
input, textarea, select {
    width: 100%;
    padding: 0.75rem 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font: inherit;
    background: white;
}
textarea {
    resize: vertical;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: none;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
    text-decoration: none;
}
.btn-light, .btn-link {
    background: #eef2ff;
    color: #312e81;
}
.btn-link {
    padding: 0.5rem 0.75rem;
}
.flash {
    border-radius: 12px;
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}
.flash.ok {
    background: #dcfce7;
    color: var(--success);
}
.flash.warn {
    background: #fef3c7;
    color: var(--warning);
}
.flash.err {
    background: #fee2e2;
    color: var(--danger);
}
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}
.login-card {
    width: 100%;
    max-width: 520px;
}
.info-box {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    background: #eff6ff;
    border-radius: 12px;
    color: #1e3a8a;
}
.receipt-body {
    background: #ffffff;
}
.receipt {
    max-width: 940px;
    margin: 2rem auto;
}
.receipt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.receipt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.receipt-grid > div {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem;
}
@media (max-width: 900px) {
    .nav-user, .navlinks, .topbar {
        width: 100%;
    }
}
@media print {
    .receipt-actions, .topbar {
        display: none !important;
    }
    body {
        background: #fff;
    }
    .receipt {
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 0;
    }
}
.table-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-top: 0.75rem;
    border-radius: 16px;
}

.payments-table {
    width: max-content;
    min-width: 1350px;
    border-collapse: separate;
    border-spacing: 0;
}

.payments-table th,
.payments-table td {
    padding: 10px 12px;
    vertical-align: top;
    line-height: 1.35;
    font-size: 0.95rem;
}

.payments-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    white-space: nowrap;
}

/* Columnas cortas: que no se rompan */
.payments-table th:nth-child(1),
.payments-table td:nth-child(1),
.payments-table th:nth-child(2),
.payments-table td:nth-child(2),
.payments-table th:nth-child(3),
.payments-table td:nth-child(3),
.payments-table th:nth-child(6),
.payments-table td:nth-child(6),
.payments-table th:nth-child(8),
.payments-table td:nth-child(8),
.payments-table th:nth-child(9),
.payments-table td:nth-child(9),
.payments-table th:nth-child(10),
.payments-table td:nth-child(10),
.payments-table th:nth-child(11),
.payments-table td:nth-child(11),
.payments-table th:nth-child(12),
.payments-table td:nth-child(12) {
    white-space: nowrap;
}

/* Vecino */
.payments-table th:nth-child(5),
.payments-table td:nth-child(5) {
    min-width: 240px;
}

/* Concepto */
.payments-table th:nth-child(7),
.payments-table td:nth-child(7) {
    min-width: 220px;
}

/* Detalle */
.payments-table th:nth-child(1),
.payments-table td:nth-child(1) {
    min-width: 90px;
}

/* Estado */
.payments-table th:nth-child(2),
.payments-table td:nth-child(2) {
    min-width: 95px;
}

/* Unidad */
.payments-table th:nth-child(3),
.payments-table td:nth-child(3) {
    min-width: 85px;
}

/* Teléfono */
.payments-table th:nth-child(6),
.payments-table td:nth-child(6) {
    min-width: 110px;
}

/* Referencia / recibo (columna 11) */
.payments-table th:nth-child(11),
.payments-table td:nth-child(11) {
    min-width: 180px;
}

/* Acciones (columna 12, boton borrar pendiente) */
.payments-table th:nth-child(12),
.payments-table td:nth-child(12) {
    min-width: 110px;
    text-align: center;
    white-space: nowrap;
}

/* Boton de borrar: compartido por resultados y emision */
.btn-delete {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.btn-delete:hover {
    background: #fecaca;
    text-decoration: none;
}
.btn-delete svg {
    flex: none;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Tabla de recibos pendientes en la vista de emision */
.emission-pending-table {
    width: 100%;
    min-width: 880px;
    border-collapse: collapse;
    margin-top: 0.75rem;
}
.emission-pending-table th,
.emission-pending-table td {
    padding: 0.75rem 0.7rem;
    border-top: 1px solid var(--border);
    vertical-align: top;
    font-size: 0.92rem;
}
.emission-pending-table thead th {
    border-top: none;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.emission-pending-table th:last-child,
.emission-pending-table td:last-child {
    text-align: center;
    white-space: nowrap;
}
.emission-pending-table td .muted {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.85rem;
}

.payments-table td small,
.payments-table td .muted,
.payments-table td .subtext {
    display: block;
    margin-top: 0.2rem;
    line-height: 1.3;
}

@media (max-width: 1400px) {
    .payments-table th,
    .payments-table td {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
}


.grid-4 {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 1rem;
}

.grid-span-2 {
    grid-column: span 2;
}

.button-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.button-row.compact {
    gap: 0.5rem;
}

.inline-form {
    display: inline;
    margin: 0;
}

.btn-small {
    padding: 0.45rem 0.7rem;
    font-size: 0.86rem;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fecaca;
    text-decoration: none;
}

.badge.info {
    background: #dbeafe;
    color: #1e3a8a;
}

.admin-tabs {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tab-link {
    display: inline-flex;
    align-items: center;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #1e3a8a;
    font-weight: 600;
    text-decoration: none;
}

.tab-link:hover {
    background: #dbeafe;
    text-decoration: none;
}

.tab-link.active {
    background: #1d4ed8;
    color: white;
}

.water-entry-grid {
    align-items: end;
}

.water-table,
.water-admin-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

.water-table th,
.water-table td,
.water-admin-table th,
.water-admin-table td {
    padding: 0.85rem 0.75rem;
    border-top: 1px solid var(--border);
    vertical-align: top;
    font-size: 0.93rem;
}

.water-table thead th,
.water-admin-table thead th {
    border-top: none;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.water-table tbody tr:first-child td,
.water-admin-table tbody tr:first-child td {
    border-top: 1px solid var(--border);
}

.water-table td:nth-child(5),
.water-admin-table td:nth-child(8) {
    min-width: 160px;
}

.water-admin-table td:nth-child(2) {
    min-width: 210px;
}

@media (max-width: 900px) {
    .grid-span-2 {
        grid-column: auto;
    }
}


.login-card-wide {
    max-width: 760px;
}

.badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.badge.success {
    background: #dcfce7;
    color: #166534;
}

/* ============================================================
   NUEVA ESTRUCTURA (Fase 1) — layout, navegación y solapas
   ============================================================ */
:root {
    --brand: #c1442e;
    --brand-dark: #9c3323;
    --ink: #16233a;
    --park: #1d6b5b;
    --surface-soft: #f4f6f8;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, .09);
    --sidebar-w: 258px;
    --topbar-h: 68px;
    --radius: 14px;
    --transition: 160ms cubic-bezier(.4, 0, .2, 1);
}

body.app-body {
    background: var(--surface-soft);
    min-height: 100vh;
}

/* ---------- Barra superior ---------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--topbar-h);
    padding: 0 1.4rem;
    background: var(--ink);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    box-shadow: var(--shadow-sm);
    flex-wrap: nowrap;
}
.app-topbar-left {
    display: flex;
    align-items: center;
    gap: .85rem;
    min-width: 0;
    flex: 1 1 auto;
}
.app-topbar .brand { min-width: 0; }
.app-topbar .brand a {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-width: 0;
}
.app-brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 11px;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
    font-size: .95rem;
    letter-spacing: -.03em;
}
.app-brand-text {
    display: grid;
    line-height: 1.15;
    min-width: 0;
}
.app-brand-text strong,
.app-brand-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-brand-text strong {
    font-size: 1rem;
    letter-spacing: -.01em;
}
.app-brand-text small {
    font-size: .7rem;
    color: #c7d2fe;
    font-weight: 500;
}
.app-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 9px;
    background: rgba(255, 255, 255, .06);
    color: #fff;
    cursor: pointer;
    transition: background var(--transition);
}
.app-menu-btn:hover { background: rgba(255, 255, 255, .15); }
.app-icon {
    width: 18px;
    height: 18px;
    flex: none;
}
.app-topbar .nav-user {
    gap: .8rem;
    flex: 0 0 auto;
    margin-left: auto;
    justify-content: flex-end;
}
.app-user-name {
    font-size: .88rem;
    color: #e5e7eb;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-logout {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    flex: none;
    white-space: nowrap;
    color: #e5e7eb !important;
    font-size: .85rem;
}
.app-logout .app-icon { width: 16px; height: 16px; }

/* ---------- Estructura con barra lateral ---------- */
.app-shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - var(--topbar-h));
}
.app-sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 1.4rem .85rem 2rem;
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
}
.app-nav-group + .app-nav-group {
    margin-top: 1.4rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
}
.app-nav-title {
    margin: 0 .7rem .5rem;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #98a2b3;
}
.app-nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .7rem;
    margin-bottom: .15rem;
    border-radius: 10px;
    color: #475467 !important;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}
.app-nav-link .app-icon { width: 17px; height: 17px; opacity: .8; }
.app-nav-link:hover {
    background: #f2f4f7;
    color: var(--ink) !important;
    transform: translateX(2px);
}
.app-nav-link.active {
    background: #fdeeea;
    color: var(--brand-dark) !important;
}
.app-nav-link.active .app-icon { opacity: 1; }
.app-nav-link.active::after {
    content: "";
    width: 5px;
    height: 5px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--brand);
}

.app-main.container {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 1.7rem clamp(1rem, 3vw, 2.6rem) 3rem;
}

/* ---------- Solapas internas ---------- */
.app-subtabs {
    display: flex;
    gap: .4rem;
    margin: 0 0 1.3rem;
    padding: .3rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
}
.app-subtabs .tab-link {
    padding: .5rem .9rem;
    border-radius: 9px;
    white-space: nowrap;
}
.app-subtabs .tab-link.active {
    background: var(--ink);
    color: #fff;
}

/* ---------- Cabecera de inicio con foto real ---------- */
.hero {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    min-height: 210px;
    padding: 2.2rem 2.4rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: #fff;
    background:
        linear-gradient(90deg, rgba(12, 25, 45, .88) 0%, rgba(12, 25, 45, .55) 55%, rgba(12, 25, 45, .12) 100%),
        url('/images/entrevias-plaza.jpg') center 45% / cover no-repeat;
    box-shadow: var(--shadow-md);
}
.hero h1 {
    margin: 0 0 .35rem;
    font-size: clamp(1.5rem, 3vw, 2.1rem);
    letter-spacing: -.02em;
}
.hero p {
    margin: 0;
    max-width: 620px;
    color: #e6ebf2;
}
.hero::before {
    content: "ENTREVÍAS · MADRID";
    position: absolute;
    top: 1.1rem;
    left: 2.4rem;
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .16em;
    color: #ffd9cf;
}

/* ---------- Mensajes ---------- */
.flash {
    position: relative;
    border-radius: 12px;
    padding-right: 2.5rem;
    animation: app-flash-in var(--transition) both;
}
.flash-close {
    position: absolute;
    top: .45rem;
    right: .6rem;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    opacity: .55;
}
.flash-close:hover { opacity: 1; }
@keyframes app-flash-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Pie ---------- */
.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.3rem clamp(1rem, 3vw, 2.6rem);
    background: #fff;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .78rem;
}
.app-footer strong { display: block; color: var(--ink); font-size: .85rem; }
.app-footer-credit a { color: var(--muted); text-decoration: underline; }

/* ---------- Accesibilidad ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .app-menu-btn { display: inline-flex; }
    .app-brand-text small { display: none; }
    .app-user-name { display: none; }
    .app-topbar .nav-user {
        width: auto;
        flex: 0 0 auto;
        margin-left: auto;
        justify-content: flex-end;
    }
    .app-sidebar {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        z-index: 50;
        transform: translateX(-105%);
        transition: transform 200ms ease;
        box-shadow: var(--shadow-md);
    }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-main.container { padding: 1.2rem 1rem 2.5rem; }
    .hero { padding: 1.6rem 1.3rem; min-height: 180px; }
    .hero::before { left: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

/* ============================================================
   CSS INLINE DE USUARIOS (movido desde users.html)
   ============================================================ */

        /* ===== Filtros ===== */
        .filter-bar {
            display: grid;
            grid-template-columns: 2fr 1fr 1fr 1fr auto;
            gap: 0.75rem;
            align-items: end;
            margin-bottom: 1rem;
        }
        .filter-bar label { font-size: 0.85rem; }
        .filter-bar input, .filter-bar select {
            width: 100%;
            padding: 0.6rem 0.7rem;
            border: 1px solid var(--border);
            border-radius: 10px;
            font: inherit;
            font-size: 0.92rem;
        }

        /* ===== Tabla de usuarios ===== */
        .users-table {
            width: 100%;
            border-collapse: collapse;
        }
        .users-table th, .users-table td {
            padding: 0.7rem 0.8rem;
            border-top: 1px solid var(--border);
            vertical-align: middle;
            font-size: 0.92rem;
        }
        .users-table thead th {
            border-top: none;
            background: #f8fafc;
            color: var(--muted);
            font-size: 0.78rem;
            text-transform: uppercase;
            letter-spacing: 0.03em;
            white-space: nowrap;
        }
        .users-table tbody tr:hover { background: #f9fafb; }
        .users-table .sort-link {
            color: inherit;
            text-decoration: none;
        }
        .users-table .sort-link:hover { color: var(--primary); }
        .sort-indicator { color: var(--primary); margin-left: 0.2rem; }
        .users-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

        /* ===== Acciones (iconos alineados) ===== */
        .actions-cell {
            width: 132px;
            white-space: nowrap;
        }
        .row-actions {
            display: flex;
            gap: 0.3rem;
            flex-wrap: nowrap;
            justify-content: center;
            align-items: center;
        }
        .row-actions form {
            display: inline-flex;
            margin: 0;
        }
        .action-btn {
            width: 34px;
            height: 34px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            border: 1px solid var(--border);
            background: #fff;
            color: #475569;
            border-radius: 8px;
            cursor: pointer;
            transition: background 0.15s, color 0.15s, border-color 0.15s;
            flex-shrink: 0;
        }
        .action-btn:hover {
            background: #eef2ff;
            border-color: #c7d2fe;
            color: #312e81;
        }
        .action-btn.edit:hover   { background: #dbeafe; color: #1e3a8a; border-color: #93c5fd; }
        .action-btn.invite:hover { background: #dcfce7; color: #166534; border-color: #86efac; }
        .action-btn.reset:hover  { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
        .action-btn:focus-visible {
            outline: 2px solid var(--primary);
            outline-offset: 2px;
        }
        .action-btn svg { display: block; }

        /* Estados */
        .status-dot {
            display: inline-block;
            width: 8px; height: 8px;
            border-radius: 50%;
            margin-right: 0.35rem;
        }
        .status-dot.active { background: #16a34a; }
        .status-dot.inactive { background: #dc2626; }

        .badge.role-admin { background: #fee2e2; color: #991b1b; }
        .badge.role-treasurer { background: #fef3c7; color: #92400e; }
        .badge.role-resident { background: #dbeafe; color: #1e3a8a; }

        /* ===== Paginación ===== */
        .pagination-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 1rem;
            flex-wrap: wrap;
            margin-top: 1rem;
            padding-top: 1rem;
            border-top: 1px solid var(--border);
        }
        .pagination-info { color: var(--muted); font-size: 0.9rem; }
        .pagination-controls {
            display: flex;
            gap: 0.3rem;
            align-items: center;
            flex-wrap: wrap;
        }
        .page-btn {
            min-width: 36px;
            padding: 0.35rem 0.6rem;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: white;
            color: var(--text);
            text-decoration: none;
            text-align: center;
            font-size: 0.9rem;
        }
        .page-btn:hover { background: #eef2ff; text-decoration: none; }
        .page-btn.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
            font-weight: 700;
        }
        .page-btn.disabled {
            opacity: 0.45;
            pointer-events: none;
        }
        .page-ellipsis { padding: 0 0.2rem; color: var(--muted); }

        /* ===== Modal de edición ===== */
        .modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(15, 23, 42, 0.55);
            z-index: 100;
            align-items: center;
            justify-content: center;
            padding: 1rem;
        }
        .modal-overlay.open { display: flex; }
        .modal-box {
            background: white;
            border-radius: 16px;
            padding: 1.5rem;
            width: min(560px, 100%);
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 20px 60px rgba(0,0,0,0.25);
        }
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }
        .modal-header h2 { margin: 0; font-size: 1.3rem; }
        .modal-close {
            background: none;
            border: none;
            font-size: 1.6rem;
            cursor: pointer;
            line-height: 1;
            color: var(--muted);
        }
    

/* ============================================================
   FASE 2 — PROFUNDIDAD, MOVIMIENTO Y MICROINTERACCIONES
   ============================================================ */

@font-face {
    font-family: "Inter Local";
    src: url("/fonts/InterVariable.woff2") format("woff2");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --font-app: "Inter Local", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ease-out: cubic-bezier(.2, .8, .2, 1);
    --lift-shadow: 0 22px 48px rgba(15, 23, 42, .13), 0 3px 10px rgba(15, 23, 42, .06);
    --hairline: rgba(15, 23, 42, .08);
    --brand-soft: #fff1ec;
    --park-soft: #e8f5f0;
}

body {
    font-family: var(--font-app);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ---------- Entrada escalonada ---------- */
.reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .55s var(--ease-out), transform .55s var(--ease-out);
}
.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Paneles con tilt y brillo ---------- */
.app-tilt {
    position: relative;
    isolation: isolate;
    transform-style: preserve-3d;
    will-change: transform;
    transition:
        transform .32s var(--ease-out),
        box-shadow .32s var(--ease-out),
        border-color .32s var(--ease-out);
}
.app-tilt::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%),
                rgba(255, 255, 255, .22), transparent 48%);
    transition: opacity .32s var(--ease-out);
}
.app-tilt:hover {
    transform: perspective(1400px)
               rotateX(var(--rx, 0deg))
               rotateY(var(--ry, 0deg))
               translateY(-1px);
    border-color: rgba(193, 68, 46, .12);
    box-shadow: 0 10px 24px rgba(17, 24, 39, .055),
                0 2px 6px rgba(17, 24, 39, .035);
}
.app-tilt:hover::after { opacity: .35; }
.app-tilt > * { position: relative; z-index: 2; }

.card, .receipt, .card-light {
    border-color: var(--hairline);
    box-shadow: 0 8px 26px rgba(17, 24, 39, .045);
}
.card:hover, .receipt:hover {
    background: linear-gradient(180deg, #fff 0%, #fdfefe 100%);
}

/* Tarjetas de métricas */
.stat { overflow: hidden; }
.stat::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand) 0%, #e07a3f 50%, var(--park) 100%);
}
.stat-value {
    font-size: 2.25rem;
    line-height: 1.05;
    letter-spacing: -.04em;
    background: linear-gradient(135deg, var(--brand), var(--ink));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.stat h3 {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
}

/* ---------- Cabecera con aurora ---------- */
.hero {
    animation: hero-enter .75s var(--ease-out);
    border: 1px solid rgba(255, 255, 255, .18);
}
.hero::before { z-index: 4; }
.hero::after {
    content: "";
    position: absolute;
    z-index: 1;
    inset: -45%;
    opacity: 1;
    pointer-events: none;
    background:
        radial-gradient(circle at 28% 32%, rgba(193, 68, 46, .50), transparent 34%),
        radial-gradient(circle at 72% 62%, rgba(29, 107, 91, .42), transparent 36%),
        radial-gradient(circle at 52% 85%, rgba(96, 135, 210, .30), transparent 32%);
    filter: blur(34px);
    animation: aurora-drift 15s ease-in-out infinite alternate;
}
.hero > * { z-index: 3; }
@keyframes hero-enter {
    from { opacity: 0; transform: translateY(18px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes aurora-drift {
    from { transform: translate3d(-4%, -3%, 0) scale(1); }
    to { transform: translate3d(5%, 4%, 0) scale(1.12); }
}

/* ---------- Barra superior y menú ---------- */
.app-topbar { overflow: hidden; }
.app-topbar::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, transparent 35%, rgba(193, 68, 46, .22) 50%, transparent 65%);
    transform: translateX(-110%);
    animation: topbar-sweep 11s ease-in-out infinite;
}
@keyframes topbar-sweep {
    0%, 55% { transform: translateX(-110%); }
    85%, 100% { transform: translateX(110%); }
}
.app-brand-mark {
    box-shadow: 0 6px 18px rgba(193, 68, 46, .32);
    transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out);
}
.app-topbar:hover .app-brand-mark {
    transform: rotate(-6deg) scale(1.06);
    box-shadow: 0 10px 24px rgba(193, 68, 46, .45);
}
.app-sidebar {
    background: linear-gradient(180deg, #fff 0%, #fbfcfe 100%);
}
.app-nav-link { overflow: hidden; }
.app-nav-link::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(90deg, rgba(193, 68, 46, .12), transparent 75%);
    transition: opacity .22s var(--ease-out);
}
.app-nav-link:hover::before { opacity: 1; }
.app-nav-link.active {
    box-shadow: inset 3px 0 0 var(--brand), 0 8px 20px rgba(193, 68, 46, .10);
}
.app-nav-link .app-icon { transition: transform .22s var(--ease-out); }
.app-nav-link:hover .app-icon { transform: scale(1.12) rotate(-4deg); }

/* ---------- Solapas ---------- */
.app-subtabs .tab-link {
    transition: transform .2s var(--ease-out), background .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.app-subtabs .tab-link:hover {
    transform: translateY(-1px);
    background: var(--brand-soft);
    box-shadow: 0 6px 14px rgba(193, 68, 46, .12);
}
.app-subtabs .tab-link.active,
.app-subtabs .tab-link.active:hover {
    background: var(--ink);
    color: #fff;
    box-shadow: 0 8px 18px rgba(22, 35, 58, .22);
}

/* ---------- Tablas ---------- */
.table-wrap {
    position: relative;
    overflow: auto;
    margin: .65rem 0 1rem;
    border: 1px solid var(--hairline);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 6px 20px rgba(17, 24, 39, .035);
}
.app-main table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .9rem;
}
.app-main thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: .85rem 1rem;
    background: #f7f9fb;
    border-bottom: 1px solid var(--hairline);
    color: #5d6879;
    font-size: .71rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
}
.app-main tbody td {
    padding: .82rem 1rem;
    border-bottom: 1px solid var(--hairline);
    vertical-align: middle;
}
.app-main tbody tr {
    transition: background .18s var(--ease-out), transform .18s var(--ease-out);
}
.app-main tbody tr:hover {
    background: linear-gradient(90deg, rgba(193, 68, 46, .055), rgba(29, 107, 91, .045));
}
.app-main tbody tr:last-child td { border-bottom: 0; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .65rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #eef2f7;
    color: #46536a;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .015em;
    white-space: nowrap;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .8;
}
.badge.warning { background: #fff4e4; color: #915a06; border-color: #ffdda8; }
.badge.success { background: #e7f7ef; color: #176b4b; border-color: #bfe7d2; }
.badge.info { background: #e8f1ff; color: #2456a6; border-color: #c9ddff; }
.badge.highlight { background: var(--brand-soft); color: var(--brand-dark); border-color: #f6c9bd; }

/* ---------- Botones ---------- */
.btn, .action-btn, .page-btn {
    position: relative;
    overflow: hidden;
    transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out);
}
.btn:not(:disabled):hover,
.action-btn:hover,
.page-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(15, 23, 42, .08);
}
.btn:not(:disabled):active,
.action-btn:active,
.page-btn:active { transform: translateY(0) scale(.97); }
.ripple {
    position: absolute;
    z-index: 0;
    border-radius: 50%;
    pointer-events: none;
    background: rgba(255, 255, 255, .45);
    transform: scale(0);
    animation: ripple-out .6s linear forwards;
}
@keyframes ripple-out {
    to { transform: scale(4); opacity: 0; }
}

/* ---------- Formularios y mensajes ---------- */
input, select, textarea {
    transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
input:hover, select:hover, textarea:hover { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(193, 68, 46, .12);
}
.flash {
    border: 1px solid rgba(15, 23, 42, .07);
    box-shadow: 0 10px 24px rgba(17, 24, 39, .07);
    backdrop-filter: blur(6px);
}
.page-header h1 {
    position: relative;
    display: inline-block;
    letter-spacing: -.02em;
}
.page-header h1::after {
    content: "";
    display: block;
    width: 52px;
    height: 3px;
    margin-top: .5rem;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--brand), var(--park));
    animation: underline-grow .6s var(--ease-out) both;
}
@keyframes underline-grow {
    from { width: 0; opacity: 0; }
    to { width: 52px; opacity: 1; }
}

/* ---------- Ajustes de ancho en formularios ---------- */
.form-stack > * { min-width: 0; }
.resident-checkbox span { overflow-wrap: anywhere; }
@media (max-width: 700px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Adaptación táctil y accesibilidad ---------- */
@media (hover: none) {
    .app-tilt:hover {
        transform: none;
        border-color: var(--hairline);
        box-shadow: 0 8px 26px rgba(17, 24, 39, .045);
    }
    .app-tilt::after { display: none; }
    .hero::after { animation-duration: 24s; }
}

@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
    .app-tilt, .app-tilt:hover { transform: none !important; transition: none !important; }
    .app-tilt::after, .hero::after, .app-topbar::after,
    .page-header h1::after, .flash { animation: none !important; }
    .hero { animation: none !important; }
}

/* ============================================================
   PWA — INSTALACIÓN Y ADAPTACIÓN MÓVIL
   ============================================================ */

/* ---------- Aviso de instalación ---------- */
.pwa-install {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 9999;
    width: auto;
    max-width: 430px;
    margin: 0 auto;
    padding: 1rem 1.1rem;
    border: 1px solid rgba(15, 23, 42, .10);
    border-radius: 18px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 18px 46px rgba(15, 23, 42, .22);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(24px) scale(.98);
    transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
}
.pwa-install.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.pwa-title {
    display: block;
    padding-right: 1.75rem;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 800;
}
.pwa-text {
    margin: .35rem 0 .8rem;
    color: #526074;
    font-size: .88rem;
    line-height: 1.45;
}
.pwa-actions {
    display: flex;
    gap: .5rem;
}
.pwa-actions .btn {
    flex: 1;
    min-height: 44px;
    font-size: .9rem;
}
.pwa-close {
    position: absolute;
    top: .35rem;
    right: .55rem;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #7b8798;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}
.pwa-close:hover { background: #f1f5f9; color: var(--ink); }

/* ---------- Ajustes táctiles y zonas seguras ---------- */
body.is-mobile input,
body.is-mobile select,
body.is-mobile textarea {
    font-size: 16px;
}
body.is-mobile .btn,
body.is-mobile .action-btn,
body.is-mobile .page-btn,
body.is-mobile .app-nav-link,
body.is-mobile .app-subtabs .tab-link {
    min-height: 44px;
}
body.is-mobile .app-topbar {
    padding-top: calc(.75rem + env(safe-area-inset-top, 0px));
}
body.is-ios .app-topbar {
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
}
body.is-mobile .app-footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}
body.is-mobile .container {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
}
body.is-mobile .app-tilt:hover {
    transform: none;
    box-shadow: 0 8px 26px rgba(17, 24, 39, .045);
}
body.is-mobile .app-tilt::after { display: none; }

@media (prefers-reduced-motion: reduce) {
    .pwa-install { transition: none !important; }
}

/* ---------- Ajuste extra de cabecero en pantallas pequeñas ---------- */
@media (max-width: 600px) {
    .app-topbar { padding-left: 1rem; padding-right: 1rem; gap: .6rem; }
    .app-topbar-left { gap: .6rem; }
    .app-topbar .brand a { gap: .5rem; }
    .app-logout { padding-left: .7rem; padding-right: .7rem; }
}

/* ---------- Panel: métricas y accesos rápidos pulsables ---------- */
.stat-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-link:hover,
.stat-link:focus-visible {
    text-decoration: none;
    border-color: rgba(193, 68, 46, .35);
    box-shadow: 0 10px 26px rgba(17, 24, 39, .07);
}
.stat-link:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
.stat-cta {
    display: inline-block;
    margin-top: .65rem;
    font-size: .76rem;
    font-weight: 700;
    color: var(--brand-dark);
}
.with-more {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    flex-wrap: wrap;
}
.section-more {
    flex: none;
    white-space: nowrap;
    font-size: .74rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: var(--brand-dark);
}
.section-more:hover { text-decoration: underline; }

/* ---------- Usuarios: vista ordenada en pantallas pequeñas ---------- */
@media (max-width: 700px) {
    .filter-bar {
        grid-template-columns: 1fr;
        gap: .85rem;
    }
    .filter-bar button[type="submit"] { width: 100%; }

    .table-scroll {
        overflow: visible;
        margin-top: .5rem;
    }
    .users-table,
    .users-table tbody,
    .users-table tr,
    .users-table td {
        display: block;
        width: 100%;
    }
    .users-table thead { display: none; }
    .users-table tr {
        border: 1px solid var(--border);
        border-radius: 14px;
        padding: .85rem .9rem;
        margin-bottom: .8rem;
        background: #fff;
        box-shadow: var(--shadow-sm);
    }
    .users-table tbody tr:hover { background: #fff; }
    .users-table td {
        border: none;
        padding: .35rem 0;
        display: grid;
        grid-template-columns: 84px minmax(0, 1fr);
        gap: .6rem;
        align-items: start;
        font-size: .92rem;
    }
    .users-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
        padding-top: .12rem;
    }
    .users-table td.num { text-align: left; }
    .users-table td.actions-cell {
        display: block;
        width: auto;
        border-top: 1px solid var(--border);
        margin-top: .45rem;
        padding-top: .7rem;
    }
    .users-table td.actions-cell::before { display: none; }
    .row-actions {
        justify-content: flex-start;
        gap: .5rem;
        flex-wrap: wrap;
    }
    .row-actions .action-btn {
        width: 44px;
        height: 44px;
    }
    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .pagination-controls { justify-content: center; }
    .modal-box { padding: 1.1rem; }
}

/* ============================================================
   LOOK & FEEL iOS — solo móvil
   ============================================================ */
body.is-mobile {
    --primary: #0a84ff;
    --primary-dark: #0062cc;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
body.is-mobile.app-body { background: #f2f2f7; }

body.is-mobile .app-topbar {
    background: rgba(22, 35, 58, .88);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
}
body.is-mobile .card,
body.is-mobile .receipt,
body.is-mobile .card-light {
    border: 0;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
body.is-mobile .card { padding: 1rem; }
body.is-mobile .hero { padding: 1.25rem 1.15rem 1.1rem; }
body.is-mobile .hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -.035em;
}
body.is-mobile .page-header h1 {
    font-size: 1.65rem;
    letter-spacing: -.03em;
}
body.is-mobile .stat-value { font-size: 2rem; }
body.is-mobile .stat-cta,
body.is-mobile .section-more { color: var(--primary-dark); }
body.is-mobile .badge { border-radius: 999px; }

body.is-mobile .btn,
body.is-mobile .action-btn,
body.is-mobile .page-btn {
    border-radius: 12px;
    font-weight: 600;
}
body.is-mobile input,
body.is-mobile select,
body.is-mobile textarea {
    border-radius: 12px;
    background: #fff;
}
body.is-mobile .filter-bar label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .02em;
}
body.is-mobile .filter-bar input,
body.is-mobile .filter-bar select {
    border: 1px solid rgba(60, 60, 67, .12);
    padding: .7rem .8rem;
}

body.is-mobile .users-table tr {
    padding: 0;
    overflow: hidden;
    border: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
body.is-mobile .users-table td {
    padding: .55rem 1rem;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: .75rem;
    border-bottom: 1px solid rgba(60, 60, 67, .10);
    font-size: .9rem;
}
body.is-mobile .users-table td:last-child { border-bottom: 0; }
body.is-mobile .users-table td::before {
    color: #8e8e93;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    padding-top: .1rem;
}
body.is-mobile .users-table td:first-child {
    display: block;
    padding: .9rem 1rem .75rem;
    border-bottom: 1px solid rgba(60, 60, 67, .10);
}
body.is-mobile .users-table td:first-child::before { display: none; }
body.is-mobile .users-table td:first-child strong { font-size: 1.02rem; }
body.is-mobile .users-table td:first-child .muted {
    margin-top: .15rem;
    font-size: .76rem;
}
body.is-mobile .users-table td.actions-cell {
    display: block;
    background: #fafafa;
    padding: .8rem 1rem;
}
body.is-mobile .row-actions .action-btn {
    border-radius: 12px;
    border-color: rgba(60, 60, 67, .12);
    background: #fff;
}
body.is-mobile .pagination-controls { gap: .35rem; }
body.is-mobile .page-btn { min-width: 40px; border-radius: 10px; }

body.is-mobile .app-subtabs {
    display: flex;
    gap: .35rem;
    padding: .25rem;
    border-radius: 12px;
    background: rgba(118, 118, 128, .12);
    overflow-x: auto;
}
body.is-mobile .app-subtabs .tab-link {
    flex: 0 0 auto;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #3c3c43;
    font-weight: 600;
    white-space: nowrap;
}
body.is-mobile .app-subtabs .tab-link.active {
    background: #fff;
    color: var(--primary-dark);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
body.is-mobile .app-nav-link { border-radius: 12px; }
body.is-mobile .app-nav-link.active {
    background: rgba(10, 132, 255, .10);
    box-shadow: none;
}

@media (max-width: 700px) {
    body.is-mobile .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    body.is-mobile .modal-box {
        width: 100%;
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
        padding: 1.25rem 1.1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }
}

/* ============================================================
   LECTOR DE CONTADOR CON CÁMARA
   ============================================================ */
.modal-overlay[hidden] { display: none !important; }
.meter-camera-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin: .85rem 0 .2rem;
}
.meter-camera-row .muted { font-size: .82rem; }
.btn-camera { display: inline-flex; align-items: center; gap: .45rem; }
.meter-modal { max-width: 480px; }
.meter-modal .modal-header { margin-bottom: .5rem; }
.meter-modal .modal-header h2 { font-size: 1.15rem; }
.meter-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    margin: .85rem 0;
    border-radius: 14px;
    overflow: hidden;
    background: #0b1220;
}
.meter-viewport video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.meter-guide {
    position: absolute;
    inset: 18% 8%;
    border: 2px dashed rgba(255, 255, 255, .9);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .28);
    pointer-events: none;
}
.meter-guide::after {
    content: "Encuadra aquí los dígitos";
    position: absolute;
    left: 50%;
    bottom: -2.1rem;
    transform: translateX(-50%);
    padding: .2rem .55rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    font-size: .72rem;
    white-space: nowrap;
}
.meter-preview {
    display: block;
    width: 100%;
    margin: .85rem 0;
    border-radius: 14px;
}
.meter-status {
    min-height: 1.25rem;
    margin: .6rem 0 0;
    font-size: .82rem;
    color: var(--muted);
}
.meter-status.is-error { color: #b91c1c; }
.meter-status.is-ok { color: #15803d; }
.meter-result {
    margin-top: .5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.meter-result label { display: block; font-weight: 600; font-size: .9rem; }
.meter-result input {
    width: 100%;
    margin-top: .35rem;
    padding: .7rem .8rem;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}
body.is-mobile .meter-result input { font-size: 16px; }
