/* =====================================================
   MGM Cape Verde — Brand System v2.1
   LIGHT-DOMINANT (75%) + DARK STRUCTURE (25%) + MUSTARD ACCENT
   Font: Montserrat — Unico e obbligatorio
   Palette: Warm Charcoal Edition 2026 — allineata a MGM Brand Guidelines
   ===================================================== */

/* --- RESET --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* --- VARIABLES --- */
:root {
  /* ── Chiaro (~75%) — Brand: Light Surface / Soft White / Warm Light ── */
  --white:      #ffffff;       /* bianco puro (update giugno 2026: avorio rimosso) */
  --bg-main:    #F5F5F3;       /* Light Surface — era #f4f4f4 */
  --bg-soft:    #ECECE8;       /* Warm Light — era #e8e8e8 */
  --bg-card:    #ffffff;       /* bianco puro — confermato update 2026 */

  /* ── Scuro (~25%) — Brand: Warm Charcoal Edition 2026 ── */
  --black:      #000000;       /* Text Black */
  --charcoal:   #0F1115;       /* Warm Charcoal Primary — era #0a0a0a */
  --dark-1:     #121417;       /* Warm Charcoal Secondary — era #111111 */
  --dark-2:     #16181D;       /* Dark Surface — era #161616 */
  --dark-3:     #1C1F26;       /* Secondary Dark — era #1e1e1e */
  --dark-4:     #232730;       /* Soft Dark — era #333333 */

  /* ── Testi — leggibilità massima ── */
  --text-main:    #1A1A1A;     /* Body Text brand — era #111111 */
  --text-sub:     #555555;     /* rafforzato: più leggibile su bianco */
  --text-muted:   #888888;     /* per testi davvero secondari */
  --text-on-dark: #ffffff;
  --text-dim:     #c8c8c8;

  /* ── Bordi ── */
  --border:       rgba(0,0,0,0.10);
  --border-med:   rgba(0,0,0,0.18);
  --border-dark:  rgba(255,255,255,0.08);

  /* ── Mustard Accent System — Brand 2026 ── */
  --mustard:        #B08D57;       /* Mustard Accent 1 — era #d4b15a */
  --mustard-2:      #A88442;       /* Mustard Accent 2 — era #b68d2a */
  --mustard-3:      #7a5f28;       /* Accent scuro leggibile su chiaro — 4.5:1 */
  --mustard-4:      #5e4200;       /* tono scuro per testi critici */
  --mustard-bg:     rgba(176,141,87,0.12);   /* aggiornato al nuovo #B08D57 */
  --mustard-bg2:    rgba(176,141,87,0.22);   /* aggiornato al nuovo #B08D57 */
  --mustard-border: rgba(168,132,66,0.32);   /* aggiornato al nuovo #A88442 */

  /* Font */
  --font: 'Montserrat', sans-serif;

  /* Layout */
  --sidebar-w: 252px;
  --topbar-h:  64px;

  /* Radii */
  --r-sm: 4px;
  --r:    8px;
  --r-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 6px rgba(0,0,0,0.07);
  --shadow:    0 3px 16px rgba(0,0,0,0.11);
  --shadow-lg: 0 6px 36px rgba(0,0,0,0.15);
}

/* --- BASE --- */
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
  line-height: 1.6;
}

/* --- TYPOGRAPHY --- */
h1 { font-size: 1.7rem;  font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: 1.2rem;  font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
h3 { font-size: 1rem;    font-weight: 600; letter-spacing: 0;        line-height: 1.25; }
h4 { font-size: .9rem;   font-weight: 500; }
h1,h2,h3,h4,h5,h6,p,span,label,td,th,li,a,button,input,select,textarea,div {
  font-family: var(--font);
}

/* =============================================================
   LOGIN
============================================================= */
.login-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: var(--bg-main);
  display: flex; align-items: center; justify-content: center;
}

.login-box {
  display: grid;
  grid-template-columns: 440px 320px;
  min-height: 520px;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-med);
  animation: fadeUp .3s ease;
}

.login-form-panel {
  background: var(--white);
  padding: 52px 48px;
  display: flex; flex-direction: column; gap: 28px;
}
.login-brand-panel {
  background: var(--dark-1);
  padding: 52px 40px;
  display: flex; flex-direction: column; justify-content: space-between;
}

.login-logo img { height: 46px; object-fit: contain; }

.login-title    { display: flex; flex-direction: column; gap: 6px; }
.login-company  {
  font-size: 1rem; font-weight: 700;
  letter-spacing: 0.01em; color: var(--text-main);
}
.login-sub {
  font-size: .73rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-sub);
}

.login-form   { display: flex; flex-direction: column; gap: 20px; }
.form-field   { display: flex; flex-direction: column; gap: 7px; }
.form-field label {
  font-size: .72rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-sub);
}
.form-field input {
  background: var(--bg-main);
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  color: var(--text-main);
  font-family: var(--font); font-size: .92rem; font-weight: 400;
  padding: 12px 15px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.form-field input:focus {
  border-color: var(--mustard-2);
  box-shadow: 0 0 0 3px var(--mustard-bg);
}
.pass-wrap { position: relative; }
.pass-wrap input { width: 100%; padding-right: 46px; }
.toggle-pass {
  position: absolute; right: 0; top: 0; height: 100%; width: 44px;
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; font-size: .88rem;
  transition: color .2s;
  display: flex; align-items: center; justify-content: center;
}
.toggle-pass:hover { color: var(--mustard-3); }

.btn-login {
  background: var(--black);
  color: var(--white);
  border: none; border-radius: var(--r-sm);
  font-family: var(--font); font-size: .75rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 14px 20px;
  cursor: pointer; transition: background .2s, transform .12s;
  margin-top: 4px;
}
.btn-login:hover  { background: var(--dark-4); transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }

.login-error {
  background: var(--bg-soft);
  border: 1px solid var(--border-med);
  border-left: 3px solid var(--mustard-3);
  color: var(--dark-1); border-radius: var(--r-sm);
  font-size: .82rem; font-weight: 500; padding: 11px 15px;
}
.login-footer {
  font-size: .72rem; font-weight: 400; letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Brand panel */
.login-brand-tagline {
  font-size: .65rem; font-weight: 700;
  letter-spacing: 0.20em; text-transform: uppercase;
  color: var(--mustard);
}
.login-brand-acronym {
  font-size: .70rem; font-weight: 400;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.45);
  margin-top: 5px;
  text-transform: none;
}
.login-brand-headline {
  font-size: 1.6rem; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.2;
  color: var(--white); margin-top: 14px;
}
.login-brand-sub {
  font-size: .80rem; font-weight: 400;
  color: var(--text-dim); margin-top: 14px; line-height: 1.75;
}
.login-brand-divider {
  width: 32px; height: 2px;
  background: var(--mustard); margin-top: 28px;
}
.login-brand-claim {
  font-size: .65rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim);
}

