/* React Bits Pro: Hero18 (shell), Bento19 (financial cards), Bento40 (pills),
   AnimatedList (rows). App only; existing layout and palette are retained. */
body.app-polish {
  --visual-line: color-mix(in srgb, var(--ink) 12%, transparent);
  --visual-ease: cubic-bezier(.22, 1, .36, 1);
  background: var(--page);
}
.app-polish main {
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 0);
  background-size: 24px 24px;
}
.app-polish .container { position: relative; }
.app-polish .sidebar { border-color: var(--visual-line); gap: 6px; }
.app-polish .brand { letter-spacing: -.04em; font-weight: 650; }
.app-polish .brand small { letter-spacing: 0; }
.app-polish .user-chip { border-color: var(--visual-line); border-radius: var(--radius); }
.app-polish .user-chip.active { background: var(--surface-2); }
.app-polish .sidebar .nav-link {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 550;
  transition: background .25s, color .25s, border-color .25s;
}
.app-polish .sidebar .nav-link.active {
  background: var(--ink); color: var(--surface); border-color: var(--ink);
}
.app-polish .sidebar .nav-link.active .lock-badge { color: inherit; }
.app-polish .sidebar .nav-ico { display: grid; place-items: center; }
.app-polish .premium-side {
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--visual-line); box-shadow: none;
}
.app-polish .premium-link, .app-polish .lock-badge, .app-polish .fake-tag.prem {
  background: var(--surface-2); color: var(--ink);
  border-color: var(--visual-line); box-shadow: none; font-weight: 550;
}
.app-polish .sidebar .nav-link.active .lock-badge { background: transparent; border-color: currentColor; }
.app-polish .page-head h1 {
  font-weight: 550; letter-spacing: -.045em; line-height: 1.15;
}
.app-polish .page-head p { font-size: 14px; max-width: 64ch; }
.app-polish .sec-tag { color: var(--ink-2); font-weight: 550; letter-spacing: .08em; }
.app-polish .sec-tag .pill { font-weight: 500; }
.app-polish .card {
  border-radius: calc(var(--radius) + 6px);
  border-color: var(--visual-line);
  box-shadow: 0 2px 3px color-mix(in srgb, var(--ink) 2%, transparent);
}
.app-polish .card h2 { font-weight: 600; letter-spacing: -.025em; }
.app-polish .card h3 { font-weight: 550; }
.app-polish .card .sub { color: var(--ink-2); font-size: 12.5px; line-height: 1.55; }
.app-polish .kpi { position: relative; isolation: isolate; }
.app-polish .kpi .label { font-size: 12px; letter-spacing: .01em; font-weight: 500; }
.app-polish .kpi .value { font-weight: 550; letter-spacing: -.045em; line-height: 1.3; }
.app-polish .kpi .foot { color: var(--ink-2); font-size: 12px; }
.app-polish .kpis > .kpi:first-child {
  background: var(--ink); color: var(--surface); border-color: var(--ink);
  transform: perspective(700px) rotateX(var(--card-rx, 0deg)) rotateY(var(--card-ry, 0deg));
  transition: transform .5s var(--visual-ease), box-shadow .5s;
}
.app-polish .kpis > .kpi:first-child::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(ellipse at var(--card-x, 75%) var(--card-y, 0%), color-mix(in srgb, var(--surface) 16%, transparent), transparent 75%);
}
.app-polish .kpis > .kpi:first-child .label,
.app-polish .kpis > .kpi:first-child .foot { color: color-mix(in srgb, var(--surface) 76%, transparent); }
.app-polish .hero .value { font-weight: 550; letter-spacing: -.05em; }
.app-polish .btn {
  position: relative; isolation: isolate; border-radius: 999px;
  font-weight: 550; border-color: var(--visual-line);
  transition: background .25s, border-color .25s, color .25s, transform .35s var(--visual-ease);
}
.app-polish .btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.app-polish .btn.primary:hover { filter: none; background: color-mix(in srgb, var(--ink) 88%, var(--surface)); }
.app-polish .btn.ghost { border-color: transparent; }
.app-polish .btn.danger { color: var(--bad-ink); }
.app-polish .btn:active { transform: scale(.96); }
.app-polish .btn.icon-btn { border-radius: var(--radius-sm); }
.app-polish .card .btn:not(.icon-btn), .app-polish .dlg .btn:not(.icon-btn) {
  max-width: 100%; white-space: normal; text-align: center;
}
.app-polish :is(.btn, .help-btn, .chip, .cal-day, .theme-choice):focus-visible {
  outline: 2px solid var(--ink); outline-offset: 3px;
}
.app-polish .input {
  border-color: var(--visual-line); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: none;
  transition: border-color .2s, box-shadow .2s;
}
.app-polish .input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 7%, transparent); }
.app-polish .seg { border-radius: 999px; background: var(--surface-2); border-color: var(--visual-line); }
.app-polish .seg button { border-radius: 999px; font-weight: 550; }
.app-polish .seg button.on { background: var(--ink); color: var(--surface); box-shadow: none; }
.app-polish .seg-tabs { background: var(--surface-2); border: 1px solid var(--visual-line); padding: 4px; border-radius: var(--radius); gap: 4px; }
.app-polish .seg-tabs a, .app-polish .seg-tabs button {
  border-radius: var(--radius-sm); background: transparent; border: 1px solid transparent;
  box-shadow: none; font-weight: 550; transition: color .25s, background .25s, transform .35s var(--visual-ease);
}
.app-polish .seg-tabs .on { background: var(--ink); color: var(--surface); border-color: var(--ink); box-shadow: none; }
.app-polish .seg-tabs a:active, .app-polish .seg-tabs button:active { transform: scale(.98); box-shadow: none; }
.app-polish .chip {
  background: var(--surface); border-color: var(--visual-line); font-weight: 500;
  transition: background .25s, color .25s, transform .35s var(--visual-ease);
}
.app-polish .chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.app-polish .chip:active { transform: scale(.95); }
.app-polish .pill { border: 1px solid var(--visual-line); font-weight: 500; }
.app-polish .pill.disp, .app-polish .pill.vinc { background: var(--surface-2); color: var(--ink-2); }
.app-polish .cal-head h2 { letter-spacing: -.035em; font-weight: 550; }
.app-polish .cal-day { background: var(--surface-2); border: 1px solid transparent; transition: background .25s, border-color .25s, box-shadow .25s; }
.app-polish .cal-day.sel { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--surface); }
.app-polish .cal-day .n { font-weight: 550; }
.app-polish .cal-dow { font-weight: 500; letter-spacing: .08em; }
.app-polish .exp-item {
  position: relative; isolation: isolate; border-bottom-color: var(--border);
  transition: background .25s, transform .35s var(--visual-ease);
}
.app-polish .exp-item .t { font-weight: 550; }
.app-polish .exp-item .a { font-weight: 600; letter-spacing: -.025em; }
.app-polish .exp-item .ic {
  border-radius: var(--radius-sm); background: var(--surface-2) !important; color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--visual-line);
}
.app-polish .ai-card, .app-polish .start-card { background: var(--surface); }
.app-polish .bud-bar-wrap {
  --bud-c: var(--accent);
  --budget-gradient: linear-gradient(90deg,
    color-mix(in srgb, var(--accent) 65%, var(--surface)) 0%,
    color-mix(in srgb, color-mix(in srgb, var(--accent) 45%, var(--warn)) 58%, var(--surface)) 28%,
    color-mix(in srgb, var(--warn) 62%, var(--surface)) 55%,
    color-mix(in srgb, var(--series-2) 58%, var(--surface)) 78%,
    color-mix(in srgb, var(--bad) 60%, var(--surface)) 100%);
}
.app-polish .bud-mid { --bud-c: var(--ink-2); }
.app-polish .bud-high { --bud-c: var(--series-2); }
.app-polish .bud-over { --bud-c: var(--bad-ink); }
.app-polish .bud-pct { font-weight: 550; letter-spacing: -.04em; }
.app-polish .bud-bar-track { height: 14px; background: var(--budget-gradient); box-shadow: none; }
.app-polish .bud-bar-track::before {
  background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--visual-line) calc(25% - 1px) 25%), color-mix(in srgb, var(--surface) 92%, transparent);
}
.app-polish .bud-bar-fill {
  background-image: var(--budget-gradient); background-repeat: no-repeat;
  box-shadow: none; animation: none; min-width: 0;
}
.app-polish .bud-bar-fill::after { content: none; }
.app-polish .bud-pending .bud-bar-fill { visibility: hidden; }
.app-polish .fx-row { border-color: var(--border); }
.app-polish .note { border-radius: var(--radius); }
.app-polish dialog { border: 1px solid var(--visual-line); border-radius: calc(var(--radius) + 6px); }
.app-polish .dlg-head h2 { font-weight: 550; letter-spacing: -.035em; }
.app-polish .dlg-head, .app-polish .dlg-foot { border-color: var(--border); }
.app-polish .help-btn { border-color: var(--visual-line); font-weight: 550; }
.app-polish .profile-link { border-color: var(--visual-line); font-weight: 550; }
.app-polish .theme-switch {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--visual-line); border-radius: 999px;
  background: var(--surface); flex: none;
}
.app-polish .theme-choice {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 0; border-radius: 999px; background: transparent; color: var(--ink-2);
  padding: 0 9px; min-height: 38px; cursor: pointer; font-size: 12px; font-weight: 550;
  transition: color .25s, background .25s;
}
.app-polish .theme-choice[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.app-polish .theme-choice svg { width: 15px; height: 15px; }
.app-polish .bottom-nav { border-color: var(--visual-line); }
.app-polish .bottom-nav .nav-link.active { color: var(--ink); }
.app-polish .bottom-nav.dock .nav-ico::before { background: var(--surface-2); border-color: var(--visual-line); }
.app-polish .bottom-nav.dock .active .nav-ico::before { background: var(--ink); border-color: var(--ink); }
.app-polish .bottom-nav.dock .active .nav-ico > svg { color: var(--surface); }
.app-polish .fab {
  display: inline-flex;
  position: fixed;
  border-radius: 999px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--ink) 18%, transparent);
  animation: none;
}
.app-polish.no-exp .fab { animation: none; }
#expenseFab[hidden] { display: none !important; }
/* The action occupies its own lane; the scrolling viewport ends above it. */
.app-polish.expense-lane {
  --expense-action-h: calc(52px + 32px);
  --expense-footer-space: calc(var(--expense-action-h) + var(--nav-h) + env(safe-area-inset-bottom));
  overflow: hidden;
}
.app-polish.expense-lane .app { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.app-polish.expense-lane .app > main {
  height: calc(100vh - var(--expense-footer-space));
  height: calc(100dvh - var(--expense-footer-space)); min-height: 0;
  overflow-y: auto; overscroll-behavior-y: contain;
  padding-bottom: 24px; scroll-padding-block: 16px 24px;
  -webkit-overflow-scrolling: touch;
}
.expense-actionbar[hidden] { display: none !important; }
.app-polish .expense-actionbar {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  height: var(--expense-action-h); z-index: 30;
  padding: 8px 16px 8px;
  background: var(--page); border-top: 1px solid var(--border);
}
.expense-actionbar-inner { max-width: 1180px; margin: 0 auto; display: flex; justify-content: flex-end; }
.app-polish .expense-actionbar .fab {
  position: relative; right: auto; bottom: auto; flex: none;
  width: 100%; justify-content: center;
  min-height: 52px; margin: 0; box-shadow: none;
}
.expense-lane .tour-bar, .expense-lane #installBar { bottom: calc(var(--expense-footer-space) + 12px); }
.expense-lane .toast:not(.big) { bottom: calc(var(--expense-footer-space) + 16px); }
.expense-lane .bottom-nav.dock .nav-ico { transform-origin: center; }
.app-polish .search-field { position: relative; }
.app-polish .search-field > svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
.app-polish .search-field .input { padding-left: 42px; }
.app-polish .search-panel .exp-item {
  border-bottom: 0; border-radius: var(--radius-sm);
  padding: 10px; margin: 2px 0; overflow: hidden;
}
.app-polish .search-panel .exp-item:hover { transform: none; background: var(--surface-2); }
.app-polish .search-panel .hero-selected { background: var(--surface-2); }
.app-polish .search-panel .hero-selected::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: -1;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 5%, transparent), transparent);
  transform: translateX(-140%); animation: hero-search-shine 4.8s cubic-bezier(.22, 1, .36, 1) infinite;
}
@keyframes hero-search-shine {
  0% { transform: translateX(-140%); }
  46%, 100% { transform: translateX(140%); }
}
.app-polish.auth-screen { --auth-background: var(--surface); }
.app-polish.auth-screen main { padding: 0; background: var(--auth-background); }
:root[data-theme="dark"] .app-polish.auth-screen { --auth-background: var(--page); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app-polish.auth-screen { --auth-background: var(--page); }
}
.app-polish.auth-screen #view { max-width: none; }
.app-polish .auth-shell { display: flex; flex-direction: column; min-height: calc(100dvh - 110px); }
.app-polish .auth-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px; padding: 12px 32px;
}
.app-polish .auth-brand { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 550; white-space: nowrap; }
.app-polish .auth-brand img { border-radius: 8px; }
.app-polish .auth-top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.app-polish .auth-top .auth-account { background: var(--surface-2); border-color: transparent; border-radius: 8px; font-size: 12px; }
.app-polish .auth-main { display: flex; align-items: center; justify-content: center; flex: 1; padding: 32px 24px 40px; }
.app-polish .card.auth-panel { width: 100%; max-width: 420px; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.app-polish .auth-panel h1 { margin: 0; font-size: 26px; font-weight: 550; text-align: center; letter-spacing: -.03em; }
.app-polish .auth-lead { color: var(--ink-2); font-size: 14px; line-height: 1.7; text-align: center; margin: 8px auto 28px; max-width: 340px; }
.app-polish .auth-panel .btn { border-radius: var(--radius-sm); min-height: 44px; }
.app-polish .auth-provider, .app-polish .auth-submit { width: 100%; }
.app-polish .auth-provider svg { stroke: none; }
.app-polish .auth-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; color: var(--muted); font-size: 12px; }
.app-polish .auth-divider::before, .app-polish .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.app-polish .auth-panel .input { min-height: 44px; background: var(--auth-background); }
.app-polish .auth-field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.app-polish .auth-field-label a { font-size: 12px; color: var(--ink-2); }
.app-polish .auth-submit { margin-top: 8px; }
.app-polish .auth-submit svg { transition: transform .35s var(--visual-ease); }
.app-polish .auth-submit:hover svg { transform: translateX(3px); }
.app-polish .auth-error { color: var(--bad-ink); }
.app-polish .auth-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; font-size: 12px; margin-top: 24px; }
.app-polish .auth-links a, .app-polish .auth-panel .switch a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.app-polish .auth-panel .btn:disabled, .app-polish .auth-panel .input:disabled { opacity: .55; cursor: wait; }
.app-polish.auth-screen .credits { margin-top: 12px; padding: 12px 16px; }
.app-polish .visual-ripple {
  position: absolute; pointer-events: none; z-index: -1; border-radius: inherit;
  inset: 0; background: radial-gradient(circle at var(--ripple-x) var(--ripple-y), currentColor, transparent 70%);
}
@media (hover: hover) and (pointer: fine) {
  .app-polish .exp-item:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); transform: translateX(2px); }
  .app-polish .chip:hover { transform: translateY(-2px); border-color: var(--axis); }
}
@media (max-width: 899px) {
  .app-polish .page-head { gap: 12px; }
  .app-polish .page-head > .actions { width: 100%; }
  .app-polish .page-head .actions { gap: 8px; }
  .app-polish .theme-switch { margin-right: auto; }
  .app-polish .page-head > .cal-head { width: 100%; justify-content: flex-start; }
  .app-polish .cal-head h1 { font-size: 24px; }
  .app-polish .kpis > .kpi:first-child { transform: none; }
}
@media (max-width: 599px) {
  .app-polish .auth-top { padding: 12px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .app-polish .auth-top-actions { display: contents; }
  .app-polish .auth-top .auth-account { grid-column: 2; grid-row: 1; }
  .app-polish .auth-top .theme-switch { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .app-polish .auth-main { padding: 32px 24px; }
  .app-polish .auth-shell { min-height: calc(100dvh - 140px); }
  .app-polish .search-panel .exp-item { padding: 10px 6px; gap: 8px; }
}
@media (min-width: 900px) {
  .app-polish .fab { bottom: 24px; right: 36px; }
  .app-polish.expense-lane {
    --expense-action-h: calc(52px + 24px);
    --expense-footer-space: calc(var(--expense-action-h) + env(safe-area-inset-bottom));
  }
  .app-polish .expense-actionbar {
    left: 240px; bottom: env(safe-area-inset-bottom); padding: 12px 36px;
  }
  .app-polish .expense-actionbar .fab { width: auto; }
  .app-polish .page-head h1 { font-size: 36px; }
  .app-polish .kpi .value { font-size: 26px; }
}
@media (max-width: 360px) {
  .app-polish .theme-choice { padding: 0 7px; gap: 4px; }
  .app-polish .theme-choice svg { width: 13px; height: 13px; }
  .app-polish .page-head > .cal-head { padding-top: 44px; padding-right: 0; }
  .app-polish .cal-head h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .app-polish *, .app-polish *::before, .app-polish *::after {
    animation: none !important; transition: none !important; scroll-behavior: auto !important;
  }
  .app-polish .kpis > .kpi:first-child, .app-polish .exp-item:hover, .app-polish .chip:hover { transform: none; }
}

/* Totali in alto: cifre che scorrono (app-motion.js, mountFlows). Il testo vero resta nascosto per i lettori di schermo. */
.nf-d { display: inline-block; height: 1.3em; clip-path: inset(0 -1em); vertical-align: top; }
.nf-col { display: flex; flex-direction: column; }
.nf-col i { display: block; height: 1.3em; line-height: 1.3em; font-style: normal; text-align: left; }
.nf-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Totali in alto: variazione sul mese prima e linea degli ultimi mesi (kpiCtxHtml in app.js) + etichette più nitide */
.app-polish .kpi .label { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.kpi-ctx { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; min-height: 26px; }
.kpi-d { font-size: 12.5px; font-weight: 650; line-height: 1.3; font-variant-numeric: tabular-nums; flex: 1 1 auto; min-width: 0; }
.kpi-d.up { color: var(--bad-ink); }
.kpi-d.down { color: var(--good-ink); }
.kpi-d.flat { color: var(--muted); }
.kpi-d-s { font-weight: 450; color: var(--muted); }
.kpi-spark { flex: 0 0 auto; margin-left: auto; width: 72px; height: 26px; }

/* Totali in alto: profondità (ombra a due strati in chiaro, riflesso e bagliore in scuro), alone di accento sulla scheda protagonista, sollevamento al passaggio */
:root { --kpi-sh: 0 1px 2px rgba(11, 11, 11, .05), 0 10px 24px -12px rgba(11, 11, 11, .2); --kpi-sh-up: 0 2px 4px rgba(11, 11, 11, .06), 0 18px 32px -14px rgba(11, 11, 11, .3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --kpi-sh: inset 0 1px 0 rgba(255, 255, 255, .07), 0 12px 26px -16px rgba(0, 0, 0, .9); --kpi-sh-up: inset 0 1px 0 rgba(255, 255, 255, .11), 0 20px 34px -16px rgba(0, 0, 0, .95); } }
:root[data-theme="dark"] { --kpi-sh: inset 0 1px 0 rgba(255, 255, 255, .07), 0 12px 26px -16px rgba(0, 0, 0, .9); --kpi-sh-up: inset 0 1px 0 rgba(255, 255, 255, .11), 0 20px 34px -16px rgba(0, 0, 0, .95); }
.app-polish .kpis > .kpi { box-shadow: var(--kpi-sh); transition: transform .35s var(--visual-ease), box-shadow .35s var(--visual-ease); }
.app-polish .kpis > .kpi:first-child { box-shadow: var(--kpi-sh), 0 22px 38px -22px color-mix(in srgb, var(--accent) 70%, transparent); }
@media (hover: hover) and (pointer: fine) {
  .app-polish .kpis > .kpi:not(:first-child):hover { transform: translateY(-2px); box-shadow: var(--kpi-sh-up); }
}
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .app-polish .kpis > .kpi:first-child { transform: perspective(700px) translateY(var(--card-lift, 0px)) rotateX(var(--card-rx, 0deg)) rotateY(var(--card-ry, 0deg)); }
  .app-polish .kpis > .kpi:first-child:hover { --card-lift: -2px; box-shadow: var(--kpi-sh-up), 0 28px 44px -22px color-mix(in srgb, var(--accent) 80%, transparent); }
}
.app-polish .kpis > .kpi:active { transform: scale(.985); }
@media (prefers-reduced-motion: reduce) {
  .app-polish .kpis > .kpi, .app-polish .kpis > .kpi:first-child, .app-polish .kpis > .kpi:hover, .app-polish .kpis > .kpi:first-child:hover, .app-polish .kpis > .kpi:active { transform: none !important; }
}

/* Riepiloghi di Famiglia e Spese mie: bordo in rilievo e ombra distante dal fondo. */
:root {
  --summary-shadow-color: var(--ink);
  --summary-shadow: var(--kpi-sh-up), inset 0 1px 0 color-mix(in srgb, var(--surface) 80%, transparent),
    0 3px 0 color-mix(in srgb, var(--ink) 9%, var(--surface)),
    0 18px 28px -12px color-mix(in srgb, var(--summary-shadow-color) 45%, transparent),
    0 32px 50px -18px color-mix(in srgb, var(--summary-shadow-color) 35%, transparent);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --summary-shadow-color: var(--page); } }
:root[data-theme="dark"] { --summary-shadow-color: var(--page); }
.app-polish .summary-board { transform-origin: center top; backface-visibility: hidden; }
.app-polish .summary-board.kpis { gap: 16px; }
.app-polish .summary-board.kpis > .kpi,
.app-polish .summary-board.kpis > .kpi:hover,
.app-polish .daily-average { box-shadow: var(--summary-shadow); }
.app-polish .summary-board.kpis > .kpi:first-child { box-shadow: var(--summary-shadow), 0 24px 40px -24px color-mix(in srgb, var(--accent) 60%, transparent); }
.app-polish .summary-pending { transform: perspective(1200px) rotateX(-88deg); }
.daily-average { margin-top: 18px; }
.daily-average-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; margin: 20px 0; }
.daily-average-hero > div:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; min-width: 0; }
.daily-average-value { font-size: clamp(30px, 5vw, 44px); font-weight: 550; letter-spacing: -.045em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.daily-average-change { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px solid color-mix(in srgb, currentColor 20%, transparent); border-radius: var(--radius-sm); background: color-mix(in srgb, currentColor 8%, var(--surface)); font-size: 13px; color: var(--ink-2); }
.daily-average-change.up { color: var(--bad-ink); }
.daily-average-change.down { color: var(--good-ink); }
.daily-average-change small { display: block; margin-top: 3px; font-variant-numeric: tabular-nums; }
.daily-average-symbol { display: grid; place-items: center; flex: 0 0 28px; font-size: 28px; font-weight: 550; }
.daily-average-symbol svg { width: 28px; height: 28px; }
.daily-average-table { width: 100%; table-layout: fixed; font-size: 13px; font-variant-numeric: tabular-nums; }
.daily-average-table th, .daily-average-table td { padding: 12px 6px; white-space: normal; overflow-wrap: anywhere; }
.daily-average-table th:first-child { width: 44%; padding-left: 0; }
.daily-average-table tr > :last-child { padding-right: 0; }
.daily-average-table thead th { font-size: 11px; color: var(--ink-2); }
.daily-average-table tbody th { text-align: left; font-weight: 550; }
.daily-average-table tbody th small { display: block; margin-top: 5px; font-size: 10px; font-weight: 450; color: var(--ink-2); }
.daily-average-table tbody tr:first-child { background: var(--surface-2); }
.daily-average-table tbody tr:first-child > :first-child { padding-left: 8px; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.daily-average-table tbody tr:first-child > :last-child { padding-right: 8px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.daily-average-note { margin: 14px 0 0; line-height: 1.6; }
.daily-average-act { justify-content: flex-end; margin-top: 16px; }
.daily-average .fake-tag.prem svg { width: 12px; height: 12px; }
@media (prefers-reduced-motion: reduce) { .app-polish .summary-board, .app-polish .summary-pending { transform: none !important; } }

/* Matita e cestino di spese fisse e ricorrenti: sfondo leggero, così si vedono come tasti */
.app-polish .fx-row .btn.sm.ghost.icon-btn { background-color: var(--accent-soft); border-color: transparent; }
.app-polish .fx-row .btn.sm.ghost.icon-btn:hover { background-color: color-mix(in srgb, var(--accent) 28%, var(--accent-soft)); }
/* «Pausa» / «Riprendi» delle spese ricorrenti: tasto con sfondo e icona a sinistra; in pausa è pieno, così si nota */
.app-polish .fx-row .btn.rec-toggle { display: inline-flex; align-items: center; gap: 6px; background-color: var(--accent-soft); border-color: transparent; font-weight: 600; }
.app-polish .fx-row .btn.rec-toggle svg { width: 14px; height: 14px; flex: 0 0 auto; }
.app-polish .fx-row .btn.rec-toggle:hover { background-color: color-mix(in srgb, var(--accent) 28%, var(--accent-soft)); }
.app-polish .fx-row .btn.rec-toggle.paused { background-color: var(--accent); color: var(--accent-ink); }
.app-polish .fx-row .btn.rec-toggle.paused:hover { background-color: color-mix(in srgb, var(--accent) 88%, var(--ink)); }

/* Titoli delle schede spese fisse da confermare e spese ricorrenti: in verde, più visibili */
.app-polish .card h2.h-green { color: var(--accent); }

/* Spese fisse del mese: «Conferma tutte» sulla riga del titolo, su una riga sola; il testo sotto, a tutta larghezza */
.fx-head-in { flex: 1; min-width: 0; }
.fx-title { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.fx-title h2 { margin: 0; }
.fx-title .btn { white-space: nowrap; flex: 0 0 auto; }
.fx-head-in .sub { margin-top: 6px; }

/* ===== Rifinitura UX (14/10/2026): prima i dati, poi i comandi ===== */
/* Riepiloghi: griglia a sei colonne. Due valori principali per riga, le voci che li compongono più piccole */
.app-polish .summary-board.kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.app-polish .summary-board.kpis > .kpi { grid-column: span 3; min-width: 0; }
.app-polish .summary-board.kpis > .kpi:only-child { grid-column: 1 / -1; }
.app-polish .summary-board.kpis > .kpi.kpi-minor { grid-column: span 2; padding: 12px 14px; box-shadow: var(--kpi-sh); }
.app-polish .kpi.kpi-minor .value { font-size: 18px; }
.app-polish .kpi.kpi-minor .foot { font-size: 11.5px; }
/* Chi deve a chi, in alto a Famiglia: la frase usa la grafica originale (.settle, sfondo verde e icona) */
.kpi-settle .settle { margin-top: 8px; padding: 12px 14px; }
.kpi-settle .settle + div { height: 6px !important; }
.kpi-settle { display: flex; flex-direction: column; }
.kpi-more { margin-top: 8px; }
.kpi-more > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-bottom: -6px; cursor: pointer; list-style: none; font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.kpi-more > summary::-webkit-details-marker { display: none; }
.kpi-more > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .25s var(--visual-ease, ease); }
.kpi-more[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.kpi-more > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.kpi-more .kpi-rows { margin-top: 8px; }
.kpi-more .kpi-link { margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .kpi-more > summary::after { transition: none; } }
.kpi-rows { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.kpi-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 8px; align-items: baseline; font-size: 12.5px; color: var(--ink-2); }
.kpi-row .dot { align-self: center; }
.kpi-row-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-row-v { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-row-s { grid-column: 2 / -1; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: auto 0 -10px; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.kpi-link svg { width: 14px; height: 14px; }
/* Cifre d'esempio Premium accanto a quelle vere: tratteggio e valore attenuato, così non si confondono */
.app-polish .kpi.kpi-ex { background: transparent; border-style: dashed; box-shadow: none; }
.app-polish .kpi.kpi-ex .value { color: var(--muted); }
/* Tema scuro: la scheda principale resta in evidenza con l'accento, senza il bianco pieno che abbaglia */
:root[data-theme="dark"] .app-polish .kpis > .kpi:first-child {
  background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
:root[data-theme="dark"] .app-polish .kpis > .kpi:first-child :is(.label, .foot) { color: var(--ink-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app-polish .kpis > .kpi:first-child {
    background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--ink);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  }
  :root:not([data-theme="light"]) .app-polish .kpis > .kpi:first-child :is(.label, .foot) { color: var(--ink-2); }
}
/* Spese mie: la presentazione diventa una riga introduttiva, non una scheda */
.app-polish .card.mine-intro { background: transparent; border: 0; box-shadow: none; padding: 0 2px; }
.app-polish .mine-intro p { font-size: 13px; line-height: 1.55; color: var(--ink-2); }
/* Inviti Premium compatti: titolo e tasto su una riga, la barra d'esempio sotto */
.app-polish .month-end.teaser { align-items: center; gap: 12px; padding: 12px 14px; }
.app-polish .month-end.teaser .ico { flex-basis: 32px; width: 32px; height: 32px; border-radius: 10px; }
.app-polish .month-end.teaser .ico svg { width: 18px; height: 18px; }
.app-polish .month-end.teaser p { margin: 2px 0 8px; font-size: 13px; color: var(--ink-2); }
@media (max-width: 479px) { .app-polish .month-end.teaser .ico { display: none; } }
@media (min-width: 700px) {
  .app-polish .month-end.teaser > div:last-child { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; align-items: center; }
  .app-polish .month-end.teaser b { grid-column: 1; }
  .app-polish .month-end.teaser p { grid-column: 1; margin-bottom: 0; }
  .app-polish .month-end.teaser .btn { grid-column: 2; grid-row: 1 / 3; }
}
/* Telefono e tablet: titolo e una sola riga di comandi (tema, stato del salvataggio, Premium, profilo) */
@media (max-width: 899px) {
  .app-polish .page-head { margin-bottom: 14px; gap: 10px; }
  .app-polish .page-head > .actions { flex-wrap: nowrap; align-items: center; gap: 8px; min-width: 0; }
  .app-polish .page-head .theme-switch { margin-right: 0; }
  .app-polish .page-head .theme-choice { width: 36px; min-height: 36px; padding: 0; }
  .app-polish .page-head .theme-choice span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .app-polish .page-head :is(.sync-slot, .mine-slot) { display: block; flex: 1 1 auto; min-width: 0; }
  .app-polish .page-head .sync-pill { display: block; max-width: max-content; min-height: 0; padding: 7px 10px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
  .app-polish .page-head .sync-pill i { display: inline-block; margin-right: 6px; vertical-align: 0; }
  .app-polish .page-head .profile-wrap { flex: none; flex-direction: row-reverse; align-items: center; gap: 8px; margin-left: auto; }
  .app-polish .page-head .profile-link { padding: 2px; gap: 0; }
  .app-polish .page-head .profile-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .app-polish .page-head .premium-link { min-height: 40px; padding: 0 14px 0 12px; font-size: 12.5px; }
  .app-polish .note.limit-note { padding: 10px 12px; }
  .app-polish .note.limit-note .small { font-size: 12.5px; }
}
@media (max-width: 599px) {
  /* Su telefono Famiglia mostra totale e "chi deve a chi" a tutta larghezza; le voci di Spese mie diventano righe compatte */
  .app-polish .summary-board.kpis { gap: 12px; }
  .app-polish .summary-board.kpis > .kpi-settle, .app-polish .summary-board.kpis > .kpi:first-child:has(+ .kpi-settle) { grid-column: 1 / -1; }
  .app-polish .summary-board.kpis > .kpi.kpi-minor { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; padding: 10px 14px; }
  .app-polish .kpi.kpi-minor .value { grid-column: 2; grid-row: 1 / 3; margin: 0; font-size: 17px; }
  .app-polish .kpi.kpi-minor .label, .app-polish .kpi.kpi-minor .foot { grid-column: 1; }
  /* Il tasto Premium diventa la sola corona: il nome resta per i lettori di schermo */
  .app-polish .page-head .premium-link { width: 40px; padding: 0; font-size: 0; }
  .app-polish .page-head .premium-link .crown { position: static; transform: none; width: 20px; height: 20px; filter: none; }
}
@media (max-width: 360px) {
  .app-polish .page-head > .cal-head { padding-top: 0; }
  .app-polish .page-head:has(.bell-btn) > .cal-head { padding-top: 44px; }
  .app-polish .page-head > .cal-head .icon-btn { width: 36px; height: 36px; min-width: 36px; }
  .app-polish .cal-head h1 { font-size: 21px; }
}
/* Computer: un solo invito "nuova spesa" (quello della colonna laterale) e un solo stato di sincronizzazione */
@media (min-width: 900px) {
  .app-polish .expense-actionbar { display: none !important; }
  .app-polish.expense-lane { --expense-action-h: 0px; --expense-footer-space: env(safe-area-inset-bottom); }
  .app-polish .page-head .sync-slot { display: none; }
}
/* Schermi touch: filtri della ricerca e stato del salvataggio più comodi da toccare */
@media (pointer: coarse) {
  .app-polish .sp-chip { min-height: 36px; }
  .app-polish .sp-key { min-height: 32px; min-width: 40px; }
  .app-polish .page-head .sync-pill { padding-block: 9px; }
}
/* Tema scuro: voce attiva e tasto "nuova spesa" della colonna laterale con l'accento, non in bianco pieno */
:root[data-theme="dark"] .app-polish .sidebar .nav-link.active { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--ink); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
:root[data-theme="dark"] .app-polish .sidebar .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
:root[data-theme="dark"] .app-polish .sidebar .btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app-polish .sidebar .nav-link.active { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--ink); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
  :root:not([data-theme="light"]) .app-polish .sidebar .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  :root:not([data-theme="light"]) .app-polish .sidebar .btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
}
/* Esempio Premium del budget: la corona sta dentro il tasto, non sopra il testo */
.app-polish .bud-teaser .btn .crown { position: static; transform: none; width: 16px; height: 16px; filter: none; }
/* Linea di tendenza (dati veri degli ultimi mesi) come sfondo semitrasparente della scheda principale */
.app-polish .kpis > .kpi:first-child { overflow: hidden; }
/* Aprendo gli anticipi di "Chi deve a chi" la scheda del totale accanto non si allunga con lei */
.app-polish .summary-board.kpis:has(.kpi-more[open]) > .kpi:not(.kpi-settle) { align-self: start; }
.app-polish .kpis > .kpi:first-child .kpi-ctx { min-height: 0; }
.app-polish .kpis > .kpi:first-child .kpi-spark { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; z-index: 0; opacity: .75; pointer-events: none; }
/* Testi sopra il grafico senza livelli negativi (Safari su iPhone può non disegnarli dentro schede con effetti 3D) */
.app-polish .kpis > .kpi:first-child :is(.label, .value, .foot, .kpi-d) { position: relative; z-index: 1; }
.kpi-spark-grid line { stroke: currentColor; stroke-opacity: .09; stroke-width: 1px; }
