/* Dividi Spesa: design bible applicata all'app (docs/DESIGN-BIBLE.md, 3/11/2026).
   Caricato per ultimo: corregge gli strati precedenti senza riscriverli. Solo token della scala:
   --fs-*, --sp-*, --r-*, colori esistenti. Niente misure scritte a mano fuori scala. */

.only-desk-inline { display: none; }
@media (min-width: 900px) { .only-desk-inline { display: inline-flex; } }

/* ---------- Intestazione compatta ---------- */
.app-polish .app-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap;
  gap: var(--sp-2); min-height: 56px;
  margin: 0 calc(-1 * var(--sp-4)) var(--sp-3); padding: var(--sp-2) var(--sp-4) !important;
  padding-top: max(var(--sp-2), env(safe-area-inset-top)) !important;
  background: var(--page);
  transition: transform .25s var(--visual-ease, ease), box-shadow .2s;
}
.app-polish .app-bar > .bar-title { min-width: 0; flex: 1 1 auto; padding: 0 !important; }
.app-polish .app-bar h1 {
  margin: 0; font-size: var(--fs-lg); line-height: 1.2; font-weight: 650; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; min-width: 0;
}
.app-polish .app-bar .bar-title > p { display: none; }
.app-polish .bar-eyebrow {
  display: flex; align-items: center; gap: var(--sp-1); margin: 0 0 2px;
  font-size: var(--fs-cap); line-height: 1.2; font-weight: 600; letter-spacing: .01em; color: var(--ink-2);
}
.app-polish .bar-eyebrow svg { width: 12px; height: 12px; flex: none; }
.app-polish .app-bar .cal-head { margin: 0 !important; padding: 0 !important; gap: 2px; justify-content: flex-start; width: auto !important; min-width: 0; }
.app-polish .app-bar .cal-head h1 { font-size: var(--fs-lg); }
.app-polish .app-bar .cal-head .icon-btn {
  width: 36px; height: 36px; min-width: 36px; min-height: 36px; padding: 0;
  border: 0; background: transparent; box-shadow: none; border-radius: var(--r-pill); color: var(--ink-2);
}
.app-polish .app-bar .cal-head .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.app-polish .app-bar > .bar-actions {
  flex: none; width: auto !important; display: flex; align-items: center; gap: var(--sp-1); flex-wrap: nowrap; min-width: 0;
}
.app-polish .app-bar .help-btn, .app-polish .app-bar .bell-btn { position: relative !important; top: auto; right: auto; width: 40px; height: 40px; border: 0; background: transparent; }
.app-polish .app-bar .bell-btn svg { width: 20px; height: 20px; }
.app-polish .app-bar .btn.sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
/* Lo stato di sincronizzazione compare nella barra solo se c'è un problema da risolvere */
.app-polish .bar-alert:not(:has(.err, .pending)) { display: none !important; }
.app-polish .app-bar .bar-alert .sync-pill { max-width: 128px; overflow: hidden; text-overflow: ellipsis; padding: 6px 10px; font-size: var(--fs-cap); }
.me-btn { position: relative; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.me-btn .avatar.light { width: 36px; height: 36px; }
.me-btn .crown { width: 16px; height: 16px; top: -7px; right: -5px; }
.me-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (min-width: 900px) { .me-btn { display: none; } }
@media (max-width: 899px) {
  .app-polish main { padding-top: 0; }
  .app-polish.bar-hide .app-bar { transform: translateY(-110%); }
  .app-polish .app-bar.scrolled { box-shadow: 0 1px 0 var(--border); }
}
@media (min-width: 900px) {
  .app-polish .app-bar { position: static; margin: 0 0 var(--sp-5); padding: 0 !important; background: none; }
  .app-polish .app-bar h1, .app-polish .app-bar .cal-head h1 { font-size: var(--fs-2xl); }
  .app-polish .app-bar .bar-title > p { display: block; margin: 2px 0 0; font-size: var(--fs-sm); color: var(--ink-2); }
}
@media (prefers-reduced-motion: reduce) { .app-polish .app-bar { transition: none; } }

/* ---------- Menu del profilo (foglio dal basso) ---------- */
.me-sheet .dlg-body { display: flex; flex-direction: column; gap: var(--sp-3); }
.me-profile, .me-premium, .me-item {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md); color: var(--ink); text-decoration: none;
}
.me-profile { background: var(--surface-2); }
.me-profile .avatar.light { width: 44px; height: 44px; }
.me-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.me-txt b { font-size: var(--fs-base); font-weight: 600; }
.me-txt small { font-size: var(--fs-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.me-premium { border: 1px solid color-mix(in srgb, #f5b800 55%, transparent); background: color-mix(in srgb, #f5b800 9%, var(--surface)); }
.me-premium .me-ico .crown { position: static; width: 22px; height: 22px; transform: none; }
.me-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); padding-top: var(--sp-2); }
.me-item:hover, .me-profile:hover { background: var(--surface-2); }
.me-ico { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-2); font-weight: 650; font-size: var(--fs-base); }
.me-ico svg { width: 18px; height: 18px; }
.me-ico .sync-pill { padding: 0; background: none; }
.me-ico .sync-pill i { width: 10px; height: 10px; }
.me-sheet .chev { color: var(--muted); display: inline-flex; }
.me-sheet .chev svg { width: 16px; height: 16px; }

/* ---------- Spese famiglia ---------- */
/* Calendario: sul telefono solo la settimana scelta, il mese intero a richiesta */
.cal-toggle {
  display: none; align-items: center; justify-content: center; gap: var(--sp-1); width: 100%;
  margin-top: var(--sp-2); min-height: 40px; border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.cal-toggle:hover { background: var(--surface-2); color: var(--ink); }
.cal-toggle svg { width: 16px; height: 16px; }
@media (max-width: 899px) {
  .cal-toggle { display: flex; }
  .cal-grid.week-only > .wk-out { display: none; }
}

/* "Chi deve a chi": una sola scheda, dettaglio completo e pagamenti al suo interno */
.app-polish .kpi-settle .kpi-more > summary { font-size: var(--fs-sm); font-weight: 600; }
.app-polish .kpi-settle .settle-note { margin: var(--sp-2) 0 var(--sp-1); }
.app-polish .kpi-settle .settle-people { margin-top: var(--sp-1); }
.app-polish .kpi-settle .settle-h { margin: var(--sp-4) 0 var(--sp-1); font-size: var(--fs-sm); font-weight: 650; }
.app-polish .kpi-settle .settle-adv { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 3px 0; }
.app-polish .kpi-settle .payment-history h3 { font-size: var(--fs-sm); font-weight: 650; margin: var(--sp-4) 0 var(--sp-1); }

/* ---------- Modulo spesa compatto ---------- */
.chip.chip-more { color: var(--ink-2); border-style: dashed; }
.chip.chip-more svg { width: 14px; height: 14px; margin-left: 2px; }
.more-opts { border-top: 1px solid var(--border); padding-top: var(--sp-2); }
.more-opts > summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: 44px; cursor: pointer; list-style: none; font-size: var(--fs-base); font-weight: 600;
}
.more-opts > summary::-webkit-details-marker { display: none; }
.more-opts > summary .small { font-weight: 400; text-align: right; }
.more-opts > summary::after { content: ""; flex: none; width: 8px; height: 8px; margin-right: 4px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg) translateY(-2px); transition: transform .2s; }
.more-opts[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.more-opts[open] > summary { margin-bottom: var(--sp-2); }

/* ---------- Premium: una sola scheda che spiega cosa offre ---------- */
.app-polish .prem-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); border: 1px solid color-mix(in srgb, #f5b800 45%, var(--border)); background: color-mix(in srgb, #f5b800 6%, var(--surface)); }
.app-polish .prem-card h2 { margin: 0; font-size: var(--fs-md); font-weight: 650; letter-spacing: -.01em; }
.app-polish .prem-card .sub { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); max-width: 62ch; }
.app-polish .prem-card .pw-list { margin: var(--sp-1) 0; }
.app-polish .prem-card .pw-list li { font-size: var(--fs-sm); }
.app-polish .prem-card .prem-note { margin: 0; }
.app-polish .prem-card .btn { margin-top: var(--sp-1); }