.pwd-rules { display: flex; flex-direction: column; gap: 7px; }
.rule {
  font-size: .78rem; font-weight: 500; letter-spacing: 0.02em;
  color: var(--text-sub); transition: color .2s;
  display: flex; align-items: center; gap: 9px;
}
.rule.ok { color: var(--mustard-3); font-weight: 600; }
.rule i  { font-size: .5rem; }

.login-box.single-col {
  grid-template-columns: 460px; min-height: auto;
}

/* =============================================================
   APP SHELL
============================================================= */
.app { display: flex; height: 100vh; overflow: hidden; background: var(--bg-main); }

/* =============================================================
   SIDEBAR — dark
============================================================= */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--dark-1);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column;
  height: 100vh; overflow-y: auto;
  position: relative; z-index: 100;
  transition: width .25s;
}
.sidebar-header {
  padding: 22px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo { height: 36px; object-fit: contain; filter: brightness(1.05); }
.sidebar-core-label {
  display: flex; flex-direction: column; gap: 3px;
  margin-top: 10px;
}
.sidebar-core-name {
  font-size: .78rem; font-weight: 700;
  color: var(--mustard); letter-spacing: 0.18em;
  text-transform: uppercase;
}
.sidebar-core-sub {
  font-size: .60rem; font-weight: 400;
  color: rgba(255,255,255,0.38); letter-spacing: 0.04em;
  line-height: 1.4; text-transform: none;
}
.sidebar-nav  { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section-label {
  font-size: .65rem; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  padding: 18px 20px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: .82rem; font-weight: 500;
  letter-spacing: 0.01em;
  border-left: 2px solid transparent;
  transition: color .2s, background .2s, border-color .2s;
}
.nav-item i {
  width: 17px; text-align: center; font-size: .88rem;
  color: rgba(255,255,255,0.35); transition: color .2s; flex-shrink: 0;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
}
.nav-item:hover i { color: var(--mustard); }
.nav-item.active {
  background: rgba(212,177,90,0.12);
  color: var(--white);
  border-left-color: var(--mustard);
  font-weight: 600;
}
.nav-item.active i { color: var(--mustard); }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
.user-badge { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--mustard); color: var(--black);
  display: flex; align-items: center; justify-content: center;
  font-size: .80rem; font-weight: 700; letter-spacing: 0;
  flex-shrink: 0;
}
.user-info  { display: flex; flex-direction: column; min-width: 0; }
.user-name  {
  font-size: .80rem; font-weight: 600; letter-spacing: 0.01em;
  color: var(--white);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role  {
  font-size: .65rem; font-weight: 600;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--mustard);
}
.btn-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.50); border-radius: var(--r-sm);
  width: 32px; height: 32px; cursor: pointer;
  font-size: .84rem; transition: color .2s, border-color .2s;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-logout:hover { color: var(--white); border-color: rgba(255,255,255,0.40); }

/* =============================================================
   TOPBAR — chiaro
============================================================= */
.main-content {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg-main);
}
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle {
  background: transparent; border: none;
  color: var(--text-sub); font-size: 1.05rem;
  cursor: pointer; padding: 6px; transition: color .2s; display: none;
}
.sidebar-toggle:hover { color: var(--mustard-3); }

.page-title {
  font-size: 1.1rem; font-weight: 700;
  letter-spacing: -0.01em; color: var(--text-main);
}
.topbar-right  { display: flex; align-items: center; gap: 22px; }
.topbar-date   {
  font-size: .76rem; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-sub);
}
.topbar-user   { display: flex; align-items: center; gap: 8px; }
.topbar-user span:first-child {
  font-size: .84rem; font-weight: 600; color: var(--text-main);
}
.role-badge {
  background: var(--mustard-bg);
  color: var(--mustard-3);
  font-size: .64rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 4px 11px; border-radius: 30px;
  border: 1px solid var(--mustard-border);
}
.role-badge.controller {
  background: var(--bg-soft); color: var(--dark-4);
  border-color: var(--border-med);
}

/* =============================================================
   MODULE CONTAINER
============================================================= */
.module-container {
  flex: 1; overflow-y: auto;
  padding: 28px;
  background: var(--bg-main);
}

/* =============================================================
   SECTION HEADER
============================================================= */
.section-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px;
}
.section-header h2 { color: var(--text-main); }
.section-header p  {
  font-size: .82rem; font-weight: 400;
  letter-spacing: 0.01em; color: var(--text-sub); margin-top: 4px;
}

/* =============================================================
   CARDS
============================================================= */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: visible;
  box-shadow: var(--shadow-sm);
}
.card .data-table-wrap { border-radius: 0 0 var(--r-lg) var(--r-lg); overflow: hidden; }

.card-header {
  padding: 16px 22px 15px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--white);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.card-title {
  font-size: .72rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-sub);
}
.card-body { padding: 22px 22px; }
.card-badge {
  font-size: .65rem; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 30px;
  background: var(--bg-soft); color: var(--text-sub);
  border: 1px solid var(--border-med);
}

.card-dark {
  background: var(--dark-1);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--r-lg); overflow: hidden;
}

/* =============================================================
   KPI CARDS
============================================================= */
.dash-kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px 22px 22px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.kpi-card::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--mustard); opacity: 0.60;
}
.kpi-label {
  font-size: .65rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-sub); margin-bottom: 12px;
}
.kpi-value {
  font-size: 1.70rem; font-weight: 700;
  letter-spacing: -0.025em; color: var(--text-main);
  line-height: 1;
}
.kpi-value.positive { color: var(--mustard-3); }
.kpi-value.negative { color: var(--dark-4); }
.kpi-value.mustard  { color: var(--mustard-2); }
.kpi-icon {
  position: absolute; right: 18px; top: 20px;
  font-size: 1.8rem;
  color: var(--border-med);
  opacity: 1;
}
.kpi-icon-text {
  position: absolute; right: 16px; top: 18px;
  font-size: .72rem; font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--mustard-3);
  opacity: 0.7;
}
.kpi-sub {
  font-size: .72rem; font-weight: 400;
  color: var(--text-muted); margin-top: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Grids */
.dash-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.dash-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 24px; }

