:root {
  --bg: #000000;
  --card: #161616;
  --card2: #1F1F1F;
  --text: #FFFFFF;
  --text2: #A1A1A6;
  --text3: #5E5E63;
  --sep: rgba(255, 255, 255, .09);
  --green: #32D74B;
  --green-bg: rgba(50, 215, 75, .15);
  --red: #FF453A;
  --red-bg: rgba(255, 69, 58, .15);
  --yellow: #FFB800;
  --yellow-bg: rgba(255, 184, 0, .14);
  --ink: #111111;
  --fill: rgba(255, 255, 255, .08);
  --radius: 22px;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 28px) calc(env(safe-area-inset-left) + 16px);
  user-select: none;
  -webkit-user-select: none;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.loader { min-height: 80vh; display: grid; place-items: center; }
.loader img { border-radius: 18px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; transform: scale(.96); } }

/* intestazione */
.top { display: flex; align-items: flex-end; justify-content: space-between; padding: 8px 4px 14px; }
.date { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .02em; }
h1 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin-top: 2px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 7px 11px; border-radius: 999px; background: var(--card); color: var(--text2); margin-bottom: 4px; white-space: nowrap; }
.badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.badge.on { color: var(--green); }
.badge.on i { background: var(--green); box-shadow: 0 0 0 0 var(--green); animation: live 1.8s infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(52,199,89,.6); } 70% { box-shadow: 0 0 0 7px rgba(52,199,89,0); } 100% { box-shadow: 0 0 0 0 rgba(52,199,89,0); } }

/* schede */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.label { font-size: 13px; font-weight: 600; color: var(--text2); }
.section { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 22px 4px 10px; display: flex; justify-content: space-between; align-items: baseline; }
.section small { font-size: 15px; font-weight: 400; color: var(--text2); }

/* saldo */
.hero .amount { font-size: 52px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin: 4px 0 10px; }
.hero .amount span { font-size: 30px; font-weight: 700; margin-left: 4px; color: var(--text2); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 700; padding: 5px 10px; border-radius: 999px; }
.pill.up { color: var(--green); background: var(--green-bg); }
.pill.down { color: var(--red); background: var(--red-bg); }
.pill.flat { color: var(--text2); background: var(--fill); }
.sub { font-size: 15px; color: var(--text2); margin-left: 8px; }
.stopbar { margin-top: 18px; }
.stopbar .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text2); margin-bottom: 8px; }
.stopbar .row b { color: var(--text); font-weight: 600; }
.track { position: relative; height: 8px; border-radius: 4px; background: var(--fill); overflow: visible; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--green); transition: width .6s ease; }
.track .fill.warn { background: var(--red); }
.track .mark { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--text3); border-radius: 1px; }

/* tre numeri */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: 18px; padding: 14px 12px; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat .v.up { color: var(--green); }
.stat .v.down { color: var(--red); }

/* posizioni aperte */
.empty { display: flex; align-items: center; gap: 12px; color: var(--text2); font-size: 15px; }
.empty .ic { width: 36px; height: 36px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; flex: none; }
.open-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.open-row + .open-row { border-top: 1px solid var(--sep); margin-top: 12px; padding-top: 12px; }
.open-row .t { font-size: 17px; font-weight: 600; }
.open-row .s { font-size: 13px; color: var(--text2); margin-top: 2px; }
.open-row .p { font-size: 20px; font-weight: 700; white-space: nowrap; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-right: 6px; vertical-align: 2px; animation: pulse 1.2s infinite; }

/* grafico */
.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--text2); padding: 7px 0; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--yellow); color: var(--ink); }
.chart svg { display: block; width: 100%; height: 150px; overflow: visible; }
.chart .axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--text3); margin-top: 6px; }
.chart .big { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.chart .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }

/* lista operazioni */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.op { display: flex; align-items: center; gap: 12px; padding: 13px 16px; }
.op + .op { border-top: 1px solid var(--sep); margin-left: 60px; padding-left: 0; }
.op + .op .dot { margin-left: -44px; }
.op .dot { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 14px; font-weight: 800; }
.op .dot.up { background: var(--green-bg); color: var(--green); }
.op .dot.down { background: var(--red-bg); color: var(--red); }
.op .dot.flat { background: var(--fill); color: var(--text2); }
.op .mid { flex: 1; min-width: 0; }
.op .t { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op .s { font-size: 13px; color: var(--text2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op .p { font-size: 17px; font-weight: 700; white-space: nowrap; }
.p.up { color: var(--green); }
.p.down { color: var(--red); }
.p.flat { color: var(--text2); font-weight: 600; font-size: 15px; }
.more { display: block; width: 100%; border: 0; background: transparent; color: var(--yellow); font: inherit; font-size: 16px; padding: 14px; border-top: 1px solid var(--sep); cursor: pointer; }

/* azioni */
.cta { display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px; font: inherit; font-size: 17px; font-weight: 700; background: var(--yellow); color: var(--ink); cursor: pointer; }
.cta:active { transform: scale(.98); }
.cta.ghost { background: var(--fill); color: var(--text); font-weight: 600; }
.note { font-size: 13px; color: var(--text2); line-height: 1.4; margin-top: 10px; text-align: center; }
.notify { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.notify .ic { width: 44px; height: 44px; border-radius: 12px; flex: none; background: var(--yellow); display: grid; place-items: center; }
.notify b { display: block; font-size: 16px; }
.notify span { font-size: 13px; color: var(--text2); }
.foot { text-align: center; font-size: 13px; color: var(--text3); margin-top: 22px; line-height: 1.6; }
.foot button { border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }

/* accesso */
.login { min-height: 82vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 10px; }
.login img { border-radius: 26px; box-shadow: 0 10px 40px rgba(255,184,0,.25); margin-bottom: 14px; }
.login h1 { font-size: 30px; }
.login p { color: var(--text2); font-size: 15px; margin-bottom: 14px; }
.login form { width: 100%; max-width: 340px; }
.login input { width: 100%; border: 0; border-radius: 14px; padding: 15px; font: inherit; font-size: 19px; text-align: center; letter-spacing: .12em; background: var(--card); color: var(--text); margin-bottom: 12px; text-transform: uppercase; user-select: text; -webkit-user-select: text; }
.login input:focus { outline: 2px solid var(--yellow); }
.err { color: var(--red); font-size: 14px; min-height: 20px; }

/* banner installazione (solo in Safari) */
.install { display: flex; gap: 12px; align-items: center; }
.install img { border-radius: 12px; flex: none; }
.install b { display: block; font-size: 16px; }
.install span { font-size: 13px; color: var(--text2); line-height: 1.35; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%) translateY(20px); background: rgba(30,30,30,.92); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; opacity: 0; transition: .3s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* accenti giallo */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 9px; }
.hero { background: linear-gradient(180deg, #1C1A12 0%, var(--card) 100%); border: 1px solid rgba(255,184,0,.18); }
.hero .label { color: var(--yellow); }
.track .mark { background: var(--yellow); }
.date { color: var(--yellow); }
.logo { font-weight: 900; letter-spacing: -.035em; }
.logo span { color: var(--yellow); }
.login .logo { font-size: 38px; }
