/* ================================================================
   Sistema de Mantenimiento UC — Tema custom
   ================================================================ */

:root {
    --primary: #1e3a5f;
    --primary-light: #2c5282;
    --primary-dark: #1a2e4a;
    --accent: #38b2ac;
    --accent-light: #4fd1c5;
    --accent-dark: #2c7a7b;

    --bg: #f7fafc;
    --surface: #ffffff;
    --surface-hover: #f0f4f8;

    --text: #1a202c;
    --text-muted: #718096;
    --text-light: #a0aec0;

    --border: #e2e8f0;
    --border-light: #edf2f7;

    --danger: #e53e3e;
    --warning: #dd6b20;
    --success: #38a169;
    --info: #3182ce;

    --sidebar-bg: #1a202c;
    --sidebar-text: #e2e8f0;
    --sidebar-hover: rgba(56, 178, 172, 0.08);
    --sidebar-active: rgba(56, 178, 172, 0.15);
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
    --transition: 200ms ease;
}

/* ---- Base ---- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ---- App wrapper ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    min-height: 70px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--sidebar-text);
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    transition: opacity var(--transition);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.nav-section {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
}

.nav-item {
    margin: 1px 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-xs);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    transition: background var(--transition), border-color var(--transition);
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-link.active {
    background: var(--sidebar-active);
    border-left-color: var(--accent);
    color: var(--accent-light);
    font-weight: 500;
}

.nav-link .nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link .nav-badge {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: var(--danger);
    color: #fff;
    font-weight: 600;
}

.nav-link .nav-badge.bg-warning {
    background: var(--warning) !important;
}

/* Submenu */
.nav-submenu {
    padding-left: 2.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 250ms ease;
}
.nav-submenu.show {
    max-height: 300px;
}
.nav-submenu .nav-link {
    font-size: 0.82rem;
    padding: 0.4rem 0.75rem;
    border-left: none;
}

.nav-toggle-icon {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform var(--transition);
}
.nav-link[aria-expanded="true"] .nav-toggle-icon {
    transform: rotate(90deg);
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-footer .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-footer .user-info {
    overflow: hidden;
    transition: opacity var(--transition);
}
.sidebar-footer .user-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--sidebar-text);
}
.sidebar-footer .user-role {
    font-size: 0.7rem;
    color: var(--text-light);
}

/* ---- Sidebar collapsed ---- */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-section,
.sidebar-collapsed .nav-link span:not(.nav-icon),
.sidebar-collapsed .nav-badge,
.sidebar-collapsed .nav-toggle-icon,
.sidebar-collapsed .nav-submenu,
.sidebar-collapsed .sidebar-footer .user-info {
    opacity: 0;
    pointer-events: none;
}
.sidebar-collapsed .main-panel {
    margin-left: var(--sidebar-collapsed);
}

/* ---- Main panel ---- */
.main-panel {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.topbar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-xs);
    transition: color var(--transition), background var(--transition);
}
.topbar-toggle:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 1.15rem;
    color: var(--text-muted);
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}
.topbar-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}
.topbar-btn .notif-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--surface);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ---- Content ---- */
.content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    width: 100%;
}

.app-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
}

/* ---- Cards ---- */
.card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition);
    background: var(--surface);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.card-body {
    padding: 1.25rem;
}

