:root {
  /* Colores extraídos del proyecto anterior */
  --brand: #009F4D;
  --brand-2: #1F71B5;
  --lime: #66BD45;
  
  /* Tema claro para Trimestres */
  --bg: #f4f7f6;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-solid: #ffffff;
  --surface-soft: rgba(248, 250, 249, 0.5);
  --ink: #2c3e50;
  --muted: #64748b;
  --line: rgba(0, 0, 0, 0.08);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --glass: blur(12px);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }

* { box-sizing: border-box; }
body { 
    margin: 0; 
    background: var(--bg); 
    color: var(--ink); 
    font-family: 'Inter', system-ui, sans-serif; 
    min-height: 100vh;
}
h1, h2, h3 { color: var(--ink); margin-top: 0; }
.page-grid { margin-top: 2rem; }

/* Modal Glassmorphism */
.modal-glass {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-glass.active {
    opacity: 1;
    pointer-events: all;
}
.modal-content {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.4);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border-radius: 20px;
    padding: 2.5rem;
    width: 90%;
    max-width: 600px;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}
.modal-glass.active .modal-content {
    transform: translateY(0) scale(1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 1rem;
}
.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--brand);
}
.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
    transition: color 0.2s;
}
.close-modal:hover { color: var(--ink); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.stat-card {
    background: rgba(255,255,255,0.6);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}
.stat-card span {
    display: block;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}
.stat-card strong {
    display: block;
    font-size: 1.2rem;
    color: var(--ink);
    word-break: break-word;
    line-height: 1.3;
}
.stat-card.highlight {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border: none;
}
.stat-card.highlight span, .stat-card.highlight strong {
    color: #fff;
}
.btn-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    transition: 0.3s;
    box-shadow: var(--shadow);
}
.btn-stats:hover {
    border-color: var(--brand);
    color: var(--brand);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 159, 77, 0.15);
}
a { color: var(--lime); text-decoration: none; }

/* Views */
.view { display: none; opacity: 0; transition: opacity 0.4s ease; }
.view.active { display: block; opacity: 1; }

/* Login */
#login-view {
    display: none; 
    height: 100vh;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% -20%, color-mix(in srgb, var(--brand) 10%, var(--bg)), var(--bg));
}
#login-view.active { display: flex; }

.login-container {
    background: var(--surface);
    padding: 3rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.brand h1 { font-weight: 800; font-size: 2.2rem; margin: 0; color: var(--brand); }
.brand p { margin: 0 0 2rem; color: var(--muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 2px;}

.input-group { margin-bottom: 1.5rem; }
.input-group label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.input-group input { 
    width: 100%; 
    padding: 0.9rem; 
    border: 1px solid var(--line); 
    border-radius: 6px; 
    background: var(--surface-soft); 
    color: var(--ink); 
    font-family: inherit;
    transition: border-color 0.3s;
}
.input-group input:focus { outline: none; border-color: var(--brand); }

.btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 1rem;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 40%, transparent); }

