/* Panel del equipo → «Carta» (js/equipo-carta.js)
   Configurar servicios, combos y bonos, ofertas y categorías.
   Piel "Glovo adulto": reutiliza components.css (.btn, .chip, .tag, .cat-mini,
   .cat-block, .tone-1…5, .choice, .consent, .stepper, .switch de equipo.css)
   y solo añade la maqueta propia con el prefijo .ct-.
   Móvil primero (320 / 390); ≥720 filas en una línea; ≥1000 hoja con vista previa al lado. */

/* ---------- Sección ---------- */
.carta { scroll-margin-top: 16px; }
.ct-head { display: flex; align-items: flex-start; gap: 10px; }
.ct-head .grow { min-width: 0; }
/* Modo demo: los cambios viven en este navegador (aviso, no bloqueo) */
.ct-demo-note { margin-top: 14px; color: var(--ink); background: var(--plum-soft); line-height: 1.45; }
.ct-demo-note b { font-weight: 700; }
.top-to-carta { margin-top: 14px; }

/* Selector segmentado: 2×2 en móvil, 4 en fila desde 560 */
.ct-seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.ct-seg button {
  min-height: var(--tap);
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-chip);
  background: var(--card);
  font-size: var(--fs-min);
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.ct-seg button:active { transform: scale(.97); }
.ct-seg button[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
@media (hover: hover) {
  .ct-seg button:not([aria-selected="true"]):hover { border-color: var(--line-2); }
}
@media (min-width: 560px) {
  .ct-seg { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.ct-pane { margin-top: 14px; outline: none; min-width: 0; }
.ct-loading { display: flex; align-items: center; gap: 12px; padding: 24px 2px; color: var(--ink-2); font-weight: 500; }
.ct-loading .spin { border-color: var(--line-2); border-top-color: var(--plum); }

/* Barra: recuento + «Nuevo …» */
.ct-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; }
.ct-count { font-size: var(--fs-min); font-weight: 500; color: var(--ink-2); line-height: 1.35; }
.ct-new { margin-left: auto; }
.ct-tip { margin-top: 10px; }

/* Grupos (por categoría / combos y bonos) */
.ct-group { margin-top: 20px; min-width: 0; }
.ct-ghead { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-bottom: 10px; }
.ct-ghead h3 { font: 600 var(--fs-body)/1.3 var(--f-ui); color: var(--ink); }
.ct-ghead .chip { padding: 4px 10px; }
.ct-ghead .ico-tile { width: 36px; height: 36px; }
.ct-n { margin-left: auto; font-weight: 600; color: var(--ink-2); }
.ct-gsub { flex-basis: 100%; font-size: var(--fs-min); color: var(--ink-2); }
.ct-mini-s { width: 36px; height: 36px; border-radius: var(--r-xs); }
.ct-mini-s .ico { width: 20px; height: 20px; }
.ct-group.is-system .ct-ghead h3 { color: var(--ink-2); }

.ct-gempty, .ct-empty {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 14px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-card);
  color: var(--ink-2);
  font-size: var(--fs-min);
  line-height: 1.45;
}
.ct-empty { justify-items: center; text-align: center; padding: 24px 16px; margin-top: 14px; }
.ct-empty b { color: var(--ink); font-weight: 600; }

/* ---------- Lista ordenable ---------- */
.ct-list {
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  min-width: 0;
}
.ct-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  min-width: 0;
  background: var(--card);
}
.ct-row:first-child { border-radius: var(--r-card) var(--r-card) 0 0; }
.ct-row:last-child { border-bottom: 0; border-radius: 0 0 var(--r-card) var(--r-card); }
.ct-row:only-child { border-radius: var(--r-card); }

/* Toda la fila (menos las herramientas) abre la hoja */
.ct-open {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 72px;
  padding: 12px 12px 6px;
  border: 0;
  border-radius: var(--r-card);
  background: none;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out);
}
@media (hover: hover) {
  .ct-open:hover { background: var(--bg); }
}
.ct-open:active { background: var(--fill); }
.ct-tx { display: grid; gap: 2px; min-width: 0; flex: 1; }
.ct-name { font-weight: 600; font-size: var(--fs-body); color: var(--ink); line-height: 1.3; overflow-wrap: anywhere; }
.ct-meta { font-size: var(--fs-min); color: var(--ink-2); line-height: 1.4; overflow-wrap: anywhere; }
.ct-p { font-variant-numeric: lining-nums tabular-nums; }
.ct-p b, .ct-p s, .ct-p small { white-space: nowrap; }
.ct-p b { color: var(--ink); font-weight: 700; }
.ct-p small { font-size: var(--fs-min); color: var(--ink-2); }
.ct-was { color: var(--ink-2); text-decoration-thickness: 1.5px; font-weight: 400; }
.ct-p .ct-now, .ct-now { color: var(--plum); font-weight: 700; }
.ct-go { flex: none; color: var(--ink-2); display: grid; place-items: center; }
.ct-go .ico { width: 20px; height: 20px; }

