/* ============================================================
   Portafoglio Bot — tema scuro, pensato prima per il telefono.
   ============================================================ */

:root {
  --bg: #0b0d12;
  --card: #131720;
  --card-2: #171c27;
  --line: #232936;
  --text: #e8ecf3;
  --muted: #8b93a7;
  --green: #21c77a;
  --red: #ff5f5f;
  --accent: #4c7dff;
  --radius: 16px;
  --content-width: 520px; /* più largo su tablet/desktop, vedi il media query più sotto */
}

@media (min-width: 640px) {
  :root { --content-width: 720px; }
}

* { box-sizing: border-box; }

button, input { font-family: inherit; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 16px 32px;
}

h2 {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}

/* ---------------- schermata chiave ---------------- */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 22px;
}

.gate-logo {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--accent), #7d4cff);
  margin-bottom: 16px;
}

.gate-card h1 { font-size: 1.35rem; margin: 0 0 10px; }

.gate-text { color: var(--muted); font-size: .92rem; line-height: 1.55; margin: 0 0 18px; }

#gateForm { display: flex; flex-direction: column; gap: 10px; }

input[type=password] {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* 16px = niente zoom automatico su mobile */
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

input[type=password]:focus { outline: none; border-color: var(--accent); }

#gateBtn {
  padding: 13px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

#gateBtn:disabled { opacity: .55; cursor: default; }

.gate-error {
  margin: 14px 0 0;
  padding: 11px 13px;
  border-radius: 11px;
  background: rgba(255, 95, 95, .12);
  border: 1px solid rgba(255, 95, 95, .3);
  color: #ffb3b3;
  font-size: .88rem;
  line-height: 1.5;
}

.gate-help { margin-top: 20px; color: var(--muted); font-size: .86rem; }
.gate-help summary { cursor: pointer; color: var(--accent); }
.gate-help ol { padding-left: 20px; line-height: 1.7; }
.gate-help b { color: var(--text); font-weight: 600; }

/* ---------------- barra in alto ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 6px;
}

.brand { font-size: .95rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), #7d4cff);
}

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
}

/* ---------------- numero grande ---------------- */

.hero { padding: 18px 0 10px; }

.hero-label { color: var(--muted); font-size: .84rem; margin-bottom: 6px; }

.equity {
  font-size: clamp(2.4rem, 11vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  transition: color .35s ease;
  line-height: 1.1;
}

.equity.up { color: var(--green); }
.equity.down { color: var(--red); }

.deltas { margin-top: 10px; font-size: .95rem; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.delta { font-variant-numeric: tabular-nums; font-weight: 600; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.muted, .sep { color: var(--muted); font-weight: 400; }

/* ---------------- grafico ---------------- */

.chart-wrap { margin: 10px -4px 0; position: relative; }
.chart-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
#chart { height: 210px; width: 100%; }

.ranges { display: flex; gap: 8px; margin: 10px 0 22px; }

.range {
  flex: 1;
  padding: 9px 0;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--card);
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}

.range.is-active { background: var(--card-2); color: var(--text); border-color: var(--line); }

/* ---------------- posizioni ---------------- */

.block { margin-bottom: 26px; }

.pos {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.pos-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .78rem;
  font-weight: 700;
  color: #0b0d12;
  flex: none;
}

.pos-icon.btc { background: #f7931a; }
.pos-icon.eth { background: #8f9eff; }
.pos-icon.other { background: #6c7688; }

.pos-main { flex: 1; min-width: 0; }
.pos-name { font-weight: 600; font-size: .96rem; }
.pos-sub { color: var(--muted); font-size: .8rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.pos-right { text-align: right; font-variant-numeric: tabular-nums; }
.pos-value { font-weight: 600; font-size: .96rem; }
.pos-pl { font-size: .8rem; margin-top: 3px; }
.pos-pl.up { color: var(--green); }
.pos-pl.down { color: var(--red); }

.cash {
  display: flex;
  justify-content: space-between;
  padding: 13px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .88rem;
}

.cash b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------------- operazioni ---------------- */

.trade {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}

.trade:last-child { border-bottom: 0; }

.trade-side {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: .95rem;
  flex: none;
}

.trade-side.buy { background: rgba(33, 199, 122, .14); color: var(--green); }
.trade-side.sell { background: rgba(255, 95, 95, .14); color: var(--red); }

.trade-main { flex: 1; min-width: 0; }
.trade-title { font-size: .92rem; font-weight: 500; }
.trade-sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.trade-val { font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--muted); }

.empty { color: var(--muted); font-size: .88rem; padding: 8px 0; }

/* ---------------- stato in fondo ---------------- */

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .78rem;
  padding-top: 6px;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.status-dot.live { background: var(--green); box-shadow: 0 0 0 3px rgba(33, 199, 122, .15); }
.status-dot.warn { background: #f0b429; }
.status-dot.off { background: var(--red); }

/* ---------------- foglio impostazioni ---------------- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: grid;
  place-items: end center;
  z-index: 50;
}

.sheet-card {
  width: 100%;
  max-width: var(--content-width);
  background: var(--card);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border: 1px solid var(--line);
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
}

.sheet-card h2 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1.1rem; margin-bottom: 16px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 20px; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; word-break: break-all; }

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
}

.btn.danger { color: #ffb3b3; border-color: rgba(255, 95, 95, .3); background: rgba(255, 95, 95, .1); }

.sheet-note { color: var(--muted); font-size: .8rem; line-height: 1.5; margin: 14px 0 0; }

[hidden] { display: none !important; }

/* ================================================================
   AVVISI — nuova operazione, invito a installare.
   ================================================================ */

.banners { position: relative; z-index: 45; }

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  font-size: .86rem;
}

.banner span:not(.dot) { flex: 1; }

.banner .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  flex: none;
}

.banner button {
  background: rgba(255, 255, 255, .16);
  border: 0;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  color: inherit;
}

.banner .banner-close {
  background: transparent;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0 4px;
}

.banner-trade { background: linear-gradient(135deg, var(--accent), #7d4cff); color: #fff; }

.banner-install { background: var(--card-2); border-bottom: 1px solid var(--line); color: var(--text); }
.banner-install .banner-action { background: var(--accent); color: #fff; }
.banner-install .banner-close { color: var(--muted); }

/* ================================================================
   NAVIGAZIONE — 5 pagine, barra fissa in basso.
   ================================================================ */

.view { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

.page-title { font-size: 1.3rem; font-weight: 700; margin: 6px 0 18px; }

.bottombar {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: var(--content-width); /* altrimenti su schermo largo si allarga a tutta la finestra */
  transform: translateX(-50%);
  z-index: 40; /* sotto al foglio impostazioni (50) */
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.navbtn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 600;
  padding: 6px 2px;
  cursor: pointer;
}

.navbtn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.navbtn.is-active { color: var(--accent); }

/* ================================================================
   HOME — riepilogo statistiche e link "vedi tutte".
   ================================================================ */

.summary-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.summary-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
}

.summary-row:nth-last-of-type(1) { border-bottom: 0; }
.summary-row.up { color: var(--green); }
.summary-row.down { color: var(--red); }

.summary-link, .see-all {
  display: block;
  margin-top: 10px;
  color: var(--accent);
  font-size: .86rem;
  font-weight: 600;
  text-decoration: none;
}

.see-all { text-align: center; padding-top: 6px; }

/* ================================================================
   STATISTICHE
   ================================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
}

.stat-tile .label { color: var(--muted); font-size: .76rem; margin-bottom: 6px; }
.stat-tile .value { font-size: 1.02rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat-tile .value.up { color: var(--green); }
.stat-tile .value.down { color: var(--red); }

.stat-note {
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.5;
  margin-top: 16px;
}

/* Barre delle operazioni chiuse: sopra la linea se in guadagno, sotto se in perdita. */

.pl-chart {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 10px;
  height: 120px;
  margin: 4px 4px 28px;
}

.pl-chart::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px dashed var(--line);
}

.pl-col { flex: 1; position: relative; }

.pl-bar {
  position: absolute;
  left: 22%;
  right: 22%;
  border-radius: 3px;
  min-height: 3px;
}

.pl-bar.up { bottom: 50%; background: var(--green); }
.pl-bar.down { top: 50%; background: var(--red); }

.pl-label {
  position: absolute;
  bottom: -20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: .68rem;
  color: var(--muted);
}

/* ================================================================
   CONFRONTO BTC/ETH
   ================================================================ */

.compare-card { margin-bottom: 26px; }
.compare-card h2 { font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--text); margin-bottom: 10px; }

.mini-chart { height: 160px; width: 100%; }

.compare-info {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: .85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.compare-info .up { color: var(--green); font-weight: 600; }
.compare-info .down { color: var(--red); font-weight: 600; }

/* ================================================================
   COME FUNZIONA
   ================================================================ */

.prose { font-size: .92rem; line-height: 1.6; }
.prose p { color: var(--text); margin: 0 0 14px; }
.prose h3 { font-size: .95rem; margin: 20px 0 8px; }
.prose ul { margin: 0 0 14px; padding-left: 20px; color: var(--text); }
.prose li { margin-bottom: 8px; }
.prose b { font-weight: 600; }

/* ================================================================
   PROTEZIONE E SEGNALE — stop-loss e medie mobili
   ================================================================ */

.pos { flex-wrap: wrap; }

.pos-guard {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}

.pos-guard b { color: var(--text); font-weight: 600; }

.chip {
  flex: none;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.chip.up { color: var(--green); border-color: rgba(33, 199, 122, .35); background: rgba(33, 199, 122, .08); }
.chip.down { color: var(--red); border-color: rgba(255, 95, 95, .35); background: rgba(255, 95, 95, .08); }

.summary-k { color: var(--muted); margin-right: 4px; }
.summary-row b.up { color: var(--green); }
.summary-row b.down { color: var(--red); }

.compare-info { flex-direction: column; gap: 6px; }
.compare-row { display: flex; justify-content: space-between; gap: 10px; }

.stat-tile .value small { font-size: .78rem; font-weight: 600; opacity: .85; }

/* le lettere A / V delle operazioni */
.trade-side { font-weight: 700; font-size: .82rem; }
.trade-val.up { color: var(--green); }
.trade-val.down { color: var(--red); }

/* ================================================================
   DEMO
   ================================================================ */

.gate-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: .8rem;
}

.gate-or::before, .gate-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

#demoBtn { margin-bottom: 0; font-weight: 500; }

.btn.ghost:hover { border-color: var(--accent); }

.banner-demo { background: rgba(240, 180, 41, .14); border-bottom: 1px solid rgba(240, 180, 41, .35); color: #f5cf6b; }
.banner-demo .dot { background: #f0b429; }
.banner-demo .banner-action { background: rgba(240, 180, 41, .2); }

/* ---------------- oro (PAXG) ---------------- */
.pos-icon.gold { background: linear-gradient(140deg, #f5d77a, #c99a2e); }
.muted-small { color: var(--muted); font-weight: 400; font-size: .78rem; }

/* punto di partenza in euro, sotto il numero grande */
.start-line { margin-top: 6px; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.start-line[hidden] { display: none; }
