/* Trakinver — estilos de aplicación (Dark Finance Dashboard) */

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

.mono-nums { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}
.sidebar__logo {
  width: 40px; height: 40px;
  background: url("/static/images/logo.15bf652fe33b.png") center/contain no-repeat;
  margin-bottom: 18px;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sidebar__sep { width: 28px; height: 1px; background: var(--border); margin: 10px 0; }
.nav-item {
  position: relative;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-item.is-active { color: var(--accent); background: var(--accent-dim); }
.nav-item svg { width: 20px; height: 20px; stroke-width: 1.5; }
.nav-item__badge {
  position: absolute; top: 6px; right: 6px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--negative); color: #fff;
  font-size: 10px; font-weight: 600;
  border-radius: 8px; display: grid; place-items: center;
}
.nav-item__tooltip {
  position: absolute; left: 52px; white-space: nowrap;
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 5px 9px; border-radius: var(--radius-sm);
  font-size: 12px; opacity: 0; pointer-events: none;
  transform: translateX(-4px); transition: all .15s ease; z-index: 20;
}
.nav-item:hover .nav-item__tooltip { opacity: 1; transform: translateX(0); }

/* ---------- Main / Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) 24px 0; position: sticky; top: 0;
  background: rgba(17,17,18,.85); backdrop-filter: blur(10px); z-index: 10;
}
.topbar__title { display: flex; align-items: baseline; gap: 10px; }
.topbar__title h1 { font-size: 18px; font-weight: 500; }
.topbar__title small { font-size: 13px; color: var(--text-secondary); font-weight: 400; }
.topbar__right { display: flex; align-items: center; gap: 16px; }
.topbar__date { font-size: 13px; color: var(--text-secondary); }
.content { padding: 24px; animation: page-in .2s ease; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Bento grid ---------- */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}
.col-1{grid-column:span 1}.col-2{grid-column:span 2}.col-3{grid-column:span 3}
.col-4{grid-column:span 4}.col-5{grid-column:span 5}.col-6{grid-column:span 6}
.col-7{grid-column:span 7}.col-8{grid-column:span 8}.col-9{grid-column:span 9}
.col-10{grid-column:span 10}.col-12{grid-column:span 12}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: border-color .2s ease, box-shadow .2s ease;
  position: relative;
  min-width: 0;
}
.card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-glow); }
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card__label { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 7px; }
.card__label svg { width: 16px; height: 16px; }
.card__expand { color: var(--text-muted); transition: color .15s ease; }
.card:hover .card__expand { color: var(--text-secondary); }
.card__expand svg { width: 16px; height: 16px; }

