/* ══════════════════════════════════════════════════════
   Universitario 5 — Portal Estudiantil
   Mobile-first · Branding dinámico por tenant
   ══════════════════════════════════════════════════════ */

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

:root {
    --primary:     #0c706d;
    --primary-rgb: 12, 112, 109;
    --accent:      #dd6542;
    --bg:          #f7f5ef;
    --surface:     #fffefa;
    --surface-2:   #f1f4ed;
    --border:      #d8e1dc;
    --text:        #17324d;
    --text-2:      #52697a;
    --text-3:      #81908f;
    --field-bg:    #ffffff;
    --field-text:  #000000;
    --field-placeholder: #6b7280;
    --danger:      #e53935;
    --success:     #2e7d32;
    --warning:     #f57f17;
    --radius-sm:   8px;
    --radius:      12px;
    --radius-lg:   20px;
    --shadow-sm:   0 2px 8px rgba(23,50,77,.07);
    --shadow:      0 7px 18px rgba(23,50,77,.10);
    --shadow-lg:   0 18px 42px rgba(23,50,77,.18);
    --header-h:    58px;
    --nav-h:       66px;
    --transition:  .18s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 600;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-160%);
    transition: transform var(--transition);
}

.skip-link:focus { transform: translateY(0); }

input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="range"]):not([type="color"]),
select,
textarea {
    background-color: var(--field-bg);
    color: var(--field-text);
    caret-color: var(--field-text);
}

input:not([type="checkbox"]):not([type="radio"])::placeholder,
textarea::placeholder {
    color: var(--field-placeholder);
    opacity: 1;
}

select option {
    background-color: var(--field-bg);
    color: var(--field-text);
}

/* ── Tipografía ──────────────────────────────────────── */
h1, h2, h3 { font-weight: 700; line-height: 1.18; letter-spacing: -.02em; }
p          { line-height: 1.5; }

/* ══════════════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════════════ */

#loginScreen {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background:
        radial-gradient(circle at 84% 12%, rgba(84, 166, 160, .32), transparent 31%),
        linear-gradient(155deg, #064f50 0%, #0c706d 100%);
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 36px 28px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255,255,255,.75);
}

/* Logo de la escuela */
.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 28px;
    text-align: center;
}

.logo-wrapper {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(var(--primary-rgb), .07);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.logo-placeholder svg { stroke: var(--primary); opacity: .6; }

.school-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.platform-tag {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
    background: var(--bg);
    padding: 2px 10px;
    border-radius: 20px;
}

/* Campos */
.field { margin-bottom: 14px; }

.field label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.field input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    color: var(--field-text);
    background: var(--field-bg);
    transition: border-color var(--transition);
    -webkit-appearance: none;
}

.field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}

/* Botón de mostrar/ocultar contraseña */
.toggle-pass {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    padding: 4px;
    display: flex;
}

.toggle-pass:hover { color: var(--text-2); }

/* Botón de login */
.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: .95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity var(--transition), transform var(--transition);
    letter-spacing: .02em;
}

.btn-login:hover:not(:disabled) { opacity: .92; }
.btn-login:active { transform: scale(.98); }
.btn-login:disabled { opacity: .55; cursor: not-allowed; }

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .65s linear infinite;
    flex-shrink: 0;
}

.login-error {
    color: var(--danger);
    font-size: .83rem;
    margin-top: 12px;
    text-align: center;
    display: none;
    animation: shake .3s ease;
}

.login-help {
    font-size: .78rem;
    color: var(--text-3);
    text-align: center;
    margin-top: 16px;
}

@keyframes shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

/* ══════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════ */

#appShell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* ── Header ──────────────────────────────────────────── */

.portal-header {
    position: sticky;
    top: 0;
    z-index: 200;
    height: var(--header-h);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px 0 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.22);
    /* Safe area para notch */
    padding-top: env(safe-area-inset-top);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.header-logo {
    height: 34px;
    border-radius: 6px;
    flex-shrink: 0;
}