.ct-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ct-chips .chip, .ct-chips .tag { padding: 4px 10px; white-space: normal; }
.ct-chip .ico { width: 16px; height: 16px; }
.ct-chip.ct-off { background: var(--plum-soft); color: var(--plum); font-weight: 600; }
.ct-chip.ct-off .ico { color: var(--plum); }
.ct-warn-t { color: var(--st-notified-fg); font-weight: 600; }

/* Oculto: atenuado pero legible */
.ct-row.is-off .cat-mini, .ct-row.is-off .ct-olabel { opacity: .45; }
.ct-row.is-off .ct-name { color: var(--ink-2); }

/* Herramientas: visible · subir/bajar · asa */
.ct-tools { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px; min-width: 0; }
.ct-vis { display: flex; align-items: center; gap: 4px; margin-right: auto; min-width: 0; }
.ct-vis .switch { margin-left: -4px; }
.ct-vis-l { font-size: var(--fs-min); font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.ct-move { display: flex; gap: 6px; flex: none; }
.ct-move .icon-btn:disabled { opacity: .3; cursor: default; transform: none; }
/* Guardando un orden: subir/bajar y el asa en pausa (aria-disabled: el foco no se pierde) */
.ct-move .icon-btn[aria-disabled="true"] { opacity: .45; cursor: progress; transform: none; }
.ct-grip.is-busy { opacity: .45; cursor: progress; }
.ct-up .ico { transform: rotate(180deg); }
.ct-grip {
  flex: none;
  width: 40px;
  height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: var(--r-btn);
  color: var(--ink-2);
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
/* Seis puntos dibujados (no hay icono de asa en el sprite) */
.ct-grip i {
  width: 14px;
  height: 22px;
  background: radial-gradient(circle, currentColor 1.7px, transparent 2px) 0 0 / 7px 7.4px;
}
@media (hover: hover) {
  .ct-grip:hover { background: var(--fill); color: var(--ink); }
}
.ct-row.is-dragging {
  position: relative;
  z-index: 2;
  border-radius: var(--r-card);
  box-shadow: var(--sh-float);
  outline: 1.5px solid var(--plum-500);
}
.ct-row.is-dragging .ct-grip { cursor: grabbing; color: var(--plum); }
html.ct-dragging, html.ct-dragging * { -webkit-user-select: none; user-select: none; cursor: grabbing !important; }

/* Oferta: etiqueta grande en lugar de miniatura */
.ct-olabel {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 64px;
  height: 52px;
  padding: 0 8px;
  border-radius: var(--r-chip);
  background: var(--plum);
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-min);
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

/* Pie del modo demo */
.ct-demo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* Estrecho (≤ 379): menos relleno y sin la palabra junto al interruptor */
@media (max-width: 379px) {
  .carta.panel { padding: 16px 12px; }
  .ct-vis-l { display: none; }
  .ct-open { gap: 10px; padding-inline: 10px; }
  .ct-open .cat-mini { width: 44px; height: 44px; }
  .ct-open .cat-mini .ico { width: 22px; height: 22px; }
  .ct-olabel { min-width: 56px; }
  .ct-tools { padding-left: 8px; gap: 4px; }
  .ct-grip { width: 36px; }
  .ct-go { display: none; }
}

/* ≥720: cada fila en una línea */
@media (min-width: 720px) {
  .ct-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding-bottom: 0; }
  .ct-open { padding: 12px; }
  .ct-tools { padding: 0 8px 0 4px; }
  .ct-vis { margin-right: 6px; }
  .ct-go { display: none; }
}

/* =========================================================
   Hoja de edición (<dialog class="sheet ct-dlg">)
   Estructura .dlg / .dlg-head / .dlg-body / .dlg-foot de equipo.css
   ========================================================= */
.ct-dlg .dlg-head { position: relative; }
.ct-dlg .dlg-head .cat-mini { width: 48px; height: 48px; }
.ct-dlg .dlg-head .ct-olabel { height: 48px; min-width: 56px; }
.ct-dlg .dlg-head h2 { font-size: 28px; }
.ct-body { gap: 14px; }

.ct-cols { display: grid; gap: 20px; min-width: 0; }
.ct-fields { display: grid; gap: 22px; min-width: 0; }

/* Bloques del formulario */
.ct-fs, .ct-fs-choice, .ct-picks { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 14px; }
.ct-fs > legend, .ct-fs-choice > legend, .ct-picks > legend {
  padding: 0;
  margin-bottom: 12px;
  font: 600 var(--fs-body)/1.3 var(--f-ui);
  color: var(--ink);
}
.ct-fs-choice > legend, .ct-picks > legend { font-size: var(--fs-min); margin-bottom: 8px; }
.ct-fs + .ct-fs, .ct-fs-choice + .ct-fs { padding-top: 18px; border-top: 1px solid var(--line); }
.ct-fs .opt, .ct-picks .opt { color: var(--ink-2); font-weight: 400; }
.ct-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 14px; }
.ct-fields .field .hint { font-size: var(--fs-min); }

