/* CRM de Cota & Volumen: lo propio de la herramienta (rejilla de pantallas, tablas, tablero, formularios).
 * Se carga después de estilos-cv.css (la hoja de marca compartida, que no se edita) y solo usa sus variables
 * y los colores de la paleta acordada. test/estilos.test.js falla si aparece otro color. */

/* ── Tipografías de la demo, servidas desde el propio CRM (sin depender de Google) ── */
@font-face { font-family: "Instrument Serif"; src: url("/fonts/instrument-serif-400.woff2") format("woff2"); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("/fonts/instrument-serif-400-italic.woff2") format("woff2"); font-style: italic; font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter Tight"; src: url("/fonts/inter-tight-variable.woff2") format("woff2"); font-style: normal; font-weight: 300 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/ibm-plex-mono-400.woff2") format("woff2"); font-style: normal; font-weight: 400; font-display: swap; }

:root {
  --crm-max: 1180px;
  --crm-gutter: 40px;
  --crm-gap: 24px;
  --crm-top: 104px;
  --crm-line: rgba(56, 61, 64, .1);
  --crm-border: rgba(28, 27, 25, .16);
  --crm-bad: #9A4F3F;
  --crm-bad-bg: rgba(154, 79, 63, .10);
  --crm-ok: #5E6B52;
  --crm-ok-bg: rgba(94, 107, 82, .12);
  --crm-ring: 0 0 0 2px #F4F1EA, 0 0 0 4px #97795D;
}

/* ── Base (la web la pone Tailwind; aquí, lo mínimo) ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-size: 15px; line-height: 1.5; font-weight: 400; min-height: 100dvh; overflow-x: hidden; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-weight: 400; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; }
img, svg { display: block; }
strong, b { font-weight: 500; }
:focus-visible { outline: 2px solid var(--color-brass); outline-offset: 3px; }
[hidden] { display: none !important; }

/* Titulares: Instrument Serif con remate en cursiva latón, como la demo */
.display em { color: var(--color-brass); font-style: italic; }
h1.display { font-size: clamp(34px, 3.4vw, 54px); }
.muted, .sub { color: var(--color-stone); }
.small { font-size: 13px; }
.bad { color: var(--crm-bad); }
.ok { color: var(--crm-ok); }
.count { color: var(--color-stone); margin-left: 6px; }
td.num, th.num, .num, .ov-count, .ov-hero, .kpi-value, .ov-chart-value, .date { font-variant-numeric: tabular-nums; }

