/* ==========================================================================
   GrailDex — Design System "Vault"
   Direzione: ledger da appraiser — ottone invecchiato come unico accento
   saturo, grafite fredda sotto. Fraunces (numeri/titoli che contano),
   Archivo (UI/corpo), JetBrains Mono (dati tabellari/prezzi/SKU). Sostituisce
   il precedente sistema (Instrument Sans + IBM Plex Mono, duotone viola/
   turchese) dopo bocciatura utente 2026-07-23 — mockup approvato:
   https://claude.ai/code/artifact/321c3c9e-2ceb-4d1a-9dd6-c31fbe208852
   ========================================================================== */

@font-face {
  font-family: 'Fraunces'; src: url('/static/fonts/fraunces.woff2') format('woff2');
  font-weight: 100 900; font-display: swap;
}
@font-face {
  font-family: 'Archivo'; src: url('/static/fonts/archivo.woff2') format('woff2');
  font-weight: 100 900; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono'; src: url('/static/fonts/jetbrainsmono.woff2') format('woff2');
  font-weight: 100 800; font-display: swap;
}

:root {
  /* Superfici — grafite fredda, non nero puro */
  --bg: #0a0b0e;
  --bg-elevated: #14161b;
  --bg-card: #1b1d26;
  --bg-hover: #272a36;
  --border: rgba(230, 228, 222, 0.10);
  --border-strong: rgba(230, 228, 222, 0.16);

  /* Testo — caldo freddo bilanciato, non bianco puro */
  --text: #ece8e0;
  --text-dim: #9b968c;
  --text-faint: #5c584f;

  /* Accento — ottone invecchiato, l'UNICO colore saturo della UI */
  --accent: #c9973f;
  --accent-bright: #e8b968;
  --accent-dim: rgba(201, 151, 63, 0.16);
  --accent-text: #14110a;

  /* Marchio "GrailDex" (mark + wordmark bicolore in topbar) — viola/teal
     di default, sovrascritti col colore del tipo quando un Pokemon
     preferito e' attivo (vedi app.py::_shell) */
  --brand-a: #8b7cf6;
  --brand-b: #2dd4bf;

  /* Semantici — smorzati, non neon */
  --positive: #6fb08a;
  --positive-dim: rgba(111, 176, 138, 0.14);
  --negative: #c1667e;
  --negative-dim: rgba(193, 102, 126, 0.14);
  --warning: #e8ab68;
  --warning-dim: rgba(232, 171, 104, 0.14);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -8px rgba(0,0,0,0.5);
  --shadow-float: 0 4px 12px rgba(0,0,0,0.4), 0 16px 40px -12px rgba(0,0,0,0.6);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font-ui: 'Archivo', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-display: 'Fraunces', serif;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 1200px 600px at 50% -10%, rgba(201,151,63,0.05), transparent);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(84px + env(safe-area-inset-bottom)); /* spazio per bottom nav mobile, +home indicator iPhone */
}

a { color: inherit; text-decoration: none; }

/* ── App shell / nav ─────────────────────────────────────────────────── */

.app-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: rgba(10,10,16,0.82);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.app-brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 17px; font-weight: 800; letter-spacing: -0.015em;
  text-decoration: none;
}
.app-brand .mark {
  width: 24px; height: 24px; flex-shrink: 0;
  filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--brand-b) 35%, transparent));
}
.app-brand .brand-a { color: var(--brand-a); }
.app-brand .brand-b { color: var(--brand-b); }

.app-nav {
  display: flex; gap: 2px;
}
.app-nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; text-decoration: none;
  color: var(--text-dim);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.app-nav a:hover { background: var(--bg-hover); color: var(--text); }
.app-nav a.active { background: var(--accent-dim); color: var(--accent-bright); }

.settings-link {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  color: var(--text-dim); transition: background .15s var(--ease), color .15s var(--ease);
  flex-shrink: 0;
}
.settings-link:hover { background: var(--bg-hover); color: var(--text); }