/* KPI cards */
.kpi-card {
    position: relative;
    overflow: hidden;
    border: none;
    box-shadow: var(--shadow);
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}
.kpi-card.kpi-primary::before { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.kpi-card.kpi-success::before { background: linear-gradient(90deg, var(--success), #48bb78); }
.kpi-card.kpi-info::before { background: linear-gradient(90deg, var(--info), #63b3ed); }
.kpi-card.kpi-warning::before { background: linear-gradient(90deg, var(--warning), #ed8936); }
.kpi-card.kpi-danger::before { background: linear-gradient(90deg, var(--danger), #fc8181); }
.kpi-card.kpi-accent::before { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.25rem;
}

/* Semáforo matafuegos: 3 micro-stats responsivos.
   Mantiene 3 columnas en cualquier pantalla (es un semáforo) pero ajusta tamaño en mobile. */
.semaforo-matafuegos .semaforo-num {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
}
.semaforo-matafuegos .badge {
    font-size: 0.7rem;
    white-space: normal;
    display: inline-block;
    max-width: 100%;
}
@media (max-width: 575.98px) {
    .semaforo-matafuegos .semaforo-num { font-size: 1.4rem; }
    .semaforo-matafuegos .badge { font-size: 0.62rem; padding: 0.2em 0.4em; }
}

/* ---- Tables ---- */
.table {
    font-size: 0.875rem;
}
.table thead th {
    background: transparent;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 0.75rem;
}
.table tbody tr {
    transition: background var(--transition);
}
.table-hover tbody tr:hover {
    background: var(--surface-hover);
}
.table tbody td {
    padding: 0.7rem 0.75rem;
    border-color: var(--border-light);
    vertical-align: middle;
}

/* ---- Buttons ---- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--transition);
}
.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-light);
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.25);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* ---- Forms ---- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 0.875rem;
    padding: 0.5rem 0.85rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 178, 172, 0.15);
}
.form-label {
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: 0.35rem;
}

/* ---- Badges ---- */
.badge {
    font-weight: 500;
    font-size: 0.72rem;
    padding: 0.3em 0.65em;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

/* ---- SweetAlert2 overrides ---- */
.swal2-popup {
    border-radius: var(--radius) !important;
    font-family: inherit !important;
}
.swal2-title {
    font-size: 1.25rem !important;
}
.swal2-html-container {
    font-size: 0.9rem !important;
}
.swal2-confirm,
.swal2-cancel {
    border-radius: var(--radius-sm) !important;
}
.swal2-popup.swal2-show {
    animation-duration: 100ms !important;
}
.swal2-popup.swal2-hide {
    animation-duration: 100ms !important;
}
.swal2-container.swal2-backdrop-show {
    animation-duration: 100ms !important;
}
.swal2-container.swal2-backdrop-hide {
    animation-duration: 100ms !important;
}

/* ---- Pagination ---- */
.pagination .page-link {
    border-radius: var(--radius-xs);
    margin: 0 2px;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
}
.pagination .page-item.active .page-link {
    background: var(--accent);
    color: #fff;
}
.pagination .page-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* ---- Dropdown (notificaciones, user menu) ---- */
.dropdown-menu {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
}
.dropdown-item {
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    padding: 0.45rem 0.75rem;
}
.dropdown-item:hover {
    background: var(--surface-hover);
}

/* ---- Auth page ---- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--primary-dark) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg), 0 20px 40px rgba(0,0,0,0.12);
    padding: 2.5rem 2rem;
}

.auth-logo {
    width: 56px;
    height: 56px;
    background: var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    margin: 0 auto 1.25rem;
}

.auth-title {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}
.auth-subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ---- Responsive ---- */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-open .sidebar-overlay {
        display: block;
    }
    .main-panel {
        margin-left: 0;
    }
    .content {
        padding: 1rem;
    }
    .sidebar-collapsed .main-panel {
        margin-left: 0;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1035;
    backdrop-filter: blur(2px);
}

/* ---- Sticky submit (relevamientos) ---- */
.sticky-submit {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border-light);
    padding: 0.75rem 1.25rem;
    margin: 0 -1.25rem -1.25rem;
    z-index: 1020;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}

/* ---- Misc ---- */
.text-accent { color: var(--accent) !important; }
.bg-accent { background: var(--accent) !important; }
.border-accent { border-color: var(--accent) !important; }

.table-actions {
    white-space: nowrap;
}

code {
    background: var(--surface-hover);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.82em;
    color: var(--primary);
}

/* Notification list */
.notif-list {
    max-height: 70vh;
    overflow-y: auto;
}
.notif-item {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-xs);
    transition: background var(--transition);
}
.notif-item:hover {
    background: var(--surface-hover);
}
.notif-item.unread {
    background: rgba(56, 178, 172, 0.04);
    font-weight: 500;
}

/* ============================================================
   Barra de progreso de navegación (vanilla, sin librería).
   Aparece al hacer click en un link interno o al submit de un form.
   ============================================================ */
.nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #38b2ac 0%, #3182ce 100%);
    box-shadow: 0 0 6px rgba(49, 130, 206, 0.5);
    z-index: 9999;
    pointer-events: none;
    transition: width 0.25s ease-out, opacity 0.25s ease-out;
    opacity: 0;
}
.nav-progress.show {
    opacity: 1;
    /* Avanza al 75% en ~3s — el último 25% lo completa el evento load. */
    animation: nav-progress-creep 3s ease-out forwards;
}
.nav-progress.done {
    width: 100% !important;
    opacity: 0;
    transition: width 0.2s ease-out, opacity 0.4s ease-out 0.2s;
}
@keyframes nav-progress-creep {
    0%   { width: 0%; }
    30%  { width: 25%; }
    60%  { width: 55%; }
    100% { width: 75%; }
}

/* Spinner en botones submit mientras la página procesa. */
.btn-loading {
    cursor: progress;
    opacity: 0.85;
}
.btn-loading .btn-spinner {
    vertical-align: -2px;
}

/* ---- Tabs del panel Inventario ---- */
/* Override de los estilos del sidebar (.nav-link) que se filtran a los nav-tabs. */
.inventario-tabs .nav-link {
    color: var(--text);
    padding: 0.55rem 0.9rem;
    overflow: visible;
    border-left: none;
    white-space: nowrap;
}
.inventario-tabs .nav-link:hover {
    background: var(--surface-hover);
    color: var(--primary);
}
.inventario-tabs .nav-link.active {
    color: var(--primary);
    background: var(--surface);
    border-color: var(--border) var(--border) var(--surface);
    font-weight: 600;
}
.inventario-tabs .nav-item.dropdown .dropdown-menu {
    /* Asegurar que el menú quede por encima de cualquier contenedor con overflow. */
    z-index: 1050;
}
.inventario-tabs .nav-link .badge {
    margin-left: 0.35rem;
}

/* ================================================================
   Mobile UI — bottom nav, FAB QR, tablas como cards, inputs táctiles
   ================================================================
   Patrón: visible solo en mobile (≤767px) usando media queries.
   En desktop estos elementos se ocultan con display: none.
*/

/* ---- Bottom nav (≤767px) ---- */
.bottom-nav {
    display: none; /* desktop por defecto */
}

@media (max-width: 767.98px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: var(--surface);
        border-top: 1px solid var(--border-light);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
        z-index: 1029;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 500;
        padding: 0.25rem 0;
        position: relative;
        transition: color var(--transition);
        min-height: 44px;
    }
    .bottom-nav-item i {
        font-size: 1.25rem;
        line-height: 1;
    }
    .bottom-nav-item.active {
        color: var(--accent-dark);
    }
    .bottom-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 25%;
        right: 25%;
        height: 3px;
        background: var(--accent);
        border-radius: 0 0 3px 3px;
    }
    .bottom-nav-item .bottom-nav-badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 18px);
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        background: var(--danger);
        color: #fff;
        border-radius: 8px;
        font-size: 0.6rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    /* El contenido necesita espacio extra abajo para no quedar tapado por el bottom nav */
    .content {
        padding-bottom: calc(64px + env(safe-area-inset-bottom) + 1rem);
    }

    /* Footer puede quedar tapado: lo ocultamos en mobile (la info ya no aporta) */
    .app-footer {
        display: none;
    }
}

/* ---- FAB Escanear QR ---- */
.fab-qr {
    display: none; /* desktop por defecto */
}

@media (max-width: 767.98px) {
    .fab-qr {
        display: flex;
        position: fixed;
        bottom: calc(64px + env(safe-area-inset-bottom) + 14px);
        right: 16px;
        width: 56px;
        height: 56px;
        background: var(--accent);
        color: #fff;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        font-size: 1.6rem;
        text-decoration: none;
        box-shadow: 0 6px 16px rgba(56, 178, 172, 0.45), 0 2px 4px rgba(0,0,0,0.1);
        z-index: 1028;
        border: none;
        transition: transform var(--transition), background var(--transition);
    }
    .fab-qr:active {
        transform: scale(0.92);
        background: var(--accent-dark);
        color: #fff;
    }
}

/* ---- Tablas → cards en mobile (≤767px) ---- */
/*
   Patrón: agregar clase .table-cards-mobile al <table>.
   En cada <td> agregar data-label="Nombre de columna" para que se vea la
   etiqueta junto al valor. El <thead> se oculta en mobile.
*/
@media (max-width: 767.98px) {
    .table-cards-mobile {
        display: block;
        background: transparent;
    }
    .table-cards-mobile thead {
        display: none;
    }
    .table-cards-mobile tbody {
        display: block;
    }
    .table-cards-mobile tbody tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border-light);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        padding: 0.85rem 1rem;
        margin-bottom: 0.85rem;
    }
    .table-cards-mobile tbody tr:hover {
        background: var(--surface);
    }
    .table-cards-mobile tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        padding: 0.35rem 0;
        border: none;
        border-bottom: 1px dashed var(--border-light);
        text-align: right;
        font-size: 0.9rem;
        min-height: 32px;
    }
    .table-cards-mobile tbody td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
    .table-cards-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }
    /* Si la celda no tiene data-label (ej. acciones), oculto el label vacío */
    .table-cards-mobile tbody td:not([data-label])::before,
    .table-cards-mobile tbody td[data-label=""]::before {
        display: none;
    }
    /* Acciones / botones: alineados a la derecha sin label */
    .table-cards-mobile tbody td.table-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 0.4rem;
        padding-top: 0.65rem;
    }
    .table-cards-mobile tbody td.table-actions .btn {
        flex: 0 0 auto;
    }
    /* Anula display:none de td responsive — en cards-mobile queremos verlas todas */
    .table-cards-mobile tbody td.d-none.d-md-table-cell,
    .table-cards-mobile tbody td.d-none.d-lg-table-cell,
    .table-cards-mobile tbody td.d-none.d-xl-table-cell {
        display: flex !important;
    }
    /* Quita scroll horizontal del wrapper cuando estamos en modo cards */
    .table-responsive:has(> .table-cards-mobile) {
        overflow-x: visible;
    }
}

