/* S096 — Hub del cliente › Ficha: resumen con métricas + secciones en tarjetas (CRM tipo Attio/Everfit).
   Va después de mc-hub.css; todo bajo #cf-root para no tocar otras pestañas del hub. */

#cf-root {
  --cfx-radius: 14px;
  --cfx-card-bg: var(--sys-surface);
  --cfx-card-border: color-mix(in srgb, var(--hairline) 100%, transparent);
  --cfx-card-shadow: 0 1px 2px color-mix(in srgb, var(--sys-text, #000) 5%, transparent);
  --cfx-tint: color-mix(in srgb, var(--sys-text, currentColor) 3%, transparent);
  --cfx-gap: 14px;
}

/* ——— Resumen (4 métricas) ——— */
#cf-root .cfs { container: cfsum / inline-size; margin: 0 0 16px; }
#cf-root .cfs:empty { display: none; }
#cf-root .cfs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@container cfsum (min-width: 760px) {
  #cf-root .cfs-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
}
#cf-root .cfs-tile {
  position: relative;
  appearance: none;
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  min-height: 96px;
  padding: 12px 14px 14px;
  border: 1px solid var(--cfx-card-border);
  border-radius: var(--cfx-radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--cfs-accent, var(--tenant-primary)) 6%, transparent), transparent 70%),
    var(--cfx-card-bg);
  box-shadow: var(--cfx-card-shadow);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  animation: cfx-in 240ms var(--mc-hub-ease, ease-out) both;
}
#cf-root .cfs-tile:nth-child(2) { animation-delay: 30ms; }
#cf-root .cfs-tile:nth-child(3) { animation-delay: 60ms; }
#cf-root .cfs-tile:nth-child(4) { animation-delay: 90ms; }
#cf-root .cfs-tile:hover {
  border-color: color-mix(in srgb, var(--cfs-accent, var(--tenant-primary)) 35%, var(--hairline));
  box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--sys-text, #000) 18%, transparent);
}
#cf-root .cfs-tile:active { transform: scale(0.985); }
#cf-root .cfs-tile:focus-visible { outline: 2px solid var(--tenant-primary); outline-offset: 2px; }
#cf-root .cfs-k {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
}
#cf-root .cfs-k span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cf-root .cfs-k .nav-ico {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  padding: 4px;
  border-radius: 7px;
  color: var(--cfs-accent, var(--tenant-primary));
  background: color-mix(in srgb, var(--cfs-accent, var(--tenant-primary)) 13%, transparent);
}
#cf-root .cfs-v {
  font-size: 1.22rem;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#cf-root .cfs-v small { font-size: 0.8rem; font-weight: 600; letter-spacing: 0; color: var(--muted); }
#cf-root .cfs-sub {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#cf-root .cfs-meter {
  display: block;
  height: 4px;
  margin-top: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--sys-text, currentColor) 9%, transparent);
  overflow: hidden;
}
#cf-root .cfs-meter i {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  border-radius: inherit;
  background: var(--cfs-accent, var(--tenant-primary));
  transform-origin: left;
  animation: cff-grow 520ms var(--mc-hub-ease, ease-out) both;
}
#cf-root .cfs-tile.is-active,
#cf-root .cfs-tile.is-ok { --cfs-accent: var(--sys-ok); }
#cf-root .cfs-tile.is-soon,
#cf-root .cfs-tile.is-warn { --cfs-accent: var(--sys-warn); }
#cf-root .cfs-tile.is-expired { --cfs-accent: var(--sys-err); }
#cf-root .cfs-tile.is-none .cfs-v { color: var(--muted); }
#cf-root .cfs-tile.is-warn .cfs-v { color: color-mix(in srgb, var(--sys-warn) 75%, var(--text)); }
#cf-root .cfs-tile.is-hot .cfs-sub { color: color-mix(in srgb, var(--tenant-primary) 80%, var(--text)); font-weight: 600; }
#cf-root .cfs-tile.is-loading { cursor: progress; }
#cf-root .cfs-tile.is-loading .mc-hub-skel { width: 70%; height: 18px; margin: 4px 0; }
@container cfsum (max-width: 380px) {
  #cf-root .cfs-tile { min-height: 88px; padding: 10px 12px 12px; }
  #cf-root .cfs-v { font-size: 1.05rem; }
}

/* ——— Sub-pestañas: segmento con indicador ——— */
#mc-client-hub-dialog #cf-root .cf-head { margin-bottom: 18px; }
#mc-client-hub-dialog #cf-root .cf-tab { min-height: 44px; font-size: 0.86rem; }

