/* ============================================
   K'ANIMALÀ CADAFAL · Tesorería
   ============================================ */

@font-face {
    font-family: 'Barlow Condensed';
    src: url('/fonts/barlow-condensed-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Barlow';
    src: url('/fonts/barlow-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Barlow';
    src: url('/fonts/barlow-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Marca: azul del escudo */
    --brand: #002E7C;
    --brand-hover: #003A9C;
    --brand-press: #00235F;
    --brand-soft: #E7EDF9;
    --brand-ring: rgba(0, 46, 124, 0.2);
    --on-brand: #FFFFFF;

    --bg: #F3F5FA;
    --surface: #FFFFFF;
    --ink: #0B1633;
    --muted: #56617A;
    --line: #D8DEEB;
    --line-strong: #B9C3D8;

    --danger: #B42318;
    --danger-bg: #FDECEA;
    --danger-line: #F5C2BC;

    --shadow-card: 0 1px 2px rgba(0, 35, 95, 0.06), 0 12px 32px -12px rgba(0, 35, 95, 0.18);
    --shadow-pop: 0 12px 28px -8px rgba(0, 35, 95, 0.28);

    --radius: 14px;
    --radius-lg: 22px;

    --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Motion */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --dur-press: 160ms;
    --dur-pop: 180ms;
    --dur-enter: 200ms;
    --dur-exit: 150ms;
    --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

    /* Azul del escudo, igual en claro y oscuro (fondos con texto blanco) */
    --shield: #002E7C;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --brand: #2F6BFF;
        --brand-hover: #4A7FFF;
        --brand-press: #1F55E0;
        --brand-soft: rgba(47, 107, 255, 0.14);
        --brand-ring: rgba(74, 127, 255, 0.35);

        --bg: #030A1C;
        --surface: #0A1631;
        --ink: #E9EEF9;
        --muted: #9AA6C0;
        --line: #1E2C4F;
        --line-strong: #2E4070;

        --danger: #FF8A80;
        --danger-bg: rgba(255, 138, 128, 0.1);
        --danger-line: rgba(255, 138, 128, 0.3);

        --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
        --shadow-pop: 0 16px 32px -8px rgba(0, 0, 0, 0.6);

        color-scheme: dark;
    }
}

/* ============================================
   BASE
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top, 0px)) 16px max(24px, env(safe-area-inset-bottom, 0px));
    line-height: 1.45;
}

/* Franja de marca superior */
body::before {
    content: '';
    position: fixed;
    inset: 0 0 auto 0;
    height: 220px;
    background: var(--brand-soft);
    z-index: -1;
}

button,
a,
label,
[role="button"] {
    touch-action: manipulation;
}

button {
    font: inherit;
    color: inherit;
}

.container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============================================
   CABECERA
   ============================================ */

.header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 4px 0;
    animation: rise 300ms var(--ease-out) backwards;
}

.logo {
    flex: none;
    width: 88px;
    height: 88px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #FFFFFF;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    user-select: none;
    -webkit-user-select: none;
    transition: transform var(--dur-press) var(--ease-out);
}

.logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.logo:active {
    transform: scale(0.95);
}

.logo:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 3px;
}

@media (prefers-color-scheme: dark) {
    .logo {
        background: #002E7C;
        border-color: var(--line-strong);
    }
}

.header-text {
    min-width: 0;
}

.kicker {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.header h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2.75rem;
    line-height: 1;
    letter-spacing: 0.01em;
    color: var(--brand);
    margin-top: 2px;
}

.subtitle {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: 0.32em;
    color: var(--ink);
    margin-top: 2px;
}

.night-note {
    font-size: 0.875rem;
    color: var(--muted);
    padding: 0 4px;
}

/* ============================================
   FORMULARIO
   ============================================ */

.form-container {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 28px 22px 24px;
    animation: rise 300ms var(--ease-out) 60ms backwards;
}

/* backwards (no both): con fill "forwards" la animación de transform deja
   cada grupo como stacking context para siempre y el dropdown (z-index 20)
   queda atrapado debajo del grupo siguiente y del botón. */
.form-group {
    margin-bottom: 22px;
    animation: rise 300ms var(--ease-out) backwards;
    animation-delay: calc(120ms + var(--i, 0) * 50ms);
}

/* El grupo con el dropdown abierto siempre por encima de sus hermanos */
.form-group:has(.dropdown-menu.active) {
    position: relative;
    z-index: 30;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--ink);
    margin-bottom: 8px;
}

.form-group label svg {
    flex: none;
    color: var(--brand);
}

/* Buscadores */
.select-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 16px; /* evita el zoom de iOS */
    cursor: pointer;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search-input::placeholder {
    color: var(--muted);
    opacity: 1;
}

.search-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-ring);
}