.header-titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header-school {
    font-size: .9rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-period {
    font-size: .72rem;
    opacity: .75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 8px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1.5px solid rgba(255,255,255,.3);
}

.btn-menu {
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    flex-shrink: 0;
}

.btn-menu:hover { background: rgba(255,255,255,.22); }

/* ── Drawer ──────────────────────────────────────────── */

.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 300;
}

.drawer-overlay.open { display: block; }

.drawer {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100dvh;
    background: var(--surface);
    z-index: 301;
    display: flex;
    flex-direction: column;
    transition: right .25s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
    padding-top: env(safe-area-inset-top);
}

.drawer.open { right: 0; }

.drawer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    background: var(--primary);
    color: #fff;
}

.drawer-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,.3);
    flex-shrink: 0;
}

.drawer-name  { font-weight: 700; font-size: .95rem; }
.drawer-email { font-size: .75rem; opacity: .8; margin-top: 2px; }

.drawer-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: none;
    color: var(--text-2);
    font-size: .9rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 2px;
    text-align: left;
    transition: background var(--transition), color var(--transition);
}

.drawer-item:hover { background: var(--bg); color: var(--text); }
.drawer-item.active { background: rgba(var(--primary-rgb),.1); color: var(--primary); font-weight: 700; }
.drawer-item svg { flex-shrink: 0; }

.drawer-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.drawer-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: none;
    color: var(--danger);
    font-size: .88rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
}

.drawer-logout:hover { background: #fdecea; }

/* ── Contenido principal ─────────────────────────────── */

.portal-main {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.tab-pane {
    display: none;
    position: absolute;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--nav-h) + 12px);
}

.tab-pane.active {
    display: block;
    animation: fadeIn .2s ease;
}

.pane-inner {
    padding: 16px;
    max-width: 680px;
    margin: 0 auto;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Barra de navegación inferior ────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 200;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: .68rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    padding-bottom: env(safe-area-inset-bottom);
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.nav-btn svg  { width: 22px; height: 22px; transition: transform .15s; }
.nav-btn span { letter-spacing: .02em; }

.nav-btn.active       { color: var(--primary); }
.nav-btn.active svg   { transform: scale(1.08); }

/* ══════════════════════════════════════════════════════
   COMPONENTES COMPARTIDOS
═══════════════════════════════════════════════════════ */

/* Tarjeta */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 8px;
}

/* Divider */
.divider {
    height: 1px;
    background: var(--border);
    margin: 10px 0;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
}

.badge-success { background: #e8f5e9; color: var(--success); }
.badge-warning { background: #fff8e1; color: var(--warning); }
.badge-danger  { background: #fce4e4; color: var(--danger);  }
.badge-neutral { background: var(--bg); color: var(--text-2); }
.badge-primary { background: rgba(var(--primary-rgb),.1); color: var(--primary); }

/* Chips de fecha/periodo */
.chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: .72rem;
    background: var(--bg);
    color: var(--text-2);
    font-weight: 500;
}

/* ── Skeletons de carga ───────────────────────────────── */

.skeleton-list { padding: 4px 0; }

.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, #eaedf0 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.skeleton-card { height: 120px; }
.skeleton-row  { height: 60px; }

@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Estado vacío / carga ─────────────────────────────── */

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-3);
    gap: 12px;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 20px;
    color: var(--text-3);
    gap: 10px;
}

.empty-state svg { opacity: .35; }
.empty-state p   { font-size: .9rem; }

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

/* ══════════════════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════════════════ */

.welcome-card {
    background: linear-gradient(135deg, var(--primary) 0%, #0d2a45 100%);
    border-radius: var(--radius-lg);
    padding: 22px 20px;
    color: #fff;
    margin-bottom: 14px;
    position: relative;
    overflow: hidden;
}

.welcome-card::after {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,.06);
}

