/* Learn CRM — interfaz v3
   Idea: el color de la unidad seleccionada tiñe la herramienta (acento, botón principal, foco).
   «Todas las unidades» usa el azul lapislázuli de Learn & Asociados. */
:root {
  --accent: #3550dc;
  --accent-ink: #ffffff;
  --bg: #eef1f0;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --sunken: #e6eae8;
  --line: #dce1de;
  --line-2: #c9d0cc;
  --text: #18202f;
  --muted: #5a6373;
  --faint: #8a92a0;
  --rail: #18202f;
  --rail-2: #222c3f;
  --rail-text: #c9d0dc;
  --rail-faint: #7d8799;
  --ok: #0d7f57;
  --warn: #a8640c;
  --bad: #c8333b;
  --wa: #128c4a;
  --shadow-1: 0 1px 0 rgba(24, 32, 47, .04), 0 1px 3px rgba(24, 32, 47, .07);
  --shadow-2: 0 2px 4px rgba(24, 32, 47, .05), 0 10px 24px -6px rgba(24, 32, 47, .14);
  --shadow-3: 0 30px 70px -10px rgba(14, 20, 32, .35);
  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --accent-strong: color-mix(in oklab, var(--accent) 78%, var(--text));
  --accent-soft: color-mix(in oklab, var(--accent) 11%, var(--surface));
  --accent-line: color-mix(in oklab, var(--accent) 35%, var(--surface));
  --ok-soft: color-mix(in oklab, var(--ok) 12%, var(--surface));
  --warn-soft: color-mix(in oklab, var(--warn) 13%, var(--surface));
  --bad-soft: color-mix(in oklab, var(--bad) 11%, var(--surface));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141d; --surface: #161d29; --surface-2: #1b2331; --sunken: #121822; --line: #263043; --line-2: #34405a;
    --text: #e7ebf2; --muted: #a3acbd; --faint: #78839a; --rail: #0b1018; --rail-2: #172031; --rail-text: #b9c2d2; --rail-faint: #6d788e;
    --ok: #45c48a; --warn: #e7a94b; --bad: #ff7a83; --wa: #2fbf6b;
    --shadow-1: 0 1px 0 rgba(0,0,0,.25); --shadow-2: 0 10px 24px -6px rgba(0,0,0,.55); --shadow-3: 0 30px 70px -10px rgba(0,0,0,.7);
    --accent-strong: color-mix(in oklab, var(--accent) 70%, white);
    --accent-soft: color-mix(in oklab, var(--accent) 18%, var(--surface));
  }
}
:root[data-theme="dark"] {
  --bg: #0f141d; --surface: #161d29; --surface-2: #1b2331; --sunken: #121822; --line: #263043; --line-2: #34405a;
  --text: #e7ebf2; --muted: #a3acbd; --faint: #78839a; --rail: #0b1018; --rail-2: #172031; --rail-text: #b9c2d2; --rail-faint: #6d788e;
  --ok: #45c48a; --warn: #e7a94b; --bad: #ff7a83; --wa: #2fbf6b;
  --shadow-1: 0 1px 0 rgba(0,0,0,.25); --shadow-2: 0 10px 24px -6px rgba(0,0,0,.55); --shadow-3: 0 30px 70px -10px rgba(0,0,0,.7);
  --accent-strong: color-mix(in oklab, var(--accent) 70%, white);
  --accent-soft: color-mix(in oklab, var(--accent) 18%, var(--surface));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-strong); text-underline-offset: 2px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -.025em; }
h2 { font-size: 16px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--faint); background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 88%, black); border-color: transparent; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: color-mix(in oklab, var(--wa) 88%, black); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--sunken); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { min-height: 44px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: inherit; cursor: pointer; opacity: .8; }
.icon-btn:hover { background: var(--sunken); opacity: 1; }