/* Dropdown: nace del input, transición interrumpible */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    max-height: 264px;
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 20;
    box-shadow: var(--shadow-pop);
    padding: 6px;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-4px) scale(0.97);
    transform-origin: top center;
    transition:
        opacity var(--dur-exit) var(--ease-out),
        transform var(--dur-exit) var(--ease-out),
        visibility 0s linear var(--dur-exit);
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition:
        opacity var(--dur-pop) var(--ease-out),
        transform var(--dur-pop) var(--ease-out),
        visibility 0s;
}

.dropdown-item {
    padding: 12px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
    -webkit-user-select: none;
}

.dropdown-item:active {
    background: var(--brand-soft);
}

.dropdown-empty,
.dropdown-empty:active {
    color: var(--muted);
    cursor: default;
    background: none;
}

.dropdown-item.selected {
    background: var(--brand);
    color: var(--on-brand);
    font-weight: 600;
}

@media (hover: hover) and (pointer: fine) {
    .dropdown-item:hover {
        background: var(--brand-soft);
    }

    .dropdown-item.selected:hover {
        background: var(--brand);
    }

    .dropdown-empty:hover {
        background: none;
    }
}

.dropdown-menu::-webkit-scrollbar {
    width: 8px;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 8px;
}

/* Archivo */
.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--brand);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition:
        transform var(--dur-press) var(--ease-out),
        border-color var(--dur-enter) ease,
        background-color var(--dur-enter) ease;
}

.form-group .file-label {
    margin-bottom: 0;
    color: var(--brand);
}

.file-label:active {
    transform: scale(0.98);
}

.file-input-wrapper input[type="file"]:focus-visible + .file-label {
    outline: 3px solid var(--brand-ring);
    outline-offset: 2px;
}

.file-icon {
    display: inline-flex;
    position: relative;
    width: 22px;
    height: 22px;
}

.file-icon svg {
    position: absolute;
    inset: 0;
    transition: opacity var(--dur-enter) var(--ease-out), transform var(--dur-enter) var(--ease-out);
}

.file-icon .icon-done {
    opacity: 0;
    transform: scale(0.9);
}

/* Estado "archivo listo" sin JS extra */
.file-input-wrapper:has(.file-name.active) .file-label {
    border-style: solid;
    border-color: var(--brand);
    background: var(--brand-soft);
}

.file-input-wrapper:has(.file-name.active) .icon-idle {
    opacity: 0;
    transform: scale(0.9);
}

.file-input-wrapper:has(.file-name.active) .icon-done {
    opacity: 1;
    transform: none;
}

@media (hover: hover) and (pointer: fine) {
    .file-label:hover {
        border-color: var(--brand);
        background: var(--brand-soft);
    }
}

.file-name {
    display: none;
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--muted);
    word-break: break-all;
    opacity: 0;
    transform: translateY(-4px);
    transition:
        opacity var(--dur-enter) var(--ease-out),
        transform var(--dur-enter) var(--ease-out),
        display var(--dur-enter) allow-discrete;
}

.file-name.active {
    display: block;
    opacity: 1;
    transform: none;
}

@starting-style {
    .file-name.active {
        opacity: 0;
        transform: translateY(-4px);
    }
}

/* ============================================
   BOTÓN ENVIAR
   ============================================ */

.submit-btn {
    width: 100%;
    min-height: 56px;
    padding: 16px;
    margin-top: 6px;
    background: var(--brand);
    color: var(--on-brand);
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 8px 20px -10px var(--brand);
    transition:
        transform var(--dur-press) var(--ease-out),
        background-color 150ms ease,
        box-shadow 150ms ease;
}

.submit-btn:active:not(:disabled) {
    transform: scale(0.97);
    background: var(--brand-press);
}

.submit-btn:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 3px;
}

.submit-btn:disabled {
    cursor: progress;
    opacity: 0.85;
}

.btn-text {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: opacity 150ms ease;
}

.btn-arrow {
    transition: transform var(--dur-pop) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .submit-btn:hover:not(:disabled) {
        background: var(--brand-hover);
    }

    .submit-btn:hover:not(:disabled) .btn-arrow {
        transform: translateX(4px);
    }
}

.btn-loader {
    display: none;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--on-brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -11px 0 0 -11px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.submit-btn.loading .btn-text {
    opacity: 0;
}

.submit-btn.loading .btn-loader {
    display: block;
}

/* ============================================
   MENSAJE DE ESTADO
   ============================================ */

.status-message {
    display: none;
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9375rem;
    text-align: center;
    opacity: 0;
    transform: translateY(8px);
    transition:
        opacity var(--dur-exit) var(--ease-out),
        transform var(--dur-exit) var(--ease-out),
        display var(--dur-exit) allow-discrete;
}

.status-message.active {
    display: block;
    opacity: 1;
    transform: none;
    transition:
        opacity var(--dur-enter) var(--ease-out),
        transform var(--dur-enter) var(--ease-out),
        display var(--dur-enter) allow-discrete;
}

@starting-style {
    .status-message.active {
        opacity: 0;
        transform: translateY(8px);
    }
}

.status-message.success {
    background: var(--brand-soft);
    color: var(--brand);
    border: 1px solid var(--brand);
}

.status-message.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-line);
}

