:root {
  --bg: #000;
  --panel: #0e0e0e;
  --line: #2a2410;
  --gold: #f5c211;
  --gold-soft: #c9a227;
  --text: #f4ecd2;
  --muted: #8a7f5f;
  --pos: #5fd38a;
  --neg: #ff6b6b;
  --radius: 4px;
  --font: "League Spartan", "Futura", "Century Gothic", "Avenir Next", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 17px;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }

.screen { max-width: 480px; margin: 0 auto; padding: 0 22px 40px; }

/* ---------- login ---------- */
#login { min-height: 100dvh; display: flex; align-items: center; }
.login-box { width: 100%; display: flex; flex-direction: column; align-items: center; }
.logo {
  font-size: 150px; line-height: 1; font-weight: 800; color: var(--gold);
  margin-bottom: 44px; text-shadow: 0 0 40px rgba(245, 194, 17, .18);
}
.field.token-field {
  height: 88px; text-align: center; font-size: 22px; letter-spacing: .08em;
  background: #fff; color: #000;
}
.field.token-field:focus { box-shadow: 0 0 0 4px rgba(245, 194, 17, .25); }
.login-label { margin: 34px 0 10px; color: var(--gold); font-weight: 700; font-size: 30px; }
.login-box .btn { margin-top: 18px; }

/* ---------- controlli ---------- */
.label {
  display: block; margin: 26px 0 8px; color: var(--gold);
  font-weight: 700; font-size: 30px; line-height: 1;
}
.field {
  width: 100%; min-height: 56px; padding: 14px 16px;
  font: inherit; font-size: 19px; color: var(--text);
  background: var(--bg); border: 3px solid var(--gold); border-radius: var(--radius);
  outline: none; -webkit-appearance: none; appearance: none;
  transition: box-shadow .15s;
}
.field:focus { box-shadow: 0 0 0 4px rgba(245, 194, 17, .18); }
textarea.field { resize: vertical; min-height: 96px; }
.amount-wrap { position: relative; }
.amount-wrap .field { padding-right: 44px; font-variant-numeric: tabular-nums; }
.currency { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--gold); font-weight: 700; }

.btn {
  width: 100%; min-height: 56px; margin-top: 30px;
  background: var(--gold); color: #000; font-weight: 800; font-size: 21px;
  border-radius: var(--radius); letter-spacing: .03em;
  transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.98); filter: brightness(.9); }
.btn:disabled { opacity: .5; }
.btn.small { min-height: 42px; margin: 0; font-size: 17px; width: auto; padding: 0 18px; }
.btn.ghost { background: transparent; color: var(--gold); border: 2px solid var(--gold); }
.link { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 8px; }
.link.danger { color: var(--neg); margin-top: 28px; }
.error { color: var(--neg); min-height: 1.2em; margin: 10px 0 0; font-size: 15px; }

/* select personalizzata, come nel disegno */
.select { position: relative; }
.select-btn { display: flex; align-items: center; justify-content: space-between; text-align: left; }
.chevron { width: 30px; height: 30px; fill: none; stroke: var(--gold); stroke-width: 2.6; transition: transform .2s; flex: none; }
.select-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.select-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% - 3px);
  margin: 0; padding: 0; list-style: none; background: var(--bg);
  border: 3px solid var(--gold); border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 18px 40px rgba(0,0,0,.8); max-height: 50vh; overflow-y: auto;
}
.select-list li {
  padding: 18px 16px; color: var(--gold); font-weight: 700; font-size: 19px;
  border-top: 2px solid var(--gold); cursor: pointer;
}
.select-list li:first-child { border-top: 0; }
.select-list li[aria-selected="true"] { background: var(--gold); color: #000; }
.select-list li:active { background: #1a1605; }

/* ---------- barra superiore ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 14px 0; background: linear-gradient(var(--bg) 80%, transparent);
}
.brand { font-size: 36px; font-weight: 800; color: var(--gold); width: 44px; height: 44px; line-height: 44px; }
.tabs { flex: 1; display: flex; border: 2px solid var(--gold); border-radius: 999px; padding: 3px; }
.tab {
  flex: 1; min-height: 40px; border-radius: 999px; color: var(--gold);
  font-weight: 700; font-size: 17px; transition: background .2s, color .2s;
}
.tab.active { background: var(--gold); color: #000; }

.banner {
  display: flex; flex-direction: column; gap: 12px; margin: 6px 0 4px; padding: 14px 16px;
  border: 1px solid var(--gold-soft); border-radius: var(--radius); background: #0d0b03; font-size: 15px;
}
.banner-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- saldo ---------- */
.balance {
  width: 100%; display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 0 12px; border-bottom: 1px solid var(--line); text-align: left;
}
.balance-label { color: var(--muted); font-size: 15px; letter-spacing: .08em; text-transform: uppercase; }
.balance-total { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.balance-detail { list-style: none; margin: 0; padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.balance-detail li { display: flex; justify-content: space-between; padding: 7px 0; font-size: 16px; }
.balance-detail small { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--muted); }

/* ---------- lista ---------- */
.table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 15px; }
.table th {
  text-align: left; color: var(--gold); font-weight: 700; font-size: 13px; letter-spacing: .08em;
  text-transform: uppercase; padding: 10px 6px; border-bottom: 2px solid var(--gold);
}
.table td { padding: 15px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:active { background: #121005; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.table td:nth-child(2) { color: var(--muted); white-space: nowrap; }
.table td:nth-child(3) { word-break: break-word; }
.empty { color: var(--muted); text-align: center; margin-top: 60px; }

/* ---------- dettaglio ---------- */
.back { width: 48px; height: 48px; margin: 4px 0 0 -10px; display: grid; place-items: center; }
.back svg { width: 34px; height: 34px; fill: none; stroke: var(--gold); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.d-title { font-size: 36px; color: var(--gold); margin: 8px 0 4px; line-height: 1.05; word-break: break-word; }
.d-meta { color: var(--muted); margin: 0 0 20px; }
.d-grid { display: grid; grid-template-columns: 1fr auto; margin: 0; border-top: 2px solid var(--gold); }
.d-grid dt, .d-grid dd { padding: 14px 0; border-bottom: 1px solid var(--line); margin: 0; }
.d-grid dt { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 14px; align-self: center; }
.d-grid dd { font-size: 24px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.d-shares { list-style: none; margin: 0; padding: 0; }
.d-shares li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.d-note { white-space: pre-wrap; margin: 0; color: var(--text); }
.d-note:empty::before { content: "—"; color: var(--muted); }
#view-detail .label { font-size: 22px; margin-top: 28px; }

/* ---------- menu e toast ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.7); display: flex; align-items: flex-end; }
.sheet-box {
  width: 100%; max-width: 480px; margin: 0 auto; padding: 26px 22px calc(26px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 3px solid var(--gold); display: flex; flex-direction: column; gap: 12px;
  animation: up .2s ease-out;
}
.sheet-box .btn { width: 100%; margin: 0; min-height: 52px; }
.sheet-user { margin: 0; font-size: 22px; }
.sheet-user strong { color: var(--gold); }
.sheet-note { margin: 0 0 6px; color: var(--muted); font-size: 15px; }
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--gold); color: #000; font-weight: 700; padding: 12px 22px; border-radius: 999px;
  z-index: 60; animation: up .2s ease-out;
}
@keyframes up { from { transform: translate(var(--tx, 0), 20px); opacity: 0; } }
.toast { --tx: -50%; }
