/*
 * PatagoniaWeb Gestión UIX
 * Capa global de refinamiento visual y responsive para todo /gestion/.
 * Objetivo: unificar la experiencia visual vigente sin romper flujos existentes.
 */

:root,
[data-theme="light"] {
    --uix-radius-xs: 0.5rem;
    --uix-radius-sm: 0.75rem;
    --uix-radius-md: 1rem;
    --uix-radius-lg: 1.25rem;
    --uix-ring: 0 0 0 3px rgba(0, 102, 255, 0.20);
    --uix-shadow-card: 0 2px 8px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05), 0 0 0 1px rgba(0, 102, 255, 0.04);
    --uix-shadow-card-hover: 0 6px 24px rgba(15, 23, 42, 0.11), 0 2px 8px rgba(0, 102, 255, 0.09), 0 0 0 1px rgba(0, 102, 255, 0.14);
    --uix-shadow-soft: 0 4px 20px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
    --uix-ring: 0 0 0 3px rgba(129, 140, 248, 0.22);
    --uix-shadow-card: 0 2px 8px rgba(0, 0, 0, 0.30), 0 1px 3px rgba(0, 0, 0, 0.20), 0 0 0 1px rgba(129, 140, 248, 0.05);
    --uix-shadow-card-hover: 0 6px 24px rgba(0, 0, 0, 0.38), 0 2px 8px rgba(129, 140, 248, 0.10), 0 0 0 1px rgba(129, 140, 248, 0.15);
    --uix-shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.28);
}

/* Textura de fondo — dot grid profesional */
body {
    background-image: radial-gradient(rgba(0, 102, 255, 0.055) 1px, transparent 1px);
    background-size: 22px 22px;
}

[data-theme="dark"] body {
    background-image: radial-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 22px 22px;
}

.main-content {
    background: transparent;
}

.main-content > * {
    /* Ancho completo: el contenido ocupa todo el área disponible (el padding de
       .main-content da el margen). Antes cap 1480px sin centrar → dejaba un
       hueco a la derecha en monitores anchos (>1480px). */
    max-width: 100%;
}

/* Header de página */
.page-header-3d {
    padding: 0;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.page-header-3d .title {
    font-size: clamp(1.125rem, 2vw, 1.375rem);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.page-header-3d .title .icon,
.page-header-3d .title > div:first-child {
    box-shadow: var(--uix-shadow-soft);
}

/* Cards — glassmorphism + profundidad */
.card-3d,
.stat-card-3d,
.ap-card {
    border-radius: var(--uix-radius-lg) !important;
    box-shadow: var(--uix-shadow-card) !important;
    border-color: color-mix(in srgb, var(--border) 82%, transparent) !important;
    background: rgba(255,255,255,0.88) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.18s ease !important;
}

[data-theme="dark"] .card-3d,
[data-theme="dark"] .stat-card-3d,
[data-theme="dark"] .ap-card {
    background: rgba(15,23,42,0.80) !important;
}

.card-3d:hover,
.stat-card-3d:hover {
    box-shadow: var(--uix-shadow-card-hover) !important;
    border-color: rgba(0, 102, 255, 0.20) !important;
    transform: translateY(-2px);
}

.card-3d-header {
    min-height: unset;
    background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 93%, var(--primary-light)) 100%);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, var(--primary-light));
}

.card-3d-header h1,
.card-3d-header h2,
.card-3d-header h3,
.card-3d-header h4,
.card-3d-header h5,
.card-3d-header h6 {
    margin: 0;
}

/* Botones — micro-lift + sombra suave */
.btn-3d {
    min-height: 2.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.10), 0 1px 2px rgba(15, 23, 42, 0.06);
    text-shadow: none;
    transition: box-shadow 0.15s ease, transform 0.12s ease, filter 0.12s ease !important;
}

.btn-3d:hover {
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px) !important;
    filter: brightness(1.07);
}

.btn-3d:active {
    transform: translateY(0) !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.10) !important;
    filter: brightness(0.96);
}

.btn-3d:focus-visible,
.sidebar-link:focus-visible,
.sidebar-sub-item:focus-visible,
.theme-toggle:focus-visible,
.panel-menu-btn:focus-visible,
.panel-sidebar-close:focus-visible {
    outline: none;
    box-shadow: var(--uix-ring) !important;
}

/* Dropdowns del topbar: se teletransportan al body para no quedar atrapados por
   el backdrop-filter del header. Fondo opaco para que no se lea contenido detrás. */
.panel-notification-wrap {
    position: relative;
}

.panel-notification-wrap .theme-toggle {
    position: relative;
}

.panel-notification-count {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--topbar-bg);
    line-height: 1;
    pointer-events: none;
}