.status-message.error.active {
    animation: nudge 300ms var(--ease-out);
}

@keyframes nudge {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

/* ============================================
   PIE
   ============================================ */

.footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 4px 0 8px;
    font-size: 0.8125rem;
    color: var(--muted);
    text-align: center;
}

.footer-legal {
    max-width: 34rem;
    margin: 0;
    text-wrap: balance;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 16px;
}

.footer-links a {
    padding: 6px 2px;
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .footer-links a:hover {
        color: var(--brand);
    }
}

.credit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
    transition: transform var(--dur-press) var(--ease-out), color 150ms ease, border-color 150ms ease;
}

.credit:active {
    transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
    .credit:hover {
        color: var(--brand);
        border-color: var(--brand);
    }
}

/* ============================================
   PANTALLA DE PAGO CONFIRMADO (vídeo)
   ============================================ */

.success-animation-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 16px;
    background: rgba(0, 20, 58, 0.94);
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms var(--ease-out), visibility 0s linear 200ms;
}

.success-animation-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 250ms var(--ease-out), visibility 0s;
}

.success-animation-container {
    width: min(100%, 720px);
    text-align: center;
}

.success-video-frame {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #002E7C;
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}

.success-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.success-text {
    margin-top: 24px;
    color: #FFFFFF;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 300ms var(--ease-out) 60ms, transform 300ms var(--ease-out) 60ms;
}

.success-animation-overlay.active .success-video-frame,
.success-animation-overlay.active .success-text {
    opacity: 1;
    transform: none;
}

.success-text h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2.5rem;
    line-height: 1.05;
    letter-spacing: 0.02em;
}

.success-text p {
    margin-top: 6px;
    font-size: 1.0625rem;
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================
   EASTER EGGS
   ============================================ */

.egg-toast {
    position: fixed;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    z-index: 90;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--bg);
    font-weight: 600;
    font-size: 0.9375rem;
    box-shadow: var(--shadow-pop);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 100%);
    transition: opacity var(--dur-enter) var(--ease-out), transform var(--dur-enter) var(--ease-out);
}

.egg-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Embestida del toro al tocar el escudo */
.logo.charge {
    animation: charge 520ms var(--ease-out);
}

@keyframes charge {
    0% { transform: none; }
    20% { transform: translateX(-4px) rotate(-6deg); }
    45% { transform: translateX(10px) rotate(4deg) scale(1.04); }
    70% { transform: translateX(-2px) rotate(-1deg); }
    100% { transform: none; }
}

/* Mascletà */
body.mascleta .container {
    animation: mascleta 480ms linear;
}

@keyframes mascleta {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-3px, 2px); }
    20% { transform: translate(3px, -2px); }
    30% { transform: translate(-2px, -3px); }
    40% { transform: translate(2px, 3px); }
    50% { transform: translate(-3px, 1px); }
    60% { transform: translate(3px, -1px); }
    70% { transform: translate(-1px, 2px); }
    80% { transform: translate(1px, -2px); }
    90% { transform: translate(-1px, 1px); }
}

/* ============================================
   PANEL DE ADMINISTRACIÓN (pensado para móvil)
   ============================================ */

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

/* Es una app: sin rebote de página ni pull-to-refresh */
html:has(.admin-body) {
    overscroll-behavior: none;
}

/* Con la hoja abierta, la página de detrás no se desplaza */
html:has(dialog[open]) {
    overflow: hidden;
}

.admin-body {
    display: block;
    padding: 0;
}

/* La franja de marca solo en el acceso; el panel tiene su propia cabecera */
.admin-body.in-app::before {
    display: none;
}

.admin-body button {
    user-select: none;
    -webkit-user-select: none;
}

.admin-input {
    cursor: text;
}

.link-btn {
    background: none;
    border: none;
    padding: 10px 4px;
    color: var(--brand);
    font-weight: 600;
    cursor: pointer;
}

.link-btn:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 2px;
    border-radius: 6px;
}

.icon-btn {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: none;
    color: var(--muted);
    cursor: pointer;
    transition: transform var(--dur-press) var(--ease-out);
}

.icon-btn:active:not(:disabled) {
    transform: scale(0.92);
    background: var(--brand-soft);
    color: var(--brand);
}

