/* Onward CRM · colores y tipografía de onwardanalytica.com, en tema claro */
:root {
  --navy: #060c14;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --sunken: #edf1f6;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0b1724;
  --muted: #5b6b82;
  --green: #00c896;
  --green-ink: #007a5c;
  --green-soft: #e6faf4;
  --blue: #1a9fff;
  --blue-ink: #0b6fd1;
  --blue-soft: #e8f4ff;
  --amber: #f59e0b;
  --amber-ink: #92400e;
  --amber-soft: #fff7e6;
  --red: #e5484d;
  --red-ink: #b42318;
  --red-soft: #fff0f0;
  --st-nuevo: #1a9fff;
  --st-contactado: #06b6d4;
  --st-seguimiento: #f59e0b;
  --st-cotizado: #4f6bed;
  --st-ganado: #00c896;
  --st-perdido: #94a3b8;
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(6, 12, 20, .06);
  --shadow: 0 1px 2px rgba(6, 12, 20, .05), 0 4px 12px rgba(6, 12, 20, .06);
  --shadow-lg: 0 12px 32px rgba(6, 12, 20, .14);
  --ring: 0 0 0 3px rgba(26, 159, 255, .35);
  --heading: #060c14;
  --topbar: rgba(255, 255, 255, .92);
  --inverse-bg: #060c14;
  --inverse-text: #ffffff;
  --red-border: #fbd0d0;
  --green-border: #b5ecd9;
  --logo-filter: none;
  color-scheme: light;
}