/* ── Aviso de datos de prueba ── */
.demo-banner { position: fixed; inset: 0 0 auto; z-index: 60; height: 26px; display: flex; align-items: center; justify-content: center; padding: 0 12px; background: var(--color-night); color: #C9A877; text-align: center; white-space: nowrap; overflow: hidden; }
.demo-banner .label { font-size: 10px; }

/* ── Cabecera: cápsula de vidrio flotante (receta de la demo 2) ── */
#nav { position: fixed; inset: 0 0 auto; z-index: 50; padding: 16px 24px 0; pointer-events: none; }
body[data-demo] #nav { top: 26px; }
#nav .nav-pill { pointer-events: auto; max-width: var(--crm-max); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-radius: 999px; padding: 8px 8px 8px 24px; }
#nav .nav-home { flex: none; display: block; padding: 4px 0; }
#nav .nav-brand img { height: 40px; width: auto; }
#nav .nav-links { display: flex; align-items: center; gap: 28px; font-size: 13px; font-weight: 400; }
#nav .nav-link { position: relative; padding: 12px 0; }
#nav .nav-link[aria-current="page"] { opacity: 1; font-weight: 500; }
#nav .nav-link[aria-current="page"]::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 999px; background: var(--color-brass); }
#nav .nav-tools { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nav-search { position: relative; display: flex; align-items: center; }
.nav-search > svg { position: absolute; left: 14px; width: 16px; height: 16px; color: var(--color-stone); pointer-events: none; }
.nav-search input { width: 196px; min-height: 40px; padding: 8px 34px 8px 38px; border-radius: 999px; border: 1px solid var(--crm-border); background: var(--color-paper); font-size: 13px; }
.nav-search input::-webkit-search-cancel-button { display: none; }
.nav-search input:focus { outline: none; box-shadow: var(--crm-ring); }
.nav-search kbd { position: absolute; right: 12px; color: var(--color-stone); border: 1px solid var(--crm-border); border-radius: 6px; padding: 1px 6px; line-height: 1.4; }
.nav-search input:focus + kbd, .nav-search input:not(:placeholder-shown) + kbd { display: none; }
.nav-search .search-close { display: none; }
/* Desplegable de resultados: panel de vidrio bajo el buscador */
.search-results { position: absolute; top: calc(100% + 12px); right: 0; width: min(420px, calc(100vw - 48px)); max-height: min(70vh, 520px); overflow-y: auto; padding: 8px; border-radius: 24px; display: flex; flex-direction: column; gap: 2px; background: var(--color-paper); border: 1px solid var(--crm-line); box-shadow: 0 30px 60px -30px rgba(20, 20, 19, .35); }
.search-results[hidden] { display: none; }
.search-results [role="option"] { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center; min-height: 52px; padding: 8px 14px; border-radius: 16px; }
.search-results [role="option"][aria-selected="true"] { background: rgba(151, 121, 93, .14); }
.search-results .search-name { grid-column: 1 / -1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .search-detail { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .tag { grid-column: 2; grid-row: 2; }
.search-results .search-empty { padding: 12px 14px; }
.search-results .search-all { position: sticky; bottom: -8px; flex: none; background: var(--color-paper); min-height: 44px; margin-top: 4px; padding: 0 14px; border-top: 1px solid var(--crm-line); text-align: left; color: var(--color-brass); }
@media (hover: hover) { .search-results [role="option"]:hover { background: rgba(151, 121, 93, .10); } }
/* Botón de la cabecera: la receta de «Solicitar demo» */
#nav .nav-cta { min-height: 40px; padding: 8px 20px; border: 0; border-radius: 999px; background: var(--color-brass); color: var(--color-bone); font-size: 13px; font-weight: 500; white-space: nowrap; }
#nav .nav-cta:hover { background: var(--color-carbon); }
#nav .nav-logout { min-height: 40px; padding: 8px 12px; font-size: 13px; }
.nav-menu-btn { display: none; color: var(--color-carbon); }
.nav-menu { pointer-events: auto; position: absolute; top: calc(100% + 8px); right: 12px; left: 12px; display: flex; flex-direction: column; padding: 8px; border-radius: 28px; }
.nav-menu a, .nav-menu button { display: flex; align-items: center; min-height: 48px; padding: 0 18px; border-radius: 999px; font-size: 16px; font-weight: 500; text-align: left; }
.nav-menu a[aria-current="page"] { background: rgba(151, 121, 93, .14); }
.nav-menu button { color: var(--color-stone); }

/* ── Barra inferior en móvil ── */
.tabbar { display: none; }

/* ── Rejilla de pantalla ── */
main { max-width: var(--crm-max); margin: 0 auto; padding: var(--crm-top) var(--crm-gutter) 96px; outline: none; min-width: 0; }
body[data-demo] main { padding-top: calc(var(--crm-top) + 26px); }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px 24px; margin-bottom: 40px; }
.head > div:first-child { min-width: 0; }
.head .sub { margin-top: 12px; font-size: 15px; }
.head .sub .tag { margin-top: 4px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.back { display: inline-block; margin-bottom: 20px; color: var(--color-stone); }
.back:hover { color: var(--color-carbon); }
.layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--crm-gap); align-items: start; }
.layout > div { display: grid; gap: var(--crm-gap); min-width: 0; }
.stack-tiles { display: grid; gap: var(--crm-gap); }
.empty { padding: 48px 0; color: var(--color-stone); max-width: 60ch; }
.empty h2 { color: var(--color-carbon); margin-bottom: 8px; }
.empty .pill { margin-top: 20px; }

/* ── Tarjetas: .tile de la demo ── */
.block.tile, .group.tile, .kpi-block.tile { padding: 36px; min-width: 0; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; min-height: 44px; }
.block-head > h2.label, .group > h2.label, .kpi-block > h2.label { color: var(--color-brass); }
.block-head > span { font-size: 14px; }
.group > h2.label, .kpi-block > h2.label { margin-bottom: 16px; }
.group.overdue > h2.label { color: var(--crm-bad); }

/* ── Botones: .pill de la demo (carbón → latón) ── */
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 12px 24px; border-radius: 999px; border: 1px solid rgba(28, 27, 25, .15); background: transparent; color: var(--color-carbon); font-size: 15px; font-weight: 500; line-height: 1.2; white-space: nowrap; cursor: pointer; }
.pill:hover { border-color: var(--color-carbon); }
.pill:focus { outline: none; }
.pill:focus-visible { outline: 2px solid var(--color-brass); outline-offset: 4px; }
.pill.primary { background: var(--color-carbon); border-color: var(--color-carbon); color: var(--color-bone); padding: 16px 28px; }
.pill.primary:hover { background: var(--color-brass); border-color: var(--color-brass); }
.pill.bronze { background: var(--color-carbon); border-color: var(--color-carbon); color: var(--color-bone); }
.pill.bronze:hover { background: var(--color-brass); border-color: var(--color-brass); }
.pill.compact { min-height: 44px; padding: 10px 20px; font-size: 14px; }
.pill.quiet { border-color: transparent; color: var(--color-stone); min-height: 44px; padding: 10px 14px; font-size: 14px; }
.pill.quiet:hover { color: var(--color-carbon); border-color: transparent; }
.pill.danger { border-color: var(--crm-bad); color: var(--crm-bad); }
.pill.danger:hover { background: var(--crm-bad-bg); }
.pill:disabled { opacity: .5; cursor: not-allowed; }
label.pill { cursor: pointer; }