/* ---- Inputs táctiles (mobile + tablet hasta 1024) ---- */
@media (max-width: 1023.98px) {
    .form-control,
    .form-select {
        font-size: 1rem; /* evita zoom-in en iOS al focus */
        padding: 0.65rem 0.9rem;
        min-height: 44px;
    }
    .form-control-sm,
    .form-select-sm {
        font-size: 0.9rem;
        padding: 0.4rem 0.7rem;
        min-height: 36px;
    }
    .btn {
        min-height: 40px;
        padding: 0.5rem 1rem;
    }
    .btn-sm {
        min-height: 32px;
        padding: 0.3rem 0.7rem;
    }
    /* Checkbox / radio más grandes para targets táctiles */
    .form-check-input {
        width: 1.2em;
        height: 1.2em;
        margin-top: 0.2em;
    }
    .form-check-label {
        padding-left: 0.25rem;
        line-height: 1.5;
    }
    /* Modales fullscreen-ish en mobile */
    @media (max-width: 575.98px) {
        .modal-dialog {
            margin: 0;
            max-width: 100%;
            min-height: 100vh;
        }
        .modal-content {
            border-radius: 0;
            min-height: 100vh;
        }
    }
}

/* ---- Tablet sweet spot (768-1023) ---- */
@media (min-width: 768px) and (max-width: 1023.98px) {
    /* Sidebar: queda visible pero más angosta para dar más espacio al contenido */
    :root {
        --sidebar-width: 220px;
    }
    .content {
        padding: 1.25rem;
    }
    /* KPI cards: ajustar tamaño para que entren bien */
    .kpi-value {
        font-size: 1.5rem;
    }
    /* Tablas: tipografía un poco menor para que entren más columnas */
    .table {
        font-size: 0.82rem;
    }
    .table thead th,
    .table tbody td {
        padding: 0.55rem 0.6rem;
    }
}