/* Modo oscuro: el fondo de onwardanalytica.com. data-theme lo pone el script del <head>. */
:root[data-theme="dark"] {
  --bg: #060c14;
  --surface: #0f1926;
  --surface-2: #132031;
  --sunken: #0a131e;
  --border: #1d2b3d;
  --border-strong: #2b3c52;
  --text: #e6ecf3;
  --muted: #8b9cb3;
  --heading: #f4f7fb;
  --green-ink: #3fe0b5;
  --green-soft: rgba(0, 200, 150, .14);
  --green-border: rgba(0, 200, 150, .35);
  --blue-ink: #62bbff;
  --blue-soft: rgba(26, 159, 255, .15);
  --amber-ink: #fbc75a;
  --amber-soft: rgba(245, 158, 11, .14);
  --red-ink: #ff8f92;
  --red-soft: rgba(229, 72, 77, .14);
  --red-border: rgba(229, 72, 77, .4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  --topbar: rgba(6, 12, 20, .85);
  --inverse-bg: #e6ecf3;
  --inverse-text: #060c14;
  --logo-filter: brightness(0) invert(1); /* el logo tiene letras marino: en oscuro va todo en blanco */
  color-scheme: dark;
}
img.logo { filter: var(--logo-filter); }
.theme-toggle .icon-sun, :root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 14px/1.5 var(--font-body); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -.01em; margin: 0; color: var(--heading); }
h1 { font-size: 26px; font-weight: 700; line-height: 1.2; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: var(--blue-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
::selection { background: var(--green-soft); color: var(--heading); }
input, select, textarea { accent-color: var(--green); caret-color: var(--green-ink); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
.icon { width: 16px; height: 16px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-danger { color: var(--red-ink); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { overflow-wrap: anywhere; }

/* ── Barra superior ───────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--topbar); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1680px; margin: 0 auto; height: 60px; padding: 0 24px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 44px; width: auto; display: block; }
.brand:hover { text-decoration: none; }
.brand-tag { font: 600 11px/1 var(--font-head); letter-spacing: .08em; color: var(--green-ink); background: var(--green-soft); padding: 4px 7px; border-radius: 6px; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.topnav a:hover { background: var(--sunken); color: var(--text); text-decoration: none; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-name { font-weight: 500; }

/* ── Estructura ───────────────────────────────── */
.page { max-width: 1680px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .muted { margin-top: 4px; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.crumb:hover { color: var(--text); text-decoration: none; }
.section-title { margin: 32px 0 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.panel > h2 { margin-bottom: 16px; }
.panel-flush { padding: 0; overflow: hidden; }

/* ── Botones y formularios ────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font: 600 14px/1 var(--font-head); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--green); color: var(--navy); }
.btn-primary:hover { background: #00b386; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--sunken); color: var(--text); }
.btn-ghost-danger { background: transparent; color: var(--red-ink); padding: 0 12px; }
.btn-ghost-danger:hover { background: var(--red-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: transparent; cursor: pointer; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); color: var(--muted); }
.icon-btn:hover { background: var(--sunken); color: var(--text); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
input, select, textarea { width: 100%; padding: 9px 12px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 84px; }

.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; }
.alert .icon { margin-top: 2px; }
.alert-error { background: var(--red-soft); color: var(--red-ink); }
.alert-warn { background: var(--amber-soft); color: var(--amber-ink); }
.alert-info { background: var(--green-soft); color: var(--green-ink); }

/* ── Piezas comunes ───────────────────────────── */
.avatar { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--blue-soft), var(--green-soft)); color: var(--blue-ink); font: 600 13px/1 var(--font-head); }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; background: var(--sunken); color: var(--text); font-size: 12px; font-weight: 500; }
.chip-sm { padding: 1px 7px; font-size: 11px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot-nuevo { background: var(--st-nuevo); }
.dot-contactado { background: var(--st-contactado); }
.dot-seguimiento { background: var(--st-seguimiento); }
.dot-cotizado { background: var(--st-cotizado); }
.dot-ganado { background: var(--st-ganado); }
.dot-perdido { background: var(--st-perdido); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 600; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill-ok { background: var(--green-soft); color: var(--green-ink); }
.pill-warn { background: var(--amber-soft); color: var(--amber-ink); }
.pill-danger { background: var(--red-soft); color: var(--red-ink); }
.pill-muted { background: var(--sunken); color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 24px 12px; }

.stats { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-sm); }
.stat-value { font: 700 26px/1.1 var(--font-head); color: var(--heading); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-danger { border-color: var(--red-border); background: var(--red-soft); }
.stat-danger .stat-value { color: var(--red-ink); }

/* ── Login ────────────────────────────────────── */
.login-page { background: radial-gradient(1200px 600px at 15% -10%, rgba(0, 200, 150, .14), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(26, 159, 255, .14), transparent 60%), var(--bg); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 16px; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: var(--shadow-lg); }
.login-logo { display: block; height: 76px; width: auto; margin-bottom: 20px; }
.login-card h1 { font-size: 22px; }
.login-card > .muted { margin: 4px 0 20px; }
.login-card .btn { margin-top: 6px; height: 44px; }
.login-foot { font-size: 12px; color: var(--muted); }

/* ── Tablero ──────────────────────────────────── */
.search { position: relative; width: min(360px, 100%); }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px; height: 40px; }
.board { scrollbar-color: var(--border-strong) transparent; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(272px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x proximity; }
.column { background: var(--sunken); border-radius: var(--radius); padding: 10px; min-height: 62vh; display: flex; flex-direction: column; scroll-snap-align: start; transition: background .15s, box-shadow .15s; }
.column.is-over { background: var(--blue-soft); box-shadow: inset 0 0 0 2px var(--blue); }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; }
.column-head h2 { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.count { min-width: 24px; padding: 1px 8px; border-radius: 99px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }
.cards { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.column-empty { display: none; margin: 0; padding: 20px 8px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; text-align: center; }
.cards:not(:has(.card:not([hidden]))) .column-empty { display: block; }

.card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; box-shadow: var(--shadow-sm); cursor: grab; transition: box-shadow .15s, border-color .15s, transform .15s; }
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card:active { cursor: grabbing; }
.card.is-dragging { opacity: .5; transform: rotate(1.5deg); }
.card.is-late { border-color: var(--red-border); background: linear-gradient(var(--red-soft), var(--red-soft)), var(--surface); }
.card:focus-within { box-shadow: var(--ring); }
.card-main { display: flex; gap: 10px; align-items: flex-start; }
.card-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-link { font: 600 14px/1.3 var(--font-head); color: var(--heading); overflow-wrap: anywhere; }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: 10px; } /* toda la tarjeta es clickeable */
.card-link:hover { text-decoration: none; }
.card-link:focus-visible { box-shadow: none; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.age { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.age .icon { width: 14px; height: 14px; }
.age-late { color: var(--red-ink); font-weight: 600; }
.age:not(.age-late) :is(.icon-late, .age-flag), .age-late .icon-age { display: none; }
.card-actions { position: relative; z-index: 1; display: flex; gap: 2px; }
.card-actions .icon-btn { width: 30px; height: 30px; }
.card-actions .icon-btn:hover { background: var(--green-soft); color: var(--green-ink); }
.no-results { text-align: center; color: var(--muted); padding: 16px; }

/* ── Detalle del lead ─────────────────────────── */
.lead-hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.lead-id { display: flex; gap: 16px; align-items: center; min-width: 0; }
.lead-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; }
.lead-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stepper { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.step { display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font: 600 13px/1 var(--font-head); cursor: pointer; white-space: nowrap; }
.step:hover { background: var(--sunken); color: var(--text); }
.step[aria-current="step"] { background: var(--inverse-bg); color: var(--inverse-text); }
.lead-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
.details { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 20px; }
.details dt { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.details dd { margin: 0; font-weight: 500; }
.detail-long { grid-column: 1 / -1; }
.detail-long dd { font-weight: 400; font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.danger-zone { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.note-form { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; margin-bottom: 20px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { position: relative; padding: 0 0 18px 24px; }
.tl-item::before { content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.tl-status::before { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.tl-item:not(:last-child)::after { content: ""; position: absolute; left: 8.5px; top: 20px; bottom: 2px; width: 1px; background: var(--border); }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; margin-bottom: 4px; }
.tl-head time { margin-left: auto; font-size: 12px; }
.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }

/* ── Admin ────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.client-link { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; color: var(--heading); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.forms .panel h3 { margin-bottom: 4px; }
.forms .panel > .muted { margin-bottom: 16px; }
.key-box { margin-bottom: 20px; padding: 16px; border-radius: var(--radius); background: var(--green-soft); border: 1px solid var(--green-border); }
.key-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.key-row code { flex: 1; min-width: 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; overflow-wrap: anywhere; }

/* ── Aviso flotante ───────────────────────────── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); padding: 10px 16px; border-radius: var(--radius-sm); background: var(--inverse-bg); color: var(--inverse-text); font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--red-ink); }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 1100px) {
  .lead-grid { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .page { padding: 16px; }
  .topbar-inner { padding: 0 16px; gap: 12px; }
  .user-name, .topnav span { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-auto-columns: 84%; }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-actions, .lead-actions .btn { width: 100%; }
  .lead-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  h1 { font-size: 22px; }
}
/* En pantallas táctiles, llamar/WhatsApp desde la tarjeta necesita blanco de dedo */
@media (pointer: coarse) {
  .card-actions .icon-btn { width: 40px; height: 40px; }
  .card-foot { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
