html {
    font-size: 14px;
    /* Mismo fondo que <body> — sin esto, el efecto rebote (rubber-band) de
       Safari en iOS al pasar el borde superior/inferior de una página con
       scroll muestra el fondo de <html> (blanco por defecto), no el de
       <body>. No se notaba mientras .auth-page-body bloqueaba el scroll con
       overflow:hidden; al liberarlo (fix de mobile en auth) quedó expuesto. */
    background: var(--page-bg);
    background-color: var(--page-bg-color); /* debajo del degradado: es el color que usa iOS Safari para sus barras y el rebote */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--page-bg);
    background-color: var(--page-bg-color); /* debajo del degradado: es el color que usa iOS Safari para sus barras y el rebote */
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh; /* en móvil 100vh ignora la barra de direcciones; 100vh queda de respaldo */
}

a {
    color: inherit;
    text-decoration: none;
}

/* El chrome/mecánica del sidebar (.app-sidebar*, .app-nav*, .app-topbar*,
   .app-shell, .app-main-shell, .app-overlay, body.sidebar-open/-collapsed)
   se movió a Commons/UIMetadata/UiMetadata.Sidebar/wwwroot/css/sidebar.css —
   corte y pegado literal (mismos selectores/variables), sin retokenizar. */

.profile-page {
    display: grid;
    gap: 1.5rem;
}

/* .profile-card se movió a UiMetadata.Elements (.ui-settings-card) — ver
   docs/reusability-audit.md. Estas reglas quedan solo para .profile-header-card
   (la tarjeta de cabecera de Perfil, no repetida, no extraída). */
.profile-header-card {
    position: relative;
    overflow: hidden;
    border-radius: 1.9rem;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg-soft);
    box-shadow: var(--chart-card-shadow);
}

.profile-header-card {
    padding: 1.6rem;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    gap: 1.2rem;
}

.profile-header-card::before {
    content: "";
    position: absolute;
    inset: auto -8% -22% auto;
    width: 260px;
    height: 260px;
    border-radius: 999px;
    background: var(--interactive-accent-glow);
    filter: blur(28px);
    opacity: 0.7;
    pointer-events: none;
}

.profile-header-copy,
.profile-status-stack,
.profile-form,
.profile-alert {
    position: relative;
    z-index: 1;
}

.profile-eyebrow {
    display: inline-flex;
    width: fit-content;
    padding: 0.38rem 0.7rem;
    border-radius: 999px;
    background: var(--interactive-accent-contrast);
    color: var(--color-primary-light);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.profile-header-copy {
    display: grid;
    gap: 0.8rem;
    align-content: center;
}

.profile-header-copy h1 {
    margin: 0;
    color: var(--text-main-strong);
    letter-spacing: -0.04em;
    font-size: clamp(2rem, 3vw, 3rem);
}

.profile-header-copy p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.6;
}

.profile-status-stack {
    display: grid;
    gap: 0.9rem;
}

.profile-stat-card,
.profile-meta-card {
    padding: 1rem 1.05rem;
    border-radius: 1.25rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border-soft);
    box-shadow: inset 0 1px 0 var(--glass-highlight-soft);
}

.profile-stat-card strong,
.profile-meta-value {
    display: block;
    color: var(--text-main-strong);
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0.25rem 0;
}

.profile-stat-label,
.profile-meta-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.profile-stat-text {
    color: var(--text-soft);
    font-size: 0.92rem;
    line-height: 1.5;
}

.profile-form {
    display: grid;
    gap: 1.15rem;
}

.profile-field-grid,
.profile-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.profile-field {
    display: grid;
    gap: 0.45rem;
}

.profile-field label {
    color: var(--text-main-strong);
    font-size: 0.92rem;
    font-weight: 600;
}