.panel-notification-menu {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    top: 3.5rem;
    width: min(22rem, calc(100vw - 2rem));
    max-height: min(30rem, calc(100vh - 4.75rem));
    overflow: hidden;
    z-index: 10020;
    pointer-events: auto;
    isolation: isolate;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.32), 0 0 0 1px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .panel-notification-menu {
    background: #0f172a;
    border-color: #334155;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(148, 163, 184, 0.08);
}

.panel-notification-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: inherit;
}

.panel-notification-header strong {
    font-size: 0.875rem;
    color: var(--text);
}

.panel-notification-header a {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.panel-notification-list {
    max-height: 22rem;
    overflow: auto;
}

.panel-notification-item,
.panel-notification-row {
    background: inherit;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}

.panel-notification-item {
    display: block;
    padding: 0.875rem 1rem;
}

.panel-notification-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
}

.panel-notification-row span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.panel-notification-item:hover,
.panel-notification-row:hover {
    background: var(--surface-hover);
}

.panel-notification-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.panel-notification-meta .badge-info {
    font-size: 0.65rem;
}

.panel-notification-meta span:last-child {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.panel-notification-title {
    display: block;
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1.3;
}

.panel-notification-text,
.panel-notification-empty {
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.35;
}

.panel-notification-text {
    display: block;
    margin-top: 0.2rem;
}

.panel-notification-empty {
    padding: 1.25rem;
    text-align: center;
}

.btn-3d-sm {
    min-height: 2.125rem;
    min-width: 2.125rem;
    padding: 0.45rem 0.7rem;
}

/* Formularios */
.form-control-3d,
.form-select-3d,
.ap-input,
.ap-select,
.ap-textarea {
    min-height: 2.6rem;
    border-radius: 0.75rem !important;
}

.form-control-3d:focus,
.form-select-3d:focus,
.ap-input:focus,
.ap-select:focus,
.ap-textarea:focus {
    box-shadow: var(--uix-ring) !important;
}

/* Tablas: comportamiento propio sin depender de Bootstrap CSS */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive .table-3d {
    min-width: 760px;
}

.table-3d thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--table-header-bg);
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
}

.table-3d tbody td {
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
}

.table-3d tbody td {
    max-width: 280px;
}

.table-3d td .btn-3d,
.table-3d td a.btn-3d,
.table-3d td button.btn-3d {
    min-width: 2.25rem;
    min-height: 2.25rem;
}

/* Acciones y filtros */
.uix-actions,
.card-3d-body form,
.card-3d-header {
    min-width: 0;
}

/* In-page tabs — mismo look "chip" que .section-tab (ver base.html). */
.tabs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1.25rem;
}

.tab-btn {
    min-height: 2.4rem;
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-sm, 10px);
    padding: 0.5rem 0.95rem;
    color: var(--ap-muted);
    background: var(--ap-card);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.tab-btn:hover {
    color: var(--ap-text);
    background: var(--ap-hover);
    border-color: color-mix(in oklab, var(--ap-brand) 40%, var(--ap-border));
    transform: translateY(-1px);
}

.tab-btn.active {
    color: var(--ap-brand);
    background: var(--ap-brand-bg);
    border-color: color-mix(in oklab, var(--ap-brand) 45%, var(--ap-border));
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ap-brand) 25%, transparent);
    font-weight: 700;
}
.tab-btn.active:hover { transform: none; }

/* Tabs de canal (asistente IA: web / WhatsApp) — mismo chip dashboard. */
.mn-tabs { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1.25rem; }
.mn-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.95rem;
    border-radius: var(--ap-radius-sm, 10px);
    color: var(--ap-muted);
    background: var(--ap-card);
    border: 1px solid var(--ap-border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.mn-tab:hover {
    color: var(--ap-text);
    background: var(--ap-hover);
    border-color: color-mix(in oklab, var(--ap-brand) 40%, var(--ap-border));
    transform: translateY(-1px);
}
.mn-tab.active {
    color: var(--ap-brand);
    background: var(--ap-brand-bg);
    border-color: color-mix(in oklab, var(--ap-brand) 45%, var(--ap-border));
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ap-brand) 25%, transparent);
    font-weight: 700;
}
.mn-tab.active:hover { transform: none; }
.mn-tab i { font-size: 0.9rem; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Sidebar */
#main-sidebar {
    box-shadow: 2px 0 20px rgba(2, 6, 23, 0.18);
}

.sidebar-link,
.sidebar-sub-item {
    min-height: 2.35rem;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease !important;
}

.sidebar-link.active,
.sidebar-sub-item.active {
    box-shadow: inset 3px 0 0 var(--sidebar-active-border), 0 2px 12px rgba(0, 102, 255, 0.18);
    background: rgba(0, 102, 255, 0.14) !important;
}

/* Toasts y diálogos */
.toast-3d {
    border-radius: var(--uix-radius-md) !important;
}

