/* Finanzas — fintech premium dark
   Paleta: navy profundo + glass + esmeralda/dorado, verde/rojo para variaciones */

:root {
  --bg: #0b0f1a;
  --bg-soft: #101627;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --card-hover: rgba(255, 255, 255, 0.07);
  --text: #e6e9f2;
  --text-dim: #8b93a7;
  --text-faint: #5b647a;
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --gold: #f5c453;
  --gold-soft: rgba(245, 196, 83, 0.12);
  --up: #34d399;
  --down: #f87171;
  --up-soft: rgba(52, 211, 153, 0.12);
  --down-soft: rgba(248, 113, 113, 0.12);
  --blue: #60a5fa;
  --violet: #a78bfa;
  --radius: 18px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100dvh;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

.bg-glow, .login-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 400px at 85% -10%, rgba(16,185,129,.13), transparent 60%),
    radial-gradient(500px 380px at -10% 20%, rgba(96,165,250,.10), transparent 60%),
    radial-gradient(700px 500px at 50% 120%, rgba(167,139,250,.08), transparent 60%);
}

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 15, 26, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
}
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 9px; width: 30px; height: 30px;
  display: grid; place-items: center; font-size: .9rem;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.dolar-chip {
  font-family: var(--mono); font-size: .74rem; font-weight: 700;
  color: var(--gold); background: var(--gold-soft);
  border: 1px solid rgba(245,196,83,.25);
  padding: 5px 10px; border-radius: 99px; white-space: nowrap;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 11px;
  border: 1px solid var(--card-border); background: var(--card);
  color: var(--text-dim); font-size: 1rem; cursor: pointer;
  display: grid; place-items: center; text-decoration: none;
  transition: .15s;
}
.icon-btn:hover { color: var(--text); background: var(--card-hover); }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Layout ---- */
.view { max-width: 900px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.section-title {
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--text-faint); margin: 6px 2px 0;
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Hero del portfolio */
.hero {
  background: linear-gradient(135deg, rgba(16,185,129,.14), rgba(96,165,250,.07) 55%, rgba(167,139,250,.09));
  border: 1px solid rgba(16,185,129,.22);
  border-radius: 22px;
  padding: 22px 20px;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; top: -60px; right: -60px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245,196,83,.14), transparent 70%);
}
.hero-label { font-size: .78rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.hero-total { font-family: var(--mono); font-size: clamp(1.9rem, 7vw, 2.7rem); font-weight: 700; letter-spacing: -0.03em; margin: 4px 0 2px; }
.hero-usd { font-family: var(--mono); font-size: 1.05rem; color: var(--gold); font-weight: 700; }
.hero-pl { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; }
.pl-chip {
  font-family: var(--mono); font-size: .8rem; font-weight: 700;
  padding: 5px 11px; border-radius: 99px;
}
.pl-chip.up { color: var(--up); background: var(--up-soft); }
.pl-chip.down { color: var(--down); background: var(--down-soft); }
.pl-chip.flat { color: var(--text-dim); background: var(--card); }
.currency-toggle {
  position: absolute; top: 16px; right: 16px; z-index: 1;
  display: flex; border: 1px solid var(--card-border); border-radius: 99px; overflow: hidden;
}
.currency-toggle button {
  border: 0; background: transparent; color: var(--text-dim);
  font-family: var(--mono); font-weight: 700; font-size: .72rem;
  padding: 5px 12px; cursor: pointer;
}
.currency-toggle button.active { background: var(--accent-soft); color: var(--accent); }

/* Grid de dólares */
.dolar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
.dolar-cell { background: var(--card); border: 1px solid var(--card-border); border-radius: 13px; padding: 10px 12px; }
.dolar-cell .k { font-size: .68rem; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.dolar-cell .v { font-family: var(--mono); font-weight: 700; font-size: .95rem; margin-top: 2px; }

/* ---- Holdings ---- */
.holding {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px; align-items: center;
  padding: 13px 14px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 15px; cursor: pointer; transition: .15s;
}
.holding:hover { background: var(--card-hover); transform: translateY(-1px); }
.asset-ico {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.05rem; font-weight: 800;
}
.asset-ico.accion, .asset-ico.cedear { background: rgba(96,165,250,.14); color: var(--blue); }
.asset-ico.bono { background: rgba(167,139,250,.14); color: var(--violet); }
.asset-ico.cripto { background: var(--gold-soft); color: var(--gold); }
.asset-ico.fci { background: rgba(52,211,153,.12); color: var(--up); }
.asset-ico.dolar { background: var(--up-soft); color: var(--up); }
.asset-ico.plazo_fijo { background: rgba(248,113,113,.10); color: #fca5a5; }
.holding-name { font-weight: 700; font-size: .95rem; }
.holding-sub { font-size: .74rem; color: var(--text-dim); font-family: var(--mono); margin-top: 2px; }
.holding-val { text-align: right; }
.holding-money { font-family: var(--mono); font-weight: 700; font-size: .95rem; }
.holding-pl { font-family: var(--mono); font-size: .74rem; font-weight: 700; margin-top: 2px; }
.up-t { color: var(--up); } .down-t { color: var(--down); } .flat-t { color: var(--text-dim); }

/* ---- Tablas ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th { text-align: left; color: var(--text-faint); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; padding: 8px 10px; border-bottom: 1px solid var(--card-border); }
td { padding: 10px; border-bottom: 1px solid rgba(255,255,255,.04); font-family: var(--mono); font-size: .8rem; }
td.txt { font-family: var(--sans); }
tr:last-child td { border-bottom: 0; }

/* ---- Botones y forms ---- */
.btn {
  border: 0; border-radius: 12px; padding: 11px 18px;
  font-weight: 700; font-size: .88rem; cursor: pointer; font-family: var(--sans);
  transition: .15s;
}
.btn-primary { background: linear-gradient(135deg, #10b981, #0d9f74); color: #04110b; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--card-border); }
.btn-danger { background: var(--down-soft); color: var(--down); }
.btn-sm { padding: 6px 12px; font-size: .76rem; border-radius: 9px; }
.btn-block { width: 100%; }

.fab {
  position: fixed; right: 18px; bottom: calc(92px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 18px; border: 0;
  background: linear-gradient(135deg, #10b981, #0d9f74);
  color: #04110b; font-size: 1.6rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 28px rgba(16,185,129,.35);
  z-index: 25;
}

label { font-size: .76rem; font-weight: 600; color: var(--text-dim); display: block; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px;
  border-radius: 11px; border: 1px solid var(--card-border);
  background: var(--bg-soft); color: var(--text);
  font-family: var(--sans); font-size: .9rem;
}
input:focus, select:focus { outline: 2px solid rgba(16,185,129,.4); border-color: transparent; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-hint { font-size: .7rem; color: var(--text-faint); margin-top: 3px; }

/* ---- Tab bar ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: rgba(13, 18, 32, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
}
.tab {
  border: 0; background: transparent; color: var(--text-faint);
  font-family: var(--sans); font-size: .64rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 10px; border-radius: 12px; cursor: pointer; position: relative;
  transition: .15s;
}
.tab-ico { font-size: 1.15rem; line-height: 1; }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.badge {
  position: absolute; top: 2px; right: 4px;
  min-width: 16px; height: 16px; border-radius: 99px;
  background: var(--down); color: #fff;
  font-size: .6rem; font-weight: 800; display: grid; place-items: center; padding: 0 4px;
}

/* ---- Modal ---- */
.modal-back {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 6, 12, 0.7);
  backdrop-filter: blur(4px);
  display: grid; place-items: end center;
  animation: fadeIn .18s;
}
@media (min-width: 640px) { .modal-back { place-items: center; } }
.modal {
  background: #121a2c; border: 1px solid var(--card-border);
  border-radius: 22px 22px 0 0; width: 100%; max-width: 560px;
  max-height: 88dvh; overflow-y: auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .22s cubic-bezier(.2,.9,.3,1);
}
@media (min-width: 640px) { .modal { border-radius: 22px; } }
.modal h3 { margin: 0 0 4px; font-size: 1.1rem; }
.modal-sub { color: var(--text-dim); font-size: .8rem; margin: 0 0 8px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }

/* ---- Toast ---- */
#toast-root { position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 60; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: #17203a; border: 1px solid var(--card-border);
  color: var(--text); font-size: .84rem; font-weight: 600;
  padding: 10px 18px; border-radius: 99px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  animation: slideDown .25s;
}
.toast.err { border-color: rgba(248,113,113,.4); color: var(--down); }
@keyframes slideDown { from { transform: translateY(-16px); opacity: 0; } }

/* ---- Charts ---- */
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 280px; }

/* ---- Alert cards ---- */
.alert-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--card-border); border-radius: 14px; }
.alert-row.triggered { border-color: rgba(245,196,83,.4); background: var(--gold-soft); }
.alert-row.off { opacity: .5; }
.alert-info { flex: 1; }
.alert-title { font-weight: 700; font-size: .88rem; }
.alert-sub { font-size: .74rem; color: var(--text-dim); font-family: var(--mono); margin-top: 2px; }

.empty {
  text-align: center; color: var(--text-faint); padding: 36px 16px;
  border: 1px dashed var(--card-border); border-radius: var(--radius);
  font-size: .88rem;
}
.empty .big { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ---- Login ---- */
.login-body { display: grid; place-items: center; min-height: 100dvh; padding: 0 16px; }
.login-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 24px; padding: 34px 26px;
  backdrop-filter: blur(10px);
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 14px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 17px; display: grid; place-items: center; font-size: 1.5rem;
}
.login-card h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.login-sub { color: var(--text-dim); font-size: .85rem; margin: 4px 0 20px; }
.login-card input { margin-bottom: 10px; text-align: center; }
.login-card button {
  width: 100%; padding: 12px; border: 0; border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #0d9f74);
  color: #04110b; font-weight: 800; font-size: .95rem; cursor: pointer;
}
.login-error { color: var(--down); font-size: .82rem; }

.muted { color: var(--text-dim); font-size: .8rem; }
.mono { font-family: var(--mono); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
