/* ══════════════════════════════════════════════════════════════════
   LeadHunter Pro — app.css v3.1
   MOBILE FIRST — Responsive para todos los dispositivos
   Base: 320px → 480px → 640px → 768px → 1024px → 1280px+
   ══════════════════════════════════════════════════════════════════ */

/* ── Variables globales ─────────────────────────────────────────── */
:root {
  --bg:          #0a0d14;
  --bg2:         #111520;
  --bg3:         #181d2e;
  --bg4:         #1e2438;
  --border:      rgba(255,255,255,0.07);
  --border2:     rgba(255,255,255,0.12);
  --text:        #e8eaf0;
  --text2:       #9ca3b0;
  --text3:       #6b7280;
  --a:           #00d4ff;
  --a2:          #0099cc;
  --green:       #10b981;
  --red:         #ef4444;
  --yellow:      #f59e0b;
  --purple:      #a855f7;
  --orange:      #f97316;
  --sidebar-w:   240px;
  --topbar-h:    54px;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 48px rgba(0,0,0,0.6);
  --transition:  0.2s cubic-bezier(0.4,0,0.2,1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* ── Reset base ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport height para mobile */
  display: flex;
  overflow-x: hidden;
  line-height: 1.5;
}

a { color: var(--a); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; line-height: 1; }
input, select, textarea {
  font-family: inherit;
  font-size: 16px; /* ← evita zoom automático en iOS */
  color: var(--text);
}
img { max-width: 100%; display: block; }

/* ── Scrollbar (solo desktop) ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR — oculta en mobile, desliza desde la izquierda
   ══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 200;
  /* Mobile: oculta por defecto */
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  padding-bottom: var(--safe-bottom);
}
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-mark {
  font-size: 1.4rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(0,212,255,0.6));
}
.logo-wordmark {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.5px;
  line-height: 1;
  color: var(--text);
}
.logo-wordmark span { color: var(--a); }
.logo-badge {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--a), var(--purple));
  color: #000;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-section-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  padding: 14px 8px 5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .9rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
  margin-bottom: 2px;
  min-height: 44px; /* touch target mínimo */
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: rgba(0,212,255,0.1);
  color: var(--a);
  border-color: rgba(0,212,255,0.2);
}
.nav-item i { width: 18px; text-align: center; font-size: .88rem; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 16px;
  padding-bottom: max(14px, var(--safe-bottom));
  border-top: 1px solid var(--border);
  font-size: .73rem;
  color: var(--text3);
  flex-shrink: 0;
}
.sidebar-footer-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  margin-right: 6px;
  box-shadow: 0 0 6px var(--green);
}

/* ══════════════════════════════════════════════════════════════════
   MAIN CONTENT — ocupa todo en mobile
   ══════════════════════════════════════════════════════════════════ */
.main-content {
  margin-left: 0; /* mobile: sin sidebar */
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* TOP BAR */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,13,20,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: var(--topbar-h);
  padding-left: max(12px, var(--safe-left));
  padding-right: max(12px, var(--safe-right));
}

/* Botón hamburguesa — siempre visible en mobile */
.sidebar-toggle {
  display: flex;
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  color: var(--text);
  font-size: 1rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border2);
  min-width: 38px;
}

