/**
 * Academia de Méritos — Design System v1
 * ----------------------------------------------------------------------
 * Capa de COMPONENTES UI consistentes para toda la app.
 * Depende de los tokens definidos en `color-palette-optimized.css`.
 *
 * Convenciones:
 *  - Todas las clases del DS usan el prefijo `am-`
 *  - No se usan `!important` salvo en utilidades de reset
 *  - Mobile-first, breakpoints: 520, 768, 1024, 1280
 *  - Compatible con cualquier página HTML existente (no rompe estilos viejos)
 *
 * Componentes incluidos:
 *  - Layout: am-page, am-page-header, am-page-title, am-section, am-container
 *  - Breadcrumb: am-breadcrumb
 *  - Hero/banner: am-hero
 *  - Cards: am-card, am-card-grid, am-stat-card
 *  - Botones: am-btn (.am-btn--primary, --secondary, --ghost, --danger, --sm, --lg, --block)
 *  - Inputs: am-input, am-textarea, am-select, am-label, am-field
 *  - Badges: am-badge (--success, --warning, --danger, --info)
 *  - Alerts: am-alert
 *  - Tabs: am-tabs
 *  - Toast: am-toast (vía JS opcional)
 *  - Empty state: am-empty
 *  - Skeleton: am-skeleton
 *  - Footer: am-footer
 * ====================================================================== */

/* =====================================================================
   1. RESET SUAVE Y BASE TIPOGRÁFICA
   ===================================================================== */
.am-page,
.am-page * {
    box-sizing: border-box;
}

.am-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    color: var(--text-primary, #1f2937);
    font-size: var(--font-size-base, 1rem);
    line-height: 1.55;
}

/* =====================================================================
   2. LAYOUT — Contenedor de página y secciones
   ===================================================================== */
.am-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md, 16px);
}

.am-section {
    padding: var(--spacing-lg, 24px) 0;
}

.am-section + .am-section {
    border-top: 1px solid var(--border-light, #e5e7eb);
}

/* Page header (título principal + subtítulo + acciones) */
.am-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md, 16px);
    flex-wrap: wrap;
    margin-bottom: var(--spacing-lg, 24px);
}

.am-page-title {
    margin: 0;
    font-size: clamp(1.25rem, 2.2vw, 1.75rem);
    font-weight: 700;
    color: var(--text-primary, #1f2937);
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.2;
}

.am-page-title i {
    color: var(--primary-700, #2563eb);
    font-size: 0.9em;
}

.am-page-subtitle {
    margin: 6px 0 0;
    color: var(--text-tertiary, #4b5563);
    font-size: 0.9rem;
}

.am-page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =====================================================================
   3. BREADCRUMB
   ===================================================================== */
.am-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-muted, #6b7280);
    margin-bottom: var(--spacing-md, 16px);
    list-style: none;
    padding: 0;
}

.am-breadcrumb a {
    color: var(--primary-700, #2563eb);
    text-decoration: none;
}

.am-breadcrumb a:hover { text-decoration: underline; }

.am-breadcrumb__sep {
    color: var(--gray-400, #d1d5db);
}

.am-breadcrumb__current {
    color: var(--text-secondary, #374151);
    font-weight: 600;
}

/* =====================================================================
   4. HERO / BANNER
   ===================================================================== */
.am-hero {
    background: var(--gradient-primary, linear-gradient(135deg, #2563eb, #7c3aed));
    color: #fff;
    border-radius: var(--radius-xl, 16px);
    padding: clamp(20px, 4vw, 36px);
    margin-bottom: var(--spacing-lg, 24px);
    box-shadow: var(--shadow-primary);
}

.am-hero__eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    opacity: 0.85;
    margin: 0 0 8px;
    font-weight: 600;
}

.am-hero__title {
    margin: 0 0 8px;
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 800;
    line-height: 1.2;
}

.am-hero__text {
    margin: 0 0 16px;
    opacity: 0.95;
    font-size: 0.98rem;
    max-width: 65ch;
}

.am-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* =====================================================================
   5. CARDS
   ===================================================================== */
.am-card {
    background: #fff;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius-lg, 12px);
    padding: var(--spacing-lg, 24px);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast, 150ms) ease,
        transform var(--transition-fast, 150ms) ease,
        border-color var(--transition-fast, 150ms) ease;
}

.am-card--hoverable:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--primary-300, #bfdbfe);
}

.am-card__title {
    margin: 0 0 6px;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}

.am-card__text {
    margin: 0;
    color: var(--text-tertiary, #4b5563);
    font-size: 0.9rem;
}

.am-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-md, 16px);
}

/* Stat card (KPIs del dashboard) */
.am-stat-card {
    background: #fff;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius-lg, 12px);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 110px;
}

.am-stat-card__head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.am-stat-card__icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    background: var(--gradient-primary);
}

.am-stat-card__label {
    margin: 0;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--text-tertiary, #4b5563);
    font-weight: 700;
}

.am-stat-card__value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-700, #2563eb);
    line-height: 1.1;
}

.am-stat-card__hint {
    color: var(--text-muted, #6b7280);
    font-size: 0.82rem;
    margin: 0;
}

/* =====================================================================
   6. BOTONES
   ===================================================================== */
.am-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast, 150ms) ease,
        transform var(--transition-fast, 150ms) ease,
        box-shadow var(--transition-fast, 150ms) ease;
    user-select: none;
    white-space: nowrap;
}

