:root {
  --verde: #0e5c45;
  --verde-scuro: #08452f;
  --verde-chiaro: #eaf4f0;
  --verde-pallido: #d3e8e0;
  --testo: #1c2a25;
  --testo-forte: #0e2e20;
  --muto: #5a6a63;
  --carta: #ffffff;
  --bordo: #dce8e2;
  --ombra: rgba(20,60,50,.08);
  --rosso: #c0392b;
  --arancio: #e67e22;
  --giallo: #d4ac0d;
  --blu: #2471a3;
  --verde-ok: #1e8e4e;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding:   0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--verde-chiaro);
  color: var(--testo);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--verde);
  color: #fff;
  padding: 14px 16px;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 1px 6px rgba(0,0,0,.15);
}

.app-header h1 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: .2px; }

.header-btn {
  background: rgba(255,255,255,.14);
  border:   0;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  padding: 8px 12px;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

main.app-main {
  max-width: 600px;
  margin:   0 auto;
  padding: 16px 16px 92px;
}

.view { display: none; }
.view.attiva { display: block; }

.carta {
  background: var(--carta);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 4px var(--ombra);
  margin-bottom: 14px;
}

.carta h2 { margin:   0 0 10px; font-size: 15px; color: var(--testo-forte); }

.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title-row h2 { margin:   0; }

.hero { background: linear-gradient(135deg, var(--verde), var(--verde-scuro)); color:#fff; }
.hero h2 { color: rgba(255,255,255,.85); }
.dr-big { font-size: 38px; font-weight: 800; margin: 4px 0 2px; }
.dr-sub { color: rgba(255,255,255,.75); font-size: 13px; }
.dr-dettaglio { margin-top: 12px; border-top:   1px solid rgba(255,255,255,.18); padding-top: 10px; }
.dr-dettaglio div { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; color: rgba(255,255,255,.9); }
.dr-dettaglio b { font-weight: 700; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap:   10px; margin-bottom:   14px; }
.kpi { background: var(--carta); border-radius: 12px; padding: 12px; box-shadow: 0 1px 4px var(--ombra); }
.kpi b { display: block; font-size: 20px; color: var(--testo-forte); }
.kpi span { font-size: 12px; color: var(--muto); }
.kpi.saldo b { color: var(--verde); }
.kpi.danger b { color: var(--rosso); }
.kpi.ok b { color: var(--verde-ok); }

.filtro { display: flex; gap:   8px; flex-wrap: wrap; align-items: center; }
.filtro select, .filtro input { font-size: 14px; padding: 8px; border-radius: 8px; border:   1px solid var(--bordo); background: #fff; color: var(--testo); }
.filtro .campo-da-a { display: flex; gap:   6px; align-items: center; font-size: 13px; color: var(--muto); }

.lista { list-style: none; margin:   0 0; padding: 0; }
.lista li { display: flex; justify-content: space-between; align-items: flex-start; gap:   8px; padding: 10px 0; border-bottom:   1px solid var(--bordo); }
.lista li:last-child { border-bottom: none; }
.lista .info { flex: 1; }
.lista .etichetta { font-weight: 600; font-size: 14px; color: var(--testo-forte); }
.lista .sotto { font-size:   12px; color: var(--muto); }
.lista .importo { font-weight: 700; white-space: nowrap; }
.lista .azioni { display: flex; gap:   6px; flex-shrink:   0; }
.lista .azioni button { font-size: 12px; padding: 4px 8px; border:   1px solid var(--bordo); background: #fff; border-radius: 8px; cursor: pointer; color: var(--testo); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size:   11px; font-weight: 600; margin-top: 4px; white-space: nowrap; }
.badge.certo { background: #e8f5ee; color: #14532d; }
.badge.stimato { background: #fff4d6; color: #7a5a00; }
.badge.da_confermare { background: #eef2ff; color: #2b4d8a; }
.badge.pagato { background: #dff3e6; color: #14532d; }
.badge.da_pagare { background: #fdeaea; color: #b03a2e; }
.badge.scaduto { background: #fddede; color: #b03a2e; }
.badge.annullato { background: #eceff1; color: #6b7680; }
.badge.stima { background: #fff4d6; color: #7a5a00; }

.avviso-stima { display: flex; gap: 10px; align-items: flex-start; background: #fff8e1; border: 1px solid #f3e2a9; }
.avviso-stima .ico-stima { font-size: 18px; color: #7a5a00; line-height: 1.4; flex-shrink: 0; }
.avviso-stima b { display: block; font-size: 14px; color: #7a5a00; margin-bottom: 2px; }
.avviso-stima p { margin: 0; font-size: 13px; color: #7a5a00; line-height: 1.4; }

.fisc-periodo { border-radius: 10px; background: #f4faf7; padding: 10px 12px; margin-bottom: 8px; }
.fisc-periodo:last-child { margin-bottom: 0; }
.fisc-periodo .fisc-periodo-titolo { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13px; margin-bottom: 6px; color: var(--testo-forte); }
.fisc-periodo .riga { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.fisc-tipo-grid { display: flex; flex-direction: column; gap: 8px; }
.fisc-tipo-card { border-radius: 10px; background: #f4faf7; padding: 10px 12px; }
.fisc-tipo-card .fisc-tipo-titolo { display: flex; justify-content: space-between; font-weight: 700; font-size: 13px; margin-bottom: 4px; color: var(--testo-forte); }
.fisc-tipo-card .riga { display: flex; justify-content: space-between; font-size: 12px; color: var(--muto); padding: 1px 0; }

label { font-size: 12px; font-weight: 600; color: var(--muto); display: block; margin-bottom:   4px; }
.campo { margin-bottom:   12px; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding:   10px 12px;
  border:   1px solid var(--bordo);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: var(--testo);
}
textarea { resize: vertical; min-height: 80px; }
.campo-riga { display: flex; gap:   8px; }
.campo-riga .campo { flex:   1; }

.btn { display: block; width:   100%; padding: 12px; border: none; border-radius: 10px; font-size: 15px; font-weight:   700; cursor: pointer; background: var(--verde); color:#fff; }
.btn.secondario { background: #fff; color: var(--verde); border:   1px solid var(--verde); }
.btn.pericolo { background:#fff; color:var(--rosso); border:   1px solid var(--rosso); }
.btn.mini { display: inline-block; width: auto; padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }

.scad-list { list-style: none; margin:   0; padding: 0; }
.scad-list li { display: flex; align-items: center; gap:   10px; padding: 10px 0; border-bottom:   1px solid var(--bordo); font-size: 14px; }
.scad-list li:last-child { border-bottom: none; }
.dot { width:   10px; height:   10px; border-radius: 50%; flex-shrink:   0; }
.dot.ritardo { background: var(--rosso); }
.dot.oggi { background: var(--arancio); }
.dot.a_3 { background: var(--arancio); }
.dot.a_7 { background: var(--giallo); }
.dot.a_15 { background: var(--blu); }
.dot.a_30 { background: var(--verde-ok); }
.scad-data { font-weight: 700; min-width:   82px; }
.bucket-tag { margin-left: auto; font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--verde-pallido); color: var(--verde-scuro); white-space: nowrap; }
.bucket-tag.ritardo { background: #fdeaea; color: var(--rosso); }
.bucket-tag.oggi, .bucket-tag.a_3 { background: #fdeee0; color: var(--arancio); }

.mese-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom:   10px; }
.mese-nav button { border:   1px solid var(--bordo); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 14px; }
.mese-nav b { font-size:   15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap:   4px; text-align: center; font-size: 12px; }
.cal-grid .g { font-weight: 700; color: var(--muto); padding: 4px 0; }
.cal-cell { position: relative; min-height: 36px; padding: 4px; border-radius: 8px; background: #f4faf7; color: var(--muto); }
.cal-cell.hoy { background: var(--verde); color: #fff; font-weight:   700; }
.cal-cell.scad { background: #ffe9d6; color: var(--testo-forte); font-weight:   600; }
.cal-cell .punto { display: flex; gap:   2px; justify-content: center; margin-top:   2px; }
.cal-cell .punto i { width:   5px; height:   5px; border-radius: 50%; background: var(--rosso); display: inline-block; }

.cal-cell.stato-prossima { background: #e9f2fb; color: var(--testo-forte); font-weight:   600; }
.cal-cell.stato-scaduta { background: #fde3e0; color: var(--testo-forte); font-weight:   600; }
.cal-cell.stato-completata { background: #e1f3e8; color: var(--testo-forte); }
.cal-cell.stato-scaduta .punto i, .cal-cell.stato-scaduta .punto i { background: var(--rosso); }
.cal-cell.stato-prossima .punto i { background: var(--blu); }
.cal-cell.stato-completata .punto i { background: var(--verde-ok); }

.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 11px; color: var(--muto); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i.lg { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.cal-legend i.lg.stato-prossima { background: var(--blu); }
.cal-legend i.lg.stato-scaduta { background: var(--rosso); }
.cal-legend i.lg.stato-completata { background: var(--verde-ok); }

.notif-badge {
  display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 99px;
  background: var(--rosso); color: #fff; font-size: 11px; font-weight: 700;
  text-align: center; vertical-align: middle; line-height: 18px;
}
.notif-badge.vuoto { background: var(--verde-ok); }

.bottom-nav button { position: relative; }
.nav-badge {
  position: absolute; top: -2px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px; background: var(--rosso); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.nav-badge.vuoto { background: var(--verde-ok); }

.notif-list li.completata { opacity: .55; }
.notif-list li.completata .etichetta { text-decoration: line-through; }
.notif-list .marca {
  margin-left: auto; border: 1px solid var(--bordo); background: #fff; color: var(--verde);
  border-radius: 8px; padding: 4px 8px; font-size: 12px; cursor: pointer; flex-shrink: 0;
}
.notif-list .fatto { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--verde-ok); flex-shrink: 0; }
.avvisi-cap {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px;
}
.avvisi-cap .puliscilette { border: none; background: none; color: var(--blu); font-size: 12px; cursor: pointer; padding: 0; }


.confronto .riga { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; border-bottom:   1px dashed var(--bordo); }
.confronto .riga:last-child { border-bottom: none; }

.bottom-nav {
  position: fixed; left:   0; right:   0; bottom:   0;
  background: #fff;
  border-top:   1px solid var(--bordo);
  display: flex;
  justify-content: space-around;
  padding: 6px 4px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  box-shadow:     0 -2px 8px rgba(0,0,0,.06);
  z-index: 50;
}
.bottom-nav button {
  border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap:   2px;
  font-size: 11px; color: var(--muto);
  padding: 4px 6px;
}
.bottom-nav button.attivo { color: var(--verde); font-weight: 700; }
.bottom-nav .ico { font-size: 20px; line-height: 1; }

.avviso { background: #fff8e1; border:   1px solid #f3e2a9; color: #7a5a00; border-radius: 10px; padding: 10px 12px; font-size:   13px; margin-bottom:   14px; }
.avviso.errore { background: #fdeaea; border-color: #f2c1c1; color: var(--rosso); }
.muto { color: var(--muto); font-size:   13px; }
.fila { display: flex; gap:   8px; align-items: center; }
.storico { font-size:   12px; color: var(--muto); margin-top:   4px; list-style: disc; padding-left: 16px; }
.vuoto { color: var(--muto); font-size: 14px; padding: 14px; text-align: center; }.hidden { display: none !important; }
.align-center { align-items: center; }

/* ---- Incassi: form completo, calcoli, import CSV ---- */
.check-line { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--testo); padding-top: 6px; }
.check-line input { width: auto; }

#incassi-calcoli .lista-calcoli { display: flex; flex-direction: column; gap: 0; }
.riga-calcolo {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 7px 0; border-bottom: 1px dashed var(--bordo); font-size: 14px;
}
.riga-calcolo:last-child { border-bottom: none; }
.sc-cal-etichetta { color: var(--testo); }
.sc-cal-valore { font-weight: 700; color: var(--testo-forte); white-space: nowrap; }
.sc-cal-valore.positivo { color: var(--verde-ok); }
.sc-cal-valore.negativo { color: var(--rosso); }
.sc-cal-nota { font-size: 12px; color: var(--muto); }

#csv-feedback p.ok { color: var(--verde-ok); font-size: 14px; margin: 10px 0 4px; }
#csv-feedback p.attenzione { color: var(--arancio); font-size: 14px; margin: 10px 0 4px; }
#csv-feedback p.errore { color: var(--rosso); font-size: 14px; margin: 10px 0 4px; }
#csv-feedback p.sotto { font-size: 12px; color: var(--muto); margin: 2px 0; }
.csv-errori { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muto); }
.csv-errori li { margin: 2px 0; }

/* ---- BLU-166: Sezioni analitica (Budget/Indicatori/Liquidità) ---- */
.bottom-nav { overflow-x: auto; justify-content: flex-start; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.bottom-nav::-webkit-scrollbar { display: none; }
.bottom-nav button { flex: 0 0 auto; min-width: 62px; }

.bv-bar { height: 12px; border-radius: 6px; background: #e6f0ec; position: relative; overflow: hidden; display: block; }
.bv-bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; display: block; }
.bv-bar > i.b { background: var(--blu, #4a90d9); }
.bv-bar > i.r { background: var(--verde); }
.bv-bars { display: flex; gap: 6px; }
.bv-bars > .chart-bar { flex: 1; }

.chart-row { margin: 10px 0; }
.chart-row .chart-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.chart-row .chart-head .val { font-weight: 700; color: var(--testo-forte); }
.chart-bar { height: 14px; border-radius: 7px; background: #e6f0ec; position: relative; overflow: hidden; display: block; }
.chart-bar > i { display: block; height: 100%; border-radius: 7px; }
.chart-bar > i.c1 { background: var(--verde); }
.chart-bar > i.c2 { background: var(--arancio); }
.chart-bar > i.c3 { background: #4a90d9; }
.chart-bar > i.c4 { background: #b98fe0; }

.bv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bv-table th { text-align: left; font-size: 11px; color: var(--muto); padding: 4px 6px; border-bottom: 1px solid var(--bordo); font-weight: 600; }
.bv-table td { padding: 6px; border-bottom: 1px dashed var(--bordo); }
.bv-table tr:last-child td { border-bottom: none; }
.bv-table td.num, .bv-table th.num { text-align: right; }
.bv-table td.tot, .bv-table th.tot { font-weight: 700; border-top: 1px solid var(--bordo); }
.pos { color: var(--verde-ok); font-weight: 700; }
.neg { color: var(--rosso); font-weight: 700; }

.liq-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.liq-card { background: var(--carta); border: 1px solid var(--bordo); border-radius: 12px; padding: 12px; box-shadow: 0 1px 4px var(--ombra); }
.liq-card h4 { margin: 0 0 2px; font-size: 12px; color: var(--muto); font-weight: 600; }
.liq-card b.h { display: block; font-size: 20px; color: var(--testo-forte); }
.liq-card b.h.risk { color: var(--rosso); }
.liq-card .liq-sub { font-size: 11px; color: var(--muto); }

.risk-banner { background: #fdeaea; border: 1px solid #f2c1c1; color: var(--rosso); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.risk-banner.ok { background: #e9f7ef; border-color: #bfe6cf; color: #1f7a4d; }
.risk-list { list-style: none; margin: 8px 0 0; padding: 0; }
.risk-list li { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed var(--bordo); }
.risk-list li:last-child { border-bottom: none; }

.kpi-line { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--bordo); font-size: 14px; }
.kpi-line:last-child { border-bottom: none; }
.kpi-line .lab { color: var(--testo); }
.kpi-line b { font-size: 16px; color: var(--testo-forte); }

.legend-row { display: flex; gap: 14px; font-size: 11px; color: var(--muto); margin: 6px 0; flex-wrap: wrap; }
.legend-row .lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid2 .kpi b { font-size: 18px; }
.form-grid { display: flex; flex-direction: column; gap: 10px; }
.form-grid .campo { margin: 0; }

/* Permessi accesso (BLU-153f) */
.tavola { width: 100%; border-collapse: collapse; font-size: 12px; }
.tavola th, .tavola td { text-align: center; padding: 6px 4px; border-bottom: 1px solid var(--bordo); }
.tavola th { color: var(--muto); font-weight: 700; }
.tavola td:first-child { text-align: left; color: var(--testo); }
.tavola .perm-ok { color: #1f7a4d; font-weight: 700; }
.tavola .perm-no { color: #c8cdd2; }

/* Esportazione (BLU-153d) */
#exp-feedback p.successo { color: #1f7a4d; font-size: 14px; margin: 10px 0 4px; }
#exp-feedback p.errore { color: var(--rosso); font-size: 14px; margin: 10px 0 4px; }
.lista .azioni select { font-size: 12px; padding: 4px; border: 1px solid var(--bordo); border-radius: 8px; background: #fff; color: var(--testo); max-width: 120px; }