.profile-field input,
.profile-field select {
    width: 100%;
    min-height: 3.2rem;
    padding: 0.88rem 1rem;
    border-radius: 1rem;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-main);
    outline: none;
    font: inherit;
    /* 16px fijo DESPUÉS de font:inherit (que hereda los 14px reales del
       html{font-size:14px} de arriba) — mismo fix puntual que el resto de
       inputs de la app, evita el zoom automático de iOS Safari al foco.
       El resto del shorthand `font` (family/weight/line-height) se mantiene
       heredado, solo el tamaño se fija. */
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.profile-field select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.6rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7.5 10 12.5 15 7.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    cursor: pointer;
}

/* El <select> cerrado hereda el tema vía --input-bg (semitransparente sobre el
   fondo oscuro de la página), pero la lista desplegable nativa se pinta en una
   capa del SO sin ese fondo detrás — hay que darle a los <option> un color
   sólido explícito o el navegador los muestra en blanco por defecto. */
.profile-field select option {
    background: var(--select-option-bg);
    color: var(--text-main);
}

.profile-field input:focus,
.profile-field select:focus {
    border-color: var(--input-border-strong);
    background-color: var(--input-bg-focus);
    box-shadow: var(--input-shadow-focus);
}

.profile-validation {
    color: var(--error-text);
    font-size: 0.82rem;
    line-height: 1.4;
}

.profile-provider-badges {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.profile-provider-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: var(--interactive-accent-contrast);
    border: 1px solid var(--interactive-accent-border);
    color: var(--text-main-strong);
    font-size: 0.84rem;
    font-weight: 600;
}

.profile-actions {
    display: flex;
    justify-content: flex-end;
}

.notif-prefs-table {
    width: 100%;
    border-collapse: collapse;
}

.notif-prefs-table th,
.notif-prefs-table td {
    padding: 0.55rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
}

.notif-prefs-table th:not(:first-child),
.notif-prefs-table td:not(:first-child) {
    text-align: center;
    width: 5.5rem;
}

.notif-prefs-table thead th {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.notif-prefs-group td {
    padding-top: 1.1rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: none;
}

.notif-prefs-table input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--color-primary);
    cursor: pointer;
}

@media (max-width: 599px) {
    .notif-prefs-table {
        font-size: 0.85rem;
    }
}

.profile-submit {
    min-height: 3.2rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-secondary));
    color: var(--text-on-accent);
    font-weight: 700;
    box-shadow: var(--button-shadow-cta);
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.profile-submit--danger {
    background: linear-gradient(135deg, var(--color-danger, #ef4444), var(--color-danger-strong, #b91c1c));
    box-shadow: 0 3px 12px rgba(239,68,68,.35);
}

.profile-submit--danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

/* .profile-danger-card/.profile-panel-kicker--danger se movieron a
   UiMetadata.Elements (.ui-settings-card.is-danger/.ui-settings-card-kicker--danger). */

.profile-danger-confirm {
    margin-bottom: 1.2rem;
}

.profile-danger-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    color: var(--text-soft);
    font-size: 0.92rem;
    line-height: 1.5;
    user-select: none;
}

.profile-danger-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.profile-danger-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.profile-danger-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-soft, #d1d5db);
    border-radius: 24px;
    transition: background 0.3s ease;
    cursor: pointer;
}

.profile-danger-toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.profile-danger-toggle input:checked + .profile-danger-toggle-slider {
    background: var(--color-danger, #ef4444);
}

.profile-danger-toggle input:checked + .profile-danger-toggle-slider::before {
    transform: translateX(20px);
}

.profile-submit:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.profile-alert {
    margin-bottom: 1rem;
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    border: 1px solid var(--glass-border-soft);
    background: var(--glass-bg);
    color: var(--text-main);
}

.profile-alert-success,
.profile-alert-info {
    border-color: var(--interactive-accent-border);
    background: var(--interactive-accent-contrast);
    color: var(--text-main-strong);
}

/* Descripción legible del campo "Expresión cron" (ScheduledTransaction) —
   ver scheduledTransaction.js/updateCronDescription y TransactionController.
   DescribeCron (Commons.CronDescription). */
.cron-description {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-soft);
}

