:root {
  --navy: #1F3A6E;
  --navy-light: #2a4d8f;
  --gray: #7A8A9A;
  --gray-light: #f0f2f5;
  --white: #ffffff;
  --border: #e2e6ea;
  --text: #1a1a2e;
  --blue: #2196F3;
  --pink: #E040A0;
  --orange: #FF9800;
  --green: #4caf7d;
  --red: #e05a5a;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'DM Sans', sans-serif; background: var(--gray-light); color: var(--text); }

/* LOGIN */
#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--navy) 0%, #0f2347 100%); }
.login-box { background: white; border-radius: 4px; padding: 48px; width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo img { height: 140px; width: auto; margin-bottom: 24px; }
.login-logo .logo-blocks { display: flex; gap: 4px; justify-content: center; margin-bottom: 12px; }
.login-logo .lb { width: 32px; height: 38px; display: flex; align-items: center; justify-content: center; font-family: 'Cormorant Garamond', serif; font-size: 20px; font-weight: 700; color: white; }
.login-logo .lb.navy { background: var(--navy); border: 2px solid rgba(255,255,255,0.3); }
.login-logo .lb.gray { background: var(--gray); }
.login-logo .logo-name { font-size: 11px; color: var(--gray); letter-spacing: 2px; text-transform: uppercase; line-height: 1.6; }
.login-title { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 600; color: var(--navy); text-align: center; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--gray); text-align: center; margin-bottom: 28px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; }
.form-group input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 3px; font-size: 14px; font-family: 'DM Sans', sans-serif; outline: none; }
.form-group input:focus { border-color: var(--navy); }
.btn-login { width: 100%; padding: 12px; background: var(--navy); color: white; border: none; border-radius: 3px; font-size: 13px; font-weight: 600; font-family: 'DM Sans', sans-serif; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; margin-top: 8px; }
.btn-login:hover { background: var(--navy-light); }
.login-error { display: none; color: var(--red); font-size: 12px; text-align: center; margin-top: 12px; }
.login-forgot { text-align: center; margin-top: 10px; }
.login-forgot a { font-size: 12px; color: var(--gray); cursor: pointer; text-decoration: underline; }
.login-forgot a:hover { color: var(--navy); }
.login-success { display: none; color: var(--green); font-size: 12px; text-align: center; margin-top: 12px; }

/* APP */
#app { display: none; height: 100vh; overflow: hidden; flex-direction: row; }
#app.visible { display: flex; }

