/* Dashboard del pipeline de leads. Hereda variables, tipografía, botones y campos de ../styles.css.
   Mismo lenguaje que el sitio: papel y tinta, líneas de 1 px, esquinas rectas y los peldaños solo como marca.
   Sin sombras: la jerarquía la dan las líneas y el peso de la letra. */

:root {
  --gutter: clamp(16px, 3vw, 32px);
  --gl: max(var(--gutter), env(safe-area-inset-left, 0px));
  --gr: max(var(--gutter), env(safe-area-inset-right, 0px));
  --alert-bg: #fdf1f0;
}

body {
  font-size: 1rem;
  /* Los datos ocupan todo el ancho: sin "rebote" lateral de la página, solo del tablero. */
  overscroll-behavior-x: none;
}

.wrap-wide {
  width: 100%;
  padding-inline: var(--gl) var(--gr);
}

/* ---------- Encabezado ---------- */

.dash-header {
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom-color: var(--line);
}

.dash-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-user-name {
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 500;
}

.btn-sm {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-quiet {
  background: var(--paper);
}

.btn:focus-visible {
  outline-offset: 2px;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 0.42em;
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.page-title .step {
  flex: none;
  width: 0.5em;
  height: 0.5em;
}

.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 28px 20px;
}

/* El manual es una herramienta de trabajo, no un enlace secundario escondido entre botones. */
.pipeline-manual {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  padding: 20px 22px;
  border: 1px solid var(--ink);
  border-left: 6px solid var(--violet);
  background: #f6f1ff;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.pipeline-manual:hover,
.pipeline-manual:focus-visible {
  border-color: var(--violet);
  background: #eee5ff;
}

.pipeline-manual:focus-visible {
  outline-offset: 3px;
}

.pipeline-manual-icono {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--ink);
  background: var(--paper);
  font-size: 1.35rem;
  font-weight: 750;
}

.pipeline-manual-contenido {
  display: grid;
  gap: 3px;
}

.pipeline-manual-etiqueta {
  color: var(--violet);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.pipeline-manual-contenido strong {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.pipeline-manual-contenido > span:last-child {
  color: var(--ink-2);
  font-size: 0.875rem;
  line-height: 1.45;
}

.pipeline-manual-accion {
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- Campos extra (selects, casillas, avisos) ---------- */

.field select,
.field .select-btn {
  width: 100%;
  min-height: 44px;
  padding: 10px 40px 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background-color: var(--paper);
  /* Flecha dibujada con degradados: no hace falta imagen ni permitir data: en la CSP. */
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.field select:hover,
.field .select-btn:hover,
.field select:focus-visible,
.field .select-btn:focus-visible,
.field input[type="search"]:hover {
  border-color: var(--ink);
}

.field select:focus-visible,
.field input:focus-visible,
.field textarea:focus-visible {
  outline-offset: 2px;
}

.field input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}

/* Un campo con error conserva el borde rojo con el cursor encima o con el foco. En styles.css `.field input:hover` (más específico)
   le ganaba a `.field [aria-invalid]` y el rojo desaparecía al pasar el mouse. Solo afecta al dashboard. */
.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"],
.field select[aria-invalid="true"],
.field input[aria-invalid="true"]:hover,
.field textarea[aria-invalid="true"]:hover,
.field select[aria-invalid="true"]:hover,
.field input[aria-invalid="true"]:focus-visible,
.field textarea[aria-invalid="true"]:focus-visible,
.field select[aria-invalid="true"]:focus-visible {
  border-color: var(--error);
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.field-group {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field-group legend {
  padding: 0;
  margin-bottom: 4px;
  font-size: 0.9375rem;
  font-weight: 500;
}

.check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-size: 0.9375rem;
  cursor: pointer;
}

.check input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.form-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--error);
  background: var(--alert-bg);
  color: var(--error);
  font-size: 0.9375rem;
  font-weight: 500;
}

.dialog-form .form-alert,
.edit-form .form-alert,
.login-form .form-alert {
  margin: 0;
}

.form-note {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  background: var(--paper-2);
  font-size: 0.9375rem;
}

.spam-note {
  display: grid;
  justify-items: start;
  gap: 8px;
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid var(--ink);
  border-left-width: 4px;
  background: var(--paper-2);
}

.spam-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.spam-text {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.spam-note .form-alert {
  margin: 0;
}

.login-form .form-actions {
  flex-wrap: wrap;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.notice {
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--paper-2);
}

/* ---------- Estados: inicio, vacío, error ---------- */

.state-box {
  display: grid;
  justify-items: start;
  gap: 12px;
  max-width: 36rem;
  padding-block: clamp(40px, 8vh, 80px);
}

#contenido > .state-box {
  max-width: none;
  padding: clamp(28px, 5vw, 48px);
  border: 1px solid var(--line);
  background: var(--paper-2);
}

.state-box.compact {
  padding: 0;
}

.state-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.state-msg {
  margin: 0;
  color: var(--ink-2);
  max-width: 44ch;
}

/* ---------- Login ---------- */

.login {
  width: 100%;
  max-width: 26rem;
  margin: clamp(32px, 9vh, 96px) auto;
  padding-inline: 20px;
}

.login-lede {
  margin: 12px 0 32px;
  color: var(--ink-2);
}

.login-account {
  margin: -16px 0 28px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--ink);
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.login-account strong {
  color: var(--ink);
}

.login-form {
  display: grid;
  gap: 20px;
}

/* ---------- Resumen ---------- */

.summary {
  margin-bottom: 28px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--ink);
}

.stat {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 14px 16px 4px 0;
}

.stat + .stat {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.stat dt {
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 500;
}

.stat dd {
  margin: 0;
}

.stat-num {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.stat.is-alert .stat-num {
  color: var(--error);
}

/* Sospechosos sin revisar: van aparte para que no se mezclen con las cifras del pipeline real. */
.summary-spam {
  margin: 12px 0 0;
  color: var(--ink-2);
  font-size: 0.875rem;
}

.summary-spam .link-btn {
  color: var(--ink);
}

/* Las tiras desplazables reciben foco (ver hacerDesplazable): el anillo va hacia adentro para que el borde de la pantalla no lo corte. */
.chips-scroll:focus-visible {
  outline-offset: -2px;
}

.by-startup {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 14px;
}

.by-startup-label {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 500;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  border-color: var(--ink);
}

.chip:active {
  transform: scale(0.98);
}

.chip[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.chip-name {
  font-weight: 600;
}

.chip-meta {
  color: inherit;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* ---------- Filtros ---------- */

/* El formulario de filtros (píldoras) está en pipeline.css. */

.results {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 0.875rem;
}

#aviso {
  margin-bottom: 12px;
}

/* ---------- Tablero ---------- */

.kanban-wrap {
  margin-inline: calc(var(--gl) * -1) calc(var(--gr) * -1);
}

.kanban {
  /* Ancla los .sr-only (position: absolute) de las tarjetas al recorte del scroll: sin esto se escapan
     y estiran el documento a más de 1500 px en el celular. */
  position: relative;
  display: grid;
  grid-auto-flow: column;
  align-items: start;
  padding: 4px var(--gr) 32px var(--gl);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gl);
  -webkit-overflow-scrolling: touch;
}

.col {
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
}

.col-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.col-more {
  width: 100%;
}

/* Arrastrar: las columnas donde se puede soltar se marcan; el resto se apaga. */
.is-dragging-any .col:not(.can-drop) {
  opacity: 0.55;
}

.card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.875rem;
  line-height: 1.45;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}

.card[draggable="true"] {
  cursor: grab;
}

.card.is-dragging {
  opacity: 0.4;
}

.card.is-saving {
  opacity: 0.55;
  pointer-events: none;
}

.card p {
  margin: 0;
}

.card-name {
  padding-block: 2px;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.card-name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.badge {
  padding: 1px 8px;
  border: 1px solid;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
}

.badge-late {
  border-color: var(--error);
  background: var(--alert-bg);
  color: var(--error);
}

.badge-spam {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.badge-stale {
  border-color: var(--line-strong);
  border-style: dashed;
  color: var(--ink-2);
}

.card-foot {
  display: grid;
  gap: 8px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.move-select {
  width: 100%;
  min-height: 36px;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background-color: var(--paper);
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.move-select:hover {
  border-color: var(--ink);
}

.move-select:focus-visible {
  outline-offset: 2px;
}

/* Táctil: objetivos de 44 px y 16 px de letra para que iOS no haga zoom al enfocar. */
@media (pointer: coarse) {
  .move-select {
    min-height: 44px;
    font-size: 1rem;
  }

  .card-name {
    padding-block: 6px;
  }
}

/* Carga: esqueleto con el mismo esqueleto del tablero. */
.skeleton-line {
  display: block;
  height: 0.75rem;
  margin-block: 6px;
  background: var(--line);
}

.w-25 { width: 25%; }
.w-45 { width: 45%; }
.w-70 { width: 70%; }
.w-85 { width: 85%; }

.skeleton-title {
  width: 40%;
  height: 2rem;
}

.skeleton-block {
  width: 90%;
  height: 8rem;
}

.skeleton-card {
  display: grid;
  gap: 4px;
  padding: 14px 12px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.detail-skeleton {
  display: grid;
  gap: 12px;
  padding-block: 32px;
}

/* ---------- Diálogo ---------- */

.dialog {
  width: min(32rem, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  overflow: auto;
  overscroll-behavior: contain;
}

.dialog::backdrop {
  background: rgb(22 20 26 / 0.45);
}

body:has(dialog[open]) {
  overflow: hidden;
}

.dialog-form {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.dialog-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dialog-sub {
  margin: -8px 0 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.dialog .form-actions {
  flex-direction: row;
  flex-wrap: wrap;
}

.dialog textarea {
  min-height: 84px;
}

/* ---------- Detalle ---------- */

.detail {
  padding-block: 8px 72px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.back::before {
  content: "";
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease-out);
}

.back:hover {
  color: var(--ink);
}

.back:hover::before {
  transform: translateX(-2px) rotate(45deg);
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 32px;
  margin: 8px 0 16px;
}

.detail-sub {
  margin: 6px 0 0;
  color: var(--ink-2);
}

.state-field {
  min-width: 14rem;
}

.state-pill {
  margin: 0;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  font-weight: 600;
}

.detail-badges {
  margin: 0 0 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 8px clamp(24px, 4vw, 56px);
  margin-top: 24px;
}

.panel {
  margin: 0 0 32px;
  padding-top: 14px;
  border-top: 1px solid var(--ink);
}

.panel-title {
  margin: 0 0 16px;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.kvs {
  display: grid;
  gap: 10px;
  margin: 0;
}

.kv {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 12px;
}

.kv dt {
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.kv.is-late dd {
  color: var(--error);
  font-weight: 600;
}

.kv a {
  text-underline-offset: 3px;
}

.message {
  margin: 0;
  max-width: 68ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-importado {
  display: grid;
  gap: 7px;
  max-width: none;
  white-space: normal;
}

.message-line,
.message-item {
  margin: 0;
  line-height: 1.55;
}

.message-item {
  position: relative;
  padding-left: 16px;
}

.message-item::before {
  content: "•";
  position: absolute;
  left: 2px;
  color: var(--ink-2);
}

.message-field {
  display: grid;
  grid-template-columns: minmax(7rem, .6fr) minmax(0, 1.4fr);
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
}

.message-field strong {
  color: var(--ink-2);
  font-size: .8125rem;
}

.message-field span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.message-space { height: 8px; }
.message.is-empty { color: var(--ink-2); }

@media (max-width: 520px) {
  .message-field { grid-template-columns: 1fr; gap: 3px; }
}

.edit-form {
  display: grid;
  gap: 18px;
  align-content: start;
}

.edit-form .panel-title {
  margin: 0;
}

.timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  padding: 0 0 22px 22px;
  border-left: 1px solid var(--line-strong);
  margin-left: 3px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -5px;
  width: 9px;
  height: 9px;
  background: var(--ink);
}

.timeline-item:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}

.timeline-head {
  margin: 0 0 4px;
}

.timeline-head time {
  color: var(--ink-2);
  font-size: 0.875rem;
}

.timeline-changes {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

/* ---------- Barra lateral: un espacio de trabajo a la vez ---------- */

.brand {
  margin-right: auto;
}

body.con-lateral {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

body.con-lateral > .dash-header {
  grid-column: 1 / -1;
  grid-row: 1;
}

body.con-lateral > main {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
}

.dash-side {
  grid-column: 1;
  grid-row: 2;
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  padding: 16px 12px 24px max(12px, env(safe-area-inset-left, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.dash-side[hidden] {
  display: none;
}

.lateral-cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 8px;
}

.lateral-titulo {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lateral-cerrar,
.dash-menu,
.lateral-velo {
  display: none;
}

.lateral-lista {
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.lateral-espacios {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 4px 14px;
  padding: 4px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}

.lateral-espacio {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.lateral-espacio.is-active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(22, 20, 26, 0.1);
}

.lateral-espacio:focus-visible,
.lateral-ajustes:focus-visible,
.lateral-filtro select:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.lateral-filtro {
  display: grid;
  gap: 6px;
  margin: 0 4px 14px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lateral-filtro select {
  width: 100%;
  min-height: 42px;
  padding: 8px 32px 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.lateral-link {
  position: relative;
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 58px;
  padding: 8px 12px;
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: color 0.15s ease, background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.lateral-link-etiqueta {
  color: inherit;
  font-weight: inherit;
}

.lateral-link-ayuda {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.lateral-link::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 2px;
  background: var(--ink);
  transform: scaleY(0);
  transition: transform 0.2s var(--ease-out);
}

@media (hover: hover) {
  .lateral-link:hover {
    background: color-mix(in srgb, var(--line) 50%, transparent);
    color: var(--ink);
  }
}

.lateral-link:active {
  background: var(--line);
}

.lateral-link[aria-current="page"] {
  background: color-mix(in srgb, var(--line) 70%, transparent);
  color: var(--ink);
  font-weight: 600;
}

.lateral-link[aria-current="page"]::before {
  transform: scaleY(1);
}

.lateral-ajustes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  margin: 16px 4px 0;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.lateral-ajustes[aria-current="page"],
.lateral-ajustes:hover {
  color: var(--ink);
}

.lateral-link:focus-visible,
.lateral-cerrar:focus-visible,
.dash-menu:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.lateral-sub .lateral-link {
  min-height: 40px;
  margin-left: 18px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
  font-size: 0.875rem;
}

.lateral-sub .lateral-link::before {
  inset: 6px auto 6px -1px;
}

@media (max-width: 860px) {
  body.con-lateral {
    display: block;
  }

  .dash-menu {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 12px 0 0;
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .dash-menu[hidden] {
    display: none;
  }

  .dash-menu-icono,
  .dash-menu-icono::before,
  .dash-menu-icono::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
  }

  .dash-menu-icono {
    position: relative;
  }

  .dash-menu-icono::before,
  .dash-menu-icono::after {
    content: "";
    position: absolute;
    left: 0;
  }

  .dash-menu-icono::before {
    top: -6px;
  }

  .dash-menu-icono::after {
    top: 6px;
  }

  .dash-side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(86vw, 320px);
    height: 100vh;
    height: 100dvh;
    padding: max(16px, env(safe-area-inset-top, 0px)) 12px max(24px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    border-right: 1px solid var(--line-strong);
    visibility: hidden;
    transform: translateX(-100%);
  }

  .lateral-cerrar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-right: -12px;
    border: 0;
    background: none;
    color: var(--ink);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
  }

  .lateral-velo {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(22, 20, 26, 0.45);
    opacity: 0;
    pointer-events: none;
  }

  body.lateral-abierta {
    overflow: hidden;
  }

  body.lateral-abierta .dash-side {
    visibility: visible;
    transform: none;
  }

  body.lateral-abierta .lateral-velo {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 860px) and (prefers-reduced-motion: no-preference) {
  .dash-side {
    transition: transform 0.28s var(--ease-out), visibility 0s linear 0.28s;
  }

  body.lateral-abierta .dash-side {
    transition: transform 0.28s var(--ease-out);
  }

  .lateral-velo {
    display: block;
    transition: opacity 0.2s ease;
  }
}

@media (max-width: 640px) {
  .dash-menu-texto {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .dash-menu {
    padding-right: 4px;
  }
}

/* ---------- SteveLab: listas, resumen y brief ---------- */

.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stats-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.brief-catalogo {
  margin-bottom: 24px;
}

.brief-catalogo-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brief-catalogo-intro .panel-title {
  margin-bottom: 12px;
}

.brief-catalogo-intro .panel-sub {
  margin: 0;
}

.brief-catalogo-intro > .badge {
  flex: none;
}

.brief-catalogo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line-strong);
}

.brief-catalogo-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: clamp(18px, 3vw, 28px);
}

.brief-catalogo-card + .brief-catalogo-card {
  border-left: 1px solid var(--line-strong);
}

.brief-catalogo-cab {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brief-catalogo-cab h3 {
  margin: 0;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.brief-catalogo-num {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brief-catalogo-descripcion,
.brief-catalogo-url {
  margin: 0;
}

.brief-catalogo-descripcion {
  max-width: 58ch;
  color: var(--ink-2);
  line-height: 1.55;
}

.brief-catalogo-url {
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.brief-catalogo-acciones,
.fila-acciones,
.fila-estado,
.brief-revision-secciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brief-catalogo-acciones {
  align-self: end;
  margin-top: 4px;
}

.lista {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fila {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr) 8.5rem 7.5rem;
  align-items: center;
  gap: 8px 20px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.fila-invitacion {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.35fr) minmax(11rem, auto) minmax(15rem, auto);
}

.fila:first-child {
  border-top: 0;
}

.fila-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.fila-nombre {
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.fila-sub,
.fila-meta {
  color: var(--ink-2);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.fila-tenue {
  color: var(--muted);
  font-size: 0.875rem;
}

.fila-accion {
  display: flex;
  justify-content: flex-end;
}

.fila-acciones {
  justify-content: flex-end;
}

/* Toda la fila de un brief es el enlace: el área de toque es grande en el celular. */
.fila-link .fila-nombre::after {
  content: "";
  position: absolute;
  inset: 0;
}

.fila-link .fila-nombre:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.fila-link .fila-nombre:focus-visible {
  outline: none;
}

.fila-link:has(.fila-nombre:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.fila-link .fila-estado {
  grid-column: 4;
  justify-self: end;
}

.fila-link:hover {
  background: var(--paper-2);
}

.fila .btn {
  position: relative;
  z-index: 1;
}

.fila-link {
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr) 8.5rem 7.5rem auto;
}

.btn-danger {
  border-color: #b42318;
  background: #b42318;
  color: #fff;
}

.btn-danger:disabled {
  opacity: 0.6;
}

/* Eliminar: discreto hasta que se necesita; el rojo aparece al apuntarlo. */
.btn-eliminar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-eliminar svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn-eliminar:hover,
.btn-eliminar:focus-visible {
  color: #b42318;
  border-color: #b42318;
}

.dialog-check {
  margin: 4px 0 12px;
}

.badge-done {
  border-color: var(--ink);
  background: var(--paper);
  color: var(--ink);
}

.badge-wait {
  border-color: var(--line-strong);
  background: var(--paper-2);
  color: var(--ink-2);
}

.lista-esqueleto {
  display: grid;
  gap: 8px;
}

.brief-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
}

.brief-mensaje {
  margin-top: 20px;
}

.brief-revision {
  display: grid;
  gap: 6px;
  margin: 0 0 24px;
  padding: 14px 16px;
  border-left: 3px solid var(--ink);
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 0.875rem;
}

.brief-revision strong {
  color: var(--ink);
  font-size: 1rem;
}

.brief-revision-secciones {
  margin-top: 4px;
}

.qa-grupo + .qa-grupo {
  margin-top: 24px;
}

.qa-seccion {
  margin: 0 0 10px;
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.qa {
  display: grid;
  gap: 16px;
  margin: 0;
}

.qa-item {
  display: grid;
  gap: 4px;
}

.qa-item dt {
  font-weight: 700;
}

.qa-item dd {
  margin: 0;
}

.qa-item .message {
  max-width: 68ch;
}

@media (max-width: 860px) {
  .brief-catalogo-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .brief-catalogo-card + .brief-catalogo-card {
    border-top: 1px solid var(--line-strong);
    border-left: 0;
  }

  .brief-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .fila {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .fila-meta {
    grid-column: 1;
    grid-row: 2;
  }

  .fila-estado,
  .fila-link .fila-estado {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .fila-accion {
    grid-column: 2;
    grid-row: 2;
    justify-content: flex-end;
  }

  .fila-meta {
    align-self: center;
  }

  .fila-link {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .fila-invitacion {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .fila-link .fila-meta {
    grid-column: 1 / -1;
  }

  .fila-link .fila-accion {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .btn-eliminar {
    min-height: 44px;
  }
}

@media (max-width: 560px) {
  .brief-catalogo-intro {
    display: grid;
  }

  .brief-catalogo-acciones .btn,
  .fila-acciones .btn {
    width: 100%;
  }

  .fila-invitacion .fila-estado,
  .fila-invitacion .fila-accion {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .fila-invitacion .fila-estado {
    grid-row: 3;
  }

  .fila-invitacion .fila-accion {
    grid-row: 4;
  }
}

/* ---------- Movimiento (solo si la persona no pidió menos) ---------- */

@media (prefers-reduced-motion: no-preference) {
  .card.is-landed {
    animation: aterrizar 0.32s var(--ease-out);
  }

  .dialog[open] {
    animation: dialogo-entra 0.24s var(--ease-out);
  }

  .dialog[open]::backdrop {
    animation: fundido 0.24s ease-out;
  }

  .skeleton-line {
    background: linear-gradient(90deg, var(--line) 0%, var(--paper-2) 50%, var(--line) 100%);
    background-size: 200% 100%;
    animation: brillo 1.4s linear infinite;
  }

  @keyframes aterrizar {
    from {
      opacity: 0.5;
      transform: scale(0.97);
    }
  }

  @keyframes dialogo-entra {
    from {
      opacity: 0;
      transform: translateY(8px) scale(0.98);
    }
  }

  @keyframes fundido {
    from {
      opacity: 0;
    }
  }

  @keyframes brillo {
    to {
      background-position: -200% 0;
    }
  }
}

/* ---------- Pantallas medianas y celulares ---------- */

@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat:nth-child(3n + 1) {
    padding-left: 0;
    border-left: 0;
  }

  .stat:nth-child(n + 4) {
    margin-top: 8px;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 860px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .dash-user-name {
    display: none;
  }



  .stats-3 .stat:first-child {
    padding-left: 0;
  }

  .dash-head {
    flex-wrap: wrap;
  }

  .head-actions {
    flex: 1 1 100%;
  }

  .head-actions .btn {
    flex: 1 1 0;
  }

  .dash-head {
    padding-block: 20px 14px;
  }

  .pipeline-manual {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
  }

  .pipeline-manual-icono {
    width: 42px;
    height: 42px;
  }

  .pipeline-manual-accion {
    grid-column: 2;
    white-space: normal;
  }

  /* En el celular las startups van en una tira que se desliza. */
  .stats {
    display: flex;
    width: max-content;
    min-width: 100%;
  }

  .stat,
  .stat:nth-child(n) {
    flex: 0 0 9.5rem;
    margin-top: 0;
    padding: 12px 14px 8px 14px;
    border-top: 0;
    border-left: 1px solid var(--line);
    scroll-snap-align: start;
  }

  .stat:first-child {
    padding-left: 0;
    border-left: 0;
  }

  .stats.stats-3 {
    display: grid;
    width: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-3 .stat,
  .stats-3 .stat:nth-child(n) {
    flex: none;
    padding: 12px 8px 8px 10px;
  }

  .stats-3 .stat:first-child {
    padding-left: 0;
  }

  .stats-3 .stat dt {
    font-size: 0.8125rem;
  }

  .by-startup {
    display: block;
  }

  .by-startup-label {
    margin-bottom: 8px;
  }

  .chips-scroll {
    margin-inline: calc(var(--gl) * -1) calc(var(--gr) * -1);
    padding-inline: var(--gl) var(--gr);
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .chips {
    flex-wrap: nowrap;
    width: max-content;
  }

  .chip {
    flex: none;
    white-space: nowrap;
  }

  /* Con puntero fino (mouse) la barra fina se ve y sirve de pista; en pantallas táctiles el deslizar basta. */
  .chips-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }

  @media (hover: none) {
    .chips-scroll {
      scrollbar-width: none;
    }

    .chips-scroll::-webkit-scrollbar {
      display: none;
    }
  }

  .kv {
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: 8px;
  }

  .state-field {
    width: 100%;
  }

  /* Hoja desde abajo, como en una app nativa. */
  .dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    margin: auto 0 0;
    border-inline: 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .dialog-form {
    padding: 20px var(--gl) 20px var(--gl);
  }

  .dialog .form-actions .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 640px) and (prefers-reduced-motion: no-preference) {
  .dialog[open] {
    animation: hoja-entra 0.28s var(--ease-out);
  }

  @keyframes hoja-entra {
    from {
      transform: translateY(32px);
      opacity: 0;
    }
  }
}

/* ---------- Etiquetas ---------- */

/* Cada color define fondo, texto y borde. El texto contrasta al menos 4,5:1 con el fondo (lo comprueba la prueba de etiquetas). */
.tag[data-color="gris"], .tag-swatch[data-color="gris"] { --tag-bg: #ececf0; --tag-fg: #3a3742; --tag-bd: #b9b6c2; }
.tag[data-color="rojo"], .tag-swatch[data-color="rojo"] { --tag-bg: #fde3e1; --tag-fg: #8f1a12; --tag-bd: #f0a9a4; }
.tag[data-color="naranja"], .tag-swatch[data-color="naranja"] { --tag-bg: #ffe8d1; --tag-fg: #7a3a00; --tag-bd: #f5b97f; }
.tag[data-color="amarillo"], .tag-swatch[data-color="amarillo"] { --tag-bg: #fff3bf; --tag-fg: #5e4700; --tag-bd: #e6cf62; }
.tag[data-color="verde"], .tag-swatch[data-color="verde"] { --tag-bg: #dcf3df; --tag-fg: #1b5e2a; --tag-bd: #91cf9b; }
.tag[data-color="turquesa"], .tag-swatch[data-color="turquesa"] { --tag-bg: #d3f3f2; --tag-fg: #0b5557; --tag-bd: #84d0cf; }
.tag[data-color="azul"], .tag-swatch[data-color="azul"] { --tag-bg: #dbe8fd; --tag-fg: #133f8c; --tag-bd: #9dbcf0; }
.tag[data-color="violeta"], .tag-swatch[data-color="violeta"] { --tag-bg: #e9e0ff; --tag-fg: #4a1fa8; --tag-bd: #bfa8f5; }
.tag[data-color="rosa"], .tag-swatch[data-color="rosa"] { --tag-bg: #fde1ef; --tag-fg: #8a1650; --tag-bd: #f2a6c9; }
.tag[data-color="marron"], .tag-swatch[data-color="marron"] { --tag-bg: #eee2d8; --tag-fg: #5a3a22; --tag-bd: #cbad94; }

.tag {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  padding: 1px 8px;
  border: 1px solid var(--tag-bd, var(--line-strong));
  background: var(--tag-bg, var(--paper-2));
  color: var(--tag-fg, var(--ink));
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
}

.tag-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tarjeta: hasta 3 etiquetas y "+N". Cada nombre se corta con puntos suspensivos a 9 rem, así una etiqueta larga no ensancha ni estira la tarjeta. */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.card-tag {
  display: flex;
  min-width: 0;
  max-width: min(9rem, 100%);
}

.card-tag-more {
  max-width: none;
}

.tag-more {
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* Editor del detalle */

.tag-editor {
  position: relative;
}

.tag-box {
  padding: 6px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  cursor: text;
  transition: border-color 0.2s ease;
}

.tag-box:hover,
.tag-box:focus-within {
  border-color: var(--ink);
}

.tag-box:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-item {
  display: flex;
  min-width: 0;
  max-width: 100%;
}

.tag-edit {
  padding: 0;
  font-size: 0.875rem;
  transition: opacity 0.15s ease, transform 0.15s var(--ease-out);
}

.tag-edit.is-pending {
  opacity: 0.6;
}

.tag-edit.is-open {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.tag-name,
.tag-x {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tag-name {
  min-width: 0;
  padding: 2px 4px 2px 10px;
  text-align: left;
}

.tag-x {
  justify-content: center;
  width: 34px;
  padding: 0;
  font-size: 1.125rem;
  line-height: 1;
}

.tag-name:hover,
.tag-x:hover {
  background: rgba(22, 20, 26, 0.08);
}

.tag-name:active,
.tag-x:active {
  background: rgba(22, 20, 26, 0.14);
}

.tag-name:focus-visible,
.tag-x:focus-visible {
  outline-offset: -3px;
}

.tag-name:disabled,
.tag-x:disabled {
  cursor: progress;
}

.tag-entry {
  flex: 1 1 150px;
  min-width: 120px;
}

.tag-entry[hidden],
.tag-add-item[hidden] {
  display: none;
}

.tag-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.tag-add-plus {
  font-size: 1.125rem;
  line-height: 1;
  font-weight: 500;
}

@media (hover: hover) {
  .tag-add:hover {
    border-color: var(--ink);
    color: var(--ink);
  }
}

.tag-add:active {
  background: var(--line);
}

.tag-add:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.tag-add.is-full {
  color: var(--muted);
  cursor: not-allowed;
}

.tag-input {
  width: 100%;
  min-height: 34px;
  padding: 4px 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* 16 px: el iPhone no hace zoom al enfocar */
}

.tag-input:focus-visible {
  outline: none;
}

.tag-input::placeholder {
  color: var(--muted);
}

.tag-options {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 264px;
  margin: 4px 0 0;
  padding: 4px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(22, 20, 26, 0.14);
  list-style: none;
}

.tag-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.9375rem;
}

.tag-option:hover {
  background: var(--paper-2);
}

.tag-option[aria-selected="true"] {
  background: var(--paper-2);
  box-shadow: inset 3px 0 0 var(--ink);
}

.tag-option-new {
  border-top: 1px solid var(--line);
  font-weight: 600;
}

.tag-option-plus {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  line-height: 1;
}

.tag-option-empty {
  padding: 12px;
  color: var(--ink-2);
  font-size: 0.875rem;
}

.tag-error {
  margin-top: 12px;
  margin-bottom: 0;
}

.tag-editor .field-help {
  margin-top: 8px;
}

.tag-palette {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper-2);
}

.tag-palette p {
  margin: 0;
}

.tag-palette-title {
  font-size: 0.9375rem;
}

.tag-swatches {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.tag-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  padding: 4px 2px;
  border: 2px solid var(--tag-bd);
  background: var(--tag-bg);
  color: var(--tag-fg);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out);
}

.tag-swatch:active {
  transform: scale(0.95);
}

.tag-swatch[aria-pressed="true"] {
  border-color: var(--ink);
}

.tag-swatch:focus-visible {
  outline-offset: 2px;
}

/* Filtro del tablero */

.tag-filter {
  position: relative;
}

.select-btn {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-filter-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  width: min(340px, calc(100vw - 2 * var(--gutter)));
  max-height: min(380px, 60dvh);
  margin-top: 4px;
  padding: 4px 12px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(22, 20, 26, 0.14);
}

.tag-filter-panel .check {
  gap: 10px;
  min-width: 0;
}

.tag-filter-panel .check .tag {
  flex: 0 1 auto;
}

.tag-filter-n {
  margin-left: auto;
  color: var(--ink-2);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.tag-filter-help {
  margin: 4px 0 4px;
  color: var(--ink-2);
  font-size: 0.8125rem;
}

/* Con el dedo, los controles de las etiquetas llegan a 44 px. */
@media (pointer: coarse) {
  .tag-name,
  .tag-x {
    min-height: 44px;
  }

  .tag-x {
    width: 44px;
  }

  .tag-input {
    min-height: 44px;
  }

  .tag-add {
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  /* En celular el panel empuja el contenido en vez de flotar: nunca se sale de la pantalla. */
  .tag-filter-panel {
    position: static;
    width: auto;
    max-height: 50dvh;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .tag-options:not([hidden]),
  .tag-filter-panel:not([hidden]),
  .tag-palette:not([hidden]) {
    animation: tag-abre 0.16s var(--ease-out);
  }

  @keyframes tag-abre {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
  }
}

/* ---------- Notas de venta ---------- */

/* Resumen: la cifra en pesos es la más larga, así que su columna es la más ancha. */
.stats.stats-nv {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1fr);
}

.stats-nv .stat-num {
  overflow-wrap: anywhere;
}

/* Lista: N°, cliente, servicio y fecha, total y estado. Con la barra lateral abierta el espacio se acaba antes, por eso pasa a dos líneas a 1000 px. */
.fila.fila-nv {
  grid-template-columns: 5.25rem minmax(0, 2fr) minmax(0, 1.4fr) 7.5rem 6.5rem;
}

.nv-num {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.nv-celda-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.nv-total {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.nv-celda-estado {
  display: flex;
  justify-content: flex-end;
}

/* Una nota anulada se apaga: el total tachado y el nombre en gris dicen que ya no vale sin gritar. */
.fila-nv.is-anulada .fila-nombre,
.fila-nv.is-anulada .nv-num {
  color: var(--muted);
}

.fila-nv.is-anulada .nv-total {
  color: var(--muted);
  font-weight: 500;
  text-decoration: line-through;
}

.badge-anulada {
  border-color: var(--line-strong);
  background: var(--paper);
  color: var(--ink-2);
  text-decoration: line-through;
}

@media (max-width: 1000px) {
  .fila.fila-nv {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "num estado"
      "main main"
      "meta total";
    gap: 2px 12px;
    padding-block: 14px;
  }

  .fila-nv .nv-num {
    grid-area: num;
  }

  .fila-nv .fila-main {
    grid-area: main;
  }

  .fila-nv .nv-celda-meta {
    grid-area: meta;
  }

  .fila-nv .nv-total {
    grid-area: total;
    align-self: end;
  }

  .fila-nv .nv-celda-estado {
    grid-area: estado;
  }
}

/* Detalle */

.nv-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.nv-razon {
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.nv-estado {
  display: grid;
  gap: 4px;
  margin: 0 0 8px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--ink);
  background: var(--paper-2);
}

.nv-estado.is-anulada {
  border-color: var(--error);
  background: var(--alert-bg);
}

.nv-estado-titulo,
.nv-estado-detalle,
.nv-estado .message {
  margin: 0;
}

.nv-estado-titulo {
  font-weight: 600;
}

.nv-estado-detalle {
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.btn-anular:focus-visible {
  border-color: #b42318;
  color: #b42318;
}

@media (hover: hover) and (pointer: fine) {
  .btn-anular:hover {
    border-color: #b42318;
    color: #b42318;
  }
}

.nv-detalle {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr);
}

.nv-kvs-servicio {
  margin-bottom: 20px;
}

.nv-tabla {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.nv-tabla th {
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--ink);
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
}

.nv-tabla td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.nv-tabla .num {
  text-align: right;
  white-space: nowrap;
}

.nv-tabla th:last-child,
.nv-tabla td:last-child {
  padding-right: 0;
}

.nv-item-titulo {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.nv-item-desc {
  margin: 2px 0 0;
  color: var(--ink-2);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Neto, IVA y total: el mismo bloque en el detalle y en el formulario. */
.nv-totales {
  display: grid;
  gap: 6px;
  width: min(100%, 24rem);
  margin: 20px 0 0 auto;
}

.nv-total-fila {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-variant-numeric: tabular-nums;
}

.nv-total-fila dt {
  color: var(--ink-2);
}

.nv-total-fila dd {
  margin: 0;
  font-weight: 500;
}

.nv-total-final {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--ink);
}

.nv-total-final dt {
  color: var(--ink);
  font-weight: 600;
}

.nv-total-final dd {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

/* Formulario */

.panel-sub {
  max-width: 60ch;
  margin: -8px 0 18px;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.nv-form {
  display: grid;
  max-width: 62rem;
}

.nv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 18px 24px;
}

.nv-ancho {
  grid-column: 1 / -1;
}

/* Los textos largos parten bajos y crecen si hace falta: la base de ../styles.css es de un formulario de contacto. */
.nv-form .field textarea {
  min-height: 5.5rem;
}

.nv-linea .field textarea {
  min-height: 4.5rem;
}

.field-cab {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.nv-req {
  color: var(--ink-2);
}

.nv-opc {
  color: var(--muted);
  font-weight: 400;
}

.contador {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.contador.is-over {
  color: var(--error);
  font-weight: 600;
}

.nv-subtitulo {
  margin: 28px 0 4px;
  font-size: 1rem;
  font-weight: 600;
}

.nv-lineas {
  display: grid;
  margin-top: 8px;
}

.nv-linea {
  display: grid;
  gap: 14px;
  padding: 16px 0 20px;
  border-bottom: 1px solid var(--line);
}

.nv-linea:first-child {
  border-top: 1px solid var(--ink);
}

.nv-linea-cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nv-linea-titulo {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.nv-linea-texto {
  display: grid;
  gap: 14px;
}

.nv-linea-nums {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) 7rem minmax(8rem, auto);
  align-items: start;
  gap: 14px 16px;
}

.nv-linea-nums input {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* El subtotal se alinea con los campos: una línea de rótulo y un alto de campo. */
.nv-linea-sub {
  display: grid;
  gap: 8px;
  align-content: start;
  margin: 0;
  text-align: right;
}

.nv-linea-sub-etiqueta {
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 500;
}

.nv-linea-sub-valor {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 48px;
  font-size: 1.0625rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.nv-agregar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 16px;
}

.nv-agregar .field-help {
  margin: 0;
}

.nv-iva {
  margin-top: 20px;
}

.nv-ayuda-iva {
  margin: -4px 0 0 32px;
}

/* Barra de abajo: el total siempre a la vista mientras se arma la nota, y las dos formas de guardar. */
.nv-barra {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--ink);
  background: var(--paper);
}

.nv-barra-fila {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}

.nv-barra-resumen {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
}

.nv-barra-etiqueta {
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 500;
}

.nv-barra-total {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.nv-barra .form-actions {
  gap: 8px 12px;
}

.nv-barra .form-alert {
  margin: 0;
}

.nv-barra .form-status:empty {
  display: none;
}

/* Al enfocar un campo, el navegador lo deja por encima de la barra fija. */
.nv-form :is(input, select, textarea, button) {
  scroll-margin-bottom: 9rem;
}

@media (max-width: 1180px) {
  .nv-detalle {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .stats.stats-nv .stat-num {
    font-size: clamp(1.0625rem, 5.4vw, 1.5rem);
  }

  .nv-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .nv-linea-nums {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  }

  /* En el celular la barra va al final del formulario: con el teclado abierto una barra fija taparía los campos. */
  .nv-barra {
    position: static;
    margin-top: 16px;
  }

  .nv-barra .form-actions .btn {
    flex: 1 1 auto;
  }

  .nv-totales {
    width: 100%;
  }

  /* La tabla de ítems pasa a una tarjeta por ítem. Los roles de la tabla están escritos en el HTML para que no se pierda su semántica. */
  .nv-tabla thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .nv-tabla,
  .nv-tabla tbody,
  .nv-tabla tr {
    display: block;
  }

  .nv-tabla tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }

  .nv-tabla td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 0;
    border: 0;
    text-align: right;
  }

  .nv-tabla td::before {
    content: attr(data-etiqueta);
    color: var(--ink-2);
    font-size: 0.875rem;
    text-align: left;
  }

  .nv-tabla td.nv-item-nombre {
    display: block;
    padding-bottom: 6px;
    text-align: left;
  }

  .nv-tabla td.nv-item-nombre::before {
    content: none;
  }

  .nv-tabla td:last-child {
    font-weight: 600;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .nv-linea.es-nueva {
    animation: nv-linea-entra 0.18s var(--ease-out);
  }

  @keyframes nv-linea-entra {
    from {
      opacity: 0;
      transform: translateY(-6px);
    }
  }
}

/* Seguimiento comercial: el color acompaña una etiqueta explícita. */
.card.card-sin-agenda { border-top: 4px solid #e6b62e; }
.card-contacto { margin: 12px 0 7px; font-size: 11px; line-height: 1.6; color: #65546e; }
.card-agenda-aviso { font-size: 11px; color: #815e00; margin: 7px 0; font-weight: 550; }

tr.fila-sin-agenda > th, tr.fila-sin-agenda > td { border-top: 3px solid #e6b62e; }

/* Ficha del lead: Respuestas de Explee (análisis de IA, próximos pasos y borrador para copiar). */
#explee-panel .panel-subtitle {
  margin: 20px 0 8px;
  font-size: 0.9375rem;
  font-weight: 600;
}
#explee-panel .muted {
  color: var(--muted, #6b6776);
}
#explee-panel .explee-pasos {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}
#explee-panel .explee-pasos p {
  margin: 2px 0 0;
}

/* Correos: la conversación con el prospecto como bandeja de entrada (ficha y vista rápida). */
.correos-lista {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.correo-fila + .correo-fila { border-top: 1px solid var(--line); }
.correo-cab {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding: 12px 14px;
  list-style: none;
}
.correo-cab::-webkit-details-marker { display: none; }
summary.correo-cab { cursor: pointer; }
summary.correo-cab:hover { background: #faf9fb; }
.correo-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: #2f6fb3;
}
.correo-fila.is-samir .correo-avatar { background: #3f7d4f; }
.correo-fila.is-automatico .correo-avatar { background: #8a7a4b; }
.correo-fila.is-cierre .correo-avatar { background: #b34b4b; }
.correo-cab-texto { min-width: 0; }
.correo-cab-texto p { margin: 0; }
.correo-linea1 {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
.correo-linea1 time {
  flex: none;
  font-size: 12px;
  color: var(--muted);
}
.correo-asunto {
  margin-top: 2px !important;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.correo-resumen {
  margin-top: 2px !important;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.correo-detalle[open] .correo-resumen { display: none; }
.correo-texto {
  margin: 0;
  padding: 0 14px 16px 58px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.correos-resumen {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--violet, #8c52ff);
  background: var(--paper, #fff);
}
.correos-resumen-t {
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.correos-resumen-texto,
.correos-resumen-paso {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.correos-resumen-puntos {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.5;
}
.correos-resumen-pie {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.correo-programados {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}
.tarea-cuerpo {
  margin: 6px 0 0;
  white-space: pre-line;
  font-size: 13px;
  line-height: 1.5;
}
.tarea-despues {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted, #6b6776);
}
