/* ================= Tokens ================= */
:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --surface-3: #e8e7e2;
  --border: #e3e1db;
  --border-strong: #cfccc4;
  --text: #141413;
  --text-2: #52514e;
  --text-3: #85847e;
  --ink: #141413;
  --ink-text: #ffffff;
  --focus: #2a78d6;

  --good: #12a06a;
  --good-ink: #0b6e48;
  --good-bg: #e3f5ec;
  --warn: #b57800;
  --warn-bg: #fdf1d8;
  --bad: #d23c3b;
  --bad-bg: #fbe6e5;
  --info-bg: #e5eefb;
  --info-ink: #1c5cab;
  --violet-bg: #ecebfa;
  --violet-ink: #4a3aa7;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #ebe9e4;

  --seq-0: #f0efeb;
  --seq-1: #cde2fb;
  --seq-2: #9ec5f4;
  --seq-3: #6da7ec;
  --seq-4: #3987e5;
  --seq-5: #256abf;
  --seq-6: #184f95;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 1px 1px rgba(20, 20, 19, .03);
  --shadow-lg: 0 24px 64px rgba(20, 20, 19, .18), 0 2px 8px rgba(20, 20, 19, .08);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #222220;
    --surface-3: #2c2c29;
    --border: #2c2c29;
    --border-strong: #3d3d39;
    --text: #f4f3ee;
    --text-2: #c3c2b7;
    --text-3: #8d8c84;
    --ink: #f4f3ee;
    --ink-text: #141413;
    --focus: #5598e7;
    --good: #34c88b;
    --good-ink: #5ee0a8;
    --good-bg: #123526;
    --warn: #e0a42a;
    --warn-bg: #3a2c0c;
    --bad: #e66767;
    --bad-bg: #3d1a1a;
    --info-bg: #182a44;
    --info-ink: #86b6ef;
    --violet-bg: #26224a;
    --violet-ink: #b3abf2;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #2a2a27;
    --seq-0: #222220;
    --seq-1: #183152;
    --seq-2: #184f95;
    --seq-3: #256abf;
    --seq-4: #3987e5;
    --seq-5: #6da7ec;
    --seq-6: #b7d3f6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface: #1a1a19;
  --surface-2: #222220;
  --surface-3: #2c2c29;
  --border: #2c2c29;
  --border-strong: #3d3d39;
  --text: #f4f3ee;
  --text-2: #c3c2b7;
  --text-3: #8d8c84;
  --ink: #f4f3ee;
  --ink-text: #141413;
  --focus: #5598e7;
  --good: #34c88b;
  --good-ink: #5ee0a8;
  --good-bg: #123526;
  --warn: #e0a42a;
  --warn-bg: #3a2c0c;
  --bad: #e66767;
  --bad-bg: #3d1a1a;
  --info-bg: #182a44;
  --info-ink: #86b6ef;
  --violet-bg: #26224a;
  --violet-ink: #b3abf2;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #2a2a27;
  --seq-0: #222220;
  --seq-1: #183152;
  --seq-2: #184f95;
  --seq-3: #256abf;
  --seq-4: #3987e5;
  --seq-5: #6da7ec;
  --seq-6: #b7d3f6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
}

/* ================= Base ================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
code, kbd, .mono { font-family: var(--mono); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--focus) 25%, transparent); }

/* ================= Botones / campos ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 550; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.btn-primary { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn-good { background: var(--good); border-color: var(--good); color: #fff; }
.btn-good:hover { background: color-mix(in srgb, var(--good) 88%, #000); }
.btn-danger { color: var(--bad); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: none; color: var(--text-2); cursor: pointer;
  padding: 6px 8px; border-radius: 6px; font-size: 13px;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { fill: currentColor; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field small { color: var(--text-3); font-size: 12px; }
.input, .field input, .field select, .field textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent);
}
select.input { padding-right: 28px; }
.form-error { color: var(--bad); font-size: 13px; }

.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  flex: none; width: 38px; height: 22px; margin-top: 1px; border-radius: 999px;
  background: var(--border-strong); position: relative; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .track { background: var(--good); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch strong { display: block; font-weight: 550; }
.switch small { color: var(--text-3); font-size: 12.5px; }

/* ================= Login ================= */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 380px; display: grid; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px 28px; box-shadow: var(--shadow);
}
.auth-mark { color: var(--ink); }
.auth-card h1 { font-size: 22px; }