.error-box { background: rgba(255, 60, 60, 0.1); color: #ff5555; padding: 1rem; border-radius: 6px; border: 1px solid rgba(255, 60, 60, 0.2); margin-bottom: 1.5rem; font-size: 0.9rem;}

/* Dashboard */
#dashboard-view {
    background: linear-gradient(to bottom, transparent 0%, transparent 75px, rgba(0, 159, 77, 0.15) 75px, #ffffff 800px);
    background-attachment: fixed;
    min-height: 100vh;
}
.nav-shell { display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; background-color: #fff; border-bottom: 1px solid #e0e0e0; box-shadow: 0 4px 20px rgba(0,0,0,0.05); margin-bottom: 2rem; position: sticky; top: 0; z-index: 1000; }
.brand-small { font-weight: 800; color: var(--brand); font-size: 1.2rem; }
.username-highlight { color: var(--brand-2); font-weight: 800; font-size: 1.1rem; }
.icon-btn { background: var(--surface-soft); border: 1px solid var(--line); color: var(--ink); padding: 0.5rem 1rem; border-radius: 999px; cursor: pointer; transition: 0.3s; }
.icon-btn:hover { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
nav { display: flex; gap: 1.5rem; align-items: center; font-size: 0.95rem; }

.dashboard-content {
        position: relative !important; padding: 3rem; max-width: 1400px; margin: 0 auto; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; }
.intro h2 { color: var(--brand); font-weight: 800; font-size: 1.8rem; margin: 0; }
.filters { display: flex; gap: 1rem; align-items: center; }
.search-box { display: flex; align-items: center; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 999px; padding: 0.5rem 1rem; gap: 0.5rem; transition: 0.3s; box-shadow: var(--shadow); }
.search-box:focus-within { border-color: var(--brand-2); box-shadow: 0 4px 15px rgba(31, 113, 181, 0.15); }
.search-box svg { color: var(--muted); }
.search-box input { border: none; background: transparent; outline: none; color: var(--ink); font-family: inherit; font-size: 0.95rem; width: 100%; max-width: 220px; transition: max-width 0.3s; }
.search-box input:focus { max-width: 260px; }

/* Custom Select */
.custom-select { position: relative; font-family: inherit; font-weight: 600; font-size: 0.95rem; min-width: 240px; }
.select-selected { background-color: var(--brand); color: #ffffff; padding: 0.8rem 1.2rem; border-radius: 999px; cursor: pointer; box-shadow: 0 4px 15px rgba(0, 159, 77, 0.2); user-select: none; display: flex; justify-content: space-between; align-items: center; transition: transform 0.2s; }
.select-selected:hover { transform: translateY(-2px); }
.select-selected::after { content: ""; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 5px solid #fff; transition: 0.3s; }
.select-selected.select-arrow-active::after { transform: rotate(180deg); }
.select-items { position: absolute; background-color: #ffffff; top: 100%; left: 0; right: 0; margin-top: 8px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); z-index: 99; overflow: hidden; border: 1px solid var(--line); }
.select-hide { display: none; }
.select-items div { color: var(--ink); padding: 0.8rem 1.2rem; cursor: pointer; transition: 0.2s; border-bottom: 1px solid var(--line); }
.select-items div:last-child { border-bottom: none; }
.select-items div:hover, .same-as-selected { background-color: var(--brand); color: #ffffff; }

/* KPIs */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}
.kpis article {
    background: linear-gradient(135deg, var(--brand-2), #0b5087);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: none;
    box-shadow: 0 10px 25px rgba(31, 113, 181, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.3s;
    color: #fff;
}
.kpis article:hover { transform: translateY(-4px); }
.kpis span { color: rgba(255, 255, 255, 0.8); font-size: 0.9rem; font-weight: 600; text-transform: uppercase; }
.kpis strong { font-size: 2.5rem; font-weight: 800; color: #fff; line-height: 1; }

/* Table */
.table-container {
    background: var(--surface-solid);
    border: none;
    border-top: 4px solid var(--brand);
    border-radius: var(--radius);
    overflow-y: auto;
    overflow-x: auto;
    max-height: calc(100vh - 12rem);
    box-shadow: 0 15px 40px rgba(31, 113, 181, 0.08);
}
.premium-table { width: 100%; border-collapse: collapse; text-align: left; }
.premium-table th { 
    background: color-mix(in srgb, var(--brand-2) 5%, white); 
    padding: 1rem 1.5rem; 
    font-weight: 600; 
    color: var(--brand-2); 
    font-size: 0.85rem; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    border-bottom: 1px solid color-mix(in srgb, var(--brand-2) 10%, white); 
    position: sticky; 
    top: 0; 
    z-index: 10; 
}
.premium-table td { padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.premium-table tbody tr { transition: background 0.2s; }
.premium-table tbody tr:hover { background: color-mix(in srgb, var(--brand-2) 3%, white); }
.text-right { text-align: right; }

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

.fade-in {
    opacity: 0;
    transform: translateY(15px);
    animation: fadeUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Layout con Sidebar */
.app-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}
.sidebar-menu {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--surface-solid);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}
.sidebar-menu h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 1px;
    margin-bottom: 1rem;
}
.main-panel {
    flex-grow: 1;
    min-width: 0;
}
.tab-btn {
    background: transparent;
    border: none;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    transition: 0.3s;
    text-align: left;
    width: 100%;
}
.tab-btn:hover {
    background: var(--surface-soft);
}
.tab-btn.active {
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    color: var(--brand);
    border-left: 3px solid var(--brand);
    border-radius: 0 8px 8px 0;
}

/* Pivot Table */
.pivot-table th:first-child, .pivot-table td:first-child {
    padding-left: 2rem;
}
.pivot-row-group {
    background: rgba(0,0,0,0.03);
    font-weight: 800;
    cursor: pointer;
}
.pivot-row-group:hover {
    background: rgba(0,0,0,0.06) !important;
}
.pivot-row-detail {
    font-size: 0.9rem;
}
.pivot-row-detail td:first-child {
    padding-left: 3rem;
    color: var(--muted);
}
.diff-pos {
    color: var(--brand);
    font-weight: 600;
}
.diff-neg {
    color: #ff5555;
    font-weight: 600;
}
/* Layout con Sidebar y Excel View */
.dashboard-top {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: center;
}
.summary-box {
    flex: 1;
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.chart-box {
    width: 300px;
    height: 200px;
}
.mini-table {
    width: 100%;
    border-collapse: collapse;
}
.mini-table th {
    text-align: left;
    border-bottom: 2px solid var(--line);
    padding: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.mini-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--surface-soft);
    font-size: 0.9rem;
    font-weight: 600;
}
.toggle-icon {
    display: inline-block;
    width: 20px;
    transition: transform 0.2s;
}
.toggle-icon.expanded {
    transform: rotate(90deg);
}

/* Scroll to top button */
.btn-scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--brand);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.btn-scroll-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.btn-scroll-top:hover {
    background-color: color-mix(in srgb, var(--brand) 80%, black);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.btn-scroll-top.show:hover {
    transform: translateY(-3px);
}



.mobile-only { display: none !important; }
.hamburger-btn { display: none; }
.sidebar-overlay { display: none; }

/* Mobile Responsiveness */


/* Ocultar lupa para administradores en todas las vistas (PC y móvil) */
#toolbar-center.is-admin .filters {
    display: none !important;
}

@media (max-width: 1024px) {
    .nav-shell { display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; background-color: #fff; border-bottom: 1px solid #e0e0e0; box-shadow: 0 4px 20px rgba(0,0,0,0.05); margin-bottom: 2rem; position: sticky; top: 0; z-index: 1000; }
    
    nav#desktop-nav {
        display: none !important;
    }
    
    .hamburger-btn {
        display: block !important;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0.5rem;
        color: var(--text-dark);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .mobile-only { display: flex !important; }

    .dashboard-content {
        position: relative !important;
        padding: 1rem;
    }

    .intro {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .filters {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .filters > * {
        flex: 1 1 100%;
    }

    .app-layout, .dashboard-top {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        width: 100%;
    }

    .main-panel {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .sidebar-menu {
        position: fixed;
        top: 0;
        left: -320px;
        width: 280px;
        max-height: 100vh;
        height: 100vh;
        z-index: 1000;
        background: var(--surface-solid);
        border-radius: 0;
        margin: 0;
        flex-direction: column;
        overflow-y: auto;
        transition: left 0.3s ease;
        padding: 1.5rem;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
        border: none;
    }
    
    .sidebar-menu.open {
        left: 0;
    }
    
    .sidebar-menu h3 { display: block; }
    
    .sidebar-menu .tab-btn {
        width: 100%;
        text-align: left;
        white-space: normal;
        border-bottom: none;
        border-left: 3px solid transparent;
        padding: 0.6rem 1rem;
        border-radius: 8px;
    }

    .sidebar-menu .tab-btn.active {
        border-bottom: none;
        border-left: 3px solid var(--brand);
        border-radius: 8px;
    }

    .kpis {
        grid-template-columns: 1fr;
    }

    .premium-table th, .premium-table td {
        padding: 0.8rem 0.5rem;
        font-size: 0.85rem;
    }

    .chart-box {
        padding: 1rem;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .btn-scroll-top {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }

    /* Header modifications for mobile */
    .nav-shell {
        padding: 0.8rem 1rem !important;
    }
    #mobile-menu-btn {
        display: flex !important;
        margin-right: 1rem;
    }
    .brand-small { display: none !important; }
    
    /* Ensure the table container acts responsive */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100vw;
        margin-left: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Sidebar adjustments */
    .sidebar-menu {
        width: 300px !important;
        left: -320px !important;
        padding: 0 !important;
    }
    .sidebar-menu.open {
        left: 0 !important;
    }
    .sidebar-menu > div {
        padding: 1.5rem;
    }

    /* Tabs styling for mobile */
    .sidebar-menu .tab-btn {
        display: flex;
        align-items: center;
        gap: 0.8rem;
        color: var(--text-dark);
        font-weight: 500;
        font-size: 0.95rem;
        padding: 0.8rem 1rem !important;
    }
    .sidebar-menu .tab-btn.active {
        background: #eef9f2;
        color: var(--brand);
        border-left: none !important;
    }

    /* ICONS */
    /* Configuracion */
    .tab-btn[data-target="configuracion"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"></path><circle cx="12" cy="12" r="3"></circle></svg>'); }
    /* Resumen */
    .tab-btn[data-target="resumen"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>'); }
    /* Resumen x Cliente */
    .tab-btn[data-target="resumen_cliente"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>'); }
    /* Resumen x Cliente Completo */
    .tab-btn[data-target="resumen_cliente_completo"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"></line><line x1="12" y1="20" x2="12" y2="4"></line><line x1="6" y1="20" x2="6" y2="14"></line></svg>'); }
    /* Resumen x Familias */
    .tab-btn[data-target="resumen_familias"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>'); }
    /* Resumen x Zonas */
    .tab-btn[data-target="resumen_zonas"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path><circle cx="12" cy="10" r="3"></circle></svg>'); }
    /* Resumen SUCA */
    .tab-btn[data-target="resumen_suca"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>'); }
    
    /* Client Tabs */
    .tab-btn[data-target="resumen-completo"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>'); }
    .tab-btn[data-target="agroquimicos"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="fauna"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="colmenas"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="carburantes"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="ferreteria"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="riego"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="tiendas"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="resumen-zona"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path><circle cx="12" cy="10" r="3"></circle></svg>'); }
    .tab-btn[data-target="resumen-suca"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>'); }



    /* Header modifications for mobile */
    .nav-shell {
        padding: 0.8rem 1rem !important;
    }
    #mobile-menu-btn {
        display: flex !important;
        margin-right: 1rem;
    }
    .brand-small { display: none !important; }
    
    /* Ensure the table container acts responsive */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100vw;
        margin-left: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Sidebar adjustments */
    .sidebar-menu {
        width: 300px !important;
        left: -320px !important;
        padding: 0 !important;
    }
    .sidebar-menu.open {
        left: 0 !important;
    }
    .sidebar-menu > div {
        padding: 1.5rem;
    }

    /* Tabs styling for mobile */
    .sidebar-menu .tab-btn {
        display: flex;
        align-items: center;
        gap: 0.8rem;
        color: var(--text-dark);
        font-weight: 500;
        font-size: 0.95rem;
        padding: 0.8rem 1rem !important;
    }
    .sidebar-menu .tab-btn.active {
        background: #eef9f2;
        color: var(--brand);
        border-left: none !important;
    }

    /* ICONS */
    /* Configuracion */
    .tab-btn[data-target="configuracion"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"></path><circle cx="12" cy="12" r="3"></circle></svg>'); }
    /* Resumen */
    .tab-btn[data-target="resumen"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>'); }
    /* Resumen x Cliente */
    .tab-btn[data-target="resumen_cliente"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>'); }
    /* Resumen x Cliente Completo */
    .tab-btn[data-target="resumen_cliente_completo"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"></line><line x1="12" y1="20" x2="12" y2="4"></line><line x1="6" y1="20" x2="6" y2="14"></line></svg>'); }
    /* Resumen x Familias */
    .tab-btn[data-target="resumen_familias"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>'); }
    /* Resumen x Zonas */
    .tab-btn[data-target="resumen_zonas"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path><circle cx="12" cy="10" r="3"></circle></svg>'); }
    /* Resumen SUCA */
    .tab-btn[data-target="resumen_suca"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>'); }
    
    /* Client Tabs */
    .tab-btn[data-target="resumen-completo"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>'); }
    .tab-btn[data-target="agroquimicos"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="fauna"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="colmenas"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="carburantes"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="ferreteria"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="riego"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="tiendas"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>'); }
    .tab-btn[data-target="resumen-zona"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path><circle cx="12" cy="10" r="3"></circle></svg>'); }
    .tab-btn[data-target="resumen-suca"]::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>'); }



    /* Mobile header layout fixes */
    .nav-shell {
        flex-wrap: wrap !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }
    
    .nav-left {
        min-width: 0 !important;
        flex: 1 !important;
        order: 1 !important;
    }
    
    .nav-shell nav {
        min-width: 0 !important;
        order: 2 !important;
    }
    
    .nav-center#toolbar-center {
        order: 3 !important;
        width: 100% !important;
        flex: 1 1 100% !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: flex-start !important;
    }
    
    #section-title {
        font-size: 1.2rem !important;
        white-space: normal !important;
    }
    
    .search-box {
        width: 100% !important;
        max-width: 100% !important;
    }
    .search-box input {
        max-width: 100% !important;
    }
    
    #toolbar-logo {
        position: static !important;
        height: 30px !important;
    }


    /* Bruteforce horizontal overflow fix WITHOUT breaking sticky */
    html, body {
        overflow-x: hidden !important; 
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .app-layout, .main-panel {
        
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .nav-shell {
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
    }
    
    .dashboard-content {
        position: relative !important;
        padding: 1rem !important; /* Restore normal padding */
    }

    
    .dashboard-content {
        position: relative !important;
        padding: 1rem !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
    
    .premium-table {
        min-width: 600px; /* Force table to be wide so it scrolls inside container */
    }
    
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }


    /* Hide desktop buttons in mobile header, since they are in the sidebar now */
    nav#desktop-nav, 
    .nav-shell nav #btn-logout, 
    .nav-shell nav #btn-download-pdf {
        display: none !important;
    }
    
    .nav-shell nav {
        justify-content: flex-end !important;
    }



    /* Fix Client Welcome Screen Logo on Mobile */
    #client-welcome-screen {
        min-height: 60vh !important;
    }
    


    /* Fix horizontal scroll bleeding from charts or grids */
    .dashboard-content, .app-layout, .page-grid, .view {
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
    
    .chart-box {
        max-width: 100% !important;
        overflow-x: auto !important;
        padding: 1rem !important;
        box-sizing: border-box !important;
    }
    



    /* Hard-limit all potentially overflowing containers */
    .premium-table {
        min-width: 500px !important;
    }
    .page-grid {
        width: 100% !important;
        max-width: 100vw !important;
    }


    /* Critical CSS Grid/Flex fix to prevent items from blowing out their containers */
    .table-container, .chart-box, .page-grid, .page-grid > * {
        min-width: 0 !important;
    }
    
    .page-grid {
        padding: 1rem !important; /* Overriding the massive 2.5rem inline padding for mobile */
    }


    .dashboard-content, .app-layout {
        min-width: 0 !important;
    }



    

    .premium-table th, .premium-table td {
        white-space: nowrap !important;
    }


    /* Ultimate Mobile Layout Lock: Make app-layout the scroll container to preserve sticky and kill horizontal scroll */
    html, body {
        overflow: hidden !important; /* Lock body completely on mobile */
        width: 100% !important;
        height: 100% !important;
        position: fixed !important; /* iOS fix */
    }
    
    .app-layout {
        height: 100vh !important;
        width: 100vw !important;
        overflow-y: auto !important; /* This becomes the main vertical scroll */
        overflow-x: hidden !important; /* Kills horizontal scroll */
        -webkit-overflow-scrolling: touch !important;
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .main-panel {
        flex: 0 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .nav-shell {
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        width: 100% !important;
    }


    /* Absolute safeguard against ANY rogue wide elements inside the main content area */
    .dashboard-content div, 
    .dashboard-content section, 
    .dashboard-content canvas {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Ensure the chart wrappers specifically are allowed to shrink */
    .dashboard-content [style*="display: flex"] {
        min-width: 0 !important;
    }
    
    /* Remove any negative margins from table containers that might persist */
    .table-container {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }


    /* Kill Safari iOS horizontal rubber-banding completely */
    html, body, .app-layout, .main-panel {
        overscroll-behavior-x: none !important;
        overscroll-behavior-y: none !important; /* Optionally stop vertical bounce on body, app-layout handles internal scroll */
    }


    /* Safely allow tables to scroll horizontally without breaking layout or cutting off the left edge */
    .responsive-table-wrapper {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin-bottom: 1rem !important;
        box-sizing: border-box !important;
    }
    
    .premium-table {
        min-width: 500px !important; /* Allow the table to stretch inside the wrapper so it scrolls */
        width: 100% !important;
    }


    /* Ensure dashboard-content also doesn't bounce vertically on iOS, preventing fake gaps */
    .dashboard-content {
        position: relative !important;
        overscroll-behavior-y: none !important;
    }


    /* Ensure the welcome screen immediately yields space as soon as JS hides it via opacity */
    #client-welcome-screen[style*="opacity: 0"] {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
    }
    
    /* Ensure no huge gaps from un-collapsed margins */
    .table-container {
        margin-top: 0 !important;
    }
    
    /* Ensure the main content doesn't have stray gaps */
    .dashboard-content {
        position: relative !important;
        gap: 0 !important;
    }


    /* BRUTAL layout gap kill */
    .dashboard-content {
        position: relative !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    .table-container {
        padding-top: 0 !important;
        margin-top: 0 !important;
        gap: 0 !important;
        display: block !important;
    }
    

    
    /* Ensure the wrapper does not add any invisible top space */
    .responsive-table-wrapper {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Ensure headings inside the cards don't have crazy top margins */
    .dashboard-content h3 {
        margin-top: 0 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }


    /* Bulletproof welcome screen hider on mobile */
    #client-welcome-screen[style*="opacity: 0"],
    #client-welcome-screen[style*="opacity:0"],
    #client-welcome-screen[style*="opacity : 0"],
    #client-welcome-screen[style*="opacity: 0;"],
    #client-welcome-screen[style*="opacity:0;"] {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .dashboard-content {
        position: relative !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    .table-container {
        padding-top: 0 !important;
        margin-top: 0 !important;
        gap: 0 !important;
    }


    /* Absolute positioning for welcome screen on mobile to GUARANTEE it takes zero vertical space in the flow */
    #client-welcome-screen {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 50 !important;
        pointer-events: none !important;
        background: transparent !important;
        /* Let flex alignment still work inside it for the logo */
    }
    
    /* Also nuke the intro header just in case it was taking space invisibly */
    #client-intro-header {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }


    /* KILL THE NAV-SHELL MARGIN-BOTTOM THAT WAS CREATING THE GREEN GAP */
    .nav-shell {
        margin-bottom: 0 !important;
        border-bottom: none !important; /* optional, to make it flush */
    }


    /* Fix fat toolbar on welcome screen by completely hiding invisible elements */
    #toolbar-center[style*="opacity: 0"],
    #toolbar-center[style*="opacity:0"],
    #toolbar-center[style*="opacity : 0"] {
        display: none !important;
    }
    
    #toolbar-logo[style*="opacity: 0"],
    #toolbar-logo[style*="opacity:0"],
    #toolbar-logo[style*="opacity : 0"] {
        display: none !important;
    }
    
    /* Fix squished big logo on iOS */
    


    #client-welcome-screen img {
        width: auto !important;
        max-width: 80% !important;
        height: auto !important;
        max-height: 80vh !important;
        transform: translateY(0) !important;
        flex-shrink: 0 !important;
        object-fit: contain !important;
        display: block !important;
        margin: auto !important;
    }


    /* Ensure page-grid (the table section container) has no top margin pushing it down */
    .page-grid {
        margin-top: 0 !important;
    }

}