/* Hero (saldo total) */
.hero {
  background: var(--gradient-hero);
  border-radius: var(--radius-xl);
  padding: 24px;
  color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 200px;
  border: none;
}
.hero:hover { box-shadow: var(--shadow-card); }
.hero__label { font-size: 13px; color: rgba(255,255,255,.75); display: flex; align-items: center; gap: 7px; }
.hero__amount { font-size: 48px; font-weight: 600; line-height: 1.1; margin: 6px 0; }
.hero__amount .cents { font-size: 28px; color: rgba(255,255,255,.6); }
.hero__amount .cur { font-size: 16px; color: rgba(255,255,255,.5); font-weight: 400; margin-left: 6px; }
.hero__divider { height: 1px; background: rgba(255,255,255,.14); margin: 14px 0; }
.hero__foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: rgba(255,255,255,.7); }
.hero__stats { display: flex; flex-wrap: wrap; gap: 14px 28px; margin-top: 22px; }
.hero__stat { display: flex; flex-direction: column; gap: 3px; }
.hero__stat .k { font-size: 11px; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .05em; }
.hero__stat .v { font-size: 16px; font-weight: 600; color: rgba(255,255,255,.95); }
.hero__stat .v.pos { color: #BBF7D0; }
.hero__stat .v.neg { color: #FECACA; }

/* Cifras */
.bignum { font-size: 28px; font-weight: 600; }
.bignum--pos { color: var(--positive); }
.bignum--neg { color: var(--negative); }
.metric-row { display: flex; align-items: center; gap: 12px; }
.subtle { color: var(--text-secondary); font-size: 13px; }
.muted { color: var(--text-muted); font-size: 12px; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.pill--pos { background: var(--positive-dim); color: var(--positive); }
.pill--neg { background: var(--negative-dim); color: var(--negative); }
.pill--neutral { background: var(--accent-dim); color: var(--accent); }
.pill--warn { background: var(--neutral-dim); color: var(--neutral); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ---------- Distribución (leyenda) ---------- */
.legend { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.legend li .pct { margin-left: auto; color: var(--text-primary); font-weight: 500; }

/* ---------- Alertas ---------- */
.alert-card { background: rgba(250,204,21,.08); border: 1px solid rgba(250,204,21,.2); }
.alert-card .card__label { color: var(--neutral); }
.alert-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.alert-list li { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }
.alert-list li b { color: var(--neutral); font-weight: 500; }

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data thead th {
  text-align: left; font-size: 11px; font-weight: 500;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em;
  padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data thead th.num, table.data tbody td.num { text-align: right; }
table.data tbody td { padding: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data tbody tr { transition: background .15s ease; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: rgba(255,255,255,.02); }
table.data tbody tr.total-row td { border-top: 2px solid var(--border-hover); border-bottom: none; font-weight: 600; color: var(--text-primary); padding-top: 14px; }
table.data .cell-name { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.txt-pos { color: var(--positive); }
.txt-neg { color: var(--negative); }
.row-highlight { background: rgba(178,229,249,.04); }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: none; border-radius: var(--radius-sm); padding: 10px 18px; font-size: 13px; font-weight: 600; transition: all .15s ease; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--accent); color: #111112; }
.btn--primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn--primary:active { transform: translateY(0); }
.btn--ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); font-weight: 500; }
.btn--ghost:hover { border-color: var(--border-hover); color: var(--text-primary); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; filter: none; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; color: var(--text-secondary); }
.input { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; color: var(--text-primary); font-family: inherit; font-size: 14px; transition: border-color .15s ease, box-shadow .15s ease; width: 100%; }
.input::placeholder { color: var(--text-muted); }
.input:hover { border-color: var(--border-hover); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(178,229,249,.12); }
.input-money { display: flex; align-items: center; gap: 8px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 14px; transition: border-color .15s ease, box-shadow .15s ease; }
.input-money:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(178,229,249,.12); }
.input-money .prefix { color: var(--text-muted); font-size: 16px; }
.input-money input { background: transparent; border: none; outline: none; color: var(--text-primary); font-family: inherit; font-size: 20px; font-weight: 500; width: 100%; padding: 8px 0; }

/* ---------- Pills de rango (3M/6M/1A/Todo) ---------- */
.range-pills { display: inline-flex; gap: 4px; background: var(--bg-elevated); padding: 3px; border-radius: var(--radius-sm); }
.range-pills button { background: transparent; border: 1px solid transparent; color: var(--text-secondary); font-size: 12px; font-weight: 500; padding: 5px 11px; border-radius: 6px; transition: all .15s ease; }
.range-pills button:hover { color: var(--text-primary); }
.range-pills button.is-active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ---------- Charts ---------- */
.chart { width: 100%; }
.chart-donut-wrap { position: relative; display: grid; place-items: center; }

/* ---------- Wizard de snapshot ---------- */
.wizard { max-width: 640px; margin: 0 auto; }
.progress { margin: 8px 0 22px; }
.progress__track { height: 8px; background: var(--bg-elevated); border-radius: 8px; overflow: hidden; }
.progress__fill { height: 100%; background: var(--accent); width: 0; transition: width .3s ease; border-radius: 8px; }
.progress__text { font-size: 13px; color: var(--text-secondary); margin-top: 8px; }
.snap-card__name { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 500; }
.snap-card__last { font-size: 13px; color: var(--text-secondary); margin: 6px 0 18px; }
.calc-result { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 7px; opacity: 0; transition: opacity .25s ease; min-height: 22px; }
.calc-result.show { opacity: 1; }
.calc-result svg { width: 18px; height: 18px; }
.wizard__nav { display: flex; justify-content: space-between; margin-top: 22px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.62); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 48px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; animation: overlay-in .18s ease; }
.modal {
  width: 100%; max-width: 620px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  box-shadow: var(--shadow-card); animation: modal-in .22s ease;
}
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal__close { background: none; border: none; color: var(--text-muted); padding: 4px; border-radius: var(--radius-sm); transition: color .15s ease, background .15s ease; }
.modal__close:hover { color: var(--text-primary); background: var(--bg-elevated); }
.modal__close svg { width: 20px; height: 20px; display: block; }
.modal #snap-card { margin-top: 4px; }
body.modal-open { overflow: hidden; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@media (max-width: 768px) { .modal-overlay { padding: calc(24px + env(safe-area-inset-top, 0px)) 12px calc(90px + env(safe-area-inset-bottom, 0px)); } }

/* ---------- Toast ---------- */
.toast-host { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }
.toast { display: flex; align-items: center; gap: 10px; background: #1C2B1C; border: 1px solid var(--positive); color: var(--text-primary); padding: 12px 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-card); animation: toast-in .25s ease; }
.toast--error { background: #2B1C1C; border-color: var(--negative); }
.toast svg { width: 18px; height: 18px; color: var(--positive); }
.toast--error svg { color: var(--negative); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; background: var(--bg-base); padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; }
.login-logo { width: 64px; height: 64px; background: url("/static/images/logo.15bf652fe33b.png") center/contain no-repeat; margin: 0 auto 20px; }
.login-card h1 { font-size: 22px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.login-card p.sub { text-align: center; color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; }
.login-error { background: var(--negative-dim); color: var(--negative); font-size: 13px; padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 16px; }

/* ---------- Misc page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px; }
.back-link:hover { color: var(--text-primary); }
.back-link svg { width: 16px; height: 16px; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.row-gap { display: flex; gap: 16px; flex-wrap: wrap; }
.section-title { font-size: 16px; font-weight: 500; margin-bottom: 14px; }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--bg-elevated) 25%, rgba(255,255,255,.04) 50%, var(--bg-elevated) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .col-3,.col-4,.col-5,.col-6,.col-7,.col-8,.col-9,.col-10 { grid-column: span 12; }
  .col-2 { grid-column: span 6; }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    height: auto; width: 100%;
    flex-direction: row; justify-content: space-around; align-items: center;
    border-right: none; border-top: 1px solid var(--border);
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 12px)) 0; z-index: 30;
    background: var(--bg-sidebar);
  }
  .sidebar__logo, .sidebar__sep { display: none; }
  .sidebar__nav { flex-direction: row; gap: 4px; flex: 1; justify-content: space-around; }
  .nav-item__tooltip { display: none; }
  .content { padding: 16px 16px calc(88px + env(safe-area-inset-bottom, 12px)); }
  .col-2 { grid-column: span 12; }
  .hero__amount { font-size: 38px; }
}

/* ---------- Ticker Tape (Cabecera) ---------- */
.ticker-tape-container {
  flex: 1;
  margin: 0 24px;
  overflow: hidden;
  position: relative;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 16px;
  display: flex;
  align-items: center;
}
.ticker-tape-wrapper {
  overflow: hidden;
  width: 100%;
  position: relative;
}
.ticker-tape {
  display: flex;
  align-items: center;
  gap: 48px;
  white-space: nowrap;
  animation: ticker-slide 35s linear infinite;
  width: max-content;
}
.ticker-tape:hover {
  animation-play-state: paused;
}
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
}
.ticker-name {
  font-weight: 600;
  color: var(--text-secondary);
}
.ticker-change {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 2px;
}
.ticker-pos {
  background: var(--positive-dim);
  color: var(--positive);
}
.ticker-neg {
  background: var(--negative-dim);
  color: var(--negative);
}
.ticker-val {
  font-weight: 500;
}
.ticker-secondary {
  color: var(--text-muted);
  font-size: 11px;
}

@keyframes ticker-slide {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-50%, 0, 0); }
}

@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
    gap: 8px;
  }
  .topbar [data-open-snapshot] {
    display: none;
  }
  .ticker-tape-container {
    order: 3;
    margin: 4px 0 0 0;
    width: 100%;
    flex: 0 0 100%;
  }
}