.am-btn:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
}

.am-btn:disabled,
.am-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
}

.am-btn--primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.am-btn--primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

.am-btn--secondary {
    background: #fff;
    color: var(--primary-700, #2563eb);
    border-color: var(--primary-300, #bfdbfe);
}

.am-btn--secondary:hover:not(:disabled) {
    background: var(--primary-100, #eff6ff);
}

.am-btn--ghost {
    background: transparent;
    color: var(--text-secondary, #374151);
}

.am-btn--ghost:hover:not(:disabled) {
    background: var(--gray-200, #f3f4f6);
}

.am-btn--danger {
    background: var(--danger-600, #dc2626);
    color: #fff;
}

.am-btn--danger:hover:not(:disabled) {
    background: var(--danger-700, #b91c1c);
}

.am-btn--success {
    background: var(--gradient-success);
    color: #fff;
}

.am-btn--sm { padding: 6px 12px; font-size: 0.82rem; }
.am-btn--lg { padding: 14px 24px; font-size: 1rem; }
.am-btn--block { display: flex; width: 100%; }

/* =====================================================================
   7. FORMULARIOS
   ===================================================================== */
.am-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: var(--spacing-md, 16px);
}

.am-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary, #374151);
}

.am-required {
    color: var(--danger-600, #dc2626);
    margin-left: 2px;
}

.am-input,
.am-textarea,
.am-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-medium, #d1d5db);
    border-radius: var(--radius-md, 8px);
    background: #fff;
    color: var(--text-primary, #1f2937);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition-fast, 150ms) ease,
        box-shadow var(--transition-fast, 150ms) ease;
}

.am-textarea { min-height: 110px; resize: vertical; }

.am-input:focus,
.am-textarea:focus,
.am-select:focus {
    outline: none;
    border-color: var(--primary-600, #3b82f6);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.am-help {
    font-size: 0.78rem;
    color: var(--text-muted, #6b7280);
}

.am-error {
    font-size: 0.78rem;
    color: var(--danger-700, #b91c1c);
}

/* =====================================================================
   8. BADGES
   ===================================================================== */
.am-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full, 9999px);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--gray-200, #f3f4f6);
    color: var(--gray-800, #374151);
}

.am-badge--primary { background: var(--primary-100); color: var(--primary-800); }
.am-badge--success { background: var(--success-100); color: var(--success-800); }
.am-badge--warning { background: var(--warning-100); color: var(--warning-800); }
.am-badge--danger  { background: var(--danger-100);  color: var(--danger-800);  }
.am-badge--info    { background: var(--info-100);    color: var(--info-800);    }

/* =====================================================================
   9. ALERTAS
   ===================================================================== */
.am-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-light, #e5e7eb);
    background: var(--gray-100, #f9fafb);
    color: var(--text-secondary, #374151);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-md, 16px);
}

.am-alert__icon { font-size: 1.05rem; line-height: 1.3; }
.am-alert__body { flex: 1; }
.am-alert__title { font-weight: 700; margin: 0 0 2px; }

.am-alert--success { background: var(--success-100, #d1fae5); color: var(--success-800, #065f46); border-color: var(--success-300, #6ee7b7); }
.am-alert--warning { background: var(--warning-100, #fef3c7); color: var(--warning-800, #92400e); border-color: var(--warning-300, #fcd34d); }
.am-alert--danger  { background: var(--danger-100,  #fee2e2); color: var(--danger-800,  #991b1b); border-color: var(--danger-300,  #fca5a5); }
.am-alert--info    { background: var(--info-100,    #dbeafe); color: var(--info-800,    #1e40af); border-color: var(--info-300,    #93c5fd); }

/* =====================================================================
   10. TABS
   ===================================================================== */
.am-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
    margin-bottom: var(--spacing-md, 16px);
    overflow-x: auto;
}

.am-tab {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-tertiary, #4b5563);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.am-tab:hover { color: var(--primary-700); }

.am-tab[aria-selected="true"] {
    color: var(--primary-700);
    border-bottom-color: var(--primary-600);
}

/* =====================================================================
   11. EMPTY STATE
   ===================================================================== */
.am-empty {
    text-align: center;
    padding: var(--spacing-xl, 32px) var(--spacing-md, 16px);
    color: var(--text-tertiary, #4b5563);
}

.am-empty__icon {
    font-size: 2.4rem;
    color: var(--gray-400, #d1d5db);
    margin-bottom: 8px;
}

.am-empty__title {
    margin: 0 0 6px;
    font-weight: 700;
    color: var(--text-secondary, #374151);
}

.am-empty__text {
    margin: 0 0 14px;
    font-size: 0.9rem;
}

/* =====================================================================
   12. SKELETON
   ===================================================================== */
@keyframes am-skeleton-pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

.am-skeleton {
    background: var(--gray-300, #e5e7eb);
    border-radius: var(--radius-md, 8px);
    animation: am-skeleton-pulse 1.4s ease-in-out infinite;
}

/* =====================================================================
   13. TOAST (apoyo CSS para app-shell.js)
   ===================================================================== */
.am-toast-host {
    position: fixed;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: var(--z-tooltip, 1070);
    pointer-events: none;
}

.am-toast {
    pointer-events: auto;
    background: #1f2937;
    color: #ffffff;
    padding: 10px 14px;
    border-radius: var(--radius-md, 8px);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    max-width: 320px;
    animation: am-toast-in 200ms ease-out;
    line-height: 1.4;
}
/* Forzar color blanco en cualquier hijo del toast — evita herencia
   accidental de estilos de página (ej. body{color:black}) */
.am-toast,
.am-toast * { color: #ffffff !important; }

.am-toast--success { background: var(--success-700, #047857); }
.am-toast--warning { background: var(--warning-700, #b45309); }
.am-toast--danger  { background: var(--danger-700,  #b91c1c); }
.am-toast--info    { background: var(--info-700,    #1d4ed8); }

@keyframes am-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================================
   14. FOOTER UNIFICADO
   ===================================================================== */
.am-footer {
    margin-top: var(--spacing-2xl, 48px);
    padding: var(--spacing-lg, 24px) var(--spacing-md, 16px);
    background: var(--gray-100, #f9fafb);
    border-top: 1px solid var(--border-light, #e5e7eb);
    color: var(--text-tertiary, #4b5563);
    font-size: 0.85rem;
    text-align: center;
}

.am-footer__links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.am-footer__links a {
    color: var(--primary-700);
    text-decoration: none;
}

.am-footer__links a:hover { text-decoration: underline; }

/* =====================================================================
   15. UTILIDADES
   ===================================================================== */
.am-stack { display: flex; flex-direction: column; gap: var(--spacing-md, 16px); }
.am-stack--sm { gap: 8px; }
.am-stack--lg { gap: var(--spacing-lg, 24px); }

.am-row { display: flex; flex-wrap: wrap; gap: var(--spacing-md, 16px); }
.am-row--between { justify-content: space-between; }
.am-row--center { justify-content: center; align-items: center; }

.am-text-muted { color: var(--text-muted, #6b7280); }
.am-text-center { text-align: center; }

.am-hidden { display: none !important; }

@media (max-width: 520px) {
    .am-container { padding: 0 12px; }
    .am-card { padding: 16px; }
    .am-hero { padding: 18px; }
    .am-page-title { font-size: 1.15rem; }
    .am-btn { padding: 9px 14px; }
}

/* =====================================================================
   16. AJUSTE: convivir con menú fijo (mobile-navigation)
   ===================================================================== */
body.am-has-nav .am-page {
    padding-top: calc(52px + env(safe-area-inset-top, 0px));
}

@media (min-width: 768px) {
    body.am-has-nav .am-page {
        padding-top: 60px;
    }
}

/* =====================================================================
   17. CAPA DE ADAPTACIÓN LEGACY
   ---------------------------------------------------------------------
   Da look unificado a clases comunes ya presentes en páginas antiguas.
   Sin `!important` para que páginas con estilo propio puedan sobreescribir.
   Solo se aplica cuando <body class="am-page"> está presente (lo añade
   app-shell.js) — así NO afecta otros consumidores legacy.
   ===================================================================== */

/* --- Botones legacy: btn-primary / btn-secondary / btn-success / btn-danger / btn-warning / action-btn --- */
.am-page .btn-primary,
.am-page .primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
    transition: transform var(--transition-fast, 150ms) ease,
                box-shadow var(--transition-fast, 150ms) ease;
}
.am-page .btn-primary:hover:not(:disabled),
.am-page .primary-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

.am-page .btn-secondary,
.am-page .secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--primary-300, #bfdbfe);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    background: #fff;
    color: var(--primary-700, #2563eb);
}
.am-page .btn-secondary:hover:not(:disabled),
.am-page .secondary-btn:hover:not(:disabled) {
    background: var(--primary-100, #eff6ff);
}

.am-page .btn-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md, 8px);
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--gradient-success);
    color: #fff;
}

.am-page .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md, 8px);
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--danger-600, #dc2626);
    color: #fff;
}
.am-page .btn-danger:hover:not(:disabled) { background: var(--danger-700, #b91c1c); }

.am-page .btn-warning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md, 8px);
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--warning-500, #f59e0b);
    color: #1f2937;
}

.am-page .action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-medium, #d1d5db);
    background: #fff;
    color: var(--text-secondary, #374151);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.am-page .action-btn:hover { background: var(--gray-200, #f3f4f6); }

/* --- Títulos legacy: section-title / page-title / dashboard-title / main-title --- */
.am-page .section-title,
.am-page .page-title,
.am-page .main-title,
.am-page .dashboard-title {
    color: var(--text-primary, #1f2937);
    font-weight: 700;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 10px;
}

.am-page .section-title { font-size: 1.15rem; margin: 0 0 12px; }
.am-page .page-title,
.am-page .main-title,
.am-page .dashboard-title { font-size: clamp(1.25rem, 2.2vw, 1.75rem); margin: 0; }

/* --- Stat-card legacy: estructura clásica con .stat-card / .stat-value / .stat-label --- */
.am-page .stat-card {
    background: #fff;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius-lg, 12px);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast, 150ms) ease,
                transform var(--transition-fast, 150ms) ease;
}
.am-page .stat-card:hover { box-shadow: var(--shadow-md); }

.am-page .stat-value,
.am-page .stat-number {
    color: var(--primary-700, #2563eb);
    font-weight: 800;
    font-size: 1.55rem;
    line-height: 1.1;
}

.am-page .stat-label {
    color: var(--text-tertiary, #4b5563);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

/* --- Card / panel genéricos --- */
.am-page .card,
.am-page .panel,
.am-page .info-card,
.am-page .feature-card {
    background: #fff;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-sm);
}

/* --- Contenedor principal típico --- */
.am-page .dashboard-container,
.am-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-md, 16px);
}

/* --- Header / hero legacy --- */
.am-page .dashboard-header,
.am-page .page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--spacing-md, 16px);
    margin-bottom: var(--spacing-lg, 24px);
}

/* --- Inputs sin clase: armonizar aspecto --- */
.am-page input[type="text"]:not([class]),
.am-page input[type="email"]:not([class]),
.am-page input[type="password"]:not([class]),
.am-page input[type="number"]:not([class]),
.am-page input[type="search"]:not([class]),
.am-page input[type="tel"]:not([class]),
.am-page input[type="url"]:not([class]),
.am-page textarea:not([class]),
.am-page select:not([class]) {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-medium, #d1d5db);
    border-radius: var(--radius-md, 8px);
    background: #fff;
    color: var(--text-primary, #1f2937);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition-fast, 150ms) ease,
                box-shadow var(--transition-fast, 150ms) ease;
}
.am-page input:not([class]):focus,
.am-page textarea:not([class]):focus,
.am-page select:not([class]):focus {
    outline: none;
    border-color: var(--primary-600, #3b82f6);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --- Mobile tweaks legacy --- */
@media (max-width: 520px) {
    .am-page .stat-card { padding: 12px 14px; }
    .am-page .stat-value,
    .am-page .stat-number { font-size: 1.3rem; }
    .am-page .btn-primary,
    .am-page .btn-secondary,
    .am-page .btn-success,
    .am-page .btn-danger,
    .am-page .btn-warning,
    .am-page .primary-btn,
    .am-page .secondary-btn {
        padding: 9px 14px;
        font-size: 0.86rem;
    }
}

/* =====================================================================
   18. AYUDA CONTEXTUAL (FAB + Drawer)
   ===================================================================== */
.am-help-fab {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
    cursor: pointer;
    z-index: var(--z-fixed, 1030);
    transition: transform var(--transition-fast, 150ms) ease;
}
.am-help-fab:hover { transform: scale(1.06); }
.am-help-fab:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
}

.am-help-drawer {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1050);
    display: flex;
    justify-content: flex-end;
    animation: am-fade-in 180ms ease-out;
}
.am-help-drawer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.am-help-drawer__panel {
    position: relative;
    width: min(380px, 92vw);
    height: 100%;
    background: #fff;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    animation: am-slide-in-right 220ms cubic-bezier(.2,.7,.2,1);
}
.am-help-drawer__head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--gray-100, #f9fafb);
}
.am-help-drawer__head h3 {
    margin: 0;
    font-size: 1.02rem;
    color: var(--text-primary, #1f2937);
    display: flex;
    align-items: center;
    gap: 8px;
}
.am-help-drawer__head h3 i { color: var(--primary-700, #2563eb); }
.am-help-drawer__close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-tertiary, #4b5563);
    padding: 4px 8px;
    border-radius: 8px;
}
.am-help-drawer__close:hover { background: var(--gray-200, #f3f4f6); }
.am-help-drawer__body {
    padding: 16px;
    overflow-y: auto;
    color: var(--text-secondary, #374151);
    font-size: 0.92rem;
}
.am-help-drawer__lead {
    margin: 0 0 12px;
    color: var(--text-secondary, #374151);
}
.am-help-drawer__body h4 {
    margin: 14px 0 6px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary, #4b5563);
}
.am-help-drawer__tips {
    margin: 0;
    padding-left: 18px;
}
.am-help-drawer__tips li { margin-bottom: 6px; }
.am-help-drawer__related {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@keyframes am-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes am-slide-in-right {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* =====================================================================
   19. MODAL GENÉRICO (AMShell.confirm / .prompt)
   ===================================================================== */
.am-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1050);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: am-fade-in 160ms ease-out;
}
.am-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}
.am-modal__panel {
    position: relative;
    width: min(460px, 100%);
    background: #fff;
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-2xl);
    padding: 22px;
    animation: am-modal-pop 200ms cubic-bezier(.2,.7,.2,1);
}
.am-modal__title {
    margin: 0 0 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}
.am-modal__text {
    margin: 0 0 14px;
    color: var(--text-secondary, #374151);
    font-size: 0.95rem;
    line-height: 1.5;
}
.am-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.am-modal .am-input { margin-top: 4px; }

@keyframes am-modal-pop {
    from { transform: scale(0.96); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* =====================================================================
   20. LOADING OVERLAY GLOBAL
   ===================================================================== */
.am-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1050);
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: am-fade-in 160ms ease-out;
}
.am-loading__panel {
    background: #fff;
    border-radius: var(--radius-lg, 12px);
    padding: 20px 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-2xl);
    min-width: 200px;
}
.am-loading__spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid var(--gray-300, #e5e7eb);
    border-top-color: var(--primary-600, #3b82f6);
    animation: am-spin 800ms linear infinite;
}
.am-loading__text {
    color: var(--text-secondary, #374151);
    font-size: 0.92rem;
    font-weight: 500;
}
@keyframes am-spin {
    to { transform: rotate(360deg); }
}

/* FAB se aleja si la página ya tiene un botón flotante propio en esa esquina:
   permite override moviendo a la izquierda */
.am-help-fab--left { right: auto; left: 16px; }

/* =====================================================================
   21. MINI-TOUR DE PRIMERA VISITA
   ===================================================================== */
.am-tour {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1050);
    pointer-events: none;
}
.am-tour__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    pointer-events: auto;
}
.am-tour__card {
    position: absolute;
    width: min(320px, 92vw);
    background: #fff;
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-2xl);
    padding: 14px 16px 12px;
    pointer-events: auto;
    border: 1px solid var(--primary-300, #bfdbfe);
}
.am-tour__title {
    margin: 0 0 6px;
    font-size: 0.98rem;
    color: var(--primary-700, #2563eb);
    font-weight: 700;
}
.am-tour__text {
    margin: 0 0 10px;
    color: var(--text-secondary, #374151);
    font-size: 0.88rem;
    line-height: 1.4;
}
.am-tour__actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.am-tour__progress {
    margin-top: 8px;
    text-align: right;
    font-size: 0.74rem;
    color: var(--text-muted, #6b7280);
    font-weight: 600;
}
.am-tour-highlight {
    position: relative;
    z-index: 1051;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.5), 0 0 0 8px rgba(37, 99, 235, 0.2);
    border-radius: 8px;
    transition: box-shadow 200ms ease;
}

/* =====================================================================
   22. BOTÓN "VOLVER ARRIBA"
   ===================================================================== */
.am-to-top {
    position: fixed;
    right: 16px;
    bottom: 76px; /* arriba del FAB de ayuda */
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--primary-600, #2563eb);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease;
    z-index: 1040;
}
.am-to-top--visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.am-to-top:hover { background: var(--primary-700, #1d4ed8); }

/* =====================================================================
   23. TOGGLE MODO OSCURO
   ===================================================================== */
.am-dark-toggle {
    position: fixed;
    right: 16px;
    bottom: 124px; /* arriba del botón "volver arriba" */
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: #fff;
    color: var(--primary-700, #1d4ed8);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    z-index: 1040;
    transition: background 200ms ease, color 200ms ease;
}
.am-dark-toggle:hover { background: var(--primary-50, #eff6ff); }

/* Tema oscuro (aplicado en <html class="am-dark">) */
html.am-dark {
    color-scheme: dark;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
}
html.am-dark body {
    background: #0f172a;
    color: #f1f5f9;
}
html.am-dark .am-card,
html.am-dark .am-stat-card,
html.am-dark .am-tour__card,
html.am-dark .am-modal__panel,
html.am-dark .am-help-drawer__panel,
html.am-dark .am-loading__panel {
    background: #1e293b;
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.08);
}
html.am-dark .am-text-muted { color: #94a3b8 !important; }
html.am-dark .am-input,
html.am-dark .am-textarea,
html.am-dark .am-select {
    background: #0f172a;
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.12);
}
html.am-dark .am-input:focus,
html.am-dark .am-textarea:focus,
html.am-dark .am-select:focus {
    border-color: var(--primary-400, #60a5fa);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
}
html.am-dark .am-btn--secondary {
    background: #334155;
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.08);
}
html.am-dark .am-btn--ghost {
    color: #cbd5e1;
}
html.am-dark .am-footer {
    background: #020617;
    color: #94a3b8;
    border-top-color: rgba(255, 255, 255, 0.06);
}
html.am-dark .am-dark-toggle {
    background: #1e293b;
    color: #fde68a;
    border-color: rgba(255, 255, 255, 0.1);
}
html.am-dark .am-breadcrumb { color: #cbd5e1; }
html.am-dark .am-breadcrumb a { color: var(--primary-300, #93c5fd); }

/* ----- IMPORTANTE: componentes flotantes SIEMPRE claros -----
   El resto de la app no está adaptada a dark mode, así que estos
   overlays se mantienen con tema claro para asegurar legibilidad. */
html.am-dark .am-tour__card,
html.am-dark .am-modal__panel,
html.am-dark .am-help-drawer__panel,
html.am-dark .am-loading__panel {
    background: #ffffff !important;
    color: #1f2937 !important;
    border-color: var(--primary-300, #bfdbfe) !important;
}
html.am-dark .am-tour__title,
html.am-dark .am-modal__title { color: var(--primary-700, #1d4ed8) !important; }
html.am-dark .am-tour__text,
html.am-dark .am-modal__text { color: #374151 !important; }
html.am-dark .am-tour__progress { color: #6b7280 !important; }

html.am-dark .am-help-drawer__head {
    background: var(--gray-100, #f9fafb) !important;
    border-bottom-color: var(--border-light, #e5e7eb) !important;
}
html.am-dark .am-help-drawer__head h3 { color: #1f2937 !important; }
html.am-dark .am-help-drawer__head h3 i,
html.am-dark .am-help-drawer__close { color: var(--primary-700, #1d4ed8) !important; }
html.am-dark .am-help-drawer__body,
html.am-dark .am-help-drawer__lead { color: #374151 !important; }
html.am-dark .am-help-drawer__body h4 { color: #4b5563 !important; }

/* ----- Refuerzo de contraste dark mode (overrides defensivos) ----- */
/* Cabezal del drawer de ayuda */
html.am-dark .am-help-drawer__head {
    background: #0f172a;
    border-bottom-color: rgba(255, 255, 255, 0.08);
}
html.am-dark .am-help-drawer__head h3,
html.am-dark .am-help-drawer__head h3 i {
    color: #f1f5f9;
}
html.am-dark .am-help-drawer__close { color: #cbd5e1; }
html.am-dark .am-help-drawer__close:hover { background: rgba(255, 255, 255, 0.06); }
html.am-dark .am-help-drawer__body { color: #cbd5e1; }
html.am-dark .am-help-drawer__body h4 { color: #94a3b8; }
html.am-dark .am-help-drawer__lead { color: #cbd5e1; }

/* Modal y Tour: títulos y texto */
html.am-dark .am-modal__title,
html.am-dark .am-tour__title { color: #f1f5f9; }
html.am-dark .am-modal__text,
html.am-dark .am-tour__text { color: #cbd5e1; }
html.am-dark .am-tour__progress { color: #94a3b8; }
html.am-dark .am-loading__text { color: #cbd5e1; }

/* Stat cards: textos */
html.am-dark .am-stat-card,
html.am-dark .am-stat-card__label,
html.am-dark .am-stat-card__value,
html.am-dark .am-stat-card__hint { color: #f1f5f9; }
html.am-dark .am-stat-card__label,
html.am-dark .am-stat-card__hint { color: #94a3b8; }

/* Cards: títulos */
html.am-dark .am-card,
html.am-dark .am-card__title { color: #f1f5f9; }
html.am-dark .am-card__text { color: #cbd5e1; }

/* Page header / hero */
html.am-dark .am-page-header,
html.am-dark .am-page-title,
html.am-dark .am-page-subtitle,
html.am-dark .am-hero,
html.am-dark .am-hero__title,
html.am-dark .am-hero__text { color: #f1f5f9; }
html.am-dark .am-page-subtitle,
html.am-dark .am-hero__eyebrow,
html.am-dark .am-hero__text { color: #cbd5e1; }

/* Inputs legacy sin clase */
html.am-dark .am-page input[type="text"]:not([class]),
html.am-dark .am-page input[type="email"]:not([class]),
html.am-dark .am-page input[type="password"]:not([class]),
html.am-dark .am-page input[type="number"]:not([class]),
html.am-dark .am-page input[type="search"]:not([class]),
html.am-dark .am-page input[type="tel"]:not([class]),
html.am-dark .am-page input[type="url"]:not([class]),
html.am-dark .am-page textarea:not([class]),
html.am-dark .am-page select:not([class]) {
    background: #0f172a;
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.12);
}
html.am-dark .am-page input::placeholder,
html.am-dark .am-page textarea::placeholder { color: #94a3b8; }

/* Alerts: invertir para que sean legibles sobre fondo oscuro */
html.am-dark .am-alert--success {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.35);
}
html.am-dark .am-alert--warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.35);
}
html.am-dark .am-alert--danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.35);
}
html.am-dark .am-alert--info {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.35);
}

/* Empty state */
html.am-dark .am-empty__title { color: #f1f5f9; }
html.am-dark .am-empty__text { color: #94a3b8; }

/* Badges info en dark */
html.am-dark .am-badge { color: #f1f5f9; }

/* Tabs */
html.am-dark .am-tab { color: #cbd5e1; }
html.am-dark .am-tab.am-tab--active { color: var(--primary-300, #93c5fd); }

/* Backdrop más oscuro en dark mode */
html.am-dark .am-help-drawer__backdrop,
html.am-dark .am-modal__backdrop { background: rgba(0, 0, 0, 0.65); }

/* =====================================================================
   24. BARRA OFFLINE
   ===================================================================== */
.am-offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--danger-600, #dc2626);
    color: #fff;
    text-align: center;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 2000;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4);
}
.am-offline-bar i { margin-right: 6px; }
body.am-has-nav .am-offline-bar + * { margin-top: 28px; }

/* =====================================================================
   25. HARDENING MOBILE — accesibilidad y compatibilidad táctil
   ===================================================================== */

/* iOS safe-area: respetar notch/home indicator en flotantes */
.am-help-fab,
.am-to-top,
.am-dark-toggle {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
}
.am-to-top { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
.am-dark-toggle { bottom: calc(128px + env(safe-area-inset-bottom, 0px)); }

.am-offline-bar {
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
}

/* Targets táctiles mínimos 44×44 (Apple HIG / WCAG 2.5.5) */
.am-btn,
.am-help-fab,
.am-to-top,
.am-dark-toggle,
.am-tab,
.am-help-drawer__close {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* Prevenir zoom en iOS al hacer focus en inputs (font-size ≥ 16px) */
@media (max-width: 768px) {
    .am-input,
    .am-textarea,
    .am-select,
    .am-page input[type="text"]:not([class]),
    .am-page input[type="email"]:not([class]),
    .am-page input[type="password"]:not([class]),
    .am-page input[type="number"]:not([class]),
    .am-page input[type="search"]:not([class]),
    .am-page input[type="tel"]:not([class]),
    .am-page input[type="url"]:not([class]),
    .am-page textarea:not([class]),
    .am-page select:not([class]) {
        font-size: 16px;
    }
}

/* Drawer de ayuda: en móviles pequeños ocupa todo el ancho */
@media (max-width: 480px) {
    .am-help-drawer__panel {
        width: 100%;
        max-width: 100%;
    }
}

/* Modal: padding lateral en móvil + ancho consistente */
@media (max-width: 480px) {
    .am-modal__panel {
        width: calc(100% - 24px);
        margin: 12px;
    }
    .am-modal__actions {
        flex-direction: column-reverse;
    }
    .am-modal__actions .am-btn {
        width: 100%;
    }
}

/* Tour: centrar la tarjeta en móvil pequeño (evita posición compleja) */
@media (max-width: 520px) {
    .am-tour__card {
        top: auto !important;
        left: 12px !important;
        right: 12px;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        width: auto;
        transform: none !important;
    }
}

/* Reposicionar dark-toggle en móvil pequeño: lado izquierdo
   para no apilar 3 botones en la esquina derecha */
@media (max-width: 520px) {
    .am-to-top {
        right: calc(12px + env(safe-area-inset-right, 0px));
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        width: 44px;
        height: 44px;
    }
    .am-dark-toggle {
        right: auto;
        left: calc(12px + env(safe-area-inset-left, 0px));
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        width: 44px;
        height: 44px;
    }
    .am-help-fab {
        right: calc(12px + env(safe-area-inset-right, 0px));
        width: 50px;
        height: 50px;
    }
    .am-toast-host {
        left: 12px;
        right: 12px;
        top: calc(56px + env(safe-area-inset-top, 0px));
    }
    .am-toast-host .am-toast {
        width: 100%;
        max-width: 100%;
    }
}

/* Footer en móvil: links wrap y centrados */
@media (max-width: 520px) {
    .am-footer__links {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
}

/* Reduce motion: respetar preferencia del usuario */
@media (prefers-reduced-motion: reduce) {
    .am-help-drawer,
    .am-help-drawer__panel,
    .am-modal__panel,
    .am-to-top,
    .am-toast,
    .am-tour__card {
        animation: none !important;
        transition: none !important;
    }
}

/* Mejora de hover sólo en dispositivos con puntero fino (no en touch) */
@media (hover: none) {
    .am-help-fab:hover { transform: none; }
    .am-card.am-card--hoverable:hover { transform: none; box-shadow: var(--shadow-md); }
}

/* =====================================================================
   26. HARDENING CROSS-BROWSER — Safari iOS + Chrome Android quirks
   ===================================================================== */

/* Resetea el flash gris al tocar elementos en iOS/Android */
.am-page * {
    -webkit-tap-highlight-color: transparent;
}

/* Evita que Safari/Chrome cambien tamaño de texto en landscape */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Scroll suave nativo (respeta prefers-reduced-motion del bloque anterior) */
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* Asegurar momentum-scroll en contenedores con overflow (iOS antiguo) */
.am-help-drawer__body,
.am-modal__panel {
    -webkit-overflow-scrolling: touch;
}

/* Prevenir bounce/rubber-band del body en iOS (drawer cubre toda la pantalla) */
.am-help-drawer,
.am-modal,
.am-loading-overlay {
    overscroll-behavior: contain;
}

/* Reset de estilos nativos en iOS para botones e inputs */
.am-btn,
.am-input,
.am-textarea,
.am-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Iconos del select: en Safari iOS el chevron nativo desaparece con appearance:none */
.am-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%236b7280' d='M5.516 7.548a.625.625 0 01.884-.032L10 11.116l3.6-3.6a.625.625 0 11.884.884l-4.042 4.042a.625.625 0 01-.884 0L5.548 8.432a.625.625 0 01-.032-.884z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 36px;
}

/* Focus visible solo desde teclado: limpia el outline molesto al hacer click */
.am-btn:focus,
.am-input:focus,
.am-textarea:focus,
.am-select:focus,
.am-help-fab:focus,
.am-to-top:focus,
.am-dark-toggle:focus {
    outline: none;
}
.am-btn:focus-visible,
.am-help-fab:focus-visible,
.am-to-top:focus-visible,
.am-dark-toggle:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.45);
    outline-offset: 2px;
}

/* Evitar overflow horizontal cuando hay texto largo o URLs sin espacios.
   Usamos `clip` en lugar de `hidden` para NO romper position:sticky en hijos.
   Fallback `hidden` para navegadores que no soportan clip. */
.am-page {
    overflow-x: hidden;
    overflow-x: clip;
}
.am-card,
.am-stat-card,
.am-alert,
.am-help-drawer__body {
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

/* Hijos flex con contenido largo: permite que se encojan en lugar de desbordar */
.am-row > *,
.am-stack > * {
    min-width: 0;
}

/* Imágenes y media responsive por defecto */
.am-page img,
.am-page video,
.am-page iframe,
.am-page svg {
    max-width: 100%;
    height: auto;
}

/* Tablas: scroll horizontal en lugar de romper el layout */
.am-page table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* iOS: inputs tipo date/time/number sin spinners molestos */
.am-page input[type="number"]::-webkit-inner-spin-button,
.am-page input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.am-page input[type="search"]::-webkit-search-decoration,
.am-page input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

/* Drawer ayuda: usar svh (small viewport height) en iOS si está disponible.
   Evita que la barra de URL recorte el contenido. */
@supports (height: 100svh) {
    .am-help-drawer__panel { height: 100svh; }
}

/* Modal: limitar altura para no salirse del viewport visible en iOS */
.am-modal__panel {
    max-height: calc(100vh - 32px);
    max-height: calc(100svh - 32px);
    overflow-y: auto;
}

/* Evitar que la animación slide-in cause horizontal overflow visible (iOS) */
.am-help-drawer { overflow: hidden; }

/* Print: ocultar elementos no esenciales */
@media print {
    .am-help-fab,
    .am-to-top,
    .am-dark-toggle,
    .am-help-drawer,
    .am-modal,
    .am-toast-host,
    .am-offline-bar,
    #mobile-navigation-container,
    .am-footer {
        display: none !important;
    }
    .am-page { padding-top: 0 !important; }
}
