/* ECAI Dashboard v5 — Core Styles */
/* ============================================
   ECAI Dashboard v3 — Apple Liquid Glass UI
   Premium Glass Morphism · Indigo Financial Theme
   Montserrat + Material Symbols Outlined
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap');

:root {
    /* Core palette — Financial Indigo */
    --primary: #4F46E5;
    --primary-medium: #6366F1;
    --primary-light: #818CF8;
    --primary-lighter: #C7D2FE;
    --primary-lightest: #EEF2FF;
    --primary-dark: #3730A3;
    --primary-darkest: #1E1B4B;

    /* Sidebar */
    --sidebar-top: #4338CA;
    --sidebar-bottom: #1E1B4B;

    /* Glass */
    --glass-bg: rgba(255, 255, 255, 0.62);
    --glass-bg-strong: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(255, 255, 255, 0.55);
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
    --glass-shadow-hover: 0 16px 48px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    --glass-shadow-elevated: 0 24px 64px rgba(0,0,0,0.10), 0 8px 24px rgba(0,0,0,0.06);

    /* Neutrals */
    --white: #ffffff;
    --bg: #F7F8FC;
    --text: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #8e8e93;
    --text-light: #aeaeb2;
    --border: rgba(0,0,0,0.08);

    /* Semantic */
    --danger: #EF4444;
    --warning: #F59E0B;
    --success: #10B981;

    /* Financial KPI colors */
    --kpi-ricavi: #2563eb;
    --kpi-mcg: #059669;
    --kpi-mil: #0891b2;
    --kpi-ebit: #d97706;
    --kpi-risultato: #7c3aed;

    /* Gestioni */
    --gi: #7c3aed;
    --gii: #9333ea;
    --gc: #0891b2;
    --gam: #d97706;

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --transition: all 0.25s cubic-bezier(.25,.46,.45,.94);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Material Symbols base */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
    font-size: 20px;
    vertical-align: middle;
    line-height: 1;
}

/* ============ AMBIENT BACKGROUND ============ */
.ambient-bg {
    position: fixed; inset: 0; z-index: 0;
    pointer-events: none; overflow: hidden;
    background: var(--bg);
}
.ambient-bg .orb {
    position: absolute; border-radius: 50%;
    filter: blur(100px); opacity: 0.12;
    animation: float 22s ease-in-out infinite;
}
.ambient-bg .orb-1 {
    width: 700px; height: 700px;
    background: radial-gradient(circle, #818CF8, #6366F1);
    top: -250px; right: -150px;
}
.ambient-bg .orb-2 {
    width: 500px; height: 500px;
    background: radial-gradient(circle, #C7D2FE, #818CF8);
    bottom: -200px; left: 80px;
    animation-delay: -8s;
}
.ambient-bg .orb-3 {
    width: 380px; height: 380px;
    background: radial-gradient(circle, #E0E7FF, #A5B4FC);
    top: 40%; left: 45%;
    animation-delay: -15s;
}
@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(30px, -20px) scale(1.04); }
    66%      { transform: translate(-20px, 15px) scale(0.96); }
}

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100dvh;
    background: linear-gradient(175deg, var(--sidebar-top) 0%, var(--sidebar-bottom) 100%);
    color: white; z-index: 200;
    display: flex; flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,0.08);
    transition: transform 0.3s cubic-bezier(.25,.46,.45,.94);
}

.sidebar-header {
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

/* Client logo area */
.client-logo-area {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    min-height: 48px;
}
.client-logo-area img {
    max-height: 44px;
    max-width: 180px;
    width: auto;
    object-fit: contain;
    border-radius: 8px;
}
.client-logo-area .logo-placeholder {
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800;
    letter-spacing: 1px;
    border: 1px solid rgba(255,255,255,0.2);
}

.sidebar-title {
    display: flex; flex-direction: column;
    align-items: center; text-align: center;
}
.sidebar-title h1 {
    font-size: 13px; font-weight: 700;
    letter-spacing: 0.3px; line-height: 1.3;
    opacity: 0.95;
}
.sidebar-title .fiscal-year {
    font-size: 11px; font-weight: 500;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
    display: flex; align-items: center; gap: 4px;
}
.sidebar-title .fiscal-year .material-symbols-outlined {
    font-size: 14px;
}

/* Sidebar nav */
.sidebar-nav {
    flex: 1; overflow-y: auto; padding: 10px 10px 24px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15); border-radius: 3px;
}