.welcome-greeting { font-size: .8rem; opacity: .8; margin-bottom: 4px; }
.welcome-name     { font-size: 1.3rem; font-weight: 800; }
.welcome-meta     { font-size: .78rem; opacity: .75; margin-top: 6px; }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.stat-tile {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: .72rem;
    color: var(--text-3);
    margin-top: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.stat-tile.highlight .stat-value { color: var(--danger); }

.quick-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.quick-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    font-family: inherit;
    transition: background var(--transition);
    box-shadow: var(--shadow-sm);
    -webkit-tap-highlight-color: transparent;
}

.quick-link:hover { background: var(--bg); }
.quick-link svg   { flex-shrink: 0; stroke: var(--primary); }

/* ══════════════════════════════════════════════════════
   HORARIO
═══════════════════════════════════════════════════════ */

.schedule-group { margin-bottom: 16px; }

.schedule-group-name {
    font-size: .78rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 6px 0 4px;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 10px;
}

.day-section { margin-bottom: 14px; }

.day-chip {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    background: rgba(var(--primary-rgb), .1);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 8px;
}

.subject-item {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    align-items: start;
}

.subject-item:last-child { border-bottom: none; }

.subject-time {
    font-size: .78rem;
    color: var(--text-2);
    font-weight: 500;
    padding-top: 2px;
}

.subject-name {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.subject-teacher {
    font-size: .75rem;
    color: var(--text-3);
    margin-top: 2px;
}

/* ══════════════════════════════════════════════════════
   CALIFICACIONES
═══════════════════════════════════════════════════════ */

.period-section { margin-bottom: 16px; }

.period-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-2);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.grade-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.grade-item:last-child { border-bottom: none; }

.grade-info { flex: 1; min-width: 0; }

.grade-subject {
    font-size: .88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grade-teacher-name {
    font-size: .74rem;
    color: var(--text-3);
    margin-top: 2px;
}

.grade-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.grade-pill {
    font-size: .9rem;
    font-weight: 800;
    min-width: 44px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.grade-a { background: #e8f5e9; color: #2e7d32; }  /* ≥ 8   */
.grade-b { background: #fff8e1; color: #f57f17; }  /* 6-7.9 */
.grade-c { background: #fce4e4; color: #c62828; }  /* < 6   */
.grade-n { background: var(--bg); color: var(--text-3); } /* sin calificación */

.attend-pill {
    font-size: .7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(var(--primary-rgb),.08);
    color: var(--primary);
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════
   ESTADO DE CUENTA
═══════════════════════════════════════════════════════ */

.account-hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.balance-card {
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.balance-card.pending {
    background: #fff8e1;
    border: 1px solid #ffe082;
}

.balance-card.paid {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
}

.balance-amount {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
}

.balance-card.pending .balance-amount { color: var(--warning); }
.balance-card.paid    .balance-amount { color: var(--success); }

.balance-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: 6px;
    opacity: .75;
}

/* Ítem del talonario */
.charge-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.charge-item:last-child { border-bottom: none; }

.charge-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.charge-name {
    font-size: .9rem;
    font-weight: 600;
    flex: 1;
}

.charge-amount-col {
    text-align: right;
    flex-shrink: 0;
}

.charge-amount {
    font-size: .95rem;
    font-weight: 800;
    color: var(--text);
}

.charge-amount.struck {
    text-decoration: line-through;
    color: var(--text-3);
    font-size: .8rem;
    font-weight: 400;
    display: block;
}

.charge-final {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary);
}

.charge-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.due-label {
    font-size: .72rem;
    font-weight: 700;
    color: var(--danger);
}

.adj-block {
    margin-top: 7px;
    padding: 7px 10px;
    background: #fff8e1;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.adj-row {
    font-size: .75rem;
    color: #795548;
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
}

.btn-pay {
    width: 100%;
    margin-top: 12px;
    padding: 13px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-pay:hover { opacity: .9; }

/* Historial de caja */
.payment-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.payment-row:last-child { border-bottom: none; }

.payment-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    stroke: var(--success);
}

.payment-info { flex: 1; min-width: 0; }
.payment-receipt { font-size: .86rem; font-weight: 600; }
.payment-date    { font-size: .74rem; color: var(--text-3); margin-top: 2px; }
.payment-amount  { font-size: .95rem; font-weight: 800; color: var(--success); flex-shrink: 0; }

/* ══════════════════════════════════════════════════════
   BOTTOM SHEET DE PAGO
═══════════════════════════════════════════════════════ */

.sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 400;
    backdrop-filter: blur(2px);
}

.sheet-backdrop.open { display: block; }

.payment-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    z-index: 401;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    box-shadow: var(--shadow-lg);
    transition: bottom .3s cubic-bezier(.4,0,.2,1);
    padding-bottom: env(safe-area-inset-bottom);
    max-height: 92dvh;
    overflow-y: auto;
}

.payment-sheet.open { bottom: 0; }

.sheet-drag-bar {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto 0;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 10px;
}

.sheet-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.sheet-close {
    background: var(--bg);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-2);
    transition: background var(--transition);
}

.sheet-close:hover { background: var(--border); }

.sheet-body { padding: 4px 20px 20px; }

.sheet-concept-label {
    font-size: .78rem;
    color: var(--text-3);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sheet-amount-display {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin: 4px 0 18px;
    line-height: 1;
}

.sheet-section-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-3);
    margin-bottom: 9px;
    margin-top: 16px;
}

/* Método de pago */
.method-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 2px;
}

