/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:          #111;
  --surface:     #1a1a1a;
  --surface2:    #222;
  --border:      #333;
  --text:        #e8e8e8;
  --text-muted:  #888;
  --accent:      #e63946;
  --accent-hover:#c1121f;
  --maps-blue:   #4285F4;
  --pa-gray:     #666;
  --success:     #1a3a2a;
  --success-text:#95d5b2;
  --error:       #3a1a1a;
  --error-text:  #ff8fa3;
  --info:        #1a2a3a;
  --info-text:   #90c2e7;
  --score-red:   #e63946;
  --score-yellow:#f4a261;
  --score-green: #2d9e5a;
  --ia-alto:     #2d9e5a;
  --ia-medio:    #f4a261;
  --ia-bajo:     #e63946;
  --ia-desc:     #555;
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius:      6px;
}

[data-theme="light"] {
  --bg:          #f5f5f5;
  --surface:     #ffffff;
  --surface2:    #f0f0f0;
  --border:      #ddd;
  --text:        #1a1a1a;
  --text-muted:  #666;
  --success:     #d4edda;
  --success-text:#155724;
  --error:       #f8d7da;
  --error-text:  #721c24;
  --info:        #d1ecf1;
  --info-text:   #0c5460;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; padding-bottom: 3rem; transition: background .2s, color .2s; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.app-wrapper { max-width: 1300px; margin: 0 auto; padding: 0 1.25rem; }

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 1.5rem 0 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem; }
.header-left h1 { font-size: 1.5rem; font-weight: 700; color: var(--accent); letter-spacing: -.5px; }
.header-left .subtitle { font-size: .82rem; color: var(--text-muted); margin-top: .2rem; }
.header-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

.proyecto-selector { display: flex; align-items: center; gap: .4rem; }
.proyecto-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; transition: background .2s; }
.proyecto-selector select { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: .3rem .6rem; font-size: .85rem; cursor: pointer; }

.btn-icon { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: .3rem .65rem; font-size: .9rem; cursor: pointer; transition: background .15s; }
.btn-icon:hover { background: var(--border); }