/* ── Selectores de vidrio (.lg-group de la demo) ── */
.lg-group { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.lg-opt { cursor: pointer; }
.subnav .lg-opt { min-height: 44px; padding: 10px 20px; }

/* ── Estados: cápsula pequeña .label sobre fondo suave ── */
.tag { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 10px; border-radius: 999px; background: var(--crm-line); color: var(--color-stone); white-space: nowrap; vertical-align: middle; }
.tag.done { background: var(--crm-ok-bg); color: var(--crm-ok); }
.tag.stop { background: var(--crm-bad-bg); color: var(--crm-bad); }

/* ── Campos de formulario ── */
input, select, textarea { width: 100%; min-height: 48px; padding: 12px 16px; border-radius: 16px; border: 1px solid var(--crm-border); background: var(--color-paper); color: var(--color-carbon); font-size: 15px; font-weight: 400; line-height: 1.35; }
select { appearance: none; -webkit-appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, #6E6A63 50%), linear-gradient(135deg, #6E6A63 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 17px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--crm-ring); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: #1C1B19; flex: none; }
input[type="file"] { display: none; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > .label { color: var(--color-stone); }
.field.check { flex-direction: row; align-items: center; gap: 12px; min-height: 44px; }
.field.check > span { font-size: 15px; }
.section-label { grid-column: 1 / -1; color: var(--color-brass); padding-top: 16px; border-top: 1px solid var(--crm-line); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.form-error { color: var(--crm-bad); margin-top: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 28px; }
.filters { display: grid; grid-template-columns: minmax(200px, 1.4fr) repeat(3, minmax(180px, 1fr)) auto; gap: 12px; margin-bottom: 24px; align-items: center; }

/* ── Ventanas: <dialog class="tile"> con el fondo y la entrada de la demo ── */
#dialog { border: 0; padding: 36px; width: min(92vw, 680px); max-height: calc(100dvh - 48px); overflow-y: auto; color: var(--color-carbon); }
#dialog h2.display { font-size: clamp(30px, 3vw, 42px); }
#dialog form > .muted { margin-top: 12px; }

/* ── Avisos breves: cápsula .glass-dark abajo en el centro ── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.toast.error { background: var(--crm-bad); }
/* Pregunta al volver a la pestaña: misma cápsula oscura que los avisos, con tres respuestas */
.ask { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 72; width: min(520px, calc(100vw - 24px)); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; padding: 14px 14px 14px 24px; border-radius: 28px; color: var(--color-bone); }
.ask[hidden] { display: none; }
.ask p { font-size: 15px; font-weight: 500; }
.ask-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ask .pill:not(.primary) { background: transparent; color: var(--color-bone); border-color: currentColor; }
.ask .pill.primary { background: var(--color-bone); color: var(--color-carbon); border-color: var(--color-bone); }
@media (prefers-reduced-motion: no-preference) { .ask:not([hidden]) { animation: crm-ask-in .45s var(--ease-expo); } }
@keyframes crm-ask-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ── Hoy: bandejas con una fila por cliente y botones directos ── */
.today-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; align-items: center; padding: 16px 0; border-top: 1px solid var(--crm-line); }
.today-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.today-name { font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
@media (hover: hover) { .today-name:hover { color: var(--color-brass); } }
.today-what { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.today-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.today-empty { padding: 4px 0 2px; }
.today-row.late .today-name { color: var(--crm-bad); }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--crm-border); background: var(--color-paper); color: var(--color-carbon); }
.icon-btn svg { width: 19px; height: 19px; }
@media (hover: hover) { .icon-btn:hover { border-color: var(--color-brass); color: var(--color-brass); } }
.icon-btn:focus-visible { outline: none; box-shadow: var(--crm-ring); }
.today-upcoming > summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; cursor: pointer; list-style: none; }
.today-upcoming > summary::-webkit-details-marker { display: none; }
.today-upcoming > summary::after { content: "+"; font-size: 20px; color: var(--color-brass); padding: 0 8px; }
.today-upcoming[open] > summary::after { content: "−"; }
.today-upcoming > summary h2 { margin: 0; }
.today-figures .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 0; }
.today-figures .kpi-value small { font: 14px var(--font-sans); color: var(--color-stone); letter-spacing: 0; }

/* ── Filas y listas dentro de tarjetas ── */
.line-item { display: flex; justify-content: space-between; gap: 16px; align-items: center; min-height: 56px; padding: 10px 0; border-top: 1px solid var(--crm-line); }
.line-item > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.line-item.done { color: var(--color-stone); }
/* ── Historial: un icono por tipo; lo automático (web y demo) en tono piedra y agrupado ── */
.act-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px 0; border-top: 1px solid var(--crm-line); }
.act-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; background: var(--color-bone); color: var(--color-carbon); }
.act-icon svg { width: 18px; height: 18px; }
.act-item.auto .act-icon, .act-group > summary .act-icon { color: var(--color-stone); background: transparent; border: 1px solid var(--crm-line); }
.act-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.act-meta > .label:first-child { color: var(--color-carbon); }
.act-summary { margin-top: 4px; white-space: pre-line; overflow-wrap: anywhere; }
.act-item.auto .act-summary { color: var(--color-stone); }
.act-item .pill { align-self: center; }
.act-group { border-top: 1px solid var(--crm-line); }
.act-group > summary { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 64px; padding: 12px 0; cursor: pointer; list-style: none; }
.act-group > summary::-webkit-details-marker { display: none; }
.act-group > summary > span:nth-child(2) { display: flex; flex-direction: column; }
.act-group > summary::after { content: "+"; font-size: 20px; color: var(--color-brass); padding: 0 8px; }
.act-group[open] > summary::after { content: "−"; }
.act-group > .act-item { padding-left: 50px; grid-template-columns: 36px minmax(0, 1fr) auto; }
@media (max-width: 767px) {
  .act-item { grid-template-columns: 36px minmax(0, 1fr); }
  .act-item .pill { grid-column: 2; justify-self: start; }
  .act-group > .act-item { padding-left: 0; }
}
.line-item .tools { flex-wrap: nowrap; }
.line-item a, td a, .follow a { font-weight: 500; }
.line-item a:hover, td a:hover { color: var(--color-brass); }
dl.facts { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); }
dl.facts dt, dl.facts dd { padding: 12px 0; border-top: 1px solid var(--crm-line); }
dl.facts dt { font-size: 13px; color: var(--color-stone); }
dl.facts dd { overflow-wrap: anywhere; }
.contact-link { color: var(--color-carbon); text-decoration: underline; text-decoration-color: rgba(28, 27, 25, .16); text-underline-offset: 3px; display: inline-block; padding: 2px 0; }
.notice { background: var(--crm-bad-bg); color: var(--crm-bad); padding: 12px 16px; border-radius: 16px; margin-bottom: 20px; }

/* Seguimientos (Hoy y Seguimiento) */
.follow { display: grid; grid-template-columns: 104px minmax(0, 1.5fr) minmax(0, 1fr) auto; gap: 16px; align-items: center; min-height: 56px; padding: 12px 0; border-top: 1px solid var(--crm-line); }
.follow-link { color: inherit; grid-template-columns: 104px minmax(0, 1.5fr) minmax(0, 1fr); border-radius: 12px; }
@media (hover: hover) { .follow-link:hover strong { color: var(--color-brass); } }
.follow .date { font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em; color: var(--color-stone); }
.overdue .follow .date { color: var(--crm-bad); }
.follow strong { font-weight: 500; }