.top-bar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  color: var(--text3);
  min-width: 0;
  overflow: hidden;
}
.top-bar-breadcrumb .sep { color: var(--border2); flex-shrink: 0; }
.top-bar-breadcrumb .current {
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-bar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 2px; flex-shrink: 0; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Ocultar texto "Search Businesses" en mobile muy pequeño */
.top-actions .btn-label { display: none; }

/* VIEW CONTAINER */
.view-container {
  flex: 1;
  padding: 14px 12px;
  overflow-x: hidden;
  padding-bottom: max(20px, var(--safe-bottom));
}
.view { display: none; }
.view.active { display: block; }

/* ══════════════════════════════════════════════════════════════════
   BOTONES — touch-friendly
   ══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 40px;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}
.btn-sm  { padding: 6px 12px; font-size: .8rem; min-height: 34px; }
.btn-lg  { padding: 12px 22px; font-size: .95rem; min-height: 48px; }
.btn-icon {
  padding: 0;
  width: 38px; height: 38px;
  min-width: 38px; min-height: 38px;
}
.btn-icon.btn-sm { width: 34px; height: 34px; min-width: 34px; min-height: 34px; }

.btn-primary  { background: linear-gradient(135deg, var(--a), #0099cc); color: #000; font-weight: 700; }
.btn-primary:hover  { opacity: .9; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,212,255,0.4); }
.btn-primary:active { transform: translateY(0); opacity: 1; }

.btn-success  { background: linear-gradient(135deg, var(--green), #059669); color: #fff; font-weight: 700; }
.btn-success:hover  { opacity: .9; transform: translateY(-1px); }
.btn-success:active { transform: translateY(0); }

.btn-danger   { background: linear-gradient(135deg, var(--red), #dc2626); color: #fff; }
.btn-danger:hover   { opacity: .9; }

.btn-warning  { background: linear-gradient(135deg, var(--yellow), #d97706); color: #000; font-weight: 700; }
.btn-warning:hover  { opacity: .9; }

.btn-purple   { background: linear-gradient(135deg, var(--purple), #7c3aed); color: #fff; }
.btn-purple:hover   { opacity: .9; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text2);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--a);
  color: var(--a);
}
.btn-outline:hover { background: rgba(0,212,255,0.08); }

.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; pointer-events: none; }

/* ══════════════════════════════════════════════════════════════════
   STATS GRID — 1 col → 2 col → 4 col
   ══════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
  animation: fadeSlideUp 0.4s ease both;
  animation-delay: var(--d, 0ms);
}
.stat-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-card.loading {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-glow {
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--stat-color, var(--a));
  opacity: .05;
  filter: blur(20px);
  pointer-events: none;
}
.stat-icon-wrap {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--stat-color-dim, rgba(0,212,255,0.08));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  font-size: .88rem;
}
.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  margin-bottom: 3px;
}
.stat-label {
  font-size: .72rem;
  color: var(--text2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stat-sub { font-size: .68rem; color: var(--text3); margin-top: 3px; }

/* ══════════════════════════════════════════════════════════════════
   CHARTS — apilados en mobile
   ══════════════════════════════════════════════════════════════════ */
.charts-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.chart-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.chart-area { min-height: 140px; }
.chart-donut { display: flex; flex-direction: column; gap: 7px; }
.chart-row { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.chart-bar-wrap { flex: 1; height: 6px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 3px; transition: width 0.8s ease; }
.chart-row-label { width: 90px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .76rem; }
.chart-row-val { width: 28px; text-align: right; color: var(--text3); font-family: monospace; font-size: .75rem; }

/* ACTIVITY */
.activity-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.activity-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.activity-card-title {
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  border: 1px solid var(--border);
}
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--a); margin-top: 5px; flex-shrink: 0; }
.activity-text { font-size: .78rem; color: var(--text2); }
.activity-biz { font-weight: 600; color: var(--text); }
.activity-time { font-size: .7rem; color: var(--text3); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════════════
   FILTERS BAR — columna en mobile, fila en desktop
   ══════════════════════════════════════════════════════════════════ */
.filters-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.filter-input, .filter-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 16px; /* evita zoom en iOS */
  transition: border-color var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.filter-input:focus, .filter-select:focus { border-color: var(--a); box-shadow: 0 0 0 2px rgba(0,212,255,0.1); }
.filter-select option { background: var(--bg3); }
.total-count {
  font-size: .78rem;
  color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
}

/* ══════════════════════════════════════════════════════════════════
   DATA TABLE — scroll horizontal en mobile
   ══════════════════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%;
  min-width: 560px; /* permite scroll en mobile */
  border-collapse: collapse;
  font-size: .82rem;
}
.data-table thead th {
  background: var(--bg3);
  color: var(--text2);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table td { padding: 10px 12px; vertical-align: middle; }
.loading-cell { text-align: center; padding: 40px; color: var(--text3); }
.empty-cell { text-align: center; padding: 48px 20px; color: var(--text3); }
.empty-cell i { font-size: 2rem; margin-bottom: 10px; opacity: .3; display: block; }

/* ══════════════════════════════════════════════════════════════════
   BADGES & TAGS
   ══════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  line-height: 1.3;
}
.badge-website   { background: rgba(16,185,129,0.12); color: var(--green);  border: 1px solid rgba(16,185,129,0.25); }
.badge-social    { background: rgba(168,85,247,0.12);  color: var(--purple); border: 1px solid rgba(168,85,247,0.25); }
.badge-maps      { background: rgba(245,158,11,0.12);  color: var(--yellow); border: 1px solid rgba(245,158,11,0.25); }
.badge-none      { background: rgba(107,114,128,0.12); color: var(--text3); border: 1px solid rgba(107,114,128,0.2); }

.badge-opportunity { background: rgba(0,212,255,0.1);   color: var(--a);      border: 1px solid rgba(0,212,255,0.25); }
.badge-competitor  { background: rgba(239,68,68,0.1);   color: var(--red);    border: 1px solid rgba(239,68,68,0.2); }

.badge-ws-valid    { background: rgba(16,185,129,0.1);  color: var(--green);  border: 1px solid rgba(16,185,129,0.2); }
.badge-ws-insecure { background: rgba(245,158,11,0.1);  color: var(--yellow); border: 1px solid rgba(245,158,11,0.2); }
.badge-ws-broken   { background: rgba(239,68,68,0.1);   color: var(--red);    border: 1px solid rgba(239,68,68,0.2); }
.badge-ws-outdated { background: rgba(107,114,128,0.1); color: var(--text3);  border: 1px solid rgba(107,114,128,0.2); }
.badge-ws-none     { background: transparent; color: var(--text3); border: 1px solid var(--border); }
.badge-ws-invalid  { background: rgba(239,68,68,0.1);   color: var(--red);    border: 1px solid rgba(239,68,68,0.2); }

.badge-new        { background: rgba(59,130,246,0.12);  color: #60a5fa;       border: 1px solid rgba(59,130,246,0.2); }
.badge-contacted  { background: rgba(245,158,11,0.12);  color: var(--yellow); border: 1px solid rgba(245,158,11,0.2); }
.badge-interested { background: rgba(168,85,247,0.12);  color: var(--purple); border: 1px solid rgba(168,85,247,0.2); }
.badge-proposal   { background: rgba(6,182,212,0.12);   color: #22d3ee;       border: 1px solid rgba(6,182,212,0.2); }
.badge-closed     { background: rgba(16,185,129,0.12);  color: var(--green);  border: 1px solid rgba(16,185,129,0.2); }
.badge-lost       { background: rgba(239,68,68,0.12);   color: var(--red);    border: 1px solid rgba(239,68,68,0.2); }

.badge-low    { color: var(--text3); }
.badge-normal { color: #60a5fa; }
.badge-high   { color: var(--yellow); }
.badge-urgent { color: var(--red); }

.biz-name  { font-weight: 600; color: var(--text); margin-bottom: 2px; font-size: .85rem; }
.biz-sub   { font-size: .74rem; color: var(--text3); }
.biz-phone { font-size: .77rem; color: var(--text2); }

.social-icons { display: flex; gap: 5px; flex-wrap: wrap; }
.social-icon-btn {
  width: 26px; height: 26px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  transition: transform var(--transition);
  min-width: 26px;
}
.social-icon-btn:hover { transform: scale(1.15); }

/* ── Pagination ─────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 8px;
}
.page-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: .82rem;
  min-height: 36px;
  min-width: 36px;
  transition: all var(--transition);
}
.page-btn:hover { border-color: var(--a); color: var(--a); }
.page-btn.active { background: var(--a); color: #000; border-color: var(--a); font-weight: 700; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { font-size: .78rem; color: var(--text3); }

/* ══════════════════════════════════════════════════════════════════
   SCRAPER VIEW — panel arriba, resultados abajo en mobile
   ══════════════════════════════════════════════════════════════════ */
.scraper-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.scraper-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.scraper-panel-title {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.scraper-panel-title i { color: var(--a); }

/* FORMULARIO */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: .74rem;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.form-label span { color: var(--text3); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: .7rem; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px; /* evitar zoom iOS */
  transition: border-color var(--transition);
  outline: none;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--a);
  box-shadow: 0 0 0 2px rgba(0,212,255,0.1);
}
.form-input::placeholder { color: var(--text3); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: .7rem; color: var(--text3); margin-top: 5px; }

/* TAGS INPUT */
.tags-input-wrap {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-height: 46px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  cursor: text;
  transition: border-color var(--transition);
}
.tags-input-wrap:focus-within { border-color: var(--a); box-shadow: 0 0 0 2px rgba(0,212,255,0.1); }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.25);
  color: var(--a);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
}
.tag-chip-remove {
  cursor: pointer;
  color: var(--a);
  opacity: .65;
  transition: opacity var(--transition);
  font-size: .8rem;
  line-height: 1;
  padding: 0 2px;
  min-width: 16px; /* touch target */
}
.tag-chip-remove:hover { opacity: 1; }
.tags-input-field {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  outline: none;
  min-width: 100px;
  flex: 1;
}
.tags-input-field::placeholder { color: var(--text3); }

