/* Portal Intel — diseño profesional, limpio y sobrio */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16202b;
  --ink-soft: #5b6b7b;
  --line: #e3e8ee;
  --accent: #0f4c81;
  --accent-ink: #ffffff;
  --ok: #1a7f4f;
  --warn: #b35c00;
  --danger: #b00020;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(22, 32, 43, .07), 0 8px 24px rgba(22, 32, 43, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }

/* Topbar */
.topbar { background: #102a43; color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 28px; height: 56px;
}
.brand { color: #fff; font-weight: 700; letter-spacing: .3px; text-decoration: none; font-size: 16px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
  color: #c4d3e3; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 14px;
}
.nav-link:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.user-zone { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; flex-direction: column; line-height: 1.2; font-size: 13px; text-align: right; }
.user-chip small { color: #9fb3c8; font-size: 11px; }
.ghost-btn {
  background: transparent; border: 1px solid rgba(255, 255, 255, .25); color: #d9e2ec;
  padding: 5px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; text-decoration: none;
}
.ghost-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.page .ghost-btn { border-color: var(--line); color: var(--ink-soft); }
.page .ghost-btn:hover { background: #eef2f6; color: var(--ink); }
.inline-form { display: inline; }

/* Layout */
.page { flex: 1; max-width: 1200px; margin: 0 auto; padding: 28px 20px 60px; width: 100%; }
.footer { text-align: center; color: var(--ink-soft); font-size: 12px; padding: 18px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 4px 0 2px; font-size: 26px; }
.page-head .muted { margin: 0; }
.head-meta { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.back-link { font-size: 13px; text-decoration: none; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }

/* Cards / stats */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 17px; }
.card h3 { margin: 18px 0 6px; font-size: 14px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.stat-num { font-size: 26px; font-weight: 700; }
.stat-label { font-size: 12.5px; color: var(--ink-soft); }

/* Filters */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.filter-bar input[type="search"] { flex: 2; min-width: 220px; }
.filter-bar select { flex: 1; min-width: 150px; }

/* Forms */
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 76, 129, .35); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 600; color: #334e68; }
label input, label select, label textarea { font-weight: 400; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline-stack { display: flex; gap: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.primary-btn {
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 8px;
  padding: 10px 18px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.primary-btn:hover { background: #0c3d68; }
.btn-secondary {
  display: inline-block; padding: 6px 12px; border-radius: 6px; font-size: 13px;
  font-weight: 500; border: 1px solid var(--line); background: #fff; color: var(--text);
  text-decoration: none; margin-left: 6px;
}
.btn-secondary:hover { background: #f4f8fc; border-color: var(--accent); color: var(--accent); }
.ficha-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 8px; }
.ficha-actions .btn-secondary { margin-left: 0; }

/* Tables */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-x: auto;
}
table { border-collapse: collapse; width: 100%; }
.leads-table th, .leads-table td, .mini-table th, .mini-table td {
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.leads-table thead th, .mini-table thead th {
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft);
  background: #fbfcfd; position: sticky; top: 0;
}
.lead-row:hover { background: #f4f8fc; }
.lead-link { font-weight: 600; text-decoration: none; }
.empty { text-align: center; color: var(--ink-soft); padding: 28px !important; }
.row-disabled { opacity: .45; }
.actions { white-space: nowrap; }
.actions form { margin-left: 4px; }
.mini-table { margin-bottom: 8px; }

/* Badges / chips / states */
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-alta { background: #e8f5ee; color: var(--ok); }
.badge-media { background: #fff4e5; color: var(--warn); }
.badge-baja { background: #eef2f6; color: var(--ink-soft); }
.chip {
  background: #eef2f6; color: #334e68; padding: 3px 10px; border-radius: 999px; font-size: 12.5px;
}
.chip-sm { font-size: 11px; padding: 2px 8px; }
.state { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 6px; white-space: nowrap; }
.state-nuevo { background: #e3f0fb; color: var(--accent); }
.state-priorizado { background: #fff4e5; color: var(--warn); }
.state-contactado { background: #ede7f6; color: #5e35b1; }
.state-investigar_a_fondo { background: #fce4ec; color: #ad1457; }
.state-ganado { background: #e8f5ee; color: var(--ok); }
.state-descartado { background: #f1f1f1; color: #757575; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; }
.dot.ok { background: var(--ok); }

/* Detail */
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.side-col { display: flex; flex-direction: column; }
.contact-name { font-weight: 700; font-size: 16px; margin: 0; }
.opening {
  margin: 8px 0 0; padding: 14px 16px; background: #f4f8fc; border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; font-style: italic;
}
.internal-card { border-left: 4px solid var(--warn); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; }
.signal-list { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; }
.signal-list li { margin-bottom: 4px; }
.internal-col { color: var(--warn); font-variant-numeric: tabular-nums; }

/* Admin */
.admin-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 18px; align-items: start; }
.temp-pass { background: #102a43; color: #9ae6b4; padding: 3px 9px; border-radius: 6px; font-size: 14px; }

/* Automatización */
.switch-row { flex-direction: row !important; align-items: center; gap: 10px !important; font-weight: 500; }
.switch-row input[type="checkbox"] { width: auto; accent-color: var(--accent); transform: scale(1.25); }
.result-box {
  background: #f4f8fc; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; margin: 4px 0;
}

/* Auth */
.auth-wrap { display: flex; justify-content: center; padding: 9vh 16px 0; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 36px 34px; width: 100%; max-width: 410px; text-align: center;
}
.auth-card h1 { margin: 4px 0 4px; font-size: 22px; }
.auth-card form { text-align: left; margin-top: 22px; }
.auth-logo { font-size: 34px; color: var(--accent); }

/* Alerts */
.alert {
  background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0;
  border-radius: 8px; padding: 10px 14px; font-size: 13.5px; margin: 14px 0; text-align: left;
}
.alert-ok { background: #e8f5ee; color: var(--ok); border-color: #bfe3cf; }

@media (max-width: 900px) {
  .detail-grid, .admin-grid, .form-row { grid-template-columns: 1fr; }
  .topbar-inner { gap: 12px; }
  .user-chip small { display: none; }
}
