:root {
  --primary: #602584;
  --primary-dark: #4a1c66;
  --primary-soft: #f1e9f7;
  --green: #17734c;
  --red: #b83225;
  --amber: #9a6a00;
  --bg: #f7f5f9;
  --card: #fff;
  --text: #241b2b;
  --muted: #5c5367;
  --label: #3f3649;
  --line: #e0d8e6;
  font-family: Inter, Nunito, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }

/* ---- encabezado */
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: var(--primary); color: #fff; flex-wrap: wrap; gap: 10px; }
.brand { font-weight: 800; font-size: 22px; }
.brand span { font-weight: 400; opacity: 0.9; }
.top-right { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.user { font-size: 14px; opacity: 0.9; }
label.inline { font-size: 15px; display: flex; gap: 8px; align-items: center; }
.top input[type='month'] { padding: 6px 8px; min-height: 38px; }

/* ---- pestañas */
.tabs { display: flex; gap: 2px; padding: 8px 20px 0; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 12px 16px; font: inherit; font-size: 16px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--primary); }
.tabs button[aria-current='page'] { color: var(--primary); border-color: var(--primary); font-weight: 700; }
:is(.tabs button, button, a, input, select):focus-visible { outline: 3px solid #b88bd6; outline-offset: 2px; }

main { max-width: 1160px; margin: 0 auto; padding: 24px 20px 80px; }
h2 { margin: 0 0 14px; font-size: 22px; line-height: 1.3; }
h3 { margin: 0 0 10px; font-size: 18px; line-height: 1.3; }
p { margin: 0 0 10px; }

/* ---- tarjetas */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.stat .label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-size: 28px; font-weight: 800; margin-top: 4px; line-height: 1.2; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); }
.muted { color: var(--muted); font-size: 14px; }

/* ---- tablas */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; background: #fff; z-index: 1; }
tbody tr:hover, table tr:hover td { background: #faf7fc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .muted { font-size: 13px; }

/* ---- botones (button y enlaces con clase .btn) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--primary); color: #fff; border: 0; border-radius: 10px; padding: 10px 18px; min-height: 42px; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: var(--primary-soft); color: var(--primary-dark); }
.btn.ghost:hover { background: #e4d4f0; }
.btn.danger { background: #fbeae8; color: var(--red); }
.btn.danger:hover { background: #f6d6d2; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 14px; }

/* ---- formularios */
.f { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: end; }
.f label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--label); }
.f > div { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input, select { font: inherit; font-size: 16px; padding: 9px 12px; min-height: 42px; border: 1px solid #cfc5d8; border-radius: 10px; background: #fff; color: var(--text); min-width: 0; width: 100%; }
select { cursor: pointer; }
input[type='checkbox'] { width: 22px; height: 22px; min-height: 0; accent-color: var(--primary); }
input::placeholder { color: #8a8095; }
.chatbox input, .top input { width: auto; }

/* ---- barras y gráficas */
.bar { height: 12px; background: var(--primary-soft); border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); }
.bar.warning > i { background: var(--amber); } .bar.over > i { background: var(--red); }
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 10px 0; flex-wrap: wrap; }
.trend { display: flex; gap: 12px; align-items: flex-end; height: 160px; padding-top: 8px; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend .pair { display: flex; gap: 4px; align-items: flex-end; height: 125px; }
.trend .pair i { width: 16px; border-radius: 3px 3px 0 0; display: block; }
.trend .inc { background: var(--green); } .trend .exp { background: var(--primary); }
.trend small { font-size: 13px; color: var(--muted); }

/* ---- chat */
.chat { display: flex; flex-direction: column; height: 66vh; min-height: 420px; }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px 2px; }
.msg { max-width: 82%; padding: 11px 15px; border-radius: 14px; white-space: pre-wrap; line-height: 1.5; font-size: 16px; }
.msg.me { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--primary-soft); border-bottom-left-radius: 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.chip { border: 1px solid var(--primary); color: var(--primary-dark); background: #fff; border-radius: 999px; padding: 6px 14px; min-height: 34px; cursor: pointer; font: inherit; font-size: 14px; }
.chip:hover { background: var(--primary-soft); }
.chatbox { display: flex; gap: 10px; } .chatbox input { flex: 1; }

.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--primary-soft); color: var(--primary-dark); }
pre.json { background: #1e1627; color: #e9dff1; padding: 14px; border-radius: 10px; overflow: auto; font-size: 13px; line-height: 1.5; }
details summary { cursor: pointer; font-size: 15px; color: var(--primary-dark); padding: 4px 0; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #241b2b; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 15px; opacity: 0; transition: opacity 0.2s; pointer-events: none; max-width: 90vw; z-index: 10; }
#toast.show { opacity: 1; } #toast.error { background: var(--red); }
.hidden { display: none !important; }

/* ---- alertas */
.alerts { display: grid; gap: 10px; margin-bottom: 16px; }
.alert { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; padding: 12px 16px; border-radius: 12px; border: 1px solid; font-size: 15px; }
.alert strong { white-space: nowrap; }
.alert.over { background: #fbeae8; border-color: var(--red); color: #6e1a11; }
.alert.warning, .alert.pace { background: #fff6dc; border-color: #c98a00; color: #5c4000; }

/* ---- selector de tipo de cambio (encabezado) */
.fxsel { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.segs { display: inline-flex; border: 1px solid rgba(255, 255, 255, 0.7); border-radius: 10px; overflow: hidden; }
.seg { border: 0; background: transparent; color: #fff; padding: 8px 16px; min-height: 38px; font: inherit; font-size: 15px; cursor: pointer; }
.seg.on { background: #fff; color: var(--primary-dark); font-weight: 700; }
.seg:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

@media (max-width: 640px) {
  main { padding: 16px 12px 80px; }
  .top { padding: 12px 14px; }
  .grid.two { grid-template-columns: 1fr; }
  .msg { max-width: 92%; }
  th, td { padding: 10px 6px; }
}
.f label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; min-height: 42px; }
.selbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin: 8px 0 4px; background: var(--primary-soft); border: 1px solid #d9c4ea; border-radius: 10px; position: sticky; top: 0; z-index: 2; }
tr.selected td { background: #f6effb; }
th input[type='checkbox'], td input[type='checkbox'] { cursor: pointer; vertical-align: middle; }
.btn.danger.solid { background: var(--red); color: #fff; }
.btn.danger.solid:hover { background: #962a1f; }
.selbar { border-width: 2px; }
.selbar strong { font-size: 16px; margin-right: 4px; }

/* ---- entrar / crear cuenta / recuperar */
.authbox { max-width: 460px; margin: 32px auto; }
.authform { display: grid; gap: 14px; }
.authform label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--label); }
.authform .btn { width: 100%; min-height: 46px; font-size: 16px; }
.authlinks { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.linkbtn { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 15px; color: var(--primary-dark); text-decoration: underline; cursor: pointer; }
.linkbtn:hover { color: var(--primary); }
.recovery { font: 700 24px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 3px; text-align: center; padding: 18px 10px; margin: 12px 0; background: var(--primary-soft); border: 2px dashed var(--primary); border-radius: 12px; user-select: all; word-break: break-all; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.hidden { display: none !important; }
