/* NEXIO Quant Trader — foglio di stile locale, nessuna risorsa esterna. */
:root {
  --bg: #f4f5f7; --surface: #ffffff; --ink: #16202b; --muted: #5d6b7a; --line: #dfe3e8; --line-strong: #c5ccd5;
  --accent: #1d4f91; --accent-ink: #ffffff;
  --ok: #1f7a4d; --ok-bg: #e4f3ea; --warn: #8a5a00; --warn-bg: #fcf1d6; --bad: #a3261f; --bad-bg: #fbe5e3;
  --neutral: #4d5967; --neutral-bg: #e9ecf0; --armed: #6b2fa0; --armed-bg: #efe4f8; --synthetic: #7a3e00; --synthetic-bg: #ffe2bf;
  --radius: 8px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
h1 { font-size: 1.55rem; line-height: 1.25; margin: 0 0 .35rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; }
h3 { font-size: .82rem; margin: 1.1rem 0 .4rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
p { margin: 0 0 .7rem; }
.lead { color: var(--muted); max-width: 78ch; margin-bottom: 1.2rem; }
.muted { color: var(--muted); } .bad { color: var(--bad); font-weight: 600; } .small { font-size: .8rem; }
.mono { font-family: var(--mono); font-size: .86em; word-break: break-all; }
.hint { color: var(--muted); font-size: .86rem; }
.empty { color: var(--muted); padding: .6rem 0; }

/* barra superiore e navigazione */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .9rem; padding: .55rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; letter-spacing: -.01em; }
.topbar-status { display: flex; flex-wrap: wrap; gap: .35rem; flex: 1; min-width: 0; }
.topbar-user { display: flex; align-items: center; gap: .8rem; font-size: .86rem; white-space: nowrap; }
.topbar-user form { margin: 0; }
.bell { text-decoration: none; } .count { background: var(--bad); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; }
.nav-toggle { display: none; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; padding: .25rem .55rem; font-size: 1rem; }
.layout { display: grid; grid-template-columns: 214px minmax(0, 1fr); min-height: calc(100vh - 50px); }
.sidenav { background: var(--surface); border-right: 1px solid var(--line); padding: .8rem .5rem; display: flex; flex-direction: column; gap: 2px; }
.sidenav a { display: block; padding: .5rem .7rem; border-radius: 6px; color: var(--ink); text-decoration: none; }
.sidenav a:hover { background: var(--bg); }
.sidenav a.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav-foot { margin-top: auto; padding: .7rem; font-size: .75rem; color: var(--muted); }
.content { padding: 1.4rem 1.6rem 3rem; min-width: 0; max-width: 1500px; }

/* schede e griglie */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.05rem 1.15rem; margin-bottom: 1rem; }
.card.pending { border-color: #d6b65c; box-shadow: inset 4px 0 0 #d6b65c; }
.subcard { border-top: 1px solid var(--line); padding-top: .7rem; margin-top: .7rem; }
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; } .grid > .card { margin-bottom: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: .15rem; }
.kpi-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi-value { font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-note { font-size: .82rem; color: var(--muted); }

/* stati: verde solo per esiti confermati, grigio per ignoto o non configurato */
.pill { display: inline-block; padding: .08rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 650; letter-spacing: .02em;
  white-space: nowrap; border: 1px solid transparent; vertical-align: baseline; }
.pill-ok { background: var(--ok-bg); color: var(--ok); } .pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); } .pill-neutral { background: var(--neutral-bg); color: var(--neutral); }
.pill-armed { background: var(--armed-bg); color: var(--armed); } .pill-synthetic { background: var(--synthetic-bg); color: var(--synthetic); }
.pill-paper { background: var(--ink); color: #fff; }

/* tabelle */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: .4rem .6rem; border-bottom: 1px solid var(--line-strong); white-space: nowrap; font-weight: 600; }
.table td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv { display: grid; grid-template-columns: minmax(150px, 34%) 1fr; gap: .4rem 1rem; margin: .4rem 0 .6rem; }
.kv dt { color: var(--muted); font-size: .86rem; } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list { margin: 0; padding-left: 1.1rem; } .list li { margin-bottom: .35rem; } ul.list { list-style: none; padding-left: 0; }
.list li.unread { border-left: 3px solid var(--accent); padding-left: .6rem; }
.code { background: #f0f2f5; border: 1px solid var(--line); border-radius: 6px; padding: .7rem; font: .78rem/1.45 var(--mono);
  overflow-x: auto; white-space: pre-wrap; word-break: break-word; max-height: 420px; }
details { margin: .6rem 0; } summary { cursor: pointer; color: var(--accent); }