/* ---- Mejoras táctiles en tablas convencionales en mobile ---- */
@media (max-width: 767.98px) {
    /* Si la tabla NO tiene .table-cards-mobile, al menos hacer scroll horizontal limpio */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    /* Targets táctiles en links de la tabla */
    .table a.btn,
    .table button.btn {
        min-height: 36px;
    }
}

/* ---- Filtros sticky en mobile ---- */
@media (max-width: 767.98px) {
    .filtros-sticky {
        position: sticky;
        top: var(--topbar-height);
        z-index: 1020;
        background: var(--bg);
        margin: -1rem -1rem 1rem;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-light);
    }
}

/* ---- Headers de página: titulo + acciones en columnas en mobile ---- */
@media (max-width: 575.98px) {
    .page-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem;
    }
    .page-header > .page-actions {
        display: flex;
        gap: 0.5rem;
    }
    .page-header > .page-actions > .btn {
        flex: 1;
    }
}

/* Logo institucional SIGMA UC. PNG transparente con líneas en azul UC. */
.sidebar-brand .brand-icon.brand-icon-logo {
    background: transparent;
    padding: 2px;
}
.sidebar-brand .brand-icon.brand-icon-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.auth-logo-img {
    width: 96px;
    height: 96px;
    object-fit: contain;
    display: block;
    margin: 0 auto 1.25rem;
}