/* Chart — altezza, padding, sfondo bianco */
.chart-wrap {
  position: relative;
  height: 280px;
  padding: 8px 12px 4px;
  background: var(--white);
}
.chart-wrap canvas {
  max-width: 100%;
}

/* =============================================================
   TABLES
============================================================= */
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.search-input {
  background: var(--white);
  border: 1px solid var(--border-med);
  color: var(--text-main); border-radius: var(--r-sm);
  font-family: var(--font); font-size: .86rem; font-weight: 400;
  padding: 9px 14px; width: 260px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-input:focus {
  border-color: var(--mustard-2);
  box-shadow: 0 0 0 3px var(--mustard-bg);
}
.search-input::placeholder { color: var(--text-muted); }

.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .84rem; }

.data-table th {
  background: var(--bg-main);
  color: var(--text-sub);
  font-size: .66rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 12px 16px; text-align: left; white-space: nowrap;
  border-bottom: 2px solid var(--border-med);
  position: sticky; top: 0; z-index: 1;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--mustard-3); }

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 400; letter-spacing: 0.01em;
  vertical-align: middle;
  background: var(--white);
}
.data-table tr:hover td { background: #fafafa; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .amount { font-weight: 600; font-size: .86rem; }
.data-table .amount.pos { color: var(--mustard-3); }
.data-table .amount.neg { color: var(--dark-4); font-weight: 700; }

/* FIX: righe evidenziate scadenziate */
.row-scaduto td {
  background: rgba(212,177,90,0.08) !important;
}
.row-scaduto td:first-child {
  border-left: 3px solid var(--mustard-3);
  padding-left: 13px;
}
.row-urgente td {
  background: rgba(212,177,90,0.04) !important;
}
.row-urgente td:first-child {
  border-left: 3px solid var(--mustard);
  padding-left: 13px;
}
/* Trasferimenti interni — sfondo neutro */
.row-trasf td {
  background: rgba(0,0,0,0.02) !important;
  opacity: 0.75;
}
.row-trasf td:first-child {
  border-left: 3px solid var(--border-med);
  padding-left: 13px;
}
/* Riga Carta di Credito — evidenziata in blu-acqua leggero */
.row-cc td {
  background: rgba(100,149,237,.06) !important;
}
.row-cc td:first-child {
  border-left: 3px solid #6495ed;
  padding-left: 13px;
}
.highlight-mustard td:first-child { border-left: 3px solid var(--mustard); padding-left: 13px; }

/* =============================================================
   IMPEGNI — tag tipo conto nella tabella
============================================================= */
.impegni-tipo {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .64rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 30px;
  white-space: nowrap;
  background: var(--bg-soft); color: var(--text-sub);
  border: 1px solid var(--border-med);
}

/* =============================================================
   COSTI FISSI — badge frequenza
============================================================= */
.freq-badge {
  display: inline-block;
  font-size: .62rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 30px;
  background: var(--mustard-bg2); color: var(--mustard-4);
  border: 1px solid var(--mustard-border);
}

/* =============================================================
   RICONCILIAZIONE — saldi editabili
============================================================= */
.ricon-input {
  background: var(--bg-main);
  border: 1px solid var(--border-med);
  color: var(--text-main); border-radius: var(--r-sm);
  font-family: var(--font); font-size: .88rem; font-weight: 600;
  padding: 6px 10px; outline: none; width: 140px;
  transition: border-color .2s, box-shadow .2s;
}
.ricon-input:focus {
  border-color: var(--mustard-2);
  box-shadow: 0 0 0 3px var(--mustard-bg);
}

/* =============================================================
   SECTION HEADER con tabs
============================================================= */
.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.tab-btn {
  background: transparent; border: none;
  font-family: var(--font); font-size: .76rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); padding: 10px 18px;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  color: var(--mustard-3);
  border-bottom-color: var(--mustard-3);
}

/* =============================================================
   ALERT / NOTICE BOXES
============================================================= */
.notice-box {
  padding: 14px 18px;
  border-radius: var(--r);
  border: 1px solid var(--border-med);
  background: var(--bg-soft);
  font-size: .82rem; font-weight: 400;
  color: var(--text-sub); line-height: 1.8;
  margin-bottom: 16px;
}
.notice-box.mustard {
  background: var(--mustard-bg);
  border-color: var(--mustard-border);
  color: var(--mustard-4);
}
.notice-box strong { color: var(--text-main); font-weight: 700; }
.notice-box i { margin-right: 8px; color: var(--mustard-2); }

/* Testi secondari nelle celle — coerente */
.td-sub {
  font-size: .78rem;
  color: var(--text-muted);
}
.td-code {
  font-weight: 700;
  color: var(--mustard-3);
  letter-spacing: 0.04em;
}

/* =============================================================
   BADGES
============================================================= */
.badge {
  display: inline-block;
  font-family: var(--font);
  font-size: .64rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 30px;
  white-space: nowrap;
}

/* Brand-compliant: solo senape / nero / grigio */
.badge-green   { background: var(--mustard-bg);  color: var(--mustard-3);  border: 1px solid var(--mustard-border); }
.badge-gold    { background: var(--bg-soft);      color: var(--dark-1);     border: 1px solid var(--border-med); }
/* FIX badge-blue: scuro ma meno aggressivo */
.badge-blue    { background: var(--dark-3);       color: #e8e8e8;           border: 1px solid var(--dark-4); }
.badge-red     { background: var(--bg-soft);      color: var(--dark-4);     border: 1px solid var(--border-med); font-style: italic; }
.badge-orange  { background: var(--mustard-bg2);  color: var(--mustard-4);  border: 1px solid var(--mustard-border); }
.badge-gray    { background: var(--bg-soft);      color: var(--text-sub);   border: 1px solid var(--border-med); }
.badge-mustard { background: var(--mustard-bg2);  color: var(--mustard-4);  border: 1px solid var(--mustard-border); font-weight: 700; }

/* Urgency — toni senape scuri, contrasto garantito su bianco */
.urgency-alta    { color: var(--mustard-4); font-weight: 700; font-size: .80rem; }
.urgency-media   { color: var(--mustard-3); font-weight: 600; font-size: .80rem; }
.urgency-bassa   { color: var(--mustard-2); font-weight: 500; font-size: .80rem; }
.urgency-nessuna { color: var(--text-muted); font-weight: 400; font-size: .80rem; }

/* =============================================================
   BUTTONS
============================================================= */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font); font-size: .72rem; font-weight: 700;
  letter-spacing: 0.10em; text-transform: uppercase;
  padding: 9px 18px; border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: background .18s, transform .12s;
  white-space: nowrap; line-height: 1;
}
.btn:hover  { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--black); color: var(--white); border-color: var(--black); }
.btn-primary:hover { background: var(--dark-4); border-color: var(--dark-4); }