.field { display: grid; gap: 6px; margin: 0 0 14px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 38px; padding: 8px 11px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 9px; transition: border-color .12s, box-shadow .12s; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: 17px; height: 17px; min-height: 0; padding: 0; accent-color: var(--accent); }
input[type="color"] { padding: 3px; width: 46px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.error { color: var(--bad); background: var(--bad-soft); padding: 9px 12px; border-radius: 9px; margin: 0 0 14px; font-weight: 500; }
.hint { font-size: 12.5px; color: var(--muted); margin: -6px 0 14px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border-radius: 11px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg-lg button { font-size: 15px; padding: 7px 16px; }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.pill.unit::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--u, var(--accent)); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-size: 10.5px; font-weight: 800; letter-spacing: .02em; flex: none; }
.avatar.none { background: transparent; border: 1.5px dashed var(--line-2); color: var(--faint); }

/* ---------- Acceso ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 44%) 1fr; }
.auth-side { background: var(--rail); color: #fff; padding: 44px 48px; display: flex; flex-direction: column; gap: 28px; position: relative; overflow: hidden; }
.auth-claim { font-size: clamp(28px, 3.4vw, 44px); line-height: 1.08; font-weight: 800; letter-spacing: -.03em; max-width: 13ch; margin-top: auto; }
.auth-units { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 15px; color: var(--rail-text); }
.auth-units li { display: flex; align-items: center; gap: 12px; }
.auth-units li::before { content: ""; width: 28px; height: 6px; border-radius: 3px; background: var(--u); }
.u-nit { --u: #3b7bff; } .u-mydemy { --u: #9b5de5; } .u-elevate { --u: #06d6a0; } .u-docentia { --u: #f4a261; }
.auth-foot { color: var(--rail-faint); font-size: 13px; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card > .muted { margin-bottom: 26px; }
.brand.auth-mobile-brand { display: none; margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; font-size: 16px; }
.brand-lg { font-size: 19px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 16px; transition: background .25s; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--rail) 236px, var(--bg) 236px); }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 18px 12px 14px; background: var(--rail); color: var(--rail-text); }
.rail .brand { color: #fff; padding: 2px 8px; }
.nav { display: grid; gap: 2px; }
.nav-btn { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--rail-text); font-weight: 600; font-size: 14.5px; cursor: pointer; text-align: left; }
.nav-btn:hover { background: var(--rail-2); color: #fff; }
.nav-btn.active { background: var(--rail-2); color: #fff; }
.nav-btn.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.badge { margin-left: auto; min-width: 21px; height: 21px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 11px; background: var(--bad); color: #fff; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rail-units { display: grid; gap: 6px; min-height: 0; overflow-y: auto; }
.rail-label { font-size: 12px; color: var(--rail-faint); padding: 0 10px; font-weight: 600; }
#rail-units { display: grid; gap: 1px; }
.unit-btn { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--rail-text); cursor: pointer; text-align: left; font-size: 13.5px; }
.unit-btn::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--u); flex: none; box-shadow: 0 0 0 3px transparent; transition: box-shadow .15s; }
.unit-btn:hover { background: var(--rail-2); color: #fff; }
.unit-btn[aria-checked="true"] { color: #fff; background: var(--rail-2); font-weight: 600; }
.unit-btn[aria-checked="true"]::before { box-shadow: 0 0 0 3px color-mix(in oklab, var(--u) 35%, transparent); }
.rail-foot { margin-top: auto; display: flex; align-items: center; gap: 9px; padding: 10px 6px 0; border-top: 1px solid var(--rail-2); }
.rail-foot .avatar { background: var(--rail-2); color: #fff; }
.me-text { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.me-text b { color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--rail-faint); font-size: 12px; }
.rail-foot .icon-btn { color: var(--rail-text); width: 30px; height: 30px; }
.rail-foot .icon-btn:hover { background: var(--rail-2); }
.mhead { display: none; }
.main { min-width: 0; padding: 26px 30px 40px; outline: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .lede { color: var(--muted); margin-top: 6px; font-size: 14.5px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar select, .toolbar input { width: auto; min-height: 36px; }
.toolbar select { min-width: 170px; }
.search { position: relative; flex: 1 1 240px; max-width: 340px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; }
.search input { padding-left: 34px; width: 100%; }
.spacer { flex: 1; }
.m-only { display: none; }

/* ---------- Embudo (franja superior del tablero) ---------- */
.funnel { display: flex; gap: 4px; margin: 4px 0 16px; }
.funnel button { flex: var(--grow, 1) 1 0; min-width: 92px; border: 0; padding: 0; background: none; cursor: pointer; text-align: left; color: var(--text); }
.funnel .bar { display: block; height: 8px; border-radius: 4px; background: color-mix(in oklab, var(--accent) var(--tone, 60%), var(--surface)); }
.funnel button.won .bar { background: var(--ok); }
.funnel button.lost .bar { background: var(--line-2); }
.funnel button.empty .bar { background: var(--sunken); }
.funnel .lbl { display: flex; align-items: baseline; gap: 6px; margin-top: 7px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.funnel .lbl b { font-size: 17px; color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }
.funnel button:hover .lbl { color: var(--text); }

/* ---------- Tablero ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding: 2px 2px 16px; align-items: flex-start; scroll-snap-type: x proximity; scroll-padding: 2px; }
.col { flex: 0 0 286px; display: flex; flex-direction: column; max-height: calc(100vh - 250px); background: var(--sunken); border-radius: 14px; scroll-snap-align: start; transition: background .12s, box-shadow .12s; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.col-head h3 { font-size: 13.5px; }
.col-head .count { margin-left: auto; font-weight: 700; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-head .sla { font-size: 12px; color: var(--faint); }
.col.won .col-head h3 { color: var(--ok); }
.col.lost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.col-body { padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 90px; }
.col.drop { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.col-empty { color: var(--faint); font-size: 12.5px; text-align: center; padding: 22px 8px; border: 1.5px dashed var(--line-2); border-radius: 10px; }

.card { position: relative; display: grid; gap: 4px; padding: 11px 12px 10px 15px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-1); cursor: grab; overflow: hidden; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--u, var(--accent)); }
.card:hover { box-shadow: var(--shadow-2); }
.card.dragging { opacity: .4; }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card .name { font-weight: 700; font-size: 14px; line-height: 1.3; flex: 1; overflow-wrap: anywhere; }
.card .sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .next { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.card .next::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.card .next.bad { color: var(--bad); } .card .next.warn { color: var(--warn); } .card .next.ok { color: var(--ok); } .card .next.none { color: var(--faint); font-weight: 500; }
.card .foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 11.5px; color: var(--faint); }
.card .foot .pill { height: 19px; font-size: 11px; }
.card .fresh { color: var(--accent-strong); font-weight: 700; }

/* ---------- Paneles y listas ---------- */
.panel { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-1); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; }
.panel-head .muted { font-size: 12.5px; }
.panel-body { padding: 4px 18px 18px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--line); }
.rows .grow { flex: 1; min-width: 0; }
.rows .title { font-weight: 600; }
.rows .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty { padding: 30px 18px; text-align: center; color: var(--muted); }
.link { background: none; border: 0; padding: 0; color: var(--text); font-weight: 700; cursor: pointer; text-align: left; font-size: 14.5px; }
.link:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

