/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0b1121;
    color: #e8edf5;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    padding: 24px;
    min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #1e2a45;
}

.header h1 {
    color: #38bdf8;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header h1 span {
    font-size: 28px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.header-actions .user-badge {
    background: #1e2a45;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-actions .user-badge .emoji {
    font-size: 16px;
}

.btn {
    padding: 7px 18px;
    border: none;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.btn:hover {
    opacity: 0.85;
    transform: scale(0.97);
}
.btn-logout {
    background: #ef4444;
    color: #fff;
}
.btn-refresh {
    background: #38bdf8;
    color: #0b1121;
}
.btn-refresh:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-reset {
    background: #dc2626;
    color: #fff;
}
.btn-reset:hover {
    opacity: 0.85;
    transform: scale(0.97);
}
.btn-reset:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-detail {
    background: transparent;
    color: #38bdf8;
    border: 1px solid #38bdf8;
}
.btn-detail:hover {
    background: #38bdf8;
    color: #0b1121;
}

/* ---- Link cambio vista desktop<->mobile (in entrambi i template) ---- */
.view-switch-link {
    color: #38bdf8;
    font-size: 12px;
    text-decoration: none;
    padding: 7px 12px;
    border: 1px solid #1e2a45;
    border-radius: 20px;
    transition: all 0.15s;
    white-space: nowrap;
}
.view-switch-link:hover {
    border-color: #38bdf8;
    background: #182240;
}

#update-time {
    color: #64748b;
    font-size: 13px;
    min-width: 140px;
    text-align: right;
}

/* ===== RIEPILOGO TOTALI ===== */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.summary-card {
    background: #141d33;
    border-radius: 16px;
    padding: 18px 20px;
    border: 1px solid #1e2a45;
    border-left: 4px solid #38bdf8;
    transition: border-color 0.2s, transform 0.1s, background 0.2s;
    cursor: pointer;
}
.summary-card:hover { border-color: #38bdf8; background: #182240; }
.summary-card:active { transform: scale(0.98); }
.summary-card.active {
    background: #182240;
    box-shadow: 0 0 0 2px #38bdf8 inset;
}
.summary-card .label {
    color: #94a3b8;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 500;
    margin-bottom: 6px;
}
.summary-card .value {
    font-size: 24px;
    font-weight: 700;
    color: #facc15;
    line-height: 1.2;
}
.summary-card.total { border-left-color: #facc15; }
.summary-card.total .value { color: #facc15; }
.summary-card.chain-solana { border-left-color: #9945FF; }
.summary-card.chain-solana .value { color: #c4a6ff; }
.summary-card.chain-ethereum { border-left-color: #627EEA; }
.summary-card.chain-ethereum .value { color: #a3b3f7; }
.summary-card.chain-ton { border-left-color: #38bdf8; }
.summary-card.chain-ton .value { color: #7dd3fc; }

/* ===== SEZIONI GENERICHE ===== */
.section {
    background: #141d33;
    border-radius: 16px;
    padding: 20px 22px;
    border: 1px solid #1e2a45;
    margin-bottom: 22px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}
.section-header h3 {
    color: #e8edf5;
    font-size: 16px;
    font-weight: 600;
}

/* ===== FILTRI / TABS (prezzi e transazioni) ===== */
.price-filter, .tx-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-btn, .tab-btn {
    background: #0b1121;
    color: #94a3b8;
    border: 1px solid #1e2a45;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.filter-btn:hover, .tab-btn:hover {
    border-color: #38bdf8;
    color: #e8edf5;
}
.filter-btn.active, .tab-btn.active {
    background: #38bdf8;
    color: #0b1121;
    border-color: #38bdf8;
}
.tx-wallet-selector-row {
    padding: 0 22px 14px;
    text-align: left;
}
.tx-wallet-selector-row select {
    background: #0b1121;
    border: 1px solid #1e2a45;
    color: #e8edf5;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 12px;
    min-width: 220px;
}
.tx-wallet-selector-row select:focus {
    outline: none;
    border-color: #38bdf8;
}

/* ===== SEZIONE PREZZI ===== */
.price-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}
.price-card {
    position: relative;
    background: #0b1121;
    border: 1px solid #1e2a45;
    border-radius: 12px;
    padding: 10px 16px 14px;
    transition: border-color 0.2s;
}
.price-card:hover { border-color: #38bdf8; }

/* Sfondo tenue in base al segno della variazione 24h — toni smorzati,
   non troppo vividi, per non affaticare la lettura su tante card insieme. */
.price-card-positive {
    background: rgba(74, 222, 128, 0.055);
    border-color: rgba(74, 222, 128, 0.18);
}
.price-card-positive:hover { border-color: rgba(74, 222, 128, 0.4); }
.price-card-negative {
    background: rgba(248, 113, 113, 0.055);
    border-color: rgba(248, 113, 113, 0.18);
}
.price-card-negative:hover { border-color: rgba(248, 113, 113, 0.4); }
.price-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    min-height: 20px;
}
.price-top-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;      /* se non c'entra in riga, va a capo invece di tagliare il testo */
    justify-content: flex-end;
    min-width: 0;         /* permette al flex item di restringersi invece di forzare overflow sulla card */
}
.price-chain {
    white-space: nowrap;  /* mai spezzato a metà parola/icona */
    font-size: 11px;
    color: #64748b;
}
.price-card .star-btn {
    background: transparent;
    border: none;
    font-size: 15px;
    cursor: pointer;
    color: #334155;
    opacity: 0.6;
    transition: all 0.15s;
    padding: 0;
}
.price-card .star-btn:hover { opacity: 1; color: #facc15; }
.price-card .star-btn.active { color: #facc15; opacity: 1; }
.price-card .token-remove-btn {
    background: transparent;
    border: none;
    font-size: 13px;
    cursor: pointer;
    color: #334155;
    opacity: 0.5;
    transition: all 0.15s;
    padding: 0;
    margin-left: 4px;
}
.price-card .token-remove-btn:hover { opacity: 1; color: #ef4444; }
.price-change {
    font-size: 13px; /* +20% rispetto agli 11px originali */
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}
.price-change-up {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
}
.price-change-down {
    color: #f87171;
    background: rgba(248, 113, 113, 0.12);
}
.price-token {
    font-weight: 700;
    font-size: 15px;
    color: #e8edf5;
    margin-bottom: 4px;
}
.price-value {
    font-size: 18px;
    font-weight: 700;
    color: #4ade80;
    margin-bottom: 4px;
}

/* ===== SEZIONE RETE SOLANA ===== */
.network-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.network-updated-at {
    font-size: 11px;
    color: #64748b;
}
.network-filter-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 12px 16px;
    margin-bottom: 14px;
    background: #0b1121;
    border: 1px dashed #1e2a45;
    border-radius: 12px;
}
.network-filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #cbd5e1;
    cursor: pointer;
    user-select: none;
}
.network-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.network-card {
    background: #0b1121;
    border: 1px solid #1e2a45;
    border-radius: 12px;
    padding: 12px 16px; /* margini fissi dx/sx: il font si adatta DENTRO questo spazio, mai lo forza */
    container-type: inline-size; /* abilita le unità cqw qui sotto, relative alla larghezza di QUESTA card */
    min-width: 0; /* permette alla card di restringersi nella cella grid invece di sforare */
}
.network-card .label {
    font-size: clamp(9px, 6.5cqw, 11px); /* si restringe con la card, ma mai sotto 9px né sopra 11px */
    color: #64748b;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* rete di sicurezza: se anche il minimo non bastasse, tronca invece di rompere il layout */
}
.network-card .value {
    font-size: clamp(13px, 12cqw, 20px); /* stessa logica: uniforme perché tutte le card hanno la stessa larghezza nella griglia a 2 colonne */
    font-weight: 700;
    color: #e8edf5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== SEZIONE SALDI ===== */
.balances-chains {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.chain-block {
    border: 1px solid #1e2a45;
    border-radius: 12px;
    overflow: hidden;
    border-left: 4px solid #38bdf8;
}
.chain-block.chain-solana { border-left-color: #9945FF; }
.chain-block.chain-ethereum { border-left-color: #627EEA; }
.chain-block.chain-ton { border-left-color: #38bdf8; }

.chain-block-header {
    background: #0b1121;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 14px;
    color: #e8edf5;
}
.chain-block-header .chain-subtotal {
    color: #facc15;
    font-size: 15px;
}
.chain-block-body {
    display: flex;
    flex-direction: column;
}
.balance-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr 1fr;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid #1e2a45;
    font-size: 13px;
}
.balance-token {
    font-weight: 700;
    color: #e8edf5;
}
.balance-amount {
    color: #cbd5e1;
    font-family: 'SF Mono', 'Consolas', monospace;
}
.balance-price {
    color: #64748b;
    font-size: 12px;
}
.balance-value {
    color: #4ade80;
    font-weight: 700;
    text-align: right;
}

/* ===== TABELLA TRANSAZIONI ===== */
.tx-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Storia di questa regola: prima percentuali (30/70, poi 22/18/30/30) — il
   problema si spostava dentro la colonna "Importo" (larga ma con contenuto
   corto). Poi shrink-to-content (width:1%) — ogni riga poteva calcolare una
   larghezza leggermente diversa in base al proprio contenuto specifico,
   risultando in bordi di colonna non perfettamente allineati riga per riga.
   Soluzione finale: larghezze FISSE in px, uguali per ogni riga a
   prescindere dal contenuto (table-layout:fixed + width esplicito su ogni
   colonna). La tabella ha una larghezza totale fissa (non 100%): lo spazio
   che avanza nel contenitore resta semplicemente vuoto dopo "Importo",
   invece di disperdersi tra le celle. Selettore scoperto a
   ".tx-table-wrap .tx-table" apposta: la tabella dettaglio (.detail-table,
   17 colonne, scroll orizzontale) NON deve essere toccata da questa regola. */
/* Storia di questa regola: prima percentuali sul CONTENITORE ESTERNO (riga
   swap+storico+network), che si rompevano a zoom diversi — problema
   risolto passando quella riga a flexbox con larghezze minime in px (vedi
   .section-row-swap-history più sopra). Qui, DENTRO al pannello storico già
   stabile, le percentuali sono sicure: 25% per colonna è relativo alla
   larghezza reale del pannello (dinamica, si adatta a quanto spazio c'è),
   non lasciando più spazio vuoto a destra. Selettore scoperto a
   ".tx-table-wrap .tx-table" apposta: la tabella dettaglio (.detail-table,
   17 colonne, scroll orizzontale) NON deve essere toccata da questa regola. */
.tx-table-wrap .tx-table {
    table-layout: fixed;
    width: 100%;
}
.tx-table-wrap .tx-table th,
.tx-table-wrap .tx-table td {
    width: 25%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tx-table-wrap .tx-table th:nth-child(1),
.tx-table-wrap .tx-table td:nth-child(1) { text-align: left; }   /* Data */
.tx-table-wrap .tx-table th:nth-child(2),
.tx-table-wrap .tx-table td:nth-child(2) { text-align: center; } /* Tipo */
.tx-table-wrap .tx-table th:nth-child(3),
.tx-table-wrap .tx-table td:nth-child(3) { text-align: center; } /* Token */
.tx-table-wrap .tx-table th:nth-child(4),
.tx-table-wrap .tx-table td:nth-child(4) { text-align: right; }  /* Importo */

/* Tendina compatta mobile: nascosta di default (desktop mostra la tabella),
   resa visibile in sua vece da style_mobile.css. */
.tx-dropdown-wrap { display: none; }

/* Righe della tendina compatta storico (mobile): griglia a 4 colonne fisse,
   così Data/Tipo/Token/Importo restano allineati riga per riga — prima era
   testo semplice concatenato dentro <option>, che non può allinearsi in
   colonne. Qui solo la struttura/allineamento: bordi, sfondo e dimensioni
   del contenitore ".tx-dropdown" restano quelli già definiti altrove. */
.tx-compact-row {
    display: grid;
    grid-template-columns: 72px 64px 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 8px 6px;
    border-bottom: 1px solid #1e2a45;
}
.tx-compact-row:last-child { border-bottom: none; }
.tx-compact-date, .tx-compact-type {
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tx-compact-token {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tx-compact-amount {
    text-align: right;
    font-variant-numeric: tabular-nums; /* cifre a larghezza fissa: gli importi restano allineati a destra tra loro */
    white-space: nowrap;
}

.tx-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}
.tx-table th {
    text-align: left;
    color: #64748b;
    font-weight: 400;
    padding: 8px;
    border-bottom: 1px solid #1e2a45;
}
.tx-table td {
    padding: 8px;
    border-bottom: 1px solid #0b1121;
}
.tx-table .status-success { color: #4ade80; }
.tx-table .status-failed { color: #f87171; }

.empty-state {
    color: #64748b;
    font-size: 14px;
    text-align: center;
    padding: 20px 0;
    grid-column: 1 / -1;
}

#balances-section-subtitle {
    color: #64748b;
    font-size: 13px;
    font-weight: 400;
}

.tx-detail-link {
    margin-top: 14px;
    text-align: right;
}

/* ===== RIGA SWAP + STORICO + RETE SOLANA, desktop =====
   Grid con percentuali fisse (24/52/24) si è rotto di nuovo agli stessi
   zoom/larghezze problematici già visti col caso a 2 colonne — le
   percentuali sono comunque relative al viewport CSS, che lo zoom del
   browser altera. Torniamo alla stessa metrica già validata: flexbox con
   flex-wrap e larghezze MINIME in px (non percentuali). I tre pannelli
   restano affiancati finché c'è spazio reale per le loro larghezze minime
   comode; altrimenti quello che non ci sta va a capo — a QUALSIASI zoom,
   senza soglie percentuali o breakpoint da tarare a mano. */
.section-row-swap-history {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
}
.section-row-swap-history .section-jupiter,
.section-row-swap-history .section-network {
    flex: 1 1 300px;   /* non scendono sotto 300px */
    max-width: 340px;  /* né diventano troppo larghi se avanza spazio */
    margin-bottom: 22px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.section-row-swap-history .section-history {
    flex: 3 1 650px;   /* non scende sotto 650px (600px tabella + padding pannello); cresce più degli altri due quando c'è spazio extra */
    margin-bottom: 22px;
    display: flex;
    flex-direction: column;
    min-width: 0; /* permette a .tx-table-wrap (overflow-x:auto) di gestire un eventuale overflow interno, invece che il layout sfori il margine della pagina */
}

/* ===== SEZIONE JUPITER SWAP (integrata fissa in pagina) ===== */
.section-jupiter {
    display: flex;
    flex-direction: column;
}
.section-jupiter #jupiter-plugin-container {
    width: 100%;
    min-height: 560px;
}

/* Hint deep-link mobile: nascosto di default (desktop), riattivato dal media
   query in style_mobile.css. Vedi nota nel template _dashboard_content.html
   sul perché si usano <a> reali invece di JS. */
.jupiter-mobile-hint {
    display: none;
    gap: 8px;
    padding: 0 0 16px 0;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
}
.jupiter-mobile-hint span {
    width: 100%;
    font-size: 12px;
    color: #64748b;
}
.btn-wallet-deeplink {
    display: inline-block;
    background: #1e2a45;
    color: #e2e8f0;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    border: 1px solid #2c3b5c;
    text-decoration: none;
}
.btn-wallet-deeplink:active {
    opacity: 0.8;
}

/* ===== MODAL DETTAGLIO SOLANA ===== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-box {
    background: #141d33;
    border: 1px solid #1e2a45;
    border-radius: 16px;
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid #1e2a45;
}
.modal-header h3 {
    color: #38bdf8;
    font-size: 16px;
}
.modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    transition: all 0.15s;
}
.modal-close:hover {
    background: #1e2a45;
    color: #e8edf5;
}
.modal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 22px;
    border-bottom: 1px solid #1e2a45;
    align-items: center;
}
.modal-filters input,
.modal-filters select {
    background: #0b1121;
    border: 1px solid #1e2a45;
    color: #e8edf5;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
}
.modal-filters input:focus,
.modal-filters select:focus {
    outline: none;
    border-color: #38bdf8;
}
.modal-filters .date-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #94a3b8;
    font-size: 12px;
}
.modal-filters .page-size-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #94a3b8;
    font-size: 12px;
    margin-left: auto;
}
.modal-filters-hint {
    padding: 0 22px 10px;
    color: #64748b;
    font-size: 11px;
}
.quick-add-row {
    border-bottom: 1px dashed #1e2a45;
}
.quick-add-input {
    width: 220px;
}
.quick-add-sep {
    width: 1px;
    height: 24px;
    background: #1e2a45;
    margin: 0 6px;
}
.modal-table-wrap {
    overflow: auto;
    padding: 0 22px;
    flex: 1;
}
.detail-table {
    white-space: nowrap;
}
.detail-table th, .detail-table td {
    font-size: 12px;
    padding: 7px 10px;
}
.filterable-th {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}
.filterable-th:hover {
    color: #38bdf8;
}
.column-filter-input {
    width: 100%;
    box-sizing: border-box;
    background: #0b1121;
    border: 1px solid #38bdf8;
    color: #e8edf5;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 11px;
    font-weight: 400;
}
.column-filter-input:focus {
    outline: none;
}
#column-filter-row th {
    padding: 4px 10px 8px;
}
.mono-small {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 11px;
    color: #64748b;
}

.txid-chip {
    background: #0b1121;
    border: 1px solid #1e2a45;
    color: #38bdf8;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    font-family: 'SF Mono', 'Consolas', monospace;
    cursor: pointer;
    transition: all 0.15s;
}
.txid-chip:hover {
    border-color: #38bdf8;
    background: #141d33;
}

.btn-mark-spam {
    background: #0b1121;
    border: 1px solid #1e2a45;
    color: #94a3b8;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-mark-spam:hover {
    border-color: #f87171;
    color: #f87171;
    background: #141d33;
}

.btn-archive-tx, .btn-restore-tx {
    background: #0b1121;
    border: 1px solid #1e2a45;
    color: #94a3b8;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    margin-left: 4px;
}
.btn-archive-tx:hover, .btn-restore-tx:hover {
    border-color: #38bdf8;
    color: #38bdf8;
    background: #141d33;
}

.txid-popup {
    position: absolute;
    z-index: 300;
    background: #141d33;
    border: 1px solid #38bdf8;
    border-radius: 10px;
    padding: 8px;
    display: flex;
    gap: 6px;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.txid-popup input {
    background: #0b1121;
    border: 1px solid #1e2a45;
    color: #e8edf5;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 11px;
    font-family: 'SF Mono', 'Consolas', monospace;
    width: 320px;
}
.txid-popup input:focus {
    outline: none;
    border-color: #38bdf8;
}
.txid-popup-mobile {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 400px;
    flex-direction: column;
    align-items: stretch;
}
.txid-popup-mobile input {
    width: 100%;
    box-sizing: border-box;
}
.modal-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 14px 22px;
    border-top: 1px solid #1e2a45;
    color: #94a3b8;
    font-size: 13px;
}

/* ===== LOGIN ===== */
.login-container {
    max-width: 420px;
    margin: 80px auto;
    background: #141d33;
    padding: 40px;
    border-radius: 16px;
    border: 1px solid #1e2a45;
}
.login-container h2 {
    color: #38bdf8;
    text-align: center;
    margin-bottom: 20px;
    font-size: 24px;
}
.login-container input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid #1e2a45;
    background: #0b1121;
    color: #e8edf5;
    font-size: 16px;
}
.login-container input:focus {
    outline: none;
    border-color: #38bdf8;
}
.login-container button {
    width: 100%;
    padding: 12px;
    background: #38bdf8;
    color: #0b1121;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    margin-top: 12px;
    transition: opacity 0.2s;
}
.login-container button:hover {
    opacity: 0.85;
}
.login-container .error {
    color: #f87171;
    text-align: center;
    margin-top: 12px;
}
.login-container form {
    display: flex;
    flex-direction: column;
}
.btn-google-login {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin-top: 14px;
    background: #ffffff;
    color: #1f2937;
    border-radius: 8px;
    font-weight: 700;
    font-size: 15px;
    text-align: center;
    text-decoration: none;
    transition: opacity 0.2s;
}
.btn-google-login:hover {
    opacity: 0.88;
}
.login-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
}
.login-toggle a {
    color: #94a3b8;
    text-decoration: underline;
    cursor: pointer;
}
.login-toggle a:hover {
    color: #38bdf8;
}

/* ===== RESPONSIVE ===== */

/* ---- Tablet e schermi medi (≤ 900px) ---- */
@media (max-width: 900px) {
    .modal-box {
        max-width: 95vw;
    }
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---- Mobile (≤ 768px) ---- */
@media (max-width: 768px) {
    body { padding: 12px; }

    /* Header: impila e restringe */
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .header h1 { font-size: 19px; }
    .header-actions {
        justify-content: space-between;
        gap: 8px;
    }
    .header-actions .user-badge { order: -1; }
    #update-time {
        text-align: left;
        min-width: 0;
        flex-basis: 100%;
        order: 10;
    }
    .btn { padding: 8px 14px; font-size: 13px; } /* target touch più grande */

    /* Riepilogo totali */
    .summary-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .summary-card { padding: 14px 16px; }
    .summary-card .value { font-size: 19px; }
    .summary-card .label { font-size: 11px; }

    /* Sezioni generiche */
    .section { padding: 16px; }
    .section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .price-filter, .tx-tabs { width: 100%; }
    .filter-btn, .tab-btn { flex: 1; text-align: center; padding: 8px 10px; }

    /* Prezzi & preferiti */
    .price-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .price-card { padding: 12px 14px; }

    /* Saldi */
    .balance-row {
        grid-template-columns: 1fr 1fr;
        row-gap: 4px;
    }
    .balance-price { display: none; }
    .chain-block-header { font-size: 13px; }

    /* Storico compatto */
    .tx-table { font-size: 12px; min-width: 500px; } /* forza scroll orizzontale invece di schiacciare le colonne */
    .tx-table th:nth-child(5), .tx-table td:nth-child(5) { display: none; } /* Fee nascosta */

    /* Login */
    .login-container { padding: 24px; margin: 40px auto; width: calc(100% - 32px); }

    /* ---- Modal storico dettagliato: full-screen su mobile ---- */
    .modal-overlay { padding: 0; align-items: stretch; }
    .modal-box {
        max-width: 100vw;
        width: 100vw;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }
    .modal-header { padding: 14px 16px; }
    .modal-header h3 { font-size: 14px; }
    .modal-filters {
        padding: 12px 16px;
        gap: 6px;
    }
    .modal-filters .page-size-label { margin-left: 0; }
    .modal-filters-hint { padding: 0 16px 8px; font-size: 10px; }
    .modal-table-wrap { padding: 0 16px; -webkit-overflow-scrolling: touch; }
    .detail-table { min-width: 1100px; } /* la tabella resta larga, scrolla in orizzontale */
    .modal-pagination { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }

    /* Popup copia TX ID: sempre centrato su mobile (gestito anche da JS/isMobile()) */
    .txid-popup { max-width: 90vw; }
}

/* ---- Telefoni piccoli (≤ 480px) ---- */
@media (max-width: 480px) {
    .summary-grid { grid-template-columns: 1fr; }
    .price-grid { grid-template-columns: repeat(2, 1fr); }
    .header-actions { flex-wrap: wrap; }
    .header-actions .btn { flex: 1 1 auto; }
    .balance-row { grid-template-columns: 1fr; row-gap: 2px; }
    .balance-value { text-align: left; }
    .login-container { padding: 20px; }
}
/* ===== PANNELLO FILTRO WALLET/CHAIN (header) ===== */
.wallet-filter-panel {
    position: absolute; top: 42px; right: 0; z-index: 50;
    background: #182240; border: 1px solid #2a3a5c; border-radius: 12px;
    padding: 14px; width: 260px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.wallet-filter-section { margin-bottom: 12px; }
.wallet-filter-section:last-child { margin-bottom: 0; }
.wallet-filter-title {
    font-size: 12px; font-weight: 600; opacity: 0.7;
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em;
}
.wallet-filter-item {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 0; font-size: 13px; cursor: pointer;
}
.wallet-filter-item input[type="checkbox"] { margin: 0; cursor: pointer; }
.wallet-filter-item .wf-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallet-filter-item .wf-default-badge {
    font-size: 10px; opacity: 0.6; background: #141d33; padding: 1px 6px; border-radius: 6px;
}

/* ===== Breakdown per-wallet nei saldi (quando più wallet condividono un token) ===== */
.balance-by-wallet {
    padding: 2px 0 6px 20px;
    font-size: 11px;
    opacity: 0.7;
}
.balance-by-wallet-row {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
}

/* ===== Tag wallet inline nelle righe storico compatto ===== */
.tx-wallet-tag {
    font-size: 10px;
    opacity: 0.6;
    background: rgba(128,128,128,0.15);
    padding: 1px 5px;
    border-radius: 6px;
    margin-left: 4px;
    white-space: nowrap;
}