.btn-secondary { background: var(--white); color: var(--text-main); border-color: var(--border-med); }
.btn-secondary:hover { background: var(--bg-soft); }

.btn-ghost     { background: transparent; color: var(--text-sub); border-color: var(--border-med); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text-main); }

.btn-danger    { background: var(--bg-soft); color: var(--dark-4); border-color: var(--border-med); }
.btn-danger:hover { border-color: var(--mustard-3); color: var(--mustard-3); }

.btn-success   { background: #2d6a4f; color: var(--white); border-color: #2d6a4f; }
.btn-success:hover { background: #1b4332; border-color: #1b4332; }

.btn-warning   { background: #7a5c00; color: #ffd97d; border-color: #7a5c00; }
.btn-warning:hover { background: #5a4300; border-color: #5a4300; }

.btn-mustard   { background: var(--mustard); color: var(--black); border-color: var(--mustard); }
.btn-mustard:hover { background: var(--mustard-2); border-color: var(--mustard-2); }

/* Archived row */
.row-archiviata td { opacity: 0.55; font-style: italic; }

.btn-sm   { padding: 6px 13px; font-size: .66rem; }
.btn-icon { padding: 7px 10px; font-size: .84rem; }

/* =============================================================
   PAGINATION
============================================================= */
.pagination {
  display: flex; align-items: center; gap: 6px;
  justify-content: center; margin-top: 20px; padding-bottom: 8px;
}
.pagination button {
  background: var(--white); border: 1px solid var(--border-med);
  color: var(--text-sub); border-radius: var(--r-sm);
  font-family: var(--font); font-size: .76rem; font-weight: 600;
  padding: 7px 13px; cursor: pointer; transition: all .18s;
}
.pagination button:hover   { border-color: var(--mustard); color: var(--mustard-3); }
.pagination button.active  { background: var(--black); color: var(--white); border-color: var(--black); }
.pagination button:disabled { opacity: .3; cursor: not-allowed; }

/* =============================================================
   FORMS
============================================================= */
.form-grid      { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; overflow-x: hidden; }
.form-grid.col3 { grid-template-columns: 1fr 1fr 1fr; overflow-x: hidden; }
.form-group     { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
  font-size: .68rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-sub);
}
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-main);
  border: 1px solid var(--border-med);
  color: var(--text-main); border-radius: var(--r-sm);
  font-family: var(--font); font-size: .88rem; font-weight: 400;
  padding: 10px 13px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--mustard-2);
  box-shadow: 0 0 0 3px var(--mustard-bg);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select option { background: var(--white); color: var(--text-main); }

/* =============================================================
   SUMMARY BAR
============================================================= */
.summary-bar {
  display: flex; gap: 36px; flex-wrap: wrap;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.summary-item { min-width: 120px; }
.summary-item .s-label {
  font-size: .65rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-sub); display: block; margin-bottom: 6px;
}
.summary-item .s-value {
  font-size: 1.15rem; font-weight: 700;
  letter-spacing: -0.01em; color: var(--text-main);
  line-height: 1;
}
.summary-item .s-value.positive { color: var(--mustard-3); }
.summary-item .s-value.negative { color: var(--dark-4); }
.summary-item .s-value.gold     { color: var(--mustard-2); }

/* =============================================================
   BILANCIO / RIEPILOGO
============================================================= */
.bilancio-section { margin-bottom: 28px; }
.bilancio-section h3 {
  font-size: .66rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--mustard-3);
  border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px;
}
.bilancio-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.bilancio-row .label { color: var(--text-sub); font-weight: 400; }
.bilancio-row .value { color: var(--text-main); font-weight: 700; }
.bilancio-row.total .label {
  color: var(--text-main); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: .80rem;
}
.bilancio-row.total .value { font-size: 1.05rem; color: var(--mustard-3); }

/* color overrides — brand safe */
.bilancio-row .value.positive { color: var(--mustard-3); }
.bilancio-row .value.negative { color: var(--dark-4); }

/* =============================================================
   RICONCILIAZIONE
============================================================= */
.ricon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.ricon-item {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}
.ricon-item .label {
  font-size: .65rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-sub); margin-bottom: 10px; display: block;
}
.ricon-item .value {
  font-size: 1.60rem; font-weight: 700;
  letter-spacing: -0.02em; color: var(--text-main);
}
.ricon-item .value.positive { color: var(--mustard-3); }
.ricon-item .value.negative { color: var(--dark-4); }
.ricon-item .sub {
  font-size: .74rem; color: var(--text-muted); margin-top: 6px;
}

/* =============================================================
   SETTINGS
============================================================= */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 26px;
  box-shadow: var(--shadow-sm);
}
.settings-card h3 {
  font-size: .66rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--mustard-3); margin-bottom: 20px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}

/* =============================================================
   MODAL
============================================================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(0,0,0,0.42); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .18s ease;
}
.modal-box {
  background: var(--white);
  border: 1px solid var(--border-med);
  border-radius: var(--r-lg);
  width: 600px; max-width: 95vw;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .2s ease;
}
.modal-box.wide { width: 760px; }
.modal-header {
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--white);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.modal-header h3 {
  font-size: 1rem; font-weight: 700;
  letter-spacing: -0.01em; color: var(--text-main);
}
.modal-close {
  background: transparent; border: none;
  color: var(--text-sub); font-size: .95rem;
  cursor: pointer; transition: color .2s; padding: 5px 7px; border-radius: 4px;
}
.modal-close:hover { color: var(--text-main); background: var(--bg-soft); }
.modal-body   { padding: 26px 28px; overflow-y: auto; overflow-x: hidden; flex: 1; }
.modal-footer {
  padding: 16px 28px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--bg-main);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* =============================================================
   TOAST
============================================================= */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  background: var(--white); border: 1px solid var(--border-med);
  border-radius: var(--r); padding: 14px 20px;
  font-size: .82rem; font-weight: 500; letter-spacing: 0.02em;
  color: var(--text-main); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 11px;
  animation: slideIn .22s ease;
  min-width: 260px;
}
.toast.success { border-left: 3px solid var(--mustard-2); }
.toast.error   { border-left: 3px solid var(--dark-4); }
.toast.info    { border-left: 3px solid var(--mustard); }
.toast.warning { border-left: 3px solid var(--mustard-3); }

