* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-caretta);
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
}

body::-webkit-scrollbar { width: 10px; }
body::-webkit-scrollbar-track { background: var(--surface-color); }
body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 5px; }

.hidden { display: none !important; }

#ux-health-dot,
#data-freshness-pill {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Utilities */
.flex { display: flex; }
.flex-column { flex-direction: column; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.mb-1 { margin-bottom: 1.5rem; }
.color-primary { color: var(--primary-color) !important; }

/* Layout */
.dashboard-container { display: flex; min-height: 100vh; }

/* Sidebar — compact, 240px */
.sidebar {
    width: 240px;
    min-width: 240px;
    flex: 0 0 240px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    padding: 1.5rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--elev-1);
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.logo img {
    max-width: 100%;
    height: auto;
    max-height: 42px;
    object-fit: contain;
}

.logo h2 {
    font-size: 0.95rem;
    color: var(--text-soft);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.menu { flex: 1; margin-top: 0.25rem; overflow-y: auto; padding-right: 2px; }
.menu::-webkit-scrollbar { width: 4px; }
.menu::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }

/* Grupuri vizuale în sidebar — toate modulele rămân accesibile,
   sunt doar reorganizate pe paliere logice. */
.menu-group { margin-bottom: 0.85rem; }
.menu-group-title {
    display: block;
    margin: 0 0 4px;
    padding: 0 12px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}
/* Grup fără itemi vizibili (ex. Administrare pentru non-admin) — colapsat */
.menu-group:not(:has(> a:not(.hidden))) { display: none; }

.menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--text-soft);
    text-decoration: none;
    border-radius: 8px;
    border-left: 3px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    font-weight: 500;
    font-size: 0.88rem;
    margin-bottom: 2px;
}

.menu a i {
    width: 16px;
    text-align: center;
    font-size: 0.92rem;
    color: var(--text-faint);
}

.menu a:hover {
    background-color: var(--bg-subtle);
    color: var(--text-default);
}
.menu a:hover i { color: var(--caretta-navy); }

.menu a.active {
    background-color: var(--caretta-navy-50);
    color: var(--caretta-navy);
    font-weight: 600;
    border-left-color: var(--caretta-navy);
}
.menu a.active i { color: var(--caretta-navy); }

.sidebar-footer { font-size: 0.72rem; color: var(--text-faint); text-align: center; margin-top: auto; border-top: 1px solid var(--border-subtle); padding-top: 0.75rem; }