/* Bottom tab bar — mobile only */
.app-bottomnav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: rgba(18,16,12,0.92);
  backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid var(--border);
}
.app-bottomnav-row { display: flex; justify-content: space-around; }
.app-bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--text-faint);
  font-size: 10.5px; font-weight: 500; padding: 4px 10px; border-radius: 10px;
  transition: color .15s var(--ease);
}
.app-bottomnav a .icon { font-size: 19px; line-height: 1; }
.app-bottomnav a.active { color: var(--accent-bright); }

@media (max-width: 720px) {
  .app-nav { display: none; }
  .app-bottomnav { display: block; }
  body { padding-bottom: 78px; }
}

/* ── Sidebar gestionale (desktop) — layout ispirato a TCG Automate,
   riferimento utente 2026-07-23: sidebar fissa con logo, menu principale,
   sezione "Options" separata sotto. Visibile SOLO sulle pagine gestionale
   (Batch, Storico, Gestionale/Business — vedi app.py::_shell
   show_sidebar), e SOLO da desktop: su mobile resta la bottom-nav
   esistente, una sidebar fissa sprecherebbe troppo spazio su schermi
   stretti. */
.app-sidebar {
  display: none;
  position: fixed; top: 0; left: 0; bottom: 0; width: 216px; z-index: 15;
  background: var(--bg-elevated); border-right: 1px solid var(--border);
  padding: 20px 14px; overflow-y: auto;
}
.app-sidebar-brand {
  display: flex; align-items: center; gap: 8px; padding: 0 6px 18px;
  font-family: var(--font-display); font-size: 16px; font-weight: 800;
}
.app-sidebar-brand .mark { width: 22px; height: 22px; flex-shrink: 0; }
.app-sidebar-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-faint); padding: 14px 10px 6px;
}
.app-sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.app-sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; color: var(--text-dim);
  transition: background .12s var(--ease), color .12s var(--ease);
}
.app-sidebar nav a:hover { background: var(--bg-hover); color: var(--text); }
.app-sidebar nav a.active { background: var(--accent-dim); color: var(--accent-bright); font-weight: 600; }
.app-sidebar-divider { height: 1px; background: var(--border); margin: 10px 6px; }

@media (min-width: 960px) {
  .app-sidebar.show { display: block; }
  .with-sidebar .page { margin-left: 216px; max-width: 1240px; }
  .with-sidebar .app-topbar { margin-left: 216px; }
}

/* Sidebar a richiesta su mobile (< 960px) -- bottone hamburger in topbar,
   drawer a scomparsa sopra il contenuto (non sposta il layout come su
   desktop) + backdrop per chiudere toccando fuori. Prima la sidebar era
   raggiungibile SOLO da desktop, su iPhone alcune sezioni (es. "Valuta
   lotto") non erano trovabili in nessun modo -- feedback utente 2026-07-24. */
.sidebar-toggle-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  color: var(--text-dim); background: transparent; border: none; cursor: pointer;
  margin-right: 4px;
}
.sidebar-toggle-btn:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 14;
  background: rgba(0, 0, 0, 0.55);
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 959px) {
  .sidebar-toggle-btn { display: flex; }
  .app-sidebar.mobile-open {
    display: block; z-index: 16;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  }
}