.icon-btn:disabled {
    opacity: 0.5;
    cursor: progress;
}

.month-arrow:disabled {
    opacity: 0.35;
    cursor: default;
}

.icon-btn:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 1px;
}

@media (hover: hover) and (pointer: fine) {
    .icon-btn:hover:not(:disabled) {
        background: var(--brand-soft);
        color: var(--brand);
    }
}

.avatar {
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.125rem;
    line-height: 1;
}

.avatar[data-admin="Ricardo"] {
    background: var(--shield);
    color: #FFFFFF;
}

.count-chip {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

/* ---------- Acceso ---------- */

.auth {
    margin: 0 auto;
    min-height: 100svh;
    padding: max(20px, env(safe-area-inset-top, 0px)) 16px max(24px, env(safe-area-inset-bottom, 0px));
}

.auth[hidden],
.auth-card[hidden] {
    display: none;
}

.auth-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.875rem;
    line-height: 1.05;
    letter-spacing: 0.01em;
}

.auth-sub {
    margin: 4px 0 20px;
    color: var(--muted);
    font-size: 0.9375rem;
}

.password-field {
    position: relative;
    margin-bottom: 16px;
}

.password-field .admin-input {
    padding-right: 52px;
}

.reveal-btn {
    position: absolute;
    top: 50%;
    right: 4px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--muted);
    cursor: pointer;
    transform: translateY(-50%);
}

.reveal-btn:focus-visible {
    outline: 3px solid var(--brand-ring);
}

.reveal-btn .icon-eye-off,
.reveal-btn[aria-pressed="true"] .icon-eye {
    display: none;
}

.reveal-btn[aria-pressed="true"] .icon-eye-off {
    display: block;
}

.who-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.who-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 148px;
    padding: 16px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition:
        transform var(--dur-press) var(--ease-out),
        border-color 150ms ease,
        background-color 150ms ease;
}

.who-btn .avatar {
    width: 60px;
    height: 60px;
    font-size: 1.75rem;
}

.who-btn:active {
    transform: scale(0.97);
    border-color: var(--brand);
    background: var(--brand-soft);
}

.who-btn:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .who-btn:hover {
        border-color: var(--brand);
        background: var(--brand-soft);
    }
}

/* ---------- App: cabecera fija ---------- */

.app {
    min-height: 100dvh;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

.app[hidden] {
    display: none;
}

.app-top {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: max(10px, env(safe-area-inset-top, 0px)) 16px 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.app-top-inner,
.app-main {
    max-width: 520px;
    margin: 0 auto;
}

.app-brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo {
    flex: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #FFFFFF;
    overflow: hidden;
}

.app-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (prefers-color-scheme: dark) {
    .app-logo {
        background: var(--shield);
        border-color: var(--line-strong);
    }
}

.app-brand {
    flex: 1;
    min-width: 0;
}

.app-brand .kicker {
    font-size: 0.75rem;
    line-height: 1.2;
}

.app-brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.375rem;
    line-height: 1;
    color: var(--brand);
}

.session-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9375rem;
}

.session-chip .avatar {
    width: 32px;
    height: 32px;
    font-size: 1rem;
}

.month-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.month-switch[hidden] {
    display: none;
}

.month-arrow {
    border: 1.5px solid var(--line-strong);
    color: var(--brand);
    background: var(--surface);
}

.month-label {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    column-gap: 8px;
    text-align: center;
}

.month-label strong {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.75rem;
    line-height: 1.1;
    letter-spacing: 0.01em;
}

.month-label span {
    color: var(--muted);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.month-today {
    flex-basis: 100%;
    padding: 2px 0 0;
    border: none;
    background: none;
    color: var(--brand);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}

.month-today[hidden] {
    display: none;
}

/* ---------- App: contenido ---------- */

.app-main {
    padding: 16px 16px 24px;
}

.tab-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tab-panel[hidden] {
    display: none;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 4px;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.1;
    letter-spacing: 0.01em;
}

.section-head .icon-btn {
    margin-left: auto;
}

.section-hint {
    padding: 0 4px;
    font-size: 0.875rem;
    color: var(--muted);
}

.load-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 8px 8px 14px;
    border: 1px solid var(--danger-line);
    border-radius: var(--radius);
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 0.9375rem;
    font-weight: 600;
}

.load-error[hidden] {
    display: none;
}

.load-error .link-btn {
    color: var(--danger);
    text-decoration: underline;
}

/* Cuota: tarjeta principal con el azul del escudo */
.hero-card {
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--shield);
    color: #FFFFFF;
    box-shadow: var(--shadow-card);
}

.hero-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
}

.hero-view {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
}

.hero-amount {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 3rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.hero-amount.is-empty {
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.7);
}