/* Resultados scraper */
.scraper-results { min-height: 200px; }

.scraper-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.summary-stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}
.summary-stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.summary-stat-label { font-size: .68rem; color: var(--text3); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.3px; }

.scraper-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* PROGRESS */
.progress-bar-wrap { background: var(--bg3); border-radius: 4px; height: 6px; overflow: hidden; margin-bottom: 10px; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--a), var(--purple)); border-radius: 4px; transition: width .3s ease; }

/* SPINNER */
.spinner { width: 22px; height: 22px; border: 2px solid var(--border2); border-top-color: var(--a); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════
   MODAL — bottom sheet en mobile, centrado en desktop
   ══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: flex-end; /* bottom sheet en mobile */
  justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius) var(--radius) 0 0; /* top rounded */
  width: 100%;
  max-width: 100%;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  animation: slideUpModal 0.3s cubic-bezier(0.16,1,0.3,1);
  padding-bottom: var(--safe-bottom);
}

.modal-lg { max-width: 100%; }

/* Drag handle visual */
.modal::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 10px auto 4px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 1;
}
.modal-title { font-size: .95rem; font-weight: 700; color: var(--text); }
.modal-close {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg4);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--red); color: #fff; }
.modal-body { padding: 16px 18px; }
.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* DETAIL GRID en modal */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.detail-field-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text3); margin-bottom: 3px; }
.detail-field-value { font-size: .86rem; color: var(--text); }
.detail-section-title {
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text3);
  margin: 16px 0 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}