/* ── Bottoni azione colorati (batch review, stile TCG Automate: ogni
   azione ha un colore distinto — viola/arancione/verde/blu — invece di
   bottoni tutti uguali) ───────────────────────────────────────────────── */
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.action-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: none;
  font-family: var(--font-ui); font-size: 13px; font-weight: 700; color: #fff;
  cursor: pointer; transition: filter .12s var(--ease), transform .1s var(--ease);
  text-decoration: none;
}
.action-btn:active { transform: scale(0.97); }
.action-btn:hover { filter: brightness(1.1); }
.action-btn-purple { background: #6d5ce8; }
.action-btn-orange { background: #d97b1f; }
.action-btn-green  { background: #1a9e6e; }
.action-btn-blue   { background: #2563c9; }

/* ── Tabella densa batch review (stile TCG Automate) ─────────────────── */
.batch-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.batch-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.batch-table th {
  text-align: left; padding: 10px 12px; color: var(--text-faint);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); background: var(--bg-elevated);
  position: sticky; top: 0;
}
.batch-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.batch-table tr:last-child td { border-bottom: none; }
.batch-table tr.row-review { background: var(--warning-dim); }
.batch-table .thumb { width: 46px; height: 64px; border-radius: 5px; object-fit: cover; display: block; cursor: zoom-in; }

/* ── Lightbox: click su foto carta -> ingrandita, in tutte le tabelle ──── */
.lightbox-overlay {
  display: none; position: fixed; inset: 0; z-index: 999;
  background: rgba(6, 6, 8, 0.88); cursor: zoom-out;
  align-items: center; justify-content: center; padding: 24px;
}
.lightbox-overlay.show { display: flex; }
.lightbox-overlay img {
  max-width: 92vw; max-height: 92vh; border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.batch-table .title-cell { white-space: normal; min-width: 200px; max-width: 320px; font-size: 12.5px; line-height: 1.35; }
.batch-table .title-cell b { font-weight: 600; }
.batch-table .sub { color: var(--text-faint); font-size: 11px; }
.batch-table select, .batch-table input {
  font-size: 12.5px; padding: 6px 7px;
}
.batch-table .btn-edit {
  background: #14161b; color: #fff; border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.batch-table .btn-del {
  background: transparent; color: var(--negative); border: none; cursor: pointer;
  padding: 4px;
}
.batch-table .market-price-cell .check-btn {
  display: inline-block; margin-top: 4px; background: #14161b; color: #fff;
  border-radius: 6px; padding: 3px 9px; font-size: 10.5px; font-weight: 600;
}

/* ── Tabella -> card impilate sotto 720px ────────────────────────────────
   Il layout denso stile TCG Automate presuppone schermo largo + pinch-zoom;
   su iPhone l'app installata come PWA (apple-mobile-web-app-capable) NON
   supporta lo zoom (limite iOS sulle web app standalone, non risolvibile
   via meta viewport) — motivo reale del feedback utente 2026-07-23 "non
   posso ingrandire la pagina". Fix: sotto 720px ogni riga diventa una card
   con etichetta+valore per campo (via data-label), niente piu' bisogno di
   zoommare o scorrere orizzontalmente per leggere/editare un prezzo. */
@media (max-width: 720px) {
  .batch-table-wrap { overflow-x: visible; border: none; background: none; }
  .batch-table { white-space: normal; }
  .batch-table tr:first-child { display: none; } /* header th, sostituita dai data-label */
  .batch-table tr {
    display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px; margin-bottom: 10px;
  }
  .batch-table td { display: block; padding: 0; border-bottom: none; }
  .batch-table td.cell-noflex:first-child { order: -2; }
  .batch-table td.cell-noflex:nth-child(2) { order: -1; }
  .batch-table .title-cell { width: 100%; max-width: none; order: -1; }
  .batch-table td[data-label] {
    flex: 1 1 128px; display: flex; flex-direction: column; gap: 4px;
  }
  .batch-table td[data-label]::before {
    content: attr(data-label); font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint);
  }
  .batch-table select, .batch-table input { width: 100%; font-size: 14px; padding: 9px 10px; }
  .batch-table .btn-del { padding: 8px; }
}

/* ── Layout primitives ───────────────────────────────────────────────── */

.page {
  max-width: 1040px; margin: 0 auto; padding: 28px 18px 40px;
  opacity: 0; animation: rise .4s var(--ease) forwards;
}
.page-narrow { max-width: 460px; }

.page-head { margin-bottom: 22px; }
.page-head h1 {
  font-family: var(--font-display); font-size: 26px; font-weight: 800;
  letter-spacing: -0.02em; margin: 0 0 4px;
}
.page-head p { margin: 0; color: var(--text-dim); font-size: 13.5px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stagger > * {
  opacity: 0; animation: rise .45s var(--ease) forwards;
}
.stagger > *:nth-child(1) { animation-delay: .03s; }
.stagger > *:nth-child(2) { animation-delay: .08s; }
.stagger > *:nth-child(3) { animation-delay: .13s; }
.stagger > *:nth-child(4) { animation-delay: .18s; }
.stagger > *:nth-child(5) { animation-delay: .23s; }
.stagger > *:nth-child(n+6) { animation-delay: .27s; }

/* ── Card ─────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
}
.card h2 {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-faint); margin: 0 0 12px;
}
a.card {
  text-decoration: none; color: inherit;
  transition: transform .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
}
a.card:hover { transform: translateY(-1px); border-color: var(--border-strong); background: var(--bg-hover); }
a.card:active { transform: translateY(0); }

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 18px; margin-top: 4px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background .12s var(--ease);
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(155deg, var(--accent-bright), var(--accent));
  color: var(--accent-text); font-weight: 700;
  box-shadow: 0 2px 6px rgba(201,151,63,0.25), 0 8px 20px -8px rgba(201,151,63,0.35);
}
.btn-primary:hover { box-shadow: 0 2px 10px rgba(201,151,63,0.35), 0 10px 28px -8px rgba(201,151,63,0.45); }

.btn-ghost {
  background: var(--bg-hover); color: var(--text); border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: #2b2620; }

.btn-danger {
  background: var(--negative-dim); color: #e58e92; border: 1px solid rgba(193,102,107,0.3);
}
.btn-sm { width: auto; padding: 7px 12px; font-size: 12.5px; margin-top: 0; }

/* ── Forms ────────────────────────────────────────────────────────────── */

label.field-label {
  display: block; margin: 14px 0 6px; font-size: 12.5px; font-weight: 500;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em;
}
input[type=text], input[type=number], input[type=file], select, textarea {
  width: 100%; box-sizing: border-box; padding: 11px 12px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  color: var(--text); border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: 14.5px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type=file] { padding: 9px 12px; cursor: pointer; }

/* ── Tables ───────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 8px 10px; color: var(--text-faint);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

.num, .money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Badges / status ──────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.badge-positive { background: var(--positive-dim); color: var(--positive); }
.badge-negative { background: var(--negative-dim); color: var(--negative); }
.badge-warning  { background: var(--warning-dim); color: var(--warning); }
.badge-neutral  { background: var(--bg-hover); color: var(--text-dim); }

.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }

/* ── Stat blocks (dashboard) ──────────────────────────────────────────── */

.stat-value {
  font-family: var(--font-display); font-size: 34px; font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 11px; color: var(--text-faint); margin-top: 4px; letter-spacing: .04em; text-transform: uppercase; }

.callout {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--warning-dim); border: 1px solid rgba(232,121,184,0.3);
  color: var(--warning); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 12.5px; font-weight: 500; margin-top: 10px;
}

/* ── Photo / scan components ──────────────────────────────────────────── */

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 44px 20px; text-align: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--bg-card); cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.dropzone:hover { border-color: var(--accent); background: var(--bg-hover); }
.dropzone.dropzone-active {
  border-color: var(--accent-bright); background: var(--bg-hover);
  border-style: solid;
}
.dropzone .icon { font-size: 34px; }
.dropzone .hint { color: var(--text-dim); font-size: 13px; }

.result-card {
  border-left: 3px solid var(--border-strong);
}
.result-card.ok   { border-left-color: var(--positive); }
.result-card.warn { border-left-color: var(--warning); }
.result-card.err  { border-left-color: var(--negative); }

.card-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }

/* ── Misc ─────────────────────────────────────────────────────────────── */

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono  { font-family: var(--font-mono); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.flex-row { display: flex; gap: 10px; align-items: center; }
.hr { height: 1px; background: var(--border); margin: 14px 0; border: none; }

/* ── List rows (set picker, ecc.) ─────────────────────────────────────── */

.list-scroll {
  max-height: 55vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card);
}
.list-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--border);
  color: var(--text); padding: 12px 14px; text-align: left; cursor: pointer;
  font-family: var(--font-ui); font-size: 13.5px;
  transition: background .12s var(--ease);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-hover); }
