:root {
  --navy: #1a2744;
  --navy-2: #243560;
  --blue: #2d5be3;
  --blue-2: #5b7fea;
  --gold: #b08d57;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #667085;
  --line: #e3e6eb;
  --ok: #1f7a4d;
  --warn: #a86b00;
  --bad: #b42318;
  --ok-bg: #e8f5ee;
  --warn-bg: #fff4e0;
  --bad-bg: #fdecea;
  --info-bg: #edf2fd;
  --radius: 10px;
  --serif: "Liberation Serif", Georgia, "Times New Roman", serif;
  --sans: Calibri, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); font-size: 15px; color: var(--ink); background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 400; margin: 0; color: var(--navy); }
h1 { font-size: 26px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
a { color: var(--blue); }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); margin-top: 18px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* Botones y formularios */
.btn { font: inherit; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; cursor: pointer; background: #fff; color: var(--ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-secondary { background: #fff; border-color: var(--line); }
.btn-secondary:hover { border-color: var(--blue); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f1c0bb; }
.btn-link { background: none; border: 0; color: var(--blue); padding: 6px 0; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.icon-btn { background: none; border: 0; font-size: 18px; cursor: pointer; position: relative; padding: 6px 8px; color: var(--ink); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 1px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > p, .modal-card p { margin: 0; }
.modal-card h4 { margin-top: 6px; font-family: var(--serif); font-weight: 400; color: var(--navy); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.form-error { color: var(--bad); background: var(--bad-bg); padding: 8px 10px; border-radius: 8px; margin: 0; }
.form-msg { margin: 0; padding: 8px 10px; border-radius: 8px; }
.form-msg.is-ok { color: var(--ok); background: var(--ok-bg); }
.form-msg.is-error { color: var(--bad); background: var(--bad-bg); }
.callout { background: var(--info-bg); border-radius: var(--radius); padding: 14px 16px; }
.callout.warn { background: var(--warn-bg); }
.callout.bad { background: var(--bad-bg); }
.done-mark { color: var(--ok); margin: 6px 0 0; }
.done-mark::before { content: "✓ "; }

/* Auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 85% -10%, rgba(45,91,227,.45), transparent 60%), linear-gradient(160deg, #101a30 0%, var(--navy) 60%, #1f2f57 100%); }
.auth-card { border-top: 4px solid var(--blue); }
.auth-card { width: 100%; max-width: 440px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-card h1 { margin-top: 8px; }
.brand-lockup { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.brand-logo { display: block; flex: none; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 22px; line-height: 1; letter-spacing: -.2px; }
.brand-name .finan { color: var(--navy); }
.brand-name .tech { color: var(--blue); }
.brand-sub { font-size: 10px; color: var(--blue); letter-spacing: 2.2px; text-transform: uppercase; font-weight: 700; margin-top: 4px; }
.setup-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 18px; }
.setup-steps li { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.qr { background: #fff; padding: 8px; width: fit-content; border: 1px solid var(--line); border-radius: 8px; }
.qr img, .qr svg { display: block; }

/* Layout app */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--navy) 240px, var(--bg) 240px); }
.sidebar { background: var(--navy); color: #cfd8e6; padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand-name .finan { color: #fff; }
.sidebar .brand-name .tech { color: #7d9cff; }
.sidebar .brand-sub { color: #9fb0d8; }
.sidebar .brand-name { font-size: 20px; }
.sidebar .brand-lockup { padding: 0 8px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
#nav { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
#nav a { color: #cfd8e6; text-decoration: none; padding: 9px 12px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
#nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
#nav a.is-active { background: rgba(45,91,227,.9); color: #fff; box-shadow: inset 3px 0 0 #9db5ff; }
.sidebar-foot { margin-top: auto; font-size: 11px; color: #8195b3; padding: 12px 8px 0; text-transform: uppercase; letter-spacing: .6px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h2 { flex: 1; font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { display: flex; flex-direction: column; line-height: 1.1; font-size: 14px; text-align: right; }
.who .muted { font-size: 12px; }
.menu-btn { display: none; }
.content { padding: 24px; max-width: 1400px; width: 100%; }
.badge { background: var(--bad); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 6px; font-family: var(--sans); }
.icon-btn .badge { position: absolute; top: 0; right: -2px; }

/* Tarjetas y grillas */
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-21 { grid-template-columns: 2fr 1fr; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.kpi .value { font-family: var(--serif); font-size: 26px; color: var(--navy); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.section-gap { margin-top: 16px; }
.chart-box { position: relative; height: 320px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8f9fb; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

/* Pills */
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eef1f5; color: var(--ink); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--blue); }
.flag { background: var(--warn-bg); color: #6b4500; padding: 6px 10px; border-radius: 6px; font-size: 13px; margin: 4px 0; }

/* Chat */
.chat { display: grid; grid-template-columns: 240px 1fr; height: calc(100vh - 150px); min-height: 460px; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.chat-side { background: #f7f9fc; border-right: 1px solid var(--line); padding: 14px 10px; overflow-y: auto; }
.chat-side-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 6px 8px; font-weight: 700; }
.chat-channels { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.chat-channels button { width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; display: flex; justify-content: space-between; align-items: center; color: var(--ink); }
.chat-channels button:hover { background: #eef2f8; }
.chat-channels button.is-active { background: var(--blue); color: #fff; }
.chat-channels button.is-active .ch-ico { color: #fff; }
.ch-ico { display: inline-block; width: 18px; color: var(--blue); font-weight: 700; }
.chat-people .person { display: flex; gap: 10px; align-items: center; padding: 6px 8px; font-size: 13px; }
.av-wrap { position: relative; display: inline-block; }
.dot { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: #c3c9d4; border: 2px solid #f7f9fc; }
.dot.on { background: #22a06b; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px; flex: none; letter-spacing: .3px; }
.chat-main { display: flex; flex-direction: column; min-width: 0; background: #fff; }
.chat-head { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.chat-head-in { display: flex; gap: 12px; align-items: center; }
.ch-badge { width: 34px; height: 34px; border-radius: 10px; background: var(--info-bg); color: var(--blue); display: grid; place-items: center; font-weight: 700; }
.ch-title { font-family: var(--serif); font-weight: 700; font-size: 17px; color: var(--navy); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 8px 18px 16px; display: flex; flex-direction: column; }
.day-sep { text-align: center; margin: 14px 0 6px; position: relative; }
.day-sep::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.day-sep span { position: relative; background: #fff; padding: 2px 12px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 12px; text-transform: capitalize; }
.msg { display: grid; grid-template-columns: 42px 1fr auto; gap: 8px; padding: 6px 8px; border-radius: 10px; position: relative; margin-top: 6px; }
.msg.grouped { margin-top: 0; padding-top: 2px; }
.msg:hover { background: #f7f9fc; }
.msg-av { display: flex; justify-content: center; }
.msg-time-side { font-size: 10px; color: transparent; padding-top: 4px; }
.msg:hover .msg-time-side { color: var(--muted); }
.msg .meta { display: flex; gap: 8px; align-items: baseline; font-size: 13px; margin-bottom: 2px; }
.msg .meta strong { color: var(--navy); }
.msg .meta .muted { font-size: 11px; }
.msg-text { white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; }
.msg.mine .msg-col { }
.msg.mine .meta strong { color: var(--blue); }
.mention { background: #e7edfd; color: var(--blue); padding: 0 3px; border-radius: 4px; font-weight: 600; }
.mention.me { background: #fff1c2; color: #7a5300; }
.quote { border-left: 3px solid var(--blue); background: #f3f6fd; padding: 4px 8px; border-radius: 4px; font-size: 13px; color: var(--muted); margin: 2px 0 4px; }
.doc-chip { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; cursor: pointer; margin-top: 4px; font: inherit; max-width: 520px; }
.doc-chip:hover { border-color: var(--blue); }
.doc-ico { width: 34px; height: 38px; border-radius: 6px; background: var(--navy); color: #fff; font-size: 9px; font-weight: 700; display: grid; place-items: center; flex: none; }
.reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.react { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 1px 8px; font-size: 12px; cursor: pointer; }
.react.mine { border-color: var(--blue); background: #edf2fd; }
.msg-tools { display: none; position: absolute; right: 10px; top: -12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 12px rgba(16,24,40,.08); padding: 2px; }
.msg:hover .msg-tools { display: flex; }
.msg-tools button { background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 14px; }
.msg-tools button:hover { background: #f1f4f9; }
.chat-empty { margin: auto; text-align: center; color: var(--ink); display: flex; flex-direction: column; gap: 6px; padding: 40px 0; }
.chat-empty .big { font-size: 36px; }
.chat-compose { border-top: 1px solid var(--line); padding: 10px 14px 12px; position: relative; }
.chat-replybar { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; background: #f3f6fd; border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; color: var(--muted); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; }
.chat-form:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(45,91,227,.12); }
.chat-form textarea { border: 0; min-height: 38px; max-height: 160px; resize: none; padding: 8px; outline: none; }
.chat-form textarea:focus { outline: none; }
.chat-tool { font-size: 18px; padding: 8px; }
.chat-send { border-radius: 10px; }
.mention-box { position: absolute; bottom: 64px; left: 60px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.12); padding: 4px; display: flex; flex-direction: column; z-index: 3; }
.mention-box button { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 6px 10px; text-align: left; cursor: pointer; border-radius: 6px; font: inherit; }
.mention-box button:hover { background: #f1f4f9; }

/* Calendario */
.cal-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-toolbar h3 { min-width: 180px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-grid .dow { font-size: 12px; color: var(--muted); padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-transform: uppercase; background: #fafbfc; }
.cal-day { min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; background: #fff; }
.cal-day.other { background: #fafbfc; color: #b0b6c0; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--blue-2); }
.cal-day .dnum { font-size: 12px; margin-bottom: 3px; }
.cal-ev { display: block; width: 100%; text-align: left; font: inherit; font-size: 12px; border: 0; border-left: 3px solid var(--blue); background: var(--info-bg); padding: 3px 5px; margin-bottom: 3px; border-radius: 4px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev.cat-reportes { border-left-color: #7a4cc2; background: #f2ecfb; }
.cal-ev.cat-pagos { border-left-color: var(--ok); background: var(--ok-bg); }
.cal-ev.cat-tax { border-left-color: var(--warn); background: var(--warn-bg); }
.cal-ev.cat-contratos { border-left-color: var(--gold); background: #f8f2e8; }
.cal-ev.cat-seguridad { border-left-color: #555; background: #eee; }
.cal-ev.st-hecho { opacity: .55; text-decoration: line-through; }
.cal-ev.overdue { border-left-color: var(--bad); background: var(--bad-bg); }

/* Notificaciones */
.notif-panel { position: fixed; right: 16px; top: 60px; width: 380px; max-width: calc(100vw - 32px); max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.15); z-index: 20; }
.notif-item { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-item.unread { background: var(--info-bg); }
.notif-item .t { font-weight: 600; }
.notif-item .b { font-size: 13px; color: var(--muted); white-space: pre-wrap; margin-top: 4px; }
.notif-item .d { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Modal y toast */
.modal { position: fixed; inset: 0; background: rgba(10,26,48,.45); display: grid; place-items: center; padding: 16px; z-index: 30; }
.modal-card { background: #fff; border-radius: 12px; width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto; padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 40; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); }

/* TradingView */
.tv-box { height: 560px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.tv-tape { min-height: 46px; margin-bottom: 16px; }
.wl-item { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.wl-item:hover, .wl-item.is-active { background: var(--info-bg); }

/* Checklist */
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }

@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3, .g-21 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; z-index: 25; transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility .2s; }
  .sidebar.open { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .menu-btn { display: inline-block; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .who { display: none; }
  .g-2, .g-4 { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat-side { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .chat-channels { flex-direction: row; overflow-x: auto; margin: 0; }
  .chat-channels button { width: auto; white-space: nowrap; }
  .chat-people, .chat-side-title { display: none; }
  .chat-msgs { height: 58vh; }
  .cal-day { min-height: 70px; }
  .cal-ev { font-size: 10px; }
  .tv-box { height: 420px; }
}
.flow-card{border:1px solid var(--line,#e4e7ef);border-radius:10px;padding:10px 12px;margin:8px 0;background:#fafbfe}
/* CRM */
.alert-list{list-style:none;margin:0;padding:0;display:grid;gap:6px}
.alert-list li{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;background:#f6f8fc;font-size:14px}
.alert-list li a{color:var(--ink,#1a2744);text-decoration:none}
.alert-list li a:hover{text-decoration:underline}
.alert-list .adot{display:inline-block;width:8px;height:8px;min-width:8px;border-radius:50%;background:#2d5be3}
.alert-list .alert-bad{background:#fdf0f0}.alert-list .alert-bad .adot{background:#d14343}
.alert-list .alert-warn{background:#fdf7ea}.alert-list .alert-warn .adot{background:#d59a1a}
.timeline{list-style:none;margin:0;padding:0;position:relative}
.timeline li{display:flex;gap:12px;padding:10px 0;border-bottom:1px solid var(--line,#e4e7ef)}
.timeline li:last-child{border-bottom:0}
.tl-icon{flex:0 0 30px;height:30px;border-radius:50%;background:#eef2fd;color:#2d5be3;display:grid;place-items:center;font-size:14px}
.tl-body{flex:1;min-width:0}.tl-body p{margin:4px 0 0;white-space:pre-wrap;font-size:14px}
.tl-head{font-size:13px;display:flex;flex-wrap:wrap;gap:4px;align-items:center}
.tl-head .btn{margin-left:auto}
.tl-next{color:#2d5be3;font-size:13px!important}
.kyc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:10px}
.kyc-item{border:1px solid var(--line,#e4e7ef);border-radius:10px;padding:10px;display:flex;flex-direction:column;gap:6px;font-size:13px}
.kyc-item select,.kyc-item input{font-size:13px}
.progress{position:relative;height:18px;min-width:90px;background:#eef2fd;border-radius:9px;overflow:hidden}
.progress span{position:absolute;inset:0 auto 0 0;background:linear-gradient(90deg,#2d5be3,#5b82ff)}
.progress em{position:relative;font-style:normal;font-size:11px;font-weight:600;padding-left:8px;line-height:18px;color:#1a2744}
