/* ============================================================
   factura — strumento locale di fatturazione (forfettario).
   Identità "Con calma": quaderno editoriale sereno, serif nei titoli.
   Chiaro di default + scuro curato. Mobile-first. Nessun CDN.
   Token-driven: colori/spaziature come CSS variables.
   ============================================================ */

/* ---------- token: tema chiaro (default) ---------- */
:root, [data-theme="light"] {
  --bg:          #FAF9F5;
  --bg-glow:     rgba(58, 79, 214, 0.05);
  --surface:     #FFFFFF;
  --surface-2:   #F5F3EC;
  --border:      #E8E4D7;
  --border-2:    #D9D3C3;

  --ink:         #141826;
  --ink-2:       #474C5C;
  --ink-3:       #6C7180;

  --indaco:      #3A4FD6;
  --indaco-ink:  #2B3BB0;
  --indaco-soft: #ECEEFB;
  --on-indaco:   #FFFFFF;

  --verde:       #0B7A54;
  --verde-ink:   #0A6547;
  --verde-soft:  #E4F3EC;

  --ambra:       #8C5400;
  --ambra-ink:   #6F4300;
  --ambra-dot:   #DB901D;
  --ambra-soft:  #FBF1DC;
  --ambra-line:  #EAD6A6;

  --rosso:       #A4322B;
  --rosso-soft:  #FBE9E8;

  --shadow-sm:   0 1px 2px rgba(20,24,38,.05);
  --shadow-md:   0 1px 2px rgba(20,24,38,.05), 0 10px 26px -14px rgba(20,24,38,.18);
  --shadow-lg:   0 1px 2px rgba(20,24,38,.05), 0 22px 48px -22px rgba(20,24,38,.26);

  --ring:        0 0 0 3px rgba(58,79,214,.22);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- token: tema scuro (curato) ---------- */
[data-theme="dark"] {
  --bg:          #101219;
  --bg-glow:     rgba(132, 150, 255, 0.09);
  --surface:     #191C25;
  --surface-2:   #212530;
  --border:      #2C303C;
  --border-2:    #3B4050;

  --ink:         #EEF0F6;
  --ink-2:       #C3C7D3;
  --ink-3:       #8B90A1;

  --indaco:      #8496FF;
  --indaco-ink:  #A6B2FF;
  --indaco-soft: #20263F;
  --on-indaco:   #0E101A;

  --verde:       #46CE96;
  --verde-ink:   #6FE0B0;
  --verde-soft:  #12291F;

  --ambra:       #F1B85E;
  --ambra-ink:   #F7CD86;
  --ambra-dot:   #F1B85E;
  --ambra-soft:  #2A2013;
  --ambra-line:  #4A3A1C;

  --rosso:       #F0938C;
  --rosso-soft:  #2C1817;

  --shadow-sm:   0 1px 2px rgba(0,0,0,.35);
  --shadow-md:   0 1px 2px rgba(0,0,0,.4), 0 14px 34px -16px rgba(0,0,0,.66);
  --shadow-lg:   0 1px 2px rgba(0,0,0,.4), 0 26px 56px -24px rgba(0,0,0,.8);

  --ring:        0 0 0 3px rgba(132,150,255,.32);
}

/* ---------- reset leggero ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img, svg { max-width: 100%; }

.serif { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; letter-spacing: -0.015em; }
.num   { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono  { font-family: var(--mono); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app { min-height: 100vh; position: relative; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.sidebar { display: none; }

.main {
  max-width: 940px;
  margin: 0 auto;
  padding: 20px 16px 120px;
  animation: page-in .4s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar a {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 10px;
  color: var(--ink-3);
  font-size: 11px; font-weight: 500;
  transition: color .18s ease;
}
.tabbar a .ic { width: 22px; height: 22px; }
.tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar a[aria-current="page"] { color: var(--indaco); }
.tabbar a[aria-current="page"] .ic { transform: translateY(-1px); }

@media (min-width: 768px) {
  .app { display: grid; grid-template-columns: 264px 1fr; align-items: start; }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    padding: 26px 18px;
    border-right: 1px solid var(--border);
    background: var(--surface);
  }
  .main { padding: 40px 40px 80px; }
}

/* ---- sidebar interni ---- */
.brand { display: flex; align-items: center; gap: 11px; }
.sidebar .brand { padding: 4px 8px 22px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 11px;
  color: var(--ink-2); font-weight: 500; font-size: 15px;
  transition: background .16s ease, color .16s ease;
}
.side-nav a .ic { width: 20px; height: 20px; color: var(--ink-3); transition: color .16s ease; }
.side-nav a:hover { background: var(--surface-2); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--indaco-soft); color: var(--indaco-ink); }
.side-nav a[aria-current="page"] .ic { color: var(--indaco); }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---- marchio ---- */
.mark { width: 30px; height: 30px; flex: none; display: block; }
.mark .lnk { stroke: var(--border-2); stroke-width: 2.4; }
.wordmark { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.wordmark b { color: var(--indaco); font-weight: 600; }

/* ============================================================
   COMPONENTI COMUNI
   ============================================================ */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink-3);
}
.eyebrow .constel { width: 15px; height: 15px; }

