/* Broker EmmeEmme
   Carta fredda e inchiostro blu; il colore serve solo a dire qualcosa:
   verde = acquisto/guadagno, mattone = vendita/perdita, ambra = conto di prova, rosso pieno = soldi veri.
   L'unico elemento "forte" è il timbro del verdetto (COMPRA, VENDI…) in Archivo stretto. */

@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo-variable.woff2") format("woff2-variations"), url("/static/fonts/archivo-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #17263b;
  --ink-2: #2c3e57;
  --paper: #eef1ed;
  --surface: #f8faf7;
  --line: #ccd4cd;
  --line-soft: #dde3dd;
  --muted: #5d6b76;
  --buy: #1d7a57;
  --buy-soft: #d6ebe0;
  --buy-bar: #8fcbb0;
  --sell: #b4372b;
  --sell-soft: #f4dfdb;
  --sell-bar: #e4a79e;
  --hold: #17263b;
  --wait: #6f7c88;
  --amber: #a86b0c;
  --amber-soft: #f6e8cc;
  --radius: 6px;
  --measure: 72ch;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums lining-nums;
}
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid #4b7bd1; outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 2rem; font-stretch: 82%; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; font-stretch: 90%; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; max-width: var(--measure); }
small, .small { font-size: .8125rem; }
.muted { color: var(--muted); }
.pos { color: var(--buy); }
.neg { color: var(--sell); }
.nowrap { white-space: nowrap; }
code { font-size: .9em; background: var(--line-soft); padding: .1em .35em; border-radius: 3px; word-break: break-all; }

/* --- testata ------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(1rem, 3vw, 2rem);
  background: var(--ink); color: var(--paper);
}
body.mode-reale .topbar { box-shadow: inset 0 -5px 0 var(--sell); }
body.mode-paper .topbar { box-shadow: inset 0 -5px 0 var(--amber); }
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; font-weight: 700; }
.mono {
  display: inline-block; font-stretch: 62%; font-weight: 800; font-size: 1.25rem; line-height: 1;
  padding: .2em .28em .14em; background: var(--paper); color: var(--ink); border-radius: 3px; letter-spacing: -.02em;
}
.brand-name { font-size: 1.05rem; font-stretch: 92%; letter-spacing: .005em; }
.topbar-right { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }
.mode-badge {
  font-size: .8125rem; font-weight: 600; text-decoration: none; color: var(--paper);
  border: 1.5px solid rgba(238,241,237,.55); border-radius: 999px; padding: .15em .7em;
}
.mode-badge.paper { background: var(--amber); border-color: var(--amber); }
.mode-badge.real { background: var(--sell); border-color: var(--sell); font-weight: 800; }
.mode-badge.locked { background: var(--amber-soft); color: var(--ink); border-color: var(--amber-soft); }
.link-btn {
  background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.topbar .link-btn { font-size: .875rem; opacity: .85; }
.link-btn.danger { color: var(--sell); }

.mainnav {
  display: flex; gap: .2rem; overflow-x: auto; scrollbar-width: none;
  padding: 0 clamp(.5rem, 3vw, 1.5rem); background: var(--surface); border-bottom: 1px solid var(--line);
}
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  flex: 0 0 auto; padding: .75rem .7rem .65rem; text-decoration: none; color: var(--muted); font-weight: 500;
  border-bottom: 3px solid transparent;
}
.mainnav a:hover { color: var(--ink); }
.mainnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 700; }
.count {
  display: inline-block; min-width: 1.4em; margin-left: .35em; padding: 0 .35em; border-radius: 999px;
  background: var(--sell); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.5;
}

.content { max-width: 1120px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem) 3rem; }
.foot { max-width: 1120px; margin: 0 auto; padding: 1.25rem clamp(1rem, 3vw, 2rem) 2.5rem; border-top: 1px solid var(--line); font-size: .8125rem; }
.foot p { max-width: 90ch; }

/* --- avvisi -------------------------------------------------------------- */
.notice { padding: .65rem 1rem; margin: 0 0 1rem; border-left: 4px solid var(--wait); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; max-width: none; }
.notice.ok { border-color: var(--buy); background: var(--buy-soft); }
.notice.err { border-color: var(--sell); background: var(--sell-soft); }
.notice.warn, .notice.demo { border-color: var(--amber); background: var(--amber-soft); }
.notice.real-money { border: 0; background: var(--sell); color: #fff; border-radius: var(--radius); font-size: 1.05rem; }

/* --- intestazioni di pagina ----------------------------------------------- */
.page-head { margin: .5rem 0 2rem; }
.page-head .lede { font-size: 1.125rem; color: var(--ink-2); }
.crumb { margin: 0 0 .25rem; font-size: .875rem; }
.actions, .row-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .75rem; }
.inline { display: inline; margin: 0; }
.block { margin: 0 0 2.5rem; }
.block > h2 { padding-bottom: .45rem; border-bottom: 1.5px solid var(--ink); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; }
.empty { color: var(--muted); padding: 1rem 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: .2rem 0; }

