/* =============================================================
   Patrimonio – Premium dark UI
   ============================================================= */
:root {
  --bg: #06060b;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.075);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-2: rgba(255, 255, 255, 0.14);
  --text: #f5f5f7;
  --muted: rgba(235, 235, 245, 0.62);
  --dim: rgba(235, 235, 245, 0.38);

  --liq: #22d3ee;
  --inv: #a78bfa;
  --pen: #fbbf24;
  --pos: #34d399;
  --neg: #fb7185;
  --accent-1: #7c5cff;
  --accent-2: #22d3ee;
  --accent: linear-gradient(135deg, var(--accent-1), var(--accent-2));

  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;

  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ios: cubic-bezier(0.32, 0.72, 0, 1);
  --out: cubic-bezier(0.16, 1, 0.3, 1);

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); overscroll-behavior-y: none; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", system-ui, sans-serif;
  font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { display: block; }

/* ---------- Aurora background ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  filter: blur(90px); opacity: 0.38; mix-blend-mode: screen;
  transition: background 1.2s ease;
  will-change: transform;
}
.b1 { background: radial-gradient(circle, #7c5cff 0%, transparent 65%); top: -35vmax; left: -25vmax; animation: drift1 22s ease-in-out infinite alternate; }
.b2 { background: radial-gradient(circle, #06b6d4 0%, transparent 65%); top: 10vmax; right: -40vmax; animation: drift2 26s ease-in-out infinite alternate; }
.b3 { background: radial-gradient(circle, #db2777 0%, transparent 65%); bottom: -45vmax; left: -10vmax; opacity: 0.22; animation: drift3 30s ease-in-out infinite alternate; }
body[data-tab="liquidita"] .b1 { background: radial-gradient(circle, #0891b2 0%, transparent 65%); }
body[data-tab="liquidita"] .b3 { background: radial-gradient(circle, #2563eb 0%, transparent 65%); }
body[data-tab="investimenti"] .b2 { background: radial-gradient(circle, #8b5cf6 0%, transparent 65%); }
body[data-tab="investimenti"] .b3 { background: radial-gradient(circle, #10b981 0%, transparent 65%); }
body[data-tab="pensione"] .b1 { background: radial-gradient(circle, #d97706 0%, transparent 65%); }
body[data-tab="pensione"] .b2 { background: radial-gradient(circle, #e11d48 0%, transparent 65%); }
@keyframes drift1 { to { transform: translate(18vmax, 12vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vmax, 14vmax) scale(0.9); } }
@keyframes drift3 { to { transform: translate(12vmax, -14vmax) scale(1.1); } }
.grain {
  position: absolute; inset: 0; opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Splash & logo ---------- */