.screen-head { margin-bottom: 26px; }
.screen-head h1 { font-size: clamp(1.65rem, 5.2vw, 2.35rem); line-height: 1.12; margin: 12px 0 8px; }
.screen-head p.lead { color: var(--ink-2); font-size: clamp(1rem, 2.6vw, 1.08rem); max-width: 58ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: clamp(18px, 4vw, 26px); }

/* ---- bottoni ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 20px; border-radius: 12px;
  border: 1px solid transparent; font-weight: 600; font-size: 15px;
  text-decoration: none;
  transition: transform .12s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
  will-change: transform;
}
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--indaco); color: var(--on-indaco); box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--indaco) 70%, transparent); }
.btn-primary:hover { background: var(--indaco-ink); color: var(--on-indaco); }
.btn-ghost { background: var(--surface); border-color: var(--border-2); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-quiet { background: transparent; color: var(--ink-2); padding: 10px 12px; }
.btn-quiet:hover { color: var(--ink); background: var(--surface-2); }
.btn-lg { padding: 16px 26px; font-size: 16px; border-radius: 14px; width: 100%; }
.btn .ic { width: 19px; height: 19px; }
@media (min-width: 620px){ .btn-lg { width: auto; } }

/* ---- pill di stato ---- */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pill--green { background: var(--verde-soft); color: var(--verde); }
.pill--green .dot { background: var(--verde); }
.pill--amber { background: var(--ambra-soft); color: var(--ambra); }
.pill--amber .dot { background: var(--ambra-dot); }
.pill--grey  { background: var(--surface-2); color: var(--ink-3); }
.pill--grey .dot { background: var(--ink-3); }

/* ---- toggle tema ---- */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 9px;
  width: 100%; padding: 10px 12px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--ink-2); font-weight: 500; font-size: 14px;
  transition: background .16s ease;
}
.theme-toggle:hover { background: var(--border); }
.theme-toggle .ic { width: 18px; height: 18px; }
.topbar .theme-toggle { width: auto; padding: 9px 11px; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }
[data-theme="dark"] .theme-toggle .sun  { display: none; }
.theme-toggle .lbl.moon { display: none; }
[data-theme="dark"] .theme-toggle .lbl.moon { display: inline; }
[data-theme="dark"] .theme-toggle .lbl.sun  { display: none; }

