/* Finanze – stile
   Un solo carattere per tutto, titoli e cifre compresi. Colore solo quando significa qualcosa. */

@font-face { font-family: "Figtree"; src: url("/fonts/figtree.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("/fonts/manrope.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("/fonts/plus-jakarta-sans.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --page: #F3F5F7;
  --surface: #FFFFFF;
  --ink: #1B2430;
  --muted: #667180;
  --faint: #9AA3AF;
  --line: #E1E5EA;
  --accent: #1E3A5F;
  --accent-soft: #E6EDF6;
  --pos: #18794E;
  --pos-soft: #E5F3EB;
  --neg: #B42318;
  --neg-soft: #FBE8E6;
  --warn: #8F5507;
  --warn-soft: #FBF0DC;
  --slate-soft: #EBEEF2;
  --overlay: rgba(16, 24, 40, 0.34);
  --font: "Figtree";
  --ui: var(--font), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --c1: #2a78d6;
  --c2: #eb6834;
  --c3: #1baf7a;
  --c4: #eda100;
  --tabbar: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0D1117;
    --surface: #171C24;
    --ink: #E7EAEE;
    --muted: #9AA4B1;
    --faint: #6B7583;
    --line: #262D38;
    --accent: #9EC1EE;
    --accent-soft: #1B2A3F;
    --pos: #4CC38A;
    --pos-soft: #12301F;
    --neg: #F2867A;
    --neg-soft: #3A1714;
    --warn: #E9B45C;
    --warn-soft: #34260C;
    --slate-soft: #222935;
    --overlay: rgba(0, 0, 0, 0.55);
    --c1: #3987e5;
    --c2: #d95926;
    --c3: #199e70;
    --c4: #c98500;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 17px/1.4 var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num, .v1, .v2, dd { font-variant-numeric: tabular-nums; }

/* ---------- pagina ---------- */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 18px calc(var(--tabbar) + env(safe-area-inset-bottom) + 28px);
}
.ph { margin: 4px 2px 0; }
.ph .kick { margin: 0 0 2px; color: var(--muted); font-size: 15px; }
.ph h1 {
  margin: 0;
  font-weight: 750;
  font-size: 31px;
  line-height: 1.12;
  letter-spacing: -0.022em;
}
.lede { margin: 10px 2px 0; color: var(--muted); font-size: 17px; line-height: 1.45; max-width: 34em; }

/* la cifra principale di una schermata */
.figure { margin: 14px 2px 0; }
.figure .big {
  display: block;
  font-weight: 750;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.figure .figsub { display: block; margin-top: 6px; color: var(--muted); font-size: 15px; line-height: 1.4; }

/* ---------- gruppi e righe ---------- */
.grp { margin-top: 28px; }
.grp > h2 { margin: 0 2px 8px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.grp > .foot { margin: 8px 4px 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.list { background: var(--surface); border-radius: 14px; overflow: hidden; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 11px 14px 11px 16px;
  border: 0;
  background: none;
  text-align: left;
  position: relative;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0; right: 0; left: 16px;
  border-top: 1px solid var(--line);
}
.row.has-ic + .row::before, .row + .row.has-ic::before { left: 56px; }
.row.tap:active { background: var(--slate-soft); }
.ri {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.ri.warn { background: var(--warn-soft); color: var(--warn); }
.ri.pos { background: var(--pos-soft); color: var(--pos); }
.ri.neg { background: var(--neg-soft); color: var(--neg); }
.ri.slate { background: var(--slate-soft); color: var(--muted); }
.ri .ic { width: 19px; height: 19px; }
.rt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.t1 { font-size: 17px; line-height: 1.3; }
.t2 { font-size: 14px; line-height: 1.35; color: var(--muted); }
.rv { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.v1 { font-size: 17px; }
.v2 { font-size: 14px; color: var(--muted); }
.chev { flex: none; width: 16px; height: 16px; color: var(--faint); margin-right: -2px; }
.row.danger .t1 { color: var(--neg); }
.row.accent .t1 { color: var(--accent); font-weight: 500; }
.row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin: 0 1px 0 0; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.muted { color: var(--muted); }

.dot.green { background: var(--pos); }
.dot.amber { background: #D98E1F; }
.dot.red { background: var(--neg); }
.dot.blue { background: #3B6FB6; }
.dot.slate { background: var(--faint); }

/* casella da spuntare dentro una riga */
.check {
  flex: none;
  appearance: none;
  -webkit-appearance: none;
  width: 24px; height: 24px;
  margin: 0 3px;
  border-radius: 50%;
  border: 2px solid var(--faint);
  display: grid; place-items: center;
}
.check:checked { background: var(--pos); border-color: var(--pos); }
.check:checked::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }

/* etichetta di stato */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  background: var(--slate-soft); color: var(--muted);
  white-space: nowrap;
}
.chip.green { background: var(--pos-soft); color: var(--pos); }
.chip.amber { background: var(--warn-soft); color: var(--warn); }
.chip.red { background: var(--neg-soft); color: var(--neg); }
.chip.blue { background: var(--accent-soft); color: var(--accent); }

/* ---------- controlli ---------- */
.seg { display: flex; margin: 16px 0 0; padding: 2px; border-radius: 10px; background: var(--slate-soft); }
.seg button { flex: 1; height: 34px; border: 0; border-radius: 8px; background: none; font-size: 15px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12); }

.btn {
  display: block; width: 100%;
  margin-top: 16px;
  padding: 14px 16px;
  border: 0; border-radius: 13px;
  background: var(--accent); color: #fff;
  font-size: 17px; font-weight: 600; text-align: center;
}
@media (prefers-color-scheme: dark) { .btn { color: #0D1117; } }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--neg-soft); color: var(--neg); }
.btn:disabled { opacity: 0.5; }
.btns { display: flex; gap: 10px; }
.btns .btn { flex: 1; }
.link { border: 0; background: none; padding: 6px 0; color: var(--accent); font-size: 17px; }

.note { margin: 14px 2px 0; padding: 12px 14px; border-radius: 12px; font-size: 15px; line-height: 1.45; background: var(--slate-soft); }
.note.ok { background: var(--pos-soft); }
.note.warn { background: var(--warn-soft); }
.note b { font-weight: 600; }

/* ---------- barra delle schede ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1; max-width: 160px;
  border: 0; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 11px; font-weight: 500;
}
.tabs button .ic { width: 25px; height: 25px; }
.tabs button.on { color: var(--accent); }

/* ---------- icone ---------- */
.ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- foglio dal basso ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: var(--overlay); transition: background 0.24s ease; }
.sheet.hidden { display: none; }
.sheet .panel {
  width: 100%; max-width: 640px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--page);
  border-radius: 22px 22px 0 0;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.enter { background: transparent; }
.sheet.enter .panel { transform: translateY(100%); }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
.sh { display: grid; grid-template-columns: 76px 1fr 76px; align-items: center; padding: 6px 12px 4px; flex: none; }
.sh h3 { margin: 0; text-align: center; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shr { text-align: right; }
.iconbtn { border: 0; background: none; color: var(--accent); width: 40px; height: 40px; display: grid; place-items: center; margin-left: -8px; }
.iconbtn .ic { width: 22px; height: 22px; }
.sb { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 18px calc(24px + env(safe-area-inset-bottom)); }
.sb > .grp:first-child { margin-top: 12px; }
.sb h4 { margin: 24px 2px 6px; font-size: 17px; font-weight: 600; }
.sb p.text { margin: 0 2px; font-size: 16px; line-height: 1.5; }
.sb ul.text { margin: 0; padding-left: 22px; font-size: 16px; line-height: 1.5; }
.sb ul.text li { margin: 3px 0; }
.sb .foot { margin: 18px 2px 0; color: var(--muted); font-size: 13px; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 14px 0 0; background: var(--line); border-radius: 14px; overflow: hidden; }
.facts div { background: var(--surface); padding: 11px 14px; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 17px; }

/* campi dei moduli */
.field { display: block; margin-top: 14px; }
.field > span { display: block; margin: 0 2px 6px; font-size: 14px; color: var(--muted); }
.field input, .field select, .field textarea {
  display: block; width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface);
  font-size: 17px;
}
.row .amount {
  flex: none; width: 128px;
  padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--page);
  text-align: right; font-size: 17px; font-variant-numeric: tabular-nums;
}
.switch {
  flex: none; appearance: none; -webkit-appearance: none;
  width: 51px; height: 31px; border-radius: 16px;
  background: var(--line); position: relative; transition: background 0.2s;
}
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.switch:checked { background: var(--pos); }
.switch:checked::after { transform: translateX(20px); }

details.more { margin-top: 12px; }
details.more > summary { list-style: none; padding: 10px 2px; color: var(--accent); font-size: 16px; }
details.more > summary::-webkit-details-marker { display: none; }

.code { margin: 18px 0 6px; text-align: center; font-size: 36px; font-weight: 700; letter-spacing: 0.14em; }

/* ---------- avvisi brevi ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 14px);
  z-index: 30; max-width: 88vw;
  padding: 11px 18px; border-radius: 14px;
  background: #1B2430; color: #fff; font-size: 15px;
  box-shadow: 0 6px 24px rgba(16, 24, 40, 0.25);
}
.toast.hidden { display: none; }

/* ---------- accesso ---------- */
.login { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 64px) 24px 40px; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; display: block; }
.login h1 { margin: 22px 0 0; font-weight: 750; font-size: 34px; letter-spacing: -0.025em; }
.login .lede { margin-left: 0; }
.login .foot { margin-top: 28px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.splash { min-height: 100vh; display: grid; place-items: center; }
.splash img { width: 72px; height: 72px; border-radius: 18px; }

.empty { padding: 16px; color: var(--muted); font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet .panel, .switch, .switch::after { transition: none; }
}

/* ---------- grafici ---------- */
.chartbox { padding: 6px 14px 10px; }
.chartbox + .row::before { left: 16px; }
.chart-title { margin: 0 0 2px; font-size: 14px; color: var(--muted); }
figure.chart { position: relative; margin: 0; border-radius: 10px; }
figure.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.cl { font: 500 11.5px var(--ui); fill: var(--muted); }
.cl.strong { fill: var(--ink); font-size: 12.5px; font-weight: 650; }
.axis { stroke: var(--line); stroke-width: 1; }
.limit { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.8; }
.cross { stroke: var(--faint); stroke-width: 1; }
.tip {
  position: absolute; top: 0; z-index: 2;
  padding: 7px 10px; border-radius: 10px;
  background: var(--ink); color: var(--surface);
  font-size: 13px; line-height: 1.35; white-space: nowrap; pointer-events: none;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.2);
}
.tip b { display: block; font-weight: 600; }
.tip span { display: block; font-variant-numeric: tabular-nums; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 2px; font-size: 14px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.muted { background: var(--faint); }

.segbar { margin: 0; padding: 14px 14px 4px; }
.seg-row { display: flex; gap: 2px; height: 28px; }
.seg-b { flex: 1 1 0; min-width: 3px; border-radius: 4px; display: flex; align-items: center; padding-left: 8px; }
.seg-b em { font-style: normal; font-size: 13px; font-weight: 650; color: #fff; }
.seg-b.c1 { background: var(--c1); }
.seg-b.c2 { background: var(--c2); }
.seg-b.c3 { background: var(--c3); }
.seg-b.c4 { background: var(--c4); }
.seg-b.c4 em { color: #0b0b0b; }
@media (prefers-color-scheme: dark) { .seg-b.c4 em { color: #fff; } }
.sw { flex: none; width: 12px; height: 12px; border-radius: 3px; margin: 0 9px; }
.sw.c1 { background: var(--c1); } .sw.c2 { background: var(--c2); } .sw.c3 { background: var(--c3); } .sw.c4 { background: var(--c4); }

.meter { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meterbox { padding: 14px 16px 12px; }
.meterbox p { margin: 8px 0 0; font-size: 14px; color: var(--muted); }

.wbar { position: relative; display: block; height: 4px; margin: 7px 0 2px; border-radius: 2px; background: var(--slate-soft); max-width: 210px; }
.wbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--accent); }
.wbar b { position: absolute; top: -3px; width: 2px; height: 10px; margin-left: -1px; border-radius: 1px; background: var(--ink); }
.sw-in { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 9px; vertical-align: -1px; }
.sw-in.c1 { background: var(--c1); } .sw-in.c2 { background: var(--c2); } .sw-in.c3 { background: var(--c3); } .sw-in.c4 { background: var(--c4); }
.pill { flex: none; border: 0; border-radius: 999px; padding: 7px 14px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; }
@media (prefers-color-scheme: dark) { .pill { color: #0D1117; } }