/* ── Tablas: sin rejilla, filas de 56 px ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-family: var(--font-mono); font-size: 11px; font-weight: 400; letter-spacing: .14em; text-transform: uppercase; color: var(--color-stone); text-align: left; padding: 12px 16px 12px 0; border-bottom: 1px solid var(--crm-line); white-space: nowrap; }
td { padding: 14px 16px 14px 0; height: 56px; border-bottom: 1px solid var(--crm-line); vertical-align: top; }
td.num, th.num { text-align: right; }
tbody tr { transition: background-color .3s; }
@media (hover: hover) { #company-table tbody tr:hover { background: var(--color-paper); } }
#company-table > .small { margin-bottom: 8px; }

/* ── Tablero ── */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 16px; overflow-x: auto; padding: 4px 4px 20px; margin: 0 -4px; }
.column { min-width: 0; border-radius: 22px; padding: 4px; transition: background-color .3s; }
.column.drop { background: rgba(151, 121, 93, .14); }
.column h2 { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 8px 0; font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--color-stone); }
.column h2 span { color: var(--color-carbon); }
.cota { position: relative; height: 22px; margin: 8px 8px 12px; }
.cota::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; border-top: 1px solid var(--color-brass); }
.cota i { position: absolute; top: 5px; height: 11px; border-left: 1px solid var(--color-brass); }
.cota i:first-child { left: 0; }
.cota i:nth-child(2) { right: 0; }
.cota span { position: absolute; left: 50%; top: 2px; transform: translateX(-50%); background: var(--color-bone); padding: 0 8px; font: 12px/18px var(--font-mono); color: var(--color-brass); white-space: nowrap; font-variant-numeric: tabular-nums; }
.card.tile { border-radius: 22px; padding: 16px; margin-bottom: 12px; cursor: grab; display: grid; gap: 6px; }
.card .title { font-weight: 500; overflow-wrap: anywhere; }
.card .title:hover { color: var(--color-brass); }
.card .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--color-stone); font-variant-numeric: tabular-nums; }
.card .next { font-size: 13px; }
.card .late { color: var(--crm-bad); }
.card select { min-height: 40px; padding: 8px 36px 8px 14px; font-size: 13px; border-radius: 999px; margin-top: 4px; }
.card .pill { width: 100%; }
.board-chips { display: none; margin-bottom: 20px; }

/* ── Barra de etapas de la oportunidad ── */
.stepper { margin-bottom: 32px; }
.stepper .lg-opt { min-height: 44px; padding: 10px 16px; font-size: 13px; }
.stepper .lg-opt:not(.reached):not([aria-pressed="true"]) { opacity: .62; }

/* ── Números (antes KPI) ── */
.kpi-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi-period { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 32px; font-size: 14px; }
.kpi-block.tile { margin-bottom: var(--crm-gap); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 24px; margin-bottom: 24px; }
.kpi-cell { min-width: 0; }
.kpi-label { font-size: 13px; color: var(--color-stone); }
.kpi-value { font-family: var(--font-serif); font-size: clamp(26px, 2.2vw, 34px); letter-spacing: -0.025em; line-height: 1.1; overflow-wrap: anywhere; }
.kpi-none { font: 15px/1.5 var(--font-sans); color: var(--color-stone); letter-spacing: 0; }
.kpi-trend { margin-bottom: 8px; }
.kpi-block .ov-block { border-top: 0; padding-top: 0; }
.hero-hours { font-family: var(--font-serif); font-size: clamp(26px, 2.2vw, 34px); letter-spacing: -0.025em; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-hours em { color: var(--color-brass); font-style: italic; }

.ov-top { margin-bottom: 32px; }
.ov-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.ov-head h2 { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--color-brass); }
.ov-head .label { color: var(--color-stone); }
.ov-head:hover .label { color: var(--color-carbon); }
.ov-track { position: relative; height: 3px; border-radius: 999px; background: var(--crm-line); }
.ov-track b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--color-brass); }
.ov-track i { position: absolute; top: -6px; height: 15px; border-left: 2px solid var(--color-carbon); }
.ov-plan { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin-bottom: 32px; }
.ov-phase-name { font-weight: 500; }
.ov-phase .small { font-size: 12.5px; }
.ov-phase:not(.now) .ov-phase-name { color: var(--color-stone); }
.ov-phase .ov-track { margin: 10px 0 10px; }
.ov-gate { font-size: 13.5px; }
.ov-also { margin-top: 4px; }
.ov-flow { border-top: 1px solid var(--crm-line); padding-top: 16px; margin-bottom: 24px; }
.ov-scroll { overflow-x: auto; }
.ov-flow-inner { min-width: 620px; }
.ov-stages { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.ov-stages a { display: flex; flex-direction: column; align-items: center; padding: 0 3px; }
.ov-stages a:hover .ov-stage-name { color: var(--color-brass); }
.ov-stage-name { font-size: 13px; }
.ov-count { font-family: var(--font-serif); font-size: clamp(26px, 2.2vw, 34px); line-height: 1; }
.ov-stages .small { font-size: 12px; line-height: 1.25; }
.ov-ribbon { display: block; width: 100%; height: 96px; margin-top: 6px; }
.ov-ribbon path { fill: var(--color-brass); opacity: .85; }
.ov-convs { position: relative; height: 40px; }
.ov-conv { position: absolute; top: 2px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; line-height: 1.2; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ov-conv strong { font-size: 14px; }
.ov-conv span { font-size: 11.5px; color: var(--color-stone); }
.ov-phone-bar { display: none; }
.ov-block { min-width: 0; }
.ov-hero { font-family: var(--font-serif); font-size: clamp(26px, 2.2vw, 34px); line-height: 1; margin-bottom: 12px; }
.ov-hero em { color: var(--color-brass); font-size: .6em; }
.ov-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.ov-chart-title { display: flex; flex-direction: column; font-size: 13px; color: var(--color-stone); }
.ov-chart-value { font-family: var(--font-serif); font-size: clamp(26px, 2.2vw, 34px); color: var(--color-carbon); white-space: nowrap; }
.ov-chart-value small { font: 13px var(--font-sans); color: var(--color-stone); }
.ov-bars { position: relative; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; height: 112px; margin-top: 8px; border-bottom: 1px solid var(--crm-border); }
.ov-bar { position: relative; height: 100%; }
.ov-bar b { position: absolute; left: 0; right: 0; bottom: 0; background: #C9A877; border-radius: 6px 6px 0 0; }
.ov-bar.now b { background: var(--color-brass); }
.ov-bar.paused b { background: var(--crm-line); }
.ov-bar.paused::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 100%; border-radius: 6px 6px 0 0; background: repeating-linear-gradient(135deg, transparent 0 5px, var(--crm-line) 5px 6px); }
.ov-goal { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--color-carbon); z-index: 1; }
.ov-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--color-stone); margin-top: 4px; }
.ov-hbar { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 2.4fr) 84px; gap: 12px; align-items: center; padding: 6px 0; font-size: 13.5px; }
.ov-hbar strong { text-align: right; font-variant-numeric: tabular-nums; }
.ov-hbar > div { height: 8px; }
.ov-hbar b { display: block; height: 100%; background: var(--color-brass); border-radius: 0 999px 999px 0; }
.ov-hbar b.soft { background: #C9A877; }

/* Medidor frente a objetivo */
.meter { position: relative; height: 18px; }
.meter::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; border-top: 1px solid var(--crm-line); }
.meter b { position: absolute; left: 0; top: 6px; height: 5px; border-radius: 999px; background: var(--color-brass); }
.meter.over b { background: var(--crm-bad); }
.meter i { position: absolute; top: 1px; height: 15px; border-left: 1.5px solid var(--color-carbon); }