/* entrata a cascata */
.stagger > * { animation: rise .5s cubic-bezier(.22,.61,.36,1) both; }
.stagger > *:nth-child(1){ animation-delay: .04s; }
.stagger > *:nth-child(2){ animation-delay: .10s; }
.stagger > *:nth-child(3){ animation-delay: .16s; }
.stagger > *:nth-child(4){ animation-delay: .22s; }
.stagger > *:nth-child(5){ animation-delay: .28s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ============================================================
   HOME
   ============================================================ */
.hero {
  position: relative; overflow: hidden;
  border-radius: 22px; border: 1px solid var(--border);
  background:
    radial-gradient(120% 140% at 88% -20%, var(--bg-glow), transparent 55%),
    var(--surface);
  padding: clamp(22px, 5vw, 38px);
  box-shadow: var(--shadow-md);
}
.hero .greet { font-size: clamp(1.5rem, 4.6vw, 2.1rem); line-height: 1.14; }
.hero .greet .accent { color: var(--indaco); }
.hero .sub { color: var(--ink-2); margin-top: 10px; max-width: 50ch; }
.hero-watermark { position: absolute; right: -22px; bottom: -30px; width: 190px; height: 190px; opacity: .5; pointer-events: none; }
[data-theme="dark"] .hero-watermark { opacity: .35; }

.today {
  margin-top: 22px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px;
  padding: 18px 20px; border-radius: 16px;
  background: var(--indaco-soft); border: 1px solid color-mix(in srgb, var(--indaco) 20%, transparent);
}
.today .txt { flex: 1 1 240px; }
.today .txt strong { color: var(--indaco-ink); }
.today .n { font-size: 1.15rem; }
.today .muted { color: var(--ink-3); font-size: .9rem; margin-top: 2px; }

.action-grid { display: grid; gap: 14px; margin-top: 26px; }
@media (min-width: 640px){ .action-grid { grid-template-columns: 1fr 1fr; } }
.action-card {
  display: flex; align-items: flex-start; gap: 14px; text-align: left;
  padding: 18px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .18s ease, border-color .16s ease;
  width: 100%;
}
.action-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-2); }
.action-card .ico {
  width: 42px; height: 42px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--indaco);
}
.action-card .ico .ic { width: 22px; height: 22px; }
.action-card h3 { font-size: 1.02rem; margin-bottom: 3px; }
.action-card p { color: var(--ink-3); font-size: .92rem; }
.action-card .go { margin-left: auto; align-self: center; color: var(--ink-3); }
.action-card .go .ic { width: 20px; height: 20px; }

.recent { margin-top: 30px; }
.recent h2 { font-size: .95rem; color: var(--ink-3); font-weight: 600; letter-spacing: .02em; margin-bottom: 8px; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px; border-bottom: 1px solid var(--border);
  color: var(--ink-2); font-size: .95rem;
}
.recent li:last-child { border-bottom: 0; }
.recent li .tick { width: 20px; height: 20px; color: var(--verde); flex: none; }
.recent li .when { margin-left: auto; color: var(--ink-3); font-size: .85rem; white-space: nowrap; }

/* ============================================================
   FORM (I MIEI DATI / profilo)
   ============================================================ */
.field { margin-bottom: 20px; }
.field label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 7px; }
.field .in, .field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border-2); color: var(--ink);
  font: inherit; transition: border-color .16s ease, box-shadow .16s ease;
}
.field .in:focus, .field input:focus, .field select:focus {
  border-color: var(--indaco); box-shadow: var(--ring); outline: none;
}
.field .help, .field .desc { display: block; margin-top: 7px; color: var(--ink-3); font-size: .86rem; line-height: 1.5; }
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236C7180' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 40px;
}
.grid-2 { display: grid; gap: 20px; }
@media (min-width: 560px){ .grid-2 { grid-template-columns: 1fr 1fr; gap: 20px 22px; } }
.grid-3 { display: grid; gap: 20px; }
@media (min-width: 560px){ .grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

.form-note {
  display: flex; gap: 11px; align-items: flex-start;
  margin: 4px 0 22px; padding: 14px 16px; border-radius: 13px;
  background: var(--verde-soft); color: var(--verde-ink); font-size: .9rem; line-height: 1.55;
}
.form-note .ic { width: 20px; height: 20px; flex: none; color: var(--verde); margin-top: 1px; }
.section-label { font-size: .82rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 30px 0 14px; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; align-items: center; }

/* blocco impostazioni (catalogo, colonne): reticolo tabellare compatto */
.subcard { margin: 0 0 16px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.mini-table th {
  text-align: left; font-weight: 600; color: var(--ink-3); font-size: .8rem;
  padding: 6px 8px; border-bottom: 1px solid var(--border-2); white-space: nowrap;
}
.mini-table td { padding: 6px 8px; vertical-align: top; }
.mini-table input {
  width: 100%; padding: 9px 10px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--border-2); color: var(--ink); font: inherit;
}
.mini-table input:focus { border-color: var(--indaco); box-shadow: var(--ring); outline: none; }

/* ============================================================
   CONTROLLA (anteprima) — il cuore
   ============================================================ */
.reassure {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 16px 18px; border-radius: 15px; margin-bottom: 20px;
  background: var(--indaco-soft); border: 1px solid color-mix(in srgb, var(--indaco) 18%, transparent);
}
.reassure .ic { width: 22px; height: 22px; flex: none; color: var(--indaco); margin-top: 1px; }
.reassure p { font-size: .92rem; color: var(--ink-2); line-height: 1.55; }
.reassure p strong { color: var(--indaco-ink); }

.summary {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(1.15rem, 3.6vw, 1.5rem); line-height: 1.4;
  margin-bottom: 22px; color: var(--ink);
}
.summary b { color: var(--indaco); font-weight: 700; }

.group-label {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); margin: 26px 0 12px;
}
.group-label .count { font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink-3); }