/* Main Content — padding compact pentru densitate premium */
.main-content {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

@media (max-width: 1280px) {
    .main-content { padding: 1.25rem 1.5rem; }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 1rem;
}

.header-left h1 {
    font-size: var(--fs-display);
    font-weight: 700;
    color: var(--caretta-navy);
    margin-bottom: 0.15rem;
    letter-spacing: -0.01em;
}
.header-left p { color: var(--text-soft); font-size: 0.92rem; }

/* RESPONSIVE DESIGN - OPTIMIZARE MOBILE/TABLETĂ */
@media (max-width: 1024px) {
    .dashboard-view { min-width: auto !important; }
    .charts-row { grid-template-columns: 1fr; }
    .chart-container { flex: 1 1 100%; }
}

@media (max-width: 768px) {
    .dashboard-container { flex-direction: column; }
    
    .sidebar { 
        width: 100%; 
        border-right: none; 
        border-bottom: 1px solid var(--border-color); 
        padding: 0.8rem; 
        position: sticky;
        top: 0;
        z-index: 100;
        gap: 5px;
    }
    
    .logo { 
        margin-bottom: 0.25rem; 
        border: none; 
        padding: 0; 
        flex-direction: row; 
        align-items: center; 
        justify-content: space-between;
        width: 100%;
    }
    
    .logo img { max-height: 30px; }
    
    .menu { 
        display: flex !important; 
        flex-direction: row; 
        overflow-x: auto; 
        gap: 6px; 
        padding-bottom: 4px;
        margin-top: 0.25rem;
    }
    
    .sincronizare-date {
        padding: 0.5rem;
        gap: 5px;
        border: none;
    }

    /* Pe mobil, ascundem implicit manual-uploads daca e nevoie */
    .manual-uploads {
        max-height: 0;
        opacity: 0;
    }
    .sincronizare-date.expanded .manual-uploads {
        max-height: 500px;
        opacity: 1;
        margin-top: 5px;
    }

    .auto-load-btn {
        margin: 0 !important;
        font-size: 0.75rem !important;
        padding: 8px 12px !important;
    }

    .main-content { padding: 1rem; }
    header { margin-bottom: 1rem; }
    .header-left h1 { font-size: 1.3rem; }
}

/* MOBILE APP SHELL - iPhone / Android dashboard polish */
@media (max-width: 820px) {
    html {
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
    }

    body {
        overflow-x: hidden;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .dashboard-container {
        width: 100%;
        min-width: 0;
    }

    .sidebar {
        padding: calc(0.65rem + env(safe-area-inset-top)) 0.75rem 0.55rem;
        max-height: 30vh;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .logo h2,
    .sidebar-footer,
    .sync-header,
    .toggle-btn {
        display: none;
    }

    .logo img {
        max-width: 156px;
        max-height: 28px;
    }

    .menu {
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        margin: 0.4rem -0.75rem 0;
        padding: 0 0.75rem 0.25rem;
    }

    .menu::-webkit-scrollbar {
        display: none;
    }

    .menu a {
        flex: 0 0 auto;
        scroll-snap-align: start;
        min-height: 40px;
        margin: 0;
        padding: 9px 12px;
        border: 1px solid var(--border-color);
        border-radius: 999px;
        background: var(--bg-color);
        font-size: 0.78rem;
        line-height: 1;
        white-space: nowrap;
    }

    .menu a:hover,
    .menu a.active {
        border-left: 1px solid var(--primary-color);
        background: var(--primary-color);
        color: #fff;
    }

    .menu a i {
        font-size: 0.9rem;
    }

    .sincronizare-date {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.45rem;
        padding: 0.45rem 0 0;
    }

    .sincronizare-date .upload-btn {
        width: 100%;
        min-height: 38px;
        justify-content: center;
        padding: 8px 9px !important;
        font-size: 0.7rem !important;
        line-height: 1.15;
        box-shadow: none;
    }

    .main-content {
        width: 100%;
        min-width: 0;
        padding: 0.9rem 0.8rem 1.5rem;
    }

    header {
        align-items: flex-start;
        gap: 0.75rem;
        padding-bottom: 0.9rem;
        margin-bottom: 0.9rem;
    }

    .header-left {
        min-width: 0;
    }

    .header-left h1 {
        font-size: 1.15rem;
        line-height: 1.12;
        margin-bottom: 0.2rem;
    }

    .header-left p {
        font-size: 0.82rem;
        line-height: 1.35;
    }

    #theme-toggle {
        flex: 0 0 auto;
        width: 40px;
        height: 40px;
        padding: 0 !important;
        justify-content: center;
        border-radius: 999px !important;
    }

    .header-right {
        flex: 0 0 auto;
        justify-content: flex-end;
        gap: 0.45rem !important;
    }

    #logout-btn {
        width: 40px;
        height: 40px;
        padding: 0 !important;
        justify-content: center;
        border-radius: 999px !important;
        font-size: 0 !important;
        box-shadow: none;
    }

    #logout-btn i {
        font-size: 1rem;
    }

    .dashboard-grid,
    #view-daily,
    #view-offers {
        gap: 0.95rem;
    }

    .controls-row,
    .mb-1 {
        margin-bottom: 0.95rem;
    }

    .slicers-wrapper,
    #view-daily .slicers-wrapper,
    #view-offers .slicers-wrapper {
        padding: 0.9rem;
        border-radius: 10px;
    }

    .slicer-group {
        gap: 0.5rem;
    }

    .slicer-group label {
        font-size: 0.72rem;
        letter-spacing: 0.03em;
        line-height: 1.25;
    }

    .slicer-container {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 0.45rem;
        padding-bottom: 0.15rem;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .slicer-container::-webkit-scrollbar {
        display: none;
    }

    .scroll-slicer,
    #view-daily .scroll-slicer,
    #view-offers .scroll-slicer {
        max-height: none;
        overflow-y: hidden;
        padding-right: 0;
    }

    .slicer-btn {
        flex: 0 0 auto;
        min-height: 34px;
        padding: 7px 11px;
        font-size: 0.78rem;
        line-height: 1.15;
        white-space: nowrap;
    }

    .kpi-cards,
    #view-daily .kpi-cards,
    #view-offers .kpi-cards,
    .monthly-breakdown-cards {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .card {
        border-radius: 10px;
        padding: 1rem;
    }

    .kpi-card,
    #view-daily .kpi-card {
        gap: 0.75rem;
        align-items: flex-start;
        min-height: 112px;
    }

    .kpi-icon,
    #view-daily .kpi-icon {
        width: 44px;
        height: 44px;
        min-width: 44px;
        border-radius: 12px;
        font-size: 1.05rem;
    }

    .kpi-info {
        min-width: 0;
    }

    .kpi-info h3 {
        font-size: 0.64rem;
        line-height: 1.25;
        letter-spacing: 0.06em;
        margin-bottom: 0.35rem;
    }

    .kpi-info h2,
    #view-daily .kpi-info h2,
    #view-daily #kpi-z-vmt-container h2 {
        font-size: 1.08rem;
        line-height: 1.14;
        letter-spacing: 0;
        overflow-wrap: anywhere;
    }

    .badge-pill {
        font-size: 0.66rem;
        padding: 3px 7px;
    }

    .charts-row,
    #view-daily .charts-row,
    #view-offers .offers-row-spikes {
        display: flex;
        flex-direction: column;
        gap: 0.9rem;
    }

    .chart-container,
    .chart-container.card,
    #view-daily .daily-chart-card,
    #view-offers .offers-chart-card {
        width: 100%;
        min-width: 0;
        min-height: 0;
        padding: 1rem;
        overflow: hidden;
    }

    .chart-container h3,
    .table-container h3,
    #view-daily .chart-container h3,
    #view-offers .offers-chart-card h3 {
        font-size: 0.95rem;
        line-height: 1.25;
        margin-bottom: 0.7rem;
    }

    .chart-container p,
    #view-daily .chart-container p {
        font-size: 0.72rem !important;
        margin-bottom: 0.7rem !important;
    }

    .chart-container > div[style*="height"],
    #view-daily .daily-chart-body,
    #view-daily .daily-chart-body-sm,
    #view-daily .daily-chart-body-md,
    #view-daily .daily-chart-body-lg,
    #view-offers .offers-chart-body {
        min-width: 0 !important;
        min-height: 260px !important;
        height: 260px !important;
    }

    .full-width-chart canvas,
    .chart-container canvas {
        min-height: 0 !important;
        max-height: 100%;
    }

    #view-daily .daily-chart-scroll {
        overflow-x: auto;
        margin-right: -0.25rem;
        padding-right: 0.25rem;
    }

    #view-daily .daily-chart-scroll .daily-chart-body-lg {
        min-width: 460px !important;
    }

    .search-box {
        margin-bottom: 0.9rem;
        width: 100%;
    }

    .search-box input,
    [style*="min-width: 320px"].search-box,
    [style*="min-width: 350px"].search-box {
        width: 100% !important;
        max-width: none;
        min-width: 0 !important;
    }

    .report-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .report-actions {
        justify-content: stretch;
        width: 100%;
    }

    .report-search {
        width: 100%;
        min-width: 0;
    }

    .report-icon-btn {
        width: 100%;
        justify-content: center;
    }

    .sc-action-stats,
    .sc-action-lanes,
    .sc-action-values {
        grid-template-columns: 1fr;
    }

    .sc-action-board {
        padding: 1rem;
    }

    .sc-action-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .table-container,
    #view-daily .table-container,
    #view-offers .table-container {
        padding: 1rem;
        overflow: hidden;
    }

    .table-responsive {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 680px;
    }

    th,
    td {
        padding: 0.68rem 0.75rem;
        font-size: 0.78rem;
        white-space: nowrap;
    }

    th {
        font-size: 0.64rem;
        letter-spacing: 0.035em;
    }

    .table-responsive::after {
        content: "gliseaza pentru mai multe coloane";
        display: block;
        padding-top: 0.45rem;
        color: var(--text-muted);
        font-size: 0.68rem;
        text-align: right;
    }

    .state-message {
        min-height: 360px;
        height: auto;
        padding: 2rem 1rem;
    }

    .state-message .icon-pulse {
        font-size: 2.8rem;
        margin-bottom: 1rem;
    }

    .state-message h3 {
        font-size: 1.35rem;
        line-height: 1.2;
    }

    .state-message p {
        font-size: 0.92rem;
        line-height: 1.35;
    }

    .kpi-card:hover,
    .mini-kpi:hover,
    .crm-card:hover,
    .upload-btn:hover {
        transform: none;
    }
}