.hero-card[data-state="loading"] .hero-amount {
    width: 150px;
    height: 48px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
}

.hero-card[data-state="loading"] .hero-btn {
    visibility: hidden;
}

.hero-btn {
    position: relative;
    flex: none;
    min-height: 44px;
    padding: 0 18px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--dur-press) var(--ease-out), background-color 150ms ease;
}

.hero-btn.solid {
    border-color: #FFFFFF;
    background: #FFFFFF;
    color: var(--shield);
}

.hero-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.hero-btn:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

.hero-btn .btn-loader {
    border-color: rgba(0, 46, 124, 0.25);
    border-top-color: var(--shield);
}

.hero-btn.loading .btn-text {
    opacity: 0;
}

.hero-btn.loading .btn-loader {
    display: block;
}

.hero-edit {
    display: none;
    margin-top: 10px;
}

.hero-card[data-state="edit"] .hero-view {
    display: none;
}

.hero-card[data-state="edit"] .hero-edit {
    display: block;
}

.money-input {
    position: relative;
}

.money-input span {
    position: absolute;
    top: 50%;
    right: 16px;
    color: var(--muted);
    font-weight: 600;
    transform: translateY(-50%);
    pointer-events: none;
}

.hero-input {
    width: 100%;
    padding: 10px 48px 10px 16px;
    border: none;
    border-radius: var(--radius);
    background: #FFFFFF;
    color: #0B1633;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2.25rem;
    font-variant-numeric: tabular-nums;
}

.hero-input:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.hero-input::placeholder {
    color: #B9C3D8;
}

.money-input:has(.hero-input) span {
    color: #56617A;
    font-size: 1.5rem;
}

.hero-hint {
    margin-top: 8px;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.75);
}

.hero-actions {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 10px;
    margin-top: 14px;
}

.hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.hero-stats dt {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.7);
}

.hero-stats dd {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.375rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

#cuotaStatus.active {
    margin-top: -4px;
}

/* Buscador */
.search-field {
    position: relative;
}