/* ─── Métricas ───────────────────────────────────────────────────────────── */
.metrics-bar { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.metric-card { flex: 1; min-width: 110px; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius); padding: .85rem 1rem; display: flex; flex-direction: column; align-items: center; gap: .15rem; transition: border-top-color .3s; position: relative; }
.metric-icon  { font-size: 1.1rem; }
.metric-val   { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.metric-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.metric-ia    { border-top-color: #9b5de5; }
.ia-breakdown { font-size: .72rem; color: var(--text-muted); margin-top: .2rem; display: flex; gap: .35rem; align-items: center; }
.ia-dot       { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.ia-dot.ia-alto  { background: var(--ia-alto); }
.ia-dot.ia-medio { background: var(--ia-medio); }
.ia-dot.ia-bajo  { background: var(--ia-bajo); }

/* ─── Search panel ───────────────────────────────────────────────────────── */
.search-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem; }

.source-tabs { display: flex; gap: .5rem; margin-bottom: 1.1rem; }
.tab-btn { display: flex; align-items: center; gap: .4rem; padding: .45rem .9rem; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-muted); font-size: .87rem; cursor: pointer; transition: border-color .15s, color .15s; }
.tab-btn:hover:not(.disabled):not([disabled]) { border-color: #555; color: var(--text); }
.tab-btn.active { border-color: var(--accent); color: var(--text); background: var(--surface2); }
.tab-btn.disabled, .tab-btn[disabled] { opacity: .45; cursor: not-allowed; }
.tab-lock { font-size: .72rem; }

.maps-hint { font-size: .82rem; color: var(--text-muted); margin-bottom: 1rem; padding: .6rem .85rem; background: var(--surface2); border-radius: var(--radius); border-left: 3px solid var(--maps-blue); }
.maps-hint code { background: var(--border); padding: .1em .35em; border-radius: 3px; font-size: .82rem; }

.form-row { display: flex; gap: 1rem; margin-bottom: 1rem; }
.form-group { flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.form-group-sm { flex: 0 0 130px; }
label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
input[type="text"], input[type="number"], select, textarea {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: .5rem .75rem; font-size: .9rem; font-family: var(--font);
  transition: border-color .15s; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #555; }
select option { background: var(--surface2); }
textarea { resize: vertical; }
.form-row-bottom { align-items: flex-end; margin-bottom: 0; }

.chips-row { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; align-items: center; }
.chip-label { font-size: .72rem; color: var(--text-muted); }
.chip { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; color: var(--text-muted); padding: .2rem .65rem; font-size: .78rem; cursor: pointer; transition: border-color .12s, color .12s; }
.chip:hover { border-color: var(--accent); color: var(--text); }

/* ─── Industrias + Subrubros ─────────────────────────────────────────────── */
.industria-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.industria-btn {
  padding: 0.4rem 0.9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.industria-btn.active,
.industria-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: #1e1010;
}

.subrubros-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  min-height: 28px;
}

/* ─── Zona con mapa ──────────────────────────────────────────────────────── */
.zona-mode-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.zona-tab {
  padding: 0.35rem 0.8rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
}

.zona-tab.active {
  border-color: var(--accent);
  color: var(--text);
  background: #1e1010;
}

#mapa-container {
  height: 280px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 0.6rem;
  z-index: 1;
}

.mapa-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
}

.mapa-zona-label {
  color: var(--accent);
  font-weight: 600;
}

.mapa-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ─── Botones ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1.1rem; border: none; border-radius: var(--radius); font-size: .9rem; font-family: var(--font); cursor: pointer; transition: background .15s, opacity .15s; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary   { background: var(--accent);   color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-outline   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-outline:hover { color: var(--text); border-color: #555; }
.btn-sm        { padding: .3rem .75rem; font-size: .82rem; }
.btn-action    { background: none; border: none; font-size: .9rem; cursor: pointer; padding: .2rem .3rem; border-radius: 4px; transition: background .1s; }
.btn-action:hover { background: var(--surface2); }
.bulk-actions  { display: flex; gap: .4rem; }

.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.hidden  { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Status ─────────────────────────────────────────────────────────────── */
.status-message { padding: .7rem 1rem; border-radius: var(--radius); font-size: .87rem; margin-bottom: .9rem; }
.status-success { background: var(--success); color: var(--success-text); }
.status-error   { background: var(--error);   color: var(--error-text); }
.status-info    { background: var(--info);    color: var(--info-text); }

/* ─── Historial + Sesiones ───────────────────────────────────────────────── */
.sesiones-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; overflow: hidden; }

.sesiones-tabs-header { display: flex; border-bottom: 1px solid var(--border); }
.stab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); padding: .6rem 1rem; font-size: .85rem; cursor: pointer; font-family: var(--font); transition: color .15s, border-color .15s; }
.stab:hover { color: var(--text); }
.stab.active { color: var(--accent); border-bottom-color: var(--accent); }

.stab-body { padding: .75rem 1rem 1rem; }

.historial-actions { margin-bottom: .6rem; }
.historial-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.historial-table th { padding: .4rem .6rem; text-align: left; font-size: .72rem; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.historial-table td { padding: .4rem .6rem; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.historial-empty { font-size: .85rem; color: var(--text-muted); padding: .5rem 0; }
.btn-repetir { font-size: .78rem; padding: .15rem .5rem; }

.sesion-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .6rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.sesion-nombre { font-size: .9rem; font-weight: 600; cursor: pointer; flex: 1; min-width: 160px; }
.sesion-nombre:hover { color: var(--accent); }
.sesion-meta { font-size: .78rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: .4rem .9rem; flex: 2; }
.sesion-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* ─── Filtros ────────────────────────────────────────────────────────────── */
.results-bar { margin-bottom: .75rem; }

.results-top-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}

.results-count-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: auto;
}

.filters-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: .6rem;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 120px;
}

.filter-item-wide { min-width: 220px; flex: 1; }
.filter-item-checks { min-width: 160px; }
.filter-item-clear { justify-content: flex-end; padding-bottom: 0; min-width: auto; }

.filter-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.filter-input { width: 100%; }

.filter-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  font-family: var(--font);
}

.filter-input-sm {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  width: 70px;
}

.checks-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.4rem 0;
}

.checkbox-label { display: flex; align-items: center; gap: .35rem; font-size: .83rem; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.checkbox-label input[type="checkbox"] { width: auto; }

.export-wrap { position: relative; }
.export-dropdown { position: absolute; top: calc(100% + 4px); right: 0; z-index: 100; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 200px; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.export-opt { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text); padding: .55rem .85rem; font-size: .87rem; cursor: pointer; font-family: var(--font); }
.export-opt:hover { background: var(--surface2); }

/* ─── Tabla ──────────────────────────────────────────────────────────────── */
.table-wrapper {
  position: relative;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  overflow: hidden;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 320px);
  min-height: 200px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.84rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  padding: 0.7rem 0.9rem;
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

th:nth-child(1), td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--surface2);
  border-right: 1px solid var(--border);
  min-width: 60px;
}