/* Agenda de hoy */
.agenda-sum { display: flex; gap: 22px; flex-wrap: wrap; margin: 2px 0 22px; }
.agenda-sum div { display: grid; }
.agenda-sum b { font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.agenda-sum span { color: var(--muted); font-size: 13px; }
.agenda-sum .bad b { color: var(--bad); } .agenda-sum .warn b { color: var(--warn); }
.group { margin-bottom: 22px; }
.group h2 { display: flex; align-items: center; gap: 8px; margin: 0 2px 10px; }
.group h2 .pill { font-size: 12px; }
.when { width: 70px; flex: none; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; line-height: 1.2; }
.when small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.when.bad { color: var(--bad); }
.rows .meta { color: var(--muted); font-size: 13px; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-1); margin-bottom: 16px; }
.kpi { padding: 18px 20px; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 32px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 4px 0 2px; line-height: 1.1; }
.kpi .note { color: var(--faint); font-size: 12px; }
.kpi.alert .value { color: var(--bad); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dash-grid .panel + .panel { margin-top: 0; }
.dash-grid .wide { grid-column: 1 / -1; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(100px, 36%) 1fr 72px; gap: 12px; align-items: center; font-size: 13.5px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--sunken); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; width: var(--w, 0%); background: var(--bar, var(--accent)); border-radius: 4px; }
.bar-row .n { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.bar-row .n small { color: var(--faint); font-weight: 500; margin-left: 4px; }
.spark { width: 100%; height: 150px; display: block; }
.spark .area { fill: var(--accent-soft); stroke: none; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark .axis { stroke: var(--line); stroke-width: 1; }
.spark-axis { display: flex; justify-content: space-between; gap: 8px; color: var(--faint); font-size: 12px; margin-top: 6px; }

/* ---------- Ficha ---------- */
.drawer-bg, .modal-bg { position: fixed; inset: 0; z-index: 40; background: rgba(12, 17, 26, .42); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(600px, 100%); display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-3); animation: slide .2s cubic-bezier(.2, .8, .2, 1); }
@keyframes slide { from { transform: translateX(32px); opacity: .3; } }
.d-head { padding: 18px 22px 18px; border-bottom: 1px solid var(--line); background: linear-gradient(var(--accent-soft), var(--surface) 70%); }
.d-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.d-top .icon-btn { margin-left: auto; }
.d-head h2 { font-size: 24px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.d-sub { color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13.5px; }
.d-sub a { color: inherit; }

.stepper { list-style: none; margin: 18px 0 0; padding: 0; display: flex; gap: 4px; }
.stepper li { flex: 1; min-width: 0; }
.stepper button { width: 100%; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; color: var(--faint); }
.stepper .seg-bar { display: block; height: 6px; border-radius: 3px; background: var(--sunken); transition: background .2s; }
.stepper .seg-name { display: block; margin-top: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper li.done .seg-bar { background: var(--accent-line); }
.stepper li.done button { color: var(--muted); }
.stepper li.current .seg-bar { background: var(--accent); }
.stepper li.current button { color: var(--text); }
.stepper li.won .seg-bar { background: var(--ok); }
.stepper li.won.current button, .stepper li.won button:hover { color: var(--ok); }
.stepper button:hover { color: var(--text); }
.stepper button:hover .seg-bar { background: var(--accent-line); }
.lost-banner { margin-top: 14px; padding: 9px 12px; border-radius: 9px; background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.lost-banner .btn { margin-left: auto; }
.d-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.d-actions .btn-wa { flex: 1 1 220px; min-height: 42px; font-size: 14.5px; }
.d-owner { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.d-owner select { width: auto; min-width: 190px; min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
.d-body { flex: 1; overflow-y: auto; padding: 0 22px 28px; }
.d-sec { padding: 18px 0; border-bottom: 1px solid var(--line); }
.d-sec:last-child { border-bottom: 0; }
.d-sec > h3 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 15px; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); margin-bottom: 6px; }
.task-row .grow { flex: 1; min-width: 0; }
.task-row .t-title { font-weight: 600; }
.task-row .t-when { font-size: 12.5px; color: var(--muted); }
.task-row .t-when.bad { color: var(--bad); font-weight: 600; } .task-row .t-when.warn { color: var(--warn); font-weight: 600; }
.task-row.done { background: transparent; opacity: .55; }
.task-row.done .t-title { text-decoration: line-through; }
.task-add { display: grid; grid-template-columns: 1fr 200px auto; gap: 8px; margin-top: 10px; }
.task-add input { min-height: 36px; }
.composer { border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { border: 0; border-radius: 0; min-height: 78px; box-shadow: none !important; }
.composer-bar { display: flex; align-items: center; gap: 6px; padding: 8px; background: var(--surface-2); border-top: 1px solid var(--line); flex-wrap: wrap; }
.chip-btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.composer-bar .btn { margin-left: auto; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line-2); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 18px; bottom: 2px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.t-whatsapp::before { box-shadow: inset 0 0 0 5px var(--wa); }
.timeline li.t-etapa::before { box-shadow: inset 0 0 0 5px var(--accent); }
.timeline li.t-web::before { box-shadow: inset 0 0 0 5px var(--warn); }
.timeline li.t-nota::before, .timeline li.t-llamada::before, .timeline li.t-correo::before, .timeline li.t-reunion::before { box-shadow: inset 0 0 0 5px var(--ok); }
.timeline .t-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 12.5px; color: var(--faint); }
.timeline .t-head b { color: var(--text); font-weight: 700; font-size: 13px; }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Modal y aviso ---------- */
.modal-bg { display: grid; place-items: center; padding: 16px; }
.modal { width: min(540px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-3); padding: 24px; animation: pop .16s ease-out; }
@keyframes pop { from { transform: scale(.98); opacity: .5; } }
.modal h2 { font-size: 20px; font-weight: 800; margin-bottom: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.reasons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 60; max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 11px; background: var(--rail); color: #fff; font-weight: 600; box-shadow: var(--shadow-3); animation: rise .18s ease-out; }
.toast.bad { background: var(--bad); }
@keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } }

/* ---------- Ajustes ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button:hover { color: var(--text); background: var(--sunken); }
.tabs button.on { color: var(--text); background: var(--surface); box-shadow: var(--shadow-1); }
.tpl { display: grid; gap: 10px; padding: 16px 18px; border-top: 1px solid var(--line); }
.tpl .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tpl .row input { width: 84px; min-height: 32px; }
.tpl .stage-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--accent); }
.tpl .stage-dot.won { background: var(--ok); } .tpl .stage-dot.lost { background: var(--line-2); }
.vars { font-size: 13px; color: var(--muted); margin-bottom: 14px; line-height: 1.9; }
.vars code { font-family: inherit; font-weight: 600; background: var(--sunken); padding: 2px 7px; border-radius: 6px; color: var(--text); }
.units-check { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 4px 0; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.inline-form .field { margin: 0; }

.oauth-cancel { margin-top: 8px; }
.oauth-note { margin: 18px 0 0; }

/* ---------- Guía ---------- */
.guide { display: grid; grid-template-columns: 210px minmax(0, 720px); gap: 32px; align-items: start; }
.g-toc { position: sticky; top: 24px; }
.g-toc-title { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.g-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: g; }
.g-toc li { counter-increment: g; }
.g-toc a { display: flex; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13.5px; }
.g-toc a::before { content: counter(g); color: var(--faint); font-variant-numeric: tabular-nums; min-width: 12px; }
.g-toc a:hover { background: var(--sunken); color: var(--text); }
.g-body { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-1); padding: 8px 32px 28px; }
.g-sec { padding: 24px 0; border-top: 1px solid var(--line); scroll-margin-top: 20px; }
.g-sec:first-child { border-top: 0; }
.g-sec h2 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 12px; }
.g-sec h3 { margin: 18px 0 6px; font-size: 14.5px; }
.g-sec p, .g-sec li { font-size: 15px; line-height: 1.6; }
.g-sec p { margin: 0 0 10px; max-width: 68ch; }
.g-sec ol, .g-sec ul { margin: 4px 0 12px; padding-left: 22px; display: grid; gap: 6px; max-width: 68ch; }
.g-sec ol li::marker { font-weight: 700; color: var(--accent-strong); }
.link-inline { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.g-table { overflow-x: auto; margin: 6px 0 14px; }
.g-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.g-table th, .g-table td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); line-height: 1.45; }
.g-table thead th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.g-table tbody th { font-weight: 700; white-space: nowrap; }
.g-flow { margin: 10px 0 16px; }
.g-flow-name { font-weight: 700; font-size: 13.5px !important; margin-bottom: 6px !important; }
.g-steps { list-style: none; padding: 0 !important; margin: 0 !important; display: flex !important; flex-wrap: wrap; gap: 6px !important; max-width: none !important; }
.g-steps li { position: relative; display: grid; padding: 8px 12px; border-radius: 9px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); min-width: 120px; line-height: 1.3 !important; }
.g-steps li b { font-size: 14px; }
.g-steps li small { font-size: 12px; color: var(--muted); }
.g-steps li.won { background: var(--ok-soft); box-shadow: inset 0 0 0 1.5px var(--ok); }
.g-lost { font-size: 13px !important; color: var(--muted); margin-top: 8px !important; }
.g-lost span { color: var(--bad); font-weight: 700; background: var(--bad-soft); padding: 2px 8px; border-radius: 6px; }
.g-quote { margin: 8px 0 0; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; font-size: 15px; line-height: 1.55; max-width: 68ch; }
.g-quote small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.g-faq { border-bottom: 1px solid var(--line); max-width: 68ch; }
.g-faq summary { cursor: pointer; padding: 11px 0; font-weight: 700; font-size: 15px; list-style-position: outside; }
.g-faq p { margin: 0 0 12px !important; color: var(--muted); }

