@layer tn.patterns {
/* ==========================================================================
   TIAMAT · patterns.css
   Patrones de producto compuestos por componentes. Cada uno resuelve una
   pregunta de negocio (¿qué hago ahora?, ¿qué bloquea?, ¿en qué etapa estoy?).
   Documentación: docs/04-patrones.md
   ========================================================================== */

/* ---------- Próxima acción (hero en tinta) ---------- */
.next-action {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 32px;
  padding: 30px 32px; border-radius: var(--tn-r-xl);
  background: var(--tn-ink); color: var(--tn-on-ink);
  box-shadow: var(--tn-sh-3);
}
.next-action--single { grid-template-columns: minmax(0, 1fr); }
.next-action__art { position: absolute; right: -150px; bottom: -190px; width: 520px; height: 520px; z-index: -1; pointer-events: none; color: var(--tn-signal); opacity: .5; }
.next-action__main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.next-action__tag { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; height: 26px; padding: 0 10px; border-radius: 7px; background: var(--tn-signal); color: var(--tn-signal-ink); font-size: 12.5px; font-weight: var(--tn-fw-semibold); }
.next-action__tag--waiting { background: rgba(255, 255, 255, .1); color: var(--tn-on-ink); }
.next-action__title { font-size: 30px; line-height: 1.12; letter-spacing: -0.025em; font-weight: var(--tn-fw-semibold); color: #fff; }
.next-action__quote { margin: 0; padding: 14px 16px; border-radius: 12px; background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); font-size: 14.5px; line-height: 1.55; color: #E3ECE9; }
/* Dueño (2026-10-27): el atajo a la ficha va a la derecha, separado del texto. */
.next-action__quote--link { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.next-action__quote--link > .btn { flex: none; }
.next-action__quote cite { display: block; margin-top: 8px; font-style: normal; font-size: 12.5px; color: var(--tn-on-ink-3); }
.next-action__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.next-action__meta { display: flex; flex-direction: column; border-left: 1px solid rgba(255,255,255,.1); padding-left: 24px; margin: 0; }
.next-action__meta > div { display: flex; flex-direction: column; gap: 3px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.next-action__meta > div:last-child { border-bottom: 0; }
.next-action__meta dt { font-size: 12px; color: var(--tn-on-ink-3); }
.next-action__meta dd { margin: 0; font-size: 14px; font-weight: var(--tn-fw-medium); color: #fff; }
/* Arte de marca (zig.art): el mar fluye y las terrazas respiran, de la base a la cima */
@media (prefers-reduced-motion: no-preference) {
  .zig-art .art-sea { animation: tn-art-sea 7s linear infinite; animation-delay: calc(var(--s) * -2.3s); }
  .zig-art .art-tier { animation: tn-art-tier 6s var(--tn-ease) infinite; animation-delay: calc(var(--t) * .5s); }
}
@keyframes tn-art-sea { to { transform: translateX(calc(var(--w) * -1)); } }
@keyframes tn-art-tier { 0%, 100% { opacity: .55; } 30% { opacity: 1; } }
.next-action--wide-meta { grid-template-columns: minmax(0, 1fr) 300px; }
@media (max-width: 1180px) {
  .next-action, .next-action--wide-meta { grid-template-columns: minmax(0, 1fr); }
  .next-action__meta { border-left: 0; padding-left: 0; border-top: 1px solid rgba(255,255,255,.1); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
}
@media (max-width: 760px) {
  .next-action { padding: 22px 20px; gap: 18px; border-radius: 18px; }
  .next-action__title { font-size: 25px; }
  .next-action__actions .btn { flex: 1 1 100%; }
  .next-action__meta { grid-template-columns: minmax(0, 1fr); }
  .next-action__art { right: -230px; bottom: -200px; }
}

/* ---------- Explicación de bloqueo (gate) ---------- */
.gate { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.gate__item { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 13px 0; border-top: 1px solid var(--tn-line); }
.gate__item:first-child { border-top: 0; padding-top: 4px; }
.gate__mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.gate__mark--ok { background: var(--tn-approved-bg); color: var(--tn-approved-fg); }
.gate__mark--observed { background: var(--tn-observed-bg); color: var(--tn-observed-fg); }
.gate__mark--review { background: var(--tn-review-bg); color: var(--tn-review-fg); }
.gate__mark--locked { background: var(--tn-sunken); color: var(--tn-text-3); }
.gate__title { font-size: 14px; font-weight: var(--tn-fw-medium); }
.gate__desc { font-size: 13px; color: var(--tn-text-3); margin-top: 2px; }

/* ---------- Requisito ---------- */
.req-group { display: flex; flex-direction: column; }
.req-card { background: var(--tn-surface); border: 1px solid var(--tn-line); border-radius: var(--tn-r-lg); box-shadow: var(--tn-sh-1); }
.req-card--focus { border-color: var(--tn-observed-line); box-shadow: 0 0 0 4px rgba(160,52,14,.06), var(--tn-sh-2); }
.req-card__body { display: flex; flex-direction: column; gap: 20px; padding: 22px; }
.req-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.req-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto minmax(92px, auto); gap: 14px; align-items: center; padding: 15px 20px; border-top: 1px solid var(--tn-line); }
.req-row:first-child { border-top: 0; }
.req-row__actions { display: flex; justify-content: flex-end; }
.req-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--tn-sunken); color: var(--tn-text-2); }
.req-icon--approved { background: var(--tn-approved-bg); color: var(--tn-approved-fg); }
.req-icon--review { background: var(--tn-review-bg); color: var(--tn-review-fg); }
.req-icon--observed { background: var(--tn-observed-bg); color: var(--tn-observed-fg); }
.req-icon--exempt { background: var(--tn-neutral-bg); color: var(--tn-neutral-fg); }
/* Requisito a cargo del proveedor (falta subir): amarillo, como el paso que le toca. Estado del archivo dentro de la tarjeta
   (dueño, 2026-10-27): falta subir (amarillo), subido (verde), a corregir (naranja); la revisión sigue en el estado de la derecha. */
.req-icon--action { background: #FFF7DC; color: #8A5A00; box-shadow: inset 0 0 0 1px #F2C94C; }
.req-file { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; width: fit-content; margin: 2px 0 0; padding: 3px 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.4; }
.req-file .ico { width: 13px; height: 13px; stroke-width: 2.2; }
.req-file.is-missing { background: #FFF7DC; color: #6B4700; box-shadow: inset 0 0 0 1px #F2C94C; }
.req-file.is-done { background: var(--tn-approved-bg); color: var(--tn-approved-fg); }
.req-file.is-observed { background: var(--tn-observed-bg); color: var(--tn-observed-fg); }
.req-file-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 2px 0 0; }
.req-file-line > .req-file { margin: 0; }
/* Dueño (2026-10-30): lo que ya está cargado en el borrador se ve con el requisito plegado. */
.req-file-loaded { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--tn-text-2); font-size: 12.5px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.req-file-loaded .ico { flex: none; width: 13px; height: 13px; color: var(--tn-text-3); }
.req-file__hint { color: var(--tn-text-3); font-size: 12.5px; }
.req-blocks { position: relative; display: inline-flex; align-items: center; gap: 4px; color: var(--tn-observed-fg); font-weight: var(--tn-fw-medium); cursor: help; }
/* Dueño (2026-10-30): sólo el candado; qué bloquea, al pasar el mouse (el texto sigue para los lectores de pantalla). */
.req-blocks__tip { position: absolute; left: -8px; bottom: calc(100% + 6px); z-index: 5; width: max-content; max-width: 16em;
  padding: 6px 10px; border-radius: var(--tn-r-sm); background: var(--tn-ink-950); color: #fff; font-size: 12.5px;
  font-weight: var(--tn-fw-medium); line-height: 1.35; box-shadow: var(--tn-sh-2); pointer-events: none; opacity: 0; transition: opacity .12s ease; }
.req-blocks:hover .req-blocks__tip { opacity: 1; }
/* La fila recorta lo que sobresale (separadores al cortar la línea): con el candado, deja lugar a su ayuda. */
.list__meta:has(.req-blocks) { clip-path: inset(-60px -16em -6px 0); }
/* JS places every enhanced help in the top layer, including narrow/tall cards. */
.tn-floating-help { position: fixed !important; inset: auto !important; margin: 0 !important; transform: none !important;
  width: max-content !important; max-width: min(300px, calc(100vw - 20px)) !important; max-height: calc(100dvh - 20px) !important;
  padding: 9px 12px; border: 0; border-radius: var(--tn-r-sm); background: var(--tn-ink-950); color: #fff;
  font-size: 12.5px; font-weight: var(--tn-fw-medium); line-height: 1.5; text-transform: none; letter-spacing: 0;
  box-shadow: var(--tn-sh-2); white-space: normal; overflow-wrap: anywhere; overflow-y: auto; z-index: 1500;
  opacity: 0; visibility: hidden; pointer-events: none; transition: none !important; }
.tn-floating-help.is-tip-visible { opacity: 1 !important; visibility: visible !important; pointer-events: auto !important; }
.tn-floating-help:not(.is-tip-visible) { opacity: 0 !important; visibility: hidden !important; }
.tn-floating-help::after { display: none !important; }
.req-blocks:focus-visible { outline: 2px solid var(--tn-brand); outline-offset: 3px; border-radius: 3px; }
@media (max-width: 760px) {
  /* La ayuda del candado no ensancha la página en pantallas angostas. */
  .req-blocks__tip { left: auto; right: 0; }
  .list__meta:has(.req-blocks) { clip-path: inset(-60px -16em -6px -16em); }
  .req-row { grid-template-columns: 34px minmax(0, 1fr); padding-left: 16px; padding-right: 16px; align-items: start; }
  .req-row > .chip, .req-row > .stack { grid-column: 2; justify-self: start; }
  .req-row__actions { grid-column: 2; justify-content: flex-start; }
  .req-card__head { flex-direction: column; }
}

/* ---------- Etapas del proceso (rail horizontal) ---------- */
.stages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--stages, 7), minmax(0, 1fr)); gap: 6px; }
.stage { display: flex; flex-direction: column; gap: 8px; padding: 12px 12px 13px; border-radius: 12px; background: var(--tn-surface-2); box-shadow: inset 0 0 0 1px var(--tn-line); min-width: 0; }
.stage__bar { height: 4px; border-radius: 4px; background: var(--tn-line); }
.stage__name { font-size: 13px; font-weight: var(--tn-fw-semibold); line-height: 1.25; }
.stage__state { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--tn-text-3); }
.stage__owner { margin-top: auto; font-size: 11.5px; color: var(--tn-text-3); }
.stage--done .stage__bar { background: var(--tn-brand); }
.stage--now { background: var(--tn-surface); box-shadow: inset 0 0 0 1.5px var(--tn-ink), var(--tn-sh-2); }
.stage--now .stage__bar { background: var(--tn-signal); box-shadow: inset 0 0 0 1px rgba(10,31,29,.15); }
@media (max-width: 1180px) { .stages { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 760px) { .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Detalle de etapas (vertical, proveedor) ---------- */
.stage-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.stage-list__item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 18px 22px; border-top: 1px solid var(--tn-line); }
.stage-list__item:first-child { border-top: 0; }
.stage-list__num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-family: var(--tn-font-sans); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: var(--tn-fw-semibold); background: var(--tn-sunken); color: var(--tn-text-3); }
.stage-list__item--done .stage-list__num { background: var(--tn-approved-bg); color: var(--tn-approved-fg); }
.stage-list__item--now { background: linear-gradient(90deg, var(--tn-signal-soft), transparent 70%); }
.stage-list__item--now .stage-list__num { background: var(--tn-signal); color: var(--tn-signal-ink); }
.stage-list__item--observed .stage-list__num { background: var(--tn-action-bg); color: var(--tn-action-fg); }
.ico.tn-ico-fill { fill: currentColor; stroke: none; }
/* Estado con explicación al pasar el mouse o con el foco (dueño, 2026-10-27). El globo se abre hacia la izquierda
   porque estos estados van en la columna derecha de las filas. */
.tn-chip-tip { position: relative; display: inline-flex; }
.tn-chip-tip > .chip { cursor: help; }
.tn-chip-tip > .chip:focus-visible { outline: 2px solid var(--tn-brand); outline-offset: 2px; }
.tn-chip-tip__bubble { position: absolute; z-index: 30; right: 0; bottom: calc(100% + 8px); width: max-content; max-width: min(280px, calc(100vw - 48px));
  padding: 9px 12px; border-radius: 10px; background: var(--tn-ink); color: #fff; font-size: 12.5px; font-weight: 400; line-height: 1.45;
  white-space: normal; text-align: left; box-shadow: var(--tn-sh-2); opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(4px); transition: opacity .15s ease, transform .15s ease, visibility .15s; }
.tn-chip-tip__bubble::after { content: ""; position: absolute; top: 100%; right: 22px; border: 6px solid transparent; border-top-color: var(--tn-ink); }
.tn-chip-tip:hover .tn-chip-tip__bubble, .tn-chip-tip:focus-within .tn-chip-tip__bubble { opacity: 1; visibility: visible; transform: none; }
.tn-chip-tip.is-dismissed .tn-chip-tip__bubble { opacity: 0; visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .tn-chip-tip__bubble { transition: none; } }
.stage-list__item--review .stage-list__num { background: var(--tn-review-bg); color: var(--tn-review-fg); }
@media (max-width: 760px) { .stage-list__item { grid-template-columns: 36px minmax(0, 1fr); } .stage-list__item > :last-child { grid-column: 2; } }

/* ---------- Colas (tiles de triage) ---------- */
.queues { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.queue { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 16px 18px; border-radius: 14px; background: var(--tn-surface); border: 1px solid var(--tn-line); box-shadow: var(--tn-sh-1); color: var(--tn-text); transition: transform var(--tn-dur-2) var(--tn-ease), box-shadow var(--tn-dur-2) var(--tn-ease), border-color var(--tn-dur-2) var(--tn-ease); }
.queue:hover { color: var(--tn-text); border-color: var(--tn-line-strong); box-shadow: var(--tn-sh-2); transform: translateY(-2px); }
.queue__top { display: flex; align-items: center; justify-content: space-between; }
.queue__icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--tn-sunken); color: var(--tn-text-2); }
.queue__n { font-family: var(--tn-font-sans); font-variant-numeric: tabular-nums; font-size: 30px; font-weight: var(--tn-fw-semibold); letter-spacing: -0.03em; line-height: 1; }
.queue__label { font-size: 13px; font-weight: var(--tn-fw-medium); color: var(--tn-text-2); }
.queue__foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--tn-text-3); }
.queue--hot { background: var(--tn-ink); border-color: var(--tn-ink); color: #fff; }
.queue--hot:hover { color: #fff; border-color: var(--tn-ink); }
.queue--hot .queue__icon { background: var(--tn-signal); color: var(--tn-ink); }
.queue--hot .queue__label { color: var(--tn-on-ink-2); }
.queue--hot .queue__foot { color: var(--tn-on-ink-3); }
@media (max-width: 1180px) { .queues { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .queues { display: flex; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scroll-snap-type: x mandatory; scrollbar-width: none; } .queue { min-width: 160px; scroll-snap-align: start; } }

/* ---------- Encabezado de expediente (contexto persistente) ---------- */
.case-head { background: var(--tn-surface); border: 1px solid var(--tn-line); border-radius: var(--tn-r-lg); box-shadow: var(--tn-sh-1); overflow: hidden; }
.case-head__top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 22px 24px; }
.case-head__identity { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 6px; }
.case-head__name { font-size: 24px; letter-spacing: -0.02em; font-weight: var(--tn-fw-semibold); line-height: 1.15; }
.case-head__facts { display: grid; grid-template-columns: 1.1fr 1fr 1.6fr .9fr; border-top: 1px solid var(--tn-line); }
.case-head__fact .chip { white-space: normal; height: auto; min-height: 24px; max-width: 100%; align-self: flex-start; line-height: 1.3; padding-top: 3px; padding-bottom: 3px; }
.case-head__fact { display: flex; flex-direction: column; gap: 4px; padding: 16px 24px; min-width: 0; }
.case-head__fact + .case-head__fact { border-left: 1px solid var(--tn-line); }
.case-head__fact--next { background: var(--tn-signal-soft); }
.case-head__fact--next .t-label { color: #4C6418; }
@media (max-width: 960px) { .case-head__facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .case-head__fact + .case-head__fact { border-left: 0; } .case-head__fact { border-top: 1px solid var(--tn-line); } .case-head__fact--next { grid-column: 1 / -1; order: -1; } }

/* ---------- Selector de turno ---------- */
.days { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.day { position: relative; }
.day input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.day__face { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0; border-radius: 12px; border: 1px solid var(--tn-line); background: var(--tn-surface); transition: background var(--tn-dur-2) var(--tn-ease), border-color var(--tn-dur-2) var(--tn-ease); }
.day__face small { font-size: 11.5px; color: var(--tn-text-3); text-transform: uppercase; letter-spacing: .04em; }
.day__face strong { font-size: 20px; font-weight: var(--tn-fw-semibold); letter-spacing: -0.02em; }
.day__face span { font-size: 11.5px; color: var(--tn-text-3); }
.day:hover .day__face { border-color: var(--tn-line-strong); }
.day input:checked + .day__face { background: var(--tn-ink); border-color: var(--tn-ink); color: #fff; }
.day input:checked + .day__face small, .day input:checked + .day__face span { color: var(--tn-on-ink-3); }
.day input:disabled + .day__face { background: transparent; border-style: dashed; color: var(--tn-text-3); }
.day input:focus-visible + .day__face { outline: 2px solid var(--tn-brand); outline-offset: 2px; }
.slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.slot { position: relative; }
.slot input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.slot__face { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--tn-line-strong); background: var(--tn-surface); transition: all var(--tn-dur-2) var(--tn-ease); }
.slot__face strong { font-family: var(--tn-font-mono); font-size: 15px; font-weight: var(--tn-fw-medium); }
.slot__face span { font-size: 12px; color: var(--tn-text-3); }
.slot:hover .slot__face { border-color: #B9C1B9; }
.slot input:checked + .slot__face { border-color: var(--tn-ink); box-shadow: 0 0 0 1px var(--tn-ink); background: var(--tn-signal-soft); }
.slot input:focus-visible + .slot__face { outline: 2px solid var(--tn-brand); outline-offset: 2px; }
/* Horario reservable con un POST por horario (contrato real): la cara entera es el botón. */
button.slot__face, a.slot__face { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
button.slot__face:hover, a.slot__face:hover { border-color: var(--tn-ink); background: var(--tn-signal-soft); }
button.slot__face:focus-visible, a.slot__face:focus-visible { outline: 2px solid var(--tn-brand); outline-offset: 2px; }
@media (max-width: 760px) { .days { grid-template-columns: repeat(3, minmax(0, 1fr)); } .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Pasos numerados (qué pasa después) ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; counter-reset: step; }
.steps__item { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; counter-increment: step; }
.steps__item::before { content: counter(step); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-family: var(--tn-font-sans); font-variant-numeric: tabular-nums; font-size: 11px; font-weight: var(--tn-fw-semibold); color: var(--tn-text-3); box-shadow: inset 0 0 0 1.5px var(--tn-line-strong); background: var(--tn-surface); }
.steps__item::after { content: ""; position: absolute; left: 10.5px; top: 24px; bottom: 2px; width: 1px; background: var(--tn-line); }
.steps__item:last-child { padding-bottom: 0; }
.steps__item:last-child::after { display: none; }
.steps__item--now::before { background: var(--tn-ink); color: var(--tn-signal); box-shadow: none; }
.steps__item--done::before { content: ""; background: var(--tn-approved-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231A6235' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 11px no-repeat; box-shadow: none; }

/* ---------- Importes ---------- */
.money { display: flex; flex-direction: column; gap: 12px; }
.money__row { display: flex; justify-content: space-between; gap: 16px; font-size: 13.5px; }
.money__row dt { color: var(--tn-text-2); }
.money__row dd { margin: 0; font-family: var(--tn-font-mono); font-feature-settings: "tnum"; }
.money__total { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding-top: 12px; border-top: 1px solid var(--tn-line); }
.money__total dd { margin: 0; font-family: var(--tn-font-mono); font-size: 24px; font-weight: var(--tn-fw-semibold); letter-spacing: -0.02em; }

/* ---------- Escala de encuesta (radios reales) ---------- */
.scale { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.scale__head { display: flex; justify-content: space-between; gap: 12px; padding: 0; }
.scale__options { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
.scale__option { position: relative; }
.scale__option input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.scale__option span { display: grid; place-items: center; height: 38px; border-radius: 9px; border: 1px solid var(--tn-line-strong); background: var(--tn-surface); font-family: var(--tn-font-sans); font-variant-numeric: tabular-nums; font-size: 13.5px; color: var(--tn-text-2); transition: all var(--tn-dur-1) var(--tn-ease); }
.scale__option:hover span { border-color: var(--tn-ink-600); color: var(--tn-text); }
.scale__option input:checked + span { background: var(--tn-ink); border-color: var(--tn-ink); color: var(--tn-signal); }
.scale__option input:focus-visible + span { outline: 2px solid var(--tn-brand); outline-offset: 2px; }
@media (max-width: 520px) { .scale__options { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* ---------- Fila de configuración ---------- */
.setting { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; padding: 20px 22px; border-top: 1px solid var(--tn-line); }
.setting:first-child { border-top: 0; }
.setting__title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14.5px; font-weight: var(--tn-fw-semibold); }
.setting__desc { margin-top: 4px; font-size: 13.5px; color: var(--tn-text-2); line-height: 1.5; }
.setting__control { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.setting--modified { background: linear-gradient(90deg, var(--tn-action-bg), transparent 60%); }
@media (max-width: 760px) { .setting { grid-template-columns: minmax(0, 1fr); gap: 12px; } .setting__control { justify-content: flex-start; } }

/* ---------- Barra de guardado ---------- */
.savebar { position: sticky; bottom: 20px; z-index: var(--tn-z-sticky); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 12px 12px 18px; border-radius: 14px; background: var(--tn-ink); color: var(--tn-on-ink-2); box-shadow: var(--tn-sh-3); font-size: 13.5px; }
.savebar__text { flex: 1; min-width: 220px; }
.savebar strong { color: #fff; font-weight: var(--tn-fw-semibold); }
.savebar[hidden] { display: none; }
.savebar.is-visible { animation: tn-rise var(--tn-dur-3) var(--tn-ease-out-expo) both; }

/* ---------- Conversación de expediente ---------- */
.threads { display: flex; flex-direction: column; gap: 4px; }
.thread-link { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 12px; color: var(--tn-text); }
.thread-link:hover { background: var(--tn-surface); text-decoration: none; color: var(--tn-text); }
.thread-link[aria-current="page"] { background: var(--tn-surface); box-shadow: 0 0 0 1px var(--tn-line), var(--tn-sh-1); }
.thread-link__top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.thread-link__preview { font-size: 12.5px; color: var(--tn-text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thread-link--unread .thread-link__top strong { font-weight: var(--tn-fw-semibold); }
.conversation { display: flex; flex-direction: column; gap: 20px; padding: 22px; background: var(--tn-surface-2); }
.msg { display: flex; gap: 12px; align-items: flex-start; max-width: 640px; }
.msg__body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.msg__meta { font-size: 12px; color: var(--tn-text-3); }
.msg__bubble { padding: 14px 16px; border-radius: 14px; border-top-left-radius: 4px; background: var(--tn-surface); box-shadow: inset 0 0 0 1px var(--tn-line); font-size: 14px; line-height: 1.55; }
.msg--mine { align-self: flex-end; flex-direction: row-reverse; text-align: left; }
.msg--mine .msg__body { align-items: flex-end; }
.msg--mine .msg__bubble { background: var(--tn-ink); color: var(--tn-on-ink); box-shadow: none; border-top-left-radius: 14px; border-top-right-radius: 4px; }
.msg--system .msg__bubble { background: transparent; box-shadow: none; border: 1px dashed var(--tn-line-strong); color: var(--tn-text-2); font-size: 13px; }

/* ---------- Visor de documento ---------- */
.viewer { border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--tn-line); background: var(--tn-surface); }
.viewer__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--tn-line); flex-wrap: wrap; }
.viewer__files { display: flex; gap: 6px; flex-wrap: wrap; }
.viewer__file { height: 26px; padding: 0 10px; border-radius: 7px; border: 0; font-size: 12px; font-weight: var(--tn-fw-medium); background: var(--tn-surface); box-shadow: inset 0 0 0 1px var(--tn-line); color: var(--tn-text-2); }
.viewer__file[aria-pressed="true"] { background: var(--tn-ink); color: #fff; box-shadow: none; }
.viewer__stage { min-height: 560px; padding: 32px; display: flex; justify-content: center; background: #DDE2DC; }
.viewer__page { width: 100%; max-width: 560px; background: #fff; border-radius: 4px; box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 20px 40px -20px rgba(0,0,0,.25); padding: 48px 52px; display: flex; flex-direction: column; gap: 12px; }
.viewer__line { height: 7px; border-radius: 4px; background: #E7EAE6; }
.viewer__line--head { height: 12px; background: #CED4CD; }
.viewer__private { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 12px; color: var(--tn-text-3); border-top: 1px solid var(--tn-line); }

/* ---------- Métricas ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-radius: 14px; background: var(--tn-surface); border: 1px solid var(--tn-line); box-shadow: var(--tn-sh-1); min-width: 0; }
.stat__label { font-size: 12.5px; color: var(--tn-text-3); font-weight: var(--tn-fw-medium); }
.stat__value { font-family: var(--tn-font-sans); font-variant-numeric: tabular-nums; font-size: 30px; font-weight: var(--tn-fw-semibold); letter-spacing: -0.03em; line-height: 1.05; }
.stat__value small { font-size: 15px; color: var(--tn-text-3); font-weight: var(--tn-fw-medium); }
.stat__foot { font-size: 12.5px; color: var(--tn-text-2); }
@media (max-width: 960px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Barras horizontales (una sola serie, escala 0-10) */
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.bars__item { display: grid; grid-template-columns: 200px minmax(0, 1fr) 48px; gap: 16px; align-items: center; font-size: 13.5px; }
.bars__track { position: relative; height: 12px; border-radius: 4px; background: var(--tn-sunken); }
.bars__fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--tn-data-1); transform-origin: left; animation: tn-grow .9s var(--tn-ease-out-expo) both; }
.bars__value { font-family: var(--tn-font-sans); font-variant-numeric: tabular-nums; font-weight: var(--tn-fw-semibold); text-align: right; }
.bars__item:hover .bars__fill { filter: brightness(1.15); }
.bars__item[data-tip] { position: relative; }
@keyframes tn-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (max-width: 760px) { .bars__item { grid-template-columns: minmax(0, 1fr) 48px; } .bars__track { grid-column: 1 / -1; grid-row: 2; } }

/* ---------- Checks de readiness ---------- */
.check-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px 22px; border-top: 1px solid var(--tn-line); }
.check-row:first-child { border-top: 0; }

/* ---------- Entrada escalonada del contenido ---------- */
@media (prefers-reduced-motion: no-preference) {
  .content > * { animation: tn-rise var(--tn-dur-4) var(--tn-ease-out-expo) both; }
  .content > :nth-child(2) { animation-delay: 50ms; }
  .content > :nth-child(3) { animation-delay: 100ms; }
  .content > :nth-child(4) { animation-delay: 150ms; }
  .content > :nth-child(5) { animation-delay: 200ms; }
  .content > :nth-child(n+6) { animation-delay: 240ms; }
}

}
@layer tn.patterns {
  /* Cierre del proceso para el proveedor (dueño, 2026-10-23): agradecimiento, certificado por correo, encuesta
     obligatoria y otros servicios de Sur Compliance. */
  .tn-closure { display: grid; gap: 18px; }
  .tn-thanks { position: relative; display: grid; gap: 12px; justify-items: start; padding: 30px 32px; border-radius: 22px; overflow: hidden;
    color: #E8F1EE; isolation: isolate;
    background: radial-gradient(70% 120% at 100% 0%, rgba(200, 241, 105, .22) 0%, transparent 60%),
                radial-gradient(60% 90% at 0% 100%, rgba(44, 120, 104, .6) 0%, transparent 65%), var(--tn-ink);
    box-shadow: 0 22px 44px -26px rgba(10, 31, 29, .85); }
  .tn-thanks__glow { position: absolute; inset: -40% -20% auto auto; width: 360px; height: 360px; z-index: -1; border-radius: 50%;
    background: radial-gradient(circle, rgba(200, 241, 105, .35), transparent 65%); animation: tn-thanks-glow 6s ease-in-out infinite alternate; }
  @keyframes tn-thanks-glow { from { transform: translate(0, 0) scale(1); } to { transform: translate(-30px, 20px) scale(1.15); } }
  .tn-thanks__logo { height: 34px; width: auto; margin-bottom: 6px; }
  .tn-thanks__kicker { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--tn-signal);
    color: var(--tn-ink); font-size: 12px; font-weight: 700; letter-spacing: .02em; }
  .tn-thanks__kicker--ink { background: var(--tn-ink); color: var(--tn-signal); }
  .tn-thanks__title { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 700; color: #fff; letter-spacing: -.01em; }
  .tn-thanks__text { margin: 0; max-width: 62ch; font-size: 15.5px; line-height: 1.6; color: rgba(232, 241, 238, .88); }
  .tn-thanks__mail { display: flex; align-items: flex-start; gap: 10px; margin: 2px 0 0; padding: 12px 14px; border-radius: 14px;
    background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1); font-size: 14.5px; line-height: 1.5; }
  .tn-thanks__mail > svg { flex: none; margin-top: 2px; color: var(--tn-signal); }
  .tn-thanks__mail strong { color: #fff; }
  .tn-thanks__mail--light { margin: 18px 0 0; background: var(--tn-signal-soft); border-color: var(--tn-signal-500); color: var(--tn-ink); }
  .tn-thanks__mail--light strong { color: var(--tn-ink); }
  .tn-thanks__mail--light > svg { color: #4C6418; }
  .tn-thanks__survey { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; width: 100%;
    margin-top: 6px; padding: 16px 18px; border-radius: 16px; background: rgba(200, 241, 105, .12); border: 1px solid rgba(200, 241, 105, .45); }
  .tn-thanks__survey > div { display: grid; gap: 2px; }
  .tn-thanks__survey strong { color: #fff; font-size: 16px; }
  .tn-thanks__survey span { color: rgba(232, 241, 238, .8); font-size: 13.5px; }
  .tn-thanks__done { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--tn-signal); font-weight: 600; }
  .tn-services { display: grid; gap: 16px; margin-top: 18px; padding: 22px 24px; border-radius: 20px; border: 1px solid var(--tn-line); background: var(--tn-surface); }
  .tn-services__head { display: grid; gap: 4px; }
  .tn-services__head h2 { margin: 0; }
  .tn-services__list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
  .tn-services__list li { display: grid; gap: 6px; align-content: start; padding: 16px; border-radius: 14px; background: var(--tn-surface-2);
    border: 1px solid var(--tn-line); transition: transform .18s, box-shadow .18s; }
  .tn-services__list li:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -16px rgba(10, 31, 29, .5); }
  .tn-services__list strong { color: var(--tn-ink); font-size: 15px; }
  .tn-services__list span:last-child { color: var(--tn-text-2); font-size: 13.5px; line-height: 1.5; }
  .tn-services__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--tn-ink); color: var(--tn-signal); }
  .tn-services__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
  .tn-services__contact { display: flex; flex-wrap: wrap; gap: 6px 18px; }
  .tn-services__contact .link { display: inline-flex; align-items: center; gap: 6px; }
  .tn-services__slogan { margin: 0; font-size: 12.5px; font-style: italic; color: var(--tn-text-3); }
  .tn-signed-unpaid { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 22px; padding: 22px 24px; border-radius: 20px;
    background: var(--tn-signal-soft); border: 1px solid var(--tn-signal-500); }
  .tn-signed-unpaid__icon { display: grid; place-items: center; flex: none; width: 54px; height: 54px; border-radius: 16px; background: var(--tn-ink); color: var(--tn-signal); }
  .tn-signed-unpaid__body { flex: 1 1 320px; display: grid; gap: 6px; justify-items: start; }
  .tn-signed-unpaid__title { margin: 0; font-size: 22px; line-height: 1.2; color: var(--tn-ink); }
  .tn-signed-unpaid__body p { margin: 0; color: var(--tn-text-2); }
  @media (max-width: 640px) { .tn-thanks { padding: 22px 18px; } .tn-thanks__title { font-size: 24px; } }
  @media (prefers-reduced-motion: reduce) { .tn-thanks__glow { animation: none; } }
}
/* Agregar el turno al calendario (dueño, 2026-10-27). */
@layer tn.patterns {
  .tn-addcal { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
  .tn-addcal__label { display: inline-flex; align-items: center; gap: 6px; color: var(--tn-text-2); font-size: 13px; font-weight: 600; }
  .tn-addcal__label small { color: var(--tn-text-3); font-weight: 500; }
  .tn-addcal__btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 10px; background: var(--tn-surface);
    color: var(--tn-ink); font-size: 13px; font-weight: 600; text-decoration: none; box-shadow: 0 0 0 1px var(--tn-line), 0 2px 6px -4px rgba(10, 31, 29, .4);
    transition: transform .16s ease, box-shadow .16s ease; }
  .tn-addcal__btn:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px var(--tn-line-strong), 0 8px 16px -10px rgba(10, 31, 29, .5); text-decoration: none; }
  .tn-addcal__btn.is-google { box-shadow: 0 0 0 1px #C6D7FB, 0 2px 6px -4px rgba(66, 133, 244, .5); }
  .tn-addcal.is-dark .tn-addcal__label { color: rgba(255, 255, 255, .78); }
  .tn-addcal.is-dark .tn-addcal__label small { color: rgba(255, 255, 255, .6); }
  .tn-addcal.is-dark .tn-addcal__btn { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
  .tn-addcal.is-dark .tn-addcal__btn:hover { background: rgba(255, 255, 255, .16); }
  @media (prefers-reduced-motion: reduce) { .tn-addcal__btn { transition: none; } }
}

/* Cierre: entrega del certificado y canales oficiales (dueño, 2026-10-31). */
@layer tn.patterns {
  .tn-certification__delivery { display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 14px 16px; border: 1px solid rgba(200, 241, 105, .3); border-radius: 12px; background: rgba(200, 241, 105, .08); color: var(--tn-on-ink); font-size: 14px; line-height: 1.6; }
  .tn-certification__delivery > .ico { flex: none; margin-top: 3px; color: var(--tn-signal); }
  .tn-certification__delivery strong { color: #fff; }
  .tn-certification__email { overflow-wrap: anywhere; }
  .tn-services__follow { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--tn-line); }
  .tn-services__follow p { margin: 0; }
  .tn-services__socials { display: flex; flex-wrap: wrap; gap: 8px; }
  .tn-services__socials a { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 12px; border: 1px solid var(--tn-line); border-radius: 10px; background: var(--tn-surface-2); color: var(--tn-ink); font-size: 13px; font-weight: 600; text-decoration: none; }
  .tn-services__socials a:hover { background: var(--tn-signal-soft); border-color: var(--tn-signal-500); }
  .tn-services__socials a:focus-visible { outline: 2px solid var(--tn-brand); outline-offset: 3px; }
  @media (max-width: 480px) { .tn-services { padding: 20px 16px; } .tn-services__foot > .btn { width: 100%; height: auto; min-height: 44px; white-space: normal; text-align: center; } }
}