.list-row.selected { background: var(--accent-dim); }
.chip {
  color: var(--accent-bright); font-weight: 600; font-size: 11.5px;
  display: inline-block; min-width: 58px; font-family: var(--font-mono);
}

/* ── Empty state ──────────────────────────────────────────────────────── */

.empty-state {
  text-align: center; padding: 30px 16px; color: var(--text-faint); font-size: 13px;
}

/* ── Row-card (liste editabili dense: revisione batch, vendite) ─────────
   Alternativa a <table> per dataset con molte colonne su mobile: invece di
   scroll orizzontale (fastidioso in un flusso ripetuto 50 volte per batch),
   impila foto+identità sopra e controlli in una riga compatta sotto. ───── */

.row-card {
  display: flex; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border);
}
.row-card:last-child { border-bottom: none; }
.row-card-review { background: var(--warning-dim); border-left: 3px solid var(--warning); }
.row-card-main { flex: 1; min-width: 0; }
.row-card-title { font-weight: 600; font-size: 14.5px; margin-bottom: 1px; }
.row-card-sub { color: var(--text-faint); font-size: 12px; font-family: var(--font-mono); }
.row-card-controls {
  display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap;
}
.row-card-controls select,
.row-card-controls input {
  padding: 7px 8px; font-size: 12.5px; width: auto;
}
.field-compact-price { width: 68px !important; font-family: var(--font-mono); }
.field-compact-qty { width: 46px !important; font-family: var(--font-mono); }