.check-row {
  display: grid; gap: 4px 18px; align-items: start;
  grid-template-columns: 1fr;
  padding: 16px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: opacity .2s ease, border-color .2s ease;
}
.check-row--green { border-left: 3px solid var(--verde); }
.check-row--amber { border-left: 3px solid var(--ambra-dot); background: color-mix(in srgb, var(--ambra-soft) 45%, var(--surface)); }
.check-row--grey  { border-left: 3px solid var(--border-2); background: var(--surface-2); }
.check-row.is-excluded { opacity: .5; }

.cr-status { order: 1; }
.cr-body   { order: 2; }
.cr-amount { order: 3; text-align: left; }

.cr-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-top: 6px; }
.cr-date { font-size: .82rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cr-client { font-weight: 600; font-size: 1.02rem; }
.cr-desc { color: var(--ink-2); font-size: .9rem; margin-top: 2px; }
.cr-good { color: var(--verde); font-size: .86rem; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; }
.cr-good .ic { width: 15px; height: 15px; }

.cr-amount .tot { font-size: 1.12rem; font-weight: 700; }
.cr-amount .split { font-size: .8rem; color: var(--ink-3); margin-top: 2px; }
.cr-amount .tot.muted { color: var(--ink-3); }

.cr-explain {
  grid-column: 1 / -1; order: 4;
  margin-top: 12px; padding: 13px 15px; border-radius: 12px;
  background: color-mix(in srgb, var(--ambra-soft) 70%, var(--surface));
  border: 1px solid var(--ambra-line);
  font-size: .9rem; color: var(--ambra-ink); line-height: 1.55;
}
.check-row--grey .cr-explain { background: var(--surface); border-color: var(--border); color: var(--ink-2); }
.cr-explain .why-head { display: flex; align-items: center; gap: 7px; font-weight: 700; color: var(--ambra); margin-bottom: 4px; }
.check-row--grey .cr-explain .why-head { color: var(--ink-3); }
.cr-explain .why-head .ic { width: 16px; height: 16px; flex: none; }

.choice { grid-column: 1 / -1; order: 5; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 12px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 42px; height: 24px; border-radius: 999px; flex: none;
  background: var(--border-2); position: relative; transition: background .16s ease;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .16s ease;
}
.switch input:checked + .track { background: var(--indaco); }
.switch input:checked + .track .thumb { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.switch .switch-label { font-size: .9rem; font-weight: 600; color: var(--ink); }
.choice-msg { font-size: .84rem; color: var(--ink-3); font-weight: 500; }
.choice-msg.excluded { color: var(--ambra); }

@media (min-width: 660px){
  .check-row { grid-template-columns: 148px 1fr auto; }
  .cr-status { order: 1; padding-top: 6px; }
  .cr-body   { order: 2; }
  .cr-amount { order: 3; text-align: right; }
  .cr-head { margin-top: 0; }
}

/* --- pannello azione finale --- */
.commit {
  margin-top: 26px; padding: clamp(20px, 4vw, 28px);
  border-radius: 20px; text-align: center;
  background:
    radial-gradient(120% 160% at 50% -40%, var(--indaco-soft), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.commit .reassure-line { color: var(--ink-2); font-size: .92rem; margin-bottom: 16px; max-width: 48ch; margin-inline: auto; }
.commit .confirm {
  display: inline-flex; gap: 10px; align-items: flex-start; text-align: left;
  max-width: 44ch; margin: 0 auto 18px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
}
.commit .confirm input { margin-top: 2px; width: 18px; height: 18px; flex: none; accent-color: var(--indaco); }
.commit .confirm span { font-size: .9rem; color: var(--ink-2); line-height: 1.5; }
.commit .safe-tags { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; margin-top: 16px; }
.safe-tag { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--ink-3); }
.safe-tag .ic { width: 15px; height: 15px; color: var(--verde); }

/* --- carica (dropzone) --- */
.dropzone {
  text-align: center; padding: clamp(30px, 8vw, 56px) 24px;
  border: 2px dashed var(--border-2); border-radius: 20px;
  background: var(--surface);
  transition: border-color .18s ease, background .18s ease;
}
.dropzone .up-ico { width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 16px; display: grid; place-items: center; background: var(--indaco-soft); color: var(--indaco); }
.dropzone .up-ico .ic { width: 28px; height: 28px; }
.dropzone h3 { font-size: 1.15rem; margin-bottom: 6px; }
.dropzone p { color: var(--ink-3); max-width: 46ch; margin: 0 auto 22px; font-size: .95rem; }
.dropzone input[type="file"] {
  display: block; margin: 0 auto 8px; max-width: 100%;
  font: inherit; color: var(--ink-2);
}
.hint-mini { color: var(--ink-3); font-size: .82rem; margin-top: 16px; text-align: center; }

/* --- fatto (esito) --- */
.done-wrap { text-align: center; padding: clamp(24px, 6vw, 44px) 20px; }
.done-badge {
  width: 76px; height: 76px; margin: 0 auto 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--verde-soft); color: var(--verde);
  animation: pop .5s cubic-bezier(.34,1.56,.64,1) both;
}
.done-badge .ic { width: 38px; height: 38px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.done-wrap h2 { font-size: clamp(1.5rem, 5vw, 2rem); margin-bottom: 12px; }
.done-wrap .done-sub { color: var(--ink-2); max-width: 50ch; margin: 0 auto 8px; }
.done-wrap .done-safe { color: var(--verde-ink); font-weight: 600; max-width: 48ch; margin: 12px auto 26px; }
.done-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* ============================================================
   LE MIE FATTURE
   ============================================================ */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.inv-list { display: flex; flex-direction: column; gap: 10px; }
.inv-row {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center;
  padding: 15px 16px; border-radius: 15px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: border-color .16s ease, transform .14s ease;
}
.inv-row:hover { border-color: var(--border-2); transform: translateY(-1px); }
.inv-main { min-width: 0; }
.inv-num {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-weight: 700; font-variant-numeric: tabular-nums; font-size: .96rem;
}
.inv-num .tag {
  font-size: .68rem; font-weight: 700; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 6px; background: var(--indaco-soft); color: var(--indaco-ink);
}
.inv-meta { color: var(--ink-3); font-size: .86rem; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.inv-meta .d { font-variant-numeric: tabular-nums; }
.inv-right { display: flex; align-items: center; gap: 14px; }
.inv-amt { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1rem; white-space: nowrap; }
.dl { display: flex; gap: 6px; }
.dl a {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 9px;
  border: 1px solid var(--border-2); background: var(--surface);
  font-size: .78rem; font-weight: 600; color: var(--ink-2);
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.dl a:hover { background: var(--indaco-soft); color: var(--indaco-ink); border-color: transparent; }
.dl a .ic { width: 14px; height: 14px; }
@media (max-width: 560px){
  .inv-row { grid-template-columns: 1fr; }
  .inv-right { justify-content: space-between; width: 100%; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
}

/* ============================================================
   ESPORTA
   ============================================================ */
.radio-set { display: grid; gap: 10px; margin-bottom: 18px; }
.radio-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 13px; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--surface);
  transition: border-color .16s ease, background .16s ease;
}
.radio-card:hover { background: var(--surface-2); }
.radio-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.radio-card .mark-r { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2px solid var(--border-2); display: grid; place-items: center; transition: border-color .16s ease; }
.radio-card .mark-r::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--indaco); transform: scale(0); transition: transform .16s ease; }
.radio-card:has(input:checked) { border-color: var(--indaco); background: var(--indaco-soft); }
.radio-card:has(input:checked) .mark-r { border-color: var(--indaco); }
.radio-card:has(input:checked) .mark-r::after { transform: scale(1); }
.radio-card .rc-t { font-weight: 600; }
.radio-card .rc-s { color: var(--ink-3); font-size: .86rem; }
.radio-card:has(input:focus-visible) { box-shadow: var(--ring); }

.recap {
  display: grid; gap: 2px; grid-template-columns: repeat(3, 1fr);
  margin: 8px 0 22px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  background: var(--border);
}
.recap div { padding: 18px 16px; background: var(--surface); text-align: center; }
.recap .rv { font-size: clamp(1.4rem, 5vw, 1.85rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.recap .rl { color: var(--ink-3); font-size: .8rem; margin-top: 3px; }
.recap .rv.euro { color: var(--indaco); }
@media (max-width: 480px){ .recap { grid-template-columns: 1fr; } .recap div { text-align: left; display: flex; justify-content: space-between; align-items: baseline; } .recap .rl { margin-top: 0; } }

.sel-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 18px; }
.sel-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.sel-table th {
  text-align: left; font-weight: 600; color: var(--ink-3); font-size: .8rem;
  padding: 10px 12px; border-bottom: 1px solid var(--border-2); white-space: nowrap; background: var(--surface-2);
}
.sel-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.sel-table tr:last-child td { border-bottom: 0; }
.sel-table td.num, .sel-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sel-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--indaco); }

.helper-callout {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 26px; padding: 16px 18px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2); font-size: .9rem; line-height: 1.55;
}
.helper-callout .ic { width: 20px; height: 20px; flex: none; color: var(--ink-3); margin-top: 1px; }

