/* ==========================================================================
   [1. SISTEMA DE DESIGN & TOKENS — myWALLET · CARTEIRA DIGITAL myMEDAL (myM)]
   Harmonizado com o Ecossistema CGD-ARF (WCAG AAA Light & Dark, Mobile-First)
   Zero desperdício de espaço ("Zero caixas dentro de caixas")
   ========================================================================== */
:root {
  --bg-page: #07090E;
  --bg-glow: radial-gradient(circle, rgba(245, 158, 11, 0.14) 0%, rgba(0, 163, 255, 0.08) 45%, rgba(7, 9, 14, 0) 72%);
  --text-page: #F8FAFC;
  --text-heading: #FFFFFF;
  --text-page-muted: #CBD5E1;
  --title-h1: #FFFFFF;
  --accent-cyan: #38BDF8;
  --cyan-bright: #00A3FF;
  --accent-gold: #FBBF24;
  --accent-gold-strong: #F59E0B;
  --accent-emerald: #34D399;
  --accent-purple: #A78BFA;
  --accent-danger: #F87171;

  --bg-card: #0F172A;
  --bg-card-elevated: #1E293B;
  --bg-input: #090E1A;
  --border-card: rgba(148, 163, 184, 0.24);
  --border-gold: rgba(245, 158, 11, 0.48);
  --text-card-title: #FFFFFF;
  --text-card-body: #E2E8F0;
  --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.42);
  --footer-border: rgba(255, 255, 255, 0.1);
  --footer-text: #94A3B8;
}

[data-theme="light"] {
  --bg-page: #F1F5F9;
  --bg-glow: radial-gradient(circle, rgba(217, 119, 6, 0.12) 0%, rgba(2, 132, 199, 0.08) 45%, rgba(241, 245, 249, 0) 72%);
  --text-page: #0F172A;
  --text-heading: #0C3E75;
  --text-page-muted: #334155;
  --title-h1: #0C3E75;
  --accent-cyan: #0369A1;
  --cyan-bright: #0284C7;
  --accent-gold: #B45309;
  --accent-gold-strong: #D97706;
  --accent-emerald: #047857;
  --accent-purple: #6D28D9;
  --accent-danger: #B91C1C;

  --bg-card: #FFFFFF;
  --bg-card-elevated: #F8FAFC;
  --bg-input: #FFFFFF;
  --border-card: #CBD5E1;
  --border-gold: #D97706;
  --text-card-title: #0C3E75;
  --text-card-body: #1E293B;
  --shadow-card: 0 8px 24px rgba(12, 62, 117, 0.09);
  --footer-border: rgba(15, 23, 42, 0.1);
  --footer-text: #475569;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-page);
  color: var(--text-page);
  font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  position: relative;
}

.bg-glow {
  position: absolute;
  top: -180px;
  left: 0;
  right: 0;
  margin: 0 auto;
  transform: none;
  width: 100%;
  max-width: 920px;
  overflow: hidden;
  height: 480px;
  background: var(--bg-glow);
  pointer-events: none;
  z-index: 0;
}

.wallet-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: calc(var(--cgd-mancha-max, 880px) + (2 * var(--cgd-page-pad, 4px)));
  margin: 0 auto;
  padding: 6px var(--cgd-page-pad, 4px) 48px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Barra Rápida de Regresso (← Voltar onde estava — sem elementos extra) */
.wallet-top-return-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.btn-return-prev {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-card);
  color: var(--text-page);
  font-size: 0.84rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.btn-return-prev:hover {
  transform: translateY(-1px);
  border-color: var(--accent-gold-strong);
}

/* Contentor Hero — ZERO "Caixa dentro de Caixa" (alinhamento total à esquerda e direita) */
.wallet-hero-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wallet-hero-top {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

/* Painel Esquerdo: Identidade & Saldo Centrados */
.wallet-identity-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 14px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14) 0%, rgba(14, 165, 233, 0.08) 100%);
  border: 1.5px solid var(--border-gold);
  box-shadow: var(--shadow-card);
}

