/* app.css — PWA mobile-first dark. Standalone (no base.css).
   Layout: topbar sticky + scrollable main + bottom nav fija. */

:root {
  --bg:          #0A0A0F;
  --bg-2:        #11111A;
  --bg-3:        #161621;
  --bg-elev:     #1B1B28;
  --surface:     rgba(255,255,255,.04);
  --surface-2:   rgba(255,255,255,.07);
  --border:      rgba(255,255,255,.08);
  --border-2:    rgba(255,255,255,.14);
  --text:        #F5F5F7;
  --text-muted:  #8A8A98;
  --text-dim:    #5C5C68;
  --brand:       #FF8A3D;
  --brand-hi:    #FFA060;
  --brand-lo:    #E8742A;
  --brand-glow:  rgba(255,138,61,.4);
  --accent-2:    #7C5CFF;
  --success:     #4ADE80;
  --warning:     #FBBF24;
  --danger:      #F87171;
  --radius:      14px;
  --radius-lg:   20px;
  --radius-pill: 999px;
  --topbar-h:    56px;
  --bottomnav-h: 64px;
  --font-sans:   "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:   ui-monospace, "JetBrains Mono", "Fira Code", Consolas, monospace;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: var(--font-sans);
  font-feature-settings: "cv02","cv03","cv04","cv11";
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { background: transparent; border: 0; cursor: pointer; }
::selection { background: var(--brand); color: #0A0A0F; }

.bg-mesh {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 40% at 50% 0%, rgba(255,138,61,.14), transparent 70%),
    radial-gradient(50% 50% at 100% 100%, rgba(124,92,255,.06), transparent 70%),
    var(--bg);
}

/* ============ TOPBAR ============ */
.topbar {
  position: sticky;
  top: 0; z-index: 30;
  padding-top: var(--safe-top);
  background: rgba(10,10,15,.75);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.brand-mini {
  display: flex; align-items: center; gap: 9px;
  font-weight: 600;
}
.brand-mini img { height: 24px; width: auto; }
.brand-mini span { font-size: 16px; letter-spacing: -.01em; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.iconbtn {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: var(--text-muted);
  position: relative;
  transition: background .12s, color .12s;
}
.iconbtn:active { background: var(--surface); color: var(--text); }
.iconbtn .badge-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--bg);
}
.avatar-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-hi), var(--accent-2));
  color: #1A0E03; font-weight: 600; font-size: 13px;
  display: grid; place-items: center;
}

/* ============ MAIN ============ */
.app-main {
  padding: 16px 16px calc(var(--bottomnav-h) + var(--safe-bottom) + 24px);
  max-width: 560px;
  margin: 0 auto;
}

.greeting {
  margin-bottom: 18px;
}
.greeting .hi {
  font-size: 13px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin: 0 0 4px;
}
.greeting h1 {
  margin: 0; font-size: 24px;
  letter-spacing: -.02em; font-weight: 600;
}

/* ============ HERO CARD (balance) ============ */
.hero-card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  background:
    radial-gradient(80% 100% at 100% 0%, rgba(255,138,61,.18), transparent 60%),
    radial-gradient(80% 100% at 0% 100%, rgba(124,92,255,.14), transparent 60%),
    linear-gradient(180deg, var(--bg-elev), var(--bg-2));
  border: 1px solid var(--border-2);
  overflow: hidden;
}
.hero-card::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse at top right, #000, transparent 70%);
  pointer-events: none;
}
.hero-label {
  position: relative;
  font-size: 12.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.hero-label svg { color: var(--brand-hi); }
.hero-amount {
  position: relative;
  font-size: 38px;
  letter-spacing: -.025em;
  font-weight: 600;
  margin-bottom: 8px;
  background: linear-gradient(180deg, #FFF, #C8C8D0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-meta {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
}
.trend {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 12.5px;
}
.trend.up { color: var(--success); background: rgba(74,222,128,.1); }
.trend.down { color: var(--danger); background: rgba(248,113,113,.1); }

/* ============ QUICK ACTIONS ============ */
.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  margin: 24px 4px 12px;
  font-weight: 500;
  display: flex; justify-content: space-between; align-items: center;
}
.section-title a { color: var(--brand-hi); text-transform: none; letter-spacing: 0; font-size: 13px; }
.actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.action {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 6px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  text-align: center;
  transition: background .1s, transform .1s, border-color .1s;
}
.action:active { transform: scale(0.97); background: var(--surface-2); }
.action .icon-wrap {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,138,61,.18), rgba(255,138,61,.05));
  border: 1px solid rgba(255,138,61,.22);
  color: var(--brand-hi);
  display: grid; place-items: center;
}