/* Budget e media senza Premium: riga apribile, spiegazione solo su richiesta. */
.app-polish .card.prem-fold { display: block; padding: 0; border-radius: var(--r-lg); }
.prem-fold > summary {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 64px;
  padding: var(--sp-3) var(--sp-4); cursor: pointer; list-style: none;
  font-size: var(--fs-base); font-weight: 550; color: var(--ink);
}
.prem-fold > summary::-webkit-details-marker { display: none; }
.prem-fold > summary > span:first-child { flex: 1; min-width: 0; }
.prem-fold > summary > .lock-badge { margin: 0; flex: none; font-size: var(--fs-xs); }
.prem-fold > summary > svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.prem-fold[open] > summary { border-bottom: 1px solid var(--border); }
.prem-fold[open] > summary > svg { transform: rotate(180deg); }
.prem-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: var(--r-lg); }
.app-polish .prem-fold > .prem-fold-content { margin: 0; padding: var(--sp-4); border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.prem-fold-content > .lock-badge { display: none; }
/* Le anteprime con numeri inventati non compaiono più: resta la spiegazione della scheda Premium */
.app-polish .fake-card:has(> .fake-tag.sample) { display: none !important; }

/* Decisione sugli effetti di ottobre (React Bits): restano riflesso e inclinazione della prima scheda (solo con il
   puntatore, quindi su computer) e le comparse morbide. Tolta la trama a puntini dello sfondo: rumore dietro ai numeri. */
.app-polish main { background-image: none; }

/* ---------- Analisi senza Premium: righe bloccate tutte uguali ---------- */
.an-locked {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 64px; padding: var(--sp-5);
  text-align: left; cursor: pointer; color: var(--ink); font: inherit;
}
.an-view .card.an-locked { border: 1px solid var(--border); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.an-locked .an-locked-t { flex: 1; min-width: 0; font-size: var(--fs-md); font-weight: 550; line-height: 1.4; letter-spacing: -.02em; }
.an-locked .lock-badge { margin-left: 0; flex: none; font-size: var(--fs-xs); }
.an-locked > svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.an-locked:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.an-locked.an-locked-in { min-height: 56px; padding: var(--sp-3) var(--sp-4); border: 1px dashed var(--border); border-radius: var(--r-md); background: transparent; grid-column: 1 / -1; }
.an-locked.an-locked-in .an-locked-t { font-size: var(--fs-base); }
/* Etichetta Premium: una sola forma (lucchetto + Premium), anche nelle schede che spiegano */
.app-polish .prem-card > .lock-badge { margin-left: 0; font-size: var(--fs-xs); }

/* ---------- Spese mie: le tre voci di dettaglio (spese personali, quota famiglia, netto) in un unico elenco ---------- */
@media (max-width: 899px) {
  body.app-polish #view .summary-board.kpis > .ds-summary-card.kpi-minor { border-radius: 0; box-shadow: none; padding-block: 12px; }
  body.app-polish #view .summary-board.kpis > .ds-summary-card.kpi-minor + .ds-summary-card.kpi-minor { margin-top: -13px; border-top-color: transparent; box-shadow: inset 0 1px 0 var(--border); }
  body.app-polish #view .summary-board.kpis > .ds-summary-card.kpi-minor:not(.kpi-minor + .kpi-minor) { border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg); }
  body.app-polish #view .summary-board.kpis > .ds-summary-card.kpi-minor:not(:has(+ .kpi-minor)) { border-bottom-left-radius: var(--r-lg); border-bottom-right-radius: var(--r-lg); }
  body.app-polish #view .summary-board.kpis > .ds-summary-card.kpi-minor .ds-summary-watermark { display: none; }
}
.da-more { margin-top: var(--sp-3); }
.da-more > summary { display: flex; align-items: center; gap: var(--sp-1); min-height: 40px; cursor: pointer; list-style: none; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.da-more > summary::-webkit-details-marker { display: none; }
.da-more > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); margin-left: 4px; }
.da-more[open] > summary::after { transform: rotate(-135deg); }

/* ---------- Analisi: un solo ritmo verticale (titolare, 3/11/2026) ----------
   12 px tra tutte le voci, anche dentro le griglie; 24 px prima dei titoli di sezione «Gratis» e «Premium», 8 px dopo.
   Annulla i margini sparsi (0, 14, 16, 20, 28 px) delle singole schede. */
#view.an-view { display: flex; flex-direction: column; gap: var(--sp-3); }
#view.an-view > *:not(.app-bar), #view.an-view > .grid > *, #view.an-view > .kpis > * { margin-top: 0 !important; margin-bottom: 0 !important; }
#view.an-view > .grid, #view.an-view > .kpis { gap: var(--sp-3) !important; }
#view.an-view > .app-bar { margin-bottom: 0; }
#view.an-view > .sec-label { margin: var(--sp-3) 0 calc(var(--sp-1) * -1) !important; }
#view.an-view > .seg-tabs + .sec-label { margin-top: var(--sp-1) !important; }
#view.an-view > .grid:empty { display: none; }
@media (min-width: 900px) { #view.an-view > .grid > .an-locked { grid-column: 1 / -1; } }

/* ---------- Opzioni: tabella dei piani chiusa di partenza (era la parte più lunga della pagina) ---------- */
.plan-more { margin-top: var(--sp-3); border-top: 1px solid var(--border); }
.plan-more > summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; cursor: pointer; list-style: none; font-size: var(--fs-base); font-weight: 600; }
.plan-more > summary::-webkit-details-marker { display: none; }
.plan-more > summary::after { content: ""; width: 8px; height: 8px; margin-right: 4px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg) translateY(-2px); transition: transform .2s; }
.plan-more[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }

/* ---------- Opzioni: righe di impostazione compatte (titolo a sinistra, scelta a destra) ---------- */
.app-polish .card.set-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-4); }
.app-polish .set-row .set-row-t { min-width: 0; }
.app-polish .set-row h2 { margin: 0; font-size: var(--fs-md); }
.app-polish .set-row .sub { margin: 2px 0 0; font-size: var(--fs-sm); }
.app-polish .set-row .seg { flex-wrap: nowrap; flex: none; }
.app-polish .set-row .seg button { min-height: 40px; min-width: 76px; padding: 0 var(--sp-3); font-size: var(--fs-base); }

/* Gli avvisi occupano una riga propria: il mese conserva lo spazio per intero. */
@media (max-width: 899px) {
  .app-polish .app-bar { flex-wrap: wrap; }
  .app-polish .app-bar > .bar-actions { display: contents; }
  .app-polish .app-bar .bar-alert { order: 2; flex: 0 0 100%; }
  .app-polish .app-bar .bar-alert .sync-pill { max-width: 100%; white-space: normal; }
  .app-polish .app-bar .cal-head h1 { overflow: visible; text-overflow: clip; }
}
#dlgConfirm .dlg-body p { white-space: pre-line; }