.splash { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; transition: opacity .5s ease, visibility .5s; }
.splash.gone { opacity: 0; visibility: hidden; }
.logo-mark {
  width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center;
  background: var(--accent);
  box-shadow: 0 20px 60px -10px rgba(124, 92, 255, .7), inset 0 1px 0 rgba(255,255,255,.35);
}
.logo-mark.big { width: 96px; height: 96px; border-radius: 30px; }
.logo-mark svg { width: 60%; height: 60%; fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.logo-mark svg circle { fill: #fff; stroke: none; }
.logo-mark svg path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 1.4s var(--out) .2s forwards; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); box-shadow: 0 10px 30px -10px rgba(124,92,255,.5); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 32px; text-align: center; }
.login-inner > * { opacity: 0; animation: rise .9s var(--out) forwards; }
.login-inner > *:nth-child(2) { animation-delay: .1s; }
.login-inner > *:nth-child(3) { animation-delay: .18s; }
.login-inner > *:nth-child(4) { animation-delay: .28s; }
.login-inner > *:nth-child(5) { animation-delay: .38s; }
.login-inner .logo-mark { margin: 0 auto 28px; }
.login-title {
  font-size: 44px; letter-spacing: -0.04em; margin: 0 0 10px; font-weight: 800;
  background: linear-gradient(180deg, #fff 30%, rgba(255,255,255,.55)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub { color: var(--muted); font-size: 17px; line-height: 1.45; margin: 0 0 40px; }
.btn-ms {
  display: inline-flex; align-items: center; gap: 12px; padding: 17px 28px; border-radius: 18px;
  background: #fff; color: #111; text-decoration: none; font-weight: 600; font-size: 17px;
  box-shadow: 0 20px 50px -15px rgba(255,255,255,.35);
  transition: transform .25s var(--spring);
}
.btn-ms:active { transform: scale(.96); }
.ms-logo { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.ms-logo i { width: 9px; height: 9px; display: block; }
.ms-logo i:nth-child(1) { background: #f25022; } .ms-logo i:nth-child(2) { background: #7fba00; }
.ms-logo i:nth-child(3) { background: #00a4ef; } .ms-logo i:nth-child(4) { background: #ffb900; }
.login-foot { margin-top: 28px; color: var(--dim); font-size: 13px; }

/* ---------- Topbar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--sat) + 10px) 20px 10px;
  transition: background .35s ease, backdrop-filter .35s ease, border-color .35s ease;
  border-bottom: 0.5px solid transparent;
}
.topbar.scrolled {
  background: rgba(10, 10, 16, 0.6);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border-bottom-color: var(--stroke);
}
.topbar-title { font-weight: 650; font-size: 17px; opacity: 0; transform: translateY(6px); transition: all .35s var(--out); }
.topbar.scrolled .topbar-title { opacity: 1; transform: none; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 0.5px solid var(--stroke);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  transition: transform .25s var(--spring), background .2s;
}
.icon-btn:active { transform: scale(.88); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .eye-off { display: none; }
body.privacy .icon-btn .eye-on { display: none; }
body.privacy .icon-btn .eye-off { display: block; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; font-weight: 700; font-size: 15px;
  background: var(--accent); box-shadow: 0 6px 20px -6px rgba(124,92,255,.8);
  transition: transform .25s var(--spring);
}
.avatar:active { transform: scale(.88); }

.offline-pill {
  position: fixed; top: calc(var(--sat) + 60px); left: 50%; transform: translateX(-50%); z-index: 19;
  font-size: 12px; padding: 6px 12px; border-radius: 99px; background: rgba(251,191,36,.15); color: var(--pen);
  border: 0.5px solid rgba(251,191,36,.3);
}

/* ---------- View ---------- */
.view {
  padding: calc(var(--sat) + 64px) 18px calc(var(--sab) + 120px);
  max-width: 640px; margin: 0 auto;
  view-transition-name: view;
}
.rise { opacity: 0; animation: rise .8s var(--out) forwards; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.985); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }

/* View transitions tra tab */
::view-transition-old(view), ::view-transition-new(view) { animation-duration: .42s; animation-timing-function: var(--out); }
html[data-dir="fwd"]::view-transition-old(view) { animation-name: outLeft; }
html[data-dir="fwd"]::view-transition-new(view) { animation-name: inRight; }
html[data-dir="back"]::view-transition-old(view) { animation-name: outRight; }
html[data-dir="back"]::view-transition-new(view) { animation-name: inLeft; }
@keyframes outLeft { to { opacity: 0; transform: translateX(-40px) scale(.98); filter: blur(6px); } }
@keyframes inRight { from { opacity: 0; transform: translateX(40px) scale(.98); filter: blur(6px); } }
@keyframes outRight { to { opacity: 0; transform: translateX(40px) scale(.98); filter: blur(6px); } }
@keyframes inLeft { from { opacity: 0; transform: translateX(-40px) scale(.98); filter: blur(6px); } }

/* ---------- Typography ---------- */
.eyebrow { color: var(--muted); font-size: 14px; font-weight: 500; margin: 0 0 4px; }
.page-title { font-size: 34px; font-weight: 800; letter-spacing: -0.035em; margin: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin: 6px 0 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 30px 4px 12px; }
.section-title h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.section-title .link { color: var(--accent-2); font-size: 15px; font-weight: 500; }

/* ---------- Hero ---------- */
.hero { padding: 6px 4px 4px; }
.hero-label { color: var(--muted); font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.hero-value {
  font-size: clamp(40px, 12vw, 54px); font-weight: 750; letter-spacing: -0.045em; line-height: 1.05; margin: 6px 0 12px;
  background: linear-gradient(180deg, #fff 40%, rgba(255,255,255,.7)); -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap;
}
.hero-value .cents { font-size: .5em; letter-spacing: -0.02em; opacity: .55; }
.hero-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 14px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 99px;
  font-size: 14px; font-weight: 600; background: var(--surface-2); border: 0.5px solid var(--stroke);
}
.pill.pos { color: var(--pos); background: rgba(52, 211, 153, .12); border-color: rgba(52,211,153,.25); }
.pill.neg { color: var(--neg); background: rgba(251, 113, 133, .12); border-color: rgba(251,113,133,.25); }
.pill svg { width: 12px; height: 12px; fill: currentColor; }
.pill.sm { font-size: 12px; padding: 3px 8px; }

/* ---------- Card ---------- */
.card {
  position: relative; border-radius: var(--r-lg); padding: 18px;
  background: var(--surface); border: 0.5px solid var(--stroke);
  -webkit-backdrop-filter: blur(30px) saturate(160%); backdrop-filter: blur(30px) saturate(160%);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 30px 60px -30px rgba(0,0,0,.6);
}
.card + .card { margin-top: 12px; }
.tap { transition: transform .35s var(--spring), background .2s; cursor: pointer; }
.tap:active { transform: scale(.97); background: var(--surface-2); }

/* ---------- Chart ---------- */
.chart-card { padding: 16px 0 10px; margin-top: 18px; overflow: hidden; }
.chips { display: flex; gap: 6px; padding: 0 16px 8px; }
.chip {
  padding: 7px 13px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all .3s var(--out);
}
.chip.active { background: rgba(255,255,255,.12); color: var(--text); }
.chart-wrap { position: relative; height: 190px; touch-action: pan-y; }
.chart .line { filter: drop-shadow(0 6px 14px rgba(124,92,255,.55)); }
.chart .area { opacity: 0; transition: opacity 1s ease .5s; }
.chart.ready .area { opacity: 1; }
.chart .grid { stroke: rgba(255,255,255,.06); stroke-dasharray: 2 5; }
.chart .cursor { stroke: rgba(255,255,255,.35); stroke-width: 1; opacity: 0; transition: opacity .15s; }
.chart .dot { fill: #fff; stroke: var(--accent-1); stroke-width: 3; opacity: 0; transition: opacity .15s; }
.chart.scrub .cursor, .chart.scrub .dot { opacity: 1; }
.chart .end { fill: var(--accent-2); }
.chart .end-glow { fill: var(--accent-2); opacity: .35; transform-box: fill-box; transform-origin: center; animation: glow 2s ease-out infinite; }
@keyframes glow { from { transform: scale(1); opacity: .5; } to { transform: scale(3.2); opacity: 0; } }
.chart-tip {
  position: absolute; top: 0; padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 600;
  background: rgba(20,20,30,.85); border: 0.5px solid var(--stroke-2); white-space: nowrap; pointer-events: none;
  opacity: 0; transform: translate(-50%, -6px); transition: opacity .15s;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.chart-tip.on { opacity: 1; }
.chart-tip small { color: var(--muted); font-weight: 500; margin-right: 6px; }
.chart-axis { display: flex; justify-content: space-between; padding: 6px 16px 0; color: var(--dim); font-size: 11px; font-weight: 500; text-transform: capitalize; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--dim); font-size: 14px; padding: 0 30px; text-align: center; }

/* ---------- Allocation ---------- */
.alloc-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 3px; margin: 4px 0 16px; }
.alloc-bar span { width: 0; border-radius: 99px; transition: width 1.2s var(--out); }
.legend-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-top: 0.5px solid var(--stroke); }
.legend-row:first-of-type { border-top: 0; }
.legend-ic {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c);
}
.legend-ic svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.legend-main { flex: 1; min-width: 0; }
.legend-name { font-weight: 600; font-size: 16px; }
.legend-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.legend-val { text-align: right; font-weight: 650; font-size: 16px; }
.legend-val small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; margin-top: 2px; }
.chev { width: 16px; height: 16px; fill: none; stroke: var(--dim); stroke-width: 2.2; flex: none; }

/* ---------- Banner ---------- */
.banner {
  display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 14px 16px; border-radius: var(--r-md);
  background: linear-gradient(135deg, rgba(251,191,36,.14), rgba(251,113,133,.1)); border: 0.5px solid rgba(251,191,36,.25);
}
.banner .dot-anim { width: 10px; height: 10px; border-radius: 50%; background: var(--pen); box-shadow: 0 0 0 0 rgba(251,191,36,.6); animation: ping 1.8s infinite; flex: none; }
@keyframes ping { 70% { box-shadow: 0 0 0 10px rgba(251,191,36,0); } 100% { box-shadow: 0 0 0 0 rgba(251,191,36,0); } }
.banner b { font-weight: 650; }
.banner p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- Bank cards (Liquidità) ---------- */
.bank-card {
  position: relative; overflow: hidden; border-radius: 24px; padding: 20px; min-height: 150px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255,255,255,.22), transparent 50%),
    linear-gradient(140deg, var(--c), color-mix(in srgb, var(--c) 45%, #050508));
  box-shadow: 0 24px 50px -24px var(--c), inset 0 1px 0 rgba(255,255,255,.25);
  margin-bottom: 14px;
}
.bank-card::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.28) 50%, transparent 65%);
  animation: shine 1.6s var(--out) forwards; animation-delay: calc(var(--i, 0) * 90ms + .3s);
}
@keyframes shine { to { transform: translateX(120%); } }
.bank-top { display: flex; justify-content: space-between; align-items: flex-start; }
.bank-inst { font-size: 13px; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .08em; }
.bank-name { font-size: 18px; font-weight: 650; margin-top: 3px; }
.bank-chip { width: 36px; height: 26px; border-radius: 6px; background: linear-gradient(135deg, #f8e7b0, #c9a44c); opacity: .9; }
.bank-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.bank-balance { font-size: 30px; font-weight: 750; letter-spacing: -0.035em; }
.bank-delta { font-size: 13px; font-weight: 600; padding: 4px 9px; border-radius: 99px; background: rgba(0,0,0,.22); white-space: nowrap; }
.stale-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 99px; background: rgba(0,0,0,.25); }
.stale-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--pen); }

