
:root{--navy:#8E0E0E;--blue:#B71C1C;--bg:#f4f7fb;--card:#fff;--green:#138a52;--red:#bf2f2f;--muted:#6b7280;--line:#e5ebf2;--amber:#f0b429}
*{box-sizing:border-box}body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:var(--bg);color:#172033}
header{position:sticky;top:0;z-index:8;background:var(--navy);color:#fff;padding:14px 16px;box-shadow:0 2px 12px #0002}
header h1{margin:0;font-size:20px}header small{opacity:.8}
main{padding:14px 14px 96px;max-width:980px;margin:auto}.page{display:none}.page.active{display:block}
.grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}.card{background:#fff;border-radius:16px;padding:14px;box-shadow:0 2px 12px #8E0E0E18}
.kpi{font-size:24px;font-weight:800;margin-top:5px}.muted{font-size:12px;color:var(--muted)}.good{color:var(--green)}.bad{color:var(--red)}
.section-title{font-size:18px;font-weight:800;margin:22px 0 10px}.row{display:flex;justify-content:space-between;gap:10px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)}
input,select,button,textarea{width:100%;padding:12px;border:1px solid #ccd6e3;border-radius:10px;background:#fff;font-size:15px}
button.primary{background:var(--blue);color:#fff;border:0;font-weight:700}button.secondary{background:#FDECEC;color:var(--navy);border:0;font-weight:700}button.danger{background:#fee2e2;color:#991b1b;border:0}
form{display:grid;gap:10px}.twocol{display:grid;grid-template-columns:1fr 1fr;gap:10px}.bar{height:10px;background:#e7edf5;border-radius:10px;overflow:hidden}.bar span{display:block;height:100%;background:#D32F2F}
nav{position:fixed;bottom:0;left:0;right:0;z-index:10;background:#fff;border-top:1px solid #dfe6ef;display:grid;grid-template-columns:repeat(6,1fr);padding-bottom:env(safe-area-inset-bottom)}
nav button{border:0;background:transparent;padding:10px 2px;font-size:11px;color:#6B3A3A}nav button.active{color:var(--blue);font-weight:800}
.scroll{overflow:auto;max-height:62vh;background:#fff;border-radius:14px}table{width:100%;border-collapse:collapse;font-size:12px}th,td{padding:8px 6px;border-bottom:1px solid var(--line);text-align:left}
th{position:sticky;top:0;background:#f8fafc}.mini{width:auto;padding:6px 8px;border:0;background:#FDECEC}.filters{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.badge{display:inline-block;padding:4px 8px;border-radius:999px;background:#e9f4ee;color:#176b43;font-size:11px}.badge.no{background:#fdeaea;color:#a11}
.modal{position:fixed;inset:0;background:#0007;display:none;align-items:flex-end;z-index:20}.modal.open{display:flex}.sheet{background:#fff;width:100%;max-height:92vh;overflow:auto;padding:16px;border-radius:20px 20px 0 0}
@media(min-width:720px){.grid{grid-template-columns:repeat(4,1fr)}.modal{align-items:center;justify-content:center}.sheet{max-width:620px;border-radius:20px}}

.status-green{border-left:5px solid #138a52}.status-yellow{border-left:5px solid #f0b429}.status-red{border-left:5px solid #bf2f2f}
.progress-label{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:#6b7280;margin-top:6px}

@media(min-width:720px){#dashboardAccounts{grid-template-columns:repeat(3,1fr)}}

#scheduledList .danger{width:100%}

:root{
  --navy:#8E0E0E;
  --blue:#B71C1C;
  --red:#C62828;
}
header{
  background:linear-gradient(135deg,#8E0E0E,#C62828);
}
button.primary{
  background:linear-gradient(135deg,#B71C1C,#D32F2F);
}
nav button.active{
  color:#B71C1C;
}
.bar span{
  background:linear-gradient(90deg,#B71C1C,#EF5350);
}

.quick-bar{
  position:fixed;left:0;right:0;bottom:58px;z-index:9;
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));
  gap:7px;padding:8px 10px;background:rgba(255,255,255,.97);
  border-top:1px solid #f0d5d5;box-shadow:0 -3px 12px #00000010
}
.quick-bar:empty{display:none}.quick-bar button{flex:1;min-width:0;border:0;color:#fff;font-weight:800;padding:10px 7px;border-radius:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.quick-preset-card{background:#fff7f7!important}

.account-dashboard-card{width:100%;text-align:left;border:0;cursor:pointer}
.account-chart-wrap{margin-top:12px;background:#fff;border:1px solid #f0dddd;border-radius:16px;padding:8px}
.account-chart-wrap svg{display:block;width:100%;height:auto}

#patrimonyAccounts .card{background:#fff7f7}

.period-preview{
  background:#fff7f7;
  border:1px solid #f1d5d5;
  border-left:5px solid #B71C1C;
  border-radius:12px;
  padding:10px 12px;
  color:#5d3030;
}

.quick-bar[data-count="2"]{grid-template-columns:repeat(2,minmax(0,1fr))}
.quick-bar[data-count="3"]{grid-template-columns:repeat(3,minmax(0,1fr))}
.quick-bar[data-count="4"]{grid-template-columns:repeat(4,minmax(0,1fr))}
.quick-bar[data-count="5"],.quick-bar[data-count="6"]{grid-template-columns:repeat(3,minmax(0,1fr))}
.quick-bar button{width:100%;min-width:0;min-height:42px;padding:8px 5px;font-size:12px}
.quick-bar[data-count="5"] button,.quick-bar[data-count="6"] button{min-height:38px}

.accounts-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}
.accounts-grid .card{margin:0}
@media (max-width:520px){
  .accounts-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

#dashboardAccounts{display:none!important}

/* V5.2.3 SAFE HOME
   Solo visualizzazione: nessun dato o backend modificato.
*/

/* Nasconde il blocco disponibilità conti dalla Home */
#dashboardAccounts,
#dashboardAccounts + *,
#dashboardAccounts ~ * {
}

/* Elementi KPI principali che non vogliamo vedere nella Home */
#dashboard #income,
#dashboard #expense,
#dashboard #balance,
#dashboard #savingRate,
#dashboard #homeSpent,
#dashboard #homeBudgetRemaining,
#dashboard #homeBudgetPercent,
#dashboard #homeBudgetBar,
#dashboard #homeBudgetDetail {
  display:none!important;
}

/* Nasconde la card contenente gli ID sopra, se supportato dal browser */
#dashboard .card:has(#income),
#dashboard .card:has(#expense),
#dashboard .card:has(#balance),
#dashboard .card:has(#savingRate),
#dashboard .card:has(#homeSpent),
#dashboard .card:has(#homeBudgetRemaining),
#dashboard .card:has(#homeBudgetPercent),
#dashboard .card:has(#homeBudgetBar),
#dashboard .card:has(#homeBudgetDetail),
#dashboard .card:has(#dashboardAccounts) {
  display:none!important;
}

/* V5.3 posizione barra rapida */
.quick-bar-top{
  position:static!important;
  margin:0 0 10px 0;
  border:0!important;
  box-shadow:none!important;
  padding:0!important;
  background:transparent!important;
}
.quick-bar-top:empty{display:none!important}

/* Nasconde sempre Risparmio dalla Home */
#dashboard .card:has(#savingRate){display:none!important}
#dashboard #savingRate{display:none!important}

/* V5.3.5 SAFE LOCAL */
.check-row{display:flex;align-items:center;gap:9px;font-size:14px;color:#444}
.check-row input{width:auto}

/* Nasconde solo graficamente Risparmio; #saving resta nel DOM per il JS */
#dashboard .card:has(#saving){display:none!important}

/* La card Saldi conti viene mostrata solo se almeno un conto è selezionato */
