/* =========================================================
   Budget — stile. Tema chiaro di base, scuro via
   prefers-color-scheme o data-theme="dark" su <html>.
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9ecf1;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #5d6b82;
  --text-3: #98a2b3;
  --accent: #2f5bd3;
  --accent-hover: #244bb8;
  --accent-ink: #ffffff;
  --accent-soft: #eef2fd;
  --in: #127a46;
  --out: #b42318;
  --in-soft: #e8f5ee;
  --out-soft: #fdeeec;
  --good: #0aac23;
  --warning: #f5a400;
  --critical: #dc3c3d;
  --series-in: #257de0;
  --series-out: #f47230;
  --grid: #eceef2;
  --hero-bg: #101828;
  --hero-text: #ffffff;
  --hero-text-2: #a3adbf;
  --hero-line: rgba(255,255,255,.1);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 12px 32px -8px rgba(16,24,40,.18), 0 4px 8px -4px rgba(16,24,40,.06);
  --nav-w: 232px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b0d12; --surface: #12151c; --surface-2: #181c25; --surface-3: #212633;
    --border: #222734; --border-strong: #2f3646;
    --text: #e8ecf2; --text-2: #97a1b3; --text-3: #6b7486;
    --accent: #7c9cff; --accent-hover: #93adff; --accent-ink: #0b1020; --accent-soft: #1a2342;
    --in: #4cc38a; --out: #f2766b; --in-soft: #12291f; --out-soft: #2e1716;
    --series-in: #338ced; --series-out: #e76624; --grid: #1e2330;
    --hero-bg: #151a26; --hero-text: #f1f4f9; --hero-text-2: #8e98ab; --hero-line: rgba(255,255,255,.07);
    --shadow: none; --shadow-lg: 0 16px 40px -8px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12; --surface: #12151c; --surface-2: #181c25; --surface-3: #212633;
  --border: #222734; --border-strong: #2f3646;
  --text: #e8ecf2; --text-2: #97a1b3; --text-3: #6b7486;
  --accent: #7c9cff; --accent-hover: #93adff; --accent-ink: #0b1020; --accent-soft: #1a2342;
  --in: #4cc38a; --out: #f2766b; --in-soft: #12291f; --out-soft: #2e1716;
  --series-in: #338ced; --series-out: #e76624; --grid: #1e2330;
  --hero-bg: #151a26; --hero-text: #f1f4f9; --hero-text-2: #8e98ab; --hero-line: rgba(255,255,255,.07);
  --shadow: none; --shadow-lg: 0 16px 40px -8px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.ico, .nav-btn svg, .icon-btn svg, .fab svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}
.num, .value, .hero-value, .kpi-value, .cat-amt, .tx-amt { font-variant-numeric: tabular-nums; }

.app { display: flex; min-height: 100dvh; }

/* ---------- navigazione ---------- */
.nav {
  width: var(--nav-w); flex-shrink: 0; position: sticky; top: 0; height: 100dvh;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; letter-spacing: -.01em; padding: 0 8px 22px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); padding: 0 10px 6px; }