.nav-section-label {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.5px;
    opacity: 0.35; padding: 18px 14px 8px;
}

.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: var(--radius-md);
    cursor: pointer; transition: var(--transition);
    font-size: 12.5px; font-weight: 500;
    color: rgba(255,255,255,0.55);
    margin-bottom: 1px; text-decoration: none;
}
.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.9);
}
.nav-item.active {
    background: rgba(255,255,255,0.18);
    color: white; font-weight: 600;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1),
                inset 0 1px 0 rgba(255,255,255,0.12);
}

.nav-item .nav-icon {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-xs);
    background: rgba(255,255,255,0.08);
    flex-shrink: 0; transition: var(--transition);
}
.nav-item .nav-icon .material-symbols-outlined {
    font-size: 18px;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}
.nav-item.active .nav-icon {
    background: rgba(255,255,255,0.2);
}
.nav-item.active .nav-icon .material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* Sidebar — locked nav item (teaser sezioni future) */
.nav-item-locked {
    opacity: 0.45;
    cursor: pointer;
    border: 1px dashed rgba(255,255,255,0.18);
    position: relative;
}
.nav-item-locked:hover {
    opacity: 0.7;
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.28);
}
.nav-icon-locked {
    background: rgba(255,255,255,0.04) !important;
}
.nav-icon-locked .material-symbols-outlined {
    font-size: 16px !important;
}
.nav-label-locked {
    flex: 1; min-width: 0;
    font-size: 11.5px;
}
.nav-badge-locked {
    font-size: 8px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    padding: 2px 6px; border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Costs teaser modal — glass morphism */
.costs-teaser-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center; justify-content: center;
}
.costs-teaser-overlay.active {
    display: flex;
}
.costs-teaser-card {
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    padding: 36px 32px 28px;
    max-width: 380px; width: 90%;
    text-align: center;
    color: white;
    box-shadow: 0 24px 80px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
    animation: costsTeaserIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes costsTeaserIn {
    from { opacity: 0; transform: scale(0.9) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.costs-teaser-icon {
    width: 56px; height: 56px; margin: 0 auto 16px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(124,58,237,0.3), rgba(79,70,229,0.3));
    border: 1px solid rgba(124,58,237,0.3);
    display: flex; align-items: center; justify-content: center;
}
.costs-teaser-icon .material-symbols-outlined {
    font-size: 28px; color: rgba(196,167,255,0.9);
    font-variation-settings: 'FILL' 0, 'wght' 300;
}
.costs-teaser-title {
    font-size: 17px; font-weight: 700; margin-bottom: 8px;
    letter-spacing: -0.2px;
}
.costs-teaser-body {
    font-size: 13px; line-height: 1.6;
    color: rgba(255,255,255,0.7);
    margin-bottom: 20px;
}
.costs-teaser-cta {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 700;
    color: rgba(196,167,255,0.9);
    letter-spacing: 0.3px;
}
.costs-teaser-close {
    margin-top: 16px;
}
.costs-teaser-close button {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    padding: 8px 24px;
    color: rgba(255,255,255,0.6);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.costs-teaser-close button:hover {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
}

/* Sidebar footer — powered by Abako */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.15);
    display: flex; align-items: center; justify-content: center;
}
.sidebar-footer-left {
    display: flex; align-items: center; gap: 6px;
}
.powered-by {
    font-size: 10px; font-weight: 500;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.3px;
    white-space: nowrap;
}
/* ============ TOPBAR ============ */
.topbar {
    position: fixed; top: 0;
    left: var(--sidebar-width); right: 0;
    height: var(--topbar-height);
    background: rgba(247, 248, 252, 0.72);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0 28px; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.topbar-greeting {
    font-size: 15px; font-weight: 650;
    color: var(--text); letter-spacing: -0.2px;
}
.topbar-date {
    font-size: 12px; color: var(--text-muted); font-weight: 400;
    display: flex; align-items: center; gap: 4px;
}
.topbar-date .material-symbols-outlined {
    font-size: 15px;
}

/* ============ EXPORT DROPDOWN ============ */
.export-dropdown {
    position: relative;
}
.export-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: 'Montserrat', sans-serif;
    font-size: 12px; font-weight: 550;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.export-btn:hover {
    background: var(--glass-bg-strong);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    color: var(--text);
}
.export-chevron {
    transition: transform 0.2s ease;
}
.export-menu.show ~ .export-btn .export-chevron,
.export-dropdown .export-menu.show + .export-btn .export-chevron {
    transform: rotate(180deg);
}
.export-menu {
    position: absolute; top: calc(100% + 6px); right: 0;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 6px;
    min-width: 160px;
    box-shadow: var(--glass-shadow-elevated);
    opacity: 0; visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.2s ease;
    z-index: 200;
}
.export-menu.show {
    opacity: 1; visibility: visible;
    transform: translateY(0);
}
.export-menu-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 12px;
    border: none; background: transparent;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-family: 'Montserrat', sans-serif;
    font-size: 12.5px; font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.export-menu-item:hover {
    background: rgba(0,0,0,0.04);
    color: var(--text);
}

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    height: calc(100dvh - var(--topbar-height));
    overflow-y: auto;
    padding: 32px 36px 60px 36px;
    position: relative; z-index: 1;
}
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.08); border-radius: 6px;
}