/* ── Home "Il Ledger" ─────────────────────────────────────────────────── */
.ledger-hero-figure {
  font-family: var(--font-display); font-weight: 900; font-size: 48px;
  letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums;
}
.ledger-hero-figure .cents { font-size: 24px; color: var(--text-faint); }
.ledger-rail {
  display: flex; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
}
.ledger-rail-item { flex: 1; padding: 0 4px; border-right: 1px solid var(--border); }
.ledger-rail-item:last-child { border-right: none; }
.ledger-rail-item .lbl {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint);
}
.ledger-rail-item .val {
  font-family: var(--font-mono); font-weight: 600; font-size: 17px; margin-top: 5px;
}
.ledger-actions {
  display: flex; flex-direction: column; gap: 1px; background: var(--border);
  border-radius: var(--radius); overflow: hidden; margin-top: 14px;
}
.ledger-action {
  background: var(--bg-card); padding: 15px 16px; display: flex; align-items: center; gap: 13px;
  transition: background .12s var(--ease);
}
.ledger-action:hover { background: var(--bg-hover); }
.ledger-action .ic {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-dim); color: var(--accent-bright); flex-shrink: 0;
}
.ledger-action .tx b { display: block; font-size: 13.5px; font-weight: 600; }
.ledger-action .tx span { font-size: 11.5px; color: var(--text-faint); }
.ledger-action .go { margin-left: auto; color: var(--text-faint); }

/* ── Home tile grandi (Scan/Collezione/Enciclopedia/Grading) — feedback
   utente 2026-07-25: "li vorrei non cosi schematici magari un po piu
   grandi e belli con un icona al loro interno a tema", poi corretto:
   "colore deve seguire tema o nessun tema ma non un bianco casuale" —
   BUG REALE: prima ogni tile aveva un colore FISSO indipendente
   (teal/oro/viola) mentre il resto della pagina cambia col Pokemon
   preferito (.page.themed) — con un tema attivo le tile sembravano
   scollegate/casuali per contrasto. Ora: nessun tema -> un solo accento
   neutro coerente per tutte; tema attivo -> tutte seguono --th-bright,
   la stessa variabile che colora hero/badge/glow altrove nella pagina. */