/* =============================================================
   ACCESS DENIED / EMPTY STATE
============================================================= */
.access-denied {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 300px; gap: 16px; text-align: center;
}
.access-denied i   { font-size: 2.2rem; color: var(--bg-soft); }
.access-denied h3  { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.access-denied p   { font-size: .84rem; font-weight: 400; color: var(--text-sub); }

.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.empty-state {
  text-align: center; padding: 72px 20px; color: var(--text-sub);
}
.empty-state i { font-size: 2.2rem; margin-bottom: 16px; opacity: .18; display: block; }
.empty-state p { font-size: .86rem; font-weight: 500; }

/* =============================================================
   IVA info panel
============================================================= */
.info-panel {
  margin-top: 20px; padding: 18px 20px;
  background: var(--bg-soft);
  border-radius: var(--r);
  border: 1px solid var(--border-med);
}
.info-panel-title {
  font-size: .66rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--mustard-3); margin-bottom: 12px;
}
.info-panel p {
  font-size: .82rem; color: var(--text-sub);
  line-height: 1.85;
}
.info-panel strong { color: var(--text-main); font-weight: 700; }

/* =============================================================
   CHECKLIST
============================================================= */
.checklist-item {
  display: flex; align-items: center; gap: 12px;
  font-size: .84rem; color: var(--text-main);
}
.checklist-item.done  { color: var(--text-sub); }
.checklist-item .ci-icon { font-size: .85rem; flex-shrink: 0; }
.checklist-item.done  .ci-icon { color: var(--mustard-3); }
.checklist-item.todo  .ci-icon { color: var(--border-med); }

/* =============================================================
   CASH FLOW MENSILE — Navigazione mesi
============================================================= */
.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 20px;
  margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.month-nav-label {
  font-size: 1rem; font-weight: 700;
  letter-spacing: -0.01em; color: var(--text-main);
}
.month-nav-sub {
  font-size: .70rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); margin-top: 2px;
}
.month-nav-btn {
  background: transparent; border: 1px solid var(--border-med);
  color: var(--text-sub); border-radius: var(--r-sm);
  width: 36px; height: 36px; cursor: pointer;
  font-size: .88rem; transition: all .18s;
  display: flex; align-items: center; justify-content: center;
}
.month-nav-btn:hover { background: var(--bg-soft); color: var(--text-main); }
.month-nav-btn:disabled { opacity: .3; cursor: not-allowed; }
.month-nav-center { text-align: center; }
.month-nav-actions { display: flex; align-items: center; gap: 8px; }

/* =============================================================
   SALDO BANCA — banner principale conto
============================================================= */
.saldo-banner {
  background: var(--dark-1);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 20px;
  box-shadow: var(--shadow);
}
.saldo-banner-main { display: flex; flex-direction: column; gap: 4px; }
.saldo-banner-label {
  font-size: .62rem; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--mustard);
}
.saldo-banner-value {
  font-size: 2.2rem; font-weight: 700;
  letter-spacing: -0.03em; color: var(--white);
  line-height: 1;
}
.saldo-banner-value.negative { color: var(--text-dim); }
.saldo-banner-sub {
  font-size: .72rem; font-weight: 400;
  color: rgba(255,255,255,0.45); margin-top: 4px;
}
.saldo-banner-stats {
  display: flex; gap: 28px; flex-wrap: wrap;
}
.saldo-stat { text-align: center; }
.saldo-stat .ss-label {
  font-size: .60rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(255,255,255,0.40); display: block; margin-bottom: 4px;
}
.saldo-stat .ss-value {
  font-size: .96rem; font-weight: 700;
  color: var(--white);
}
.saldo-stat .ss-value.pos { color: var(--mustard); }
.saldo-stat .ss-value.neg { color: var(--text-dim); }

/* =============================================================
   BANNER SCADENZE 15 GIORNI
============================================================= */
.scad-banner {
  background: var(--mustard-bg);
  border: 1px solid var(--mustard-border);
  border-radius: var(--r);
  margin-bottom: 20px;
  overflow: hidden;
}
.scad-banner-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--mustard-border);
}
.scad-banner-title {
  font-size: .66rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--mustard-4);
  display: flex; align-items: center; gap: 8px;
}
/* .scad-scroll / .scad-card — rimosso (layout orizzontale dismesso) */

/* Tabella scadenze: scroll verticale max 5 righe */
.scad-table-wrap {
  overflow: hidden;
}
.scad-table {
  table-layout: fixed;
  width: 100%;
}
.scad-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-soft);
}
.scad-tbody {
  display: block;
  max-height: calc(5 * 46px);  /* ~5 righe */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--mustard-border) transparent;
}
.scad-tbody::-webkit-scrollbar { width: 4px; }
.scad-tbody::-webkit-scrollbar-thumb { background: var(--mustard-border); border-radius: 2px; }
.scad-table thead tr,
.scad-tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}
.row-scaduto td { background: rgba(212,177,90,.09); }
.row-urgente  td { background: rgba(212,177,90,.04); }
.scad-empty {
  padding: 14px 18px;
  font-size: .82rem; color: var(--mustard-3); font-weight: 500;
}

/* =============================================================
   SEZIONE MESE — transazioni + previsti
   Due sezioni visivamente distinte:
   cf-card-real  = movimenti bancari reali (dark header)
   cf-card-prev  = previsti/impegni        (mustard-tinted header)
============================================================= */

/* --- Card contenitore Transazioni bancarie --- */
.cf-card-real {
  border-top: 3px solid var(--dark-1);
  overflow: hidden;
}
.cf-header-real {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  background: var(--dark-1);
  color: var(--white);
}