.wallet-brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.wallet-brand-coin-3d {
  width: 60px;
  height: 60px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 5px 12px rgba(217, 119, 6, 0.42));
}

.wallet-brand-titles {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1px;
}

.wallet-kicker {
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--accent-gold);
}

.wallet-main-heading {
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: clamp(1.5rem, 3.3vw, 2.05rem);
  font-weight: 900;
  line-height: 1.05;
  color: var(--text-heading);
}

.wallet-main-heading .brand-medal {
  color: var(--accent-gold-strong);
}

.wallet-balance-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding-top: 2px;
}

.wallet-balance-label {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text-page-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wallet-balance-value {
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: clamp(1.95rem, 4.6vw, 2.6rem);
  font-weight: 900;
  color: var(--accent-gold);
  line-height: 1.04;
  font-variant-numeric: tabular-nums;
}

.wallet-plan-badges-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
  margin-top: 2px;
}

.wallet-plan-badges-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.wallet-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--text-card-body);
}

/* Painel Direito: Protocolo + Chave Pública 0x... */
.wallet-key-pane {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 12px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-card);
  box-shadow: var(--shadow-card);
}

.wallet-protocol-pill-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.wallet-protocol-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.14);
  border: 1.5px solid var(--border-gold);
  color: var(--accent-gold);
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
}

.wallet-key-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wallet-key-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-page-muted);
}

.wallet-key-status {
  font-size: 0.73rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  white-space: nowrap;
}

.wallet-address-box {
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-page);
  word-break: break-all;
  line-height: 1.35;
  text-align: center;
}

.wallet-key-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.btn-wallet-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 9px;
  border: 1.5px solid var(--border-card);
  background: var(--bg-card-elevated);
  color: var(--text-page);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-wallet-action:hover {
  border-color: var(--accent-gold-strong);
}

.btn-wallet-action.primary {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  border-color: #B45309;
  color: #0F172A;
}

/* ==========================================================================
   [2. 4 PILARES DE MINERAÇÃO ATIVA — SETA PARA DENTRO (↘) E PARA FORA (↗)]
   ========================================================================== */
.wallet-kpis-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.wallet-kpi-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 8px 8px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-card);
  box-shadow: var(--shadow-card);
  position: relative;
}

.wallet-kpi-visual-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.wallet-kpi-dir {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 28px;
  cursor: help;
}

.wallet-dir-arrow {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  transition: transform 0.15s ease;
}

.wallet-dir-arrow svg {
  width: 100%;
  height: 100%;
}

/* Seta Para Dentro (↘ apontada ao ícone central) */
.wallet-dir-arrow.arrow-in {
  background: rgba(16, 185, 129, 0.16);
  border: 1.2px solid rgba(52, 211, 153, 0.5);
  color: var(--accent-emerald);
}

/* Seta Para Fora (↗ apontada para o exterior) */
.wallet-dir-arrow.arrow-out {
  background: rgba(56, 189, 248, 0.16);
  border: 1.2px solid rgba(56, 189, 248, 0.5);
  color: var(--accent-cyan);
}

.wallet-kpi-dir:hover .wallet-dir-arrow {
  transform: scale(1.1);
}

.wallet-kpi-dir strong {
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 1.28rem;
  font-weight: 900;
  color: var(--text-heading);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.wallet-kpi-icon-3d {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.32));
}

.wallet-kpi-label {
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-page-muted);
  text-align: center;
  line-height: 1.1;
}

/* Banner Pedagógico do Livro Preparado para a Próxima Revolução */
.wallet-vision-callout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-gold);
  box-shadow: var(--shadow-card);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-card-body);
}

.wallet-vision-callout img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.wallet-vision-callout a {
  color: var(--accent-gold);
  font-weight: 900;
  text-decoration: underline;
}

/* Navegação por Separadores (Tabs) Mobile-First */
.wallet-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-card);
  padding: 6px;
  border-radius: 14px;
  border: 1.5px solid var(--border-card);
  box-shadow: var(--shadow-card);
}