th:nth-child(2), td:nth-child(2) {
  position: sticky;
  left: 60px;
  z-index: 5;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 180px;
  max-width: 220px;
}

thead th:nth-child(1),
thead th:nth-child(2) {
  z-index: 15;
  background: var(--surface2);
}

tbody tr:nth-child(even) td:nth-child(1),
tbody tr:nth-child(even) td:nth-child(2) {
  background: #161616;
}
tbody tr:hover td:nth-child(1),
tbody tr:hover td:nth-child(2) {
  background: #1e1e1e;
}

td:nth-child(2), th:nth-child(2) {
  box-shadow: 4px 0 6px -2px rgba(0,0,0,0.4);
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
.sort-arrow { font-size: .7rem; margin-left: .2rem; }
td { padding: .55rem .75rem; border-bottom: 1px solid var(--surface2); vertical-align: middle; }
tbody tr:nth-child(even) { background: #141414; }
[data-theme="light"] tbody tr:nth-child(even) { background: #f8f8f8; }
tbody tr:hover { background: var(--surface2); }
tbody tr.row-duplicate { opacity: .6; }

.td-nombre a { color: var(--text); text-decoration: none; }
.td-nombre a:hover { color: var(--accent); text-decoration: underline; }
.td-dir, .td-tel { color: var(--text-muted); font-size: .81rem; }
.td-email { font-size: .8rem; color: var(--text-muted); }
.td-ig .link-ig { color: #c13584; font-size: .8rem; text-decoration: none; }
.td-ig .link-ig:hover { text-decoration: underline; }
.link-web { color: var(--maps-blue); text-decoration: none; }
.link-web:hover { text-decoration: underline; }
.rating  { color: #f4c430; font-size: .81rem; }
.empty   { color: #444; }
.td-actions { white-space: nowrap; }

.estado-select { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; color: var(--text); padding: .2rem .4rem; font-size: .78rem; cursor: pointer; width: auto; }
.estado-select:focus { outline: none; border-color: var(--accent); }

.nota-text  { cursor: pointer; font-size: .8rem; }
.nota-empty { color: var(--text-muted); font-style: italic; }
.nota-input { width: 130px; padding: .2rem .4rem; font-size: .8rem; background: var(--surface2); border: 1px solid var(--accent); border-radius: 4px; color: var(--text); }

/* ─── Score bar ──────────────────────────────────────────────────────────── */
.score-bar { display: flex; align-items: center; gap: .4rem; min-width: 80px; }
.score-fill { height: 6px; border-radius: 3px; transition: width .3s; flex-shrink: 0; }
.score-fill.score-red    { background: var(--score-red); }
.score-fill.score-yellow { background: var(--score-yellow); }
.score-fill.score-green  { background: var(--score-green); }
.score-num { font-size: .78rem; color: var(--text-muted); white-space: nowrap; min-width: 22px; }

/* ─── IA Badge ───────────────────────────────────────────────────────────── */
.ia-badge { display: inline-block; padding: .18em .55em; border-radius: 4px; font-size: .75rem; font-weight: 600; cursor: help; }
.ia-alto-badge  { background: rgba(45,158,90,.2);  color: #4ade80; }
.ia-medio-badge { background: rgba(244,162,97,.2); color: #fbbf24; }
.ia-bajo-badge  { background: rgba(230,57,70,.2);  color: #f87171; }
.ia-desc-badge  { background: rgba(80,80,80,.3);   color: #888; }

[data-theme="light"] .ia-alto-badge  { background: #d1fae5; color: #065f46; }
[data-theme="light"] .ia-medio-badge { background: #fef3c7; color: #92400e; }
[data-theme="light"] .ia-bajo-badge  { background: #fee2e2; color: #991b1b; }
[data-theme="light"] .ia-desc-badge  { background: #f3f4f6; color: #6b7280; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: .12em .45em; border-radius: 4px; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.badge-pa     { background: var(--pa-gray); color: #fff; }
.badge-maps   { background: var(--maps-blue); color: #fff; }
.badge-tienda { background: #1a3a2a; color: #4ade80; font-size: .72rem; font-weight: 600; }
[data-theme="light"] .badge-tienda { background: #d1fae5; color: #065f46; }
.badge-ya { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); font-size: .68rem; font-weight: 400; margin-left: .4rem; padding: .1em .4em; border-radius: 4px; }

/* ─── Modal (base) ───────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-height: 92vh; overflow-y: auto; }
.modal-wide    { max-width: 540px; }
.modal-contact { max-width: 480px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-header h3 { font-size: 1rem; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: .9rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.modal-divider { border: none; border-top: 1px solid var(--border); margin: .25rem 0; }
.modal-section-title { font-size: .82rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.modal-hint { font-size: .78rem; color: var(--text-muted); }
.modal-hint code { background: var(--border); padding: .1em .35em; border-radius: 3px; }

/* color picker */
.color-picker { display: flex; gap: .5rem; }
.color-opt { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform .15s, border-color .15s; }
.color-opt.active { border-color: var(--text); transform: scale(1.15); }

/* tag input */
.tag-input-wrap { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: .4rem .6rem; display: flex; flex-wrap: wrap; gap: .35rem; cursor: text; min-height: 38px; }
.tag-input-wrap:focus-within { border-color: var(--accent); }
.tag { background: var(--border); border-radius: 20px; padding: .15rem .55rem; font-size: .8rem; display: flex; align-items: center; gap: .3rem; }
.tag button { background: none; border: none; color: var(--text-muted); font-size: .9rem; cursor: pointer; padding: 0; line-height: 1; }
.tag button:hover { color: var(--accent); }
#rubros-input, #zonas-input { background: none; border: none; color: var(--text); font-size: .85rem; outline: none; min-width: 100px; flex: 1; padding: .1rem 0; }

/* ─── Modal contacto ─────────────────────────────────────────────────────── */
.contact-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1rem; gap: 0; }
.contact-tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); padding: .5rem .9rem; font-size: .87rem; cursor: pointer; font-family: var(--font); transition: color .15s, border-color .15s; }
.contact-tab:hover { color: var(--text); }
.contact-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.contact-tab-content { display: flex; flex-direction: column; gap: .75rem; }
.contact-tab-content label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.contact-tab-content textarea { min-height: 100px; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .form-row { flex-direction: column; }
  .form-group-sm { flex: 1; }
}
@media (max-width: 600px) {
  .metrics-bar .metric-card { min-width: 90px; }
  .metric-val { font-size: 1.3rem; }
  .filters-row select, .filter-input { width: 100%; }
  .results-meta-row { flex-direction: column; align-items: flex-start; }
  .source-tabs { flex-direction: column; }
  .header-right { flex-wrap: wrap; justify-content: flex-end; }
}

/* Mejoras v2: fuentes, multipin y drawer */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  margin-bottom: 1.25rem;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-header .subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0;
}

.source-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
  color: var(--text);
}

.tab-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface2);
}

.tab-btn.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}

.tab-btn.disabled,
.tab-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.badge-yelp { background: #d32323; color: #fff; }
.badge-instagram { background: #c13584; color: #fff; }

.maps-advanced-hint,
.maps-cost-estimate {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface2);
  border-radius: var(--radius);
  border-left: 3px solid var(--maps-blue);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  margin-left: 0.35rem;
}

#mapa-container {
  width: 100%;
  height: 340px;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.mapa-controls {
  flex-wrap: wrap;
}

.pins-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.pin-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pin-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  font-size: 0.85rem;
}

.pin-chip button:hover { color: #e63946; }

.search-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.search-progress .progress-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.search-progress .progress-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.row-new td:first-child {
  border-left: 3px solid var(--accent);
}

.lead-name-btn {
  border: none;
  background: none;
  color: var(--text);
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.lead-name-btn:hover {
  color: var(--accent);
  text-decoration: underline;
}

.lead-drawer {
  position: fixed;
  right: -420px;
  top: 0;
  height: 100vh;
  width: 400px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  transition: right 0.25s ease;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}

.lead-drawer.open { right: 0; }

.lead-drawer-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
}

.lead-drawer h3 {
  padding-right: 2rem;
  margin-bottom: 1rem;
}

.lead-drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.lead-detail-list div {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.lead-detail-list dt {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lead-detail-list dd {
  margin-top: 0.2rem;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.sesiones-toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.sesiones-toolbar input[type="search"] {
  flex: 1;
  min-width: 220px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.45rem 0.7rem;
}

.sesion-check input { width: auto; }

@media (min-width: 768px) {
  .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
  }

  .form-row-bottom {
    grid-template-columns: 130px auto;
    align-items: end;
  }
}