.home-tiles {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-top: 16px;
}
.home-tile {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px; padding: 24px 12px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  transition: transform .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
}
.home-tile:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.home-tile:active { transform: translateY(0); }
.home-tile-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--accent-dim); color: var(--accent-bright);
  border: 1px solid color-mix(in srgb, var(--accent-bright) 35%, transparent);
  margin: 0 auto 2px;
}
.home-tile-label { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.home-tile-sub { font-size: 11px; color: var(--text-faint); line-height: 1.3; }

.page.themed .home-tile-icon {
  background: color-mix(in srgb, var(--th-bright) 18%, transparent);
  color: var(--th-bright);
  border-color: color-mix(in srgb, var(--th-bright) 45%, transparent);
}
.page.themed .home-tile:hover { background: color-mix(in srgb, var(--th-bright) 6%, var(--bg-card)); }

/* ── Tema Pokemon preferito v3 (vedi themes.py per la storia completa
   delle revisioni) — hero cinematico PERSISTENTE in cima alla Home,
   mockup approvato dall'utente 2026-07-23:
   https://claude.ai/code/artifact/0959b1cd-8e74-4548-9281-8891afd87b5d
   Artwork ufficiale grande (non piu' sprite pixel come protagonista) +
   raggi rotanti + bagliore + galleggiamento reale + headline a rotazione. */

/* Reperto in teca — SOLO nel picker Impostazioni (vedi themes.py
   render_specimen_case): cerchio con bagliore, sprite Showdown animato
   nitido (pixel art nativa, mai ingrandita a sfocarsi). */
.specimen-case {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 38% 30%, color-mix(in srgb, var(--sp-color) 22%, var(--bg-elevated)), var(--bg) 75%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sp-bright) 45%, transparent),
              0 0 18px -4px color-mix(in srgb, var(--sp-bright) 60%, transparent);
  flex-shrink: 0;
}
.specimen-case img { image-rendering: pixelated; object-fit: contain; }

/* Hero cinematico Home — full-bleed, sotto la topbar, sopra il contenuto
   ledger. Altezza fissa ma contenuta (non deve spingere giu' tutto il
   resto su schermi piccoli).

   Opacita' degli effetti colore ALZATE (era 14-26%, feedback utente
   2026-07-23: "i colori trasparenti non fanno giustizia, si vedono
   troppo poco, giallo su nero" — su fondo quasi nero un color-mix a
   bassa percentuale scompare quasi del tutto, anche con colori accesi
   come il giallo Elettro). Bagliori/testo usano SEMPRE --th-bright (mai
   --th-color grezzo attenuato), che e' garantito luminoso per tutti e 18
   i temi (L>=0.55 in HSL, verificato). */
.hero {
  position: relative; height: 46vh; min-height: 340px; max-height: 460px;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 8%, color-mix(in srgb, var(--th-bright) 40%, var(--bg)) 0%, var(--bg) 65%);
}
.hero-sunburst {
  position: absolute; inset: -20%;
  background: repeating-conic-gradient(from 0deg,
    color-mix(in srgb, var(--th-bright) 30%, transparent) 0deg 6deg,
    transparent 6deg 18deg);
  opacity: .7; animation: hero-sun-spin 26s linear infinite;
  mask-image: radial-gradient(60% 55% at 50% 32%, black 0%, transparent 72%);
}
@keyframes hero-sun-spin { to { transform: rotate(360deg); } }

.hero-glow {
  position: absolute; left: 50%; top: 30%; width: 320px; height: 320px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, color-mix(in srgb, var(--th-bright) 70%, transparent) 0%, transparent 70%);
  filter: blur(4px);
}

.hero-art {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%);
  width: 220px; height: 220px; object-fit: contain; z-index: 2;
  filter: drop-shadow(0 18px 30px rgba(0,0,0,0.5))
          drop-shadow(0 0 32px color-mix(in srgb, var(--th-bright) 75%, transparent));
  animation: hero-art-float 5s ease-in-out infinite;
}
@keyframes hero-art-float {
  0%, 100% { transform: translate(-50%, -50%) translateY(0) rotate(-1.5deg); }
  50%      { transform: translate(-50%, -50%) translateY(-12px) rotate(1.5deg); }
}