@media (max-width: 430px) {
    .main-content {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    .kpi-cards,
    #view-daily .kpi-cards,
    #view-offers .kpi-cards,
    .monthly-breakdown-cards {
        grid-template-columns: 1fr;
    }

    .kpi-card,
    #view-daily .kpi-card {
        min-height: auto;
    }

    .chart-container > div[style*="height"],
    #view-daily .daily-chart-body,
    #view-daily .daily-chart-body-sm,
    #view-daily .daily-chart-body-md,
    #view-daily .daily-chart-body-lg,
    #view-offers .offers-chart-body {
        min-height: 240px !important;
        height: 240px !important;
    }

    #view-daily .daily-chart-scroll .daily-chart-body-lg {
        min-width: 420px !important;
    }
}

@media (max-width: 380px) {
    .sincronizare-date {
        grid-template-columns: 1fr;
    }
}

/* Mobile-first navigation shell. Desktop sidebar remains the source of truth. */
.mobile-bottom-nav,
.mobile-more-backdrop,
.mobile-more-sheet {
    display: none;
}

.mobile-filter-minihead,
.mobile-table-cards,
.mobile-dashboard-toggle {
    display: none;
}

@media (max-width: 820px) {
    body {
        padding-bottom: calc(78px + env(safe-area-inset-bottom));
    }

    body.mobile-more-open {
        overflow: hidden;
    }

    .dashboard-container {
        display: block;
    }

    .sidebar {
        display: none !important;
    }

    .main-content {
        padding: calc(0.7rem + env(safe-area-inset-top)) 0.8rem calc(6.25rem + env(safe-area-inset-bottom));
    }

    .main-content > header {
        position: sticky;
        top: 0;
        z-index: 120;
        align-items: center;
        min-height: 52px;
        margin: calc(-0.7rem - env(safe-area-inset-top)) -0.8rem 0.75rem;
        padding: calc(0.58rem + env(safe-area-inset-top)) 0.8rem 0.58rem;
        background: color-mix(in srgb, var(--bg-color) 94%, transparent);
        border-bottom: 1px solid var(--border-subtle);
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
        backdrop-filter: blur(12px);
    }

    .header-left h1 {
        font-size: 1rem;
        line-height: 1.12;
        margin: 0;
        max-width: 62vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-left p {
        display: none;
    }

    .header-right {
        align-items: center;
    }

    #theme-toggle,
    #logout-btn,
    #ux-print-btn {
        width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
    }

    #ux-print-btn {
        padding: 0 !important;
        justify-content: center !important;
        font-size: 0 !important;
        border-radius: 999px !important;
        box-shadow: none !important;
    }

    #ux-print-btn i {
        font-size: 1rem;
    }

    #global-filters-container {
        position: sticky;
        top: calc(52px + env(safe-area-inset-top));
        z-index: 90;
        margin: 0 -0.15rem 0.75rem;
    }

    #global-filters-container .slicers-wrapper {
        padding: 0.65rem !important;
        border-radius: 12px;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    }

    #global-filters-container .slicer-group label {
        font-size: 0.64rem;
    }

    #global-filters-container .slicer-btn {
        min-height: 32px;
        padding: 6px 10px;
        font-size: 0.74rem;
    }

    .mobile-filter-minihead {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 0.55rem;
    }

    .mobile-filter-toggle,
    .mobile-filter-apply {
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        border: 1px solid var(--border-subtle);
        border-radius: 10px;
        padding: 0 12px;
        background: var(--surface-color);
        color: var(--text-default);
        font-family: inherit;
        font-size: 0.78rem;
        font-weight: 850;
    }

    .mobile-filter-toggle[aria-expanded="true"],
    .mobile-filter-apply {
        border-color: var(--caretta-navy);
        background: var(--caretta-navy);
        color: #fff;
    }

    .mobile-filter-panel:not(.mobile-filter-open) .slicer-group:nth-of-type(n+2),
    .mobile-filter-panel:not(.mobile-filter-open) .daily-slicers-row:nth-of-type(n+2),
    .mobile-filter-panel:not(.mobile-filter-open) .pallet-filter-grid,
    .mobile-filter-panel:not(.mobile-filter-open) .filter-head p {
        display: none !important;
    }

    .mobile-filter-panel:not(.mobile-filter-open) .daily-slicers-row:first-of-type .slicer-group:nth-child(n+2) {
        display: none !important;
    }

    .mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1400;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 2px;
        min-height: calc(64px + env(safe-area-inset-bottom));
        padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--surface-color) 96%, transparent);
        border-top: 1px solid var(--border-subtle);
        box-shadow: 0 -18px 38px rgba(15, 23, 42, 0.14);
        backdrop-filter: blur(16px);
    }

    .mobile-bottom-nav button {
        min-width: 0;
        min-height: 50px;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: var(--text-soft);
        font-family: inherit;
        font-size: 0.66rem;
        font-weight: 800;
        line-height: 1.05;
        cursor: pointer;
    }

    .mobile-bottom-nav button i {
        font-size: 1rem;
    }

    .mobile-bottom-nav button.active,
    .mobile-bottom-nav button[aria-expanded="true"] {
        background: var(--caretta-navy-50);
        color: var(--caretta-navy);
    }

    body.visit-modal-open .mobile-bottom-nav,
    body.visit-modal-open .mobile-more-backdrop,
    body.visit-modal-open .mobile-more-sheet,
    body:has(#visit-modal:not(.hidden)) .mobile-bottom-nav,
    body:has(#visit-modal:not(.hidden)) .mobile-more-backdrop,
    body:has(#visit-modal:not(.hidden)) .mobile-more-sheet {
        display: none !important;
    }

    .mobile-bottom-nav button[hidden],
    .mobile-more-sheet button[hidden] {
        display: none !important;
    }

    .mobile-more-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1390;
        display: block;
        background: rgba(15, 23, 42, 0.42);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease;
    }

    .mobile-more-backdrop:not(.hidden) {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-more-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1410;
        display: block;
        max-height: min(78vh, 640px);
        padding: 14px 14px calc(86px + env(safe-area-inset-bottom));
        overflow: auto;
        background: var(--surface-color);
        border: 1px solid var(--border-subtle);
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -24px 70px rgba(15, 23, 42, 0.28);
        transform: translateY(calc(100% + 18px));
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.22s ease, visibility 0.22s ease;
    }

    .mobile-more-sheet.open {
        transform: translateY(0);
        visibility: visible;
        pointer-events: auto;
    }

    .mobile-more-head {
        position: sticky;
        top: -14px;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin: -14px -14px 12px;
        padding: 14px;
        background: var(--surface-color);
        border-bottom: 1px solid var(--border-subtle);
    }

    .mobile-more-head span,
    .mobile-more-group-title {
        display: block;
        color: var(--text-faint);
        font-size: 0.64rem;
        font-weight: 900;
        letter-spacing: 0.07em;
        text-transform: uppercase;
    }

    .mobile-more-head strong {
        display: block;
        color: var(--text-strong);
        font-size: 1rem;
        line-height: 1.2;
    }

    .mobile-more-close {
        width: 38px;
        height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--border-subtle);
        border-radius: 11px;
        background: var(--bg-subtle);
        color: var(--text-strong);
        cursor: pointer;
    }

    .mobile-more-grid {
        display: grid;
        gap: 14px;
    }

    .mobile-more-group {
        display: grid;
        gap: 7px;
    }

    .mobile-more-sheet button[data-mobile-target] {
        width: 100%;
        min-height: 46px;
        display: flex;
        align-items: center;
        gap: 11px;
        padding: 0 12px;
        border: 1px solid var(--border-subtle);
        border-radius: 12px;
        background: var(--bg-surface);
        color: var(--text-default);
        font-family: inherit;
        font-size: 0.88rem;
        font-weight: 800;
        text-align: left;
        cursor: pointer;
    }

    .mobile-more-sheet button[data-mobile-target].active {
        border-color: var(--caretta-navy);
        background: var(--caretta-navy-50);
        color: var(--caretta-navy);
    }

    .mobile-more-sheet button[data-mobile-target] i {
        width: 20px;
        color: var(--caretta-navy);
        text-align: center;
    }

    #toast-container {
        right: 10px !important;
        bottom: calc(82px + env(safe-area-inset-bottom)) !important;
        left: 10px;
    }

    #toast-container > div {
        max-width: none !important;
        width: 100% !important;
    }

    .mobile-table-cards {
        display: grid;
        gap: 10px;
    }

    .table-responsive.mobile-cardized:not(.mobile-show-table) table {
        display: none;
    }

    .table-responsive.mobile-cardized.mobile-show-table .mobile-table-card,
    .table-responsive.mobile-cardized.mobile-show-table .mobile-table-empty,
    .table-responsive.mobile-cardized.mobile-show-table .mobile-table-more {
        display: none;
    }

    .mobile-table-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 2px 0 4px;
        color: var(--text-soft);
        font-size: 0.74rem;
        font-weight: 850;
    }

    .mobile-table-toggle {
        min-height: 34px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        border: 1px solid var(--border-subtle);
        border-radius: 10px;
        padding: 0 11px;
        background: var(--surface-color);
        color: var(--caretta-navy);
        font-family: inherit;
        font-size: 0.76rem;
        font-weight: 900;
    }

    .mobile-table-card,
    .mobile-table-empty,
    .mobile-table-more {
        border: 1px solid var(--border-subtle);
        border-radius: 12px;
        background: var(--surface-color);
        padding: 12px;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
    }

    .mobile-table-title {
        display: grid;
        gap: 3px;
        margin-bottom: 10px;
    }

    .mobile-table-title strong {
        color: var(--text-strong);
        font-size: 0.92rem;
        line-height: 1.25;
    }

    .mobile-table-title em {
        color: var(--text-soft);
        font-size: 0.76rem;
        font-style: normal;
        line-height: 1.25;
    }

    .mobile-table-fields {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .mobile-table-fields span {
        min-width: 0;
        display: grid;
        gap: 2px;
        padding: 8px;
        border-radius: 9px;
        background: var(--bg-subtle);
    }

    .mobile-table-fields small {
        color: var(--text-faint);
        font-size: 0.62rem;
        font-weight: 900;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .mobile-table-fields strong {
        color: var(--text-default);
        font-size: 0.78rem;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .mobile-table-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 10px;
    }

    .mobile-table-actions button,
    .mobile-table-actions a {
        min-height: 36px;
        flex: 1 1 auto;
    }

    .mobile-table-empty,
    .mobile-table-more {
        color: var(--text-soft);
        font-size: 0.82rem;
        font-weight: 800;
        text-align: center;
    }

    .table-responsive.mobile-cardized::after {
        content: none;
    }

    .mobile-dashboard-toggle {
        width: 100%;
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        border: 1px solid var(--border-subtle);
        border-radius: 12px;
        background: var(--surface-color);
        color: var(--caretta-navy);
        font-family: inherit;
        font-size: 0.84rem;
        font-weight: 900;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
    }

    .dashboard-view:not(.mobile-show-all) .charts-row,
    .dashboard-view:not(.mobile-show-all) .chart-container,
    .dashboard-view:not(.mobile-show-all) .table-container,
    .dashboard-view:not(.mobile-show-all) .monthly-breakdown-cards,
    .dashboard-view:not(.mobile-show-all) .dealer-period-panel,
    .dashboard-view:not(.mobile-show-all) .profit-match-report,
    .dashboard-view:not(.mobile-show-all) .vplan-section,
    .dashboard-view:not(.mobile-show-all) .vdb-section,
    .dashboard-view:not(.mobile-show-all) .vdb-action-panel,
    .dashboard-view:not(.mobile-show-all) .cc-conversion-card,
    .dashboard-view:not(.mobile-show-all) .cc-grid,
    .dashboard-view:not(.mobile-show-all) .cc-chart-card,
    .dashboard-view:not(.mobile-show-all) .cc-module-shortcuts,
    .dashboard-view:not(.mobile-show-all) .incasari-payers-card,
    .dashboard-view:not(.mobile-show-all) #ux-heatmap-wrap,
    .dashboard-view:not(.mobile-show-all) #ux-gauge-wrap,
    .dashboard-view:not(.mobile-show-all) #crm-grid,
    .dashboard-view:not(.mobile-show-all) #crm-results-bar,
    .dashboard-view:not(.mobile-show-all) .pallets-charts {
        display: none !important;
    }

    .dashboard-view:not(.mobile-show-all) > .card.table-container:first-child {
        display: none !important;
    }

    #view-visits:not(.mobile-show-all) > .card.table-container:first-child,
    #view-admin-users:not(.mobile-show-all) .admin-panel,
    #view-pallets:not(.mobile-show-all) .pallets-filters {
        display: block !important;
    }

    #view-visits-dashboard:not(.mobile-show-all) .vdb-kpi-grid .kpi-card:nth-child(n+5),
    #view-visit-planner:not(.mobile-show-all) .vplan-kpi-grid .kpi-card:nth-child(n+4),
    #view-daily:not(.mobile-show-all) .kpi-cards .kpi-card:nth-child(n+5),
    #view-offers:not(.mobile-show-all) .kpi-cards .kpi-card:nth-child(n+4),
    #view-pallets:not(.mobile-show-all) .kpi-cards .kpi-card:nth-child(n+4) {
        display: none !important;
    }

    #caretta-login-overlay {
        padding: 16px;
        box-sizing: border-box;
    }

    #caretta-login-overlay > div {
        width: min(320px, calc(100vw - 32px)) !important;
        padding: 32px 24px !important;
        box-sizing: border-box !important;
    }
}