.content-inner {
    max-width: 1100px;
}

/* ============ SECTIONS ============ */
.dash-section {
    margin-bottom: 28px;
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.section-header {
    margin-bottom: 16px;
}
.section-header .section-tag {
    margin-bottom: 6px;
}
.section-header h2 {
    font-size: 18px; font-weight: 700; color: var(--text);
    letter-spacing: -0.4px; line-height: 1.2;
    display: flex; align-items: center; gap: 10px;
    margin-top: 0;
}
.section-header h2 .section-icon {
    width: 34px; height: 34px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.section-header h2 .section-icon .material-symbols-outlined {
    font-size: 18px; color: var(--primary);
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}
.section-header p {
    color: var(--text-muted); font-size: 13px; font-weight: 400;
    margin-top: 4px; padding-left: 44px;
}

/* ============ GLASS CARDS ============ */
.glass-card {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 28px;
    margin-bottom: 18px;
    box-shadow: var(--glass-shadow);
    transition: var(--transition);
    position: relative; overflow: hidden;
}
/* Top highlight */
.glass-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
    pointer-events: none;
}
.glass-card:hover {
    box-shadow: var(--glass-shadow-hover);
    border-color: rgba(255,255,255,0.65);
}

/* ============ KPI CARDS ============ */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 14px;
}

.kpi-card-compact {
    padding: 16px 14px !important;
    min-width: 110px;
    max-width: 160px;
}
.kpi-label-ros {
    font-size: 9px !important;
    line-height: 1.35;
    letter-spacing: 0.4px;
}

.kpi-card {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 22px 20px;
    box-shadow: var(--glass-shadow);
    transition: var(--transition);
    position: relative; overflow: hidden;
}
.kpi-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
    pointer-events: none;
}
.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--glass-shadow-hover);
    border-color: rgba(255,255,255,0.65);
}

.kpi-card .kpi-icon-wrapper {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.kpi-card .kpi-icon-wrapper::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, transparent 100%);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    pointer-events: none;
}
.kpi-card .kpi-icon-wrapper .material-symbols-outlined {
    font-size: 20px;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.kpi-label {
    font-weight: 600; font-size: 11px;
    letter-spacing: 0.03em; text-transform: uppercase;
    color: var(--text-muted);
}

.kpi-value {
    font-weight: 800; font-size: 1.5rem;
    letter-spacing: -0.03em; line-height: 1.2;
    margin-top: 8px;
}

.kpi-sub {
    font-weight: 400; font-size: 11.5px;
    margin-top: 4px; color: var(--text-light);
}

/* ============ CHART CONTAINERS (Glass) ============ */
.chart-container {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--glass-shadow);
    transition: var(--transition);
    position: relative; overflow: hidden;
}
.chart-container::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
    pointer-events: none;
}
.chart-container:hover {
    box-shadow: var(--glass-shadow-hover);
    border-color: rgba(255,255,255,0.65);
}