.hero-grid {
  position: absolute; left: 0; right: 0; bottom: 0; height: 42%;
  background-image:
    linear-gradient(color-mix(in srgb, var(--th-bright) 35%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--th-bright) 35%, transparent) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: linear-gradient(to top, black, transparent);
  transform: perspective(260px) rotateX(58deg);
  transform-origin: bottom;
  opacity: .65;
}

.hero-badge {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px; z-index: 4;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  color: #0c0a06; background: var(--th-bright);
  padding: 6px 12px; border-radius: 100px;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--th-bright) 70%, transparent);
}

/* Wordmark "GrailDex" — ingrandito e reso bicolore (era 24px monocolore),
   e riposizionato per SOVRAPPORSI alla parte bassa dell'artwork invece di
   stare sotto — crea profondita' reale (il testo passa "davanti" al
   Pokemon che galleggia dietro), feedback utente 2026-07-23. */
.hero-copy {
  position: absolute; left: 0; right: 0; bottom: 78px; z-index: 3; text-align: center; padding: 0 20px;
}
.hero-copy h2 {
  font-family: var(--font-display); font-weight: 900; font-size: 40px; letter-spacing: -0.03em;
  line-height: 1; margin: 0 0 8px;
  text-shadow: 0 4px 22px rgba(0,0,0,0.75), 0 2px 6px rgba(0,0,0,0.6);
}
.hero-copy h2 .a { color: var(--th-bright); }
.hero-copy h2 .b { color: var(--text); }
.hero-cycle { font-size: 13px; font-weight: 600; color: var(--text); height: 18px; overflow: hidden; position: relative; text-shadow: 0 2px 10px rgba(0,0,0,0.7); }
.hero-cycle span {
  display: block; position: absolute; inset: 0; opacity: 0; animation: hero-cycle-fade 6s infinite;
}
.hero-cycle span:nth-child(1) { animation-delay: 0s; }
.hero-cycle span:nth-child(2) { animation-delay: 2s; }
.hero-cycle span:nth-child(3) { animation-delay: 4s; }
@keyframes hero-cycle-fade {
  0%, 4%   { opacity: 0; transform: translateY(6px); }
  8%, 28%  { opacity: 1; transform: translateY(0); }
  33%,100% { opacity: 0; transform: translateY(-6px); }
}

.hero-cta {
  position: absolute; left: 24px; right: 24px; bottom: 18px; z-index: 3;
  display: block; background: linear-gradient(120deg, var(--th-color), var(--th-bright));
  color: #14110a; border: none; border-radius: 100px; padding: 14px; text-align: center;
  font-family: var(--font-ui); font-weight: 700; font-size: 14.5px;
  box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--th-bright) 80%, transparent);
}

/* Velo di colore tema esteso a TUTTA la pagina sotto l'hero (non solo
   l'hero stesso) — "tutte le sezioni devono seguire i colori del pokemon
   scelto", feedback utente 2026-07-23. Applicato dal wrapper .page quando
   un tema e' attivo. */
.page.themed { position: relative; }
.page.themed::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(140% 60% at 50% 0%, color-mix(in srgb, var(--th-bright) 10%, transparent), transparent 55%);
}
.page.themed .card { border-color: color-mix(in srgb, var(--th-bright) 22%, var(--border)); }

@media (prefers-reduced-motion: reduce) {
  .hero-sunburst, .hero-art, .hero-cycle span { animation: none !important; }
}