/* FINAL MOBILE OVERRIDES - Raport Zilnic slicere */
.command-center {
    gap: 1rem;
}

.cc-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.15rem 0 0.3rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.cc-eyebrow {
    margin: 0 0 0.35rem;
    color: var(--primary-color);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.cc-hero h2 {
    margin: 0;
    color: var(--text-main);
    font-size: 1.45rem;
    line-height: 1.15;
}

.cc-hero p {
    max-width: 680px;
    margin: 0.4rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.cc-health {
    min-width: 190px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.72);
}

body.dark-mode .cc-health {
    background: rgba(15, 23, 42, 0.7);
}

.cc-health span,
.cc-card-head span {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
}

.cc-health strong {
    color: var(--text-main);
    font-size: 1rem;
}

.cc-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
}

.cc-kpi {
    min-height: 118px;
    padding: 1rem;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.55rem;
}

.cc-kpi span {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.cc-kpi strong {
    color: var(--text-main);
    font-size: clamp(1.1rem, 2vw, 1.65rem);
    line-height: 1.05;
}

.cc-kpi small {
    color: var(--text-muted);
    font-weight: 700;
}

.cc-kpi-alert {
    border-color: rgba(239, 68, 68, 0.24);
}

.cc-kpi-alert strong {
    color: #dc2626;
}

.cc-kpi-deltas {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.cc-delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--text-main) 6%, transparent);
    color: var(--text-muted);
    line-height: 1.1;
}

