/* Luckysplit — stile ispirato a iOS. Tipografia in rem: segue la "Dimensione testo" dell'iPhone
   grazie a font: -apple-system-body sulla radice (17 px al valore standard). */

:root {
  color-scheme: light dark;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --fill: #E3E3E8;
  --ink: #1C1C1E;
  --ink-2: #6C6C70;
  --sep: #D1D1D6;
  --chevron: #8E8E93;
  --accent: #1E7B4F;
  --accent-ink: #FFFFFF;
  --accent-soft: #E8F3ED;
  --warn: #A34A00;
  --danger: #C4291C;
  --nico: #2563EB;
  --anna: #C2410C;
  --chip-soft: #FDF0E8;
  --bar: #48484A;
  --bar-muted: #8E8E93;
  --track: #F2F2F7;
  --tabbar: rgba(249, 249, 249, 0.94);
  --seg-on: #FFFFFF;
  --beam: #1C1C1E;
  --beam-base: #C7C7CC;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  --overlay: rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --fill: #2C2C2E;
    --ink: #FFFFFF;
    --ink-2: #AEAEB2;
    --sep: #38383A;
    --chevron: #8E8E93;
    --accent: #4CC38A;
    --accent-ink: #000000;
    --accent-soft: #12301F;
    --warn: #FF9F0A;
    --danger: #FF6961;
    --nico: #5A93F2;
    --anna: #DE7228;
    --chip-soft: #3A2516;
    --bar: #D1D1D6;
    --bar-muted: #8E8E93;
    --track: #2C2C2E;
    --tabbar: rgba(22, 22, 23, 0.94);
    --seg-on: #636366;
    --beam: #F2F2F7;
    --beam-base: #48484A;
    --shadow: none;
    --overlay: rgba(0, 0, 0, 0.6);
  }
}

@supports (font: -apple-system-body) {
  html { font: -apple-system-body; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; font-size: 17px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 1rem; line-height: 1.3; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.form input:focus-visible, .amount-field input:focus-visible, label input[type="search"]:focus-visible { outline: none; }
.share-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.rounded { font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif; }
.muted { color: var(--ink-2); }
.warn { color: var(--warn); }
svg.i { width: 1.2em; height: 1.2em; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- struttura */
#app { min-height: 100dvh; }
.screen { padding: calc(env(safe-area-inset-top) + 12px) 16px calc(83px + env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 16px; max-width: 640px; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 12px; }
h1.large { margin: 0; font-size: 2rem; line-height: 1.2; font-weight: 700; letter-spacing: 0.01em; }
h2.section { margin: 0; font-size: 1.18rem; font-weight: 700; }
.eyebrow { margin: 0; font-size: 0.765rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.03em; padding: 0 4px; }
.head-row { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; gap: 8px; }

.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 0; display: inline-flex; align-items: center; justify-content: center; position: relative; flex: 0 0 auto; }
.icon-btn.primary { background: var(--accent); color: var(--accent-ink); }
.icon-btn.plain { background: var(--fill); color: var(--ink); }
.icon-btn .badge { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* ---------- controlli */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill); }
.seg button { min-height: 32px; border: 0; border-radius: 7px; background: transparent; font-size: 0.88rem; }
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: var(--seg-on); box-shadow: var(--shadow); font-weight: 600; }

.btn { min-height: 44px; border: 0; border-radius: 12px; padding: 0 16px; font-size: 1rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.link-btn { min-height: 44px; border: 0; background: transparent; color: var(--accent); font-size: 0.88rem; padding: 0 4px; }

.chip { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--sep); background: var(--card); display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; flex: 0 0 auto; }
.chip[aria-checked="true"] { border: 2px solid var(--accent); }
.chip.dark { background: var(--ink); color: var(--bg); border-color: var(--ink); }
/* chip con menu nativo: il <select> trasparente copre tutto il chip (16px: niente zoom su iPhone) */
.chip-select { position: relative; cursor: pointer; }
.chip-select select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; -webkit-appearance: none; appearance: none; }
.chip-select:has(select:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }

.avatar { width: 28px; height: 28px; border-radius: 14px; color: #FFFFFF; font-size: 0.765rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
@media (prefers-color-scheme: dark) { .avatar { color: #000000; } }
.dot { width: 10px; height: 10px; border-radius: 5px; flex: 0 0 auto; display: inline-block; }
.cat-ico { width: 34px; height: 34px; border-radius: 17px; color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.cat-ico svg.i { width: 18px; height: 18px; }
.cat-ico.empty { background: transparent; border: 1.5px dashed var(--chevron); }
.cat-ico.neutral { background: var(--fill); color: var(--ink); }

/* ---------- liste e card */
.card { background: var(--card); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.group { list-style: none; margin: 0; padding: 0 0 0 16px; background: var(--card); border-radius: 12px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px 8px 0; border-bottom: 0.5px solid var(--sep); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; color: var(--ink); }
.group > li:last-child > .row, .group > .row:last-child { border-bottom: 0; }
.row .grow { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.row .title { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 0.765rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .amt.in { color: var(--accent); }
.row .chev { color: var(--chevron); }
.pill-count { min-width: 24px; height: 24px; padding: 0 8px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 0.88rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.empty-state { text-align: center; padding: 32px 16px; color: var(--ink-2); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- Home: bilancia */
.balance { align-items: center; text-align: center; gap: 14px; }
.balance .meta { align-self: stretch; display: flex; justify-content: space-between; align-items: baseline; }
.beam-wrap { width: 300px; max-width: 100%; height: 92px; position: relative; }
.beam { position: absolute; left: 20px; right: 20px; top: 34px; display: flex; align-items: center; transform-origin: 50% 50%; transition: transform 0.6s cubic-bezier(.3,1.4,.5,1); }
.beam .bar { flex: 1 1 auto; height: 6px; border-radius: 3px; background: var(--beam); }
.beam .avatar { width: 44px; height: 44px; border-radius: 22px; font-size: 1rem; }
.beam .avatar span { display: inline-block; transition: transform 0.6s cubic-bezier(.3,1.4,.5,1); }
.fulcrum { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); width: 0; height: 0; border-left: 12px solid transparent; border-right: 12px solid transparent; border-bottom: 22px solid var(--beam); }
.base { position: absolute; left: 50%; top: 82px; transform: translateX(-50%); width: 80px; height: 4px; border-radius: 2px; background: var(--beam-base); }
@media (prefers-reduced-motion: reduce) { .beam, .beam .avatar span { transition: none; } }
.big-amount { font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif; font-size: 2.6rem; line-height: 1.15; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.hint-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--chip-soft); font-size: 0.88rem; }

/* ---------- barre e grafici */
.track { height: 8px; border-radius: 4px; background: var(--track); display: flex; overflow: hidden; }
.track > span { height: 8px; border-radius: 4px; background: var(--bar); display: block; }
.split-bar { height: 10px; display: flex; gap: 2px; }
.split-bar > span { height: 10px; display: block; }
.split-bar > span:first-child { border-radius: 4px 0 0 4px; }
.split-bar > span:last-child { border-radius: 0 4px 4px 0; }
.split-bar > span:only-child { border-radius: 4px; }
.cat-line { display: flex; flex-direction: column; gap: 6px; padding: 10px 16px; color: var(--ink); width: 100%; background: none; border: 0; text-align: left; }
.cat-line .top { display: flex; align-items: center; gap: 8px; }
.cat-line .name { flex: 1 1 auto; font-size: 0.88rem; }
.cat-line .val { min-width: 84px; text-align: right; font-size: 0.88rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; font-size: 0.765rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.donut { position: relative; width: 200px; height: 200px; align-self: center; }
.donut .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut path { stroke: var(--card); stroke-width: 2; }
.months { position: relative; height: 150px; }
.months .avg { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--bar-muted); }
.months .cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: var(--gap, 8px); align-items: end; touch-action: pan-y; }
.months .cols button { height: 150px; border: 0; background: transparent; padding: 0; display: flex; align-items: flex-end; justify-content: center; gap: 2px; min-width: 0; }
.months .cols button span { display: block; border-radius: 4px 4px 0 0; }
.months .cols .b-cur { width: min(30px, 70%); background: var(--bar-muted); }
.months .cols.yoy .b-cur, .months .cols.yoy .b-prev { width: min(14px, 42%); }
.months .cols .b-prev { border: 1.5px solid var(--bar-muted); border-bottom: 0; background: transparent; }
.months .cols .b-prev.zero { visibility: hidden; }
.months .cols.dense .b-cur { width: 72%; border-radius: 2px 2px 0 0; }
.months .cols button[aria-checked="true"] .b-cur { background: var(--ink); }
.months .cols button[aria-checked="true"] .b-prev { border-color: var(--ink); }
.month-labels { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: var(--gap, 8px); border-top: 1px solid var(--sep); padding-top: 6px; text-align: center; font-size: 0.765rem; color: var(--ink-2); }
.month-labels.dense span { text-align: left; white-space: nowrap; overflow: visible; }
.month-labels .on { color: var(--ink); font-weight: 600; }

/* ---------- tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 6px 8px env(safe-area-inset-bottom); min-height: calc(83px - 34px + env(safe-area-inset-bottom)); background: var(--tabbar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: 0.5px solid var(--sep); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (prefers-reduced-transparency: reduce) { .tabbar { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; } }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 49px; color: var(--ink-2); font-size: 10px; font-weight: 500; }
.tabbar a svg.i { width: 26px; height: 26px; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ---------- sheet */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.2s ease; }
.sheet { width: 100%; max-width: 640px; height: calc(100dvh - env(safe-area-inset-top) - 10px); background: var(--bg); border-radius: 12px 12px 0 0; display: flex; flex-direction: column; animation: up 0.28s cubic-bezier(.2,.9,.3,1); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .overlay, .sheet { animation: none; } }
.grabber { align-self: center; width: 36px; height: 5px; border-radius: 3px; background: var(--chevron); opacity: 0.5; margin-top: 6px; }
.sheet-bar { display: grid; grid-template-columns: minmax(96px, auto) minmax(0, 1fr) minmax(96px, auto); align-items: center; min-height: 52px; padding: 0 8px; }
.sheet-bar h1 { margin: 0; text-align: center; font-size: 1rem; font-weight: 600; }
.sheet-bar .left { justify-self: start; }
.sheet-bar .right { justify-self: end; }
.sheet-bar .pill { min-height: 36px; padding: 0 16px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.sheet-bar .pill[disabled] { opacity: 0.45; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 16px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 20px; -webkit-overflow-scrolling: touch; }

/* ---------- moduli */
.amount-field { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 8px; }
.amount-field .line { display: flex; align-items: baseline; gap: 8px; justify-content: center; }
.amount-field input { width: 210px; border: 0; background: transparent; text-align: right; font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif; font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; padding: 0; }
.amount-field select { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 0; background: var(--fill); font-weight: 600; -webkit-appearance: none; appearance: none; text-align: center; }
.form { background: var(--card); border-radius: 12px; padding-left: 16px; display: flex; flex-direction: column; }
.form label, .form .frow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding-right: 16px; border-bottom: 0.5px solid var(--sep); }
.form > :last-child { border-bottom: 0; }
.form input, .form select { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; text-align: right; font-size: 1rem; }
.form input[type="date"] { flex: 0 0 auto; }
.share-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding-right: 16px; border-bottom: 0.5px solid var(--sep); }
.share-row:last-child { border-bottom: 0; }
.form .share-row label, .share-row label { flex: 1 1 auto; display: block; min-height: 0; padding: 0; border: 0; }
.share-row input { width: 100px; min-height: 36px; border: 1px solid var(--sep); border-radius: 8px; padding: 0 10px; text-align: right; font-variant-numeric: tabular-nums; background: var(--card); }
.share-row input:disabled { opacity: 0.4; }
.check { width: 28px; height: 28px; border-radius: 14px; border: 2px solid var(--beam-base); background: transparent; color: var(--accent-ink); padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.check[aria-checked="true"] { border: 0; background: var(--accent); }
.check[aria-checked="false"] svg { visibility: hidden; }
.check.square { border-radius: 6px; }
.switch { width: 51px; height: 31px; border-radius: 16px; border: 0; padding: 2px; background: var(--beam-base); display: flex; justify-content: flex-start; flex: 0 0 auto; }
.switch[aria-checked="true"] { background: var(--accent); justify-content: flex-end; }
.switch span { width: 27px; height: 27px; border-radius: 14px; background: #FFFFFF; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.status-line { margin: -12px 4px 0; font-size: 0.765rem; }
.error-box { background: var(--chip-soft); color: var(--ink); border-radius: 12px; padding: 12px 14px; font-size: 0.88rem; }

/* ---------- login */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); gap: 20px; max-width: 420px; margin: 0 auto; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.brand .mark { width: 72px; height: 72px; border-radius: 16px; display: block; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* ---------- toast */
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 0.88rem; max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center; }
.toast button { border: 0; background: none; color: #4CC38A; font-weight: 600; min-height: 32px; }
@media (prefers-color-scheme: dark) { .toast button { color: #1E7B4F; } }

/* ---------- importazione */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 168px; padding: 24px 16px; border: 2px dashed var(--sep); border-radius: 16px; background: var(--card); text-align: center; cursor: pointer; }
.drop > svg.i { width: 32px; height: 32px; color: var(--accent); }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
.facts div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.facts dt { font-size: 0.765rem; color: var(--ink-2); }
.facts dd { margin: 0; font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.map-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 0; border-bottom: 0.5px solid var(--sep); }
.group > .map-row:last-child { border-bottom: 0; }
.map-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.map-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.map-top .title { font-size: 1rem; min-width: 0; overflow-wrap: anywhere; }
.map-n { font-size: 0.765rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.map-sel select { width: 100%; min-height: 36px; border: 1px solid var(--sep); border-radius: 8px; padding: 0 8px; background: var(--card); color: var(--accent); font-size: 0.88rem; }
.map-row.off .map-top .title { color: var(--ink-2); text-decoration: line-through; }
.map-row.off .map-sel select { color: var(--ink-2); }
.done-mark { width: 56px; height: 56px; border-radius: 28px; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; }
.done-mark svg.i { width: 30px; height: 30px; }
svg.i.inline { width: 1em; height: 1em; vertical-align: -0.125em; }
.balance-check { gap: 8px; }
.bal-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 0.88rem; }
.bal-row > span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.bal-row.strong { font-size: 1rem; font-weight: 600; }

/* ---------- Home: mese, commento, debito nel tempo */
.month-nav { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; margin: -4px -4px 0; }
.month-title { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.month-name { font-size: 1rem; font-weight: 600; }
.icon-btn[disabled] { opacity: 0.35; cursor: default; }
.mood { margin: 0; max-width: 34ch; text-align: center; font-size: 0.88rem; line-height: 1.35; color: var(--ink-2); font-style: italic; text-wrap: balance; }
.mood[data-fascia="tirchio"], .mood[data-fascia="rosica"] { color: var(--ink); }
.debt { gap: 8px; }
.debt-chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.debt-chart .ch-band { fill: var(--fill); }
.debt-chart .ch-zero { stroke: var(--ink-2); stroke-width: 1; }
.debt-chart .ch-month { fill: var(--ink-2); font-size: 11px; }
.debt-chart .ch-month.on { fill: var(--ink); font-weight: 600; }
.debt-chart .ch-val { fill: var(--ink); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.debt-chart .ch-hit { fill: transparent; cursor: pointer; outline: none; }
.debt-chart .ch-hit.sel, .debt-chart .ch-hit:focus-visible { fill: var(--ink); fill-opacity: 0.06; }
.ch-say { margin: 0; min-height: 1.3em; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.765rem; color: var(--ink-2); }
.ch-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.month-card { touch-action: pan-y; }
.month-body { display: flex; flex-direction: column; gap: 12px; transition: opacity 0.15s ease 0.12s; }
.month-body.loading { opacity: 0.45; }
.month-body.from-left { animation: month-in-left 0.22s cubic-bezier(.2,.9,.3,1); }
.month-body.from-right { animation: month-in-right 0.22s cubic-bezier(.2,.9,.3,1); }
@keyframes month-in-left { from { opacity: 0.3; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes month-in-right { from { opacity: 0.3; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .month-body { transition: none; }
  .month-body.from-left, .month-body.from-right { animation: month-fade 0.12s linear; }
  @keyframes month-fade { from { opacity: 0.6; } to { opacity: 1; } }
}
/* Mese/Anno e grafico dell'anno */
.scope-seg { margin: -4px 0 4px; }
.scope-seg button { min-height: 30px; font-size: 0.82rem; }
.month-body.fade-in { animation: month-fade-in 0.18s ease-out; }
@keyframes month-fade-in { from { opacity: 0.4; } to { opacity: 1; } }
.year-bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); height: 112px; margin: 0 -4px; }
.yb { display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; border-radius: 6px; cursor: pointer; }
.yb:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.yb:active .yb-bar { opacity: 0.7; }
.yb-plot { height: 94px; display: grid; grid-template-rows: var(--rows, 100% 0%); }
.yb-up, .yb-down { position: relative; min-height: 0; }
.yb-up { border-bottom: 1px solid var(--sep); }
.yb-bar { position: absolute; left: 50%; transform: translateX(-50%); width: min(16px, 60%); }
.yb-up .yb-bar { bottom: 0; }
.yb-down .yb-bar { top: 0; }
.yb-up .yb-bar { border-radius: 3px 3px 0 0; }
.yb-down .yb-bar { border-radius: 0 0 3px 3px; }
.yb-lab { font-size: 11px; line-height: 14px; text-align: center; color: var(--ink-2); }
.yb.on .yb-lab { color: var(--ink); font-weight: 600; }
.yb.future .yb-lab { opacity: 0.45; }
.yb.future { cursor: default; }
.yb-note { margin: -4px 0 0; font-size: 0.765rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.yb-note > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.yb-note > span:last-child:not(:first-child) { margin-left: auto; }
@media (prefers-reduced-motion: reduce) { .month-body.fade-in { animation: none; } }
.flow { display: flex; flex-direction: column; gap: 8px; }
.flow-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 0.88rem; }
.flow-row > .num { text-align: right; min-width: 7.5em; font-weight: 600; }
.flow-track { height: 10px; display: flex; gap: 2px; }
.flow-track > span { height: 10px; display: block; border-radius: 0; }
.flow-track > span:first-child { border-radius: 4px 0 0 4px; }
.flow-track > span:last-child { border-radius: 0 4px 4px 0; }
.flow-track > span:only-child { border-radius: 4px; }

/* ---------- passaggi tra schermate */
#main { transition: opacity 0.12s ease 0.08s; }
#main.busy { opacity: 0.5; pointer-events: none; }
#main.swap { animation: screen-in 0.18s ease-out; }
@keyframes screen-in { from { opacity: 0.4; } to { opacity: 1; } }
.skeleton { display: flex; flex-direction: column; gap: 16px; padding-top: 64px; }
.skeleton span { display: block; height: 120px; border-radius: 16px; background: var(--card); }
.skeleton span:first-child { height: 44px; border-radius: 9px; background: var(--fill); }
@media (prefers-reduced-motion: reduce) { #main { transition: none; } #main.swap { animation: none; } }
.screen > .month-body { gap: 16px; touch-action: pan-y; }
.month-head { padding: 12px 16px; touch-action: pan-y; }

/* stato dei dati sopra la tab bar: passivo, non copre il contenuto più del necessario */
.sync { position: fixed; left: 16px; right: 16px; margin: 0 auto; width: fit-content; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; background: var(--card); color: var(--ink-2); border: 1px solid var(--sep); box-shadow: var(--shadow); font-size: 0.88rem; }
.sync span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sync[hidden] { display: none; }
.sync.stale { padding-right: 4px; }
.sync button { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; min-height: 44px; min-width: 44px; padding: 0 12px; }
/* il titolo riceve il focus solo per VoiceOver: niente contorno visibile */
h1[tabindex="-1"]:focus { outline: none; }

/* righe categoria nei Filtri: tutta la riga è il controllo (48 pt), il quadratino è solo il segno */
.row.cat-pick { min-height: 48px; font: inherit; }

/* ---------- Report 0.15 */
:root { --pos: #1E7B4F; --neg: #A34A00; --heat-ink-3: var(--ink); }
@media (prefers-color-scheme: dark) { :root { --pos: #38A872; --neg: #CF730A; --heat-ink-3: var(--accent-ink); } }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend .sw.cur { background: var(--bar-muted); }
.legend .sw.prev { border: 1.5px solid var(--bar-muted); }
.legend .sw.avg { width: 18px; height: 0; border-radius: 0; border-top: 1.5px dashed var(--bar-muted); }
.legend .sw.pos { background: var(--pos); }
.legend .sw.neg { background: var(--neg); }
.legend { flex-wrap: wrap; row-gap: 6px; }
/* variazione rispetto al periodo precedente: freccia + numero, colore neutro (salire non è per forza un male) */
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 0.765rem; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta .i { width: 0.95em; height: 0.95em; }
/* calendario: una tinta, dal chiaro allo scuro; il numero del giorno resta leggibile su ogni gradino */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .wd { text-align: center; font-size: 0.765rem; color: var(--ink-2); }
.cal .day { min-height: 44px; border: 0; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0; font-size: 0.88rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.day.h0 { background: var(--track); }
.day.h1 { background: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.day.h2 { background: color-mix(in srgb, var(--accent) 45%, var(--card)); }
.day.h3 { background: color-mix(in srgb, var(--accent) 70%, var(--card)); color: var(--heat-ink-3); }
.day.h4 { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cal .day.future { background: transparent; color: var(--ink-2); }
.cal .day[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
.cal-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 0.765rem; color: var(--ink-2); }
.cal-legend .day { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
/* entrate e uscite: sopra la linea messo da parte, sotto speso più delle entrate */
.net { position: relative; height: 110px; display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: var(--gap, 8px); }
.net::before { content: ""; position: absolute; left: 0; right: 0; top: var(--zero, 50%); border-top: 1px solid var(--bar-muted); z-index: 1; }
.net .col { position: relative; min-width: 0; }
.net .col span { position: absolute; left: 50%; transform: translateX(-50%); width: min(30px, 72%); }
.net .pos { bottom: calc(100% - var(--zero, 50%)); background: var(--pos); border-radius: 4px 4px 0 0; }
.net .neg { top: var(--zero, 50%); background: var(--neg); border-radius: 0 0 4px 4px; }
/* coppie etichetta–valore su righe: reggono cifre lunghe e testo grande */
.kv { margin: 0; display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 0.5px solid var(--sep); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--ink-2); font-size: 0.88rem; }
.kv dd { margin: 0; font-weight: 600; white-space: nowrap; }
.kv .sum dt { color: var(--ink); font-weight: 600; }
/* righe categoria/esercente: con testo grande l'importo va a capo invece di uscire dallo schermo */
.cat-line .top { flex-wrap: wrap; row-gap: 2px; }
.cat-line .name { min-width: 0; overflow-wrap: anywhere; }
.cat-line .val { margin-left: auto; }
/* ---------- valuta estera: cambio BCE e commissione */
.form.fx .frow.note { min-height: 36px; font-size: 0.88rem; }
.form.fx .frow.note .muted { flex: 1 1 auto; }
.form.fx .status-line { margin: 0; padding: 8px 16px 8px 0; font-size: 0.88rem; }
.fee-unit { flex: 0 0 auto; grid-auto-columns: 44px; }
.fee-unit button { min-height: 32px; font-weight: 600; }
.form.fx label > span:first-child { flex: 0 0 auto; white-space: nowrap; }

/* filtri: categorie con sottocategorie apribili; "in parte" = trattino, come le liste di iOS */
.cat-node { display: flex; align-items: stretch; }
.cat-node .row { flex: 1 1 auto; min-width: 0; }
.cat-node .sub-count { font-size: 0.765rem; white-space: nowrap; }
.disclose { flex: 0 0 48px; min-height: 48px; border: 0; border-bottom: 0.5px solid var(--sep); background: transparent; color: var(--ink-2); display: flex; align-items: center; justify-content: center; padding: 0; }
.disclose .i { transition: transform 0.2s ease; }
.disclose[aria-expanded="true"] .i { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .disclose .i { transition: none; } }
.group > li:last-child .cat-node > .disclose { border-bottom: 0; }
.kids { list-style: none; margin: 0; padding: 0 0 0 40px; }
.kids .row.kid { min-height: 44px; font-size: 0.94rem; }
.check[aria-checked="mixed"] { border: 0; background: var(--accent); position: relative; }
.check[aria-checked="mixed"] svg { visibility: hidden; }
.check[aria-checked="mixed"]::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 2.5px; margin: -1.25px 0 0 -6px; border-radius: 2px; background: var(--accent-ink); }

/* ---------- 0.20: con amici, da incassare, verifica */
.friend-row .friend-name { text-align: left; flex: 1 1 auto; min-width: 0; min-height: 44px; border: 0; background: transparent; font-size: 1rem; color: var(--ink); padding: 0; }
.friend-row .friend-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper .icon-btn { width: 44px; height: 36px; border-radius: 18px; }
.recv .row { border-bottom: 0.5px solid var(--sep); }
.group > li.recv:last-child .row, .group > li.recv:last-child .recv-actions { border-bottom: 0; }
.recv-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 16px 12px 0; border-bottom: 0.5px solid var(--sep); }
.recv-actions .btn { min-height: 44px; flex: 1 1 0; padding: 0 12px; white-space: nowrap; }
.recv-actions .link-btn { flex: 1 0 100%; }
.verify-card { border-bottom: 0.5px solid var(--sep); padding-bottom: 8px; }
.group > li.verify-card:last-child { border-bottom: 0; }
.verify-bank { display: flex; align-items: center; gap: 8px; padding-right: 16px; min-height: 44px; }
.verify-bank > span:first-child { flex: 1 1 auto; font-size: 0.88rem; color: var(--ink-2); }
.verify-bank input { width: 120px; min-height: 36px; border: 1px solid var(--sep); border-radius: 8px; padding: 0 10px; text-align: right; font-variant-numeric: tabular-nums; background: var(--card); color: var(--ink); font-size: 1rem; }
.verify-bank input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.verify-diff { margin: 0; padding-right: 16px; font-size: 0.765rem; }
.ok-text { color: var(--accent); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
select.adopt { min-height: 36px; max-width: 46%; padding: 0 28px 0 12px; border-radius: 18px; border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 0.88rem;
  -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select.adopt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 0.24 — tag, trasferimenti, rimborsabili */
.switch:disabled { opacity: 0.4; }
.check.on { border: 0; background: var(--accent); }
.check.mixed { border: 0; background: var(--accent); }
.check.off svg { visibility: hidden; }
.tag-ico { background: var(--accent-soft); color: var(--accent); }
.tag-chip { padding-left: 10px; padding-right: 8px; }
.tag-chip svg.i { width: 16px; height: 16px; color: var(--accent); }
.tag-chip svg.i.x { color: var(--ink-2); width: 14px; height: 14px; }
.row .amt.xfer { color: var(--ink-2); }
.row .sub .tagname { color: var(--accent); }
.row .sub .note { color: var(--ink); }
.tag-line { display: flex; flex-direction: column; gap: 6px; width: 100%; min-height: 56px; padding: 10px 16px; border: 0; background: none; text-align: left; color: var(--ink); border-bottom: 0.5px solid var(--sep); font: inherit; }
.tag-line:last-child { border-bottom: 0; }
.tag-line .top { display: flex; align-items: center; gap: 10px; }
.tag-line .name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.tag-line .name b { font-weight: 400; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-line .name small { font-size: 0.765rem; color: var(--ink-2); }
.tag-line .val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag-line .chev { color: var(--chevron); }

/* 0.25 — categorie e Rivedi categorie */
.drag-row .row { padding-right: 4px; }
.drag { width: 44px; height: 44px; border: 0; background: none; color: var(--chevron); display: inline-flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; flex: 0 0 auto; }
.dragging { position: relative; z-index: 2; background: var(--card); box-shadow: 0 6px 18px rgba(0,0,0,0.18); border-radius: 12px; }
.swatches { flex-direction: row; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
.swatch { width: 40px; height: 40px; border-radius: 20px; border: 0; color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; }
.swatch[aria-checked="true"] { outline: 3px solid var(--ink); outline-offset: 2px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-pick { width: 44px; height: 44px; border-radius: 10px; border: 0; background: var(--fill); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; }
.icon-pick[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.map-line { display: flex; flex-direction: column; min-width: 0; }
.map-line .to { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-line .from { font-size: 0.765rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-soft { font-size: 0.7rem; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.steps { display: flex; gap: 6px; justify-content: center; }
.steps span { width: 8px; height: 8px; border-radius: 4px; background: var(--beam-base); }
.steps span.on { background: var(--accent); width: 20px; }
.badge-soft { display: inline-flex; align-items: center; gap: 3px; } .badge-soft svg.i.mini { width: 12px; height: 12px; }
.cat-ico.big svg.i { width: 30px; height: 30px; }

/* 0.26 — Movimenti › Seleziona */
.sel-row .check { margin-right: -4px; }
.sel-row[disabled] { opacity: 0.45; }
.select-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; padding: 6px 8px env(safe-area-inset-bottom); min-height: calc(83px - 34px + env(safe-area-inset-bottom));
  background: var(--tabbar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: 0.5px solid var(--sep);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (prefers-reduced-transparency: reduce) { .select-bar { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; } }
.select-bar button { border: 0; background: none; color: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 49px; font-size: 11px; font-weight: 500; }
.select-bar button svg.i { width: 24px; height: 24px; }
.select-bar button.danger { color: var(--danger); }
.select-bar button:disabled { color: var(--ink-2); opacity: 0.5; }
body:has(.select-bar) .tabbar { visibility: hidden; }