/* ============ LIST ============ */
.list-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--surface); }
.list-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.list-icon.brand { background: rgba(255,138,61,.12); color: var(--brand-hi); border-color: rgba(255,138,61,.22); }
.list-icon.ok    { background: rgba(74,222,128,.1); color: var(--success); border-color: rgba(74,222,128,.22); }
.list-icon.warn  { background: rgba(251,191,36,.1); color: var(--warning); border-color: rgba(251,191,36,.22); }
.list-body { flex: 1; min-width: 0; }
.list-title {
  font-size: 14.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-meta {
  font-size: 12.5px; color: var(--text-muted);
  margin-top: 2px;
}
.list-amount {
  font-size: 14.5px; font-weight: 600;
  font-family: var(--font-mono);
  flex-shrink: 0;
  text-align: right;
}
.list-amount.neg { color: var(--text); }
.list-amount.pos { color: var(--success); }

/* ============ MINI CARD ============ */
.mini-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.mini-card h3 {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}
.kv-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { color: var(--text-muted); }
.kv-row .v {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  max-width: 60%;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ PLAYGROUND ============ */
.field {
  display: flex; align-items: stretch;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
}
.field input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  padding: 12px 14px;
  font-size: 14px;
  font-family: var(--font-mono);
}
.field input::placeholder { color: var(--text-dim); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .1s, box-shadow .18s, background .12s;
  min-height: 44px;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, var(--brand-hi), var(--brand-lo));
  color: #1A0E03;
  box-shadow: 0 0 0 1px rgba(255,138,61,.4),
              0 6px 18px -8px var(--brand-glow),
              inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-2);
}
.field .btn {
  border-radius: 0;
  border-left: 1px solid var(--border);
  padding: 0 18px;
  min-height: auto;
}
.codeblock {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
  overflow-x: auto;
  min-height: 50px;
  white-space: pre-wrap;
  word-break: break-word;
}
.codeblock .empty { color: var(--text-dim); font-style: italic; }

/* ============ BOTTOM NAV ============ */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 40;
  padding-bottom: var(--safe-bottom);
  background: rgba(10,10,15,.85);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--border);
}
.bottomnav-inner {
  height: var(--bottomnav-h);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 560px; margin: 0 auto;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-dim);
  font-size: 11px;
  position: relative;
  transition: color .1s;
}
.tab:active { color: var(--text-muted); }
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--brand-hi); }
.tab.active::before {
  content: ""; position: absolute;
  top: -1px; left: 50%; transform: translateX(-50%);
  width: 28px; height: 2px;
  background: var(--brand);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 0 12px var(--brand-glow);
}
.tab.fab .fab-circle {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--brand-hi), var(--brand-lo));
  color: #1A0E03;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px var(--brand-glow),
              0 0 0 1px rgba(255,138,61,.5),
              inset 0 1px 0 rgba(255,255,255,.25);
  margin-top: -10px;
}
.tab.fab .fab-circle svg { width: 24px; height: 24px; }
.tab.fab span { display: none; }

/* ============ LOGIN ============ */
.login-page {
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
  max-width: 460px;
  margin: 0 auto;
}
.login-brand {
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  margin-bottom: 36px;
}
.login-brand img { height: 38px; }
.login-brand span { font-size: 22px; font-weight: 600; letter-spacing: -.015em; }
.login-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  position: relative;
}
.login-card::before {
  content: ""; position: absolute; inset: -1px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,138,61,.25), transparent 40%);
  z-index: -1;
  filter: blur(8px);
  opacity: .6;
}
.login-card h1 {
  text-align: center;
  font-size: 20px;
  letter-spacing: -.02em;
  margin: 0 0 6px;
  font-weight: 600;
}
.login-card .sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--text-muted); font-weight: 500;
}
.login-form input {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 13px 14px;
  font-size: 16px; /* >=16px evita zoom de iOS al focus */
  color: var(--text);
}
.login-form input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--bg);
  box-shadow: 0 0 0 3px rgba(255,138,61,.14);
}
.login-form .btn { margin-top: 8px; }
.login-error {
  background: rgba(248,113,113,.08);
  border: 1px solid rgba(248,113,113,.25);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #FF9999;
  margin: 0;
}
.login-hint {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}
.login-hint code {
  font-family: var(--font-mono);
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--brand-hi);
  font-size: 11.5px;
}