.nav-btn {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; text-align: left; color: var(--text-2); font-weight: 500; position: relative;
}
.nav-btn svg { width: 19px; height: 19px; }
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--surface-2); color: var(--text); }
.nav-btn.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-btn.active svg { color: var(--accent); }
.sync-pill {
  margin-top: auto; font-size: 12px; color: var(--text-2); padding: 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); display: flex; align-items: center; gap: 8px; min-width: 0;
}
.sync-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.sync-pill[data-state="ok"] .sdot { background: var(--good); }
.sync-pill[data-state="busy"] .sdot { background: var(--accent); animation: pulse 1s infinite; }
.sync-pill[data-state="err"] .sdot { background: var(--critical); }
.sync-pill[data-state="off"] .sdot { background: var(--warning); }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- area principale ---------- */
.main { flex: 1; min-width: 0; padding: 26px 36px 110px; max-width: 1160px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { font-size: 24px; margin: 0; font-weight: 650; letter-spacing: -.02em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.month-nav { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; box-shadow: var(--shadow); }
.month-label { border: 0; background: none; font-weight: 600; min-width: 136px; padding: 5px 8px; text-transform: capitalize; border-radius: 7px; }
.icon-btn { width: 32px; height: 32px; border-radius: 7px; border: 0; background: none; display: grid; place-items: center; color: var(--text-2); }
.icon-btn:hover, .month-label:hover { background: var(--surface-2); color: var(--text); }
.theme-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.gap-top { margin-top: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); min-width: 0;
}
.card h2 {
  font-size: 13px; margin: 0 0 16px; font-weight: 600; color: var(--text);
  display: flex; justify-content: space-between; align-items: center; gap: 4px 8px; flex-wrap: wrap;
}
.card h2 small { font-weight: 500; color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-2); }
.stat .label { color: var(--text-2); font-size: 12px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; }
.stat .sub { color: var(--text-2); font-size: 12px; margin-top: 4px; }
.pos { color: var(--in); }
.neg { color: var(--out); }
.muted { color: var(--text-2); }
.empty { color: var(--text-2); text-align: center; padding: 30px 8px; font-size: 13px; }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 500; padding: 0; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

/* ---------- riquadro saldo ---------- */
.hero {
  background: var(--hero-bg); color: var(--hero-text); border-radius: 16px; padding: 26px 28px;
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center; position: relative; overflow: hidden;
  border: 1px solid var(--hero-line);
}
.hero::after {
  content: ""; position: absolute; right: -120px; top: -140px; width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,156,255,.22), transparent 65%); pointer-events: none;
}
.hero .eyebrow { color: var(--hero-text-2); }
.hero-value { font-size: 40px; font-weight: 650; letter-spacing: -.03em; margin: 6px 0 4px; line-height: 1.1; }
.hero-sub { color: var(--hero-text-2); font-size: 13px; }
.hero-kpis { display: grid; gap: 12px; position: relative; z-index: 1; }
.kpi { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid var(--hero-line); }
.kpi-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.kpi-ico.in { background: rgba(76,195,138,.16); color: #5fd49a; }
.kpi-ico.out { background: rgba(242,118,107,.16); color: #f58a80; }
.kpi-value { font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin-top: 2px; }
.kpi-sub { font-size: 12px; color: var(--hero-text-2); margin-top: 1px; }

/* ---------- icone categoria ---------- */
.cat-ico {
  --c: var(--text-3);
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent);
}
.cat-ico .ico { width: 18px; height: 18px; }
.cat-ico.sm { width: 26px; height: 26px; border-radius: 7px; }
.cat-ico.sm .ico { width: 14px; height: 14px; }

/* ---------- barre per categoria ---------- */
.cat-rows { display: flex; flex-direction: column; gap: 14px; }
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; align-items: center; }
.cat-name { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; min-width: 0; }
.cat-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; display: inline-block; }
.cat-amt { font-size: 13px; font-weight: 600; text-align: right; }
.cat-amt .muted { font-weight: 400; margin-left: 4px; }
.bar-track { grid-column: 1 / -1; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; }
.bar-meta { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-top: -2px; }
.status { display: inline-flex; align-items: center; gap: 5px; }
.status i { font-style: normal; display: inline-flex; }
.status .ico { width: 13px; height: 13px; stroke-width: 2.2; }