.cron-description-error {
    color: var(--color-danger, #ef4444);
}

.cron-description-warning {
    display: inline-block;
    margin-top: 0.2rem;
    color: var(--color-danger, #ef4444);
}

.profile-alert-warning {
    border-color: var(--warning-border);
    background: var(--warning-bg);
    color: var(--warning-text);
}

.profile-alert-danger {
    border-color: var(--error-border);
    background: var(--error-bg);
    color: var(--error-text);
}

.profile-alert ul {
    margin: 0;
    padding-left: 1rem;
}

.view-container {
    margin: auto;
    padding: 1.25rem;
}

.settlement-summary {
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--glass-border-soft);
    background: var(--bg-card);
}

.settlement-summary h3 {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    color: var(--text-main-strong);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settlement-summary h3::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary-light);
    flex: none;
}

.settlement-summary .settlement-empty {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.settlement-debt-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.settlement-debt-row {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 1rem 0.6rem 0.6rem;
    border-radius: 999px;
    background: var(--bg-main-accent);
    border: 1px solid var(--glass-border-soft);
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.settlement-debt-row:hover {
    border-color: var(--interactive-accent-border);
    transform: translateY(-1px);
}

.settlement-avatar {
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
}

.settlement-debt-name {
    color: var(--text-main-strong);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.settlement-debt-verb {
    color: var(--text-soft);
    font-size: 0.85rem;
    flex: none;
}

.settlement-debt-amount {
    flex: none;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--danger-text);
    white-space: nowrap;
}

.settlement-debt-arrow {
    color: var(--text-soft);
    flex: none;
    font-size: 0.8rem;
}

.pending-settlement-banner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.pending-settlement-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--interactive-accent-border, var(--glass-border-soft));
    background: var(--bg-main-accent);
    color: var(--text-main-strong);
    font-size: 0.9rem;
}

.pending-settlement-row > span { flex: 1 1 auto; }

.settlement-debt-settle-btn {
    flex: none;
    margin-left: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    border: none;
    background: var(--color-primary-light, #2563eb);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.settlement-global-kpi {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.settlement-global-kpi .kpi-amount {
    font-size: 1.4rem;
    font-weight: 700;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.primary-btn {
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    color: var(--text-on-accent);
    padding: 0.75rem 1.8rem;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--button-shadow-soft);
    transition: all 0.3s ease;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--button-shadow-strong);
}

/* ── Claim Invitation ─────────────────────────────────── */
.claim-invitation-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: calc(2rem + env(safe-area-inset-top, 0px)) calc(2rem + env(safe-area-inset-right, 0px))
             calc(2rem + env(safe-area-inset-bottom, 0px)) calc(2rem + env(safe-area-inset-left, 0px));
}

.claim-invitation-card {
    width: 100%;
    max-width: 440px;
    padding: 2.4rem;
    border-radius: 2rem;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg-soft);
    box-shadow: var(--chart-card-shadow);
    display: grid;
    gap: 1.2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

    .claim-invitation-card::before {
        content: "";
        position: absolute;
        inset: auto -8% -22% auto;
        width: 260px;
        height: 260px;
        border-radius: 999px;
        background: var(--interactive-accent-glow);
        filter: blur(28px);
        opacity: 0.7;
        pointer-events: none;
    }

.claim-invitation-avatar {
    position: relative;
    z-index: 1;
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary-strong));
    color: var(--text-on-accent);
    font-size: 1.8rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    box-shadow: var(--sidebar-brand-shadow);
}

.claim-invitation-card h2 {
    position: relative;
    z-index: 1;
    margin: 0;
    color: var(--text-main-strong);
    font-size: 1.4rem;
    letter-spacing: -0.03em;
}