/* NOTES */
.notes-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.note-item { padding: 10px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .8rem; }
.note-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.note-type-badge { font-size: .64rem; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; background: var(--bg4); color: var(--text3); }
.note-author { font-size: .7rem; color: var(--text3); }
.note-date { font-size: .66rem; color: var(--text3); margin-left: auto; }
.note-content { color: var(--text2); line-height: 1.4; word-break: break-word; }

/* STATUS PIPELINE */
.status-pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.status-step {
  flex: 1;
  min-width: 30%;
  padding: 9px 4px;
  text-align: center;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: all var(--transition);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text3);
  background: var(--bg3);
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.status-step:last-child { border-right: none; }
.status-step:hover { color: var(--text); background: var(--bg4); }
.status-step.active { color: #000 !important; font-weight: 800; }
.status-step[data-status="new"].active        { background: #3b82f6; }
.status-step[data-status="contacted"].active  { background: var(--yellow); }
.status-step[data-status="interested"].active { background: var(--purple); }
.status-step[data-status="proposal"].active   { background: #06b6d4; }
.status-step[data-status="closed"].active     { background: var(--green); }
.status-step[data-status="lost"].active       { background: var(--red); }

/* ══════════════════════════════════════════════════════════════════
   TOAST — esquina inferior en mobile
   ══════════════════════════════════════════════════════════════════ */
#toastContainer {
  position: fixed;
  bottom: max(16px, var(--safe-bottom));
  left: 12px; right: 12px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--border2);
  box-shadow: var(--shadow-lg);
  font-size: .84rem;
  animation: slideInUp 0.3s cubic-bezier(0.16,1,0.3,1);
  color: var(--text);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--yellow); }
.toast.info    { border-left: 3px solid var(--a); }
.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-msg { flex: 1; line-height: 1.4; word-break: break-word; }

/* ══════════════════════════════════════════════════════════════════
   VIEW HEADER
   ══════════════════════════════════════════════════════════════════ */
