:root {
  --navy: #0b0b0c;          /* negro del logo */
  --navy-2: #1d1d20;
  --brand: #8a6a12;         /* dorado oscuro: textos y enlaces sobre blanco */
  --brand-ink: #111111;     /* texto sobre dorado */
  --gold: #d4af37;          /* dorado del logo */
  --gold-light: #f2d675;
  --gold-dark: #a8841f;
  --gold-grad: linear-gradient(180deg, #ecc95b 0%, #d4af37 55%, #b8921f 100%);
  --focus: rgba(212, 175, 55, .3);
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .25);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important; background: linear-gradient(180deg, #121214 0%, #050505 100%); color: #d6d3d1; border-right: 1px solid rgba(212,175,55,.18); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; }
.brand img { width: 44px; height: 44px; border-radius: 50%; box-shadow: 0 0 14px rgba(212,175,55,.35); }
.brand b { display: block; font-size: 15px; letter-spacing: .1em; color: var(--gold-light); }
.brand span { font-size: 11px; color: var(--gold); letter-spacing: .04em; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: #d6d3d1; font-weight: 500; }
.nav a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--gold-grad); color: #111; font-weight: 650; }
.nav .badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.install-btn { display: flex; align-items: center; gap: 10px; margin: 0 4px 12px; padding: 10px 12px; border-radius: 9px; border: 1px solid rgba(212,175,55,.45); background: transparent; color: var(--gold-light); font-weight: 600; cursor: pointer; }
.install-btn:hover { background: rgba(212,175,55,.12); }
.side-user { border-top: 1px solid rgba(212,175,55,.2); padding: 14px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold-grad); color: #111; display: grid; place-items: center; font-weight: 700; flex: none; }
.side-user .who { flex: 1; min-width: 0; }
.side-user .who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { font-size: 11px; text-transform: capitalize; }
.icon-btn { background: transparent; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: inherit; display: inline-grid; place-items: center; }
.icon-btn:hover { background: rgba(127,127,127,.15); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(245,245,243,.92); backdrop-filter: blur(8px); display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); }
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 560px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding: 10px 12px 10px 40px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); outline: none; }
.search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--focus); }
.topbar .spacer { flex: 1; }
.view { padding: 24px 28px calc(48px + env(safe-area-inset-bottom)); max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--surface); padding: 9px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; white-space: nowrap; color: var(--ink-2); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--gold-grad); border-color: var(--gold-dark); color: var(--brand-ink); }
.btn.primary:hover { background: var(--gold-dark); }
.btn.gold { background: #111; border-color: var(--gold); color: var(--gold-light); }
.btn.gold:hover { background: #000; color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ok { color: var(--ok); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(127,127,127,.1); }
.btn.wa { color: #128c4b; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); outline: none; min-height: 38px; }
textarea.input { resize: vertical; min-height: 76px; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--focus); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.span2 { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--gold-dark); }
.hint { font-size: 12px; color: var(--muted); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-b { padding: 16px 18px; }
.card-b.flush { padding: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: block; color: inherit; position: relative; overflow: hidden; }
a.kpi:hover { border-color: var(--gold); text-decoration: none; }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 26px; font-weight: 750; margin-top: 4px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.kpi.alert { border-color: #fecaca; background: var(--danger-bg); }
.kpi.alert .val { color: var(--danger); }
.kpi.warn { border-color: #fde68a; background: var(--warn-bg); }
.kpi.warn .val { color: var(--warn); }
.kpi.info .val { color: var(--info); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 16px; }
.section-title { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }

/* ---------- Pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.pill.status { color: #fff; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.due { font-weight: 650; font-size: 13px; white-space: nowrap; }
.due.overdue { color: var(--danger); }
.due.today { color: var(--warn); }
.due.upcoming { color: var(--info); }
.due.none { color: var(--muted); font-weight: 500; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--gold); }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip .n { font-size: 11px; opacity: .8; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover { background: #f7f9fc; }
.t .name { font-weight: 650; color: var(--ink); }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }

.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--line-2); margin-bottom: 8px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.li { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .title { font-weight: 650; }
.li .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.li .note { font-size: 13px; color: var(--ink-2); margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.li .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.li.overdue { box-shadow: inset 3px 0 0 var(--danger); }
.li.today { box-shadow: inset 3px 0 0 var(--warn); }
.li.upcoming { box-shadow: inset 3px 0 0 var(--info); }

/* ---------- Bars (gráficos sencillos) ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.vbars { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.vbar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; position: relative; }
.vbar .fill { width: 100%; max-width: 38px; background: var(--gold-grad); border-radius: 4px 4px 0 0; min-height: 2px; }
.vbar .v { font-size: 11px; font-weight: 700; color: var(--ink-2); margin-bottom: 3px; }
.vlabels { display: flex; gap: 4px; margin-top: 6px; }
.vlabels span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); overflow: hidden; white-space: nowrap; min-width: 0; }

/* ---------- Ficha del cliente ---------- */
.client-head { padding: 18px 20px; display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.client-head .avatar { width: 52px; height: 52px; font-size: 19px; background: var(--navy); color: var(--gold); }
.client-head .info { flex: 1; min-width: 220px; }
.client-head h1 { font-size: 21px; }
.client-head .meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); margin-top: 4px; font-size: 13px; }
.client-head .quick { display: flex; gap: 8px; flex-wrap: wrap; }
.pipeline { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 20px 18px; }
.step { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 700; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 6px; }
.step:hover { border-color: var(--ink-2); }
.step.done { background: var(--surface-2); color: var(--muted); }
.step.current { color: #fff; border-color: transparent; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.next-fu { margin: 0 20px 18px; padding: 12px 14px; border-radius: 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.next-fu.none { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.next-fu.overdue { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.next-fu.today { background: var(--warn-bg); color: #92400e; border: 1px solid #fde68a; }
.next-fu.upcoming { background: var(--info-bg); color: #1e3a8a; border: 1px solid #bfdbfe; }
.next-fu .grow { flex: 1; min-width: 200px; }
.client-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; margin-top: 16px; align-items: start; }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 4px 0 10px; }
.save-bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 18px; display: flex; gap: 8px; justify-content: flex-end; border-radius: 0 0 var(--radius) var(--radius); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tab { background: none; border: 0; padding: 13px 12px 11px; cursor: pointer; font-weight: 650; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab.on { color: var(--brand); border-bottom-color: var(--gold); }
.tab .n { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: 11px; padding: 0 7px; color: var(--ink-2); }
.tab .n.red { background: var(--danger); border-color: var(--danger); color: #fff; }

.timeline { list-style: none; margin: 0; padding: 6px 18px 12px; }
.timeline li { position: relative; padding: 10px 0 10px 26px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--tl, var(--line-2)); }
.timeline .d { font-size: 12px; color: var(--muted); }
.timeline .txt { white-space: pre-wrap; word-break: break-word; }

.doc-folder { border-bottom: 1px solid var(--line); }
.doc-folder:last-child { border-bottom: 0; }
.doc-folder > .fh { display: flex; align-items: center; gap: 8px; padding: 10px 18px; font-weight: 700; background: var(--surface-2); font-size: 13px; }
.doc { display: flex; align-items: center; gap: 10px; padding: 9px 18px; }
.doc .grow { flex: 1; min-width: 0; }
.doc .fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.dropzone { border: 2px dashed var(--line-2); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--gold); background: #fdf8e7; color: var(--brand); }

/* ---------- Alerts ---------- */
.alert-box { border-radius: 10px; padding: 12px 14px; border: 1px solid; font-size: 13px; }
.alert-box.warn { background: var(--warn-bg); border-color: #fde68a; color: #78350f; }
.alert-box.error { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }
.alert-box .dup { display: flex; align-items: center; gap: 10px; padding: 8px 0 0; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fade .12s ease-out; }
.modal { background: var(--surface); width: 100%; max-width: 560px; border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 720px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-b { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 360px; animation: fade .15s; font-weight: 500; }
.toast.error { background: var(--danger); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art { background: radial-gradient(90% 70% at 20% 15%, #3a2f0f 0%, #0b0b0c 60%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h2 { font-size: 34px; line-height: 1.15; font-weight: 750; max-width: 420px; }
.login-art p { color: #cbd5e1; max-width: 420px; font-size: 15px; }
.login-art .gold { color: var(--gold); }
.login-logo { width: 132px; height: 132px; border-radius: 50%; box-shadow: 0 0 40px rgba(212,175,55,.35); margin-bottom: 26px; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--surface); }
.login-form form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }

.overlay { display: none; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { min-width: 160px; }
.load-more { padding: 14px; text-align: center; border-top: 1px solid var(--line); }
.mobile-only { display: none; }
.cards-list { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .dash-grid, .client-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .overlay.open { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .topbar .search { order: 3; flex-basis: 100%; max-width: none; }
  .view { padding: 16px 16px 40px; }
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px 20px; min-height: auto; }
  .login-art h2 { font-size: 24px; }
  .login-art .hide-sm { display: none; }
}
@media (max-width: 680px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .hide-sm { display: none !important; }
  .mobile-only { display: initial; }
  .table-wrap.responsive table { display: none; }
  .table-wrap.responsive .cards-list { display: flex; flex-direction: column; }
  .mcard { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
  .mcard:last-child { border-bottom: 0; }
  .mcard .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
  .li { flex-wrap: wrap; padding: 12px 16px; }
  .li .actions { width: 100%; justify-content: flex-start; }
  .bar-row { grid-template-columns: 100px 1fr 36px; }
  .toolbar .field { min-width: calc(50% - 5px); flex: 1; }
  .kpi .val { font-size: 22px; }
  .btn-new-label { display: none; }
  .client-head .quick { width: 100%; }
  .modal-back { padding: 0; align-items: stretch; }
  .modal { border-radius: 0; min-height: 100%; }
  #toasts { left: 16px; right: 16px; bottom: 16px; }
}

/* ---------- v1.1: autorización de datos y compra de cartera ---------- */
.consent-box { margin-top: 16px; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line); }
.consent-box.warn { background: var(--warn-bg); border-color: #fde68a; }
.consent-box.ok { background: var(--ok-bg); border-color: #bbf7d0; }
.cartera-row { display: grid; grid-template-columns: 1fr 170px 38px; gap: 8px; margin-bottom: 8px; align-items: center; }
@media (max-width: 680px) { .cartera-row { grid-template-columns: 1fr 120px 38px; } }

/* ---------- v1.2: WhatsApp ---------- */
.wa-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; height: calc(100vh - 210px); min-height: 480px; }
.wa-list-card, .wa-chat { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.wa-list { overflow-y: auto; flex: 1; }
.wa-item { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); padding: 12px 14px; cursor: pointer; align-items: flex-start; }
.wa-item:hover { background: var(--surface-2); }
.wa-item.on { background: #fdf8e7; box-shadow: inset 3px 0 0 var(--gold); }
.wa-item .grow { flex: 1; min-width: 0; }
.wa-name, .wa-prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-item .badge { background: #16a34a; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.wa-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.wa-head .grow { flex: 1; min-width: 180px; }
.wa-back { display: none; }
.wa-thread { flex: 1; overflow-y: auto; padding: 16px; background: #efeae2; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.wa-msg { display: flex; }
.wa-msg.out { justify-content: flex-end; }
.wa-bubble { max-width: min(78%, 520px); background: #fff; border-radius: 10px; padding: 7px 10px 5px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.wa-msg.out .wa-bubble { background: #d9fdd3; }
.wa-msg.out.bot .wa-bubble { background: #fff6d6; }
.wa-who { font-size: 11px; font-weight: 700; color: var(--brand); margin-bottom: 2px; }
.wa-text { white-space: pre-wrap; word-break: break-word; }
.wa-doc { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-weight: 600; }
.wa-meta { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; }
.wa-err { font-size: 11px; color: var(--danger); margin-top: 2px; }
.wa-compose { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.wa-compose textarea { flex: 1; min-height: 42px; max-height: 140px; resize: vertical; }
@media (max-width: 900px) {
  .wa-layout { grid-template-columns: 1fr; height: calc(100vh - 230px); }
  .wa-layout .wa-chat { display: none; }
  .wa-layout.has-chat .wa-chat { display: flex; }
  .wa-layout.has-chat .wa-list-card { display: none; }
  .wa-back { display: inline-grid; }
}

/* ---------- v1.3: precalificación del bot ---------- */
.prequal-box { margin-top: 16px; padding: 14px 16px; border-radius: 10px; background: #fdf8e7; border: 1px solid #f0dc9c; }
.prequal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; }
.prequal-grid > div { display: flex; flex-direction: column; }
