:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-soft: #eff6ff;
  --primary-line: #bfdbfe;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --gmaps: #16a34a;
  --instagram: #db2777;
  --linkedin: #0a66c2;
  --facebook: #1877f2;
  --shadow: 0 1px 2px rgb(15 23 42 / .05), 0 4px 16px rgb(15 23 42 / .05);
  --shadow-lg: 0 20px 50px rgb(15 23 42 / .22);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #111a2e;
    --surface-2: #0f1729;
    --ink: #e5e9f2;
    --ink-2: #c4cbd8;
    --muted: #8a96ab;
    --line: #1f2b45;
    --line-2: #2d3b5a;
    --primary: #4f8cff;
    --primary-soft: #14223f;
    --primary-line: #24407a;
    --ok-soft: #0c2a22;
    --warn-soft: #2d2410;
    --bad-soft: #2f1418;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #0f1729; --ink: #e5e9f2; --ink-2: #c4cbd8; --muted: #8a96ab;
  --line: #1f2b45; --line-2: #2d3b5a; --primary: #4f8cff; --primary-soft: #14223f; --primary-line: #24407a;
  --ok-soft: #0c2a22; --warn-soft: #2d2410; --bad-soft: #2f1418; --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 18px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---------- Controles ---------- */
input[type="text"], input[type="search"], input[type="number"], select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  min-height: 38px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; margin: 0; }

.btn, .btn-primary, .btn-ghost {
  font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--radius-sm); padding: 8px 14px; min-height: 38px;
  cursor: pointer; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active, .btn-primary:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn-lg { min-height: 46px; padding: 10px 22px; font-size: 15px; }
.icon-btn { min-height: 30px; width: 30px; padding: 0; }

.ico { display: inline-flex; width: 16px; height: 16px; flex: none; }
.ico svg { width: 100%; height: 100%; }

.lbl { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand strong { display: block; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { display: block; font-size: 12px; color: var(--muted); margin-top: -1px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='14' cy='14' r='6.5' fill='none' stroke='white' stroke-width='2.6'/%3E%3Cpath d='M19 19l6 6' stroke='white' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 100%;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.settings-btn { width: 38px; min-height: 38px; }
.settings-btn .ico { width: 19px; height: 19px; }
.chip-status {
  font: inherit; cursor: pointer; color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 6px 11px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
}
.chip-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip-status.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.chip-status.bad { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.chip-status.bad .dot { background: var(--bad); }
.meter { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.meter-bar { width: 90px; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter-bar > i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

/* ---------- Estructura ---------- */
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; padding: 20px 22px 40px; max-width: 1560px; margin: 0 auto; }
.sidebar { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 18px; }
.main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

.side-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 10px 6px; }
.list-nav { display: flex; flex-direction: column; gap: 2px; }
.list-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--ink-2); font-weight: 500; border: 1px solid transparent; position: relative;
}
.list-item:hover { background: var(--surface); }
.list-item.active { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 650; box-shadow: var(--shadow); }
.list-item .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.list-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.list-item .menu { display: none; }
.list-item:hover .menu, .list-item.active .menu { display: inline-flex; }
.list-item:hover .count, .list-item.active .count { display: none; }
.list-item.all .menu { display: none !important; }
.list-item.all:hover .count, .list-item.all.active .count { display: inline; }
.side-add { width: 100%; justify-content: flex-start; color: var(--primary); }
.side-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 2px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; }
.stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); }