/* --- Card contenitore Previsti/Impegni --- */
.cf-card-prev {
  border-top: 3px solid var(--mustard-2);
  overflow: hidden;
}
.cf-header-prev {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  background: var(--mustard-bg2);
  border-bottom: 1px solid var(--mustard-border);
}

/* --- Elementi comuni ai due header --- */
.cf-header-left  { display: flex; align-items: center; gap: 14px; }
.cf-header-right { text-align: right; }

.cf-header-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08);
  border-radius: var(--r-sm);
  font-size: 1.05rem;
  color: var(--mustard);
  flex-shrink: 0;
}
.cf-header-icon.prev {
  background: var(--mustard-bg2);
  border: 1px solid var(--mustard-border);
  color: var(--mustard-3);
}

.cf-header-title {
  font-size: .72rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--white);
}
.cf-header-title.prev { color: var(--mustard-4); }

.cf-header-sub {
  font-size: .70rem; color: rgba(255,255,255,0.50);
  margin-top: 3px; line-height: 1.4;
}
.cf-header-sub.prev { color: var(--text-muted); }

.cf-header-amount {
  font-size: 1.25rem; font-weight: 700;
  letter-spacing: -0.02em;
  display: block; margin-bottom: 3px;
}
.cf-header-amount.pos { color: var(--mustard); }
.cf-header-amount.neg { color: rgba(255,255,255,0.75); }

.cf-header-detail {
  font-size: .72rem; font-weight: 600;
}

/* legacy — mantenuto per compatibilità */
.cf-section-title {
  font-size: .62rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-sub);
  padding: 14px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
}
.cf-section-title .cf-tot {
  font-size: .80rem; font-weight: 700;
  letter-spacing: -0.01em;
}

/* Riporto da mese precedente */
.row-riporto td { background: rgba(212,177,90,0.06) !important; }
.row-riporto td:first-child {
  border-left: 3px solid var(--mustard-2);
  padding-left: 13px;
}
.badge-riporto {
  font-size: .58rem; font-weight: 700;
  letter-spacing: 0.10em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 30px;
  background: var(--mustard-bg2); color: var(--mustard-4);
  border: 1px solid var(--mustard-border);
  margin-left: 6px; vertical-align: middle;
}

/* Vista annuale sommario */
.annual-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 12px;
  margin-top: 20px;
}
.annual-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer; transition: box-shadow .18s, transform .15s;
}
.annual-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.annual-card.current-month { border-color: var(--mustard); }
.annual-card .am-label {
  font-size: .62rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px;
}
.annual-card .am-saldo {
  font-size: 1.05rem; font-weight: 700;
  letter-spacing: -0.01em;
}
.annual-card .am-saldo.pos { color: var(--mustard-3); }
.annual-card .am-saldo.neg { color: var(--dark-4); }
.annual-card .am-sub {
  font-size: .70rem; color: var(--text-muted); margin-top: 4px;
}

/* =============================================================
   IMPEGNI per mese
============================================================= */
.imp-month-block { margin-bottom: 28px; }
.imp-month-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--dark-1); border-radius: var(--r) var(--r) 0 0;
}
.imp-month-title {
  font-size: .70rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--mustard);
}
.imp-month-stats {
  display: flex; gap: 16px;
}
.imp-month-stat {
  font-size: .68rem; font-weight: 600;
  color: rgba(255,255,255,0.55);
}
.imp-month-stat span { color: var(--white); }
.imp-month-stat.pos { color: var(--mustard); }
.imp-month-stat.neg { color: rgba(255,255,255,0.75); }

/* =============================================================
   RESPONSIVE aggiuntivo
============================================================= */
@media (max-width: 900px) {
  .saldo-banner { flex-direction: column; gap: 16px; }
  .saldo-banner-stats { gap: 16px; }
  .annual-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 600px) {
  .annual-grid { grid-template-columns: 1fr 1fr; }
  .saldo-banner-value { font-size: 1.7rem; }
  .month-nav-label { font-size: .88rem; }
}

/* =============================================================
   ANIMATIONS
============================================================= */
@keyframes fadeIn  { from { opacity: 0; }                             to { opacity: 1; } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: translateX(0); } }

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

/* =============================================================
   RESPONSIVE
============================================================= */
@media (max-width: 1300px) {
  .dash-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1100px) {
  .dash-grid, .dash-grid-3 { grid-template-columns: 1fr; }
  .ricon-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .login-box { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar-w)); transition: left .25s; }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: flex; }
  .dash-kpi-grid  { grid-template-columns: 1fr 1fr; }
  .module-container { padding: 16px; }
  .ricon-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid.col3 { grid-template-columns: 1fr 1fr; }
  .summary-bar { gap: 20px; padding: 16px 18px; }
}
@media (max-width: 480px) {
  .dash-kpi-grid  { grid-template-columns: 1fr; }
  .module-container { padding: 12px; }
  .form-grid.col3 { grid-template-columns: 1fr; }
}

/* =============================================================
   REPORT MODULE
============================================================= */
.report-summary-bar {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-bottom: 4px;
}
.rep-kpi {
  flex: 1 1 160px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 4px;
}
.rep-kpi-green { border-left: 3px solid #2d6a4f; }
.rep-kpi-red   { border-left: 3px solid #c0392b; }
.rep-kpi-neutral { border-left: 3px solid var(--mustard-3); }
.rep-kpi .kpi-label {
  font-size: .64rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted);
}
.rep-kpi .kpi-val {
  font-size: 1.1rem; font-weight: 800;
  letter-spacing: -.02em; color: var(--text-main);
}

/* Fabbisogno annuale grid */
.fab-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 20px;
}
.fab-month-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s;
}
.fab-month-card:hover { box-shadow: var(--shadow); }
.fab-month-card.fab-current { border-color: var(--mustard-3); border-width: 2px; }
.fab-month-card.fab-past    { opacity: .75; }
.fab-month-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.fab-month-name {
  font-size: .72rem; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-main);
}
.fab-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .78rem; padding: 3px 0;
}
.fab-label { color: var(--text-sub); }
.fab-val   { font-weight: 700; }
.fab-divider {
  height: 1px; background: var(--border);
  margin: 6px 0;
}
.fab-net .fab-label,
.fab-net .fab-val { font-size: .82rem; }

