/* ═══════════════════════════════════════════════════════════════
   GAHX Trade — tema escuro fintech, mobile-first.
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg: #0d0f12;
  --bg-elev: #14181e;
  --bg-elev2: #1b212a;
  --line: #232a34;
  --text: #e6e9ef;
  --muted: #8b97a7;
  --accent: #22c55e;
  --accent-2: #3b82f6;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: calc(72px + var(--safe-b));
}
h1, h2, h3 { margin: 0; font-weight: 650; }
b { font-weight: 650; }
.muted { color: var(--muted); }
.pos-text { color: var(--accent); }
.neg-text { color: var(--danger); }

/* ── Cabeçalho ── */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(13, 15, 18, 0.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font-size: 1.02rem; letter-spacing: .2px; }
.brand-name b { color: var(--accent); }
.brand-badge {
  display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
  width: 56px; height: 56px; border-radius: 16px; font-size: 1.3rem; color: #06210f;
  background: linear-gradient(135deg, #22c55e, #0f7a3a);
  box-shadow: 0 4px 14px rgba(34, 197, 94, .35);
}
.brand-badge.sm { width: 34px; height: 34px; border-radius: 10px; font-size: .9rem; }
.header-cap { margin-left: auto; text-align: right; line-height: 1.1; }
.header-cap-label { display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.header-cap-value { font-size: 1.05rem; font-weight: 700; color: var(--accent); }
.header-logout { font-size: 1.1rem; }

/* ── Layout ── */
.app-main { max-width: 900px; margin: 0 auto; padding: 16px; }
.view { display: none; animation: fade .18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-title { font-size: 1.35rem; margin: 4px 2px 14px; }

.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card h3 { font-size: 1rem; margin-bottom: 10px; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 0; }

/* ── Cartões de estatística ── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; display: flex; flex-direction: column; gap: 3px; position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--muted); }
.stat-accent::before { background: var(--accent); }
.stat-pos::before { background: var(--accent); }
.stat-neg::before { background: var(--danger); }
.stat-neutral::before { background: var(--accent-2); }
.stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.stat-value { font-size: 1.25rem; font-weight: 700; }
.stat-pos .stat-value { color: var(--accent); }
.stat-neg .stat-value { color: var(--danger); }
.stat-accent .stat-value { color: var(--accent); }
.stat-sub { font-size: .72rem; color: var(--muted); }

/* ── Gráficos ── */
.chart-card { padding-bottom: 12px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { display: flex; gap: 12px; font-size: .74rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { position: relative; width: 100%; }
.gt-chart-svg { width: 100%; height: auto; display: block; aspect-ratio: 720 / 340; }
.gt-grid { stroke: var(--line); stroke-width: 1; }
.gt-axis-label { fill: var(--muted); font-size: 13px; font-family: inherit; }
.gt-empty { fill: var(--muted); font-size: 16px; }
.gt-marker { stroke: rgba(230, 233, 239, .35); stroke-width: 1; stroke-dasharray: 4 3; }
.gt-marker-bar { fill: rgba(255, 255, 255, .05); }
.chart-note { font-size: .74rem; margin: 8px 2px 0; }

.gt-tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--bg-elev2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: .78rem; box-shadow: var(--shadow); min-width: 130px;
}
.gt-tip-title { font-weight: 700; margin-bottom: 5px; color: var(--text); }
.gt-tip-row { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.gt-tip-row b { color: var(--text); }
.gt-tip-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.gt-tip-total { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }

/* ── Formulários ── */
.form { display: flex; flex-direction: column; gap: 11px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: .78rem; color: var(--muted); }
.form-span { grid-column: 1 / -1; }
input, select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 1rem;
  font-family: inherit; -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 197, 94, .15); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b97a7' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}

.btn {
  border: 0; border-radius: 10px; padding: 12px 16px; font-size: 1rem; font-weight: 650;
  font-family: inherit; cursor: pointer; min-height: 44px; transition: filter .15s, opacity .15s;
}
.btn:active { filter: brightness(.92); }
.btn-primary { background: var(--accent); color: #06210f; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }

/* ── Listas ── */
.list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.list li { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.list li.empty { justify-content: center; color: var(--muted); font-size: .84rem; border-style: dashed; }
.row-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.row-main b { font-size: .98rem; }
.row-main .muted { font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 3px 7px; border-radius: 6px; }
.tag-in { background: rgba(34, 197, 94, .16); color: var(--accent); }
.tag-out { background: rgba(239, 68, 68, .16); color: var(--danger); }
.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 6px; border-radius: 8px; min-width: 34px; min-height: 34px; }
.icon-btn:hover { color: var(--danger); background: rgba(239, 68, 68, .1); }

/* ── Calculadora ── */
.calc-result { text-align: center; }
.calc-lote { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0 16px; }
.calc-lote-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.calc-lote-value { font-size: 3rem; font-weight: 800; color: var(--accent); line-height: 1; }
.calc-lote-sub { font-size: .78rem; color: var(--muted); }
.calc-breakdown { display: grid; gap: 8px; text-align: left; border-top: 1px solid var(--line); padding-top: 14px; }
.calc-breakdown > div { display: flex; justify-content: space-between; align-items: baseline; font-size: .88rem; }
.calc-breakdown span { color: var(--muted); }

/* ── Navegação inferior ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(13, 15, 18, .95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.nav-btn {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 0 9px; font-size: .68rem; font-family: inherit; min-height: 56px;
}
.nav-btn.active { color: var(--accent); }
.nav-ico { font-size: 1.25rem; line-height: 1; filter: grayscale(.2); }

/* ── Overlay de login ── */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: none;
  place-items: center; padding: 24px; background: var(--bg);
}
.overlay.show { display: grid; }
.login-card {
  width: 100%; max-width: 340px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.login-card h1 { font-size: 1.4rem; }
.login-card input, .login-card .btn { width: 100%; }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  z-index: 60; background: var(--bg-elev2); color: var(--text); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--accent); }
.toast.error { border-color: var(--danger); }
.toast.warn { border-color: var(--warn); }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 55; display: none; place-items: center; padding: 24px; background: rgba(0, 0, 0, .6); }
.modal.show { display: grid; }
.modal-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; max-width: 360px; width: 100%; box-shadow: var(--shadow); }
.modal-card h3 { margin-bottom: 8px; }
.modal-card p { color: var(--muted); margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.about p { margin: 0; }

/* ── Desktop / tablet ── */
@media (min-width: 720px) {
  .two-col { grid-template-columns: 1fr 1fr; gap: 14px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .app-main { padding: 22px; }
}