/* ── Acceso ── */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px; }
.login { width: min(400px, 100%); padding: 40px 36px; display: flex; flex-direction: column; align-items: stretch; gap: 20px; }
.login .login-logo { width: 168px; height: auto; margin: 0 auto 8px; }
.login h1 { text-align: center; font-size: clamp(34px, 3.4vw, 46px); }
.login form { display: flex; flex-direction: column; gap: 16px; }
.login .pill.primary { width: 100%; }
.login .motto { text-align: center; color: var(--color-stone); }
.login .form-error { margin: 0; }

/* ── Portátil estrecho y tableta ── */
@media (max-width: 1100px) {
  #nav .nav-links { gap: 20px; }
  .nav-search input { width: 150px; }
  .layout { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
  .follow, .follow-link { grid-template-columns: 96px minmax(0, 1fr) auto; }
  .follow .who { grid-column: 2; grid-row: 2; }
  .ov-plan { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  #nav .nav-links, #nav .nav-logout { display: none; }
  .nav-menu-btn { display: grid; }
}

/* ── Móvil ── */
@media (max-width: 767px) {
  .today-row { grid-template-columns: minmax(0, 1fr); }
  .today-actions { justify-content: flex-start; }
  .today-figures .kpi-grid { grid-template-columns: 1fr; gap: 16px; }
  .ask { bottom: calc(92px + env(safe-area-inset-bottom)); padding: 14px 14px 14px 20px; }
  :root { --crm-gutter: 20px; --crm-gap: 16px; --crm-top: 88px; }
  #nav { padding: 12px 12px 0; padding-top: max(12px, env(safe-area-inset-top)); }
  body[data-demo] #nav { top: 26px; padding-top: 8px; }
  #nav .nav-pill { padding: 6px 6px 6px 18px; gap: 8px; }
  #nav .nav-brand img { height: 36px; }
  #nav .nav-search, #nav .nav-cta { display: none; }
  /* Modo búsqueda: el buscador ocupa la cápsula y los resultados caen debajo */
  body.searching #nav .nav-home, body.searching #nav .nav-menu-btn, body.searching #nav .nav-logout { display: none; }
  body.searching #nav .nav-tools, body.searching #nav .nav-search { display: flex; flex: 1; }
  body.searching .nav-search input { width: 100%; min-height: 44px; padding-right: 52px; }
  body.searching .nav-search kbd { display: none; }
  body.searching .nav-search .search-close { display: grid; position: absolute; right: 0; }
  /* El vidrio de la cápsula es el bloque contenedor: los resultados ocupan todo su ancho */
  body.searching .nav-search { position: static; }
  body.searching .nav-search > svg { left: 32px; }
  body.searching .search-close { right: 6px; top: 6px; }
  .search-results { top: calc(100% + 10px); left: 0; right: 0; width: auto; max-height: calc(100dvh - 220px); }
  main { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
  .head { margin-bottom: 28px; }
  .head .tools { width: 100%; }
  h1.display { overflow-wrap: anywhere; }
  .block.tile, .group.tile, .kpi-block.tile { padding: 28px 20px; }
  .demo-banner .label { font-size: 9.5px; letter-spacing: .08em; }

  /* Barra inferior: cápsula de vidrio flotante */
  .tabbar { position: fixed; z-index: 50; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr 1fr 64px; align-items: center; padding: 6px; border-radius: 999px; }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border-radius: 999px; font-size: 11.5px; font-weight: 500; color: var(--color-stone); }
  .tabbar svg { width: 20px; height: 20px; }
  .tabbar a[aria-current="page"] { color: var(--color-carbon); background: rgba(151, 121, 93, .14); }
  .tabbar .tabbar-add { justify-self: end; width: 48px; height: 48px; min-height: 0; margin-right: 2px; background: var(--color-brass); color: var(--color-bone); }
  .tabbar .tabbar-add svg { width: 22px; height: 22px; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }

  /* Tablero: una etapa cada vez */
  .board-chips { display: flex; }
  .board { display: block; overflow: visible; padding: 0; margin: 0; }
  .column { display: none; padding: 0; }
  .column.active { display: block; }
  .card.tile { cursor: default; }
  .card select { font-size: 16px; min-height: 44px; }

  /* Tablas: cada fila se convierte en una tarjeta */
  .table-wrap { overflow: visible; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tbody { display: grid; gap: 12px; }
  table.stack tr { background: var(--color-paper); border-radius: 22px; padding: 12px 20px; box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 20px 50px -34px rgba(20, 20, 19, .35); }
  table.stack td { display: flex; justify-content: space-between; gap: 16px; height: auto; padding: 8px 0; border: 0; border-top: 1px solid var(--crm-line); text-align: right; overflow-wrap: anywhere; }
  table.stack td:first-child { border-top: 0; display: block; text-align: left; font-size: 16px; padding-bottom: 10px; }
  table.stack td:first-child::before { display: none; }
  table.stack td > * { min-width: 0; }
  table.stack td::before { content: attr(data-label); flex: none; max-width: 42%; font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--color-stone); text-align: left; padding-top: 3px; }

  .follow, .follow-link { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .follow .who { grid-column: auto; grid-row: auto; }
  .line-item { flex-wrap: wrap; }
  .line-item .tools { flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .ov-plan { grid-template-columns: 1fr 1fr; }
  .ov-charts { grid-template-columns: 1fr; }
  .ov-scroll { overflow: visible; }
  .ov-flow-inner { min-width: 0; }
  .ov-ribbon, .ov-convs { display: none; }
  .ov-stages { grid-template-columns: 1fr; text-align: left; }
  .ov-stages a { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 12px; padding: 8px 0; border-top: 1px solid var(--crm-line); }
  .ov-count { grid-column: 2; grid-row: 1 / span 2; }
  .ov-phone-bar { display: block; grid-column: 1 / -1; height: 6px; background: var(--color-brass); border-radius: 0 999px 999px 0; margin-top: 4px; }
  .ov-hbar { grid-template-columns: minmax(0, 1fr) 72px; }
  .ov-hbar > div { grid-column: 1 / -1; grid-row: 2; }
  .filters { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }   /* en iPhone, por debajo de 16 px Safari amplía la página */

  /* Ventanas a pantalla completa desde abajo; las acciones quedan sobre el teclado */
  #dialog { position: fixed; top: var(--vv-top, 0); left: 0; right: auto; bottom: auto; margin: 0; width: 100%; max-width: none; height: var(--vv-height, 100dvh); max-height: none; border-radius: 28px 28px 0 0; padding: calc(24px + env(safe-area-inset-top)) 20px 0; }
  #dialog[open] { animation: crm-sheet-in .5s var(--ease-expo); }
  #dialog form { min-height: 100%; display: flex; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; margin-bottom: 20px; }
  .field.full { grid-column: auto; }
  .form-actions { position: sticky; bottom: 0; margin: auto -20px 0; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: var(--color-paper); border-top: 1px solid var(--crm-line); }
  .form-actions .pill { flex: 1; }
  .login { padding: 32px 24px; }
}
@keyframes crm-sheet-in { from { transform: translateY(24px); opacity: 0; } }
@media (max-width: 389px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .tabbar a, .tabbar button { font-size: 11px; }
}
@media (pointer: coarse) {
  .pill, .pill.compact, .pill.quiet { min-height: 44px; }
}

/* ── Desplegables propios (public/selector.js): botón encima del <select>, que queda oculto y guarda el valor ── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
select.sel-native { position: absolute; top: 0; left: 0; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; border: 0; opacity: 0; pointer-events: none; }
.sel-trigger { position: relative; width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 12px 16px; border-radius: 16px; border: 1px solid var(--crm-border); background: var(--color-paper); color: var(--color-carbon); font-size: 15px; line-height: 1.35; text-align: left; cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.sel-trigger .sel-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-trigger.is-placeholder .sel-value { color: var(--color-stone); }
.sel-trigger .sel-chevron { flex: none; color: var(--color-stone); transition: transform .2s var(--ease-expo), color .15s ease; }
.sel-trigger[aria-expanded="true"] { box-shadow: var(--crm-ring); }
.sel-trigger[aria-expanded="true"] .sel-chevron { transform: rotate(180deg); color: var(--color-carbon); }
.sel-trigger:focus-visible { outline: none; box-shadow: var(--crm-ring); }
.sel-trigger:disabled { opacity: .5; cursor: default; }
@media (hover: hover) { .sel-trigger:not(:disabled):hover { border-color: var(--color-stone); } .sel-trigger:hover .sel-chevron { color: var(--color-carbon); } }
.card .sel-trigger { min-height: 40px; padding: 8px 12px 8px 14px; font-size: 13px; border-radius: 999px; margin-top: 4px; }

/* Lista: papel opaco, esquinas de 20 px, resaltado que se desliza y marca en la opción elegida */
.sel-pop { position: fixed; inset: auto; margin: 0; z-index: 80; box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 6px; display: flex; flex-direction: column; gap: 2px; border-radius: 20px; background: var(--color-paper); color: var(--color-carbon); border: 1px solid var(--crm-line); box-shadow: 0 30px 60px -30px rgba(20, 20, 19, .35); outline: none; }
.sel-item { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; border-radius: 14px; font-size: 14px; color: var(--color-stone); cursor: pointer; user-select: none; outline: none; transition: color .12s ease; }
.sel-item .sel-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-item .sel-check { flex: none; opacity: 0; color: var(--color-brass); }
.sel-item.is-active, .sel-item.is-checked { color: var(--color-carbon); }
.sel-item.is-checked { font-weight: 500; }
.sel-item.is-checked .sel-check { opacity: 1; }
.sel-item[aria-disabled="true"] { opacity: .45; cursor: default; }
.sel-item:focus-visible { box-shadow: inset 0 0 0 1px var(--color-brass); }
.sel-mark { position: absolute; z-index: 0; top: 0; left: 6px; right: 6px; height: 0; border-radius: 14px; opacity: 0; pointer-events: none; }
.sel-mark.is-on { opacity: 1; }
.sel-mark-checked { background: rgba(151, 121, 93, .14); }
.sel-mark-hover { background: rgba(151, 121, 93, .10); }
@media (prefers-reduced-motion: no-preference) {
  .sel-pop:not(.no-anim) .sel-mark-hover { transition: transform .18s var(--ease-expo), height .18s var(--ease-expo), opacity .12s ease; }
  .sel-pop { animation: crm-sel-in .16s var(--ease-expo); transform-origin: top center; }
  .sel-pop[data-side="top"] { transform-origin: bottom center; }
  .sel-item .sel-check path { stroke-dasharray: 24; stroke-dashoffset: 0; }
  .sel-item.is-checked .sel-check path { animation: crm-sel-check .2s ease-out; }
}
@keyframes crm-sel-in { from { opacity: 0; transform: translateY(-4px) scaleY(.96); } }
@keyframes crm-sel-check { from { stroke-dashoffset: 24; } }
@media (max-width: 767px) {
  .sel-trigger { font-size: 16px; }
  .card .sel-trigger { min-height: 44px; font-size: 16px; }
  .sel-item { min-height: 44px; font-size: 16px; }
}

/* ── Ficha única del cliente (fase 3): cabecera con contacto, pestañas, etapas y dos columnas ── */
.ficha-head { margin-bottom: 28px; }
.ficha-contact { gap: 8px; }
.contact-pill { gap: 8px; min-height: 44px; padding: 10px 18px; font-size: 14px; }
.contact-pill svg { width: 18px; height: 18px; flex: none; }
.contact-pill.is-off { opacity: .4; cursor: default; }
.contact-pill.is-off:hover { border-color: rgba(28, 27, 25, .15); }
.ficha-tabs { margin-bottom: 16px; }
.ficha-tabs .lg-opt { min-height: 44px; padding: 10px 18px; font-size: 14px; }
.ficha-stages { margin-bottom: 32px; }
.ficha-stages .stepper { margin-bottom: 10px; }
.ficha-empty { padding: 8px 0 32px; }
.layout.ficha { grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); }
.ficha-tools { margin-top: 32px; justify-content: flex-end; }
.quick-log { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.quick-log input { flex: 1; min-width: 0; min-height: 44px; padding: 10px 16px; border-radius: 999px; }
.person .consents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag.quiet-tag { background: transparent; border: 1px solid var(--crm-line); }
.ficha-side .block.tile { padding: 28px; }
.side-date { font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--color-stone); }
.side-title { margin: 6px 0 16px; font-size: 17px; line-height: 1.35; }
.side-next.late { box-shadow: inset 3px 0 0 var(--crm-bad); }
.side-actions { gap: 8px; margin-top: 16px; }
.side-reminders { margin-top: 18px; border-top: 1px solid var(--crm-line); padding-top: 12px; }
.side-reminders summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--color-stone); }
.side-reminders .line-item { min-height: 0; }
.side-demo .facts { margin-top: 4px; }
.budget-lines { display: grid; }
.budget-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 40px; padding: 6px 0; border-top: 1px solid var(--crm-line); font-variant-numeric: tabular-nums; }
.budget-line > span:last-child { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.budget-line.extra { font-size: 14px; color: var(--color-stone); }
.budget-line.total { border-top-color: var(--color-carbon); font-size: 17px; }
.x-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-right: -8px; border-radius: 999px; color: var(--color-stone); font-size: 18px; cursor: pointer; }
.x-btn:hover { color: var(--crm-bad); background: var(--crm-bad-bg); }
.side-config { margin-top: 16px; padding: 14px 16px; border-radius: 16px; background: var(--crm-line); font-size: 14px; }
.side-config .label { color: var(--color-brass); margin-bottom: 6px; }
.side-config ul { margin: 0; padding-left: 18px; }
.qualify-row { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--crm-line); font-size: 14px; }
.qualify-row:first-of-type { border-top: 0; padding-top: 0; }
.qualify .lg-opt { min-height: 44px; padding: 8px 16px; font-size: 13px; }
@media (max-width: 1100px) { .layout.ficha { grid-template-columns: 1fr; } .ficha-side { order: -1; } }
@media (max-width: 767px) {
  .ficha-contact { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .contact-pill { padding: 10px 8px; }
  .ficha-stages .stepper { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 4px; scrollbar-width: none; }
  .ficha-stages .stepper .lg-opt { flex: none; }
  .ficha-tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .ficha-tabs .lg-opt { flex: none; }
  .ficha-side .block.tile { padding: 22px; }
  .quick-log { flex-wrap: wrap; }
  .quick-log input { flex-basis: 100%; }
  .ficha-tools { justify-content: flex-start; }
  .x-btn { width: 44px; height: 44px; margin-right: -12px; }
}
.block-head > .label.tag { font-size: 11px; }

/* ── Clientes en lista: chips de filtro y botones directos en cada fila ── */
.list-filters { display: grid; gap: 12px; margin-bottom: 24px; }
.list-search { display: flex; gap: 16px; align-items: center; }
.list-search .search { flex: 1; max-width: 520px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--crm-border); background: transparent; color: var(--color-stone); font-size: 14px; white-space: nowrap; cursor: pointer; transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
.chip[aria-pressed="true"] { background: var(--color-carbon); border-color: var(--color-carbon); color: var(--color-bone); }
.chips.board-chips { display: none; margin-bottom: 20px; }
.narrow-only { display: none; }
.chip-count { font-variant-numeric: tabular-nums; opacity: .7; }
@media (hover: hover) { .chip:not([aria-pressed="true"]):hover { border-color: var(--color-carbon); color: var(--color-carbon); } }
.link-btn { color: var(--color-brass); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; }
.list-count { margin-bottom: 8px; }
.client-table .client-name { font-weight: 500; }
.client-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.client-table td { vertical-align: middle; }
.client-table .row-actions .today-actions { flex-wrap: nowrap; justify-content: flex-end; }

/* ── Tablero: días en la etapa, fila de etapas y columnas plegadas ── */
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.card-days { font-size: 12px; color: var(--color-stone); font-variant-numeric: tabular-nums; }
.card-move { min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--crm-border); font-size: 13px; color: var(--color-carbon); cursor: pointer; }
.card-move[aria-expanded="true"] { background: var(--color-carbon); border-color: var(--color-carbon); color: var(--color-bone); }
.card-moves { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; border-top: 1px solid var(--crm-line); }
.card-moves .chip { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.card-moves .chip[aria-current] { cursor: default; }
.card.moving { box-shadow: var(--crm-ring); }
/* Las seis columnas abiertas y las dos plegadas caben en un portátil de 1280 px; más estrecho, el tablero se desplaza. */
.board { grid-template-columns: repeat(6, minmax(158px, 1fr)) auto; grid-auto-flow: row; gap: 10px; margin: 0 calc(var(--crm-gutter) * -1 + 8px); padding: 4px 8px 20px; }
.card-foot { flex-wrap: wrap; }
.board-folded { display: grid; gap: 10px; align-content: start; width: 118px; }
.board-folded:has(details[open]) { width: 220px; }
.column.folded { border: 1px dashed var(--crm-border); }
.column.folded summary { display: grid; gap: 2px; padding: 10px 12px; cursor: pointer; list-style: none; min-height: 44px; }
.column.folded summary::-webkit-details-marker { display: none; }
.folded-name { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--color-stone); }
.folded-count { font-size: 20px; }
.folded-total { font: 12px/18px var(--font-mono); color: var(--color-brass); }
.column.folded[open] summary { margin-bottom: 8px; }
.folded-empty { padding: 0 12px 12px; }
@media (max-width: 767px) {
  .list-search { flex-wrap: wrap; }
  .list-search .search { max-width: none; flex-basis: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--crm-gutter) * -1); padding: 0 var(--crm-gutter); }
  .chip { min-height: 44px; flex: none; }
  .client-table .row-actions::before { display: none; }
  .client-table .row-actions .today-actions { justify-content: flex-start; flex-wrap: wrap; width: 100%; }
  .chips.board-chips { display: flex; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }
  .board-folded { display: block; width: auto; }
  .board-folded:has(details[open]) { width: auto; }
  .column.folded { border: 0; }
  .column.folded summary { display: none; }
  .card-move { min-height: 44px; }
  .card-moves .chip { min-height: 44px; }
  /* Enlaces de texto con zona táctil de 44 px */
  .back, .person .contact-link, .client-name, .card .title { display: inline-flex; align-items: center; min-height: 44px; }
  .back { margin-bottom: 8px; }
}

