/* ============================================================
   finanzas.mitempo.app — sistema visual
   Dark, profesional, minimalista. IBM Plex Sans + Mono.
   Todos los tokens son CSS vars para que Tweaks pueda pisarlos.
   ============================================================ */

:root {
  --bg:        #1d1f23;
  --bg-2:      #191b1e;
  --surface:   #252830;
  --surface-2: #2c303a;
  --surface-3: #343945;

  --border:        #343845;
  --border-soft:   #2b2f39;
  --border-strong: #424857;

  --text:   #e8e8e8;
  --text-2: #a8adba;
  --text-3: #6b7180;
  --text-4: #4a4f5c;

  --pos:  #00ff88;
  --neg:  #ff4444;
  --info: #4488ff;
  --warn: #ffb020;
  --muted: #6b7180;

  --pos-dim:   color-mix(in oklab, var(--pos) 16%, transparent);
  --neg-dim:   color-mix(in oklab, var(--neg) 16%, transparent);
  --info-dim:  color-mix(in oklab, var(--info) 16%, transparent);
  --warn-dim:  color-mix(in oklab, var(--warn) 16%, transparent);
  --muted-dim: color-mix(in oklab, var(--muted) 18%, transparent);

  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --radius:    6px;
  --radius-lg: 10px;
  --radius-sm: 4px;

  --row-pad-y: 11px;
  --cell-fs:   13.5px;

  --shadow:    0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.55);

  --sidebar-w: 232px;
  --header-h:  62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overflow: hidden; }

.mono, .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
  letter-spacing: -0.01em;
}

::selection { background: color-mix(in oklab, var(--info) 40%, transparent); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 99px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ===================== layout shell ===================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ---- sidebar ---- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 4px;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 18px;
}
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: var(--radius-sm);
  background: var(--pos);
  display: grid; place-items: center;
  color: #06170e;
  font-family: var(--mono);
  font-weight: 700; font-size: 17px;
}
.brand-name {
  font-family: var(--mono); font-size: 15px;
  letter-spacing: -0.02em; font-weight: 500;
}
.brand-name b { font-weight: 700; }
.brand-name span { color: var(--text-3); }

.nav-label {
  font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.13em; color: var(--text-4);
  padding: 14px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius);
  color: var(--text-2); cursor: pointer;
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .12s, color .12s;
  user-select: none;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); border-color: var(--border); }
.nav-item.active .nav-ico { color: var(--pos); }
.nav-ico {
  width: 17px; height: 17px; flex: 0 0 auto;
  color: var(--text-3); transition: color .12s;
}
.nav-spacer { flex: 1; }
.sidebar-foot {
  border-top: 1px solid var(--border-soft);
  padding-top: 12px; margin-top: 8px;
  display: flex; align-items: center;
  gap: 10px; padding-left: 8px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-3);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  color: var(--text-2); flex: 0 0 auto;
}

/* ---- main column ---- */
.main {
  display: flex; flex-direction: column;
  min-width: 0; height: 100vh; overflow: hidden;
}
.topbar {
  height: var(--header-h); flex: 0 0 auto;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  backdrop-filter: blur(8px);
}
.topbar h1 {
  font-size: 18px; font-weight: 600; margin: 0;
  letter-spacing: -0.01em;
}
.topbar .sub {
  font-size: 12.5px; color: var(--text-3);
  display: flex; align-items: center; gap: 7px;
}
.topbar-right {
  margin-left: auto; display: flex;
  align-items: center; gap: 12px;
}
.last-upd {
  font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono);
}
.dot-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pos);
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--pos) 60%, transparent);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--pos) 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.content {
  flex: 1 1 auto; overflow-y: auto;
  padding: 26px; scroll-behavior: smooth;
}
.content-inner { max-width: 1320px; margin: 0 auto; }

.subbar {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-2);
  padding: 9px 26px;
  display: flex; align-items: center;
  gap: 22px; overflow-x: auto;
  font-size: 12.5px;
}