/* ================= Layout ================= */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--surface); padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--ink); }
.brand-text { display: grid; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 14.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text span { font-size: 12px; color: var(--text-3); }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; fill: currentColor; opacity: .8; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-3); color: var(--text); }
.nav a.active svg { opacity: 1; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 8px; }
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: 11.5px; font-weight: 650; display: inline-grid; place-items: center;
}
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 12px; }
.foot-row { display: flex; justify-content: space-between; }
.meta-status {
  display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 12.5px; color: var(--text-2);
}
.meta-status strong { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot-good { background: var(--good); }
.dot-warn { background: var(--warn); }
.dot-bad { background: var(--bad); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 560px; }
.search input {
  width: 100%; height: 42px; padding: 0 44px 0 40px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  font-size: 15px;
}
.search input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 13px; top: 12px; color: var(--text-3); pointer-events: none; }
.search kbd {
  position: absolute; right: 10px; top: 10px; height: 22px; min-width: 22px; padding: 0 6px;
  display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 5px;
  font-size: 12px; color: var(--text-3); background: var(--surface-2);
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 420px; overflow: auto;
}
.search-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 8px; text-align: left; cursor: pointer;
}
.search-item:hover, .search-item.active { background: var(--surface-2); }
.search-item .code { font-family: var(--mono); font-weight: 650; letter-spacing: .03em; }
.search-item .meta { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 14px; color: var(--text-2); font-size: 13.5px; }