.search-field svg {
    position: absolute;
    top: 50%;
    left: 14px;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.search-field .admin-input {
    padding-left: 44px;
}

.search-field .admin-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.people-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Listas */
.list-card {
    list-style: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.person-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 64px;
    padding: 10px 12px 10px 16px;
    border: none;
    border-top: 1px solid var(--line);
    background: none;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.person-row:first-child {
    border-top: none;
}

.person-row:active {
    background: var(--brand-soft);
}

.person-row:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: -3px;
}

@media (hover: hover) and (pointer: fine) {
    .person-row:hover {
        background: var(--bg);
    }
}

.person-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.person-mote {
    font-weight: 600;
}

.person-nombre {
    overflow: hidden;
    color: var(--muted);
    font-size: 0.875rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.fine-chip {
    flex: none;
    padding: 3px 10px;
    border: 1px solid var(--danger-line);
    border-radius: 999px;
    background: var(--danger-bg);
    color: var(--danger);
    font-weight: 600;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

/* Cuota distinta a la general */
.cuota-chip {
    flex: none;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.row-chevron {
    flex: none;
    color: var(--line-strong);
}

.list-empty {
    padding: 20px 16px;
    color: var(--muted);
    text-align: center;
}

/* Historial */
.day-group + .day-group {
    margin-top: 18px;
}

.day-label {
    padding: 0 4px 8px;
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.history-row {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
}

.history-row:first-child {
    border-top: none;
}

.history-row .avatar {
    width: 36px;
    height: 36px;
    font-size: 1rem;
}

.history-body {
    flex: 1;
    min-width: 0;
}

.history-text {
    font-size: 0.9375rem;
    line-height: 1.4;
}

.history-meta {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

/* Esqueleto de carga: bloques estáticos, sin animación */
.avatar.skeleton,
.skeleton-line {
    background: var(--line);
}

.skeleton-line {
    display: block;
    height: 12px;
    margin-top: 6px;
    border-radius: 6px;
}

.skeleton-line.short {
    width: 40%;
}

.empty-state {
    padding: 32px 20px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    text-align: center;
}

.empty-state strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.375rem;
}

.empty-state p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.9375rem;
}

/* ---------- Barra de pestañas (zona del pulgar) ---------- */

.tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: flex;
    justify-content: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--line);
    background: var(--surface);
}

/* Con el teclado abierto la barra estorba: se oculta mientras se escribe */
.admin-body:has(.app input:focus) .tabbar {
    display: none;
}

.tabbar-inner {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    width: 100%;
    max-width: 520px;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 60px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.tab-btn svg {
    transition: transform var(--dur-press) var(--ease-out);
}

.tab-btn:active svg {
    transform: scale(0.9);
}

.tab-btn[aria-selected="true"] {
    color: var(--brand);
}

.tab-btn:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: -6px;
    border-radius: 14px;
}

/* El toast no tapa la barra de pestañas */
.admin-body.in-app .egg-toast {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Hoja inferior (multas) ---------- */

.sheet {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-width: 520px;
    max-height: calc(100dvh - 32px);
    margin: 0 auto;
    padding: 0;
    border: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-pop);

    /* Sale por donde entró: hacia abajo */
    transform: translateY(100%);
    transition:
        transform 200ms var(--ease-drawer),
        overlay 200ms allow-discrete,
        display 200ms allow-discrete;
}

.sheet[open] {
    transform: none;
    transition:
        transform 300ms var(--ease-drawer),
        overlay 300ms allow-discrete,
        display 300ms allow-discrete;
}

@starting-style {
    .sheet[open] {
        transform: translateY(100%);
    }
}

.sheet::backdrop {
    background: rgba(3, 10, 28, 0.5);
    opacity: 0;
    transition:
        opacity 200ms var(--ease-out),
        overlay 200ms allow-discrete,
        display 200ms allow-discrete;
}

.sheet[open]::backdrop {
    opacity: 1;
}

@starting-style {
    .sheet[open]::backdrop {
        opacity: 0;
    }
}

.sheet-inner {
    max-height: inherit;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.sheet-head .icon-btn {
    margin: -8px -8px 0 0;
}

.sheet-kicker {
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 600;
}

.sheet-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.875rem;
    line-height: 1.1;
}

.sheet-sub {
    color: var(--muted);
}

/* Cuota personalizada: misma fila que las multas, con importe en vez de contador */
.money-compact {
    flex: none;
    width: 124px;
}

.money-compact span {
    right: 14px;
}

.money-field {
    height: 44px;
    padding: 0 32px 0 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.money-field[aria-invalid="true"] {
    border-color: var(--danger);
}

.cuota-row .multa-price.is-error {
    color: var(--danger);
}

/* Pago del mes (marcado manual): se guarda al momento, aparte del formulario */
.pago-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding: 12px 12px 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    transition: background-color 200ms var(--ease-out), border-color 200ms var(--ease-out);
}

.pago-row[data-pagado="true"] {
    border-color: transparent;
    background: var(--brand-soft);
}

.pago-row[data-pagado="true"] .multa-price {
    color: var(--brand);
    font-weight: 600;
}

.pago-btn {
    position: relative;
    flex: none;
    min-height: 44px;
    padding: 0 18px;
    border: 1.5px solid var(--brand);
    border-radius: 999px;
    background: var(--brand);
    color: var(--on-brand);
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--dur-press) var(--ease-out), background-color 150ms ease, color 150ms ease;
}

.pago-row[data-pagado="true"] .pago-btn {
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--ink);
}

.pago-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.pago-btn:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 2px;
}

.pago-btn:disabled {
    cursor: default;
}

.pago-row[data-pagado="true"] .pago-btn .btn-loader {
    border-color: var(--line);
    border-top-color: var(--brand);
}

.pago-btn.loading .btn-text {
    opacity: 0;
}

.pago-btn.loading .btn-loader {
    display: block;
}

@media (hover: hover) and (pointer: fine) {
    .pago-btn:hover:not(:disabled) {
        background: var(--brand-hover);
    }

    .pago-row[data-pagado="true"] .pago-btn:hover:not(:disabled) {
        background: var(--surface);
        border-color: var(--brand);
    }
}

#pagoStatus.active {
    margin-top: 8px;
}

.multa-rows {
    margin: 8px 0 16px;
}

.multa-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.multa-row:last-child {
    border-bottom: 1px solid var(--line);
}

.multa-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.multa-label {
    font-weight: 600;
}

.multa-price {
    color: var(--muted);
    font-size: 0.875rem;
}

.stepper {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.stepper-btn {
    width: 44px;
    height: 44px;
    border: 1.5px solid var(--line-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--brand);
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: transform var(--dur-press) var(--ease-out), border-color 150ms ease;
}

.stepper-btn:active:not(:disabled) {
    transform: scale(0.92);
    background: var(--brand-soft);
}

.stepper-btn:disabled {
    color: var(--line-strong);
    cursor: default;
}

.stepper-btn:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .stepper-btn:hover:not(:disabled) {
        border-color: var(--brand);
    }
}

.stepper-value {
    min-width: 2ch;
    font-family: var(--font-display);
    font-size: 1.625rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.multa-summary {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
}

.multa-summary div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 0;
    color: var(--muted);
}

.multa-summary dd {
    font-variant-numeric: tabular-nums;
}

.multa-summary div:last-child {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    font-weight: 600;
}