/* ——— Tarjeta base ——— */
#cf-root .cfg-main > .cfg-sec,
#cf-root .cfg-main > .cfg-goal,
#cf-root .cfg-rail,
#cf-root .cfh-main,
#cf-root .cfh-rail .cf-hist-card,
#cf-root .cfp-cur,
#cf-root .cfp-card,
#cf-root .cfp .cf-block {
  border: 1px solid var(--cfx-card-border);
  border-radius: var(--cfx-radius);
  background: var(--cfx-card-bg);
  box-shadow: var(--cfx-card-shadow);
}

/* ——— General ——— */
#mc-client-hub-dialog #cf-root .cfg { gap: var(--cfx-gap); max-width: none; }
#cf-root .cfg-main { gap: var(--cfx-gap); }
#cf-root .cfg-main > .cfg-sec,
#cf-root .cfg-main > .cfg-goal { padding: 14px 16px 10px; }
#cf-root .cfg-main > .cfg-goal {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--tenant-primary) 7%, transparent), transparent 60%),
    var(--cfx-card-bg);
}
#cf-root .cfg-h {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
#cf-root .cfg-prop { min-height: 42px; }
@container cfpane (min-width: 700px) {
  #mc-client-hub-dialog #cf-root .cfg { grid-template-columns: minmax(0, 1fr) 280px; gap: 0 var(--cfx-gap); }
  #cf-root .cfg-rail { position: sticky; top: 0; padding: 4px 16px; border-left: 1px solid var(--cfx-card-border); }
}
@container cfpane (min-width: 1000px) {
  #mc-client-hub-dialog #cf-root .cfg { grid-template-columns: minmax(0, 1fr) 300px; }
}
@container cfpane (max-width: 699px) {
  #cf-root .cfg-rail { padding: 4px 16px; border-top: 1px solid var(--cfx-card-border); }
}
@container cfpane (min-width: 1180px) {
  #cf-root .cfg-main { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  #cf-root .cfg-main .cfg-prop { grid-template-columns: 112px minmax(0, 1fr); }
  #cf-root .cfg-main > .cfg-goal { grid-column: 1 / -1; }
}
#cf-root .cfg-rail-sec { padding: 14px 0; }
#cf-root .cfg-rail-sec:first-child { padding-top: 14px; }

/* ——— Formularios ——— */
#mc-client-hub-dialog #cf-root .cf-forms,
#mc-client-hub-dialog #cf-root .cf-neg { max-width: none; }
#mc-client-hub-dialog #cf-root .cf-forms-table-wrap,
#mc-client-hub-dialog #cf-root .cf-neg-table-wrap {
  border-radius: var(--cfx-radius);
  box-shadow: var(--cfx-card-shadow);
}
@container cfpane (min-width: 640px) {
  #mc-client-hub-dialog #cf-root .cf-forms-table thead th,
  #mc-client-hub-dialog #cf-root .cf-neg-table thead th { background: var(--cfx-tint); padding-block: 10px; }
  #mc-client-hub-dialog #cf-root .cf-forms-table tbody td,
  #mc-client-hub-dialog #cf-root .cf-neg-table tbody td { padding-block: 12px; }
}
@container cfpane (max-width: 639px) {
  #mc-client-hub-dialog #cf-root .cf-forms-table-wrap,
  #mc-client-hub-dialog #cf-root .cf-neg-table-wrap { box-shadow: none; }
  #mc-client-hub-dialog #cf-root .cf-forms-table tbody tr,
  #mc-client-hub-dialog #cf-root .cf-neg-table tbody tr { box-shadow: var(--cfx-card-shadow); }
  #mc-client-hub-dialog #cf-root .cf-forms-table tbody td.usuarios-roster-actions-col,
  #mc-client-hub-dialog #cf-root .cf-forms-table tbody td.cf-forms-del-head { position: static; background: none; box-shadow: none; }
  #mc-client-hub-dialog #cf-root .cf-forms-table tbody tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  #mc-client-hub-dialog #cf-root .cf-forms-table tbody td[data-label="Enviado"] { grid-column: 2 / -1; }
  #mc-client-hub-dialog #cf-root .cf-forms-table tbody td.usuarios-roster-actions-col { justify-content: flex-end; align-self: end; }
  #mc-client-hub-dialog #cf-root .cf-forms-table tbody td.cf-forms-del-head { align-self: end; }
  #mc-client-hub-dialog #cf-root .cf-forms-table tbody .cf-forms-pill { justify-self: start; }
}
#mc-client-hub-dialog #cf-root .cf-forms-pill.is-programado {
  color: color-mix(in srgb, var(--text) 70%, var(--muted));
  background: color-mix(in srgb, var(--sys-text, currentColor) 7%, transparent);
}
#mc-client-hub-dialog #cf-root .cf-forms-table thead th.usuarios-roster-actions-col,
#mc-client-hub-dialog #cf-root .cf-neg-table thead th.cf-neg-actions-col { background: var(--cfx-tint); }
#cf-root .cff-summary {
  padding: 10px 14px;
  border: 1px solid var(--cfx-card-border);
  border-radius: 12px;
  background: var(--cfx-tint);
}