.method-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    font-size: .78rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-2);
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.method-card:hover:not(:disabled) { border-color: var(--primary); background: rgba(var(--primary-rgb),.04); }
.method-card.selected { border-color: var(--primary); background: rgba(var(--primary-rgb),.08); color: var(--primary); }
.method-card:disabled { opacity: .4; cursor: not-allowed; }
.method-card svg { stroke: currentColor; }

/* Gateway */
.gateway-chips {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.gw-chip {
    padding: 7px 14px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    font-size: .8rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.gw-chip:hover   { border-color: var(--primary); color: var(--primary); }
.gw-chip.selected { border-color: var(--primary); background: var(--primary); color: #fff; }

/* Resultado del pago */
.sheet-result {
    margin-top: 14px;
    border-radius: var(--radius);
    padding: 14px;
    font-size: .85rem;
    line-height: 1.6;
    display: none;
}

.sheet-result.show { display: block; }
.sheet-result.success { background: #e8f5e9; color: #1b5e20; }
.sheet-result.error   { background: #fce4e4; color: #b71c1c; }
.sheet-result.loading { background: #fff8e1; color: #795548; }

.sheet-result code {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: .06em;
    margin: 6px 0;
    color: inherit;
}

/* Botón confirmar pago */
.btn-pay-confirm {
    width: 100%;
    margin-top: 18px;
    padding: 15px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: .95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity var(--transition);
    letter-spacing: .02em;
}

.btn-pay-confirm:hover:not(:disabled) { opacity: .92; }
.btn-pay-confirm:disabled { opacity: .55; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════
   NOTIFICACIÓN TOAST
═══════════════════════════════════════════════════════ */

.toast {
    position: fixed;
    bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a1d23;
    color: #fff;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: .83rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 500;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    box-shadow: var(--shadow);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ══════════════════════════════════════════════════════
   RESPONSIVE — ESCRITORIO
═══════════════════════════════════════════════════════ */

@media (min-width: 640px) {
    .pane-inner  { padding: 20px 24px; }
    .stats-grid  { grid-template-columns: repeat(3, 1fr); }

    .payment-sheet {
        left: 50%;
        right: auto;
        /* El sheet debe quedar totalmente fuera del viewport antes de abrirse. */
        transform: translateX(-50%) translateY(120dvh);
        width: 460px;
        border-radius: var(--radius-lg);
        bottom: auto;
        top: 50%;
        margin-top: -10px;
        transition: transform .3s cubic-bezier(.4,0,.2,1);
    }

    .payment-sheet.open {
        bottom: auto;
        transform: translateX(-50%) translateY(-50%);
    }

    .bottom-nav { display: none; }

    .portal-header { padding: 0 24px; }

    /* En desktop mostrar tabs en el header */
    .portal-main { padding-bottom: 0; }
    .tab-pane    { padding-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