/* Prefijo «$» y sufijo «min» / «%» dentro del campo */
.ct-affix { position: relative; min-width: 0; }
.ct-pre, .ct-suf {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-2);
  font-weight: 600;
  pointer-events: none;
}
.ct-pre { left: 14px; }
.ct-suf { right: 14px; }
.ct-pre ~ .input { padding-left: 32px; }
.ct-affix:has(.ct-suf) .input { padding-right: 56px; }
input.input[type="date"] { min-width: 0; }

/* Interruptor con texto (toda la fila responde) */
.ct-sw {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 6px 4px 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  background: var(--card);
  cursor: pointer;
}
.ct-sw .tx { display: grid; gap: 2px; min-width: 0; flex: 1; }
.ct-sw b { font-weight: 600; color: var(--ink); line-height: 1.3; }
.ct-sw .tx span { font-size: var(--fs-min); color: var(--ink-2); line-height: 1.4; }

/* Opciones (tipo, a qué aplica) */
.ct-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 8px; }
.ct-choices .choice-row { min-height: 64px; padding: 12px 14px; }
.ct-ch { display: grid; gap: 2px; min-width: 0; text-align: left; }
.ct-ch b { font-size: var(--fs-min); }

/* Color: cinco muestras */
.ct-tones { display: flex; flex-wrap: wrap; gap: 10px; }
.ct-tone {
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: var(--r-chip);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: box-shadow var(--dur-1) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.ct-tone .ico { width: 22px; height: 22px; stroke-width: 2.2; opacity: 0; transition: opacity var(--dur-1) var(--ease-out); }
.ct-tone[aria-checked="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }
.ct-tone[aria-checked="true"] .ico { opacity: 1; }
.ct-tone:active { transform: scale(.94); }

/* Icono: rejilla; el elegido sobre el color elegido */
.ct-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tap), 1fr)); gap: 8px; }
.ct-icon {
  min-width: var(--tap);
  height: 52px;
  border: 0;
  border-radius: var(--r-chip);
  background: var(--fill);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.ct-icon .ico { width: 26px; height: 26px; stroke-width: 1.4; }
.ct-icon[aria-checked="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); color: #fff; }
/* .ct-icon pisa el fondo de .tone-N (misma especificidad, va después): el elegido lo recupera */
.ct-icon.tone-1 { background: var(--tone-1); }
.ct-icon.tone-2 { background: var(--tone-2); }
.ct-icon.tone-3 { background: var(--tone-3); }
.ct-icon.tone-4 { background: var(--tone-4); }
.ct-icon.tone-5 { background: var(--tone-5); }
.ct-icon:active { transform: scale(.94); }
@media (hover: hover) {
  .ct-icon:not([aria-checked="true"]):hover { background: var(--fill-2); }
}

/* Servicios de un combo */
.ct-items { list-style: none; display: grid; border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--card); padding: 0 10px; }
.ct-item { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.ct-item:last-child { border-bottom: 0; }
.ct-item .ct-tx { flex: 1 1 120px; }
.ct-item .ct-tx b { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.ct-item .stepper { margin-left: auto; }
.ct-add { margin-top: 2px; }

/* Resumen de ahorro */
.ct-sum { display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--r-btn); background: var(--card); border: 1px solid var(--line); font-size: var(--fs-min); }
.ct-sum-l { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-2); }
.ct-sum-l b { color: var(--ink); font-weight: 700; }
.ct-sum-v { display: flex; align-items: flex-start; gap: 8px; margin-top: 4px; padding: 8px 10px; border-radius: var(--r-chip); background: var(--fill); color: var(--ink); font-weight: 600; line-height: 1.4; }
.ct-sum-v .ico { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.ct-sum-v.is-ok { background: var(--st-booked-bg); color: var(--st-booked-fg); }
.ct-sum-v.is-bad { background: var(--alert-bg); color: var(--rose-ink); border: 1px solid var(--pink-200); }
.ct-sum.is-empty { display: flex; align-items: flex-start; gap: 10px; color: var(--ink-2); line-height: 1.45; }
.ct-sum.is-empty .ico { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--plum); }

/* Selección múltiple (ofertas → servicios / combos) */
.ct-picks { gap: 8px; }
.ct-picks-h { margin-top: 6px; font-size: var(--fs-min); font-weight: 600; color: var(--ink-2); }
.ct-pick { align-items: center; padding: 10px 14px; }
.ct-pick-t { display: grid; gap: 2px; min-width: 0; }
.ct-pick-t b { font-weight: 600; color: var(--ink); line-height: 1.3; }
.ct-pick-t span { font-size: var(--fs-min); color: var(--ink-2); }

/* Zona de borrado: separada del Guardar */
.ct-danger-zone { padding-top: 18px; border-top: 1px solid var(--line); }
.ct-del { color: var(--rose-ink); }
.ct-del .ico { color: var(--rose-ink); }
@media (hover: hover) {
  .ct-del:hover { border-color: var(--pink-400); background: var(--alert-bg); }
}

/* Pie fijo: Cancelar · Guardar */
.ct-dlg .ct-foot {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  gap: 10px;
}
.ct-foot .btn-primary { flex: 1; min-width: 0; }
.ct-foot .btn-ghost { flex: none; }

/* ---------- Vista previa ---------- */
.ct-prev {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px;
  border-radius: var(--r-card);
  background: var(--fill);
  min-width: 0;
}
.ct-prev-k { display: flex; align-items: center; gap: 8px; font-size: var(--fs-min); font-weight: 600; color: var(--ink); }
.ct-prev-k .ico { width: 18px; height: 18px; color: var(--plum); }
.ct-prev-where { font-size: var(--fs-min); color: var(--ink-2); line-height: 1.4; }
.ct-prev-note { display: flex; align-items: flex-start; gap: 8px; font-size: var(--fs-min); color: var(--ink-2); line-height: 1.4; }
.ct-prev-note .ico { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--plum); }
.ct-prev-note.is-warn { padding: 8px 10px; border-radius: var(--r-chip); background: var(--st-notified-bg); color: var(--st-notified-fg); font-weight: 500; }
.ct-prev-note.is-warn .ico { color: currentColor; }