.range { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); }
.seg button {
  border: 0; background: none; padding: 6px 11px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 550; color: var(--text-2); white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.range-custom { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.range-custom input { height: 34px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); }
.no-range .range { display: none; }

.view { padding: 28px; width: 100%; max-width: 1360px; outline: none; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.view-head h1 { font-size: 24px; font-weight: 650; }
.view-head p { color: var(--text-2); margin-top: 4px; max-width: 70ch; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ================= Tarjetas ================= */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; font-weight: 620; }
.card-head p { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 16px 18px 18px; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: grid; gap: 16px; }
.mt { margin-top: 16px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; }
.kpi-foot { font-size: 12px; color: var(--text-3); margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.delta { font-weight: 600; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--bad); }
.kpi.hero { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.kpi.hero .kpi-label, .kpi.hero .kpi-foot { color: color-mix(in srgb, var(--ink-text) 70%, transparent); }
.kpi.hero .delta.up { color: #5ee0a8; }
:root[data-theme="dark"] .kpi.hero .delta.up { color: var(--good-ink); }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.card.fill { display: flex; flex-direction: column; }
.card.fill > .card-body { flex: 1; display: flex; flex-direction: column; }
.card.fill .chart-box { flex: 1; min-height: 220px; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Embudo */
.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 74px; gap: 10px; align-items: center; font-size: 13px; }
.funnel-row .lbl { color: var(--text-2); }
.funnel-row .val { text-align: right; font-weight: 600; }
.funnel-row .val small { display: block; font-weight: 500; color: var(--text-3); font-size: 11.5px; }
.bar-track { height: 22px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; transition: width .4s ease; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 550; color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
tbody tr.selected td { background: color-mix(in srgb, var(--focus) 8%, transparent); }
td .code { font-family: var(--mono); font-weight: 650; letter-spacing: .03em; white-space: nowrap; }
#contacts-table table { min-width: 700px; }
.filters .switch { white-space: nowrap; }
td .sub { display: block; color: var(--text-3); font-size: 12px; }
.cell-bar { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; min-width: 120px; }
.card-body .table-wrap { margin: 0 -18px; padding: 0 6px; }
.cell-bar .bar-track { height: 8px; }
.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.check { width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2);
}
.chip svg { width: 12px; height: 12px; fill: currentColor; }
.chip-nuevo { background: var(--surface-3); color: var(--text-2); }
.chip-contacto { background: var(--info-bg); color: var(--info-ink); }
.chip-lead { background: var(--violet-bg); color: var(--violet-ink); }
.chip-valioso { background: var(--good-bg); color: var(--good-ink); }
.chip-descartado { background: transparent; color: var(--text-3); border: 1px dashed var(--border-strong); }
.chip-sent { background: var(--good-bg); color: var(--good-ink); }
.chip-test { background: var(--warn-bg); color: var(--warn); }
.chip-failed { background: var(--bad-bg); color: var(--bad); }
.chip-pending { background: var(--surface-3); color: var(--text-2); }
.chip-ad { background: var(--info-bg); color: var(--info-ink); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--text-2); font-weight: 550;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--ink); }
.tabs .count { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-weight: 600; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .input { width: auto; min-width: 160px; height: 34px; font-size: 13px; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 10px; border-radius: 999px;
  background: var(--surface-3); font-size: 12.5px; font-weight: 550;
}
.filter-pill button { border: 0; background: none; cursor: pointer; color: var(--text-3); font-size: 16px; line-height: 1; padding: 0 4px; }

.bulkbar {
  position: sticky; bottom: 16px; z-index: 15; margin-top: 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 12px; background: var(--ink); color: var(--ink-text); box-shadow: var(--shadow-lg);
}
.bulkbar .btn { height: 32px; font-size: 13px; }
.bulkbar .input { width: 120px; height: 32px; background: var(--surface); color: var(--text); }
.bulkbar strong { margin-right: auto; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; font-size: 13px; color: var(--text-2); border-top: 1px solid var(--border); }
.pager div { display: flex; gap: 6px; }

.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px;
  font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent;
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: currentColor; }
.notice-warn { background: var(--warn-bg); color: var(--text); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice-warn svg { color: var(--warn); }
.notice-bad { background: var(--bad-bg); color: var(--text); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice-bad svg { color: var(--bad); }
.notice-info { background: var(--info-bg); color: var(--text); }
.notice-info svg { color: var(--info-ink); }
.notice a { font-weight: 600; }

.insights { display: grid; gap: 10px; }
.insight { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); }
.insight b { color: var(--text); }
.insight-icon { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); }
.insight-icon svg { width: 15px; height: 15px; fill: var(--text-2); }

/* Lista de actividad */
.feed { display: grid; max-height: 340px; overflow-y: auto; margin-right: -8px; padding-right: 8px; }
.feed-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.feed-item:last-child { border-bottom: 0; }
.feed-item:hover .code { text-decoration: underline; }
.feed-item .code { font-family: var(--mono); font-weight: 650; }
.feed-item .meta { font-size: 12px; color: var(--text-3); }
.feed-item .amt { font-weight: 650; text-align: right; }

/* Heatmap */
.heat { display: grid; grid-template-columns: 38px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 11px; }
.heat .hl { color: var(--text-3); display: flex; align-items: center; }
.heat .hh { color: var(--text-3); text-align: center; }
.heat .hc { aspect-ratio: 1; border-radius: 3px; background: var(--seq-0); min-height: 12px; }
.heat .hc:hover { outline: 2px solid var(--text); outline-offset: -1px; }
.heat-scale { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-3); margin-top: 10px; }
.heat-scale i { width: 16px; height: 10px; border-radius: 2px; display: inline-block; }

.tip {
  position: fixed; z-index: 100; pointer-events: none; padding: 8px 10px; border-radius: 8px;
  background: var(--ink); color: var(--ink-text); font-size: 12.5px; line-height: 1.4; box-shadow: var(--shadow-lg); max-width: 240px;
}

/* ================= Drawer ================= */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 10, 9, .35); z-index: 40; animation: fade .2s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(520px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 20px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.drawer-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-code { display: flex; align-items: center; gap: 10px; }
.drawer-code h2 { font-family: var(--mono); font-size: 24px; letter-spacing: .04em; font-weight: 700; }
.drawer-body { overflow-y: auto; padding: 18px 20px 28px; display: grid; gap: 18px; align-content: start; }
.drawer-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin-bottom: 10px; }
.action-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: grid; gap: 12px; background: var(--surface-2); }
.action-card.done { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.action-row { display: grid; grid-template-columns: 1fr 86px; gap: 8px; }
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.action-buttons .btn-good { flex: 1; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.match { display: grid; gap: 10px; }
.match-top { display: flex; align-items: center; gap: 12px; }
.match-score { font-size: 22px; font-weight: 700; }
.match-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.match-bar div { height: 100%; border-radius: 999px; }
.signals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; }
.signals span { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.signals span.off { color: var(--text-3); }
.signals svg { width: 14px; height: 14px; flex: none; }
.conv-list { display: grid; gap: 8px; }
.conv {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px;
}
.conv.voided { opacity: .55; }
.conv.voided .conv-title { text-decoration: line-through; }
.conv-title { font-weight: 600; }
.conv-meta { color: var(--text-3); font-size: 12px; grid-column: 1 / -1; }
.conv-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.timeline { display: grid; gap: 0; font-size: 13px; }
.tl { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; padding: 6px 0; position: relative; }
.tl::before { content: ""; position: absolute; left: 6px; top: 20px; bottom: -6px; width: 2px; background: var(--border); }
.tl:last-child::before { display: none; }
.tl i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); margin-top: 3px; }
.tl i.on { border-color: var(--good); background: var(--good); }
.tl time { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }

/* ================= Config ================= */
.settings { display: grid; gap: 16px; max-width: 880px; }
.settings .card-body { display: grid; gap: 14px; }
.settings-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.codebox { position: relative; }
.codebox pre {
  margin: 0; padding: 14px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
  font: 12.5px/1.6 var(--mono); overflow-x: auto; white-space: pre; color: var(--text);
}
.codebox .btn { position: absolute; top: 8px; right: 8px; }
.steps { counter-reset: s; display: grid; gap: 18px; }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.step::before {
  counter-increment: s; content: counter(s); width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ink); color: var(--ink-text); font-weight: 700; font-size: 13px;
}
.step h3 { font-size: 15px; margin-bottom: 4px; }
.step > div { display: grid; gap: 8px; min-width: 0; }
.step p { color: var(--text-2); }
.inline-code { font-family: var(--mono); font-size: 12.5px; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); }

/* ================= Toasts ================= */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px;
  background: var(--ink); color: var(--ink-text); box-shadow: var(--shadow-lg); font-size: 13.5px;
  animation: toast-in .22s cubic-bezier(.32, .72, 0, 1);
}
.toast.bad { background: var(--bad); color: #fff; }
.toast svg { width: 16px; height: 16px; fill: currentColor; flex: none; }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }

@keyframes fade { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ================= Responsive ================= */
@media (max-width: 1180px) {
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1.stack-md { grid-template-columns: minmax(0, 1fr); }
  .range .seg button[data-range="1"] { display: none; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; width: 264px;
    transform: translateX(-100%); transition: transform .24s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-grid; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .range { margin-left: 0; width: 100%; overflow-x: auto; }
  .view { padding: 20px 16px; }
  .g-2, .g-3, .g-2-1 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .search kbd { display: none; }
  .search input { font-size: 16px; padding-right: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 22px; }
  .kv { grid-template-columns: 110px 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .signals { grid-template-columns: 1fr; }
  .view-head h1 { font-size: 21px; }
  .funnel-row { grid-template-columns: 86px 1fr 64px; }
  .range-custom input { width: 130px; }
}

/* ================= Simplificado: inicio / pasos / plegables ================= */
.no-search .search { visibility: hidden; }
.home { max-width: 680px; margin: 28px auto 0; display: grid; gap: 14px; }
.home h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.home > p { color: var(--text-2); font-size: 15px; }
.home-search { position: relative; }
.home-search svg { position: absolute; left: 18px; top: 20px; color: var(--text-3); pointer-events: none; }
.home-search input {
  width: 100%; height: 64px; padding: 0 18px 0 54px;
  border: 2px solid var(--border-strong); border-radius: 16px; background: var(--surface);
  font: 600 22px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  box-shadow: var(--shadow);
}
.home-search input::placeholder { font-family: var(--sans); font-weight: 450; letter-spacing: 0; text-transform: none; color: var(--text-3); font-size: 18px; }
.home-search input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent); }
.results { display: grid; gap: 8px; }
.result {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; text-align: left;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .15s, transform .08s;
}
.result:hover, .result.active { border-color: var(--border-strong); background: var(--surface-2); }
.result:active { transform: translateY(1px); }
.result .code { font: 700 18px/1.2 var(--mono); letter-spacing: .04em; }
.result .meta { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.result .go { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 13px; font-weight: 550; white-space: nowrap; }
.result-empty { padding: 18px; border-radius: 14px; background: var(--surface-2); color: var(--text-2); }

.home-extra { max-width: 680px; margin: 28px auto 0; display: grid; gap: 16px; }
.today { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.today .kpi-value { font-size: 24px; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; padding-bottom: 0; }
.checklist .num-dot {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--border-strong); font-weight: 700; font-size: 13px; color: var(--text-2);
}
.checklist li.done .num-dot { background: var(--good); border-color: var(--good); color: #fff; }
.checklist li.done .step-title { color: var(--text-3); text-decoration: line-through; }
.checklist .step-title { font-weight: 600; }
.checklist .step-sub { font-size: 13px; color: var(--text-3); }
.checklist .btn { margin-left: auto; }

details.more { border-top: 1px solid var(--border); }
details.more > summary {
  list-style: none; cursor: pointer; padding: 14px 0; display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; color: var(--text-2); font-size: 14px;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "+"; font-size: 18px; font-weight: 400; color: var(--text-3); }
details.more[open] > summary::after { content: "–"; }
details.more > summary:hover { color: var(--text); }
details.more > .more-body { padding-bottom: 14px; display: grid; gap: 16px; }
.card-body details.more:first-child { border-top: 0; }

.big-action { display: grid; gap: 12px; padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.big-action.done { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.big-action h3 { font-size: 17px; }
.money-input { position: relative; }
.money-input span { position: absolute; right: 12px; top: 10px; color: var(--text-3); font-size: 13px; font-weight: 600; }
.money-input input { padding-right: 52px; font-size: 16px; }
.btn-xl { height: 50px; font-size: 16px; border-radius: 12px; }
.link-row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.link-btn { border: 0; background: none; padding: 4px; color: var(--text-2); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { color: var(--text); }
.summary-line { color: var(--text-2); font-size: 13.5px; }

.setup-step { display: grid; gap: 14px; }
.setup-step h2 { display: flex; align-items: center; gap: 10px; }
.status-ok { color: var(--good-ink); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.status-missing { color: var(--warn); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.help-list { margin: 0; padding-left: 20px; color: var(--text-2); display: grid; gap: 4px; font-size: 13.5px; }

@media (max-width: 560px) {
  .home { margin-top: 8px; }
  .home h1 { font-size: 24px; }
  .home-search input { height: 56px; font-size: 18px; }
  .today { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .today .kpi { padding: 12px; }
  .today .kpi-value { font-size: 18px; }
  .result .go span { display: none; }
  .checklist li { flex-wrap: wrap; }
}
@media (min-width: 981px) { .no-search.no-range .topbar { display: none; } }
.settings, .settings > *, .setup-step > *, .more-body > *, .codebox { min-width: 0; }
.codebox pre { max-width: 100%; }
.codebox pre { padding-right: 96px; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