.cc-delta b {
    font-weight: 800;
    color: var(--text-main);
}

.cc-delta em {
    font-style: normal;
    color: var(--text-muted);
    opacity: 0.85;
    font-weight: 600;
}

.cc-delta i {
    font-size: 0.7rem;
}

.cc-delta-up {
    background: color-mix(in srgb, #10b981 12%, transparent);
}
.cc-delta-up b { color: #059669; }

.cc-delta-down {
    background: color-mix(in srgb, #ef4444 12%, transparent);
}
.cc-delta-down b { color: #dc2626; }

.cc-delta-flat {
    background: color-mix(in srgb, var(--text-muted) 10%, transparent);
}

.cc-kpi-breakdown {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* WEB OPTIMIZATION - desktop dashboard shell, readability and interaction */
@media (min-width: 821px) {
    body {
        background:
            linear-gradient(180deg, rgba(246, 248, 251, 0.98), rgba(241, 245, 249, 0.98));
    }

    .dashboard-container {
        align-items: stretch;
    }

    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow: hidden;
    }

    .sidebar .menu {
        max-height: calc(100vh - 150px);
    }

    .main-content {
        width: min(100%, 1760px);
        max-width: 1760px;
        margin-inline: auto;
        padding: 1.15rem 1.45rem 1.5rem;
    }

    .main-content > header {
        position: sticky;
        top: 0;
        z-index: 80;
        min-height: 72px;
        margin: -1.15rem -1.45rem 1rem;
        padding: 0.9rem 1.45rem 0.85rem;
        background: rgba(246, 248, 251, 0.94);
        border-bottom: 1px solid var(--border-subtle);
        backdrop-filter: blur(16px);
        box-shadow: 0 10px 22px -24px rgba(15, 23, 42, 0.42);
    }

    body.dark-mode .main-content > header {
        background: rgba(15, 23, 42, 0.94);
    }

    .header-left h1 {
        font-size: 1.48rem;
        line-height: 1.12;
    }

    .header-left p {
        max-width: 780px;
        line-height: 1.35;
    }

    .dashboard-view,
    .dashboard-grid,
    .command-center {
        gap: 1rem;
    }

    .dashboard-view > .card,
    .dashboard-view > .table-container,
    .dashboard-view > .report-toolbar,
    .dashboard-view > .report-actions,
    .dashboard-view > .vdb-filters-panel,
    .dashboard-view > .vdb-section,
    .admin-panel,
    .slicers-wrapper,
    .chart-container.card,
    .daily-chart-card,
    .offers-chart-card,
    .cc-card,
    .cc-chart-card,
    .cc-alert-panel,
    .cc-target-card,
    .vplan-section,
    .pallets-filters,
    .pallets-chart-card {
        border: 1px solid var(--border-subtle);
        border-radius: 10px;
        box-shadow: var(--elev-1);
    }

    .dashboard-view > .card,
    .dashboard-view > .table-container,
    .dashboard-view > .report-toolbar,
    .dashboard-view > .report-actions,
    .dashboard-view > .vdb-filters-panel,
    .dashboard-view > .vdb-section,
    .admin-panel,
    .slicers-wrapper {
        padding: 1rem;
    }

    .report-toolbar,
    .report-actions,
    .controls-row,
    .dealer-period-panel,
    .vdb-filter-grid,
    .pallet-filter-grid,
    .daily-slicers-row,
    .slicer-container {
        align-items: center;
        gap: 0.65rem;
    }

    .controls-row,
    #global-filters-container,
    #view-daily .controls-row,
    #view-offers .controls-row,
    #view-scadentar .sc-action-toolbar,
    #view-visits-dashboard .vdb-filters-panel,
    #view-visit-planner .vdb-filters-panel,
    #view-pallets .pallets-filters {
        position: sticky;
        top: 72px;
        z-index: 68;
        background: rgba(246, 248, 251, 0.94);
        border: 1px solid var(--border-subtle);
        border-radius: 10px;
        box-shadow: 0 12px 24px -22px rgba(15, 23, 42, 0.35);
        backdrop-filter: blur(14px);
    }

    body.dark-mode .controls-row,
    body.dark-mode #global-filters-container,
    body.dark-mode #view-daily .controls-row,
    body.dark-mode #view-offers .controls-row,
    body.dark-mode #view-scadentar .sc-action-toolbar,
    body.dark-mode #view-visits-dashboard .vdb-filters-panel,
    body.dark-mode #view-visit-planner .vdb-filters-panel,
    body.dark-mode #view-pallets .pallets-filters {
        background: rgba(15, 23, 42, 0.94);
    }

    #global-filters-container {
        padding: 0;
    }

    #global-filters-container .slicers-wrapper {
        box-shadow: none;
        border: 0;
        background: transparent;
    }

    .slicer-group label,
    .vdb-control label,
    .filter-head span,
    .report-toolbar p,
    .kpi-info h3 {
        letter-spacing: 0.03em;
    }

    .upload-btn,
    .secondary-btn,
    .slicer-btn,
    .icon-btn,
    .report-search input,
    .search-box input,
    input,
    select,
    textarea {
        border-radius: 8px;
    }

    .upload-btn,
    .secondary-btn,
    .slicer-btn {
        min-height: 38px;
        padding: 0.55rem 0.85rem;
    }

    .search-box input,
    .report-search input,
    .vdb-control input,
    .vdb-control select,
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="email"],
    select {
        min-height: 38px;
        font-size: 0.86rem;
    }

    .kpi-cards,
    .cc-kpis,
    #view-daily .kpi-cards,
    #view-offers .kpi-cards,
    #view-pallets .kpi-cards,
    #view-visits-dashboard .vdb-kpi-grid,
    #view-visit-planner .vplan-kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
        gap: 0.78rem;
    }

    .kpi-card,
    .cc-kpi {
        min-height: 92px;
        padding: 0.85rem;
        gap: 0.8rem;
    }

    .kpi-icon {
        width: 46px;
        height: 46px;
        border-radius: 12px;
        font-size: 1.1rem;
    }

    .kpi-info h2 {
        font-size: clamp(1.18rem, 1.25vw, 1.55rem);
        line-height: 1.05;
    }

    .kpi-info h3,
    .cc-kpi span {
        font-size: 0.68rem;
        line-height: 1.2;
    }

    .charts-row,
    #view-daily .charts-row,
    #view-scadentar .charts-row,
    #view-offers .offers-chart-grid,
    .pallets-charts,
    .cc-top-grid,
    .cc-grid-2col {
        gap: 1rem;
    }

    .chart-container,
    .daily-chart-card,
    .offers-chart-card,
    .cc-chart-card,
    .pallets-chart-card {
        min-width: 0;
        padding: 1rem;
    }

    .chart-container h3,
    .daily-chart-card h3,
    .offers-chart-card h3,
    .cc-chart-card h3,
    .pallets-chart-card h3 {
        font-size: 0.98rem;
        line-height: 1.25;
        margin-bottom: 0.35rem;
    }

    .chart-container p,
    .daily-chart-card p,
    .offers-chart-card p,
    .cc-chart-card p,
    .pallets-chart-card p {
        font-size: 0.8rem;
        line-height: 1.35;
    }

    .chart-container > div[style*="height"],
    .daily-chart-body,
    .daily-chart-body-sm,
    .daily-chart-body-md,
    .daily-chart-body-lg,
    .offers-chart-body,
    .cc-chart-wrap,
    .pallets-chart-body {
        max-height: 330px;
    }

    .full-width-chart canvas,
    .chart-container canvas,
    .daily-chart-body canvas,
    .offers-chart-body canvas {
        max-height: 330px;
    }

    .table-container {
        overflow: hidden;
    }

    .table-responsive {
        width: 100%;
        max-height: min(62vh, 680px);
        overflow: auto;
        border: 1px solid var(--border-subtle);
        border-radius: 10px;
        background: var(--surface-color);
    }

    .table-responsive table,
    .data-table,
    #dataTable,
    #dailyTable,
    #obiectiveTable,
    #offersTable,
    #sc-table,
    #palletsTable,
    #visitsTable,
    #visitPlannerTable,
    #vdb-unvisited-table,
    #vdb-actions-table,
    #vdb-new-partners-table,
    #vdb-latest-table,
    #vdb-health-table,
    .admin-users-table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        font-size: 0.82rem;
    }

    .table-responsive thead th,
    .data-table thead th,
    #dataTable thead th,
    #dailyTable thead th,
    #obiectiveTable thead th,
    #offersTable thead th,
    #sc-table thead th,
    #palletsTable thead th,
    #visitsTable thead th,
    #visitPlannerTable thead th,
    #vdb-unvisited-table thead th,
    #vdb-actions-table thead th,
    #vdb-new-partners-table thead th,
    #vdb-latest-table thead th,
    #vdb-health-table thead th,
    .admin-users-table thead th {
        position: sticky;
        top: 0;
        z-index: 4;
        background: var(--bg-subtle);
        color: var(--text-strong);
        font-size: 0.72rem;
        line-height: 1.25;
        text-transform: uppercase;
        letter-spacing: 0.035em;
        box-shadow: inset 0 -1px 0 var(--border-subtle);
    }

    .table-responsive th,
    .table-responsive td,
    .data-table th,
    .data-table td,
    .admin-users-table th,
    .admin-users-table td {
        padding: 0.66rem 0.78rem;
        vertical-align: middle;
    }

    .table-responsive tbody tr:nth-child(even) td,
    .data-table tbody tr:nth-child(even) td,
    .admin-users-table tbody tr:nth-child(even) td {
        background: color-mix(in srgb, var(--bg-subtle) 48%, transparent);
    }

    .table-responsive tbody tr:hover td,
    .data-table tbody tr:hover td,
    .admin-users-table tbody tr:hover td {
        background: color-mix(in srgb, var(--caretta-navy-50) 64%, transparent);
    }

    .table-responsive td:first-child,
    .data-table td:first-child,
    .table-name-cell,
    .admin-summary-cell {
        max-width: 340px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #crm-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 0.85rem;
    }

    .crm-card {
        min-height: 128px;
        padding: 1rem;
    }

    .crm-results-bar,
    .crm-page-controls,
    .admin-panel-header,
    .admin-access-head,
    .user-admin-actions {
        gap: 0.75rem;
    }

    .user-admin-form {
        gap: 0.85rem;
    }

    #view-visits-dashboard .vdb-kpi-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    #view-visits-dashboard .vdb-section,
    #view-visit-planner .vplan-section {
        padding: 1rem;
    }

    #view-visit-planner #vp-day-plans.vplan-day-grid {
        grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
        gap: 1rem;
        align-items: start;
    }

    #view-visit-planner .vplan-day-card,
    #view-visit-planner .vplan-partner-card {
        border-radius: 10px;
    }

    #view-visit-planner .vplan-day-top,
    #view-visit-planner .vplan-day-controlbar,
    #view-visit-planner .vplan-route-list {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    #view-pallets .pallet-filter-grid {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    }

    #view-pallets .pallets-table-wrap,
    #view-visits .table-responsive,
    #view-visit-planner .table-responsive,
    #view-crm .table-responsive,
    #view-admin-users .table-responsive {
        max-height: min(66vh, 720px);
    }
}

@media (min-width: 1500px) {
    .main-content {
        padding-inline: 1.75rem;
    }

    .main-content > header {
        margin-inline: -1.75rem;
        padding-inline: 1.75rem;
    }

    .kpi-cards,
    #view-daily .kpi-cards,
    #view-offers .kpi-cards,
    #view-pallets .kpi-cards {
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    }
}