/* ---------- Rows (Investimenti) ---------- */
.row { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-top: 0.5px solid var(--stroke); }
.row:first-child { border-top: 0; }
.row-ic {
  width: 42px; height: 42px; border-radius: 13px; flex: none; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; letter-spacing: -.02em;
  background: color-mix(in srgb, var(--c) 20%, transparent); color: var(--c);
  border: 0.5px solid color-mix(in srgb, var(--c) 35%, transparent);
}
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-val { text-align: right; font-weight: 650; font-size: 16px; white-space: nowrap; }
.row-val .pl { display: block; font-size: 12px; font-weight: 600; margin-top: 3px; }
.pos-t { color: var(--pos); } .neg-t { color: var(--neg); }
.group-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 22px 6px 8px; }
.group-head .gdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 8px; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 14px; }
.donut { position: relative; width: 132px; height: 132px; flex: none; }
.donut svg { transform: rotate(-90deg); }
.donut circle.seg { transition: stroke-dasharray 1.3s var(--out); }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut-center b { display: block; font-size: 19px; font-weight: 750; letter-spacing: -0.03em; }
.donut-center small { color: var(--muted); font-size: 12px; }
.donut-legend { flex: 1; min-width: 0; display: grid; gap: 10px; }
.dl { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.dl i { width: 10px; height: 10px; border-radius: 4px; background: var(--c); flex: none; }
.dl span { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl b { font-weight: 650; }

/* Stats grid */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat { padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 0.5px solid var(--stroke); }
.stat small { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }

/* ---------- Pension cards ---------- */
.pen-card { overflow: hidden; }
.pen-card .glow { position: absolute; width: 220px; height: 220px; right: -70px; top: -90px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c) 55%, transparent), transparent 70%); opacity: .6; pointer-events: none; }
.pen-head { display: flex; align-items: center; gap: 12px; }
.pen-value { font-size: 32px; font-weight: 750; letter-spacing: -0.035em; margin: 16px 0 6px; }
.progress { height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; margin: 14px 0 8px; }
.progress span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 50%, #fff)); transition: width 1.3s var(--out) .2s; }
.pen-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }

/* ---------- Storico ---------- */
.hist-row { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-top: 0.5px solid var(--stroke); }
.hist-row:first-child { border-top: 0; }
.hist-month { flex: 1; font-weight: 600; text-transform: capitalize; }
.hist-month small { display: block; color: var(--dim); font-weight: 500; font-size: 12px; text-transform: none; margin-top: 2px; }
.hist-val { text-align: right; font-weight: 650; }
.hist-val small { display: block; font-size: 12px; font-weight: 600; margin-top: 2px; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 34px 20px; }
.empty .big-ic { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 20px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, #7c5cff) 18%, transparent); color: var(--c, #a78bfa); }
.empty .big-ic svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.empty h3 { margin: 0 0 6px; font-size: 19px; }
.empty p { margin: 0 0 20px; color: var(--muted); font-size: 15px; line-height: 1.45; }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  height: 54px; border-radius: 17px; font-weight: 650; font-size: 17px;
  transition: transform .3s var(--spring), opacity .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); box-shadow: 0 14px 34px -12px rgba(124,92,255,.8); }
.btn.ghost { background: var(--surface-2); border: 0.5px solid var(--stroke); }
.btn.danger { color: var(--neg); background: rgba(251,113,133,.1); margin-top: 10px; }
.btn.danger.confirm { background: var(--neg); color: #fff; }
.btn.inline { width: auto; height: 44px; padding: 0 20px; display: inline-flex; font-size: 15px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.add-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); box-shadow: 0 10px 26px -8px rgba(124,92,255,.85);
  transition: transform .3s var(--spring);
}
.add-btn:active { transform: scale(.85) rotate(90deg); }
.add-btn svg { width: 20px; height: 20px; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; fill: none; }
.add-row { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; border-radius: var(--r-md); border: 1px dashed var(--stroke-2); color: var(--muted); font-weight: 600; margin-top: 4px; }
.add-row svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sab) + 10px); width: min(calc(100% - 28px), 460px);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px; border-radius: 30px;
  background: rgba(22, 22, 32, 0.62);
  -webkit-backdrop-filter: blur(30px) saturate(190%); backdrop-filter: blur(30px) saturate(190%);
  border: 0.5px solid var(--stroke-2);
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06);
}
.tab-indicator {
  position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 4);
  border-radius: 24px; background: rgba(255,255,255,.1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  transition: transform .55s var(--spring);
}
.tab {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 6px; color: var(--dim); font-size: 10.5px; font-weight: 600;
  transition: color .3s ease, transform .3s var(--spring);
}
.tab:active { transform: scale(.9); }
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .45s var(--spring); }
.tab.active { color: var(--text); }
.tab.active svg { transform: translateY(-1px) scale(1.08); }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .4s ease;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px;
  max-height: calc(100dvh - var(--sat) - 20px);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(30, 30, 44, .96), rgba(16, 16, 24, .98));
  -webkit-backdrop-filter: blur(40px); backdrop-filter: blur(40px);
  border-radius: 32px 32px 0 0; border: 0.5px solid var(--stroke-2); border-bottom: 0;
  transform: translateY(105%); transition: transform .55s var(--ios);
  box-shadow: 0 -30px 80px -20px rgba(0,0,0,.8);
}
.sheet.open { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-grip { padding: 10px 0 4px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.sheet-grip span { width: 38px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.25); }
.sheet-body { overflow-x: hidden; overflow-y: auto; padding: 6px 20px calc(var(--sab) + 24px); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-body > * { opacity: 0; animation: rise .55s var(--out) forwards; animation-delay: calc(var(--i, 0) * 40ms + 80ms); }
.sheet h3 { font-size: 22px; letter-spacing: -0.02em; margin: 6px 0 4px; text-align: center; }
.sheet .sheet-sub { color: var(--muted); text-align: center; font-size: 14px; margin: 0 0 14px; }

/* ---------- Form ---------- */
form { display: grid; gap: 12px; }
.amount-field { text-align: center; padding: 10px 0 8px; }
.amount-field label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.amount-wrap { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: 6px; }
.amount-wrap input {
  min-width: 2.4em; max-width: 78vw; text-align: right; background: none; border: 0; outline: none; padding: 0;
  font-size: 46px; font-weight: 750; letter-spacing: -0.04em; caret-color: var(--accent-2);
  -webkit-user-select: text; user-select: text;
}
.amount-wrap span { font-size: 28px; font-weight: 600; color: var(--muted); }
.amount-prev { color: var(--muted); font-size: 13px; margin-top: 4px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field input { width: 100%; min-width: 0; }
.field label { color: var(--muted); font-size: 13px; font-weight: 600; padding-left: 4px; }
.field input {
  height: 50px; padding: 0 16px; border-radius: var(--r-sm); font-size: 17px;
  background: rgba(255,255,255,.06); border: 0.5px solid var(--stroke); outline: none;
  transition: border-color .2s, background .2s; -webkit-user-select: text; user-select: text;
  -webkit-appearance: none; appearance: none;
}
.field input:focus { border-color: var(--accent-1); background: rgba(124,92,255,.08); }
.field input[type="month"] { line-height: 50px; }
.grid2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 15px; background: rgba(255,255,255,.06); }
.seg.wrap { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
.seg input { display: none; }
.seg label { text-align: center; padding: 10px 6px; border-radius: 11px; font-size: 14px; font-weight: 600; color: var(--muted); transition: all .3s var(--out); }
.seg input:checked + label { background: rgba(255,255,255,.14); color: var(--text); box-shadow: 0 4px 14px -6px rgba(0,0,0,.6); }
.swatches { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; padding: 4px 2px; }
.swatches input { display: none; }
.swatches label { width: 30px; height: 30px; border-radius: 50%; background: var(--c); transition: transform .3s var(--spring); box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); }
.swatches input:checked + label { transform: scale(1.12); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--c); }
.total-preview { display: flex; justify-content: space-between; padding: 14px 16px; border-radius: var(--r-sm); background: rgba(124,92,255,.1); border: 0.5px solid rgba(124,92,255,.3); font-weight: 650; }

/* Settings */
.profile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 14px; }
.profile .avatar { width: 72px; height: 72px; font-size: 28px; display: grid; place-items: center; margin-bottom: 8px; }
.profile small { color: var(--muted); }
.setting { display: flex; justify-content: space-between; align-items: center; padding: 15px 16px; border-radius: var(--r-sm); background: rgba(255,255,255,.05); font-weight: 600; }
.switch { width: 51px; height: 31px; border-radius: 99px; background: rgba(255,255,255,.16); position: relative; transition: background .3s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .4s var(--spring); box-shadow: 0 3px 8px rgba(0,0,0,.3); }
.switch.on { background: var(--pos); }
.switch.on::after { transform: translateX(20px); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 50%; top: calc(var(--sat) + 12px);
  transform: translate(-50%, calc(-100% - var(--sat) - 30px)); padding: 12px 18px; border-radius: 99px;
  background: rgba(30,30,44,.92); border: 0.5px solid var(--stroke-2); font-weight: 600; font-size: 15px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 20px 40px -10px rgba(0,0,0,.6); transition: transform .55s var(--spring); white-space: nowrap;
}
.toast.show { transform: translate(-50%, 0); }
.toast.err { color: var(--neg); }

