/* Finanze – stile mobile-first ottimizzato per iPhone */

:root {
  --bg: #F2F3F7;
  --surface: #FFFFFF;
  --surface-2: #F6F7FA;
  --line: rgba(15, 23, 42, 0.08);
  --text: #0E1221;
  --text-2: #5B6275;
  --text-3: #9298A8;
  --accent: #4C4FE0;
  --accent-soft: rgba(76, 79, 224, 0.1);
  --in: #12A150;
  --out: #F0624D;
  --neg: #E5484D;
  --pos: #12A150;
  --warn: #D97706;
  --hero-1: #2B2E83;
  --hero-2: #4C4FE0;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 24px rgba(15, 23, 42, 0.06);
  --radius: 20px;
  --radius-sm: 14px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0D14;
    --surface: #161925;
    --surface-2: #1E2231;
    --line: rgba(255, 255, 255, 0.07);
    --text: #F2F4FA;
    --text-2: #A3A9BB;
    --text-3: #6C7386;
    --accent: #7E81FF;
    --accent-soft: rgba(126, 129, 255, 0.14);
    --in: #34C774;
    --out: #FF7A66;
    --neg: #FF6369;
    --pos: #34C774;
    --hero-1: #23266E;
    --hero-2: #4448C9;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
body.no-scroll { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
small { font-size: 0.8em; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 8px 0 4px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.ico { width: 22px; height: 22px; flex: none; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 10px) 18px 8px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title { font-size: 30px; font-weight: 750; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
  background: var(--accent-soft); color: var(--accent);
}
.avatar.lg { width: 52px; height: 52px; font-size: 22px; }
.month-switch {
  margin-top: 10px; display: flex; align-items: center; gap: 6px;
  background: var(--surface); border-radius: 999px; padding: 4px; box-shadow: var(--shadow);
  touch-action: pan-y;
}
.month-label { flex: 1; text-align: center; font-weight: 650; padding: 8px 0; position: relative; }
.dot-badge { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-left: 7px; vertical-align: middle; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); }
.icon-btn:active { background: var(--surface-2); }

/* ---------- View ---------- */
.view { padding: 8px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); display: flex; flex-direction: column; gap: 14px; }
.view.enter { animation: viewIn 0.32s var(--ease); }
.view.enter[data-dir="next"] { animation-name: viewInNext; }
.view.enter[data-dir="prev"] { animation-name: viewInPrev; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes viewInNext { from { opacity: 0; transform: translateX(22px); } }
@keyframes viewInPrev { from { opacity: 0; transform: translateX(-22px); } }

/* ---------- Hero ---------- */
.hero {
  border-radius: 24px; padding: 20px 20px 18px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, var(--hero-2) 0%, var(--hero-1) 70%);
  box-shadow: 0 10px 30px rgba(43, 46, 131, 0.28);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}
.hero.neg { background: radial-gradient(120% 140% at 100% 0%, #E5484D 0%, #8E1C2C 75%); box-shadow: 0 10px 30px rgba(142, 28, 44, 0.3); }
.hero.in { background: radial-gradient(120% 140% at 100% 0%, #22B866 0%, #0B6B3A 75%); box-shadow: 0 10px 30px rgba(11, 107, 58, 0.28); }
.hero-label { font-size: 14px; opacity: 0.8; font-weight: 550; }
.hero-amount { font-size: 40px; font-weight: 760; letter-spacing: -0.03em; margin: 2px 0 12px; font-variant-numeric: tabular-nums; }
.hero-bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
.hero-bar span { display: block; height: 100%; border-radius: inherit; background: #fff; animation: grow 0.8s var(--ease); transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } }
.hero-sub { margin-top: 9px; font-size: 14px; opacity: 0.88; }
.hero-chip { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 600; padding: 6px 11px; border-radius: 99px; background: rgba(255, 255, 255, 0.16); }
.hero.in .hero-amount { margin-bottom: 4px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi {
  background: var(--surface); border-radius: var(--radius-sm); padding: 13px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden;
  transition: transform 0.15s var(--ease);
}
.kpi:not(.static):active { transform: scale(0.97); }
.kpi::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--k, var(--accent)); }
.kpi-in { --k: var(--in); } .kpi-out { --k: var(--out); } .kpi-fixed { --k: #7C3AED; } .kpi-extra { --k: #F59E0B; }
.kpi-save { --k: var(--accent); } .kpi-rate { --k: #0EA5E9; }
.kpi-label { font-size: 13px; color: var(--text-2); font-weight: 550; }
.kpi-value { font-size: 20px; font-weight: 720; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-3); }
.compare { font-size: 13.5px; font-weight: 600; text-align: center; margin-top: -4px; }
.compare.bad { color: var(--neg); } .compare.good { color: var(--pos); }

/* ---------- Card ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.card-head h3 { font-size: 18px; font-weight: 700; }
.link { color: var(--accent); font-weight: 600; font-size: 15px; padding: 4px 0; }
.list-card { padding: 10px 14px 6px; }
.day-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); font-weight: 600; padding: 4px 2px 6px; border-bottom: 1px solid var(--line); }

/* ---------- Righe ---------- */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; width: 100%; border-radius: 12px; transition: background 0.15s; }
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--surface-2); }
.row-ico {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; flex: none;
  background: color-mix(in srgb, var(--c) 14%, transparent);
}
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-amt.muted { color: var(--text-3); }
.row.compact { padding: 9px 4px; }
.row.current { background: var(--accent-soft); }
.history { margin-top: 8px; }
.badge { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); vertical-align: 2px; margin-left: 4px; }
.badge.new { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }

.summary-line { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; color: var(--text-2); font-size: 14px; }
.summary-line strong { color: var(--text); font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.hint { font-size: 13px; color: var(--text-2); margin: -6px 4px 0; }

/* ---------- Segmented & chips ---------- */
.segmented { display: flex; background: color-mix(in srgb, var(--text) 7%, transparent); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { flex: 1; text-align: center; padding: 8px 6px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-2); transition: all 0.2s var(--ease); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); }
.segmented.small button { padding: 6px; font-size: 13px; }
.card .segmented { margin-bottom: 6px; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; }
.chip { flex: none; padding: 7px 13px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px; font-weight: 550; white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); }
.chips.wrap .chip { background: var(--surface-2); box-shadow: none; }
.chips.wrap .chip:active { background: var(--accent-soft); }

/* ---------- Donut ---------- */
.donut-wrap { display: flex; justify-content: center; padding: 10px 0 6px; }
.donut { width: 190px; height: 190px; }
.donut-track { fill: none; stroke: var(--surface-2); stroke-width: 11; }
.donut-seg { fill: none; stroke-width: 11; animation: donutIn 0.9s var(--ease) both; }
@keyframes donutIn { from { stroke-dasharray: 0 100; } }
.donut-center { text-anchor: middle; font-size: 13px; font-weight: 750; fill: var(--text); letter-spacing: -0.02em; }
.donut-sub { text-anchor: middle; font-size: 6px; fill: var(--text-2); }
.legend { display: flex; flex-direction: column; margin-top: 4px; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto auto; align-items: center; gap: 10px; padding: 9px 2px; border-top: 1px solid var(--line); font-size: 14.5px; }
.legend-row:active { background: var(--surface-2); }
.legend-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-pct { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.legend-val { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 76px; text-align: right; }
.dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Bar chart ---------- */
.bars { width: 100%; height: auto; display: block; overflow: visible; }
.bars .grid { stroke: var(--line); stroke-width: 1; }
.bars .grid.zero { stroke: var(--text-3); stroke-opacity: 0.5; }
.bars .axis { font-size: 9.5px; fill: var(--text-3); }
.bars .axis.strong { fill: var(--text); font-weight: 700; }
.bars .bar { transform-box: fill-box; transform-origin: bottom; animation: barIn 0.6s var(--ease) both; }
.bars .bar.neg { transform-origin: top; }
.bars .hi-bg { fill: var(--accent-soft); }
.bars .tap { fill: transparent; cursor: pointer; }
@keyframes barIn { from { transform: scaleY(0); } }
.chart-legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); margin: -4px 0 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; gap: 8px; }
.hbar-top strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-top small { color: var(--text-3); font-weight: 500; }
.hbar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hbar-track span { display: block; height: 100%; border-radius: inherit; transform-origin: left; animation: grow 0.7s var(--ease) both; }