/* Report — barra filtri periodo */
.rep-filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 18px;
  margin-bottom: 4px; box-shadow: var(--shadow-sm);
}
.rep-filter-group { display: flex; flex-direction: column; gap: 5px; }
.rep-filter-label { font-size: .64rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); }
.rep-filter-sel {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--bg-main);
  font-family: var(--font); font-size: .82rem; color: var(--text-main);
  min-width: 110px; cursor: pointer;
}
.rep-filter-sel:focus { outline: none; border-color: var(--mustard-3); }

/* Report — righe drilldown cliccabili */
.rep-drill-row:hover { background: var(--bg-soft); }
.rep-drill-row:hover td:first-child { color: var(--mustard-3); }
.rep-drill-row { transition: background .15s; }

/* Bulk actions bar */
.bulk-action-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--black); color: var(--white);
  border-radius: var(--r-sm);
  margin: 8px 16px;
  border: 1px solid rgba(255,255,255,0.10);
}
.bulk-count { font-size: .80rem; font-weight: 600; white-space: nowrap; }
.bulk-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
/* Checkbox column alignment in data-table */
.data-table td input[type="checkbox"],
.data-table th input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--mustard);
  width: 15px; height: 15px;
}

/* Fabbisogno — alert box */
.fab-alert-warn {
  display: flex; align-items: center; gap: 12px;
  background: #fff5f5; border: 1.5px solid #c0392b;
  border-radius: var(--r); padding: 16px 20px;
  font-size: .9rem; color: #c0392b; font-weight: 600;
  line-height: 1.5;
}
.fab-alert-warn .fa { font-size: 1.3rem; flex-shrink: 0; }
.fab-alert-ok {
  display: flex; align-items: center; gap: 12px;
  background: #f0faf4; border: 1.5px solid #2d6a4f;
  border-radius: var(--r); padding: 16px 20px;
  font-size: .9rem; color: #2d6a4f; font-weight: 600;
  line-height: 1.5;
}
.fab-alert-ok .fa { font-size: 1.3rem; flex-shrink: 0; }

/* Anagrafica — costo fisso cf-extra usa display:contents per stare nel form-grid */
#cf-extra { display: contents; }

/* ── Badge paese CH / CV ─────────────────────────────── */
.badge-paese {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  padding: 2px 8px; border-radius: 20px;
  white-space: nowrap; font-family: var(--font);
}
.badge-paese-ch {
  background: #e8f0fe; color: #1a3a6b;
  border: 1px solid #b8cef5;
}
.badge-paese-cv {
  background: #fdf3e3; color: #7a4800;
  border: 1px solid #f0cc88;
}

/* ── Icona allegato nella tabella ────────────────────── */
.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-sub); cursor: pointer;
  border-radius: var(--r-sm); transition: all .15s;
}
.btn-ghost:hover { background: var(--bg-main); color: var(--text-main); }

/* ── Modulo Investitori — card grid ─────────────────── */
.inv-kpi-danger { border-left-color: #c0392b !important; border-left-width: 3px !important; }
.inv-empty {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted); font-size: .88rem;
}
.inv-empty i { font-size: 2rem; opacity: .2; display: block; margin-bottom: 12px; }

/* Card grid layout */
.inv-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 8px;
}

/* Single investor card */
.inv-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .18s, transform .18s;
}
.inv-card:hover { box-shadow: 0 4px 18px rgba(0,0,0,.10); transform: translateY(-2px); }
.inv-card-closed { opacity: .65; }

/* Card header (avatar + name + actions) */
.inv-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.inv-card-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--mustard-light, #fdf3e3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--mustard);
  flex-shrink: 0;
}
.inv-card-name { flex: 1; min-width: 0; }
.inv-card-title {
  font-size: .9rem; font-weight: 700;
  color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inv-card-sub {
  font-size: .72rem; color: var(--text-muted);
  margin-top: 2px;
}
.inv-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Card body — stats grid */
.inv-card-body { padding: 12px 16px; flex: 1; }

/* Sections inside card or form */
.inv-section { margin-bottom: 12px; }
.inv-section-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 6px;
}
.inv-section-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
}

/* Individual stat inside a section */
.inv-stat { }
.inv-stat-label {
  font-size: .68rem; color: var(--text-muted);
  margin-bottom: 2px;
}
.inv-stat-val {
  font-size: .88rem; font-weight: 600;
  color: var(--text-main);
}
.inv-stat-val.danger { color: #c0392b; }
.inv-stat-val.ok    { color: #2d6a4f; }

/* Card footer */
.inv-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--bg-main);
}

/* ── Form sections inside modals ────────────────────── */
.inv-form-section {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.inv-form-section-title {
  background: var(--bg-main);
  padding: 8px 14px;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.inv-form-section-title i { color: var(--mustard); }
.inv-form-section > .form-grid {
  padding: 14px 14px 4px;
}

/* Responsive */
@media (max-width: 768px) {
  .inv-cards-grid { grid-template-columns: 1fr; }
  .inv-section-grid { grid-template-columns: 1fr; }
}

/* Tabella — colonna num (allineata a destra) */
th.num, td.num { text-align: right; }

/* ── Nav section label ───────────────────────────────── */
/* (già presente, assicura .nav-section-label in sidebar) */

/* ══════════════════════════════════════════════════════
   CAMPANELLA NOTIFICHE
══════════════════════════════════════════════════════ */
.notif-bell-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.notif-bell {
  position: relative;
  width: 38px; height: 38px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-sub);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
}
.notif-bell:hover { background: var(--bg-main); border-color: var(--mustard); color: var(--mustard); }

.notif-badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 18px; height: 18px;
  background: #c0392b;
  color: #fff;
  border-radius: 20px;
  font-size: .62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--black);
  pointer-events: none;
  animation: notif-pulse 2s infinite;
}
@keyframes notif-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

/* ── Pannello notifiche dropdown ── */
.notif-panel {
  position: fixed;
  top: 68px; right: 16px;
  width: 420px;
  max-height: 560px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-main);
  flex-shrink: 0;
}

.notif-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.notif-empty {
  text-align: center;
  padding: 36px 24px;
  color: var(--text-muted);
  font-size: .84rem;
}
.notif-empty i { font-size: 2rem; display: block; margin-bottom: 10px; color: #2d6a4f; }

/* ── Singola notifica ── */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
  cursor: default;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-main); }

