/* ============================================
   INVENTORYPRO V2 — SISTEMA DE DISEÑO PREMIUM
   RESPONSIVE MOBILE-FIRST
   ============================================ */

/* ---------- Variables de Tema ---------- */
:root {
    --font: 'Inter', system-ui, sans-serif;

    /* Dark theme — más cálido, menos "gamer" */
    --bg-body:    #0f1118;
    --bg-sidebar: #151821;
    --bg-card:    #1a1f2e;
    --bg-hover:   #222839;
    --border:     #2a3042;

    --text-primary:   #eaedf4;
    --text-secondary: #8e95a9;
    --text-muted:     #545b6e;

    --accent:       #0891b2;    /* Cyan/Teal — identidad PSI profesional */
    --accent-light: rgba(8,145,178,0.12);
    --accent-glow:  rgba(8,145,178,0.35);

    --success: #10b981;    /* Emerald — más suave */
    --warning: #f59e0b;
    --danger:  #f43f5e;    /* Rose — menos agresivo */
    --purple:  #a78bfa;

    --sidebar-width: 260px;
    --topbar-height: 56px;
    --bottom-nav-height: 64px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.25);
    --radius: 14px;

    /* Gradientes Modernos */
    --grad-blue: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
    --grad-purple: linear-gradient(135deg, #9333ea 0%, #ec4899 100%);
    --grad-orange: linear-gradient(135deg, #ea580c 0%, #f59e0b 100%);
    --grad-teal: linear-gradient(135deg, #0d9488 0%, #10b981 100%);
    --grad-green: linear-gradient(135deg, #16a34a 0%, #84cc16 100%);
    --grad-red: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%);
    --grad-indigo: linear-gradient(135deg, #3730a3 0%, #6366f1 100%);
    --grad-slate: linear-gradient(135deg, #475569 0%, #94a3b8 100%);
    --grad-yellow: linear-gradient(135deg, #ca8a04 0%, #facc15 100%);
}

.card-grad-blue { background: var(--grad-blue) !important; color: white !important; }
.card-grad-purple { background: var(--grad-purple) !important; color: white !important; }
.card-grad-orange { background: var(--grad-orange) !important; color: white !important; }
.card-grad-teal { background: var(--grad-teal) !important; color: white !important; }
.card-grad-green { background: var(--grad-green) !important; color: white !important; }
.card-grad-red { background: var(--grad-red) !important; color: white !important; }
.card-grad-indigo { background: var(--grad-indigo) !important; color: white !important; }
.card-grad-slate { background: var(--grad-slate) !important; color: white !important; }
.card-grad-yellow { background: var(--grad-yellow) !important; color: white !important; }

[data-theme="light"] {
    --bg-body:    #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card:    #ffffff;
    --bg-hover:   #f1f5f9;
    --border:     #cbd5e1;
    --text-primary:   #0f172a;
    --text-secondary: #475569;
    --text-muted:     #64748b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ---------- Componentes Dashboard (Mosaico) ---------- */
.dashboard-mosaico {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.mosaico-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem 1.5rem;
    border-radius: 20px;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    position: relative;
    overflow: hidden;
}
.mosaico-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
    color: white;
}
.mosaico-icon {
    margin-bottom: 1rem;
    opacity: 0.9;
    transition: transform 0.3s ease;
}
.mosaico-item:hover .mosaico-icon {
    transform: scale(1.1);
}
.mosaico-bg-shape {
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    z-index: 0;
}
.mosaico-item > span, .mosaico-item > svg {
    position: relative;
    z-index: 1;
}

/* ---------- Layout Principal ---------- */
.app-layout { display: flex; min-height: 100vh; }

/* ---------- SIDEBAR OVERLAY (Mobile) ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 150;
}
.sidebar-overlay.active { display: block; }

/* ---------- SIDEBAR ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 200;
    transition: transform 0.3s ease, background 0.3s ease;
}

.sidebar-logo {
    padding: 1.1rem 1.25rem 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-logo .logo-icon {
    width: 32px; height: 32px;
    background: transparent !important;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: white; flex-shrink: 0;
}
.sidebar-logo .logo-text {
    font-size: 1.3rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px;
}
.sidebar-logo .logo-text span { display: none; }

/* Botón cerrar sidebar en mobile */
.sidebar-close {
    display: none;
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
}
.sidebar-close:hover { color: white; }

.sidebar-nav { flex: 1; padding: 0.875rem 0.75rem; }

.nav-section-title {
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.75rem 0.5rem 0.4rem;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 0.6rem 0.75rem;
    border-radius: 8px; text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px; font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.15s ease;
    min-height: 42px; /* Touch target */
}
.nav-item:hover { background: var(--bg-hover) !important; color: var(--accent) !important; }
.nav-item.active { background: var(--accent-light) !important; color: var(--accent) !important; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer { padding: 0.75rem; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 0.5rem 0.75rem; border-radius: 8px; cursor: pointer;
    transition: background 0.15s;
}
.sidebar-user:hover { background: var(--bg-hover); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.user-info .name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-info .role { font-size: 11px; color: var(--text-secondary); }

/* ---------- MAIN WRAPPER ---------- */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

/* ---------- TOPBAR ---------- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 100;
    gap: 1rem;
}
.topbar-left h2 { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.topbar-left p { font-size: 12px; color: var(--text-secondary); }
.topbar-right { display: flex; align-items: center; gap: 0.625rem; flex-shrink: 0; }
.topbar-date { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }

/* Botón hamburguesa (solo mobile) */
.btn-menu {
    display: none;
    width: 40px; height: 40px;
    background: var(--accent-light);
    border: 1px solid var(--accent);
    border-radius: 8px;
    cursor: pointer;
    align-items: center; justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
    transition: background 0.2s;
}
.btn-menu:hover { background: var(--accent); color: white; }
.btn-menu svg { width: 20px; height: 20px; }

/* Botón Tema */
.btn-theme {
    width: 36px; height: 36px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s; flex-shrink: 0;
}
.btn-theme:hover { color: var(--text-primary); border-color: var(--accent); }
.btn-theme svg { width: 16px; height: 16px; }

/* Botón Volver */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: .45rem 1rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}
.btn-back:hover { color: var(--text-primary); border-color: var(--accent); background: var(--accent-light); }
.btn-back svg { width: 14px; height: 14px; }

/* ---------- MAIN CONTENT ---------- */
.page-content { flex: 1; padding: 1.5rem; }

/* ---------- STATS GRID ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem 1.25rem;
    display: flex; flex-direction: column; gap: 8px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    position: relative; overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-4px); }
.stat-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-card-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-secondary); }
.stat-card-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.stat-card-icon svg { width: 18px; height: 18px; }
.stat-card-value { font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); line-height: 1; margin: 4px 0 0; word-break: break-all; }
.stat-card-sub { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-card-accent { position: absolute; top: 0; right: 0; width: 120px; height: 120px; border-radius: 50%; filter: blur(40px); opacity: 0.1; pointer-events: none; }

/* Colores tarjetas (Sin borde superior, estilo limpio) */
.card-blue, .card-orange, .card-purple, .card-green, .card-teal { border-top: none; }
.icon-blue   { background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(59,130,246,0.05)); color: #3b82f6; }
.icon-orange { background: linear-gradient(135deg, rgba(249,115,22,0.2), rgba(249,115,22,0.05)); color: #f97316; }
.icon-purple { background: linear-gradient(135deg, rgba(167,139,250,0.2), rgba(167,139,250,0.05)); color: #a78bfa; }
.icon-green  { background: linear-gradient(135deg, rgba(34,197,94,0.2), rgba(34,197,94,0.05)); color: #22c55e; }
.icon-teal   { background: linear-gradient(135deg, rgba(45,212,191,0.2), rgba(45,212,191,0.05)); color: #2dd4bf; }
.glow-blue   { background: #3b82f6; }
.glow-orange { background: #f97316; }
.glow-purple { background: #a78bfa; }
.glow-green  { background: #22c55e; }
.glow-teal   { background: #2dd4bf; }

/* ---------- DASHBOARD GRIDS ---------- */
.dashboard-grid-main {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1rem;
    margin-bottom: 1rem;
}
.dashboard-grid-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ---------- CONTENT CARDS — DISEÑO PREMIUM ---------- */
.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 2px solid var(--card-color, var(--accent));
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.22s, transform 0.22s;
}
/* Glow difuminado en la esquina — igual que stat-card-accent */
.content-card::before {
    content: '';
    position: absolute;
    top: -15px; right: -15px;
    width: 100px; height: 100px;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.12;
    pointer-events: none;
    background: var(--card-color, var(--accent));
    transition: opacity 0.3s;
}
.content-card:hover::before { opacity: 0.22; }
.content-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* Colores rotativos para content-card según posición */
.content-card:nth-child(5n+1) { --card-color: #3b82f6; }
.content-card:nth-child(5n+2) { --card-color: #f97316; }
.content-card:nth-child(5n+3) { --card-color: #a78bfa; }
.content-card:nth-child(5n+4) { --card-color: #22c55e; }
.content-card:nth-child(5n+5) { --card-color: #2dd4bf; }

/* Si hay solo una card, que sea azul siempre */
.content-card:only-child { --card-color: #3b82f6; }

/* Variantes de color manuales */
.content-card.card-blue   { --card-color: #3b82f6; }
.content-card.card-green  { --card-color: #22c55e; }
.content-card.card-orange { --card-color: #f97316; }
.content-card.card-purple { --card-color: #a78bfa; }
.content-card.card-teal   { --card-color: #2dd4bf; }

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.card-title {
    font-size: 15px; font-weight: 700; color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}
.card-title svg { color: var(--card-color, var(--accent)); }
.card-badge {
    font-size: 11px;
    background: rgba(59,130,246,0.12);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(59,130,246,0.2);
    font-weight: 600;
}

/* ---------- GRID UTILITIES RESPONSIVE ---------- */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-sidebar { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
.grid-stats-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; }
.grid-main-chart { display: grid; grid-template-columns: 1fr 380px; gap: 1rem; }

/* ---------- TABLAS RESPONSIVE ---------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- LISTAS ---------- */
.data-list { display: flex; flex-direction: column; gap: 4px; }
.data-row { display: flex; align-items: center; justify-content: space-between; padding: 0.65rem 0.5rem; border-radius: 8px; transition: background 0.15s; }
.data-row:hover { background: var(--bg-hover); }
.data-row-left { display: flex; align-items: center; gap: 10px; }
.data-row-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.data-row-title { font-size: 13px; font-weight: 500; }
.data-row-sub { font-size: 11px; color: var(--text-secondary); }
.data-row-right { text-align: right; }
.data-row-value { font-size: 13px; font-weight: 600; }
.data-row-date { font-size: 11px; color: var(--text-secondary); }

/* ---------- BADGES ---------- */
.badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.badge-success { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-warning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-danger  { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ---------- ALERT BANNER ---------- */
.alert-banner {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; border-radius: 8px; font-size: 13px;
    background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3);
    color: #f59e0b; margin-bottom: 1rem;
}

/* ---------- FORMULARIOS PREMIUM ---------- */
input, select, textarea {
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    background: var(--bg-hover) !important;
    border: 1.5px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 8px;
    padding: 0.6rem 0.875rem;
    transition: all 0.2s ease;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-light) !important;
    background: var(--bg-card) !important;
}
/* Labels de formularios */
label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.375rem;
    letter-spacing: 0.02em;
}

/* ---------- MODALES RESPONSIVE ---------- */
.modal-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}
.modal-backdrop.active { display: flex; }
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 16px;
    padding: 1.75rem;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
    animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.modal-box::before {
    content: '';
    position: absolute;
    top: -20px; right: -20px;
    width: 100px; height: 100px;
    background: var(--accent);
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.08;
    pointer-events: none;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* =============================================
   RESPONSIVE BREAKPOINTS
   ============================================= */

/* ── Tablet grande: 1280px ── */
@media (max-width: 1280px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .dashboard-grid-main { grid-template-columns: 1fr; }
}

/* ── Tablet: 1024px ── */
@media (max-width: 1024px) {
    .dashboard-grid-bottom { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Mobile grande: 768px ── */
@media (max-width: 768px) {

    /* Sidebar se oculta y convierte en drawer */
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        z-index: 300;
        box-shadow: 4px 0 20px rgba(0,0,0,0.4);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: flex; }

    /* Main no tiene margen lateral */
    .main-wrapper { margin-left: 0; }

    /* Botón hamburguesa visible */
    .btn-menu { display: flex !important; }
    
    /* Sidebar always starts hidden on mobile */
    .sidebar { transform: translateX(-100%) !important; }
    .sidebar.open { transform: translateX(0) !important; }

    /* Todas las grids colapsan a 1 columna */
    .grid-2col,
    .grid-3col,
    .grid-sidebar,
    .grid-main-chart,
    .dashboard-grid-main,
    .dashboard-grid-bottom { 
        display: block !important; 
    }
    .grid-2col > *,
    .grid-3col > *,
    .grid-sidebar > *,
    .grid-main-chart > * {
        margin-bottom: 1rem;
    }
    
    /* Stats: 2 columnas en móvil */
    .stats-grid,
    .grid-stats-5 { 
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 0.75rem; 
    }

    /* FORZAR grids inline a colapsar */
    [style*="grid-template-columns: 1fr 340px"],
    [style*="grid-template-columns:1fr 340px"] {
        display: block !important;
    }
    [style*="grid-template-columns: 1fr 340px"] > *,
    [style*="grid-template-columns:1fr 340px"] > * {
        margin-bottom: 1rem;
        width: 100% !important;
    }
    [style*="grid-template-columns: repeat(2,1fr)"],
    [style*="grid-template-columns:repeat(2,1fr)"] {
        grid-template-columns: 1fr !important;
    }
    [style*="grid-template-columns: repeat(3,1fr)"],
    [style*="grid-template-columns:repeat(3,1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }


    /* Topbar compacta */
    .topbar { padding: 0 1rem; }
    .topbar-date { display: none; }
    .topbar-left h2 { font-size: 1rem; }
    .topbar-left p { display: none; }

    /* Stats: 2 columnas */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .stat-card-value { font-size: 1.4rem; }

    /* Padding reducido */
    .page-content { padding: 1rem; }

    /* Grids a 1 columna */
    .dashboard-grid-main,
    .dashboard-grid-bottom { grid-template-columns: 1fr; }

    /* Grids personalizados de módulos */
    div[style*="grid-template-columns: 1fr 340px"] {
        display: block !important;
    }
    div[style*="grid-template-columns: 1fr 340px"] > div {
        margin-bottom: 1rem;
    }
    div[style*="grid-template-columns: repeat(2,1fr)"] {
        grid-template-columns: 1fr !important;
    }
    div[style*="grid-template-columns: repeat(3,1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Tablas con scroll horizontal */
    .content-card { padding: 1rem; overflow: hidden; word-wrap: break-word; }
    .content-card.table-desktop { padding: 0; }
    .content-card table { min-width: 560px; }

    /* Stat cards: evitar desbordamiento */
    .stat-card { overflow: hidden; min-width: 0; }
    .stat-card-value { font-size: 1.4rem; word-break: break-all; }

    /* Filtros: 1 columna en móvil */
    .filter-grid { grid-template-columns: 1fr !important; gap: 1rem; }
    .filter-card { padding: 1rem; overflow: hidden; }

    /* Modales a pantalla completa */
    .modal-backdrop { padding: 0.5rem; align-items: flex-end; }
    .modal-box { max-width: 100%; border-radius: 12px 12px 0 0; }
    div[style*="max-width:420px"], div[style*="max-width:400px"], 
    div[style*="max-width:450px"], div[style*="max-width:500px"], 
    div[style*="max-width:600px"], div[style*="max-width:640px"], 
    div[style*="max-width:700px"] { max-width: 100% !important; }

    /* Botones de acción en tabla: columna */
    td div[style*="display:flex;gap:.4rem"] {
        flex-direction: column !important;
        gap: 4px !important;
    }
    td div[style*="display:flex;gap:.5rem"] {
        flex-direction: column !important;
        gap: 4px !important;
    }

    /* Filtros en fila scrollable */
    div[style*="display:flex;gap:.5rem;margin-bottom:1.25rem"] {
        overflow-x: auto;
        padding-bottom: 4px;
        flex-wrap: nowrap !important;
    }

    /* Acciones del topbar */
    div[style*="display:flex; gap:1rem"] {
        gap: 0.5rem !important;
    }

    /* Ocultar fecha en topbar de módulos */
    .topbar-right .topbar-date { display: none; }

    /* Cards stat más compactas */
    .stat-card { padding: 0.875rem 1rem; overflow: hidden; min-width: 0; }
}

/* ── Mobile pequeño: 480px ── */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.625rem; }
    .stat-card-value { font-size: 1.25rem; word-break: break-all; }
    .stat-card-title { font-size: 10.5px; }
    .page-content { padding: 0.75rem; }

    .topbar-left h2 { font-size: 0.875rem; }
    .topbar { padding: 0 0.75rem; }
    .stat-card { padding: 0.75rem; }

    /* Modales anclados al fondo en mobile pequeño */
    div[style*="position:fixed"][style*="align-items:center"] {
        align-items: flex-end !important;
        padding: 0 !important;
    }
    div[style*="max-width:420px"], div[style*="max-width:400px"], 
    div[style*="max-width:450px"], div[style*="max-width:500px"], 
    div[style*="max-width:600px"], div[style*="max-width:640px"], 
    div[style*="max-width:700px"] {
        max-width: 100% !important;
        border-radius: 12px 12px 0 0 !important;
        margin: 0 !important;
    }

    /* Botones de acción en tablas: apilados */
    td > div { flex-direction: column !important; gap: 3px !important; }
    td > div > button, td > div > form > button {
        width: 100%;
        text-align: center;
    }

    /* Inputs y selects full width */
    input[type="number"], input[type="text"], input[type="date"], select {
        min-height: 42px;
        font-size: 16px !important; /* Evita zoom en iOS */
    }

    .modal-box { padding: 1rem; border-radius: 12px 12px 0 0; }

    /* Ocultar columnas secundarias en tablas pequeñas */
    .hide-mobile { display: none !important; }
}


/* =============================================
   FILTROS Y REPORTES
   ============================================= */
.filter-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.time-filters {
    display: flex;
    background: var(--bg-hover);
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

.time-btn {
    flex: 1;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary) !important;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.time-btn:hover { color: var(--accent) !important; }
.time-btn.active {
    background: var(--accent) !important;
    color: white !important;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.date-range {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 0.75rem;
}

.date-range input {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    width: 100%;
}

.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.btn-filter-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.btn-print { background: var(--bg-hover) !important; color: var(--text-primary) !important; }
.btn-print:hover { background: var(--accent) !important; border-color: var(--accent) !important; color: white !important; }

.btn-clear { background: transparent; color: var(--text-secondary); }
.btn-clear:hover { color: var(--danger); border-color: var(--danger); }

/* Estilos para Impresión */
@media print {
    .sidebar, .topbar, .filter-card, .btn-float, .sidebar-overlay { display: none !important; }
    .main-wrapper { margin-left: 0 !important; padding: 0 !important; }
    .page-content { padding: 0 !important; }
    .content-card { border: none !important; box-shadow: none !important; }
    body { background: white !important; color: black !important; }
    table { width: 100% !important; color: black !important; }
    tr { border-bottom: 1px solid #ddd !important; }
    .badge { border: 1px solid #ddd !important; color: black !important; background: white !important; }
}

/* ==============================================
   DISEÑO PREMIUM GLOBAL — TABLAS Y UI
   ============================================== */

/* Tablas premium */
table {
    width: 100%;
    border-collapse: collapse;
}
thead tr {
    background: var(--bg-hover);
    border-bottom: 2px solid var(--accent);
}
thead th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    white-space: nowrap;
}
tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover) !important; }
td {
    padding: 0.875rem 1rem;
    font-size: 14px;
    color: var(--text-primary);
    vertical-align: middle;
}

/* Filter-card premium */
.filter-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.filter-card::before {
    content: '';
    position: absolute;
    top: -10px; right: -10px;
    width: 100px; height: 100px;
    background: var(--accent);
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.07;
    pointer-events: none;
}

/* Sidebar premium: borde izquierdo en activo */
.nav-item.active {
    background: var(--accent-light) !important;
    color: var(--accent) !important;
    border-left: 3px solid var(--accent);
    padding-left: calc(0.75rem - 3px);
}

/* Topbar premium */
.topbar {
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 8px rgba(0,0,0,0.15);
}
[data-theme="light"] .topbar {
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

/* Stat cards: animación de entrada suave */
.stat-card {
    animation: cardIn 0.4s ease both;
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }

/* Botones de acción en tablas */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn-action-edit {
    background: rgba(59,130,246,0.1);
    color: #3b82f6;
    border-color: rgba(59,130,246,0.25);
}
.btn-action-edit:hover { background: #3b82f6; color: white; }
.btn-action-delete {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
    border-color: rgba(239,68,68,0.25);
}
.btn-action-delete:hover { background: #ef4444; color: white; }
.btn-action-success {
    background: rgba(34,197,94,0.1);
    color: #22c55e;
    border-color: rgba(34,197,94,0.25);
}
.btn-action-success:hover { background: #22c55e; color: white; }

/* Page content: animación de entrada */
.page-content {
    animation: pageIn 0.3s ease;
}
@keyframes pageIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ==============================================
   GRID DE TARJETAS Y MODALES PREMIUM
   ============================================== */

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
.grid-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.25rem;
}
@media (max-width: 768px) {
    .grid-2col, .grid-3col {
        grid-template-columns: 1fr;
    }
}


.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Animación de entrada para el grid */
.cat-grid > * {
    animation: fadeInScale 0.4s ease backwards;
}
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.cat-actions {
    display: flex;
    gap: 6px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-icon.delete:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239,68,68,0.1);
}

/* Modales Premium */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent);
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 550px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin: auto;
    position: relative;
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
    from { transform: scale(0.9) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-box label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.modal-box input, 
.modal-box select, 
.modal-box textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-hover) !important;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s;
}

.modal-box input:focus, 
.modal-box select:focus, 
.modal-box textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}

/* ═══════════════════════════════════════════
   BOTTOM NAVIGATION BAR (Mobile)
   ═══════════════════════════════════════════ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    z-index: 500;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom);
    backdrop-filter: blur(12px);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    .bottom-nav { display: flex; }
    .page-content { padding-bottom: calc(var(--bottom-nav-height) + 1rem) !important; }
    .fab-container { bottom: calc(var(--bottom-nav-height) + 24px); z-index: 600; }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 10px;
    transition: all 0.2s;
    min-width: 56px;
}
.bottom-nav-item.active {
    color: var(--accent);
}
.bottom-nav-item.active svg {
    filter: drop-shadow(0 0 6px var(--accent-glow));
}
.bottom-nav-item:active {
    transform: scale(0.92);
}

.bottom-nav-center {
    position: relative;
    top: -12px;
}
.bottom-nav-center .center-bubble {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0891b2, #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(8,145,178,0.45);
    border: 3px solid var(--bg-sidebar);
    transition: transform 0.2s, box-shadow 0.2s;
}
.bottom-nav-center:active .center-bubble {
    transform: scale(0.92);
}

@keyframes slideUpSheet {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ═══════════════════════════════════════════
   FLOATING ACTION BUTTON (FAB)
   ═══════════════════════════════════════════ */
.fab-container {
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 600;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.fab-button {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px var(--accent-glow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.fab-button:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px var(--accent-glow);
}
.fab-button.open svg {
    transform: rotate(45deg);
}

.fab-options {
    display: none;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    animation: fabIn 0.25s ease;
}
.fab-options.open { display: flex; }

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

.fab-option {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    animation: fabItemIn 0.2s ease backwards;
}
.fab-option:nth-child(1) { animation-delay: 0.02s; }
.fab-option:nth-child(2) { animation-delay: 0.06s; }
.fab-option:nth-child(3) { animation-delay: 0.10s; }
.fab-option:nth-child(4) { animation-delay: 0.14s; }

@keyframes fabItemIn {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
}

.fab-option span {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}
.fab-option-icon {
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════
   NAV-GROUP (Collapsible Sidebar Sections)
   ═══════════════════════════════════════════ */
.nav-group { margin-bottom: 2px; }
.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s;
    min-height: 44px;
}
.nav-group-toggle:hover { background: var(--bg-hover); color: var(--accent); }
.nav-group-toggle svg:first-child { width: 16px; height: 16px; flex-shrink: 0; }
.nav-group-toggle span { flex: 1; text-align: left; }
.nav-group-toggle .chevron {
    transition: transform 0.2s;
    opacity: 0.5;
}
.nav-group.open .nav-group-toggle .chevron {
    transform: rotate(180deg);
}
.nav-group.open .nav-group-toggle {
    color: var(--accent);
}

.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    padding-left: 12px;
}
.nav-group.open .nav-group-items {
    max-height: 300px;
}

/* ═══════════════════════════════════════════
   CARD-LIST (Mobile Cards instead of Tables)
   ═══════════════════════════════════════════ */
.card-list {
    display: none; /* Solo se muestra en mobile */
    flex-direction: column;
    gap: 10px;
}
.card-list-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow 0.2s;
    overflow: hidden;
    word-break: break-word;
}
.card-list-item:active {
    box-shadow: var(--shadow-md);
}
.card-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-list-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.card-list-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}
.card-list-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.card-list-detail {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.card-list-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}
.card-list-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.card-list-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .card-list { display: flex; }
    .table-desktop { display: none !important; }
}
@media (min-width: 769px) {
    .card-list { display: none; }
}