.sheet .submit-btn:disabled:not(.loading) {
    background: var(--line);
    color: var(--muted);
    box-shadow: none;
    cursor: default;
    opacity: 1;
}

/* ============================================
   CUENTAS DEL CADAFAL (página principal, público)
   Reutiliza .month-switch, .list-card, .fine-chip y .empty-state del panel
   ============================================ */

.resumen {
    padding: 22px 20px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    animation: rise 300ms var(--ease-out) 220ms backwards;
}

.resumen-heading {
    margin: 0;
}

/* Cabecera que abre y cierra el panel: toda la franja es pulsable */
.resumen-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: calc(100% + 16px);
    margin: -8px;
    padding: 8px;
    border: none;
    border-radius: var(--radius);
    background: none;
    color: inherit;
    text-align: left;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.resumen-toggle:focus-visible {
    outline: 3px solid var(--brand-ring);
}

.resumen-toggle:active {
    background: var(--bg);
}

@media (hover: hover) and (pointer: fine) {
    .resumen-toggle:hover {
        background: var(--bg);
    }
}

.resumen-toggle-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.resumen-toggle-sub {
    color: var(--muted);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 400;
}

.resumen-chevron {
    flex: none;
    color: var(--brand);
    transition: transform 200ms var(--ease-out);
}

.resumen-toggle[aria-expanded="true"] .resumen-chevron {
    transform: rotate(180deg);
}

.resumen-body {
    margin-top: 16px;
    animation: rise 200ms var(--ease-out);
}

.resumen-body[hidden] {
    display: none;
}

.resumen .month-switch {
    margin-top: 0;
}

.resumen-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.resumen-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 0.875rem;
}

.resumen-refresh:disabled {
    color: var(--muted);
    cursor: progress;
}

.resumen .list-card {
    box-shadow: none;
}

.month-badge {
    flex-basis: 100%;
    color: var(--brand);
    font-size: 0.8125rem;
    font-weight: 600;
}

.month-badge[hidden] {
    display: none;
}

.resumen-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 16px;
}

.resumen-stats div {
    min-width: 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg);
}

.resumen-stats dt {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.resumen-stats dd {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Barra de "han pagado": se escala, no cambia de ancho */
.resumen-progress {
    height: 8px;
    margin-top: 12px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.resumen-progress[hidden] {
    display: none;
}

.resumen-progress span {
    display: block;
    height: 100%;
    background: var(--brand);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 300ms var(--ease-out);
}

#resumenList {
    margin-top: 12px;
}

#resumenList .empty-state .link-btn {
    margin-top: 6px;
}

.resumen-group + .resumen-group {
    margin-top: 16px;
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
    padding: 10px 14px;
    border-top: 1px solid var(--line);
}

.status-row:first-child {
    border-top: none;
}

.status-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fine-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.fine-tag {
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 0.75rem;
    font-weight: 600;
}

.pay-pill {
    flex: none;
    padding: 4px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pay-pill.is-paid {
    border-color: transparent;
    background: var(--brand-soft);
    color: var(--brand);
}

.pay-pill.is-paid::before {
    content: '✓ ';
}

.resumen-rest {
    margin-top: 10px;
}

.resumen-rest:empty {
    display: none;
}

@media (max-width: 380px) {
    .resumen {
        padding: 20px 16px 16px;
    }

    .resumen-stats dd {
        font-size: 1.125rem;
    }
}

/* ============================================
   APP INSTALABLE Y AVISOS (js/avisos.js)
   ============================================ */

.app-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: 2px 12px;
    padding: 16px 10px 16px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    animation: rise 300ms var(--ease-out) 40ms backwards;
    transition:
        opacity var(--dur-exit) var(--ease-out),
        transform var(--dur-exit) var(--ease-out);
}

.app-card.is-leaving {
    opacity: 0;
    transform: scale(0.98);
}

.app-card-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand);
}

.app-card[data-mode="install"] .icon-bell,
.app-card[data-mode="avisos"] .icon-install {
    display: none;
}

.app-card-text {
    min-width: 0;
    padding-top: 2px;
}

.app-card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3125rem;
    line-height: 1.1;
    letter-spacing: 0.01em;
    color: var(--ink);
    text-wrap: balance;
}

.app-card-sub {
    margin-top: 4px;
    font-size: 0.9375rem;
    color: var(--muted);
    text-wrap: pretty;
}

.app-card-close {
    width: 40px;
    height: 40px;
    margin: -8px 0 0;
}

.app-card-btn {
    grid-column: 1 / -1;
    margin: 12px 6px 0 0;
    min-height: 48px;
    padding: 12px 16px;
    border: 1.5px solid transparent;
    border-radius: var(--radius);
    /* Secundario: la acción principal de la página sigue siendo «Enviar pago» */
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition:
        transform var(--dur-press) var(--ease-out),
        border-color 150ms ease;
}