.claim-invitation-info {
    position: relative;
    z-index: 1;
    margin: 0;
    color: var(--text-main);
    font-size: 1rem;
    line-height: 1.6;
}

.claim-invitation-sub {
    position: relative;
    z-index: 1;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.6;
}

.claim-invitation-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    margin-top: 0.4rem;
}

    .claim-invitation-actions .btn-primary,
    .claim-invitation-actions .btn-secondary {
        min-height: 3rem;
        padding: 0.75rem 1.6rem;
        border-radius: 999px;
        border: none;
        font-size: 0.95rem;
        font-weight: 600;
        cursor: pointer;
        transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
    }

    .claim-invitation-actions .btn-primary {
        background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary-strong));
        color: var(--text-on-accent);
        box-shadow: var(--button-shadow-cta);
    }

        .claim-invitation-actions .btn-primary:hover {
            transform: translateY(-1px);
            filter: brightness(1.05);
        }

    .claim-invitation-actions .btn-secondary {
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        color: var(--text-soft);
    }

        .claim-invitation-actions .btn-secondary:hover {
            background: var(--glass-bg-stronger);
            border-color: var(--glass-border-strong);
            color: var(--text-main);
        }

/* 599px — breakpoint móvil acordado en la auditoría responsive (Fase 2),
   antes 480px sin relación con el resto del sistema. */
@media (max-width: 599px) {
    .view-container {
        padding: 0;
    }

    .claim-invitation-card {
        padding: 1.8rem 1.4rem;
    }

    .claim-invitation-actions {
        flex-direction: column;
    }

        .claim-invitation-actions .btn-primary,
        .claim-invitation-actions .btn-secondary {
            width: 100%;
        }
}

/* 1023px — mismo breakpoint tablet/desktop que sidebar.css, antes 991.98px
   (coincidían por casualidad, no por una variable compartida). */
@media (max-width: 1023px) {

    /* minmax(0, 1fr), no "1fr" a secas — mismo bug que .auth-shell en
       auth.css: sin el minmax(0, ...), un grid track no se encoge por
       debajo del ancho mínimo de su contenido (min-width:auto implícito en
       los ítems de grid), y una tarjeta con contenido ancho (ej. el código
       QR/las casillas de 2FA en TwoFactor/Setup) puede desbordar el
       viewport en vez de ajustarse. */
    .profile-header-card,
    .profile-field-grid,
    .profile-meta-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* 599px — breakpoint móvil acordado, antes 640px. */
@media (max-width: 599px) {
    .profile-header-card {
        padding: 1.2rem;
        border-radius: 1.5rem;
    }

    .profile-actions {
        justify-content: stretch;
    }

    .profile-submit {
        width: 100%;
    }
}

/* Campana de notificaciones (UiMetadata.Notifications) alineada a la derecha de la barra superior. */
.app-topbar .ui-notif { margin-left: auto; }

/* Aviso de "hay una versión nueva" (js/pwa.js). Abajo, por encima de la zona segura del iPhone. */
.update-banner {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: calc(100vw - 2rem);
    padding: 0.6rem 0.75rem 0.6rem 1rem;
    border-radius: 999px;
    color: var(--text-on-accent, #fff);
    background: linear-gradient(90deg, var(--color-primary, #6d4aff), var(--color-secondary, #a855f7));
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    font-size: 0.9rem;
}

.update-banner-text { min-width: 0; }

.update-banner-action,
.update-banner-close {
    min-height: 44px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    color: inherit;
    font: inherit;
}

.update-banner-action {
    padding: 0 1rem;
    font-weight: 600;
    background: rgba(255, 255, 255, .22);
}

.update-banner-close {
    width: 44px;
    font-size: 1.4rem;
    line-height: 1;
    background: transparent;
}

@media (prefers-reduced-motion: no-preference) {
    .update-banner { animation: update-banner-in .25s ease-out; }
}

@keyframes update-banner-in {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}