/* ===================== buttons ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-4); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--pos); color: #06170e; border-color: var(--pos); }
.btn-primary:hover { background: color-mix(in oklab, var(--pos) 88%, white); border-color: var(--pos); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn .spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== cards ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.card-head {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.card-title {
  font-size: 14px; font-weight: 600;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 9px;
}
.card-title .ico { color: var(--text-3); width: 16px; height: 16px; }
.card-sub { font-size: 12px; color: var(--text-3); }

.metric {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px 17px;
  position: relative; overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.metric:hover { border-color: var(--border); }
.metric .m-label {
  font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; font-weight: 500;
}
.metric .m-label .ico { width: 14px; height: 14px; }
.metric .m-value {
  font-family: var(--mono); font-size: 26px; font-weight: 600;
  letter-spacing: -0.03em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.metric .m-value .cur {
  font-size: 15px; color: var(--text-3);
  font-weight: 500; margin-right: 3px;
}
.metric .m-foot {
  margin-top: 11px; display: flex;
  align-items: center; gap: 8px; font-size: 12.5px;
}
.metric .accent-edge {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}

.delta { font-family: var(--mono); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.delta.up   { color: var(--pos); }
.delta.down { color: var(--neg); }
.delta.flat { color: var(--text-3); }
.delta svg  { width: 12px; height: 12px; }
.muted-note { color: var(--text-3); font-size: 12.5px; }

/* ===================== badges / señales ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent; white-space: nowrap;
}
.badge .pip { width: 6px; height: 6px; border-radius: 50%; }
.sig-COMPRAR  { color: var(--pos);    background: var(--pos-dim);   border-color: color-mix(in oklab, var(--pos) 35%, transparent); }
.sig-COMPRAR .pip { background: var(--pos); }
.sig-ACUMULAR { color: var(--info);   background: var(--info-dim);  border-color: color-mix(in oklab, var(--info) 35%, transparent); }
.sig-ACUMULAR .pip { background: var(--info); }
.sig-ESPERAR  { color: var(--text-2); background: var(--muted-dim); border-color: var(--border-strong); }
.sig-ESPERAR .pip { background: var(--muted); }
.sig-VENDER   { color: var(--neg);    background: var(--neg-dim);   border-color: color-mix(in oklab, var(--neg) 35%, transparent); }
.sig-VENDER .pip { background: var(--neg); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; padding: 5px 11px;
  border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2);
  cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
  font-weight: 500;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.active { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.chip .pip { width: 7px; height: 7px; border-radius: 50%; }

.fx-pill {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-soft);
  min-width: 116px;
}
.fx-pill .fx-name { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); font-weight: 600; }
.fx-pill .fx-val  { font-family: var(--mono); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fx-pill .fx-d    { font-family: var(--mono); font-size: 11.5px; }

/* ===================== tables ===================== */
.tbl-wrap { width: 100%; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--cell-fs); }
table.tbl thead th {
  text-align: right; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3); font-weight: 600;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0;
  background: var(--surface);
}
table.tbl thead th:first-child { text-align: left; }
table.tbl tbody td {
  padding: var(--row-pad-y) 14px;
  border-bottom: 1px solid var(--border-soft);
  text-align: right; white-space: nowrap; color: var(--text);
}
table.tbl tbody td:first-child { text-align: left; }
table.tbl tbody tr { transition: background .1s; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.t-ticker { font-family: var(--mono); font-weight: 600; letter-spacing: -0.01em; }
.t-name   { color: var(--text-3); font-size: 12px; font-weight: 400; }
.t-num    { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.t-pos    { color: var(--pos); }
.t-neg    { color: var(--neg); }
.t-sub    { color: var(--text-3); font-size: 11.5px; }

.cat-tag { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.cat-dot { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }

/* ===================== alerts ===================== */
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 15px; border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface-2); border-left-width: 3px;
}
.alert .a-ico   { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.alert .a-title { font-size: 13.5px; font-weight: 600; }
.alert .a-body  { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.alert .a-time  { font-size: 11px; color: var(--text-4); font-family: var(--mono); margin-left: auto; white-space: nowrap; }
.alert.pos  { border-left-color: var(--pos);  } .alert.pos  .a-ico { color: var(--pos); }
.alert.neg  { border-left-color: var(--neg);  } .alert.neg  .a-ico { color: var(--neg); }
.alert.info { border-left-color: var(--info); } .alert.info .a-ico { color: var(--info); }
.alert.warn { border-left-color: var(--warn); } .alert.warn .a-ico { color: var(--warn); }

/* ===================== opportunity row ===================== */
.opp {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 4px; border-bottom: 1px solid var(--border-soft);
  cursor: pointer; transition: background .1s; border-radius: var(--radius);
}
.opp:last-child { border-bottom: none; }
.opp:hover { background: var(--surface-2); }
.opp .rank { font-family: var(--mono); font-size: 12px; color: var(--text-4); width: 18px; text-align: center; flex: 0 0 auto; }
.opp .opp-main { flex: 1; min-width: 0; }
.opp .opp-tk { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.opp .opp-nm { font-size: 11.5px; color: var(--text-3); }
.opp .opp-px { text-align: right; }

/* ===================== forms (config) ===================== */
.field { margin-bottom: 18px; }
.field-label { font-size: 13px; font-weight: 600; margin-bottom: 7px; display: block; }
.field-hint  { font-size: 12px; color: var(--text-3); margin-top: 6px; }
input.inp, select.inp {
  width: 100%; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--sans);
  font-size: 14px; padding: 10px 12px;
  outline: none; transition: border-color .12s;
}
input.inp:focus, select.inp:focus { border-color: var(--info); }
input.inp.mono { font-family: var(--mono); }

.toggle {
  width: 42px; height: 24px; border-radius: 99px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  position: relative; cursor: pointer; flex: 0 0 auto;
  transition: background .15s, border-color .15s;
}
.toggle::after {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-2); top: 2px; left: 2px;
  transition: transform .16s cubic-bezier(.4,1.3,.5,1), background .15s;
}
.toggle.on { background: var(--pos-dim); border-color: color-mix(in oklab, var(--pos) 45%, transparent); }
.toggle.on::after { transform: translateX(18px); background: var(--pos); }

.slider-row { display: flex; align-items: center; gap: 14px; }
input[type=range].rng {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 5px; border-radius: 99px;
  background: var(--surface-3); outline: none;
}
input[type=range].rng::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--pos); cursor: pointer;
  border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--pos);
}
input[type=range].rng::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--pos); cursor: pointer; border: 3px solid var(--bg);
}
.rng-val { font-family: var(--mono); font-size: 15px; font-weight: 600; min-width: 52px; text-align: right; }

