:root {
  --blue: #0A6FDB;
  --blue-bg: #E8F2FD;
  --bg: #F4F5F7;
  --bg-input: #EEF0F4;
  --card: #fff;
  --text: #0E1117;
  --text-2: #5A5D68;
  --text-3: #8B8F9A;
  --border: #E2E4EA;
  --border2: #D0D4DE;
  --green: #059669;
  --green-bg: #ECFDF5;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --amber: #D97706;
  --amber-bg: #FFFBEB;
  --purple: #7C3AED;
  --purple-bg: #F5F3FF;
  --sidebar-w: 240px;
  --brand-header-h: 72px;
  --topbar-h: var(--brand-header-h);
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Source Sans 3', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
h1,h2,h3,h4 { font-family: 'Barlow', sans-serif; margin: 0; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }

.app-boot {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  gap: 10px;
  background:
    radial-gradient(ellipse 70% 50% at 20% 20%, rgba(14, 165, 168, 0.12), transparent 55%),
    linear-gradient(160deg, #E8EEF5 0%, #F3F5F8 50%, #E6EBEF 100%);
  color: var(--text);
}
.app-boot-mark {
  font-family: 'Outfit', 'Barlow', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.04em;
  text-align: center;
}
.app-boot-logo {
  display: block;
  width: min(280px, 72vw);
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
}
.app-boot-copy {
  margin: 0;
  text-align: center;
  color: var(--text-2);
  font-size: 0.95rem;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  padding: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(14, 165, 168, 0.14), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(10, 111, 219, 0.1), transparent 50%),
    linear-gradient(160deg, #E8EEF5 0%, #F3F5F8 45%, #E6EBEF 100%);
  overflow: hidden;
}
.login-shell {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  width: 100%;
  min-height: 100vh;
  animation: loginFade 0.7s ease both;
}
.login-visual {
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: clamp(32px, 6vw, 72px);
  background:
    linear-gradient(145deg, rgba(8, 22, 38, 0.55), rgba(8, 22, 38, 0.25)),
    linear-gradient(120deg, #0B3A5C 0%, #0E6B78 48%, #0A6FDB 100%);
  color: #fff;
  overflow: hidden;
}
.login-visual-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 30% 70%, #000 20%, transparent 75%);
  opacity: 0.7;
  animation: loginGridDrift 18s linear infinite;
}
.login-visual-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}
.login-visual-orb-a {
  width: min(420px, 55vw);
  height: min(420px, 55vw);
  right: -8%;
  top: -12%;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.35), transparent 70%);
  animation: loginOrb 10s ease-in-out infinite alternate;
}
.login-visual-orb-b {
  width: min(320px, 45vw);
  height: min(320px, 45vw);
  left: -10%;
  bottom: 8%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.28), transparent 68%);
  animation: loginOrb 12s ease-in-out infinite alternate-reverse;
}
.login-visual-content {
  position: relative;
  z-index: 1;
  max-width: 440px;
  animation: loginRise 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}
.login-kicker {
  margin: 0 0 14px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.72);
}
.login-hero-brand {
  font-family: 'Outfit', 'Barlow', sans-serif;
  font-size: clamp(2.6rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
}
.login-hero-brand em {
  display: block;
  font-style: normal;
  font-weight: 600;
  color: #9BE8E0;
  font-size: 0.72em;
  margin-top: 0.12em;
}
.login-hero-copy {
  margin: 0;
  max-width: 28ch;
  font-size: 1.05rem;
  line-height: 1.45;
  color: rgba(255,255,255,0.84);
}
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vw, 48px);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  padding: clamp(28px, 4vw, 40px);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  animation: loginRise 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}
.brand {
  font-family: 'Outfit', 'Barlow', sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.brand .brand-name { display: block; color: var(--text); }
.brand .brand-product {
  display: block;
  color: #0E6B78;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: -0.01em;
}
.subtitle { color: var(--text-2); margin: 10px 0 8px; font-size: 0.95rem; }
.login-tenant {
  display: inline-block;
  margin: 0 0 22px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--blue-bg);
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.login-submit {
  width: 100%;
  margin-top: 6px;
  padding: 12px 18px;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.15s;
}
.login-submit:hover { transform: translateY(-1px); opacity: 1; background: #085fc0; }
#login-form label:focus-within input {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(10, 111, 219, 0.12);
}
@keyframes loginFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes loginRise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes loginOrb {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(18px, -14px) scale(1.06); }
}
@keyframes loginGridDrift {
  from { transform: translate(0, 0); }
  to { transform: translate(24px, 24px); }
}
@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual {
    min-height: 38vh;
    align-items: flex-end;
    padding: 28px 24px 32px;
  }
  .login-hero-brand { font-size: clamp(2.2rem, 9vw, 3rem); }
  .login-panel { padding: 20px 18px 36px; align-items: flex-start; }
  .login-card { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .login-shell, .login-visual-content, .login-card,
  .login-visual-orb, .login-visual-grid { animation: none; }
}
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 14px; color: var(--text-2); }
label input, label select, label textarea { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); }
.color-field {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  min-height: 44px;
}
label input[type="color"] {
  width: 52px;
  height: 44px;
  margin-top: 0;
  padding: 0;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}