/* ---------- Tabelle statistiche ---------- */
.cmp-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) 0.85fr 0.85fr 0.8fr; gap: 4px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; align-items: center; font-variant-numeric: tabular-nums; }
.cmp-grid > span:not(:first-child) { text-align: right; }
.cmp-grid > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-grid.head { border-top: 0; font-size: 12px; color: var(--text-3); font-weight: 650; padding-top: 0; }
.cmp-grid.strong { font-weight: 700; }
.cmp-sep { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 700; padding: 14px 0 4px; }
.delta { font-size: 12.5px; font-weight: 700; color: var(--text-3); }
.delta.bad { color: var(--neg); } .delta.good { color: var(--pos); }
.month-table { display: flex; flex-direction: column; }
.mt-row { display: grid; grid-template-columns: 1fr 1.1fr 1.1fr 1.1fr; gap: 6px; padding: 10px 4px; border-top: 1px solid var(--line); font-size: 14px; width: 100%; font-variant-numeric: tabular-nums; border-radius: 10px; }
.mt-row > span:not(:first-child) { text-align: right; }
.mt-row.head { border-top: 0; font-size: 12px; color: var(--text-3); font-weight: 650; padding-top: 0; }
.mt-row.current { background: var(--accent-soft); font-weight: 650; }
.mt-row:not(.head):active { background: var(--surface-2); }