/* ---------- Skeleton ---------- */
.sk { border-radius: 14px; background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.1) 50%, rgba(255,255,255,.04) 75%); background-size: 200% 100%; animation: sk 1.4s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Privacy ---------- */
.money { transition: filter .35s ease; }
body.privacy .money { filter: blur(9px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
  .rise, .sheet-body > *, .login-inner > * { opacity: 1; }
}

/* ===== Performance iOS ===== */
.blob { filter: none; mix-blend-mode: normal; width: 95vmax; height: 95vmax; opacity: .5; transition: none; }
.b3 { opacity: .28; }

.card, .icon-btn, .sheet, .sheet-backdrop, .chart-tip {
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.card { background: rgba(255,255,255,.05); contain: layout paint; }
.sheet { background: #15151f; }
.sheet-backdrop { background: rgba(0,0,0,.6); }
.chart .line { filter: none; }

/* animazioni senza blur, solo opacity + transform (accelerate dalla GPU) */
@keyframes rise { from { opacity: 0; transform: translate3d(0,14px,0); } to { opacity: 1; transform: none; } }
@keyframes outLeft  { to   { opacity: 0; transform: translate3d(-24px,0,0); } }
@keyframes inRight  { from { opacity: 0; transform: translate3d(24px,0,0); } }
@keyframes outRight { to   { opacity: 0; transform: translate3d(24px,0,0); } }
@keyframes inLeft   { from { opacity: 0; transform: translate3d(-24px,0,0); } }
::view-transition-old(view), ::view-transition-new(view) { animation-duration: .28s; }

.rise { animation-duration: .5s; animation-delay: calc(min(var(--i, 0), 6) * 45ms); }
.view.no-anim .rise { animation: none; opacity: 1; }