.integ {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 16px; border: 1px solid var(--border-soft);
  border-radius: var(--radius); background: var(--surface-2);
}
.integ + .integ { margin-top: 10px; }
.integ-ico {
  width: 38px; height: 38px; border-radius: var(--radius);
  background: var(--bg-2); border: 1px solid var(--border);
  display: grid; place-items: center; flex: 0 0 auto;
}
.integ-ico svg { width: 20px; height: 20px; }
.integ-main { flex: 1; min-width: 0; }
.integ-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.integ-desc { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.status-tag {
  font-size: 10.5px; font-family: var(--mono); font-weight: 600;
  padding: 2px 7px; border-radius: var(--radius-sm);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.status-tag.on  { color: var(--pos);    background: var(--pos-dim); }
.status-tag.off { color: var(--text-3); background: var(--muted-dim); }

/* ===================== misc ===================== */
.grid { display: grid; gap: 16px; }
.row  { display: flex; gap: 16px; }
.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3); font-weight: 600; margin: 4px 0 14px;
}
.divider { height: 1px; background: var(--border-soft); margin: 18px 0; }
.tabs {
  display: flex; gap: 4px; padding: 3px;
  background: var(--bg-2); border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}
.tab {
  padding: 7px 15px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: var(--text-3); cursor: pointer; border: none;
  background: transparent; font-family: var(--sans);
  transition: background .12s, color .12s; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow); }

.kpi-strip    { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.metric-grid  { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.tooltip {
  position: fixed; z-index: 200;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 10px 12px;
  max-width: 250px; font-size: 12px; color: var(--text);
  box-shadow: var(--shadow-lg); pointer-events: none; line-height: 1.45;
}
.tooltip .tt-head { font-family: var(--mono); font-weight: 600; margin-bottom: 4px; font-size: 12px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-3); }

.mobile-nav      { display: none; }
.mobile-topbrand { display: none; }

.page-enter { animation: fadeUp .28s ease; }
@keyframes fadeUp {
  from { transform: translateY(5px); }
  to   { transform: none; }
}
@media (prefers-reduced-motion: reduce) { .page-enter { animation: none; } }

/* ===================== responsive ===================== */
@media (max-width: 900px) {
  body { font-size: 14px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-topbrand {
    display: flex; align-items: center; gap: 9px;
    padding-right: 6px; border-right: 1px solid var(--border-soft); margin-right: 4px;
  }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar h1 { font-size: 16px; }
  .topbar .sub { display: none; }
  .content { padding: 16px 14px 88px; }
  .metric-grid, .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-2); border-top: 1px solid var(--border);
    z-index: 60; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mobile-nav .mn-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 12px; border-radius: var(--radius);
    color: var(--text-3); cursor: pointer;
    font-size: 10px; font-weight: 600; flex: 1;
  }
  .mobile-nav .mn-item svg { width: 20px; height: 20px; }
  .mobile-nav .mn-item.active { color: var(--pos); }
  .last-upd .lu-text { display: none; }
  .subbar { padding: 8px 14px; gap: 14px; }
}

@media (max-width: 560px) {
  .metric-grid, .kpi-strip { grid-template-columns: 1fr 1fr; }
  .metric .m-value { font-size: 22px; }
}

/* ---- Lock screen ---- */
.lock-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.lock-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px 32px;
  width: 340px; max-width: calc(100vw - 32px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.lock-card .brand-mark {
  display: flex; align-items: center; justify-content: center;
}