/* --- pulsanti ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: .4em; font: inherit; font-weight: 600; font-size: .95rem;
  padding: .55em 1.05em; border-radius: var(--radius); border: 1.5px solid var(--ink); background: transparent;
  color: var(--ink); cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: rgba(23,38,59,.06); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--ink-2); }
.btn.buy { background: var(--buy); border-color: var(--buy); color: #fff; }
.btn.buy:hover { background: #17664a; }
.btn.sell { background: var(--sell); border-color: var(--sell); color: #fff; }
.btn.sell:hover { background: #9b2e24; }
.btn.ghost { border-color: var(--line); }
.btn.ghost.danger { color: var(--sell); border-color: var(--sell-bar); }
.btn.small { font-size: .85rem; padding: .35em .75em; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* --- timbro del verdetto ------------------------------------------------- */
.stamp {
  display: inline-block; font-stretch: 62%; font-weight: 800; font-size: 1.6rem; line-height: 1;
  letter-spacing: .03em; padding: .2em .38em .12em; border: 2.5px solid currentColor; border-radius: 3px;
  color: var(--wait); background: var(--surface); white-space: nowrap;
}
.stamp.buy { color: var(--buy); background: var(--buy-soft); }
.stamp.sell { color: var(--sell); background: var(--sell-soft); }
.stamp.hold { color: var(--hold); }
.stamp.small { font-size: .95rem; border-width: 1.5px; padding: .15em .3em .08em; vertical-align: .05em; }

/* --- elenco segnali ------------------------------------------------------ */
.signals { list-style: none; margin: 0; padding: 0; }
.signal { display: grid; grid-template-columns: 9rem 1fr; gap: 1.25rem; padding: 1.5rem 0; border-bottom: 1px solid var(--line); }
.signal:first-child { padding-top: .75rem; }
.signal-verdict { display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; }
.conf { font-size: .8125rem; color: var(--muted); }
.signal h3 { font-size: 1.3rem; font-stretch: 88%; display: flex; flex-wrap: wrap; align-items: baseline; gap: .2em .5em; }
.signal h3 a { text-decoration: none; }
.signal h3 .name, h1 .name { font-weight: 400; color: var(--muted); font-size: .8em; font-stretch: 100%; }
.signal h3 .px { margin-left: auto; font-stretch: 100%; font-size: 1.05rem; }
.why { color: var(--ink-2); }
.sizing { font-size: .9375rem; color: var(--muted); }

/* --- scala stop / ingresso / obiettivo ----------------------------------- */
.ladder { margin: 1.6rem 0 .5rem; max-width: 560px; }
.ladder-track { position: relative; height: 12px; background: var(--line-soft); border-radius: 6px; }
.ladder .seg { position: absolute; top: 0; height: 100%; }
.ladder .seg.loss { background: var(--sell-bar); border-radius: 6px 0 0 6px; }
.ladder .seg.gain { background: var(--buy-bar); border-radius: 0 6px 6px 0; }
.ladder .tick { position: absolute; top: -5px; width: 2px; height: 22px; background: var(--ink); transform: translateX(-1px); }
.ladder .now { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--ink); transform: translate(-50%, -50%); }
.ladder-labels { position: relative; height: 1.5em; margin-top: .35rem; font-size: .8125rem; }
.ladder-labels span { position: absolute; white-space: nowrap; }
.ladder-labels .l-stop { color: var(--sell); transform: translateX(-10%); }
.ladder-labels .l-target { color: var(--buy); transform: translateX(-90%); }
.ladder-labels .l-entry { top: -3.2em; transform: translateX(-50%); font-weight: 600; }
.ladder-note { font-size: .875rem; color: var(--muted); margin-top: .3rem; }