/* ——— Historial ——— */
#mc-client-hub-dialog #cf-root .cfh { gap: var(--cfx-gap); max-width: none; }
#cf-root .cfh-main { padding: 14px 16px 10px; }
@container cfpane (min-width: 760px) {
  #mc-client-hub-dialog #cf-root .cfh { grid-template-columns: minmax(0, 1fr) 290px; gap: 0 var(--cfx-gap); }
  #mc-client-hub-dialog #cf-root .cfh-rail { padding-left: 0; border-left: 0; gap: var(--cfx-gap); }
}
@container cfpane (max-width: 759px) {
  #mc-client-hub-dialog #cf-root .cfh-rail { border-top: 0; padding-top: 0; gap: var(--cfx-gap); }
}
#mc-client-hub-dialog #cf-root .cfh-rail .cf-hist-card,
#mc-client-hub-dialog #cf-root .cfh-rail .cf-hist-card:last-child {
  margin: 0;
  padding: 12px 16px 10px;
  border: 1px solid var(--cfx-card-border);
  border-radius: var(--cfx-radius);
  background: var(--cfx-card-bg);
}
#cf-root .cfh-filter { display: inline-flex; align-items: center; gap: 6px; }
#cf-root .cfh-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: color-mix(in srgb, var(--sys-text, currentColor) 8%, transparent);
}
#cf-root .cfh-count:empty { display: none; }
@container cfpane (max-width: 520px) {
  #mc-client-hub-dialog #cf-root .cfh-head .cfh-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #mc-client-hub-dialog #cf-root .cfh-filters > .cfh-filter { justify-content: center; padding: 0 4px; }
}
#cf-root .cfh-filter.is-active .cfh-count {
  color: var(--tenant-primary);
  background: color-mix(in srgb, var(--tenant-primary) 13%, transparent);
}
#cf-root .cfh-month {
  margin: 14px 0 4px 0;
  padding: 6px 0 6px 40px;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
#cf-root .cfh-dot { flex-basis: 28px; width: 28px; height: 28px; border-width: 0; }
#cf-root .cfh-dot--train { color: var(--tenant-primary); background: color-mix(in srgb, var(--tenant-primary) 13%, var(--sys-surface)); }
#cf-root .cfh-dot--note { color: #6d5bd0; background: color-mix(in srgb, #6d5bd0 13%, var(--sys-surface)); }
#cf-root .cfh-dot--plan { color: var(--sys-ok); background: color-mix(in srgb, var(--sys-ok) 14%, var(--sys-surface)); }
#cf-root .cfh-dot--body { color: #1f8bb8; background: color-mix(in srgb, #1f8bb8 13%, var(--sys-surface)); }
#cf-root .cfh-dot--form { color: color-mix(in srgb, var(--sys-warn) 80%, var(--text)); background: color-mix(in srgb, var(--sys-warn) 15%, var(--sys-surface)); }
#cf-root .cfh-dot--life { color: var(--muted); background: color-mix(in srgb, var(--sys-text, currentColor) 7%, var(--sys-surface)); }
#cf-root .cfh-item::before { left: 13.5px; }
#cf-root .cfh-hit { padding-block: 8px; }