/* Helpers responsive reutilizables */
.uix-grid-2,
.uix-grid-3,
.uix-grid-4 {
    display: grid;
    gap: 1rem;
}

.uix-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.uix-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.uix-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Responsive auto-fit grid */
.uix-grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.uix-grid-auto-sm {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.uix-grid-auto-xs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

/* Sidebar + content layout */
.uix-grid-sidebar {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
}

/* Content + right sidebar layout */
.uix-grid-content-sidebar {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
}

/* Utilidades de gap para combinar con uix-grid-* */
.uix-gap-1 { gap: 0.25rem; }
.uix-gap-2 { gap: 0.5rem; }
.uix-gap-3 { gap: 0.75rem; }
.uix-gap-4 { gap: 1rem; }
.uix-gap-5 { gap: 1.5rem; }
.uix-gap-6 { gap: 2rem; }

.uix-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 0.75rem;
    align-items: end;
}

.uix-inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.uix-muted-action {
    opacity: .58;
    cursor: not-allowed !important;
    filter: grayscale(.2);
}

.uix-help-text {
    font-size: .78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ============================================================
   ACCESIBILIDAD BASE (WCAG 2.2)
   ============================================================ */

/* Focus states visibles para teclado */
:focus-visible {
    outline: 2px solid var(--primary, #0066FF);
    outline-offset: 2px;
}

/* Skip link para navegación por teclado */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    padding: 8px 16px;
    background: var(--primary, #0066FF);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 var(--uix-radius-sm, 0.75rem) 0;
    z-index: 9999;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 0;
}

/* Screen reader only */
.sr-only,
.uix-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

/* ============================================================
   COMPONENTES BASE DEL DESIGN SYSTEM
   ============================================================ */

/* Skeleton loader */
.uix-skeleton {
    background: linear-gradient(
        90deg,
        var(--border, #e2e8f0) 25%,
        var(--surface-hover, #f8fafc) 50%,
        var(--border, #e2e8f0) 75%
    );
    background-size: 200% 100%;
    border-radius: var(--uix-radius-sm, 0.75rem);
    animation: uix-skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes uix-skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.uix-skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.uix-skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 0.75rem;
}

.uix-skeleton-circle {
    border-radius: 50%;
    aspect-ratio: 1;
}

/* Focus ring utilidad */
.uix-focus-ring:focus-visible {
    outline: 2px solid var(--primary, #0066FF);
    outline-offset: 2px;
}

/* Loading spinner */
.uix-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border, #e2e8f0);
    border-top-color: var(--primary, #0066FF);
    border-radius: 50%;
    animation: uix-spin 0.8s linear infinite;
}

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

/* Empty state mejorado */
.empty-state-3d {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--text-muted, #94a3b8);
}

.empty-state-3d .icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state-3d p {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.empty-state-3d .empty-hint {
    font-size: 0.85rem;
    color: var(--text-disabled, #cbd5e1);
    margin-bottom: 1.25rem;
}

/* ── Gradientes de header por módulo ──────────────────────────────────────
   Centraliza los background inline de .card-header en cada listado.
   Uso: <div class="card-header module-header--inventario">
   NO usar clases Tailwind aquí; este archivo se sirve directamente. */
.module-header--inventario  { background: linear-gradient(135deg, rgba(0, 102, 255,0.07) 0%, transparent 100%); }
.module-header--ventas       { background: linear-gradient(135deg, rgba(0,102,255,0.07) 0%, transparent 100%); }
.module-header--reparaciones { background: linear-gradient(135deg, rgba(245,158,11,0.07) 0%, transparent 100%); }
.module-header--presupuestos { background: linear-gradient(135deg, rgba(0,102,255,0.07) 0%, transparent 100%); }
.module-header--clientes     { background: linear-gradient(135deg, rgba(14,165,233,0.07) 0%, transparent 100%); }
.module-header--proveedores  { background: linear-gradient(135deg, rgba(100,116,139,0.06) 0%, transparent 100%); }

/* Visually hidden (para labels de iconos) */
.uix-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Mobile/tablet */
@media (max-width: 1023px) {
    .main-content {
        padding: 1rem !important;
    }

    #main-sidebar {
        width: min(18rem, 86vw) !important;
    }
}

@media (max-width: 820px) {
    .uix-grid-2,
    .uix-grid-3,
    .uix-grid-4,
    .uix-filter-grid,
    .uix-grid-sidebar,
    .uix-grid-content-sidebar {
        grid-template-columns: 1fr !important;
    }

    .page-header-3d {
        gap: 0.75rem;
    }

    .page-header-3d > a,
    .page-header-3d > button,
    .page-header-3d .btn-3d {
        width: 100%;
    }

    .card-3d-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .card-3d-body {
        padding: 1rem;
    }

    .tabs-container {
        width: 100%;
    }

    .tab-btn {
        flex: 1 1 100%;
        justify-content: center;
    }
}

@media (max-width: 560px) {
    .main-content {
        padding: 0.75rem !important;
    }

    .page-header-3d .title {
        width: 100%;
    }

    .btn-3d,
    .ap-btn {
        width: 100%;
        justify-content: center;
    }

    .table-responsive .table-3d {
        min-width: 680px;
    }

    .toast-container-3d,
    #toast-container {
        left: 0.75rem !important;
        right: 0.75rem !important;
        bottom: 0.75rem !important;
        max-width: none !important;
    }
}

/* Sticky filters para tablas de listado */
.uix-sticky-filters {
    position: sticky;
    top: var(--panel-topbar-height, 0);
    z-index: 10;
    background: var(--surface-bg, #f8fafc);
    padding: 1rem 0;
    margin-bottom: 1rem;
}

[data-theme="dark"] .uix-sticky-filters {
    background: var(--surface-bg, #020617);
}

.uix-actions-inline {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Touch targets ≥44px en mobile (WCAG 2.5.5) */
@media (max-width: 820px) {
    /* Botones pequeños en tablas: forzar min-height */
    .btn-3d-sm,
    .table-3d .btn-3d,
    .table-3d .btn-3d-sm {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem 0.75rem;
    }

    /* Inputs, selects, textareas */
    .form-control-3d,
    .form-select-3d,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="tel"],
    select,
    textarea {
        min-height: 44px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    /* Checkbox / radio: agrandar área táctil a 44px (WCAG) sin romper diseño visual */
    /* Se utiliza un wrapper .uix-checkbox-wrapper o .form-check-label para asegurar click real */
    .uix-checkbox-wrapper {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        margin: -10px;
        cursor: pointer;
    }

    /* Labels de checkbox con área táctil */
    .form-check-label {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* Links de acción en tablas */
    .table-3d a,
    .table-3d button {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Breadcrumb links */
    .breadcrumb-3d a,
    .breadcrumb-3d span {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Sidebar links */
    .sidebar-link,
    .sidebar-sub-item {
        min-height: 44px;
    }

    /* Tabs */
    .tab-btn {
        min-height: 44px;
    }

    /* Pagination */
    .pagination-3d .page-link {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Partial _pagination.html táctil */
    .pagination-btn {
        min-height: 44px;
        min-width: 44px;
    }
    .pagination-num,
    .pagination-num-active {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ============================================================
   Pagination partial — _pagination.html
   Variables requeridas: --border, --surface, --card, --text,
   --text-muted, --primary, --primary-hover (o --primary).
   NO usa clases utilitarias Tailwind (subset del panel).
   ============================================================ */

.pagination-nav {
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
}

.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.375rem;
}

/* Botones Anterior / Siguiente */
.pagination-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.9rem;
    min-height: 40px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card, var(--surface, #fff));
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
}

.pagination-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    text-decoration: none;
}

.pagination-btn-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Label de texto: visible >=640px, solo icono en mobile */
.pagination-btn-label {
    display: none;
}

@media (min-width: 640px) {
    .pagination-btn-label {
        display: inline;
    }
}

/* Info central "Página N de M" (style=simple) */
.pagination-info {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--text);
    white-space: nowrap;
}

/* Botones numéricos (style=numbers) */
.pagination-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--card, var(--surface, #fff));
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pagination-num:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    text-decoration: none;
}

.pagination-num-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    cursor: default;
    pointer-events: none;
}

/* Contrato responsive global del panel — 2026-08-02, ChatGPT Sol.
   Es deliberadamente conservador: evita overflow y refluye encabezados sin
   cambiar la lógica o el orden semántico de cada módulo. */
#hx-area,
#hx-area > *,
.card,
.card-header,
.page-header-3d,
.table-responsive,
.mn-shell {
    min-width: 0;
    max-width: 100%;
}

img,
video,
canvas,
svg {
    max-width: 100%;
}

.table-responsive {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.form-input,
input,
select,
textarea {
    max-width: 100%;
}

.page-header-3d,
.card-header {
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .page-header-3d {
        align-items: flex-start !important;
        gap: .65rem !important;
    }

    .page-header-3d > .title {
        min-width: 0;
    }

    .page-header-3d > :not(.title) {
        max-width: 100%;
    }

    .card-header {
        gap: .5rem;
    }

    .card-header > span,
    .card-header > small {
        white-space: normal;
        text-align: left;
    }

    .mn-actions,
    .page-actions,
    .form-actions {
        flex-wrap: wrap;
    }

    .mn-actions > *,
    .page-actions > *,
    .form-actions > * {
        max-width: 100%;
    }
}
