/* unpomeunpote — stile iOS */
:root {
  --tint: #30b350; --tint-press: #27994a;
  --red: #ff3b30; --orange: #ff9500; --green: #30b350; --blue: #007aff;
  --bg: #f2f2f7; --cell: #ffffff; --cell-press: #e5e5ea;
  --label: #000000; --label2: rgba(60,60,67,.6); --label3: rgba(60,60,67,.3);
  --sep: rgba(60,60,67,.29); --fill: rgba(118,118,128,.12); --fill2: rgba(118,118,128,.2);
  --bar: rgba(249,249,249,.82); --bar-border: rgba(0,0,0,.18);
  --shadow: 0 8px 30px rgba(0,0,0,.12);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --w: 600px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --tint: #32d74b; --tint-press: #28b33e; --red: #ff453a; --orange: #ff9f0a; --green: #32d74b; --blue: #0a84ff;
    --bg: #000000; --cell: #1c1c1e; --cell-press: #2c2c2e;
    --label: #ffffff; --label2: rgba(235,235,245,.6); --label3: rgba(235,235,245,.3);
    --sep: rgba(84,84,88,.6); --fill: rgba(118,118,128,.24); --fill2: rgba(118,118,128,.32);
    --bar: rgba(22,22,24,.8); --bar-border: rgba(255,255,255,.12);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--label); font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif; letter-spacing: -.01em; }
body { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior-y: none; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }
a { color: var(--tint); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
svg { display: block; }
.loading { padding-top: 45vh; text-align: center; color: var(--label2); }
.spinner { width: 28px; height: 28px; margin: 40vh auto 0; border: 3px solid var(--fill2); border-top-color: var(--label2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- struttura */
.screen { max-width: var(--w); margin: 0 auto; min-height: 100vh; padding-bottom: calc(110px + var(--safe-b)); }
.screen.modal { padding-bottom: calc(40px + var(--safe-b)); }
.anim-push { animation: push .32s cubic-bezier(.2,.8,.2,1); }
.anim-pop { animation: pop .32s cubic-bezier(.2,.8,.2,1); }
.anim-modal { animation: modalin .38s cubic-bezier(.2,.9,.2,1); }
.anim-fade { animation: fade .2s ease; }
@keyframes push { from { transform: translateX(30%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: translateX(-20%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes modalin { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.nav { position: sticky; top: 0; z-index: 20; height: calc(44px + var(--safe-t)); padding: var(--safe-t) 8px 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: transparent; border-bottom: .5px solid transparent;
  transition: background .2s, border-color .2s; }
.nav.solid, .modal .nav { background: var(--bar); border-bottom-color: var(--bar-border); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.nav-title { font-weight: 600; font-size: 17px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw; opacity: 0; transition: opacity .2s; }
.nav.solid .nav-title, .nav.always .nav-title, .modal .nav-title { opacity: 1; }
.nav-left { justify-self: start; display: flex; } .nav-right { justify-self: end; display: flex; gap: 2px; }
.nav-btn { background: none; border: 0; color: var(--tint); font-size: 17px; padding: 8px; display: flex; align-items: center; gap: 2px; min-height: 44px; }
.nav-btn:active { opacity: .4; }
.nav-btn.bold { font-weight: 600; }
.nav-btn:disabled { color: var(--label3); }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: .01em; margin: 2px 20px 8px; line-height: 1.15; word-break: break-word; }
.subtitle { margin: -4px 20px 12px; color: var(--label2); font-size: 15px; }

/* ---------- liste raggruppate iOS */
.group-title { font-size: 13px; text-transform: uppercase; color: var(--label2); margin: 22px 32px 7px; letter-spacing: .02em; }
.group-foot { font-size: 13px; color: var(--label2); margin: 7px 32px 0; line-height: 1.35; }
.list { background: var(--cell); border-radius: 12px; margin: 0 16px; overflow: hidden; }
.list + .list { margin-top: 20px; }
.row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 16px; background: var(--cell); }
.row::after { content: ""; position: absolute; left: var(--inset, 16px); right: 0; bottom: 0; height: .5px; background: var(--sep); }
.row:last-child::after { display: none; }
.row.tap:active, .row[data-go]:active { background: var(--cell-press); }
.row.has-avatar { --inset: 68px; min-height: 60px; }
.row.has-icon { --inset: 60px; }
.row .main { flex: 1; min-width: 0; }
.row .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 14px; color: var(--label2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row .val { color: var(--label2); text-align: right; white-space: nowrap; }
.row .amt { text-align: right; font-size: 13px; white-space: nowrap; line-height: 1.2; }
.row .amt b { display: block; font-size: 16px; font-weight: 600; }
.chev { color: var(--label3); flex: 0 0 auto; margin-right: -4px; }
.row.center { justify-content: center; color: var(--tint); }
.row.destructive { justify-content: center; color: var(--red); }
.row input, .row select, .row textarea { border: 0; background: transparent; outline: none; padding: 0; min-width: 0; font-size: 17px; }
.row input { flex: 1; text-align: right; }
.row input.left { text-align: left; }
.row select { -webkit-appearance: none; appearance: none; text-align: right; text-align-last: right; color: var(--label2); flex: 1; }
.row textarea { width: 100%; resize: none; min-height: 70px; padding: 4px 0; }
.row label { flex: 0 0 auto; }
.row .lbl { flex: 0 0 auto; }
.ico { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: 0 0 30px; }
.ico svg { width: 18px; height: 18px; }
.date-box { width: 34px; text-align: center; font-size: 11px; color: var(--label2); line-height: 1.05; flex: 0 0 34px; text-transform: uppercase; }
.date-box b { display: block; font-size: 19px; color: var(--label); font-weight: 600; }
.cat { width: 40px; height: 40px; border-radius: 10px; background: var(--fill); display: grid; place-items: center; font-size: 22px; flex: 0 0 40px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; background: var(--fill); color: var(--label2); vertical-align: 2px; margin-left: 4px; }
.badge.tint { background: color-mix(in srgb, var(--tint) 18%, transparent); color: var(--tint); }
.badge.red { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.badge.orange { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.owe { color: var(--orange); } .owed { color: var(--green); } .muted { color: var(--label2); }
.deleted .t { text-decoration: line-through; color: var(--label2); }
.empty { text-align: center; color: var(--label2); padding: 40px 32px; font-size: 15px; }
.empty .big { font-size: 54px; margin-bottom: 10px; }

/* ---------- avatar */
.av { border-radius: 50%; flex: 0 0 auto; object-fit: cover; display: grid; place-items: center; color: #fff; font-weight: 600; background: #8e8e93; overflow: hidden; }
.av.ph { background: var(--fill2) !important; color: var(--label2); border: 1.5px dashed var(--label3); }

/* ---------- card riepilogo */
.summary-card { margin: 4px 16px 0; background: var(--cell); border-radius: 16px; padding: 16px; }
.summary-card .big { font-size: 22px; font-weight: 700; }
.summary-card .line { font-size: 15px; margin-top: 4px; }
.pills { display: flex; gap: 8px; overflow-x: auto; padding: 14px 16px 2px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; border: 0; background: var(--cell); color: var(--tint); font-weight: 600; font-size: 15px; padding: 9px 14px; border-radius: 20px; }
.pill svg { width: 17px; height: 17px; }
.pill.primary { background: var(--tint); color: #fff; }
.pill:active { opacity: .6; }
.search { margin: 6px 16px 0; display: flex; align-items: center; gap: 6px; background: var(--fill); border-radius: 10px; padding: 0 8px; height: 36px; color: var(--label2); }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 17px; color: var(--label); }

/* ---------- pulsanti */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: calc(100% - 32px); margin: 16px; height: 50px; border: 0; border-radius: 12px;
  background: var(--tint); color: #fff; font-size: 17px; font-weight: 600; }
.btn:active { background: var(--tint-press); }
.btn:disabled { opacity: .5; }
.btn.plain { background: var(--cell); color: var(--tint); }
.btn.plain:active { background: var(--cell-press); }
.btn.gray { background: var(--fill); color: var(--tint); }
.btn.full { width: 100%; margin: 12px 0 0; }
.btn svg { width: 20px; height: 20px; }
.link-btn { background: none; border: 0; color: var(--tint); font-size: 15px; padding: 10px; }
.mini { border: 0; background: var(--fill); color: var(--tint); font-weight: 600; font-size: 14px; padding: 6px 12px; border-radius: 15px; flex: 0 0 auto; }
.mini.on { background: var(--tint); color: #fff; }
.mini:active { opacity: .6; }

/* ---------- segmented control */
.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin: 0 16px; position: relative; }
.seg button { flex: 1; border: 0; background: transparent; font-size: 13px; font-weight: 500; padding: 6px 2px; border-radius: 7px; white-space: nowrap; }
.seg button.on { background: var(--cell); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button.on { background: #636366; } }

/* ---------- switch iOS */
.switch { position: relative; width: 51px; height: 31px; flex: 0 0 51px; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; z-index: 1; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--fill2); border-radius: 16px; transition: background .25s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .25s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- checkmark */
.check { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--label3); display: grid; place-items: center; flex: 0 0 24px; color: #fff; }
.check.on { background: var(--tint); border-color: var(--tint); }
.check svg { width: 14px; height: 14px; opacity: 0; }
.check.on svg { opacity: 1; }

/* ---------- tab bar */
.tabbar { position: fixed; z-index: 30; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--w);
  display: flex; padding: 6px 0 calc(var(--safe-b) + 4px); background: var(--bar); border-top: .5px solid var(--bar-border);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 500; color: #999; }
.tabbar a svg { width: 26px; height: 26px; }
.tabbar a.on { color: var(--tint); }
.fab { position: fixed; z-index: 31; bottom: calc(66px + var(--safe-b)); right: max(16px, calc(50vw - var(--w) / 2 + 16px));
  display: flex; align-items: center; gap: 6px; border: 0; background: var(--tint); color: #fff; font-weight: 600; font-size: 16px;
  padding: 13px 18px; border-radius: 26px; box-shadow: 0 6px 20px color-mix(in srgb, var(--tint) 45%, transparent); }
.fab svg { width: 20px; height: 20px; }
.fab:active { transform: scale(.96); }

/* ---------- autenticazione */
.auth { max-width: 420px; margin: 0 auto; padding: calc(56px + var(--safe-t)) 0 40px; }
.auth .logo { width: 92px; height: 92px; border-radius: 22px; display: block; margin: 0 auto 14px; box-shadow: var(--shadow); }
.auth h1 { text-align: center; margin: 0; font-size: 30px; font-weight: 700; }
.auth p.sub { text-align: center; color: var(--label2); margin: 6px 24px 26px; font-size: 15px; }
.auth .links { text-align: center; display: grid; gap: 4px; margin-top: 8px; }
.error { color: var(--red); font-size: 14px; margin: 10px 32px 0; min-height: 0; }
.error:empty { display: none; }
.devbox { margin: 16px; background: color-mix(in srgb, var(--orange) 14%, var(--cell)); border-radius: 12px; padding: 12px 14px; font-size: 14px; word-break: break-all; }
.note { margin: 0 16px; background: var(--cell); border-radius: 12px; padding: 14px 16px; font-size: 15px; line-height: 1.4; }

/* ---------- form spesa */
.amount-hero { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.amount-hero .cat { width: 52px; height: 52px; flex-basis: 52px; font-size: 28px; border-radius: 12px; border: 0; }
.amount-hero input.desc { font-size: 20px; font-weight: 500; text-align: left; }
.amount-hero input.amount { font-size: 34px; font-weight: 700; text-align: left; letter-spacing: -.02em; }
.cur-btn { border: 0; background: var(--fill); border-radius: 10px; padding: 0 10px; height: 52px; min-width: 52px; font-weight: 600; font-size: 15px; color: var(--label); text-align: center; text-align-last: center; -webkit-appearance: none; appearance: none; }
.split-input { width: 92px !important; flex: 0 0 92px !important; text-align: right; background: var(--fill) !important; border-radius: 8px !important; padding: 6px 8px !important; font-size: 16px !important; }
.split-hint { font-size: 13px; color: var(--label2); text-align: right; min-width: 64px; }
.status-line { margin: 8px 32px 0; font-size: 13px; }

/* ---------- dettaglio */
.detail-head { text-align: center; padding: 8px 20px 18px; }
.detail-head .cat { width: 72px; height: 72px; font-size: 40px; border-radius: 18px; margin: 0 auto 10px; }
.detail-head h2 { margin: 0; font-size: 22px; font-weight: 700; }
.detail-head .amount { font-size: 34px; font-weight: 700; margin-top: 2px; letter-spacing: -.02em; }
.detail-head .meta { color: var(--label2); font-size: 14px; margin-top: 6px; }
.bubble { background: var(--fill); border-radius: 16px; padding: 8px 12px; font-size: 15px; display: inline-block; max-width: 100%; white-space: pre-wrap; word-break: break-word; }
.composer { display: flex; gap: 8px; align-items: center; padding: 8px 12px 8px 16px; }
.composer input { flex: 1; text-align: left !important; background: var(--fill) !important; border-radius: 18px !important; padding: 8px 14px !important; }
.send { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--tint); color: #fff; display: grid; place-items: center; flex: 0 0 32px; }
.send svg { width: 18px; height: 18px; }

/* ---------- profilo */
.profile-head { text-align: center; padding: 6px 0 4px; }
.profile-head .av { margin: 0 auto; }
.profile-head h2 { margin: 10px 0 0; font-size: 22px; }
.profile-head .link-btn { margin-top: 2px; }

/* ---------- totali */
.bar { height: 6px; background: var(--fill); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; background: var(--tint); border-radius: 3px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 16px; }
.stat { background: var(--cell); border-radius: 14px; padding: 12px 14px; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { font-size: 13px; color: var(--label2); }

/* ---------- dialoghi iOS */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.4); display: grid; place-items: center; animation: fade .2s; }
.alert { width: 270px; border-radius: 14px; background: var(--bar); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); overflow: hidden; text-align: center; animation: pop-in .25s cubic-bezier(.2,.9,.3,1.2); }
@media (prefers-color-scheme: light) { .alert { background: rgba(242,242,242,.92); } }
@keyframes pop-in { from { transform: scale(1.15); opacity: 0; } to { transform: none; opacity: 1; } }
.alert .ab { padding: 19px 16px 16px; }
.alert h3 { margin: 0; font-size: 17px; font-weight: 600; }
.alert p { margin: 4px 0 0; font-size: 13px; line-height: 1.35; }
.alert input { width: 100%; margin-top: 14px; padding: 7px 8px; font-size: 15px; border: .5px solid var(--sep); border-radius: 7px; background: var(--cell); outline: none; }
.alert .btns { display: flex; border-top: .5px solid var(--sep); }
.alert .btns.v { flex-direction: column; }
.alert .btns button { flex: 1; border: 0; background: transparent; color: var(--blue); font-size: 17px; height: 44px; }
.alert .btns:not(.v) button + button { border-left: .5px solid var(--sep); }
.alert .btns.v button + button { border-top: .5px solid var(--sep); }
.alert .btns button.bold { font-weight: 600; }
.alert .btns button.red { color: var(--red); }
.alert .btns button:active { background: var(--fill); }
.overlay.sheet { place-items: end center; padding: 0 8px calc(8px + var(--safe-b)); }
.action-sheet { width: 100%; max-width: 420px; animation: modalin .3s cubic-bezier(.2,.9,.2,1); }
.action-sheet .grp { border-radius: 14px; overflow: hidden; background: var(--bar); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); }
@media (prefers-color-scheme: light) { .action-sheet .grp { background: rgba(242,242,242,.94); } }
.action-sheet .head { padding: 14px 16px; text-align: center; font-size: 13px; color: var(--label2); border-bottom: .5px solid var(--sep); }
.action-sheet button { display: block; width: 100%; border: 0; background: transparent; height: 57px; font-size: 20px; color: var(--blue); }
.action-sheet button + button { border-top: .5px solid var(--sep); }
.action-sheet button.red { color: var(--red); }
.action-sheet button:active { background: var(--fill); }
.action-sheet .cancel { margin-top: 8px; border-radius: 14px; background: var(--cell); font-weight: 600; }
.grid-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 12px; max-height: 60vh; overflow: auto; }
.grid-picker button { height: auto; font-size: 12px; color: var(--label); padding: 10px 2px; border-radius: 12px; border: 0 !important; }
.grid-picker button span { display: block; font-size: 30px; margin-bottom: 4px; }
.grid-picker button.on { background: color-mix(in srgb, var(--tint) 20%, transparent); }

.toast { position: fixed; z-index: 200; top: calc(10px + var(--safe-t)); left: 50%; transform: translate(-50%, -150%); max-width: min(92vw, 420px);
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); color: var(--label);
  padding: 12px 18px; border-radius: 22px; font-size: 15px; font-weight: 500; box-shadow: var(--shadow); transition: transform .35s cubic-bezier(.2,.9,.3,1.1), opacity .25s; text-align: center; opacity: 0; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (min-width: 700px) {
  body { background: var(--bg); }
  .screen { border-left: .5px solid var(--sep); border-right: .5px solid var(--sep); }
}
.amount-hero input, .composer input { border: 0; outline: none; background: transparent; flex: 1; min-width: 0; padding: 0; }
.amount-hero .cat { cursor: pointer; }
.row input[type=date] { -webkit-appearance: none; appearance: none; color: var(--label2); min-height: 24px; }
.row input[type=date]::-webkit-date-and-time-value { text-align: right; }