/* ——— Plan y productos ——— */
#mc-client-hub-dialog #cf-root .cf-plan { max-width: none; }
#cf-root .cfp { gap: var(--cfx-gap); }
#cf-root .cfp-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--cfx-gap); }
@container cfplan (min-width: 720px) {
  #cf-root .cfp-top { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: stretch; }
}
#cf-root .cfp-cur { padding: 14px 16px 16px; border-bottom: 1px solid var(--cfx-card-border); }
#cf-root .cfp-cur:not(.cfp-prods) {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--cfp-accent, var(--muted)) 9%, transparent), transparent 55%),
    var(--cfx-card-bg);
}
#cf-root .cfp-cur.is-active { --cfp-accent: var(--sys-ok); }
#cf-root .cfp-cur.is-soon { --cfp-accent: var(--sys-warn); }
#cf-root .cfp-cur.is-expired { --cfp-accent: var(--sys-err); }
#cf-root .cfp-name { font-size: 1.25rem; }
#cf-root .cfp-cur .cfp-meter-bar { max-width: none; height: 6px; }
#cf-root .cfp-cur.is-active .cfp-meter-bar i { background: var(--sys-ok); }
#cf-root .cfp-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--cfx-card-border);
}
#cf-root .cfp-facts-svc { grid-column: 1 / -1; }
#cf-root .cfp-prod-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
#cf-root .cfp-prod-list li { display: flex; align-items: center; gap: 10px; min-width: 0; }
#cf-root .cfp-prod-ico {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--tenant-primary);
  background: color-mix(in srgb, var(--tenant-primary) 12%, transparent);
}
#cf-root .cfp-prod-ico .nav-ico { width: 16px; height: 16px; }
#cf-root .cfp-prod-txt { display: grid; min-width: 0; line-height: 1.3; }
#cf-root .cfp-prod-txt b { font-size: 0.86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cf-root .cfp-prod-txt i { font-style: normal; font-size: 0.74rem; color: var(--muted); }
#cf-root .cfp-card { padding: 14px 16px 12px; }
#mc-client-hub-dialog #cf-root .cfp .cf-block { padding: 14px 16px 16px; }
#mc-client-hub-dialog #cf-root .cfp .cf-block h4 { font-size: 0.92rem; }
#mc-client-hub-dialog #cf-root .cfp .usuarios-roster-wrap { border-radius: 12px; }
#mc-client-hub-dialog #cf-root .cf-plan-tx thead th { background: var(--cfx-tint); }
#cf-root .cfp-concept b { display: block; font-weight: 600; overflow-wrap: anywhere; }
#cf-root .cfp-concept .hint { display: block; margin: 1px 0 0; font-size: 0.74rem; }
#cf-root .cfp-act { text-align: right; white-space: nowrap; }
#mc-client-hub-dialog #cf-root .cf-neg-pill.is-cerrado { color: var(--muted); background: color-mix(in srgb, var(--sys-text, currentColor) 7%, transparent); }
#cf-root .cf-delivery-chip { display: inline-flex; align-items: center; gap: 4px; margin: 2px 6px 2px 0; font-size: 0.78rem; }
@container cfplan (min-width: 621px) {
  #mc-client-hub-dialog #cf-root .cf-plan-tx td.cf-delivery-cell { display: table-cell; white-space: normal; }
}
#mc-client-hub-dialog #cf-root .cf-plan-tx td.cf-delivery-cell .hint { display: inline; margin: 0; }
#mc-client-hub-dialog #cf-root .cf-plan-tx tbody tr:nth-child(even) { background: none; }
#mc-client-hub-dialog #cf-root .cf-plan-tx tbody tr:hover { background: var(--cfx-tint); }
#mc-client-hub-dialog #cf-root .cf-plan-tx td.cfp-concept { white-space: normal; }
@container cfplan (max-width: 620px) {
  #mc-client-hub-dialog #cf-root .cf-plan-tx,
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody { display: block; }
  #mc-client-hub-dialog #cf-root .cf-plan-tx thead { display: none; }
  #mc-client-hub-dialog #cf-root .cfp .usuarios-roster-wrap { border: 0; overflow: visible; }
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody { display: grid; gap: 8px; }
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px 12px;
    padding: 12px 14px;
    border: 1px solid var(--cfx-card-border);
    border-radius: 12px;
  }
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody td { display: grid; gap: 2px; padding: 0; border: 0; white-space: normal; text-align: left; }
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody td[data-label]::before { content: attr(data-label); font-size: 0.68rem; color: var(--muted); }
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody td.cfp-concept,
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody td.cf-delivery-cell,
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody td.cfp-act { grid-column: 1 / -1; }
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody td.cfp-concept::before { display: none; }
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody td.cfp-act:empty { display: none; }
  #mc-client-hub-dialog #cf-root .cf-plan-tx tbody td.cfp-act { justify-items: end; }
}

/* ——— Negocio ——— */
#cf-root .cfn-summary.cfg-pulse {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@container cfpane (min-width: 640px) {
  #cf-root .cfn-summary.cfg-pulse { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
}
#cf-root .cfn-summary .cfg-pulse-i {
  padding: 10px 14px;
  border: 1px solid var(--cfx-card-border);
  border-radius: 12px;
  background: var(--cfx-tint);
}
#mc-client-hub-dialog #cf-root .cf-neg-empty { display: grid; justify-items: center; gap: 6px; padding: 36px 16px; }
#cf-root .cf-neg-empty h4 { margin: 4px 0 0; font-size: 0.95rem; color: var(--text); }
#cf-root .cf-neg-empty p { margin: 0; max-width: 52ch; font-size: 0.84rem; line-height: 1.5; }
#cf-root .cf-neg-empty-ico {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--tenant-primary);
  background: color-mix(in srgb, var(--tenant-primary) 11%, transparent);
}
#cf-root .cf-neg-empty-ico .nav-ico { width: 20px; height: 20px; }
#cf-root .cf-neg-empty .ghost { margin-top: 6px; }

@keyframes cfx-in { from { opacity: 0; transform: translateY(4px); } }

@media (pointer: coarse) {
  #cf-root .cfs-tile { min-height: 96px; }
  #cf-root .cfh-filter { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  #cf-root .cfs-tile, #cf-root .cfs-meter i { animation: none; }
  #cf-root .cfs-tile { transition: none; }
}