/* --- dati ---------------------------------------------------------------- */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem 1.5rem; margin: 0 0 1rem; }
.facts.grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.facts div { min-width: 0; }
.facts dt { font-size: .8125rem; color: var(--muted); }
.facts dd { margin: .1rem 0 0; font-size: 1.15rem; font-weight: 600; }
.facts.big dd { font-size: 1.7rem; font-stretch: 80%; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8125rem; padding: .5rem .6rem; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
.table td { padding: .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr.inactive td { opacity: .5; }
.table tr.current td { background: var(--surface); }
.table .r, .reasons .pts { text-align: right; white-space: nowrap; }
.side { font-size: .8125rem; font-weight: 700; padding: .1em .45em; border-radius: 3px; }
.side.buy { background: var(--buy-soft); color: var(--buy); }
.side.sell { background: var(--sell-soft); color: var(--sell); }
.status { font-size: .875rem; font-weight: 600; }
.st-da_confermare, .st-da_verificare, .st-invio { color: var(--amber); }
.st-eseguito { color: var(--buy); }
.st-rifiutato { color: var(--sell); }
.st-annullato, .st-scaduto { color: var(--muted); }
.row-line { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; padding: .7rem 0; border-bottom: 1px solid var(--line-soft); }
.row-line .btn { margin-left: auto; }
.rows { list-style: none; margin: 0; padding: 0; }
.pager { display: flex; gap: 1.5rem; margin-top: 1rem; }

/* segnale */
.signal-head { display: grid; grid-template-columns: auto 1fr; gap: 1.25rem; align-items: start; }
.signal-head .stamp { font-size: 2.3rem; }
.big-why { font-size: 1.2rem; line-height: 1.5; max-width: 66ch; }
.chart-wrap { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: .5rem; }
.chart { width: 100%; height: auto; display: block; aspect-ratio: 820 / 320; }
.chart .ax { font-size: 11px; fill: var(--muted); font-family: inherit; }
.chart .lv { font-size: 11px; fill: #fff; font-weight: 700; font-family: inherit; }
.chart .lvl { font-size: 11px; font-weight: 700; font-family: inherit; }
.legend { font-size: .8125rem; color: var(--muted); display: flex; gap: .5rem 1rem; align-items: center; flex-wrap: wrap; }
.key { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--wait); margin-right: -.6rem; }
.key.k50 { border-top: 2px dashed var(--ink); }
.score { margin-bottom: 1rem; }
.score-track { position: relative; height: 10px; background: var(--line-soft); border-radius: 5px; margin: .4rem 0 .6rem; }
.score-zero { position: absolute; left: 50%; top: -4px; width: 2px; height: 18px; background: var(--ink); }
.score-bar { position: absolute; top: 0; height: 100%; border-radius: 5px; }
.score-bar.pos { background: var(--buy); }
.score-bar.neg { background: var(--sell); }
.reasons { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.reasons td { padding: .35rem .4rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.reasons .pts { width: 3.2rem; font-weight: 700; }
.reasons .pts.pos { color: var(--buy); } .reasons .pts.neg { color: var(--sell); }
.news { white-space: pre-line; background: var(--surface); border-left: 3px solid var(--line); padding: .6rem .9rem; font-size: .9375rem; }
.sources { font-size: .8125rem; padding-left: 1.1rem; }
.small-details { font-size: .875rem; color: var(--muted); margin-bottom: 1rem; }
.small-details summary { cursor: pointer; }

/* risultati */
.verdict-box p { font-size: 1.15rem; max-width: 80ch; }
.stats-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.statcol { border-top: 1.5px solid var(--ink); padding-top: .75rem; }
.statcol .facts { grid-template-columns: 1fr; gap: .5rem; }
.statcol .facts div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line-soft); padding-bottom: .35rem; }
.statcol .facts dd { font-size: 1rem; margin: 0; text-align: right; }

/* --- moduli -------------------------------------------------------------- */
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: .5em .65em; min-height: 2.6rem; max-width: 100%;
}
input:focus, select:focus { border-color: var(--ink); }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9375rem; }
label small { font-weight: 400; color: var(--muted); }
label.check, label.radio { flex-direction: row; align-items: flex-start; gap: .6rem; margin: .5rem 0; }
label.check input, label.radio input { min-height: 0; margin-top: .3em; width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }
fieldset { border: 0; border-top: 1.5px solid var(--ink); margin: 0 0 2rem; padding: 1rem 0 0; min-width: 0; }
legend { font-weight: 700; font-size: 1.25rem; font-stretch: 90%; padding: 0 .5rem 0 0; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.1rem 1.75rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; margin-top: 1rem; }
.filters label { font-size: .875rem; }
.toc { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .9rem; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); padding: 1rem 0; }
.order-form { max-width: 820px; margin-bottom: 2.5rem; }
.calc { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: .9rem 1rem .3rem; margin: 0 0 1rem; }
.totp { max-width: 260px; margin-bottom: .5rem; }
.qr { background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); margin: .5rem 0; }