.wallet-tab-btn {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--text-page-muted);
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.wallet-tab-btn:hover {
  color: var(--text-page);
  background: var(--bg-card-elevated);
}

.wallet-tab-btn.active {
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 55%, #F59E0B 100%);
  border-color: #D97706;
  color: #451A03;
  box-shadow: 0 3px 10px rgba(217, 119, 6, 0.25);
}

.wallet-tab-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.wallet-tab-panel.active {
  display: flex;
}

/* Cartões de Secção */
.wallet-section-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-card);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wallet-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-card);
  padding-bottom: 8px;
}

.wallet-section-header img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.wallet-section-header h2 {
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-heading);
}

/* Grelha de Perfil & Selfie */
.wallet-profile-grid {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.wallet-avatar-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-card);
}

.wallet-avatar-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent-gold-strong);
  background: #0F172A;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wallet-avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wallet-form-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wallet-field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wallet-field-group label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-card-title);
}

.wallet-input,
.wallet-select {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1.5px solid var(--border-card);
  background: var(--bg-input);
  color: var(--text-page);
  font-size: 0.88rem;
  font-weight: 600;
}

.wallet-input:focus,
.wallet-select:focus {
  outline: none;
  border-color: var(--accent-gold-strong);
}

.wallet-checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-card);
  font-size: 0.83rem;
  line-height: 1.4;
  color: var(--text-card-body);
  cursor: pointer;
}

.wallet-checkbox-card input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: #D97706;
  flex-shrink: 0;
}

/* Simulador / Laboratório PoW e Regras */
.wallet-pow-explainer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.wallet-pow-box {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-card-body);
}

.wallet-pow-box h3 {
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 1rem;
  font-weight: 900;
  color: var(--text-heading);
}

.wallet-pow-terminal {
  padding: 12px;
  border-radius: 10px;
  background: #090D16;
  border: 1.5px solid #334155;
  color: #E2E8F0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
}

/* Livro-Razão (Blockchain Ledger) */
.wallet-ledger-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wallet-tx-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px;
  border-radius: 11px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-card);
}

.wallet-tx-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.wallet-tx-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-heading);
}

.wallet-tx-amount-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.16);
  color: var(--accent-gold);
  font-weight: 900;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.wallet-tx-amount-pill.is-negative {
  background: rgba(239, 68, 68, 0.16);
  color: var(--accent-danger);
}

.wallet-tx-amount-pill img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.wallet-tx-hashes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.73rem;
  color: var(--text-page-muted);
  background: var(--bg-input);
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border-card);
}

.wallet-tx-hashes div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Quadro de Honra (Leaderboard) */
.wallet-lb-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wallet-lb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-card);
  flex-wrap: wrap;
}

.wallet-lb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wallet-lb-rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #0F172A;
  font-weight: 900;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

footer {
  width: 100%;
  border-top: 1px solid var(--footer-border);
  padding: 18px 14px;
  text-align: center;
  color: var(--footer-text);
  font-size: 0.8rem;
  margin-top: auto;
}

/* Responsividade Mobile (< 768px) — Zero desperdício lateral */
@media (max-width: 768px) {
  .wallet-container {
    padding: 4px var(--cgd-page-pad, 4px) 36px;
    gap: 8px;
  }

  .wallet-identity-pane,
  .wallet-key-pane,
  .wallet-section-card {
    padding: 12px 10px;
    border-radius: 12px;
  }

  .wallet-hero-top,
  .wallet-profile-grid,
  .wallet-pow-explainer-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .wallet-kpis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .wallet-vision-callout {
    padding: 10px 11px;
    font-size: 0.82rem;
  }

  .wallet-tx-hashes {
    grid-template-columns: 1fr;
  }

  .wallet-tabs-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    padding: 5px;
  }

  .wallet-tab-btn {
    font-size: 0.82rem;
    padding: 8px 6px;
    white-space: normal;
    text-align: center;
  }
}