/* ---------- Búsqueda ---------- */
.search-card { padding: 18px 20px 20px; }
.search-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { max-width: 100%; overflow-x: auto; display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.tab {
  font: inherit; font-weight: 600; font-size: 13.5px; border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(15 23 42 / .12); }
.tab .src-dot { width: 8px; height: 8px; border-radius: 50%; }

.fields { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 14px; }
.f-8 { grid-column: span 8; } .f-6 { grid-column: span 6; } .f-4 { grid-column: span 4; } .f-3 { grid-column: span 3; } .f-2 { grid-column: span 2; } .f-12 { grid-column: span 12; }
.options { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-top: 2px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; user-select: none; }
.check small { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; width: 100%; }
.seg button {
  flex: 1; font: inherit; font-size: 13px; font-weight: 600; padding: 8px 6px; min-height: 38px; border: 0; background: var(--surface);
  color: var(--muted); cursor: pointer; border-right: 1px solid var(--line-2);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.info-note {
  grid-column: span 12; font-size: 12.5px; color: var(--ink-2); background: var(--primary-soft);
  border: 1px solid var(--primary-line); border-radius: var(--radius-sm); padding: 9px 12px;
}
.info-note code { font-size: 12px; word-break: break-all; }

.search-foot { display: flex; align-items: flex-end; gap: 16px; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.target { flex: 0 1 380px; min-width: 240px; }
.target-row { display: flex; gap: 8px; }
.estimate { flex: 1; min-width: 200px; font-size: 13px; color: var(--muted); min-height: 38px; display: flex; flex-direction: column; justify-content: center; }
.estimate b { color: var(--ink); font-size: 15px; }
.estimate .warn { color: var(--bad); font-weight: 600; }

/* ---------- Corridas ---------- */
.runs-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.run {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; min-width: 0; cursor: pointer; transition: border-color .15s;
}
.run:hover { border-color: var(--line-2); }
.run.active-filter { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.run-top { display: flex; align-items: center; gap: 8px; }
.run-label { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .6s; }
.progress.indet > i { width: 35% !important; animation: indet 1.3s infinite ease-in-out; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.run-actions { display: flex; gap: 6px; }
.run-error { color: var(--bad); }

/* ---------- Insignias ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 99px; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge.src-gmaps { color: var(--gmaps); background: color-mix(in srgb, var(--gmaps) 10%, transparent); border-color: color-mix(in srgb, var(--gmaps) 25%, transparent); }
.badge.src-instagram { color: var(--instagram); background: color-mix(in srgb, var(--instagram) 10%, transparent); border-color: color-mix(in srgb, var(--instagram) 25%, transparent); }
.badge.src-linkedin { color: var(--linkedin); background: color-mix(in srgb, var(--linkedin) 10%, transparent); border-color: color-mix(in srgb, var(--linkedin) 25%, transparent); }
.badge.src-facebook { color: var(--facebook); background: color-mix(in srgb, var(--facebook) 10%, transparent); border-color: color-mix(in srgb, var(--facebook) 25%, transparent); }
.badge.st-ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.st-run { color: var(--primary); background: var(--primary-soft); border-color: transparent; }
.badge.st-bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.badge.st-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.no-web { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.lead-st { font: inherit; font-size: 12px; font-weight: 650; border-radius: 99px; padding: 3px 8px; min-height: 0; width: auto; border: 1px solid var(--line); cursor: pointer; }
.lead-st.st-nuevo { color: var(--primary); background: var(--primary-soft); }
.lead-st.st-contactado { color: var(--warn); background: var(--warn-soft); }
.lead-st.st-interesado { color: #7c3aed; background: color-mix(in srgb, #7c3aed 10%, transparent); }
.lead-st.st-cliente { color: var(--ok); background: var(--ok-soft); }
.lead-st.st-descartado { color: var(--muted); background: var(--surface-2); }

/* ---------- Prospectos ---------- */
.leads-card { padding: 18px 0 6px; }
.leads-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 0 20px 14px; flex-wrap: wrap; }
.export-btns { display: flex; gap: 8px; }
.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 170px 160px 160px; gap: 10px; padding: 0 20px; }
.search-box { position: relative; }
.search-box .ico { position: absolute; left: 11px; top: 11px; color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 34px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 20px 14px; }
.chip {
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.chip.run-chip { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.bulkbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 20px 12px; padding: 8px 12px;
  background: var(--primary-soft); border: 1px solid var(--primary-line); border-radius: var(--radius-sm);
}
.bulkbar > span { font-weight: 650; color: var(--primary); margin-right: 6px; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table.leads { width: 100%; border-collapse: collapse; }
.leads th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700;
  padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.leads td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.leads tbody tr { cursor: pointer; }
.leads tbody tr:hover td { background: var(--surface-2); }
.leads tbody tr.selected td { background: var(--primary-soft); }
.col-check { width: 40px; padding-left: 20px !important; }
.leads th:first-child, .leads td:first-child { padding-left: 20px; }
.lead-name { font-weight: 650; color: var(--ink); min-width: 170px; max-width: 320px; }
.lead-sub { min-width: 170px; }
.lead-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.contact { display: flex; flex-direction: column; gap: 3px; font-size: 13px; min-width: 150px; }
.contact-line { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.contact-line .ico { width: 13px; height: 13px; color: var(--muted); }
.copy { opacity: 0; border: 0; background: none; padding: 0 2px; cursor: pointer; color: var(--muted); display: inline-flex; }
.contact-line:hover .copy { opacity: 1; }
.copy:hover { color: var(--primary); }
.web { font-size: 13px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }
.stars { color: #f59e0b; }
.dots { display: inline-flex; gap: 3px; margin-left: 2px; }
.dots i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }

.empty { text-align: center; padding: 48px 20px !important; color: var(--muted); cursor: default; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pager .pages { display: flex; gap: 6px; align-items: center; }

/* ---------- Panel lateral ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.drawer::before { content: ""; position: absolute; inset: 0; background: rgb(15 23 42 / .35); opacity: 0; transition: opacity .2s; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(500px, 100vw); background: var(--surface);
  box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .22s ease; overflow-y: auto; padding: 22px;
}
.drawer.open { pointer-events: auto; }
.drawer.open::before { opacity: 1; }
.drawer.open .drawer-panel { transform: none; }
.d-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.d-head h3 { font-size: 19px; flex: 1; }
.d-grid { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 13.5px; margin: 14px 0; }
.d-grid dt { color: var(--muted); }
.d-grid dd { margin: 0; word-break: break-word; }
.d-bio { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; white-space: pre-wrap; }
.d-section { margin-top: 18px; }
.d-section .lbl { margin-bottom: 7px; }
.d-links { display: flex; flex-wrap: wrap; gap: 8px; }
.list-picks { display: flex; flex-wrap: wrap; gap: 7px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 16px; background: rgb(15 23 42 / .45); }
.modal.open { display: flex; }
.modal-panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; }
.modal-panel.wide { width: min(980px, 100%); }
.modal-panel h3 { font-size: 17px; margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 26px; height: 26px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.colors button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
table.history { width: 100%; border-collapse: collapse; font-size: 13px; }
.history th, .history td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.history th { font-size: 11.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }

/* ---------- Corridas en curso (solo barra de progreso) ---------- */
.progress-area { display: flex; flex-direction: column; gap: 8px; }
.prog {
  background: var(--surface); border: 1px solid var(--primary-line); border-radius: 12px; padding: 10px 14px 12px;
  box-shadow: var(--shadow); cursor: pointer;
}
.prog-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; min-width: 0; }
.prog-label { font-weight: 650; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog-text { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.prog-pct { font-size: 12.5px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.prog .progress { height: 8px; }
.src-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- Navegación entre vistas (barra superior) ---------- */
.view-nav { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.view-nav a {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 16px; border-radius: 8px;
  font-weight: 650; font-size: 13.5px; color: var(--muted); text-decoration: none;
}
.view-nav a:hover { color: var(--ink); text-decoration: none; }
.view-nav a.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(15 23 42 / .12); }
.nav-count { font-size: 11.5px; font-weight: 700; background: var(--primary-soft); color: var(--primary); border-radius: 99px; padding: 1px 7px; }
.nav-count:empty { display: none; }

/* ---------- Vista Historial de corridas ---------- */
.history-view { max-width: 1560px; margin: 0 auto; padding: 20px 22px 40px; display: flex; flex-direction: column; gap: 16px; }
.history-card { padding: 18px 0 6px; }
.history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 0 20px 14px; }
.history-head h1 { font-size: 19px; }
.history-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.history-stats .stat { min-width: 120px; }
.history-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 190px 210px; gap: 10px; padding: 0 20px 14px; }
table.runs-table { width: 100%; border-collapse: collapse; }
.runs-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700;
  padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.runs-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.runs-table th:first-child, .runs-table td:first-child { padding-left: 20px; }
.runs-table th:last-child, .runs-table td:last-child { padding-right: 20px; }
.runs-table tbody tr { cursor: pointer; }
.runs-table tbody tr:hover td { background: var(--surface-2); }
.run-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.run-cell-label { font-weight: 650; color: var(--ink); }
.num-col { text-align: right; }
.actions-col { text-align: right; width: 1%; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.row-actions a.btn { text-decoration: none; }
.nowrap { white-space: nowrap; }
.show-sm { display: none; margin-top: 4px; }
.history-detail { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.back-btn { align-self: flex-start; }

/* ---------- Resumen de la corrida en el visor ---------- */
.leads-title { min-width: 0; flex: 1; }
.run-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }

/* ---------- Autocompletado de lugares ---------- */
.ac { position: relative; }
.ac-list {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: 300px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 4px;
}
.ac-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.ac-item:hover, .ac-item.active { background: var(--primary-soft); }
.ac-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.ac-name b { color: var(--ink); font-weight: 700; }
.ac-type { flex: none; font-size: 11.5px; color: var(--muted); }
.ac-empty { padding: 10px; font-size: 13px; color: var(--muted); }
.ac-foot { padding: 5px 10px 3px; font-size: 10.5px; color: var(--muted); text-align: right; border-top: 1px solid var(--line); margin-top: 4px; }

/* ---------- Configuración ---------- */
.set-section { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.set-head h4 { margin: 0; font-size: 14.5px; }
.set-row { display: flex; gap: 8px; }
.set-row input { flex: 1; min-width: 0; }
.set-current { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-current code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; font-size: 12.5px; }
.set-msg { font-size: 12.5px; min-height: 18px; }
.set-msg.bad { color: var(--bad); }
.set-msg.ok { color: var(--ok); }
.set-warn { font-size: 12.5px; color: var(--ink-2); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: var(--radius-sm); padding: 8px 11px; }
.banner .btn-sm { margin-left: 8px; }

/* ---------- Avisos ---------- */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--ink); color: var(--surface); border-radius: 11px; padding: 11px 14px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: pop .2s ease;
}
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.banner {
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); color: var(--ink-2);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 14px;
}
.banner code { font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .toolbar { grid-template-columns: 1fr 1fr 1fr; }
  .search-box { grid-column: span 3; }
  .hide-md { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 32px; }
  .sidebar { position: static; min-width: 0; }
  .list-nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .history-toolbar { grid-template-columns: 1fr 1fr; } .history-toolbar .search-box { grid-column: span 2; }
  .prog-text { display: none; }
  .list-item { flex: none; }
  .list-item .menu { display: none !important; }
  .side-stats { grid-template-columns: repeat(4, 1fr); }
  .f-8, .f-6, .f-4, .f-3, .f-2 { grid-column: span 12; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; row-gap: 8px; }
  .view-nav { order: 3; width: 100%; }
  .view-nav a { flex: 1; justify-content: center; }
  .history-view { padding: 14px 16px 32px; }
  .history-head, .history-toolbar { padding-left: 16px; padding-right: 16px; }
  .runs-table th:first-child, .runs-table td:first-child { padding-left: 16px; }
  .runs-table th:last-child, .runs-table td:last-child { padding-right: 16px; }
  .show-sm { display: block; }
  .run-cell { flex-wrap: wrap; gap: 4px 8px; }
  .row-actions { gap: 2px; }
  .runs-table th, .runs-table td { padding-left: 6px; padding-right: 6px; }
  .row-actions .btn-sm { padding: 5px 7px; }
  .history-stats .stat { min-width: 0; flex: 1; }
  .meter { display: none; }
  .brand-sub { display: none; }
  .search-card { padding: 16px; }
  .tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; padding: 7px 4px; font-size: 12.5px; gap: 5px; white-space: nowrap; }
  .toolbar { grid-template-columns: 1fr 1fr; padding: 0 16px; }
  .search-box { grid-column: span 2; }
  #fSort { grid-column: span 2; }
  .chips, .leads-head, .pager { padding-left: 16px; padding-right: 16px; }
  .bulkbar { margin: 0 16px 12px; }
  .hide-sm { display: none; }
  .side-stats { grid-template-columns: 1fr 1fr; }
  .search-foot { flex-direction: column; align-items: stretch; }
  .target { flex: none; }
  .btn-lg { width: 100%; }
  .export-btns { width: 100%; }
  .export-btns .btn { flex: 1; }
}