/* ── Fase 4: contador de avisos, diálogo «Mensaje» y plantillas en Ajustes ── */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px;
  border-radius: 999px; background: var(--color-carbon); color: var(--color-paper); font-size: 11.5px; font-weight: 600; line-height: 1; vertical-align: 1px; }
.nav-badge[hidden] { display: none; }
.tabbar a { position: relative; }
.tabbar .nav-badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; }
form.compose textarea { min-height: 150px; line-height: 1.5; }
.compose-hint { grid-column: 1 / -1; margin: 0; }
.template-text { margin-top: 4px; max-width: 62ch; }
.template-item .tools { flex-wrap: nowrap; }
@media (max-width: 767px) {
  .template-item { flex-direction: column; align-items: stretch; }
  .template-item .tools { justify-content: flex-start; }
}

/* ── Fase 5: móvil. Barra fija de contacto en la ficha, encima del menú inferior ── */
.ficha-dock { display: none; }
@media (max-width: 767px) {
  .ficha-dock { position: fixed; z-index: 49; left: 12px; right: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; padding: 6px; border-radius: 999px; }
  .ficha-dock .dock-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 16px; background: var(--color-carbon); color: var(--color-paper); border-color: var(--color-carbon); font-weight: 500; }
  .ficha-dock .dock-btn + .dock-btn { background: var(--color-paper); color: var(--color-carbon); border-color: var(--crm-border); }
  .ficha-dock svg { width: 20px; height: 20px; flex: none; }
  main:has(.ficha-dock) { padding-bottom: calc(176px + env(safe-area-inset-bottom)); }
  body:has(.ficha-dock) .toast { bottom: calc(156px + env(safe-area-inset-bottom)); }
  /* En la cabecera ya no hacen falta Llamar y WhatsApp: queda el correo. */
  main:has(.ficha-dock) .ficha-contact .contact-pill:not([data-track="correo"]) { display: none; }
  main:has(.ficha-dock) .ficha-contact { grid-template-columns: 1fr; }
}