/* messaggi */
.msg, .banner { border-radius: 6px; padding: .6rem .8rem; margin: 0 0 .8rem; border: 1px solid var(--line); background: var(--surface); }
.msg-success { background: var(--ok-bg); border-color: #b9dcc6; color: #14522f; }
.msg-error, .msg-err, .banner-bad { background: var(--bad-bg); border-color: #edb9b4; color: #7c1b15; }
.msg-warning, .banner-warn { background: var(--warn-bg); border-color: #ecd391; color: #664200; }
.msg-info { background: #e6eef8; border-color: #bcd0ea; color: #173a69; }

/* moduli e pulsanti */
.btn { display: inline-block; font: inherit; font-weight: 600; padding: .42rem .85rem; border-radius: 6px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover { border-color: var(--ink); } .btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-warn { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn-link { border-color: transparent; background: none; color: var(--accent); padding-left: .2rem; padding-right: .2rem; }
.btn-small { padding: .2rem .55rem; font-size: .8rem; } .btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .7rem 0 .3rem; }
.form { display: grid; gap: .8rem; max-width: 620px; } .form.grid-form { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); max-width: none; align-items: end; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; max-width: none; margin-top: .8rem; }
.field { display: grid; gap: .25rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.field label, .field legend { font-size: .86rem; font-weight: 600; } .unit { font-weight: 400; color: var(--muted); }
input:not([type=checkbox]), select { font: inherit; padding: .42rem .55rem; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
.check { display: flex; align-items: flex-start; gap: .45rem; font-weight: 400 !important; } .check input { margin-top: .25rem; }
.help { font-size: .8rem; color: var(--muted); } .error { font-size: .82rem; color: var(--bad); font-weight: 600; }
.has-error input, .has-error select { border-color: var(--bad); }
form.inline { display: inline-flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .2rem 0; } form.stack { display: grid; gap: .3rem; justify-items: start; }
.filters { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .9rem; }
.chip { padding: .2rem .65rem; border: 1px solid var(--line-strong); border-radius: 999px; text-decoration: none; color: var(--ink); font-size: .82rem; background: var(--surface); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* wizard, checklist, percorso del segnale */
.steps, .checklist, .path { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 74px minmax(150px, 250px) 1fr; gap: .8rem; padding: .55rem 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.steps li:last-child { border-bottom: 0; }
.step-state { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.steps li.done .step-state { color: var(--ok); font-weight: 700; } .step-label { font-weight: 600; }
.checklist li { padding: .35rem 0; } .checklist .mark { display: inline-block; width: 1.3rem; font-weight: 700; }
.checklist .ok .mark { color: var(--ok); } .checklist .ko .mark { color: var(--bad); } .checklist .ko { color: var(--ink); }
.path > li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; margin-bottom: .8rem; }

/* grafici */
.chart { width: 100%; min-height: 260px; margin-bottom: .6rem; }
.chart .u-legend { font-size: .8rem; color: var(--muted); }

/* accesso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.7rem; width: 100%; max-width: 400px; }
.auth-card .brand { font-size: 1.15rem; display: block; }
.env-pill { display: inline-block; margin: .35rem 0 1rem; background: var(--ink); color: #fff; border-radius: 999px; padding: .05rem .6rem; font-size: .72rem; font-weight: 700; letter-spacing: .04em; }
.auth-card form { display: grid; gap: .8rem; margin: .8rem 0; } .auth-card label { display: grid; gap: .25rem; font-size: .86rem; font-weight: 600; }
.qr { display: block; margin: .6rem auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.codes { columns: 2; list-style: none; padding: 0; font-family: var(--mono); } .secret-once { font-size: .8rem; word-break: break-all; }

/* modalita' sintetica: watermark permanente */
.synthetic-bar { background: var(--synthetic-bg); color: var(--synthetic); font-weight: 700; text-align: center; padding: .3rem .8rem; font-size: .82rem; border-bottom: 1px solid #e9b877; }
.watermark { position: fixed; inset: 0; z-index: 50; pointer-events: none; display: grid; place-items: center; font-size: 11vw; font-weight: 800;
  color: rgba(160, 82, 0, .085); transform: rotate(-24deg); white-space: nowrap; letter-spacing: .04em; user-select: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-block; }
  .sidenav { display: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidenav.open { display: flex; }
  .topbar { flex-wrap: wrap; } .topbar-status { order: 3; flex-basis: 100%; }
  .topbar-user .user { display: none; }
  .content { padding: 1rem .8rem 2.5rem; }
  .kv { grid-template-columns: 1fr; gap: .1rem; } .kv dd { margin-bottom: .5rem; }
  .steps li { grid-template-columns: 1fr; gap: .1rem; }
  h1 { font-size: 1.3rem; }
}