/* ---------- Móvil ---------- */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi:nth-child(4) { border-left: 0; } .kpi:nth-child(n+4) { border-top: 1px solid var(--line); } }
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .brand.auth-mobile-brand { display: flex; }
  .app { grid-template-columns: 1fr; background: var(--bg); }
  .rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 30; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 0; border-top: 1px solid var(--rail-2); }
  .rail > .brand, .rail-units, .rail-foot { display: none; }
  .nav { display: flex; flex: 1; justify-content: space-around; gap: 0; }
  .nav-btn { flex: 1; flex-direction: column; gap: 3px; font-size: 11.5px; padding: 6px 4px; text-align: center; }
  .nav-btn.active::before { left: 30%; right: 30%; top: -6px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .nav-btn .badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 18px; height: 18px; font-size: 10.5px; }
  .mhead { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .mhead select { flex: 1; min-height: 36px; }
  .main { padding: 16px 14px 92px; }
  h1 { font-size: 22px; }
  .m-only { display: initial; }
  .d-only { display: none; }
  .toolbar select { flex: 1 1 150px; min-width: 0; }
  .search { max-width: none; flex-basis: 100%; }
  .funnel { overflow-x: auto; padding-bottom: 4px; }
  .col { flex-basis: 84vw; max-height: none; }
  .dash-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { border-left: 0 !important; border-top: 1px solid var(--line); }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--line) !important; }
  .grid2 { grid-template-columns: 1fr; }
  .rows > li { flex-wrap: wrap; }
  .rows .actions { width: 100%; justify-content: flex-start; padding-left: 84px; }
  .task-add { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
  .stepper .seg-name { font-size: 10.5px; }
  .d-head, .d-body { padding-left: 16px; padding-right: 16px; }
  .guide { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .g-toc { position: static; }
  .g-toc ol { display: flex; flex-wrap: wrap; gap: 4px; }
  .g-toc a { background: var(--surface); padding: 5px 10px; font-size: 12.5px; }
  .g-body { padding: 4px 16px 20px; }
  .g-sec { scroll-margin-top: 64px; }
  .nav-btn { font-size: 10.5px; padding: 6px 2px; }
}
