:root {
  --bg: #0a1020;
  --bg-2: #0f172b;
  --card: #131c33;
  --card-2: #182240;
  --line: #22304f;
  --ink: #e8edf7;
  --muted: #8f9bb8;
  --faint: #5d6a8a;
  --amber: #f5a524;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #60a5fa;
  --violet: #a78bfa;
  --cyan: #22d3ee;
  --font-display: 'Cabinet Grotesk', 'Satoshi', system-ui, sans-serif;
  --font-body: 'Satoshi', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --r: 14px;
  --r-sm: 9px;
  --side-w: 300px;
  --top-h: 60px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums lining-nums; }
.pos { color: var(--green); } .neg { color: var(--red); } .flat { color: var(--muted); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; grid-template-rows: var(--top-h) 1fr; height: 100dvh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--bg-2); position: sticky; top: 0; z-index: 20; }
.sidebar { grid-row: 2; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--bg-2); overflow: hidden; }
.main { grid-row: 2; overflow-y: auto; overscroll-behavior: contain; padding: 24px 28px 40px; scroll-behavior: smooth; }

.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.logo { color: var(--ink); flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: 1.5px; }
.brand-name em { font-style: normal; color: var(--amber); }
.brand-sub { color: var(--muted); font-size: 13px; padding-left: 12px; border-left: 1px solid var(--line); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.updated { color: var(--muted); font-size: 13px; }
.geo-pill { font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); }
.live-pill .short { display: none; }
.live-pill, .geo-pill { white-space: nowrap; }
.live-pill { font-size: 12px; font-weight: 700; letter-spacing: .5px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.live-pill.live { color: #86efac; border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.12); }
.live-pill.live::before { animation: pulse 1.6s ease-in-out infinite; }
.live-pill.delayed { color: #fcd38d; border-color: rgba(245,165,36,.4); background: rgba(245,165,36,.12); }
.live-pill.closed { color: var(--muted); }
.live-pill.off { color: #fca5a5; border-color: rgba(239,68,68,.4); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.flash-up { animation: flashUp .9s ease-out; } .flash-down { animation: flashDown .9s ease-out; }
@keyframes flashUp { 0% { background: rgba(34,197,94,.35); } 100% { background: transparent; } }
@keyframes flashDown { 0% { background: rgba(239,68,68,.35); } 100% { background: transparent; } }
.delay-note { font-size: 12px; color: var(--muted); }
.geo-pill.alto { background: rgba(239,68,68,.15); color: #fca5a5; border-color: rgba(239,68,68,.4); }
.geo-pill.medio { background: rgba(245,165,36,.15); color: #fcd38d; border-color: rgba(245,165,36,.4); }
.geo-pill.basso { background: rgba(34,197,94,.15); color: #86efac; border-color: rgba(34,197,94,.4); }
.icon-btn { display: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); width: 38px; height: 38px; cursor: pointer; font-size: 18px; }

/* ---------- sidebar ---------- */
.side-nav { display: flex; flex-direction: column; padding: 14px 12px 6px; gap: 2px; }
.nav-link { padding: 9px 12px; border-radius: var(--r-sm); color: var(--muted); font-weight: 500; }
.nav-link:hover { background: var(--card); color: var(--ink); }
.nav-link.active { background: var(--card-2); color: var(--ink); box-shadow: inset 3px 0 0 var(--amber); }
.side-tools { padding: 10px 12px 6px; border-top: 1px solid var(--line); margin-top: 8px; }
#search { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--ink); padding: 9px 12px; font: inherit; font-size: 14px; }
#search:focus { outline: 2px solid rgba(245,165,36,.5); outline-offset: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: transparent; cursor: pointer; }
.chip.active, .chip:hover { border-color: var(--amber); color: var(--ink); }
.title-list { list-style: none; margin: 0; padding: 6px 8px 12px; overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.title-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; }
.title-row:hover { background: var(--card); }
.title-row.active { background: var(--card-2); box-shadow: inset 3px 0 0 var(--amber); }
.title-row .n { font-weight: 700; font-size: 14px; }
.title-row .s { color: var(--faint); font-size: 12px; margin-left: 6px; font-weight: 500; }
.title-row .p { text-align: right; font-size: 13px; }
.title-row .b { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.group-head { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); padding: 12px 10px 4px; font-weight: 700; }
.side-foot { padding: 8px 14px; font-size: 11px; color: var(--faint); border-top: 1px solid var(--line); margin: 0; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); display: inline-block; }
.dots i.on { background: var(--amber); }

/* ---------- components ---------- */
.view > * + * { margin-top: 20px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.sub { color: var(--muted); margin: 4px 0 0; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; min-width: 0; }
.card.tight { padding: 14px 16px; }
.card h3 { margin-bottom: 10px; }
.kpi .v { font-family: var(--font-mono); font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.5px; }
.kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.kpi .d { font-size: 13px; margin-top: 4px; color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; letter-spacing: .3px; white-space: nowrap; }
.badge.buy { background: rgba(34,197,94,.16); color: #86efac; }
.badge.sell { background: rgba(239,68,68,.16); color: #fca5a5; }
.badge.neutral { background: rgba(143,155,184,.16); color: #c7d0e3; }
.badge.geo { background: rgba(245,165,36,.16); color: #fcd38d; }
.bar { height: 8px; background: var(--line); border-radius: 4px; position: relative; overflow: hidden; }
.bar > i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.scorebar { position: relative; height: 10px; background: var(--line); border-radius: 5px; }
.scorebar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--faint); }
.scorebar > i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.r, th.r { text-align: right; white-space: nowrap; }
th.sortable { padding: 0; }
th.sortable .th-btn { all: unset; display: inline-flex; align-items: center; gap: 4px; width: 100%; box-sizing: border-box; padding: 8px 10px; cursor: pointer; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; }
th.r.sortable .th-btn { justify-content: flex-end; }
th.sortable .th-btn:hover, th.sortable .th-btn:focus-visible { color: var(--ink); background: var(--card-2); outline: none; }
th.sortable .arrow { display: inline-block; width: 10px; font-size: 10px; opacity: .35; }
th.sortable .arrow::after { content: "⇅"; }
th.sortable.asc .arrow::after { content: "▲"; } th.sortable.desc .arrow::after { content: "▼"; }
th.sortable.asc, th.sortable.desc { color: var(--amber); } th.sortable.asc .arrow, th.sortable.desc .arrow { opacity: 1; }
.sort-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.sort-label { white-space: nowrap; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 1px; margin-right: 4px; }
.chip { background: var(--card-2); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip:hover { color: var(--ink); border-color: var(--faint); }
.legend-btn { margin-left: auto; }
.legend-panel { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 16px; margin: 0 0 12px; }
.legend-panel h4, .legend-h { margin: 0 0 8px; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--amber); }
.legend-h { margin-top: 16px; }
.legend-panel dl, .legend-dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 18px; }
.legend-panel dl div, .legend-dl div { display: grid; grid-template-columns: 96px 1fr; gap: 8px; font-size: 13px; line-height: 1.45; padding: 4px 0; border-bottom: 1px solid var(--line); }
.legend-panel dt, .legend-dl dt { color: var(--ink); font-weight: 700; }
.legend-panel dd, .legend-dl dd { margin: 0; color: var(--muted); }
.chip.on { background: rgba(245,165,36,.16); color: #fcd38d; border-color: rgba(245,165,36,.5); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--card-2); }
.chart-box { position: relative; width: 100%; height: 380px; }
.chart-box.sm { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.list { margin: 0; padding-left: 18px; }
.list li { margin: 6px 0; color: var(--ink); }
.list.muted li { color: var(--muted); }
.warn { background: rgba(245,165,36,.1); border: 1px solid rgba(245,165,36,.35); border-radius: var(--r-sm); padding: 12px 14px; color: #fcd38d; }
.danger { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.35); border-radius: var(--r-sm); padding: 12px 14px; color: #fca5a5; }
.plan-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.plan-cell { background: var(--card-2); border-radius: var(--r-sm); padding: 12px; }
.plan-cell .l { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.plan-cell .v { font-family: var(--font-mono); font-size: 18px; font-weight: 600; margin-top: 4px; }
.plan-cell.entry { box-shadow: inset 0 0 0 1px rgba(96,165,250,.5); }
.plan-cell.stop { box-shadow: inset 0 0 0 1px rgba(239,68,68,.5); }
.plan-cell.target { box-shadow: inset 0 0 0 1px rgba(34,197,94,.5); }
.bias { font-family: var(--font-display); font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.bias.LONG { color: var(--green); } .bias.SHORT { color: var(--red); } .bias.NEUTRALE { color: var(--muted); }
.calc { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: end; }
.calc label { display: block; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.calc input { width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--ink); padding: 9px 10px; font-family: var(--font-mono); font-size: 15px; }
.calc-out { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--card-2); color: var(--muted); }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.price-big { font-family: var(--font-mono); font-size: 30px; font-weight: 600; }
details { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 14px; background: var(--card-2); }
details + details { margin-top: 8px; }
summary { cursor: pointer; font-weight: 700; }
details p { margin: 8px 0 0; color: var(--muted); }
.headline a { color: var(--blue); }
.headline .src { color: var(--faint); font-size: 12px; margin-right: 6px; font-weight: 700; }
.foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 30px; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 15; }
.geo-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.linkish { color: var(--amber); cursor: pointer; font-weight: 700; }
.mini-rank li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.mini-rank li:last-child { border-bottom: none; }
.mini-rank { list-style: none; margin: 0; padding: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g21, .g3 { grid-template-columns: 1fr; }
  .plan-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .calc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: var(--top-h); bottom: 0; left: 0; width: min(86vw, 340px); transform: translateX(-100%); transition: transform .25s ease; z-index: 16; }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; }
  .icon-btn { display: inline-flex; align-items: center; justify-content: center; }
  .live-pill { font-size: 11px; padding: 4px 8px; }
  .live-pill .full { display: none; } .live-pill .short { display: inline; }
  .geo-pill { display: none; }
  .topbar { gap: 8px; padding: 0 12px; } .topbar-right { gap: 8px; flex-shrink: 0; } .brand { min-width: 0; }
  .brand-sub, .updated { display: none; }
  .main { padding: 16px 14px 32px; }
  .g4, .g2 { grid-template-columns: 1fr 1fr; }
  .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 22px; }
  .chart-box { height: 300px; }
  h1 { font-size: 24px; }
  .bias { font-size: 28px; }
  table { font-size: 13px; }
  th, td { padding: 8px 6px; }
  th.sortable { padding: 0; } th.sortable .th-btn { padding: 8px 6px; }
  .sort-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .chip { flex: 0 0 auto; font-size: 14px; padding: 8px 14px; }
  .legend-btn { margin-left: 0; }
  .legend-panel dl div, .legend-dl div { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 480px) {
  .g4, .g2 { grid-template-columns: 1fr; }
  .calc, .calc-out { grid-template-columns: 1fr; }
}

.icon-btn.show { display: inline-flex; align-items: center; justify-content: center; }
/* pagina di accesso */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, rgba(245,165,36,.12), transparent), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; color: var(--ink); text-decoration: none; }
.login-card h1 { font-size: 24px; margin: 0 0 6px; font-family: var(--font-display); }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.field input { background: var(--bg-2); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 12px 14px; font-size: 16px; font-family: inherit; }
.field input:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: transparent; }
.btn-primary { width: 100%; background: var(--amber); color: #1a1200; border: 0; border-radius: 10px; padding: 13px; font-weight: 800; font-size: 16px; cursor: pointer; font-family: var(--font-display); letter-spacing: .3px; }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.login-err { color: #fca5a5; font-size: 14px; min-height: 20px; margin: 0 0 12px; }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---- editor portafoglio ---- */
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.btn-secondary { background: var(--card-2); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; font-size: 15px; }
.btn-secondary:hover { border-color: var(--amber); }
.btn-primary.inline { width: auto; padding: 11px 20px; font-size: 15px; }
.file-btn { display: inline-block; }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(4,8,20,.72); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.modal-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); width: min(1100px, 100%); max-height: 94vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal-head { display: flex; justify-content: space-between; gap: 16px; padding: 20px 22px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-family: var(--font-display); font-size: 24px; }
.modal-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 22px 6px; }
.modal-hint { color: var(--muted); font-size: 13px; flex: 1 1 260px; }
.modal-body { padding: 8px 22px 12px; overflow: auto; flex: 1 1 auto; }
.edit-table { width: 100%; border-collapse: collapse; }
.edit-table th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.edit-table th.r { text-align: right; }
.edit-table td { padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.edit-table input, .edit-table select { width: 100%; min-width: 70px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: inherit; font-size: 15px; }
.edit-table input.num { text-align: right; font-family: var(--font-mono); }
.edit-table input:focus, .edit-table select:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: transparent; }
.edit-table input.bad { border-color: var(--red); }
.edit-table td.name { min-width: 170px; } .edit-table td.sym { min-width: 110px; } .edit-table td.note { min-width: 160px; }
.edit-table .del { background: transparent; border: 1px solid var(--line); color: #fca5a5; border-radius: 8px; width: 38px; height: 38px; cursor: pointer; font-size: 16px; }
.edit-table .del:hover { border-color: var(--red); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 22px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-actions { display: flex; gap: 10px; margin-left: auto; }
.modal-foot .btn-primary { width: auto; padding: 12px 22px; }
.err { color: #fca5a5; font-weight: 600; font-size: 14px; min-height: 1.4em; }
.ok-note { color: #86efac; font-weight: 600; }
.pf-meta { color: var(--muted); font-size: 13px; }
.pf-missing { margin-top: 10px; color: #fcd38d; font-size: 14px; }
@media (max-width: 720px) {
  .modal { padding: 0; align-items: stretch; }
  .modal-box { max-height: 100vh; border-radius: 0; width: 100%; }
  .edit-table thead { display: none; }
  .edit-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .edit-table td { border: 0; padding: 0; }
  .edit-table td.name, .edit-table td.note { grid-column: 1 / -1; }
  .edit-table td::before { content: attr(data-l); display: block; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; }
  .edit-table td.act::before { content: none; }
}