.view-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.view-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.view-title i { color: var(--a); font-size: 1rem; }
.view-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Section divider ─────────────────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
}
.section-divider::before, .section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Utilities ───────────────────────────────────────────────────── */
.text-muted  { color: var(--text3); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue   { color: #60a5fa; }
.text-cyan   { color: var(--a); }
.text-purple { color: var(--purple); }
.font-mono   { font-family: 'JetBrains Mono', monospace; }
.d-flex      { display: flex; }
.align-center { align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.mb-0        { margin-bottom: 0; }
.mt-auto     { margin-top: auto; }
.ml-auto     { margin-left: auto; }

/* ══════════════════════════════════════════════════════════════════
   TEMPLATES GRID
   ══════════════════════════════════════════════════════════════════ */
.templates-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.template-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}
.template-card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: var(--shadow); }
.template-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.template-card-name { font-weight: 700; color: var(--text); font-size: .88rem; }
.template-card-channel {
  font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 4px; white-space: nowrap;
  background: var(--bg4); color: var(--text3);
  flex-shrink: 0;
}
.template-card-channel.whatsapp { background: rgba(37,211,102,0.1); color: #25d366; }
.template-card-channel.email    { background: rgba(59,130,246,0.1);  color: #60a5fa; }
.template-card-channel.call     { background: rgba(245,158,11,0.1);  color: var(--yellow); }
.template-card-channel.sms      { background: rgba(168,85,247,0.1);  color: var(--purple); }
.template-card-preview {
  font-size: .78rem;
  color: var(--text3);
  line-height: 1.5;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.template-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.template-card-meta { font-size: .7rem; color: var(--text3); }
.template-card-actions { display: flex; gap: 6px; }

/* ══════════════════════════════════════════════════════════════════
   ANIMACIONES
   ══════════════════════════════════════════════════════════════════ */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUpModal {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}
.animate-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* Reduce animations on low-power mode */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ══════════════════════════════════════════════════════════════════
   ── BREAKPOINT 480px (teléfonos más grandes)
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 480px) {
  .view-container { padding: 16px 14px; }
  .scraper-summary { grid-template-columns: repeat(5, 1fr); }
  .templates-grid { grid-template-columns: 1fr; }
  #toastContainer { left: auto; right: 14px; max-width: 360px; }
  .top-actions .btn-label { display: inline; }
}

/* ══════════════════════════════════════════════════════════════════
   ── BREAKPOINT 640px (teléfonos landscape / tablet pequeña)
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  html { font-size: 14px; }
  .view-container { padding: 18px 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-value { font-size: 1.75rem; }
  .filters-bar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .filter-input { min-width: 0; flex: 1 1 160px; }
  .filter-select { flex: 0 1 auto; width: auto; }
  .total-count { margin-left: auto; text-align: left; }
  .view-header { flex-direction: row; align-items: center; justify-content: space-between; }
  .templates-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════════════════
   ── BREAKPOINT 768px (tablet vertical)
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0); /* siempre visible */
    position: fixed;
    z-index: 100;
  }
  .sidebar-overlay { display: none !important; }
  .sidebar-toggle { display: none; } /* esconde hamburguesa */
  .main-content { margin-left: var(--sidebar-w); }
  .top-bar { padding: 0 20px; }

  .modal-overlay { align-items: center; padding: 20px; }
  .modal {
    border-radius: var(--radius);
    max-width: 560px;
    max-height: 88vh;
    padding-bottom: 0;
    animation: fadeSlideUp 0.25s ease;
  }
  .modal::before { display: none; } /* no drag handle en desktop */
  .modal-lg { max-width: 800px; }

  .view-container { padding: 22px 24px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .stat-value { font-size: 1.9rem; }
  .charts-row { flex-direction: row; }
  .activity-row { flex-direction: row; }
  #toastContainer { left: auto; right: 24px; bottom: 24px; max-width: 380px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .toast { animation: slideInRight 0.3s cubic-bezier(0.16,1,0.3,1); }
}

/* ══════════════════════════════════════════════════════════════════
   ── BREAKPOINT 1024px (tablet horizontal / laptop pequeño)
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  .scraper-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    align-items: start;
  }
  .scraper-panel { position: sticky; top: calc(var(--topbar-h) + 20px); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .templates-grid { grid-template-columns: repeat(2, 1fr); }
  .form-input, .form-select, .form-textarea { font-size: .9rem; }
  .filter-input, .filter-select { font-size: .85rem; }
  .tags-input-field { font-size: .88rem; }
}

/* ══════════════════════════════════════════════════════════════════
   ── BREAKPOINT 1280px (desktop completo)
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .scraper-layout { grid-template-columns: 400px 1fr; }
  .templates-grid { grid-template-columns: repeat(3, 1fr); }
  .view-container { padding: 24px 28px; }
}

/* ──────────────────────────────────────────────────────────────────
   Keyframe extra para desktop
   ────────────────────────────────────────────────────────────────── */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