label input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
label input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 7px;
}
label input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 7px;
}
.color-swatch-preview {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
  flex-shrink: 0;
}
.color-hex {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.error { color: var(--red); font-size: 0.85rem; margin-top: 12px; }

/* Buttons */
.btn-primary, .btn-secondary, .btn-ghost, .btn-sm { border: none; border-radius: 8px; padding: 10px 18px; font-weight: 600; cursor: pointer; transition: opacity 0.15s; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { opacity: 0.92; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }
.btn-link { background: none; border: none; color: var(--blue); font-weight: 600; cursor: pointer; padding: 0; }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-action { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.btn-wa { color: #128C7E; border-color: #bbf7d0; background: #f0fdf4; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #0E1117; color: #fff; display: flex; flex-direction: column;
  flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
}
.sidebar-brand {
  height: var(--brand-header-h);
  min-height: var(--brand-header-h);
  padding: 0 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  box-sizing: border-box;
}
.sidebar-logo { font-family: 'Outfit', 'Barlow', sans-serif; font-weight: 800; font-size: 1.1rem; display: block; line-height: 1.15; }
.sidebar-tag { font-size: 0.72rem; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.06em; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 14px;
  border: none; border-radius: 8px; background: transparent; color: rgba(255,255,255,0.7);
  font-weight: 600; font-size: 0.9rem; cursor: pointer; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-svg {
  width: 18px; height: 18px; flex-shrink: 0;
  stroke: currentColor; stroke-width: 2; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 0.7rem; padding: 2px 7px; border-radius: 999px; }
.sidebar-brand.has-logo { padding: 0 18px; }
.sidebar-logo-img {
  display: block; max-width: 100%; max-height: 52px; width: auto; object-fit: contain;
}
.brand-logo-img {
  display: block; max-height: 64px; max-width: 260px; margin: 0 0 14px; object-fit: contain;
  border-radius: 8px;
}
.login-brand { text-align: left; margin-bottom: 4px; }
.logo-upload-block { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 24px; }
.logo-preview-wrap {
  width: 160px; height: 100px; border: 1px dashed var(--border2); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; background: var(--bg);
  overflow: hidden;
}
.logo-preview { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-placeholder { color: var(--text-3); font-size: 0.85rem; }
.logo-upload-actions { display: flex; flex-direction: column; gap: 8px; }
.logo-file-btn { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.section-divider { margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--border); }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user strong { display: block; font-size: 0.88rem; }
.sidebar-user span { font-size: 0.75rem; color: rgba(255,255,255,0.5); }

.main-wrap { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar,
.crm-topheader {
  height: var(--brand-header-h);
  min-height: var(--brand-header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-sizing: border-box;
}
.btn-menu { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.topbar-title { min-width: 0; flex-shrink: 1; }
.topbar-title h1 { font-size: 1.2rem; font-weight: 700; line-height: 1.15; }
.topbar-sub { font-size: 0.8rem; color: var(--text-3); margin: 2px 0 0; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.market-ticker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.market-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  line-height: 1;
}
.market-label {
  font-family: 'Outfit', 'Barlow', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.market-value {
  font-family: 'Barlow', sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.market-live {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--green);
  background: var(--green-bg);
  padding: 2px 5px;
  border-radius: 4px;
  align-self: center;
}
.market-updated {
  font-size: 0.7rem;
  color: var(--text-3);
  white-space: nowrap;
}
@media (max-width: 1100px) {
  .market-updated { display: none; }
}
@media (max-width: 900px) {
  .market-ticker { gap: 6px; }
  .market-item { padding: 5px 8px; }
  .market-value { font-size: 0.88rem; }
}
.search-box input { padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; min-width: 200px; }
.content { padding: 24px; flex: 1; }
.view { display: none; }
.view.active { display: block; }

/* KPIs */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.kpi.accent { border-color: var(--blue); background: linear-gradient(135deg, #fff, var(--blue-bg)); }
.kpi-label { display: block; font-size: 0.75rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { display: block; font-family: 'Barlow', sans-serif; font-size: 1.75rem; font-weight: 800; margin-top: 4px; }
.kpi-sub { font-size: 0.78rem; color: var(--text-3); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel-flush { padding: 0; overflow: hidden; }
.panel h2 { font-size: 0.95rem; margin-bottom: 16px; }
.pipeline-bars { display: flex; flex-direction: column; gap: 10px; }
.pipeline-row { display: grid; grid-template-columns: 100px 1fr 36px; align-items: center; gap: 10px; font-size: 0.85rem; }
.pipeline-track { height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.pipeline-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.pipeline-count { text-align: right; font-weight: 700; color: var(--text-2); }
.trend-chart { width: 100%; height: 180px; display: block; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th { text-align: left; padding: 12px 16px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); border-bottom: 1px solid var(--border); background: var(--bg); }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: #fafbfc; }
.empty-msg, .empty-state { color: var(--text-3); padding: 24px; text-align: center; }

/* Pipeline */
.pipe-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.pipe-subtitle { color: var(--text-2); font-size: 0.9rem; margin: 0; }
.pipe-stats { display: flex; gap: 16px; font-size: 0.85rem; color: var(--text-2); }
.pipe-stats .won { color: var(--green); }
.pipe-hint { font-size: 0.8rem; color: var(--text-3); margin: 0 0 14px; }

.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: calc(100vh - 220px); }
.kanban-board::-webkit-scrollbar { height: 8px; }
.kanban-board::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.kanban-loading { padding: 48px; color: var(--text-3); width: 100%; text-align: center; }
.kanban-column { flex: 0 0 280px; min-width: 280px; display: flex; flex-direction: column; background: var(--bg-input); border-radius: var(--radius); border: 1px solid var(--border); max-height: calc(100vh - 220px); transition: border-color 0.15s, box-shadow 0.15s; }
.kanban-column.drag-over { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-bg); }
.kanban-column.col-ganado { border-top: 3px solid var(--green); }
.kanban-column.col-perdido { border-top: 3px solid var(--red); opacity: 0.92; }
.kanban-col-header { padding: 14px; flex-shrink: 0; }
.kanban-col-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.kanban-col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-col-name { font-family: 'Barlow', sans-serif; font-size: 0.88rem; font-weight: 700; flex: 1; }
.kanban-col-count { font-size: 0.72rem; font-weight: 700; background: var(--card); border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px; }
.kanban-col-meta { display: flex; justify-content: space-between; font-size: 0.76rem; color: var(--text-3); font-weight: 600; }
.kanban-col-uf { color: var(--blue); }
.kanban-col-body { flex: 1; overflow-y: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.kanban-empty { padding: 20px 12px; text-align: center; color: var(--text-3); font-size: 0.82rem; border: 2px dashed var(--border); border-radius: 8px; }
.kanban-empty.drop-target { border-color: var(--blue); background: var(--blue-bg); color: var(--blue); }
.kanban-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: grab; transition: box-shadow 0.15s, transform 0.15s; }
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.kanban-card.dragging { opacity: 0.5; transform: rotate(2deg); }
.kanban-card-top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.kanban-card-uf { font-weight: 700; color: var(--blue); font-size: 0.85rem; }
.kanban-card-name { font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.kanban-card-company { font-size: 0.8rem; color: var(--text-2); margin-bottom: 8px; }
.kanban-card-footer { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-3); }
.kanban-card-age { background: var(--amber-bg); color: var(--amber); padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.kanban-card-age.stale { background: var(--red-bg); color: var(--red); }

/* Leads toolbar */
.leads-toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.leads-toolbar input, .leads-toolbar select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.leads-toolbar input { flex: 1; min-width: 200px; }
.leads-actions { display: flex; gap: 8px; margin-left: auto; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; }
.page-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); cursor: pointer; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Activities */
.activities-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.activity-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-check { width: 20px; height: 20px; margin-top: 2px; cursor: pointer; accent-color: var(--blue); }
.activity-body { flex: 1; }
.activity-body.done { opacity: 0.55; text-decoration: line-through; }
.activity-type { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--text-3); }
.activity-due { font-size: 0.78rem; color: var(--text-3); }
.activity-due.overdue { color: var(--red); font-weight: 600; }
.activities-mini .activity-item { padding: 8px 0; }

/* Drawer */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: flex; justify-content: flex-end; }
.drawer { width: 480px; max-width: 100%; height: 100%; background: var(--card); box-shadow: -8px 0 40px rgba(0,0,0,0.15); display: flex; flex-direction: column; animation: slideIn 0.25s ease; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.drawer-meta { font-size: 0.75rem; color: var(--blue); font-weight: 700; margin-bottom: 4px; }
.drawer-header h2 { font-size: 1.2rem; }
.drawer-close { background: var(--bg-input); border: none; border-radius: 8px; width: 32px; height: 32px; font-size: 1.3rem; cursor: pointer; color: var(--text-2); line-height: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.status-selector { margin-bottom: 20px; }
.status-selector label { font-size: 0.78rem; margin-bottom: 6px; }
.status-select { width: 100%; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.detail-label { display: block; font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.detail-value { font-weight: 600; font-size: 0.9rem; word-break: break-word; }
.detail-section { margin-top: 24px; }
.detail-section h4 { font-size: 0.85rem; margin-bottom: 12px; color: var(--text-2); }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.notes-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; max-height: 200px; overflow-y: auto; }
.note-item { background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 0.88rem; }
.note-meta { font-size: 0.72rem; color: var(--text-3); margin-top: 6px; }
.note-input-row { display: flex; gap: 8px; align-items: flex-end; }
.note-input-row textarea { flex: 1; resize: vertical; min-height: 60px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; padding: 24px; box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 1.1rem; }
.modal-close { background: var(--bg-input); border: none; border-radius: 8px; width: 32px; height: 32px; font-size: 1.3rem; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-msg { margin-top: 12px; font-size: 0.85rem; font-weight: 600; color: var(--green); }
.panel-sub { color: var(--text-3); font-size: 0.85rem; margin: -8px 0 16px; }
.modal-wide { max-width: 560px; }
.modal-confirm { max-width: 420px; }
.btn-danger-solid { background: var(--red); color: #fff; }
.btn-danger-text { color: var(--red); }

/* Leads toolbar extras */
.search-inline { flex: 1; max-width: 320px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; }

/* Alert panel */
.alert-panel { border-color: #fcd34d; background: linear-gradient(135deg, #fff, var(--amber-bg)); margin-bottom: 16px; }
.alert-panel-head { display: flex; align-items: center; gap: 10px; }
.alert-badge { background: var(--amber); color: #fff; font-size: 0.75rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.alert-panel-sub { color: var(--text-2); font-size: 0.85rem; margin: 6px 0 14px; }
.data-table-compact td, .data-table-compact th { padding: 8px 12px; font-size: 0.85rem; }
.stale-days { color: var(--red); font-weight: 700; font-size: 0.85rem; }

/* Reports */
.reports-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.source-bars { display: flex; flex-direction: column; gap: 10px; }
.source-row { display: grid; grid-template-columns: 100px 1fr 36px; gap: 10px; align-items: center; font-size: 0.88rem; }
.source-track { height: 8px; background: var(--bg-input); border-radius: 999px; overflow: hidden; }
.source-fill { height: 100%; background: var(--blue); border-radius: 999px; }

/* Settings */
.settings-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.settings-tab {
  border: 1px solid var(--border); background: var(--card); border-radius: 8px;
  padding: 8px 14px; font-weight: 600; font-size: 0.85rem; cursor: pointer; color: var(--text-2);
}
.settings-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.settings-panels .settings-panel { display: none; }
.settings-panels .settings-panel.active { display: block; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.custom-field-row { display: grid; grid-template-columns: 1fr 1fr 100px 32px; gap: 8px; margin-bottom: 8px; align-items: center; }
.custom-field-row input, .custom-field-row select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.custom-fields-form label { margin-bottom: 10px; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 14px; }
.check-row input { width: auto; margin: 0; }
.wa-template-row, .webhook-row {
  border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px;
  display: grid; gap: 8px;
}
.wa-template-row { grid-template-columns: 1fr auto; }
.wa-template-row textarea { grid-column: 1 / -1; padding: 8px; border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
.webhook-row .wh-events { min-height: 72px; }
.field-readonly { display: block; margin-top: 6px; font-weight: 600; color: var(--blue); }
.pipe-pipeline-select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; font-weight: 600; min-width: 220px; }
.ai-output { background: var(--bg); border-radius: 8px; padding: 12px; margin-top: 10px; font-size: 0.9rem; line-height: 1.5; }
.ai-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.api-key-row, .pipeline-admin-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.api-docs { margin-top: 16px; font-size: 0.85rem; }
.api-docs pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow: auto; font-size: 0.78rem; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: #0E1117; color: #fff; padding: 12px 20px; border-radius: 8px; font-size: 0.88rem; z-index: 400; box-shadow: var(--shadow); animation: fadeUp 0.2s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Status badges in table */
.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.status-pill--nuevo { background: var(--blue-bg); color: var(--blue); }
.status-pill--contactado { background: var(--amber-bg); color: var(--amber); }
.status-pill--propuesta { background: var(--purple-bg); color: var(--purple); }
.status-pill--ganado { background: var(--green-bg); color: var(--green); }
.status-pill--perdido { background: var(--red-bg); color: var(--red); }

/* Responsive */
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .custom-field-row { grid-template-columns: 1fr; }
  .leads-actions { margin-left: 0; width: 100%; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .btn-menu { display: block; }
  .kanban-column { flex: 0 0 260px; min-width: 260px; }
  .drawer { width: 100%; }
  .search-box { display: none; }
  .market-updated,
  .market-live { display: none; }
  .crm-topheader { gap: 10px; padding: 0 14px; }
  .topbar-sub { display: none; }
}

/* Área Web */
.web-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.web-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid-2 label { display: grid; gap: 6px; font-weight: 600; font-size: 0.85rem; }
.form-grid-2 .span-2 { grid-column: 1 / -1; }
.form-grid-2 input,
.form-grid-2 textarea,
.form-grid-2 select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-weight: 500;
}
.web-service-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.web-service-row input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
.modal.modal-lg { width: min(720px, calc(100% - 24px)); }
.td-actions { white-space: nowrap; }
.muted { color: var(--text-2); font-size: 0.9rem; }
@media (max-width: 800px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .web-service-row { grid-template-columns: 1fr; }
  .web-panel-head { flex-direction: column; }
}

/* Área Web wizard + analytics */
.web-wizard { max-width: 820px; margin: 0 auto; }
.web-wizard-card { padding: 24px; }
.web-wizard-progress { display: flex; gap: 8px; margin-bottom: 16px; }
.web-step-dot {
  width: 10px; height: 10px; border-radius: 999px;
  background: var(--border);
}
.web-step-dot.active { background: var(--blue); }
.web-wizard-step { display: none; }
.web-wizard-step.active { display: block; }
.web-wizard-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px;
}
.web-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.web-type-card {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  display: grid;
  gap: 6px;
}
.web-type-card strong { font-size: 0.95rem; }
.web-type-card span { color: var(--text-2); font-size: 0.82rem; }
.web-type-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 25%, transparent);
}
.web-domain-dns {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.88rem;
}
.web-domain-dns table { width: 100%; border-collapse: collapse; }
.web-domain-dns th, .web-domain-dns td {
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 0.82rem;
}
.web-domain-dns code {
  background: #fff; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border);
}
.web-domain-dns ul { margin: 10px 0 0; padding-left: 18px; color: var(--text-2); }
.web-publish-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px 18px;
}
.web-publish-status {
  display: inline-block;
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--amber);
}
.web-publish-status.is-live { color: var(--green); }
.web-publish-copy .muted { margin: 4px 0 0; }
.web-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  color: var(--text);
}
.web-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.web-switch-ui {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #CBD5E1;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.web-switch-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s ease;
}
.web-switch input:checked + .web-switch-ui { background: var(--green); }
.web-switch input:checked + .web-switch-ui::after { transform: translateX(20px); }
.web-switch input:focus-visible + .web-switch-ui {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.web-switch-inline { margin: 12px 0 4px; }
.web-switch-label { font-size: 0.9rem; white-space: nowrap; }
@media (max-width: 700px) {
  .web-publish-bar { flex-direction: column; align-items: flex-start; }
}
.web-funnel { display: grid; gap: 10px; }
.web-funnel-row {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
}
.web-funnel-bar {
  height: 10px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
}
.web-funnel-bar i {
  display: block;
  height: 100%;
  background: var(--blue);
  border-radius: 999px;
}
.web-heat-wrap { margin-top: 8px; }
#web-heatmap {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #F8FAFC;
}
.web-heat-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-2);
  margin-top: 6px;
}
.web-rec-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.web-rec {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--card);
}
.web-rec p { margin: 6px 0 0; color: var(--text-2); font-size: 0.9rem; }
.web-rec-high { border-left: 3px solid #DC2626; }
.web-rec-medium { border-left: 3px solid #D97706; }
.web-rec-low { border-left: 3px solid #059669; }