.ct-pv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-card);
  background: var(--card);
  border: 1px solid var(--line);
  min-width: 0;
}
.ct-pv-tx { display: grid; gap: 2px; min-width: 0; flex: 1; }
.ct-pv-tx b { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.ct-pv-tx .tag { margin-left: 4px; vertical-align: 1px; }
.ct-pv-add { pointer-events: none; }

.ct-pv-card {
  width: min(100%, 260px);
  border-radius: var(--r-card);
  background: var(--card);
  border: 1px solid var(--line);
  overflow: hidden;
}
.ct-pv-card .cat-block, .ct-pv-cat .cat-block { min-height: 116px; border-radius: 0; }
.ct-flag {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  font-size: var(--fs-min);
  font-weight: 600;
  line-height: 1.2;
}
.ct-pv-b { display: grid; gap: 2px; padding: 12px 14px 14px; }
.ct-pv-b b { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.ct-pv-cat { width: min(100%, 260px); border-radius: var(--r-card); overflow: hidden; }
.ct-pv-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.ct-pv-pills .pill { pointer-events: none; }
.ct-pv-offer { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.ct-ex { list-style: none; display: grid; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-btn); padding: 0 12px; }
.ct-ex li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-min); }
.ct-ex li:last-child { border-bottom: 0; }
.ct-ex-n { font-weight: 600; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.ct-ex-p { white-space: nowrap; }

/* ---------- Confirmaciones (<dialog class="sheet ct-ask">) ---------- */
.ct-ask .dlg-head { padding-top: 22px; }
.ct-ask .dlg-head h2 { font-size: 26px; }
.ct-ask-body { gap: 12px; }
.ct-ask-body p { font-size: var(--fs-min); color: var(--ink-2); line-height: 1.5; }
.ct-ask-foot .link-btn { justify-self: center; }

@media (min-width: 768px) {
  dialog.ct-ask { width: min(480px, calc(100% - 48px)); }
}

/* ≥1000: hoja ancha con la vista previa fija a la derecha */
@media (min-width: 1000px) {
  dialog.ct-dlg { width: min(940px, calc(100% - 64px)); }
  .ct-cols { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 28px; }
  .ct-fields { grid-column: 1; grid-row: 1; }
  .ct-prev { grid-column: 2; grid-row: 1; position: sticky; top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .ct-seg button, .ct-open, .ct-tone, .ct-icon { transition: none; }
}