.add-form { position: relative; display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; max-width: 760px; }
.add-form .grow { flex: 1 1 280px; }
.suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 5; list-style: none; margin: .25rem 0 0; padding: .25rem 0;
  background: #fff; border: 1.5px solid var(--ink); border-radius: var(--radius); max-height: 320px; overflow-y: auto;
}
.suggest li { padding: .5rem .8rem; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--paper); }
.suggest .ex { color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.suggest li.off { opacity: .5; }
.conid-form { display: flex; align-items: center; gap: .5rem; position: relative; flex-wrap: wrap; }
.conid-form input { width: 7.5rem; min-height: 2.1rem; padding: .3em .5em; }
.conid-options { list-style: none; margin: .25rem 0 0; padding: .25rem; width: 100%; font-size: .8125rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.conid-options li { padding: .3rem .4rem; cursor: pointer; }
.conid-options li:hover { background: var(--paper); }

.log { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.log li { padding: .4rem 0; border-bottom: 1px solid var(--line-soft); }
.log time { color: var(--muted); display: inline-block; min-width: 7.5rem; }
.log .kind { font-weight: 600; margin-right: .3rem; }
.log .lv-warning { color: var(--amber); }
.log .lv-error { color: var(--sell); }

/* --- accesso ------------------------------------------------------------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--ink); }
.login-box { width: min(380px, 100%); background: var(--paper); border-radius: 10px; padding: 1.75rem; }
.login-box .brand { color: var(--ink); margin-bottom: 1.5rem; }
.login-box .mono { background: var(--ink); color: var(--paper); }
.login-box form { display: grid; gap: 1rem; }
.login-box h1 { font-size: 1.5rem; margin: 0; }
.login-box .btn { justify-content: center; }

/* --- schermi piccoli ----------------------------------------------------- */
@media (max-width: 760px) {
  h1 { font-size: 1.6rem; }
  .two-col, .stats-3 { grid-template-columns: 1fr; gap: 2rem; }
  .signal { grid-template-columns: 1fr; gap: .6rem; }
  .signal-verdict { flex-direction: row; align-items: center; gap: .75rem; }
  .signal h3 .px { margin-left: 0; width: 100%; }
  .signal-head { grid-template-columns: 1fr; }
  .signal-head .stamp { font-size: 1.9rem; }
  .brand-name { display: none; }
  .row-line .btn { margin-left: 0; }
  .facts.big dd { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
.nowrap form + form { margin-left: .9rem; }

/* --- facilità d'uso ------------------------------------------------------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* pulsantino "?" e spiegazione */
.hint {
  display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; margin: 0 .1rem; padding: 0;
  border-radius: 50%; border: 1.5px solid var(--muted); background: transparent; color: var(--muted);
  font-weight: 700; font-size: .72rem; line-height: 1; font-family: inherit; cursor: pointer; vertical-align: .1em; flex: 0 0 auto;
}
.hint:hover, .hint[aria-expanded="true"] { border-color: var(--ink); color: var(--paper); background: var(--ink); }
.hint-pop {
  position: absolute; z-index: 30; max-width: min(320px, calc(100vw - 2rem)); padding: .75rem .9rem;
  background: var(--ink); color: var(--paper); border-radius: var(--radius); font-size: .875rem; line-height: 1.45;
  box-shadow: 0 6px 20px rgba(23,38,59,.25);
}
.hint-row { display: inline-flex; flex-wrap: wrap; gap: .2rem .5rem; margin-left: .5rem; align-items: center; }
label .hint { align-self: flex-start; }

/* quantità con − e + */
.stepper { display: flex; align-items: stretch; gap: 0; }
.stepper input { flex: 1; min-width: 0; text-align: center; border-radius: 0; }
.stepper .step {
  width: 2.8rem; font-weight: 700; font-size: 1.25rem; line-height: 1; font-family: inherit; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.stepper .step:first-child { border-radius: var(--radius) 0 0 var(--radius); border-right: 0; }
.stepper .step:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: 0; }
.stepper .step:active { background: var(--line-soft); }

/* profili di rischio */
.profiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.profile {
  position: relative; display: flex; flex-direction: column; gap: .35rem; padding: 1rem 1rem 1.1rem; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); font-weight: 400;
}
.profile:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.profile input { position: absolute; top: 1rem; right: 1rem; width: 1.1rem; height: 1.1rem; min-height: 0; accent-color: var(--ink); }
.profile-name { font-weight: 800; font-stretch: 85%; font-size: 1.2rem; }
.profile-desc { color: var(--ink-2); font-size: .9rem; }
.profile-cap { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.profile-cap label { flex: 0 1 320px; }
details.advanced { margin: 0 0 1.5rem; border-top: 1.5px solid var(--ink); }
details.advanced > summary { cursor: pointer; padding: 1rem 0; font-weight: 700; font-size: 1.1rem; font-stretch: 90%; }
details.advanced[open] > summary { margin-bottom: .5rem; }

/* domande all'AI */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.chip {
  font: inherit; font-size: .9rem; padding: .4em .85em; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.ask-form { display: flex; gap: .6rem; align-items: flex-end; max-width: 760px; }
.ask-form textarea { flex: 1; resize: vertical; min-height: 2.8rem; }
.answers { max-width: 760px; margin-top: 1rem; display: grid; gap: .9rem; }
.qa { border-left: 3px solid var(--ink); padding: .1rem 0 .1rem .9rem; }
.qa .q { font-weight: 700; margin: 0 0 .3rem; }
.qa .a { margin: 0; white-space: pre-line; }
.qa.pending .a { color: var(--muted); }
.qa.error { border-left-color: var(--sell); }

/* grafico interattivo */
.seg-control { display: inline-flex; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: .6rem; }
.seg-control a { padding: .35rem .8rem; text-decoration: none; font-size: .875rem; color: var(--muted); }
.seg-control a + a { border-left: 1.5px solid var(--line); }
.seg-control a[aria-current="true"] { background: var(--ink); color: var(--paper); font-weight: 600; }
.chart-wrap.interactive { position: relative; touch-action: pan-y; }
.chart-tip {
  position: absolute; top: .5rem; z-index: 3; pointer-events: none; padding: .45rem .65rem; border-radius: var(--radius);
  background: var(--ink); color: var(--paper); font-size: .8125rem; line-height: 1.4; white-space: nowrap;
}

/* guida primi passi */
.guide { background: var(--surface); border: 1.5px solid var(--ink); border-radius: 10px; padding: 1.1rem 1.25rem .8rem; margin: 0 0 2rem; }
.guide-head { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin-bottom: .6rem; }
.guide-head h2 { margin: 0; font-size: 1.2rem; }
.guide-count { font-size: .875rem; color: var(--muted); }
.guide-bar { flex: 1 1 120px; height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.guide-bar span { display: block; height: 100%; background: var(--buy); }
.guide-steps { list-style: none; margin: 0 0 .5rem; padding: 0; }
.guide-steps li { display: flex; align-items: center; gap: .8rem; padding: .55rem 0; border-top: 1px solid var(--line-soft); }
.guide-steps .tick {
  flex: 0 0 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: 50%;
  border: 1.5px solid var(--ink); font-weight: 700; font-size: .85rem;
}
.guide-steps li.done .tick { background: var(--buy); border-color: var(--buy); color: #fff; }
.guide-steps li.done .step-text { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.guide-steps .step-text { flex: 1; display: flex; flex-direction: column; }
.guide-steps .step-text small { color: var(--muted); }

@media (max-width: 760px) {
  .profiles { grid-template-columns: 1fr; }
  .ask-form { flex-direction: column; align-items: stretch; }
}

label .lbl { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .3rem; }
form.settings { margin-bottom: 2.5rem; }
.chart .lvl { paint-order: stroke; stroke: #f8faf7; stroke-width: 4px; stroke-linejoin: round; }
.only-narrow { display: none; }
@media (max-width: 600px) {
  .only-wide { display: none; }
  .only-narrow { display: block; }
}

/* --- telefono ------------------------------------------------------------- */
.tabbar, .sheet { display: none; }
.install-tip { background: var(--surface); border: 1.5px solid var(--ink); border-radius: 10px; padding: .8rem 1rem .4rem; margin-bottom: 1.25rem; }
.install-tip p { margin: 0; }

@media (max-width: 760px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .topbar { padding-top: max(.7rem, env(safe-area-inset-top)); position: sticky; top: 0; z-index: 20; }
  .mainnav, .wide-only { display: none; }
  .content { padding-top: 1rem; }
  .foot { padding-bottom: 1.5rem; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px env(safe-area-inset-bottom); z-index: 35;
    box-shadow: 0 -4px 16px rgba(23,38,59,.06);
  }
  .tabbar a, .tabbar button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 56px; padding: 4px 0; font-weight: 600; font-size: .7rem; line-height: 1.1; font-family: inherit; color: var(--muted); text-decoration: none;
    background: none; border: 0; cursor: pointer;
  }
  .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar circle { fill: currentColor; stroke: none; }
  .tabbar [aria-current="page"] { color: var(--ink); }
  .tabbar [aria-current="page"]::before {
    content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--ink);
  }
  .tab-badge {
    position: absolute; top: 4px; left: 54%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--sell); color: #fff; font-size: .7rem; line-height: 18px; text-align: center;
  }
  .sheet { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(23,38,59,.35); }
  .sheet[hidden] { display: none; }
  .sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0; background: var(--paper); border-radius: 16px 16px 0 0;
    padding: .75rem 1rem calc(1rem + 66px + env(safe-area-inset-bottom)); display: grid;
  }
  .sheet-panel a, .sheet-panel button {
    display: block; width: 100%; text-align: left; padding: 1rem .25rem; font-weight: 600; font-size: 1.05rem; font-family: inherit; color: var(--ink);
    text-decoration: none; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer;
  }
  .sheet-panel button { color: var(--sell); border-bottom: 0; }

  /* tocchi comodi */
  .btn { min-height: 46px; padding: .6em 1.1em; }
  .btn.small { min-height: 40px; }
  input, select, textarea { font-size: 16px; min-height: 48px; } /* 16px: niente zoom automatico su iPhone */
  .row-actions .btn, .actions .btn { flex: 1 1 auto; justify-content: center; }
  .page-head { margin-bottom: 1.25rem; }
  .page-head .lede { font-size: 1.02rem; }
  .hint { width: 1.6rem; height: 1.6rem; font-size: .8rem; }

  /* conferma dell'ordine: pulsante grande in fondo, annulla come scelta secondaria */
  .order-form .row-actions { flex-direction: column; align-items: stretch; }
  .order-form .row-actions .btn.ghost { border: 0; min-height: 40px; color: var(--muted); text-decoration: underline; }
  .order-form label.check { padding: .75rem; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }

  /* tabelle trasformate in schede */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; padding: .55rem .85rem; margin-bottom: .7rem; }
  table.cards td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .3rem 0; border: 0; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: .8125rem; text-align: left; flex: 0 0 auto; }
  table.cards td[data-label=""]::before, table.cards td:not([data-label])::before { content: none; }
  table.cards td.card-title { display: block; text-align: left; font-size: 1.02rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line-soft); margin-bottom: .2rem; }
  table.cards td.card-actions { justify-content: flex-start; flex-wrap: wrap; padding-top: .5rem; }
  table.cards .r { text-align: right; }
  .table-scroll { overflow: visible; }
  .conid-form { justify-content: flex-end; }
}

@media (max-width: 760px) {
  table.cards tr { display: flex; flex-direction: column; }
  table.cards td.card-title { order: -1; }
  table.cards td.card-actions { order: 10; }
}