.chart-title {
    font-size: 14px; font-weight: 650; color: var(--text);
    margin-bottom: 20px; display: flex; align-items: center;
    gap: 10px; letter-spacing: -0.2px;
}
.chart-title .chart-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary-lightest), rgba(199, 210, 254, 0.5));
    border: 1px solid rgba(79, 70, 229, 0.08);
    border-radius: var(--radius-xs);
    display: flex; align-items: center; justify-content: center;
}
.chart-title .chart-icon .material-symbols-outlined {
    font-size: 17px; color: var(--primary);
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* ============ DATA TABLES (Glass) ============ */
.data-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    font-size: 13px;
}
.data-table thead th {
    text-align: left; font-size: 10.5px; font-weight: 650;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.7px; padding: 10px 12px;
    background: rgba(0,0,0,0.02);
    border-bottom: 1.5px solid rgba(0,0,0,0.06);
}
.data-table thead th:first-child { text-align: left; }
.data-table thead th:not(:first-child) { text-align: right; }
.data-table thead th:first-child { border-radius: var(--radius-xs) 0 0 0; }
.data-table thead th:last-child  { border-radius: 0 var(--radius-xs) 0 0; }

.data-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    color: var(--text-secondary);
    vertical-align: middle;
}
.data-table tbody tr {
    transition: background 0.15s ease;
}
.data-table tbody tr:hover td {
    background: rgba(79, 70, 229, 0.015);
}
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .row-bold td {
    font-weight: 650;
    background: rgba(0,0,0,0.02);
    color: var(--text);
}

/* Amount colors */
.amount-positive { color: var(--success); }
.amount-negative { color: var(--danger); }

/* ============ DETAIL EXPANDABLE ============ */
.detail-row {
    max-height: 0; overflow: hidden;
    transition: max-height 0.4s cubic-bezier(.25,.46,.45,.94),
                opacity 0.3s ease;
    opacity: 0;
}
.detail-row.expanded {
    max-height: 3000px;
    opacity: 1;
}

.detail-toggle {
    width: 100%;
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition);
    -webkit-appearance: none; appearance: none;
    color: inherit; font: inherit;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.detail-toggle:hover {
    background: var(--glass-bg-strong);
    box-shadow: var(--glass-shadow);
    border-color: rgba(255,255,255,0.65);
}
.detail-toggle .chevron {
    transition: transform 0.3s cubic-bezier(.25,.46,.45,.94);
    font-size: 1.25rem; opacity: 0.4;
}
.detail-toggle.open .chevron {
    transform: rotate(180deg);
}
.detail-toggle .detail-tag {
    font-size: 10.5px; padding: 2px 8px; border-radius: 6px;
    font-weight: 600; letter-spacing: 0.3px;
}

/* ============ INCIDENCE BAR ============ */
.incidence-bar {
    height: 6px;
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(.25,.46,.45,.94);
    position: relative; overflow: hidden;
}
.incidence-bar::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, transparent 100%);
    border-radius: 3px 3px 0 0;
    pointer-events: none;
}

/* ============ SENSITIVITY (What-If) ============ */
.sensitivity-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 18px;
    align-items: start;
}
.sensitivity-levers {
    position: sticky;
    top: calc(var(--topbar-height) + 16px);
}
.sensitivity-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
}

/* Slider lever row */
.sensitivity-lever {
    margin-bottom: 18px;
}
.sensitivity-lever:last-child {
    margin-bottom: 0;
}
.sensitivity-lever-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.sensitivity-lever-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.2px;
}
.sensitivity-lever-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 40px;
    text-align: right;
    letter-spacing: -0.3px;
    transition: color 0.2s ease;
}
.sensitivity-lever-value.positive { color: #059669; }
.sensitivity-lever-value.negative { color: #ef4444; }

/* Custom range slider */
.sensitivity-slider-track {
    position: relative;
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
}
.sensitivity-slider {
    --fill-pct: 50%;
    --thumb-color: var(--primary);
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    background: linear-gradient(
        to right,
        rgba(0,0,0,0.08) 0%,
        rgba(0,0,0,0.08) var(--fill-pct),
        rgba(0,0,0,0.08) var(--fill-pct),
        rgba(0,0,0,0.08) 100%
    );
    position: relative;
}

/* Track fill via pseudo — using linear-gradient trick */
.sensitivity-slider {
    background: linear-gradient(
        to right,
        rgba(0,0,0,0.06) 0%,
        rgba(0,0,0,0.06) 50%,
        rgba(0,0,0,0.06) 100%
    );
}

/* Webkit thumb */
.sensitivity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--thumb-color);
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.sensitivity-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.08);
}
.sensitivity-slider:active::-webkit-slider-thumb {
    transform: scale(1.05);
}

/* Firefox thumb */
.sensitivity-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--thumb-color);
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    cursor: pointer;
}
.sensitivity-slider::-moz-range-track {
    height: 5px;
    border-radius: 3px;
    background: rgba(0,0,0,0.06);
    border: none;
}