/* Bordo sinistro colorato per urgenza */
.notif-item-scaduta { border-left: 3px solid #c0392b; }
.notif-item-alta    { border-left: 3px solid #e67e22; }
.notif-item-media   { border-left: 3px solid var(--mustard); }
.notif-item-bassa   { border-left: 3px solid var(--border); }

.notif-item-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem;
  flex-shrink: 0;
}
.notif-verde  { background: #eafaf1; color: #2d6a4f; }
.notif-rosso  { background: #fdf0ef; color: #c0392b; }
.notif-giallo { background: #fdf3e3; color: #7a4800; }
.notif-blu    { background: #eaf0fe; color: #1a3a6b; }

.notif-item-body  { flex: 1; min-width: 0; }
.notif-item-title {
  font-size: .83rem; font-weight: 600;
  color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-item-sub {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: .73rem; color: var(--text-muted);
  margin-top: 4px; align-items: center;
}

/* Chip urgenza */
.notif-urg { font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.notif-urg-scaduta { background: #fdf0ef; color: #c0392b; }
.notif-urg-alta    { background: #fef5ec; color: #a04000; }
.notif-urg-media   { background: #fdf3e3; color: #7a4800; }
.notif-urg-bassa   { background: var(--bg-main); color: var(--text-muted); }

.notif-item-actions {
  display: flex;
  gap: 4px;
  align-items: flex-start;
  flex-shrink: 0;
}
.notif-goto, .notif-dismiss {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  font-size: .75rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all .12s;
}
.notif-goto:hover    { background: var(--mustard-light,#fdf3e3); color: var(--mustard); border-color: var(--mustard); }
.notif-dismiss:hover { background: #fdf0ef; color: #c0392b; border-color: #c0392b; }

/* ══════════════════════════════════════════════════════
   AVATAR UTENTE (tabella utenti sistema)
══════════════════════════════════════════════════════ */
.usr-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--black);
  color: var(--mustard);
  font-size: .82rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid var(--mustard);
}

/* Responsive pannello notifiche */
@media (max-width: 480px) {
  .notif-panel { width: calc(100vw - 16px); right: 8px; }
}

/* ══════════════════════════════════════════════════════
   SCADENZIARIO RIMBORSI ED INTERESSI
══════════════════════════════════════════════════════ */

/* Blocco per investitore */
.scad-inv-block {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  overflow: hidden;
}

.scad-inv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.scad-inv-body { overflow-x: auto; }
.scad-inv-body .data-table { border-radius: 0; border: none; }

/* Righe rate */
.scad-row-pagata td  { opacity: .55; text-decoration: line-through; background: #f8fdf8; }
.scad-row-pagata td:last-child { text-decoration: none; opacity: 1; }
.scad-row-scaduta td { background: #fff5f5; }
.scad-row-scaduta td:first-child { border-left: 3px solid #c0392b; }
.scad-row-futura td  { background: var(--white); }
.scad-row-futura td:first-child { border-left: 3px solid transparent; }

/* ══════════════════════════════════════════════════════
   MODULO BUDGET
══════════════════════════════════════════════════════ */

/* KPI bar in cima all'analisi */
.bud-kpi-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.bud-kpi {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 20px;
  min-width: 160px;
  flex: 1;
}
.bud-kpi-label {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.bud-kpi-val {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Progress bar utilizzo budget */
.bud-progress-wrap {
  flex: 1;
  height: 8px;
  background: var(--bg-main);
  border-radius: 20px;
  overflow: visible;
  position: relative;
  min-width: 80px;
  border: 1px solid var(--border);
}
.bud-progress-bar {
  height: 100%;
  border-radius: 20px;
  transition: width .4s ease;
}
.bud-progress-over {
  position: absolute;
  right: 0; top: 0;
  height: 100%;
  border-radius: 0 20px 20px 0;
  background: #c0392b;
  opacity: .7;
}
.bud-bar-ok   { background: #2d6a4f; }
.bud-bar-warn { background: #e67e22; }
.bud-bar-over { background: #c0392b; }
.bud-pct {
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  min-width: 36px;
  text-align: right;
}
.bud-pct.bud-bar-ok   { color: #2d6a4f; }
.bud-pct.bud-bar-warn { color: #e67e22; }
.bud-pct.bud-bar-over { color: #c0392b; }

/* Badge stato */
.bud-badge-over { background: #fdf0ef; color: #c0392b; border: 1px solid #f5c2bd; font-size: .68rem; }
.bud-badge-warn { background: #fef5ec; color: #a04000; border: 1px solid #f9d4a7; font-size: .68rem; }
.bud-badge-ok   { background: #eafaf1; color: #2d6a4f; border: 1px solid #b8e6cd; font-size: .68rem; }

/* Alert proiezione */
.bud-alert-over {
  display: flex; align-items: center; gap: 12px;
  background: #fdf0ef;
  border: 1.5px solid #c0392b;
  border-radius: var(--r);
  padding: 14px 20px;
  font-size: .88rem;
  color: #c0392b;
  font-weight: 600;
  margin-bottom: 16px;
}
.bud-alert-over i { font-size: 1.2rem; flex-shrink: 0; }
.bud-alert-ok {
  display: flex; align-items: center; gap: 12px;
  background: #eafaf1;
  border: 1.5px solid #2d6a4f;
  border-radius: var(--r);
  padding: 14px 20px;
  font-size: .88rem;
  color: #2d6a4f;
  font-weight: 600;
  margin-bottom: 16px;
}
.bud-alert-ok i { font-size: 1.2rem; flex-shrink: 0; }

/* Riga mese corrente evidenziata */
.bud-row-current td {
  background: rgba(200,168,75,.07);
}

/* Grid mesi nel form budget */
.bud-mesi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.bud-mese-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bud-mese-label {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.bud-mese-inp {
  width: 100%;
  padding: 6px 8px;
  font-size: .82rem;
  text-align: right;
}

/* Responsive */
@media (max-width: 768px) {
  .bud-kpi   { min-width: 120px; }
  .bud-mesi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  .bud-mesi-grid { grid-template-columns: repeat(2, 1fr); }
  .bud-kpi-bar   { flex-direction: column; }
}

@media (max-width: 1100px) {
  .fab-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .fab-grid { grid-template-columns: repeat(2, 1fr); }
  .report-summary-bar .rep-kpi { flex: 1 1 140px; }
  .rep-filter-bar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 480px) {
  .fab-grid { grid-template-columns: 1fr; }
}