/* ---------- Empty, banner, skeleton ---------- */
.empty { text-align: center; padding: 40px 18px; }
.empty h3 { font-size: 19px; margin-bottom: 6px; }
.empty p { color: var(--text-2); margin: 0 0 18px; }
.empty-ico { font-size: 42px; margin-bottom: 8px; }
.empty-card { text-align: center; padding: 26px 18px; }
.empty-card p { margin: 6px 0 16px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.banner { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; background: var(--surface); border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow); font-size: 14px; border: 1px solid var(--accent-soft); }
.banner .ico { width: 17px; height: 17px; vertical-align: -3px; color: var(--accent); }
.banner-x { font-size: 22px; line-height: 1; color: var(--text-3); padding: 0 4px; }
.banner-actions { display: flex; align-items: center; gap: 6px; }
.skeleton { display: flex; flex-direction: column; gap: 14px; }
.sk { background: var(--surface); border-radius: var(--radius-sm); height: 82px; position: relative; overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 5%, transparent), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.sk-hero { height: 150px; border-radius: 24px; }
.sk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sk-card { height: 260px; border-radius: var(--radius); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; align-items: center; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  max-width: 560px; margin: 0 auto;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--text-3); text-decoration: none; padding: 6px 0; transition: color 0.2s; }
.tab .ico { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }
.fab {
  width: 56px; height: 56px; border-radius: 18px; flex: none; margin: 0 6px; transform: translateY(-14px);
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, var(--hero-2), var(--hero-1));
  box-shadow: 0 8px 22px rgba(76, 79, 224, 0.45);
  transition: transform 0.15s var(--ease);
}
.fab .ico { width: 28px; height: 28px; stroke-width: 2.4; }
.fab:active { transform: translateY(-14px) scale(0.92); }