/* ============================================================
   ALERT / MESSAGGI DI STATO
   ============================================================ */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 14px 16px; border-radius: 14px; margin-bottom: 20px;
  border: 1px solid var(--border); background: var(--surface); font-size: .92rem; line-height: 1.55;
}
.alert .ic { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert.ok { background: var(--verde-soft); border-color: color-mix(in srgb, var(--verde) 26%, transparent); color: var(--verde-ink); }
.alert.ok .ic { color: var(--verde); }
.alert.warn { background: var(--ambra-soft); border-color: var(--ambra-line); color: var(--ambra-ink); }
.alert.warn .ic { color: var(--ambra); }
.alert.danger { background: var(--rosso-soft); border-color: color-mix(in srgb, var(--rosso) 30%, transparent); color: var(--rosso); }
.alert.danger .ic { color: var(--rosso); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-body strong { display: block; margin-bottom: 2px; }

.empty { color: var(--ink-3); padding: 8px 0; }
.muted { color: var(--ink-3); }

/* ============================================================
   BANNER AMBIENTE DI PROVA (demo hostata) — mostrato solo se demo_mode.
   Striscia sobria a tutta larghezza in cima a ogni pagina, sopra topbar/sidebar.
   Solo token esistenti; nuova classe perche' non c'e' un equivalente riusabile.
   ============================================================ */
.demo-banner {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 9px 16px;
  background: var(--indaco-soft);
  border-bottom: 1px solid color-mix(in srgb, var(--indaco) 22%, transparent);
  color: var(--indaco-ink);
  font-size: .82rem; font-weight: 500; line-height: 1.4; text-align: center;
}
.demo-banner .ic { width: 16px; height: 16px; flex: none; color: var(--indaco); }

/* ============================================================
   LOGIN (area di prova) — pagina di autenticazione standalone.
   login.html NON estende base.html e NON usa lo shell .app/.main: quello e'
   una grid con colonna sidebar (264px 1fr da >=768px) e, senza sidebar, il
   contenuto finirebbe schiacciato nella prima colonna con meta' pagina vuota.
   Qui un layout centrato dedicato: intro sopra, form nella card, tutto al
   centro del viewport. Solo token gia' definiti sopra.
   ============================================================ */
.login-body {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}

.auth {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px calc(40px + env(safe-area-inset-bottom, 0));
  /* stesso glow sereno di .hero, ancorato in alto: riempie con calma i lati */
  background:
    radial-gradient(120% 80% at 50% -8%, var(--bg-glow), transparent 62%),
    var(--bg);
}

.auth-inner {
  width: 100%; max-width: 420px;
  animation: page-in .4s cubic-bezier(.22,.61,.36,1) both;
}

.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  margin-bottom: 26px;
}

.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .eyebrow { justify-content: center; }
.auth-title {
  font-size: clamp(1.6rem, 5vw, 2.15rem); line-height: 1.14;
  margin: 12px 0 10px; text-wrap: balance;   /* titolo su 1-2 righe, mai a fisarmonica */
}
.auth-lead {
  color: var(--ink-2); font-size: clamp(1rem, 2.6vw, 1.05rem);
  max-width: 42ch; margin: 0 auto;            /* larghezza di lettura comoda */
}

@media (min-width: 768px) { .auth { padding: 56px 24px; } }

/* ============================================================
   ridotto movimento
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; }
}