.app-card-btn:active:not(:disabled) {
    transform: scale(0.97);
    border-color: var(--brand);
}

.app-card-btn:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .app-card-btn:hover:not(:disabled) {
        border-color: var(--brand);
    }
}

/* Sheet de instalación */
.os-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 16px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
}

.os-tab {
    min-height: 44px;
    border: none;
    border-radius: 9px;
    background: none;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition:
        transform var(--dur-press) var(--ease-out),
        background-color 150ms ease,
        color 150ms ease;
}

.os-tab[aria-selected="true"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.os-tab:active {
    transform: scale(0.97);
}

.os-tab:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 1px;
}

.install-steps {
    list-style: none;
    margin-top: 8px;
}

.install-steps li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.install-steps li:first-child {
    border-top: none;
}

.step-n {
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.0625rem;
}

.install-steps li > span:last-child {
    padding-top: 3px;
}

.step-glyph {
    display: inline-block;
    vertical-align: -3px;
    margin: 0 2px;
    color: var(--brand);
}

.install-now {
    margin-top: 8px;
    box-shadow: none;
}

/* Sheet de avisos: elegir persona */
.person-pick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
}

.person-opt {
    min-height: 48px;
    padding: 10px 12px;
    border: 1.5px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    font-size: 0.9375rem;
    text-align: left;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition:
        transform var(--dur-press) var(--ease-out),
        border-color 150ms ease,
        background-color 150ms ease;
}

.person-opt:active:not(:disabled),
.person-opt[aria-pressed="true"] {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.person-opt:active:not(:disabled) {
    transform: scale(0.97);
}

.person-opt:disabled {
    cursor: progress;
    opacity: 0.55;
}

.person-opt[aria-pressed="true"]:disabled {
    opacity: 1;
}

.person-opt:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .person-opt:hover:not(:disabled) {
        border-color: var(--brand);
    }
}

.avisos-status {
    min-height: 1.45em;
    margin-top: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--muted);
}

.avisos-status.error {
    color: var(--danger);
}

.avisos-status.ok {
    color: var(--brand);
}

.footer-avisos {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0 6px;
}

.footer-avisos .link-btn {
    padding: 6px 2px;
}

/* Panel: pestaña App (filas informativas, no pulsables) */
.app-row {
    cursor: default;
}

.app-row:active {
    background: none;
}

#tabApp .hero-card {
    margin-bottom: 14px;
}

#appHint {
    margin-bottom: 10px;
}

/* ============================================
   ENTRADA
   ============================================ */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 380px) {
    .logo {
        width: 72px;
        height: 72px;
    }

    .header h1 {
        font-size: 2.25rem;
    }

    .form-container {
        padding: 24px 16px 20px;
    }

    .success-text h2 {
        font-size: 2rem;
    }
}

/* ============================================
   MOVIMIENTO REDUCIDO: menos y más suave, no cero
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .header,
    .form-container,
    .form-group,
    .resumen {
        animation-name: fade;
    }

    .resumen-progress span,
    .resumen-chevron {
        transition: none;
    }

    .resumen-body {
        animation-name: fade;
    }

    /* La hoja aparece con un fundido, sin desplazarse */
    .sheet,
    .sheet[open] {
        transform: none;
        opacity: 0;
        transition:
            opacity 200ms var(--ease-out),
            overlay 200ms allow-discrete,
            display 200ms allow-discrete;
    }

    .sheet[open] {
        opacity: 1;
    }

    @starting-style {
        .sheet[open] {
            transform: none;
            opacity: 0;
        }
    }

    .dropdown-menu,
    .dropdown-menu.active,
    .status-message,
    .status-message.active,
    .file-name,
    .success-video-frame,
    .success-text,
    .file-icon svg {
        transform: none;
    }

    .egg-toast,
    .egg-toast.show {
        transform: translate(-50%, 0);
    }

    .status-message.error.active,
    .logo.charge,
    body.mascleta .container {
        animation: none;
    }

    .submit-btn:active:not(:disabled),
    .logo:active,
    .file-label:active,
    .credit:active,
    .who-btn:active,
    .stepper-btn:active:not(:disabled),
    .icon-btn:active:not(:disabled),
    .hero-btn:active:not(:disabled),
    .pago-btn:active:not(:disabled),
    .tab-btn:active svg {
        transform: none;
    }

    .submit-btn:hover:not(:disabled) .btn-arrow {
        transform: none;
    }

    .app-card {
        animation-name: fade;
    }

    .app-card.is-leaving,
    .app-card-btn:active:not(:disabled),
    .os-tab:active,
    .person-opt:active:not(:disabled) {
        transform: none;
    }
}
