@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root{
  --bg: #12141a;
  --surface: #191c24;
  --surface-2: #1f2330;
  --border: #2a2e3a;
  --text: #e8e9ed;
  --text-dim: #8b90a0;
  --text-faint: #565b6b;
  --accent: #c9a227;
  --accent-dim: #8a7220;
  --urgente: #e2574c;
  --vencido: #b23a2e;
  --ganado: #4fae7c;
  --perdido: #6b7280;
  --ghosting: #9b6ef3;
  --seguimiento: #4a90d9;
  --radius: 10px;
  --radius-sm: 6px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:'Inter',system-ui,sans-serif;
  font-size:14px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
.mono{ font-family:'IBM Plex Mono',monospace; }

button{ font-family:inherit; }
input,select,textarea{ font-family:inherit; font-size:inherit; }

/* ---------- Password gate ---------- */
#gate{
  position:fixed; inset:0; display:flex; align-items:center; justify-content:center;
  background:radial-gradient(circle at 30% 20%, #1a1e29 0%, #0e1015 70%);
  z-index:100;
}
.gate-card{
  width:340px; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:32px;
}
.gate-card h1{ font-size:17px; margin:0 0 4px; }
.gate-card p{ color:var(--text-dim); margin:0 0 20px; font-size:13px; }
.gate-card label{ display:block; font-size:12px; color:var(--text-dim); margin:14px 0 6px; }
.gate-card input{
  width:100%; background:var(--surface-2); border:1px solid var(--border); color:var(--text);
  padding:10px 12px; border-radius:var(--radius-sm); outline:none;
}
.gate-card input:focus{ border-color:var(--accent); }
.gate-card button{
  width:100%; margin-top:20px; background:var(--accent); color:#1a1400; border:none;
  padding:11px; border-radius:var(--radius-sm); font-weight:600; cursor:pointer;
}
.gate-card button:hover{ background:#ddb436; }
.gate-error{ color:var(--urgente); font-size:12.5px; margin-top:12px; min-height:16px; }
.gate-adv{ margin-top:18px; border-top:1px solid var(--border); padding-top:14px; }
.gate-adv summary{ color:var(--text-faint); font-size:12px; cursor:pointer; }

/* ---------- App shell ---------- */
#app{ display:none; height:100vh; }
#app.ready{ display:flex; }

.sidebar{
  width:220px; flex-shrink:0; background:var(--surface); border-right:1px solid var(--border);
  display:flex; flex-direction:column; padding:20px 0;
}
.brand{ padding:0 20px 18px; border-bottom:1px solid var(--border); margin-bottom:10px; }
.brand strong{ display:block; font-size:14.5px; }
.brand span{ color:var(--text-dim); font-size:12px; }

.nav-item{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:10px 20px; color:var(--text-dim); cursor:pointer; font-size:13.5px;
  border-left:3px solid transparent;
}
.nav-item:hover{ color:var(--text); background:rgba(255,255,255,.02); }
.nav-item.active{ color:var(--text); border-left-color:var(--accent); background:rgba(201,162,39,.06); }
.nav-badge{
  background:var(--surface-2); color:var(--text-dim); font-size:11px; padding:1px 7px; border-radius:20px;
}
.nav-badge.alert{ background:var(--urgente); color:#fff; }

.sidebar-footer{ margin-top:auto; padding:14px 20px 0; border-top:1px solid var(--border); }
.btn-logout{ background:none; border:none; color:var(--text-faint); font-size:12px; cursor:pointer; padding:0; }
.btn-logout:hover{ color:var(--text-dim); }
.btn-refresh{ background:none; border:1px solid var(--border); color:var(--text-dim); font-size:12px; cursor:pointer; padding:6px 10px; border-radius:var(--radius-sm); margin-bottom:10px; width:100%; }
.btn-refresh:hover{ border-color:var(--accent); color:var(--accent); }

.main{ flex:1; overflow-y:auto; padding:26px 32px 60px; }
.view-header{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:20px; }
.view-header h2{ margin:0; font-size:19px; font-weight:600; }
.view-sub{ color:var(--text-dim); font-size:13px; margin-top:2px; }

.filters{ display:flex; gap:8px; margin-bottom:18px; flex-wrap:wrap; }
.chip{
  background:var(--surface); border:1px solid var(--border); color:var(--text-dim);
  padding:6px 12px; border-radius:20px; font-size:12.5px; cursor:pointer;
}
.chip.active{ background:var(--surface-2); color:var(--text); border-color:var(--accent-dim); }

/* ---------- Lead cards ---------- */
.lead{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:16px 18px; margin-bottom:10px;
}
.lead-top{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.lead-name{ font-weight:600; font-size:14.5px; }
.lead-meta{ color:var(--text-dim); font-size:12.5px; margin-top:2px; }
.lead-meta .mono{ color:var(--text-faint); }

.badge{
  font-size:11px; padding:3px 9px; border-radius:20px; font-weight:600; white-space:nowrap;
}
.badge-urgente{ background:rgba(226,87,76,.15); color:var(--urgente); }
.badge-vencido{ background:rgba(178,58,46,.22); color:#ff8a7d; }
.badge-ok{ background:rgba(255,255,255,.04); color:var(--text-faint); }

.lead-actions{ display:flex; gap:8px; margin-top:12px; flex-wrap:wrap; align-items:center; }
.check-field{ display:flex; align-items:center; gap:6px; background:var(--surface-2); border:1px solid var(--border); padding:6px 10px; border-radius:var(--radius-sm); }
.check-field input[type=checkbox]{ accent-color:var(--accent); width:15px; height:15px; }
.check-field .ts{ color:var(--text-faint); font-size:11.5px; }
.check-field .ts input{ background:none; border:none; color:var(--text-dim); font-size:11.5px; padding:0; }

.btn{ background:var(--surface-2); border:1px solid var(--border); color:var(--text); padding:6px 12px; border-radius:var(--radius-sm); font-size:12.5px; cursor:pointer; }
.btn:hover{ border-color:var(--accent-dim); }
.btn-primary{ background:var(--accent); border-color:var(--accent); color:#1a1400; font-weight:600; }
.btn-primary:hover{ background:#ddb436; }
.btn-danger{ color:var(--urgente); }
.btn-danger:hover{ border-color:var(--urgente); }

.lead-detail{ margin-top:12px; border-top:1px solid var(--border); padding-top:12px; display:grid; grid-template-columns:1fr 1fr; gap:10px 20px; }
.lead-detail .q{ font-size:12px; color:var(--text-faint); margin-bottom:2px; }
.lead-detail .a{ font-size:13px; color:var(--text-dim); }
.lead-comment textarea{
  width:100%; min-height:56px; background:var(--surface-2); border:1px solid var(--border); color:var(--text);
  border-radius:var(--radius-sm); padding:8px 10px; resize:vertical; margin-top:6px;
}
.toggle-detail{ color:var(--text-faint); font-size:12px; cursor:pointer; margin-top:10px; display:inline-block; }
.toggle-detail:hover{ color:var(--accent); }

.select-mini{ background:var(--surface-2); border:1px solid var(--border); color:var(--text); padding:6px 10px; border-radius:var(--radius-sm); font-size:12.5px; }

.empty{ color:var(--text-faint); font-size:13px; padding:30px 0; text-align:center; }

/* ---------- Kanban ---------- */
.kanban{ display:flex; gap:14px; overflow-x:auto; padding-bottom:20px; align-items:flex-start; }
.kcol{ flex:0 0 260px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:12px; min-height:120px; }
.kcol-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; padding-bottom:8px; border-bottom:2px solid var(--kcolor,var(--border)); }
.kcol-head strong{ font-size:13px; }
.kcol-head span{ color:var(--text-dim); font-size:11.5px; }
.kcard{
  background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:10px 11px; margin-bottom:8px; cursor:grab; font-size:12.5px;
}
.kcard:active{ cursor:grabbing; }
.kcard.dragging{ opacity:.4; }
.kcard .kname{ font-weight:600; font-size:13px; }
.kcard .kmeta{ color:var(--text-faint); font-size:11px; margin-top:3px; }
.kcol.dragover{ border-color:var(--accent); }

/* ---------- Duplicados ---------- */
.dup-group{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px 16px; margin-bottom:14px; }
.dup-tag{ display:inline-block; font-size:11px; color:var(--text-faint); margin-bottom:8px; }
.dup-row{ display:flex; align-items:center; justify-content:space-between; padding:8px 0; border-top:1px solid var(--border); }
.dup-row:first-of-type{ border-top:none; }

@media (max-width:760px){
  .sidebar{ width:64px; }
  .brand span, .nav-item span.label{ display:none; }
  .main{ padding:18px; }
  .lead-detail{ grid-template-columns:1fr; }
}