/* SIDEBAR */
.sidebar { width: 200px; background: var(--navy); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-logo { padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo-blocks { display: flex; gap: 3px; margin-bottom: 8px; }
.lb { width: 22px; height: 26px; display: flex; align-items: center; justify-content: center; font-family: 'Cormorant Garamond', serif; font-size: 14px; font-weight: 700; color: white; }
.lb.navy { background: var(--navy); border: 1.5px solid rgba(255,255,255,0.4); }
.lb.gray { background: var(--gray); }
.logo-name { font-size: 7.5px; color: rgba(255,255,255,0.6); letter-spacing: 1.5px; text-transform: uppercase; line-height: 1.7; }
.sidebar-menu { padding: 12px 0; flex: 1; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 9px; padding: 9px 16px; color: rgba(255,255,255,0.58); font-size: 12px; cursor: pointer; border-left: 3px solid transparent; transition: all 0.15s; user-select: none; }
.menu-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }
.menu-item.active { background: rgba(255,255,255,0.13); color: white; border-left: 3px solid rgba(255,255,255,0.7); }
.menu-icon { font-size: 13px; width: 16px; text-align: center; flex-shrink: 0; }
.menu-arrow { margin-left: auto; font-size: 9px; transition: transform 0.2s; }
.menu-item.open .menu-arrow { transform: rotate(90deg); }
.submenu { overflow: hidden; max-height: 0; transition: max-height 0.25s ease; }
.submenu.open { max-height: 200px; }
.submenu-item { display: flex; align-items: center; gap: 9px; padding: 7px 16px 7px 38px; color: rgba(255,255,255,0.45); font-size: 11px; cursor: pointer; border-left: 3px solid transparent; transition: all 0.15s; }
.submenu-item:hover { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.8); }
.submenu-item.active { color: white; border-left: 3px solid rgba(255,255,255,0.4); background: rgba(255,255,255,0.08); }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* TOPBAR */
.topbar { background: white; padding: 0 24px; height: 54px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.back-btn { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 11px; color: #666; cursor: pointer; font-family: 'DM Sans', sans-serif; display: none; }
.topbar-title { font-size: 14px; font-weight: 600; color: var(--navy); }
.topbar-breadcrumb { font-size: 11px; color: #aaa; display: none; }
.topbar-breadcrumb span { color: var(--navy); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.periodo-badge { background: var(--gray-light); border-radius: 6px; padding: 4px 12px; font-size: 11px; color: #555; }
.cliente-badge { background: #f0f4ff; border: 1px solid #c8d4f0; border-radius: 20px; padding: 4px 12px; font-size: 11px; color: var(--navy); font-weight: 500; }
.export-btn { background: var(--navy); color: white; border: none; border-radius: 6px; padding: 5px 12px; font-size: 11px; cursor: pointer; font-family: 'DM Sans', sans-serif; }
.btn-esci { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 12px; font-size: 11px; color: #666; cursor: pointer; font-family: 'DM Sans', sans-serif; }

/* CONTENT */
.content { flex: 1; padding: 20px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.page { display: none; flex-direction: column; gap: 16px; }
.page.active { display: flex; }

/* CARD */
.card { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 18px; }
.card-title { font-size: 10.5px; color: var(--gray); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 14px; font-weight: 600; }
.divider { border: none; border-top: 1px solid #f0f0f0; margin: 12px 0; }

/* GRIDS */
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }

/* KPI */
.kpi-card { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 16px 18px; }
.kpi-label { font-size: 10px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; }
.kpi-val { font-size: 22px; font-weight: 700; color: var(--navy); line-height: 1; }
.kpi-sub { font-size: 11px; color: #aaa; margin-top: 4px; }
.delta-pos { color: var(--green); font-size: 11px; margin-top: 3px; font-weight: 600; }
.delta-neg { color: var(--red); font-size: 11px; margin-top: 3px; font-weight: 600; }

/* DONUT */
.donut-section { display: flex; align-items: center; gap: 16px; }
.donut-container { position: relative; width: 80px; height: 80px; flex-shrink: 0; }
.donut-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); text-align: center; }
.donut-center-n { font-size: 13px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.donut-center-l { font-size: 8px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.4px; }
.legend { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend-name { font-size: 11px; color: #555; flex: 1; }
.legend-val { font-size: 11px; font-weight: 700; color: var(--navy); }
.legend-pct { font-size: 10px; color: #aaa; margin-left: 2px; }
.m { color: var(--blue); } .f { color: var(--pink); }

/* BARRE */
.bar-row { margin-bottom: 8px; }
.bar-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.bar-name { font-size: 11px; color: #333; }
.bar-right { display: flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 600; }
.bar-track { height: 7px; background: #eef0f5; border-radius: 99px; overflow: hidden; display: flex; }
.bar-fill { height: 100%; border-radius: 99px; }
.bar-m { height: 100%; background: var(--blue); border-radius: 99px 0 0 99px; }
.bar-f { height: 100%; background: var(--pink); border-radius: 0 99px 99px 0; }

/* ETA */
.eta-row { display: flex; gap: 4px; }
.eta-block { flex: 1; background: #f5f7fc; border-radius: 6px; padding: 6px 4px; text-align: center; }
.eta-range { font-size: 9px; color: var(--gray); margin-bottom: 3px; }
.eta-bar-track { height: 30px; background: #eef0f5; border-radius: 3px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.eta-bar-f { width: 100%; background: var(--pink); }
.eta-bar-m { width: 100%; background: var(--blue); }
.eta-gender { display: flex; justify-content: center; gap: 3px; margin-top: 3px; }
.eta-g { font-size: 9px; font-weight: 700; }

/* TABELLA */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th { padding: 9px 12px; font-size: 10px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; text-align: left; background: #fafafa; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
.data-table tbody td { padding: 9px 12px; font-size: 12px; color: #333; border-bottom: 1px solid #f8f8f8; white-space: nowrap; }
.data-table tbody tr:hover td { background: #f9fbff; }
.cdc-pill { font-size: 10px; background: #f0f4ff; color: var(--navy); border-radius: 4px; padding: 1px 6px; display: inline-block; margin: 1px; }

/* BADGE */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 10px; font-weight: 500; }
.badge.ti { background: #e6f4ec; color: #2e7d52; }
.badge.td { background: #fff3e0; color: #b45309; }
.badge.q { background: #e8eaf6; color: #3949ab; }
.badge.attivo { background: #e6f4ec; color: #2e7d52; }
.badge.cessato { background: #fde8e8; color: #b91c1c; }
.badge-pos { background: #e8f5e9; color: #2e7d32; border-radius: 99px; padding: 2px 8px; font-size: 10px; font-weight: 600; }
.badge-neg { background: #fde8e8; color: #b91c1c; border-radius: 99px; padding: 2px 8px; font-size: 10px; font-weight: 600; }
.badge-neu { background: #f5f5f5; color: #666; border-radius: 99px; padding: 2px 8px; font-size: 10px; font-weight: 600; }

/* TOOLBAR */
.toolbar { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 12px 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar-label { font-size: 11px; color: var(--gray); font-weight: 500; }
select { background: var(--gray-light); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; font-size: 11px; color: #333; outline: none; cursor: pointer; font-family: 'DM Sans', sans-serif; }
.tab-group { display: flex; background: var(--gray-light); border-radius: 8px; padding: 3px; gap: 2px; }
.tab { padding: 4px 12px; border-radius: 6px; font-size: 11px; color: #666; cursor: pointer; transition: all 0.15s; user-select: none; }
.tab.active { background: white; color: var(--navy); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* DIP HEADER */
.dip-header { background: white; border-radius: 12px; border: 1px solid var(--border); border-left: 4px solid var(--navy); padding: 18px 24px; display: flex; align-items: center; gap: 20px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--navy); display: flex; align-items: center; justify-content: center; font-size: 16px; color: white; font-weight: 700; flex-shrink: 0; font-family: 'Cormorant Garamond', serif; }
.dip-name { font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: 4px; font-family: 'Cormorant Garamond', serif; }
.dip-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.meta-item { font-size: 11px; color: #555; }
.meta-item strong { color: var(--navy); }
.dip-kpi { display: flex; gap: 24px; margin-left: auto; }
.kpi-item { text-align: center; }
.kpi-item .val { font-size: 18px; font-weight: 700; color: var(--navy); line-height: 1; }
.kpi-item .lbl { font-size: 10px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 3px; }

/* FILTRI */
.filters-row { display: flex; gap: 8px; padding: 10px 18px; border-bottom: 1px solid #f0f0f0; flex-wrap: wrap; background: #fafafa; }
.filter-wrap { position: relative; }
.filter-btn { display: flex; align-items: center; gap: 5px; background: white; border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; font-size: 11px; color: #444; cursor: pointer; font-family: 'DM Sans', sans-serif; }
.filter-btn.active { border-color: var(--navy); background: #f0f4ff; color: var(--navy); font-weight: 600; }
.filter-count { background: var(--navy); color: white; border-radius: 99px; padding: 1px 5px; font-size: 9px; margin-left: 2px; }
.dropdown { position: absolute; top: calc(100% + 4px); left: 0; background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); min-width: 160px; z-index: 100; display: none; max-height: 200px; overflow-y: auto; }
.dropdown.open { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 12px; color: #333; cursor: pointer; }
.dropdown-item:hover { background: #f5f7ff; }
.dropdown-item input { accent-color: var(--navy); }
.dropdown-item.select-all { border-bottom: 1px solid #f0f0f0; font-weight: 600; color: var(--navy); font-size: 11px; }

/* STORICO */
.storico-row { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f5f5f5; }
.storico-row:last-child { border-bottom: none; }
.storico-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--navy); margin-top: 4px; flex-shrink: 0; }
.storico-date { font-size: 11px; color: var(--gray); width: 60px; flex-shrink: 0; }
.storico-desc { font-size: 12px; color: #333; flex: 1; }
.storico-badge { font-size: 10px; background: #f0f4ff; color: var(--navy); border-radius: 4px; padding: 1px 6px; margin-left: 6px; }

/* RESIDUI */
.residui-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.residuo-item { background: #f5f7fc; border-radius: 8px; padding: 10px; }
.residuo-label { font-size: 10px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.residuo-vals { display: flex; gap: 14px; }
.residuo-val { font-size: 18px; font-weight: 700; color: var(--navy); line-height: 1; }
.residuo-unit { font-size: 10px; color: #aaa; margin-top: 2px; }

/* TFR */
.tfr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tfr-item { background: #f5f7fc; border-radius: 8px; padding: 12px; }
.tfr-label { font-size: 10px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.tfr-val { font-size: 18px; font-weight: 700; color: var(--navy); }
.tfr-sub { font-size: 10px; color: #aaa; margin-top: 2px; }

/* CDC */
.cdc-item-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid #f5f5f5; }
.cdc-item-row:last-child { border-bottom: none; }
.cdc-name { font-size: 13px; font-weight: 600; color: var(--navy); }
.cdc-pct { font-size: 13px; font-weight: 700; color: var(--gray); }

/* FIELD */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.field-label { font-size: 10px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.field-value { font-size: 13px; color: var(--navy); font-weight: 500; }

/* BUDGET TABLE */
.budget-table { width: 100%; border-collapse: collapse; }
.budget-table thead th { padding: 9px 12px; font-size: 10px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; text-align: right; background: #fafafa; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
.budget-table thead th:first-child { text-align: left; }
.budget-table tbody td { padding: 9px 12px; font-size: 12px; color: #333; border-bottom: 1px solid #f8f8f8; text-align: right; white-space: nowrap; }
.budget-table tbody td:first-child { text-align: left; }
.budget-table tbody tr:hover td { background: #f9fbff; }
.budget-table tbody tr.totale td { font-weight: 700; color: var(--navy); background: #f5f7ff; border-top: 2px solid var(--border); }
.mese-cons { font-weight: 600; color: var(--navy); }
.mese-prev { color: #aaa; font-style: italic; }
.cons { color: var(--navy); font-weight: 600; }
.prev-val { color: var(--gray); }
.proiezione { color: var(--orange); font-weight: 600; }

/* TRASPARENZA */
.tras-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.tras-item { background: #f5f7fc; border-radius: 8px; padding: 14px; }
.tras-level { font-size: 11px; font-weight: 600; color: var(--navy); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.ral-compare { display: flex; flex-direction: column; gap: 6px; }
.ral-row { display: flex; align-items: center; gap: 8px; }
.ral-sym { font-size: 11px; font-weight: 700; width: 16px; }
.ral-bar-wrap { flex: 1; }
.ral-bar-track { height: 6px; background: #e0e5f0; border-radius: 99px; overflow: hidden; }
.ral-bar-fill { height: 100%; border-radius: 99px; }
.ral-val { font-size: 11px; font-weight: 600; color: var(--navy); width: 64px; text-align: right; }

/* DIP LISTA */
.dip-list-item { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid #f5f5f5; cursor: pointer; transition: background 0.12s; }
.dip-list-item:hover { background: #f9fbff; }
.dip-list-item:last-child { border-bottom: none; }
.dip-avatar-sm { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); display: flex; align-items: center; justify-content: center; font-size: 12px; color: white; font-weight: 700; flex-shrink: 0; font-family: 'Cormorant Garamond', serif; }
.dip-list-name { font-size: 13px; font-weight: 600; color: var(--navy); }
.dip-list-sub { font-size: 11px; color: var(--gray); }
.dip-list-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-wrap { padding: 12px 18px; border-bottom: 1px solid #f0f0f0; background: #fafafa; }
.search-input { width: 100%; background: white; border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; font-size: 12px; color: #333; outline: none; font-family: 'DM Sans', sans-serif; }
.loading-msg { text-align: center; padding: 40px; color: var(--gray); font-size: 13px; }

/* SCADENZE */
.scad-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f5f5f5; }
.scad-row:last-child { border-bottom: none; }
.scad-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.scad-desc { font-size: 12px; color: #333; flex: 1; }
.scad-date { font-size: 11px; font-weight: 600; }

/* RESET PASSWORD */
.login-forgot { text-align: center; margin-top: 10px; }
.login-forgot a { font-size: 12px; color: var(--gray); cursor: pointer; text-decoration: underline; }
.login-forgot a:hover { color: var(--navy); }
.login-success { display: none; color: var(--green); font-size: 12px; text-align: center; margin-top: 12px; }
