/* w4113ts: stessi colori dell'app BTC Wallet Monitor, solo tema scuro */
:root {
  --bg: #0F0F0F;
  --card: #1A1A1A;
  --card-hi: #222222;
  --border: #2D2D2D;
  --green: #00854D;
  --green-text: #2FBF7F;
  --red: #CD4949;
  --red-text: #E06666;
  --text: #FFFFFF;
  --muted: #8C8C8C;
  --btc: #F7931A;
  --eth: #8A9BFF;
  --sol: #14F195;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--green-text); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green-text); outline-offset: 2px; }

/* ── barra in alto, come l'AppBar ── */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(15, 15, 15, .92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: .5px; font-family: var(--mono); }
.brand img { border-radius: 8px; }
.bar-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 10px; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--card); color: var(--text); }
.icon-btn .ico-eye-off { display: none; }
.icon-btn[aria-pressed="true"] { color: var(--btc); }
.icon-btn[aria-pressed="true"] .ico-eye { display: none; }
.icon-btn[aria-pressed="true"] .ico-eye-off { display: block; }

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ── totale ── */
.total {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px 14px; margin-bottom: 24px;
}
.total-label { margin: 0; color: var(--muted); font-size: 13px; }
.total-value { margin: 2px 0 12px; font-size: 34px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.prices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.price {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
  padding: 7px 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border);
  font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.price b { font-weight: 700; font-size: 12px; }
.price small { font-size: 12px; }

.up { color: var(--green-text); }
.down { color: var(--red-text); }
.sync { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }

/* ── pulsanti ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 600;
  text-decoration: none;
}
.btn:hover { background: var(--card-hi); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--green); border-color: var(--green); }
.btn-primary:hover { background: #00965A; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--red-text); border-color: rgba(205, 73, 73, .5); }
.btn-block { display: flex; width: 100%; margin-top: 10px; }
.btn-refresh { background: var(--bg); }
.btn-refresh.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-refresh.spin svg { animation: none; } }

/* ── sezioni ── */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
h2 { margin: 0; font-size: 17px; font-weight: 700; }
select {
  max-width: 55%; height: 34px; padding: 0 10px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
}

/* ── portafogli: bordo e icona nel colore scelto, come nell'app ── */
.wallet {
  --c: var(--btc);
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 12px; margin-bottom: 10px; border-radius: var(--radius);
  background: var(--card); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.w-ico {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c);
  font-weight: 800; font-size: 18px; border: 0; cursor: pointer; padding: 0;
}
.w-main { min-width: 0; }
.w-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.w-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coin-tag { flex: none; font-size: 10px; font-weight: 700; letter-spacing: .4px; padding: 1px 6px; border-radius: 6px; border: 1px solid currentColor; }
.coin-btc { color: var(--btc); }
.coin-eth { color: var(--eth); }
.coin-sol { color: var(--sol); }
.w-addr {
  display: block; max-width: 100%; margin-top: 2px; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--muted); font: 11px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;
}
.w-addr:hover { color: var(--text); }
.w-err { margin-top: 4px; color: var(--red-text); font-size: 12px; }
.linkish { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; cursor: pointer; font-size: 12px; }
.w-bal { text-align: right; font-variant-numeric: tabular-nums; }
.w-coin { color: var(--c); font-weight: 700; font-size: 15px; white-space: nowrap; }
.w-eur { color: var(--muted); font-size: 12px; white-space: nowrap; }
.w-loading { color: var(--muted); font-size: 12px; }
.tokens { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.token { font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 2px 8px; font-variant-numeric: tabular-nums; }
.token b { color: var(--text); font-weight: 600; }
.w-links { grid-column: 2 / -1; display: flex; gap: 14px; font-size: 12px; }
.w-links a, .w-links button { color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none; font-size: 12px; }
.w-links a:hover, .w-links button:hover { color: var(--text); }

.empty { text-align: center; color: var(--muted); padding: 28px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-title { color: var(--text); font-weight: 600; font-size: 17px; margin: 0 0 6px; }
.empty p { margin: 0; }

/* ── movimenti ── */
section + section { margin-top: 26px; }
.txs { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tx { border-bottom: 1px solid var(--border); }
.tx:last-child { border-bottom: 0; }
.tx a { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; color: var(--text); text-decoration: none; }
.tx a:hover { background: var(--card-hi); }
.tx-dir { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }
.tx-in .tx-dir { background: rgba(0, 133, 77, .18); color: var(--green-text); }
.tx-out .tx-dir { background: rgba(205, 73, 73, .16); color: var(--red-text); }
.tx-who { min-width: 0; }
.tx-who b { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-who small { color: var(--muted); font-size: 12px; }
.tx-amt { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.tx-in .tx-amt b { color: var(--green-text); }
.tx-out .tx-amt b { color: var(--red-text); }
.tx-amt small { display: block; color: var(--muted); font-size: 12px; }
.pending { color: var(--btc); }
.tx-empty { padding: 14px; color: var(--muted); font-size: 13px; }

.note { margin: 28px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.foot { max-width: 640px; margin: 0 auto; padding: 20px 16px 32px; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--text); }

/* ── finestre ── */
dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0; border-radius: 16px;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
}
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog form, .dlg-body { padding: 18px; }
dialog h3 { margin: 0 0 14px; font-size: 18px; }
dialog label, .label-like { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
dialog label.btn { display: flex; margin: 10px 0 0; color: var(--text); font-size: 14px; }
dialog input {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
}
#f-address { font-family: var(--mono); font-size: 13px; }
dialog input:focus { border-color: var(--green); outline: none; }
.detect { min-height: 18px; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.detect.ok { color: var(--green-text); }
.detect.bad { color: var(--red-text); }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { background: var(--c); width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch[aria-checked="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--card) inset; }
.dlg-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 20px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 420px) {
  .total-value { font-size: 30px; }
  .wallet { grid-template-columns: 40px 1fr auto; gap: 10px; }
  .w-ico { width: 40px; height: 40px; }
}