/* ── Fase 5: Números (puerta actual, embudo, cuatro cifras, origen) ── */
.numeros { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.numeros > .kpi-block { margin: 0; }
.numeros > .gate-block, .numeros > .kpi-more { grid-column: 1 / -1; }
.gate-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-top: 8px; }
.gate-name { font-size: clamp(28px, 2.6vw, 40px); line-height: 1.05; margin: 0 0 8px; }
.gate-name em { color: var(--color-brass); }
.gate-rule { margin: 0 0 4px; font-size: 17px; }
.gate-days { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex: none; }
.gate-days strong { font-family: var(--font-serif); font-weight: 400; font-size: clamp(40px, 4vw, 56px); line-height: 1; letter-spacing: -0.03em; }
.gate-days.bad strong { color: var(--crm-bad); }
.gate-progress { height: 8px; margin: 24px 0 10px; border-radius: 999px; background: rgba(151, 121, 93, .14); overflow: hidden; }
.gate-progress b { display: block; height: 100%; border-radius: inherit; background: var(--color-brass); }
.gate-progress b.ok { background: var(--crm-ok); }
.gate-count { margin: 0 0 6px; }
.kpi-toggle .lg-opt { min-height: 36px; padding: 0 14px; }
.funnel-period { margin: 16px 0 20px; }
.funnel { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.funnel-step { display: grid; grid-template-columns: 96px minmax(0, 1fr) 40px 118px; align-items: center; gap: 12px; font-size: 14px; }
.funnel-bar { height: 22px; border-radius: 6px; background: rgba(151, 121, 93, .10); overflow: hidden; }
.funnel-bar b { display: block; height: 100%; border-radius: 6px; background: var(--color-brass); }
.funnel-value { font-family: var(--font-serif); font-weight: 400; font-size: 22px; text-align: right; }
.funnel-conv { white-space: nowrap; }
.figures-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.kpi-more > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; min-height: 44px; }
.kpi-more > summary::-webkit-details-marker { display: none; }
.kpi-more > summary::after { content: '+'; font-size: 20px; color: var(--color-stone); }
.kpi-more[open] > summary::after { content: '−'; }
.kpi-more[open] > summary { margin-bottom: 24px; }
@media (max-width: 1023px) {
  .numeros { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .numeros { gap: 16px; }
  .gate-main { gap: 16px; }
  .funnel-step { grid-template-columns: 84px minmax(0, 1fr) 32px; row-gap: 2px; }
  .funnel-conv { grid-column: 2 / -1; }
  .funnel-period { justify-content: space-between; }
  .kpi-more > summary .small { display: none; }
}
.numeros-col { display: grid; gap: 24px; min-width: 0; }
.numeros-col > .kpi-block { margin: 0; }
.origins { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.origins li { display: grid; gap: 6px; }
.origin-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.origin-head strong { font-weight: 500; }
.origins .funnel-bar { height: 10px; }
@media (max-width: 767px) {
  .numeros-col { gap: 16px; }
  .funnel-period { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; text-align: center; font-size: 13px; }
  .funnel-period .pill { padding: 0 14px; }
}
@media (max-width: 767px) {
  .kpi-toggle .lg-opt { min-height: 44px; }
  .today-name, .ov-head { display: inline-flex; align-items: center; min-height: 44px; }
  .ov-head { display: flex; }
}