/* ── Griglia scelta Pokemon preferito (/settings) ────────────────────── */
.theme-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.theme-pick {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 6px; border-radius: var(--radius); border: 1.5px solid var(--border);
  background: var(--bg-card); cursor: pointer; width: 100%;
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .1s var(--ease);
}
.theme-pick:active { transform: scale(0.96); }
.theme-pick.selected {
  border-color: var(--pick-bright); background: color-mix(in srgb, var(--pick-color) 14%, var(--bg-card));
}
.theme-pick-name { font-size: 12px; font-weight: 600; margin-top: 6px; }
.theme-pick-type { font-size: 10.5px; color: var(--text-faint); }
@media (min-width: 700px) {
  .theme-grid { grid-template-columns: repeat(6, 1fr); }
}

/* Collezione — galleria carte grandi (i collezionisti vogliono vedere bene
   la carta, non una riga di tabella compatta come il Magazzino business) */
.collection-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.collection-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-card);
}
.collection-card-img {
  width: 100%; aspect-ratio: 5 / 7; object-fit: contain;
  border-radius: 8px; background: var(--bg-hover); display: block;
}
.collection-card-info { margin-top: 8px; font-size: 13px; }
.collection-card-info .sub { color: var(--text-faint); font-size: 12px; margin-top: 2px; }
.collection-card-del {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-radius: 50%; padding: 5px;
}

/* Master Set — carta mancante sbiadita/desaturata, a colpo d'occhio
   distinta da una posseduta senza dover leggere il badge "manca" */
.masterset-missing { opacity: 0.45; }
.masterset-missing .collection-card-img { filter: grayscale(1); }

.collection-card-chart {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-radius: 50%; padding: 5px; color: var(--text-dim);
  display: flex;
}
.collection-card-chart:hover { color: var(--accent-bright); }

.collection-card-fav {
  position: absolute; top: 14px; left: 46px; z-index: 2;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-radius: 50%; padding: 5px; display: flex;
}
.btn-icon-plain {
  background: none; border: none; padding: 0; margin: 0;
  display: flex; cursor: pointer; color: var(--text-dim);
}
.btn-icon-plain:hover { color: #f5b800; }

.chart-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--text-faint); font-size: 13px; gap: 4px;
}
.value-chart { color: var(--text); }

/* Valuta lotto — picker candidati VISIVO (immagine reale per ogni stampa
   possibile), non un menu testuale: scegliere tra "Gengar · Rare · Fossil #5"
   e altre 25 righe identiche di testo e' impossibile senza vedere le carte
   -- bug reale segnalato 2026-07-24 (lotto da <40€ valutato oltre 600€
   perche' il picker preselezionava una stampa a caso e l'operatore non
   aveva modo di distinguerle a colpo d'occhio). */
.lot-candidate-group + .lot-candidate-group { margin-top: 12px; }
.lot-candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.lot-candidate-option {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 6px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); cursor: pointer;
  font-size: 10.5px; text-align: center; color: var(--text-dim);
  transition: border-color .12s var(--ease), background .12s var(--ease);
}
.lot-candidate-option input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.lot-candidate-option:has(input:checked) {
  border-color: var(--accent-bright); background: var(--accent-dim); color: var(--text);
}
.lot-candidate-img { width: 100%; border-radius: 4px; aspect-ratio: 5/7; object-fit: cover; }
/* Immagine non disponibile per questa carta (set nuovissimo, il CDN
   gratuito images.pokemontcg.io non l'ha ancora indicizzata -- verificato
   2026-07-24, 404 reale, non un bug nostro) -- placeholder ESPLICITO
   invece dell'icona di immagine rotta del browser (::before su <img> non
   e' affidabile cross-browser), cosi' l'operatore sa che deve confrontare
   a mano con testo/numero invece di fidarsi di un'immagine mancante
   silenziosa. */
.lot-candidate-img-placeholder {
  display: none; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 5/7; border-radius: 4px;
  background: var(--bg-hover); color: var(--text-faint);
  font-size: 9.5px; text-align: center; padding: 6px;
}
.lot-candidate-discard {
  justify-content: center; min-height: 90px; font-weight: 600;
}
.lot-candidate-discard input:checked ~ span,
.lot-candidate-option:has(input:checked).lot-candidate-discard { color: var(--negative); }