/* ---------- Pulsanti e form ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 13px; font-weight: 650; font-size: 15px; transition: transform 0.12s, opacity 0.2s; text-align: center; }
.btn:active { transform: scale(0.97); }
.btn.block { width: 100%; }
.btn.lg { padding: 15px 18px; font-size: 16.5px; border-radius: 15px; }
.btn.small { padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { color: var(--text-2); }
.btn.danger { background: var(--neg); color: #fff; }
.btn.danger-ghost { color: var(--neg); background: color-mix(in srgb, var(--neg) 10%, transparent); }
.btn.danger-ghost .ico { width: 19px; height: 19px; }
.btn.grow { flex: 1; }
.btn:disabled { opacity: 0.6; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; animation: spin 0.7s linear infinite; }
.btn.secondary.busy::after { border-color: var(--accent-soft); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.form, .entry-form, .kind-fields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); padding-left: 2px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px;
  padding: 12px 13px; font-size: 16px; outline: none; transition: border-color 0.15s, box-shadow 0.15s; min-height: 46px;
  -webkit-appearance: none; appearance: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input:disabled { opacity: 0.55; }
.field textarea { resize: none; }
.field-row { display: flex; gap: 10px; }
.form-error { margin: 0; color: var(--neg); font-size: 14px; font-weight: 550; text-align: center; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

.amount-field { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 6px 0 2px; color: var(--out); }
.amount-field.in { color: var(--in); }
.amount-field .cur { font-size: 30px; font-weight: 650; }
.amount-field input {
  border: 0; background: none; outline: none; font-size: 46px; font-weight: 760; letter-spacing: -0.03em;
  width: 4ch; max-width: 78vw; text-align: center; color: inherit; font-variant-numeric: tabular-nums; padding: 0;
}
.amount-field input::placeholder { color: var(--text-3); opacity: 0.5; }

.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cat {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 9px; border-radius: 14px;
  background: var(--surface-2); border: 1.5px solid transparent; transition: all 0.15s var(--ease); text-align: center;
}
.cat:active { transform: scale(0.95); }
.cat.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 13%, var(--surface)); }
.cat-ico { font-size: 22px; line-height: 1.1; }
.cat-label { font-size: 11.5px; font-weight: 600; line-height: 1.2; color: var(--text-2); }
.cat.on .cat-label { color: var(--text); }

/* ---------- Bottom sheet ---------- */
.sheet-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(5, 8, 20, 0); transition: background 0.25s; display: flex; align-items: flex-end; justify-content: center; }
.sheet-overlay.open { background: rgba(5, 8, 20, 0.42); }
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100dvh - var(--safe-t) - 24px);
  background: var(--surface); border-radius: 26px 26px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  transform: translateY(100%); transition: transform 0.32s var(--ease);
  display: flex; flex-direction: column;
}
.sheet-overlay.open .sheet { transform: none; }
.sheet-overlay.closing .sheet { transform: translateY(100%); transition-duration: 0.24s; }
.sheet-grip { width: 38px; height: 5px; border-radius: 99px; background: var(--text-3); opacity: 0.4; margin: 9px auto 4px; flex: none; }
.sheet-body { overflow-y: auto; padding: 8px 18px calc(var(--safe-b) + 18px); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-title { font-size: 20px; text-align: center; margin-bottom: 4px; }

/* Selettore mese */
.mp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.mp-head h2 { font-size: 22px; }
.mp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.mp-grid button { padding: 14px 0; border-radius: 12px; background: var(--surface-2); text-align: center; font-weight: 600; }
.mp-grid button.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.mp-grid button.on { background: var(--accent); color: #fff; }

/* Impostazioni */
.settings { display: flex; flex-direction: column; gap: 8px; }
.profile { display: flex; align-items: center; gap: 14px; padding: 6px 2px 10px; }
.group-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 700; margin: 8px 4px 0; }
.group { background: var(--surface-2); border-radius: 14px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; cursor: pointer; }
.item + .item { border-top: 1px solid var(--line); }
.item > span { flex: 1; display: flex; flex-direction: column; font-weight: 600; }
.item > span small { font-weight: 450; color: var(--text-2); font-size: 12.5px; }
.item .ico { color: var(--accent); }
.item .chev { color: var(--text-3); width: 16px; height: 16px; }
.item.danger, .item.danger .ico { color: var(--neg); }
.item:active { background: var(--line); }

/* ---------- Toast & offline ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); z-index: 200;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 600; font-size: 14.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25); transition: all 0.28s var(--ease); max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--neg); color: #fff; }
.offline-pill { display: none; position: fixed; top: calc(var(--safe-t) + 6px); left: 50%; transform: translateX(-50%); z-index: 50; background: var(--warn); color: #fff; font-size: 12.5px; font-weight: 650; padding: 5px 12px; border-radius: 99px; white-space: nowrap; }
body.offline .offline-pill { display: block; }

/* ---------- Auth ---------- */
.auth { padding: calc(var(--safe-t) + 48px) 20px calc(var(--safe-b) + 24px); display: flex; flex-direction: column; gap: 16px; max-width: 420px; margin: 0 auto; }
.auth.enter { animation: viewIn 0.4s var(--ease); }
.auth-brand { text-align: center; margin-bottom: 8px; }
.auth-brand img { border-radius: 18px; box-shadow: 0 10px 30px rgba(76, 79, 224, 0.35); }
.auth-brand h1 { font-size: 32px; margin: 14px 0 6px; }
.auth-brand p { color: var(--text-2); margin: 0; }
.auth-form { padding: 18px; }
.auth-foot { text-align: center; font-size: 13px; color: var(--text-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (min-width: 600px) {
  .tabbar { border-radius: 22px 22px 0 0; border: 1px solid var(--line); }
}

/* ---------- v1.1: periodi e stato pagamento ---------- */
.month-label { display: flex; flex-direction: column; align-items: center; padding: 4px 0; line-height: 1.2; }
.pl-main { font-weight: 680; font-size: 16px; }
.pl-sub { font-size: 11.5px; font-weight: 600; color: var(--text-3); margin-top: 1px; }
.pl-sub.salary { color: var(--in); }

.hero-bar { display: flex; }
.hero-bar span { flex: none; }
.hero-bar i { display: block; height: 100%; background: repeating-linear-gradient(45deg, rgba(255,255,255,.55) 0 4px, rgba(255,255,255,.25) 4px 8px); animation: grow 0.8s var(--ease); transform-origin: left; }
.hero-due { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.16); font-size: 13.5px; opacity: .95; }
.hero-due b { font-weight: 720; font-variant-numeric: tabular-nums; }

.fixed-row { padding: 0; gap: 4px; }
.fixed-row .row-hit { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 10px 2px; border-radius: 12px; }
.fixed-row .row-hit:active { background: var(--surface-2); }
.fixed-row:active { background: none; }
.fixed-row.paid .row-title, .fixed-row.paid .row-amt { color: var(--text-2); }
.fixed-row.paid .row-amt { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-3) 60%, transparent); }
.row-sub.late { color: var(--neg); font-weight: 600; }
.paycheck {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  border: 2px solid color-mix(in srgb, var(--text-3) 70%, transparent); transition: all .2s var(--ease); margin-left: 4px;
}
.paycheck svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.5); transition: all .2s var(--ease); }
.paycheck.on { background: var(--in); border-color: var(--in); }
.paycheck.on svg { opacity: 1; transform: none; }
.paycheck:active { transform: scale(.88); }

.pay-summary { padding: 14px 16px; }
.pay-top { display: flex; justify-content: space-between; font-size: 14px; color: var(--text-2); }
.pay-top b { color: var(--text); font-size: 17px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.pay-bar { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--warn) 22%, transparent); margin: 10px 0 8px; overflow: hidden; }
.pay-bar span { display: block; height: 100%; background: var(--in); border-radius: inherit; transition: width .4s var(--ease); }
.pay-foot { font-size: 12.5px; color: var(--text-3); }
.link.small { font-size: 13px; padding: 0; }

.banner.accent { border-color: color-mix(in srgb, var(--in) 35%, transparent); background: color-mix(in srgb, var(--in) 7%, var(--surface)); }
.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -6px; }
.quick-dates .chip { background: var(--surface-2); box-shadow: none; font-size: 13px; padding: 6px 11px; }
.quick-dates .chip:active { background: var(--accent-soft); }
.period-hint, .pay-hint { margin: -4px 2px 0; }
.paystate.disabled { opacity: .45; pointer-events: none; }
.field-row.three .field:first-child { flex: 0 0 38%; }