/* ---------- grafico ---------- */
.chart { width: 100%; height: 260px; display: block; overflow: visible; }
.chart text { font-size: 11px; fill: var(--text-3); font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart g.hover path { opacity: .82; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin: -6px 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.tooltip {
  position: fixed; pointer-events: none; z-index: 50; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 12px;
  box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .1s; min-width: 160px;
}
.tooltip.show { opacity: 1; }
.tooltip b { display: block; margin-bottom: 6px; text-transform: capitalize; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; line-height: 1.7; font-variant-numeric: tabular-nums; }
.tooltip .tt-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }

/* ---------- movimenti ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { flex: 1; min-width: 150px; }
.input, .toolbar input, .toolbar select, .field input, .field select, .field textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.day-group { margin-bottom: 18px; }
.day-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; color: var(--text-2); padding: 0 4px 8px; text-transform: capitalize; font-variant-numeric: tabular-nums; }
.tx-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tx-list.flat { border: 0; box-shadow: none; border-radius: 0; margin: -6px -8px; }
.tx {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 0; background: none; width: 100%; text-align: left;
  border-bottom: 1px solid var(--border);
}
.tx-list.flat .tx { padding: 9px 8px; border-radius: 8px; border-bottom: 0; }
.tx:last-child { border-bottom: 0; }
.tx:hover { background: var(--surface-2); }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-sub { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-weight: 600; white-space: nowrap; font-size: 14px; }
.badge {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2);
  border: 1px solid var(--border-strong); padding: 0 5px; border-radius: 4px; margin-left: 8px; vertical-align: 1px;
}

/* ---------- impostazioni ---------- */
.settings { display: grid; grid-template-columns: 1fr; gap: 16px; max-width: 760px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row + .row { margin-top: 10px; }
.btn {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm); padding: 8px 14px;
  font-weight: 500; display: inline-flex; align-items: center; gap: 6px; justify-content: center; color: var(--text);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--out); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: wait; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; font-weight: 500; }
.list-item .grow .muted { font-weight: 400; }
.help { font-size: 13px; color: var(--text-2); line-height: 1.55; margin: 0 0 14px; }
#pushState { display: inline-flex; align-items: center; gap: 6px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 7px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 7px; }
.seg button .ico { width: 15px; height: 15px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.1); }
:root[data-theme="dark"] .seg button.on { background: var(--surface-3); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .seg button.on { background: var(--surface-3); } }
.seg.type button.on[data-v="out"] { color: var(--out); }
.seg.type button.on[data-v="in"] { color: var(--in); }

/* ---------- fogli (dialog) ---------- */
.sheet {
  border: 1px solid var(--border); padding: 0; border-radius: 16px; background: var(--surface); color: var(--text);
  width: min(500px, 100vw); max-height: 92dvh; box-shadow: var(--shadow-lg);
}
.sheet[open] { animation: sheet-in .18s ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.sheet::backdrop { background: rgba(10,14,22,.5); backdrop-filter: blur(2px); }
.sheet form { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.sheet h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.amount-input { font-size: 30px !important; font-weight: 650; text-align: center; letter-spacing: -.02em; font-variant-numeric: tabular-nums; padding: 12px !important; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--border); }
.sheet-actions .spacer { flex: 1; }
.cat-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.cat-pick button {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); padding: 7px 8px;
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); text-align: left; min-width: 0;
}
.cat-pick button span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-pick button:hover { background: var(--surface-2); }
.cat-pick button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--accent-soft); }
.color-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.color-pick button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.color-pick button.on { box-shadow: 0 0 0 2px var(--text); }
.icon-pick { --c: var(--accent); display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.icon-pick button { height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); display: grid; place-items: center; }
.icon-pick button:hover { background: var(--surface-2); }
.icon-pick button.on { color: var(--c); border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }

/* ---------- pulsante + e notifiche toast ---------- */
.fab {
  position: fixed; right: 28px; bottom: 28px; height: 48px; padding: 0 20px 0 16px; border-radius: 12px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-lg); z-index: 20; transition: background .15s, transform .15s;
}
.fab:hover { background: var(--accent-hover); transform: translateY(-1px); }
.fab svg { width: 20px; height: 20px; stroke-width: 2.2; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(12px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 500;
  transition: .2s; z-index: 60; pointer-events: none; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- avvisi promemoria ---------- */
.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.alert {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.alert::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--warning); }
.alert .grow { flex: 1; min-width: 0; font-size: 14px; }
.alert .grow small { display: block; color: var(--text-2); font-size: 12px; margin-top: 2px; }
.copy-box { display: flex; gap: 6px; }
.copy-box input { flex: 1; min-width: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.steps { margin: 0 0 14px; padding-left: 20px; font-size: 13px; color: var(--text-2); line-height: 1.65; }
textarea.input { min-height: 140px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; resize: vertical; }
.imp-list { max-height: 40dvh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.imp-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.imp-row:last-child { border-bottom: 0; }
.imp-row.dup { opacity: .5; }
.imp-row select { max-width: 130px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12px; }

/* ---------- pagina di accesso ---------- */
.auth-page { min-height: 100dvh; }
.auth-shell { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr); min-height: 100dvh; }
.auth-side {
  background: #101828; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-side::after {
  content: ""; position: absolute; right: -200px; bottom: -200px; width: 560px; height: 560px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,156,255,.25), transparent 65%);
}
.auth-side .brand { padding: 0; font-size: 18px; }
.auth-side h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.03em; margin: 0 0 14px; font-weight: 650; max-width: 420px; }
.auth-side p { color: #a3adbf; margin: 0; max-width: 400px; font-size: 15px; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; position: relative; z-index: 1; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: #d0d6e2; font-size: 14px; }
.auth-points .ico { width: 20px; height: 20px; color: #7c9cff; margin-top: 1px; }
.auth-foot { color: #6b7486; font-size: 12px; position: relative; z-index: 1; }
.auth-main { display: grid; place-items: center; padding: 32px 20px calc(32px + env(safe-area-inset-bottom)); position: relative; }
.auth-main .theme-btn { position: absolute; top: 20px; right: 20px; }
.auth { width: min(400px, 100%); display: flex; flex-direction: column; gap: 22px; }
.auth-head h1 { margin: 0 0 6px; font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.auth-head p { margin: 0; color: var(--text-2); }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; }
.auth-tabs { display: flex; }
.auth-tabs button { flex: 1; justify-content: center; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .link-btn { align-self: center; }
.btn.big { padding: 11px; font-size: 14px; width: 100%; }
.auth-msg { margin: 0; font-size: 13px; color: var(--out); background: var(--out-soft); padding: 10px 12px; border-radius: var(--radius-sm); }
.auth-msg:empty { display: none; }
.auth-msg.ok { color: var(--in); background: var(--in-soft); }
.auth-skip { align-self: center; color: var(--text-2); text-align: center; font-size: 13px; }

/* ---------- telefono ---------- */
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-mobile-brand { display: flex; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; width: auto; height: auto; z-index: 30;
    flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px);
  }
  .brand, .sync-pill, .nav-label { display: none; }
  .nav-btn { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 4px; flex: 1; align-items: center; background: none !important; }
  .nav-btn.active::before { display: none; }
  .nav-btn.active { color: var(--accent); }
  .main { padding: calc(16px + env(safe-area-inset-top)) 16px 120px; }
  .topbar { margin-bottom: 16px; }
  .topbar h1 { font-size: 22px; }
  .topbar-right { width: 100%; }
  .month-nav { flex: 1; justify-content: space-between; }
  .theme-btn { width: 40px; height: 40px; }
  .month-label { min-width: 0; flex: 1; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 .stat:first-child { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: 1fr; }
  .stat .value { font-size: 22px; }
  .hero { padding: 22px 20px; border-radius: 14px; gap: 18px; }
  .hero-value { font-size: 34px; }
  .hero-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .kpi-ico { width: 30px; height: 30px; border-radius: 8px; }
  .kpi-value { font-size: 17px; }
  .card { padding: 16px; }
  .fab { bottom: calc(80px + env(safe-area-inset-bottom)); right: 16px; width: 52px; height: 52px; padding: 0; justify-content: center; border-radius: 14px; }
  .fab span { display: none; }
  .sheet { margin: auto auto 0; border-radius: 18px 18px 0 0; max-width: 100vw; border-bottom: 0; }
  .sheet form { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .cat-pick { grid-template-columns: 1fr 1fr; }
}
.brand img, .auth-mobile-brand img { border-radius: 8px; box-shadow: 0 0 0 1px var(--border); }
.auth-side .brand img { box-shadow: 0 0 0 1px rgba(255,255,255,.12); }