/* Reset button */
.sensitivity-reset {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    margin-top: 24px;
    border-radius: var(--radius-md);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    font-weight: 550;
    color: var(--text-secondary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.sensitivity-reset .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-muted);
}
.sensitivity-reset:hover {
    background: var(--glass-bg-strong);
    box-shadow: var(--glass-shadow);
    border-color: rgba(255,255,255,0.65);
    color: var(--text);
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes sectionIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes countUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeInUp 0.5s cubic-bezier(.25,.46,.45,.94) forwards;
    opacity: 0;
}
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }
.delay-7 { animation-delay: 0.35s; }

/* ============ SECTION TAG (Glossy pill) ============ */
.section-tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 14px;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    color: var(--primary);
    font-size: 10px; font-weight: 700; border-radius: 20px;
    text-transform: uppercase; letter-spacing: 0.8px;
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow: 0 2px 12px rgba(0,0,0,0.04),
                0 1px 3px rgba(0,0,0,0.03),
                inset 0 1px 0 rgba(255,255,255,0.9);
    position: relative; overflow: hidden;
}
.section-tag::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.5) 0%, transparent 100%);
    border-radius: 20px 20px 0 0;
    pointer-events: none;
}

/* ============ GRID HELPERS ============ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

/* ============ MOBILE SIDEBAR ============ */
.sidebar-toggle {
    display: none;
    position: fixed; top: 6px; left: 6px; z-index: 310;
    width: 44px; height: 44px;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    align-items: center; justify-content: center;
    cursor: pointer; box-shadow: var(--glass-shadow);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
/* Expand touch target beyond visible button (56x56 hit area) */
.sidebar-toggle::before {
    content: '';
    position: absolute;
    top: -6px; left: -6px; right: -6px; bottom: -6px;
}
.sidebar-toggle:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.95);
}
.sidebar-toggle .material-symbols-outlined {
    font-size: 24px; color: var(--text);
    pointer-events: none;
}

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 190;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ============ FOOTER ============ */
.dash-footer {
    padding: 24px 0;
    margin-top: 32px;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11.5px; color: var(--text-light); font-weight: 400;
}
.dash-footer .footer-left {
    display: flex; align-items: center; gap: 5px;
}
.dash-footer .footer-left .material-symbols-outlined {
    font-size: 14px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .sensitivity-grid {
        grid-template-columns: 1fr;
    }
    .sensitivity-levers {
        position: static;
    }
    .sensitivity-kpi-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

@media (max-width: 800px) {
    .sensitivity-kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        height: 100dvh;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    /* Body scroll lock when sidebar open */
    body.sidebar-open {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
        top: 0;
    }
    .sidebar-header {
        padding: 14px 16px 12px;
    }
    .client-logo-area {
        margin-bottom: 8px;
        min-height: 36px;
    }
    .client-logo-area img {
        max-height: 36px;
    }
    .sidebar-nav {
        padding: 6px 10px 16px;
    }
    .nav-section-label {
        padding: 12px 14px 6px;
    }
    .sidebar-footer {
        padding: 8px 12px;
    }
    .sidebar-toggle {
        display: flex;
    }
    .sidebar-overlay.show {
        display: block;
    }

    .topbar {
        left: 0;
        padding-left: 54px;
        padding-right: 10px;
        gap: 6px;
    }
    .topbar-greeting {
        font-size: 12px;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .budget-anno-selector {
        gap: 2px;
        flex-shrink: 0;
    }
    .budget-anno-selector .anno-btn {
        width: 32px;
        height: 32px;
    }
    .budget-anno-selector .anno-label {
        font-size: 14px;
        min-width: 38px;
    }
    .main-content {
        margin-left: 0;
        padding: 20px 16px 48px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .kpi-card-compact {
        max-width: none;
    }
    .kpi-value {
        font-size: 1.2rem;
    }
    .kpi-card {
        padding: 16px 14px;
    }

    .chart-container {
        padding: 18px 14px;
        border-radius: var(--radius-lg);
    }
    .glass-card {
        padding: 18px 14px;
        border-radius: var(--radius-lg);
    }

    .section-header h2 { font-size: 16px; }
    .section-header p { padding-left: 0; }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .kpi-value {
        font-size: 1.05rem;
    }
    .sensitivity-kpi-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}


/* allocator.css loaded via <link> in base.html */
