/* TriON Bloque · armazón del panel web (base_bloque.html).
   Solo lo propio de la web: el menú, la cabecera de página y los avisos. Los
   componentes están en bloque.css (copia de la base de diseño) y los valores
   en tokens.css. Nada de valores sueltos: todo sale de las variables. */

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }
body.tb-app { min-height: 100vh; }

/* ---------- Armazón: carril + panel + contenido ---------- */
.tb-shell { display: flex; min-height: 100vh; }
.tb-shell__rail { position: sticky; top: 0; height: 100vh; flex: 0 0 var(--rail); display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: 20px 0; overflow-y: auto; }
.tb-shell__panel { position: sticky; top: 0; height: 100vh; flex: 0 0 248px; overflow-y: auto; background: var(--block); border-radius: 0 var(--radius-xl) var(--radius-xl) 0; }
.tb-shell__main { flex: 1 1 auto; min-width: 0; padding: 28px var(--space-7) 64px; display: flex; flex-direction: column; gap: var(--space-4); max-width: calc(var(--content-max) + 64px); }
.tb-rail__spacer { flex: 1; min-height: 16px; }
.tb-rail__item svg { width: 24px; height: 24px; }
/* Etiqueta del riel al pasar el ratón o con el foco. La pinta bloque.js como
   un elemento fijo en <body>: dentro del riel (overflow-y: auto) quedaba recortada. */
.tb-tip {
  position: fixed; z-index: 900; transform: translateY(-50%); pointer-events: none;
  white-space: nowrap; background: var(--paper); color: var(--ink); font: 700 13px/18px var(--font-sans);
  padding: 6px 10px; border-radius: var(--radius-pill); box-shadow: var(--shadow-float);
}

/* Cabecera de cada página: título + periodo + acción principal */
.tb-pagehead { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.tb-pagehead__text { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; }
.tb-pagehead__eyebrow { font: 700 13px/16px var(--font-display); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.tb-pagehead__title { margin: 0; font: 900 34px/38px var(--font-display); letter-spacing: -0.02em; text-wrap: balance; }
.tb-pagehead__tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* Rejillas de contenido */
.tb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); grid-auto-flow: dense; }
.tb-grid--wide { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.tb-span-2 { grid-column: span 2; }
.tb-span-2r { grid-row: span 2; }
.tb-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.tb-split { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-start; }
.tb-split > .tb-split__main { flex: 3 1 560px; min-width: 0; }
.tb-split > .tb-split__side { flex: 1 1 300px; min-width: 0; }

/* Formularios de Django dentro de un bloque */
.tb-form { display: flex; flex-direction: column; gap: var(--space-4); max-width: 560px; }
.tb-form .tb-form__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; padding-top: var(--space-2); }
.tb-form select:not(.tb-select), .tb-form input[type="text"]:not(.tb-input), .tb-form input[type="email"]:not(.tb-input),
.tb-form input[type="number"]:not(.tb-input), .tb-form input[type="date"]:not(.tb-input), .tb-form input[type="password"]:not(.tb-input), .tb-form textarea:not(.tb-textarea) {
  width: 100%; height: var(--control); padding: 0 16px; border-radius: var(--radius-md); border: 1px solid transparent;
  background: var(--block-2); color: var(--text); font: 500 16px/22px var(--font-sans); outline: none;
}
.tb-form textarea:not(.tb-textarea) { height: auto; min-height: 96px; padding: 12px 16px; }
.tb-form select:focus, .tb-form input:focus, .tb-form textarea:focus { border-color: var(--lime); box-shadow: 0 0 0 3px var(--lime-tint); }
.tb-form .errorlist { margin: 0; padding: 0; list-style: none; color: var(--coral); font: 600 13px/18px var(--font-sans); }

/* ---------- Avisos de Django (mensajes) ---------- */
.tb-toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: var(--space-2); z-index: 1000; pointer-events: none; }
.tb-toasts .tb-toast { pointer-events: auto; }
.tb-imperson { position: sticky; top: 0; z-index: 900; margin: 0 0 var(--space-2); }

/* ---------- Cajón de notificaciones (lo rellena notifications.js) ---------- */
.tb-drawer-wrap { position: fixed; inset: 0; z-index: 950; display: flex; justify-content: flex-end; }
.tb-drawer-wrap .tb-drawer { height: 100%; overflow-y: auto; }
.tb-notifs { display: flex; flex-direction: column; background: var(--block-2); border-radius: var(--radius-lg); overflow: hidden; }
.tb-notifs .notification-item, .tb-notifs > div { display: flex; gap: var(--space-3); align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.tb-notifs .notification-item:last-child { border-bottom: 0; }
.tb-notifs .notification-item p { margin: 0; font: 500 13px/18px var(--font-sans); color: var(--text-2); }
.tb-notifs .notification-item p:first-child { font: 700 14px/20px var(--font-sans); color: var(--text); }
.tb-notifs .notification-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.tb-notifs .notification-item > div:first-child { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--block); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tb-notifs .status-indicator { width: 8px; height: 8px; border-radius: 4px; background: var(--coral); flex-shrink: 0; margin-top: 6px; }
.tb-notifs .text-center { padding: var(--space-6); text-align: center; color: var(--text-2); font: 500 14px/20px var(--font-sans); }
.notification-dot.hidden { display: none; }

/* ---------- Móvil (< 900px): carril abajo como la app ---------- */
.tb-only-mobile { display: none; }
@media (max-width: 899px) {
  .tb-shell { flex-direction: column; }
  .tb-shell__rail { position: fixed; top: auto; bottom: 12px; left: 16px; right: 16px; height: var(--tabbar); flex-direction: row; justify-content: space-around; padding: 0 8px; background: var(--block); border-radius: var(--radius-pill); box-shadow: var(--shadow-float); z-index: 800; overflow: visible; }
  .tb-shell__rail .tb-rail__logo, .tb-shell__rail .tb-rail__spacer, .tb-shell__rail .tb-rail__extra { display: none; }
  .tb-shell__rail .tb-rail__item { width: 48px; height: 48px; border-radius: 24px; }
  .tb-shell__panel { position: fixed; top: auto; left: 16px; right: 16px; bottom: calc(var(--tabbar) + 24px); height: auto; max-height: 70vh; border-radius: var(--radius-xl); box-shadow: var(--shadow-float); z-index: 790; }
  .tb-shell__main { padding: 20px 16px 110px; }
  .tb-pagehead__title { font-size: 26px; line-height: 30px; }
  /* Título y campana en la primera fila; periodo y acción debajo, a lo ancho */
  .tb-pagehead__text { order: 1; flex: 1 1 0; }
  .tb-pagehead > .tb-notif-btn { order: 2; align-self: flex-start; }
  .tb-pagehead__tools { order: 3; flex: 1 1 100%; }
  .tb-span-2 { grid-column: auto; }
  .tb-tip { display: none; }
  .tb-only-mobile { display: flex; }
}

/* =====================================================================
   Piezas comunes de templates/bloque/ (README.md allí). Lo que falta en
   bloque.css (copia de la base) y necesita el panel web.
   ===================================================================== */

/* ---------- Rejillas extra ---------- */
.tb-grid--kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tb-grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.tb-muted { color: var(--text-2); }

/* ---------- Segmented con enlaces (aria-current) ---------- */
a.tb-seg__opt { display: inline-flex; align-items: center; text-decoration: none; }
.tb-seg__opt[aria-current]:not([aria-current="false"]) { background: var(--paper); color: var(--ink); }
.tb-seg__opt:not([aria-current]):not([aria-pressed="true"]):hover { background: var(--block-2); }

/* ---------- Selector de periodo (bloque/periodo.html) ---------- */
.tb-period { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.tb-period__nav { display: inline-flex; align-items: center; gap: 4px; }
.tb-period .tb-range { min-width: 150px; justify-content: center; }
.tb-range:hover { background: var(--block-2); }
.tb-range:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tb-range--static { cursor: default; }
.tb-range--static:hover { background: var(--block); }
.tb-iconbtn--off { color: var(--placeholder); cursor: not-allowed; }
.tb-iconbtn--off:hover { background: var(--block); }
.tb-period__pop { position: absolute; top: calc(100% + 8px); right: 0; z-index: 600; flex-wrap: wrap; }
.tb-period__scrim { display: none; }
.tb-period__rango { display: flex; flex-direction: column; gap: var(--space-3); width: 240px; }
.tb-presets button:hover:not([aria-pressed="true"]) { background: var(--block-2); }
.tb-presets button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
@media (max-width: 599px) {
  .tb-period__scrim { display: block; position: fixed; inset: 0; z-index: 990; }
  .tb-period__pop { position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 991; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: var(--space-5) var(--space-4) var(--space-6); max-height: 90vh; overflow-y: auto; }
  .tb-period__pop .tb-presets { flex-direction: row; flex-wrap: wrap; min-width: 0; width: 100%; }
  .tb-period__pop .tb-presets button { box-shadow: inset 0 0 0 1px var(--line); }
  .tb-period__rango { width: 100%; }
}

/* ---------- Colores de familia en relleno ---------- */
.tb-fill-paper { background: var(--paper); }
.tb-fill-lima { background: var(--lime); }
.tb-fill-turquesa { background: var(--turquesa); }
.tb-fill-azul { background: var(--azul); }
.tb-fill-violeta { background: var(--violeta); }
.tb-fill-naranja { background: var(--naranja); }
.tb-fill-coral { background: var(--coral); }
.tb-fill-block { background: var(--block-2); }

/* ---------- Embudo (bloque/funnel.html) ---------- */
.tb-embudo__leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font: 600 12px/16px var(--font-sans); color: var(--text-2); }
.tb-embudo__leyenda li { display: inline-flex; align-items: center; gap: 6px; }
.tb-embudo__leyenda i { width: 10px; height: 10px; border-radius: 3px; }
.tb-embudo__lista { container-type: inline-size; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.tb-embudo__etapa { display: flex; flex-direction: column; }
.tb-embudo__fila { display: grid; grid-template-columns: 200px minmax(0, 1fr) 64px; align-items: center; gap: var(--space-3); min-height: 44px; padding: 4px 10px; margin: 0 -10px; border-radius: var(--radius-md); color: var(--text); text-decoration: none; }
.tb-embudo__fila--link:hover { background: var(--block-2); }
.tb-embudo__fila--link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tb-embudo__nombre { font: 600 14px/18px var(--font-sans); }
.tb-embudo__pista { display: block; height: 16px; border-radius: var(--radius-pill); background: var(--block-2); overflow: hidden; }
.tb-embudo__pista i { display: block; height: 100%; border-radius: inherit; }
.tb-embudo__n { text-align: right; font: 900 20px/1 var(--font-display); }
.tb-embudo__ratio, .tb-embudo__etapa > .tb-embudo__nota { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 2px 0 8px calc(200px + var(--space-3)); }
.tb-embudo__nota { margin: 0; font: 500 12px/16px var(--font-sans); color: var(--text-2); }
.tb-semaforo { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--block-2); color: var(--text); font: 700 12px/16px var(--font-sans); white-space: nowrap; }
.tb-semaforo--extraordinario { background: var(--lime); color: var(--ink); }
.tb-semaforo--correcto { background: transparent; box-shadow: inset 0 0 0 1px var(--line-control); }
.tb-semaforo--limite { background: transparent; box-shadow: none; border: 1px dashed var(--line-control); }
.tb-semaforo--critico { background: var(--coral-tint); color: var(--coral); }
.tb-semaforo--sin_datos, .tb-semaforo--muestra_baja { background: var(--block-2); color: var(--text-2); }
.tb-embudo__ratio.is-cuello .tb-semaforo--critico { background: var(--coral-tint); box-shadow: inset 0 0 0 1px var(--coral); }
/* Forma de embudo «de siempre» (bloque/funnel.html, core/_funnel_static.html):
   barras centradas, más estrechas cuanto más abajo (--w lo pone la plantilla),
   cifra y nombre dentro. Si el nombre no cabe, pasa a dos líneas. */
.tb-embudo__lista--forma { gap: 6px; }
.tb-embudo__barra { box-sizing: border-box; align-self: center; width: var(--w, 100%); min-width: min-content; max-width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 16px; border: 0; border-radius: var(--radius-md); color: var(--ink); text-decoration: none; text-align: center; font: inherit; }
.tb-embudo__barra .tb-embudo__n { font: 900 18px/1 var(--font-display); text-align: center; }
.tb-embudo__barra .tb-embudo__nombre { font: 700 14px/18px var(--font-sans); }
a.tb-embudo__barra, button.tb-embudo__barra { cursor: pointer; transition: transform .12s ease, filter .12s ease; }
a.tb-embudo__barra:hover, button.tb-embudo__barra:hover { transform: scale(1.02); filter: brightness(1.06); }
.tb-embudo__barra:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tb-embudo__barra[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg, #0A0A0A), 0 0 0 5px var(--lime); }
.tb-embudo__lista--forma .tb-embudo__ratio, .tb-embudo__lista--forma .tb-embudo__etapa > .tb-embudo__nota { justify-content: center; text-align: center; padding: 4px 0 2px; }
@media (prefers-reduced-motion: reduce) { a.tb-embudo__barra:hover, button.tb-embudo__barra:hover { transform: none; } }
/* Estrecho (móvil o bloque de media columna): nombre y cifra arriba, barra debajo */
@container (max-width: 520px) {
  .tb-embudo__fila { grid-template-columns: minmax(0, 1fr) 56px; grid-template-areas: "nombre n" "pista pista"; row-gap: 6px; padding: 8px 10px; }
  .tb-embudo__nombre { grid-area: nombre; }
  .tb-embudo__n { grid-area: n; font-size: 18px; }
  .tb-embudo__pista { grid-area: pista; height: 12px; }
  .tb-embudo__ratio, .tb-embudo__etapa > .tb-embudo__nota { padding-left: 0; }
  /* Embudo más suave en estrecho (del 100 % al ~64 %): los nombres largos caben */
  .tb-embudo__barra { width: calc(100% - (100% - var(--w, 100%)) * 0.65); padding: 6px 12px; }
}

/* ---------- Chips y estados ---------- */
.tb-chip--coral-solid { background: var(--coral); color: var(--ink); font-weight: 800; }
.tb-chip .tb-ico { width: 14px; height: 14px; }
/* Estados en tablas de admin / billing: el estado se ve por forma además de por color */
.tb-badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--block-2); color: var(--text); font: 700 12px/16px var(--font-sans); white-space: nowrap; }
.tb-badge::before { font: 900 12px/1 var(--font-sans); }
.tb-badge--ok { background: var(--lime-tint); color: var(--lime); }
.tb-badge--ok::before { content: "✓"; }
.tb-badge--pendiente { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line-control); }
.tb-badge--pendiente::before { content: ""; width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 2px currentColor; }
.tb-badge--error { background: var(--coral-tint); color: var(--coral); }
.tb-badge--error::before { content: "!"; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: var(--coral); color: var(--ink); font-size: 10px; }
.tb-badge--info { background: var(--azul-tint); color: var(--azul); }
.tb-badge--neutral { background: var(--block-2); color: var(--text-2); }

/* ---------- KPI (bloque/kpi.html) ---------- */
.tb-stat__unit { font-size: .55em; letter-spacing: 0; font-weight: 800; white-space: nowrap; }
/* Casilla estrecha (2 por fila en el móvil): la cifra grande baja para no salirse */
.tb-stat { container-type: inline-size; }
@container (max-width: 190px) { .tb-stat__value { font-size: 30px; line-height: 34px; } .tb-stat--sm .tb-stat__value { font-size: 24px; line-height: 28px; } }
a.tb-stat--link { text-decoration: none; transition: background-color .15s; }
a.tb-stat--link:hover { background: var(--block-2); }
a.tb-stat--paper.tb-stat--link:hover { background: #FFFFFF; }
a.tb-stat--link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tb-delta--flat { color: var(--text-2); }
.tb-stat--paper .tb-delta, .tb-stat--lime .tb-delta, .tb-hero .tb-delta { color: var(--ink); }

/* ---------- Vacío (bloque/vacio.html) ---------- */
.tb-empty--compact { background: transparent; padding: var(--space-6) var(--space-4); }
.tb-empty--compact .tb-empty__ico { width: 48px; height: 48px; border-radius: 16px; }
.tb-empty--error .tb-empty__ico { color: var(--coral); }
.tb-table .tb-empty { white-space: normal; }

/* ---------- Modal y diálogo de confirmar ---------- */
.tb-modal-wrap { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.tb-modal-wrap .tb-modal { width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; }
.tb-modal--lg { max-width: 720px; }
.tb-modal__head { display: flex; align-items: flex-start; gap: var(--space-3); }
.tb-modal__head .tb-modal__title { flex: 1; }
.tb-modal__text { margin: 0; font: 500 15px/22px var(--font-sans); color: var(--text-2); }
.tb-modal__body { display: flex; flex-direction: column; gap: var(--space-4); }
.tb-modal__foot { flex-wrap: wrap; }
@media (max-width: 599px) {
  .tb-modal-wrap { align-items: flex-end; padding: 0; }
  .tb-modal-wrap .tb-modal { max-width: none; border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 90vh; }
  .tb-modal__foot .tb-btn { flex: 1 1 auto; }
}

/* ---------- Cajón (bloque/drawer_inicio.html) ---------- */
.tb-drawer-wrap .tb-drawer { overflow: hidden; }
.tb-drawer__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-4); margin: 0 calc(-1 * var(--space-6)); padding: 0 var(--space-6); }
.tb-drawer__body > .tb-drawer__foot { position: sticky; bottom: 0; background: var(--block); padding-bottom: 2px; }
@media (max-width: 899px) {
  .tb-drawer-wrap { align-items: flex-end; }
  .tb-drawer-wrap .tb-drawer { width: 100%; height: auto; max-height: 90vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: var(--space-5); }
  .tb-drawer-wrap .tb-drawer__body { margin: 0 calc(-1 * var(--space-5)); padding: 0 var(--space-5); }
}

/* ---------- Avisos lanzados desde JS (tbToast) ---------- */
/* A lo ancho y centrados (con left:50% + translate el contenedor encogía el texto) */
.tb-toasts { left: 16px; right: 16px; transform: none; }
.tb-toasts .tb-toast { max-width: 560px; }
@media (max-width: 899px) { .tb-toasts { bottom: calc(var(--tabbar) + 28px); } }

/* ---------- Tablas: ordenar (data-tb-sort) y móvil ---------- */
.tb-table th button:hover { color: var(--text); }
.tb-table th[aria-sort] button:hover { color: var(--lime-soft); }
.tb-table th button:focus-visible { box-shadow: var(--focus-ring); border-radius: 6px; }
.tb-sort-ico { display: inline-block; min-width: 10px; font-size: 10px; }
.tb-table th.num button { flex-direction: row-reverse; }
.tb-table a { color: var(--text); font-weight: 700; text-decoration: none; }
.tb-table a:hover { color: var(--lime); }

/* ---------- Formularios de Django (.tb-form y bloque/campo.html) ---------- */
.tb-form--auto > div, .tb-form--auto > p { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.tb-form--auto > div > label, .tb-form--auto > p > label { font: 700 13px/16px var(--font-sans); color: var(--text-2); }
.tb-form input[type="url"]:not(.tb-input), .tb-form input[type="tel"]:not(.tb-input), .tb-form input[type="search"]:not(.tb-input),
.tb-form input[type="time"]:not(.tb-input), .tb-form input[type="datetime-local"]:not(.tb-input), .tb-form input[type="month"]:not(.tb-input) {
  width: 100%; height: var(--control); padding: 0 16px; border-radius: var(--radius-md); border: 1px solid transparent;
  background: var(--block-2); color: var(--text); font: 500 16px/22px var(--font-sans); outline: none;
}
.tb-form select:not(.tb-select) { appearance: none; padding-right: 44px; background-image: linear-gradient(45deg, transparent 50%, #FFFFFF 50%), linear-gradient(135deg, #FFFFFF 50%, transparent 50%); background-position: calc(100% - 22px) 21px, calc(100% - 16px) 21px; background-size: 6px 6px; background-repeat: no-repeat; }
.tb-form select[multiple]:not(.tb-select) { height: auto; min-height: 120px; padding: 8px; background-image: none; }
.tb-form input::placeholder, .tb-form textarea::placeholder { color: var(--placeholder); }
.tb-form [aria-invalid="true"], .tb-field.is-invalid input:not([type="checkbox"]):not([type="radio"]), .tb-field.is-invalid select, .tb-field.is-invalid textarea { border-color: var(--coral) !important; }
.tb-form .helptext { font: 500 13px/18px var(--font-sans); color: var(--text-2); }
.tb-field__opt { font-weight: 500; color: var(--text-3); }
.tb-form fieldset, fieldset.tb-field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.tb-field legend { padding: 0; margin-bottom: 6px; }
/* Casillas y radios sin clase (los pinta Django) con el aspecto de tb-check */
.tb-form input[type="checkbox"], .tb-form input[type="radio"], .tb-field input[type="checkbox"], .tb-field input[type="radio"] {
  appearance: none; width: 24px; height: 24px; margin: 0; flex-shrink: 0; border-radius: 8px; box-shadow: inset 0 0 0 2px var(--line-control);
  background: transparent; display: inline-grid; place-content: center; cursor: pointer; vertical-align: middle;
}
.tb-form input[type="radio"], .tb-field input[type="radio"] { border-radius: 50%; }
.tb-form input[type="checkbox"]:checked, .tb-field input[type="checkbox"]:checked { background: var(--lime); box-shadow: none; }
.tb-form input[type="checkbox"]:checked::after, .tb-field input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 6px; border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: translateY(-2px) rotate(-45deg); }
.tb-form input[type="radio"]:checked, .tb-field input[type="radio"]:checked { box-shadow: inset 0 0 0 2px var(--lime); }
.tb-form input[type="radio"]:checked::after, .tb-field input[type="radio"]:checked::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--lime); }
.tb-form input[type="checkbox"]:focus-visible, .tb-form input[type="radio"]:focus-visible, .tb-field input[type="checkbox"]:focus-visible, .tb-field input[type="radio"]:focus-visible { box-shadow: var(--focus-ring); }
/* El interruptor tapa la casilla: deshace lo de arriba dentro de .tb-switch */
.tb-switch input[type="checkbox"] { appearance: none; position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; box-shadow: none; background: none; border-radius: 16px; }
.tb-switch input[type="checkbox"]:checked::after { display: none; }
.tb-check--switch { gap: 12px; }
/* Radios / casillas múltiples de Django: <div id><div><label><input> Texto</label></div>… */
.tb-choices > div { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tb-choices > div > div { display: contents; }
.tb-choices label { display: inline-flex; align-items: center; gap: 10px; min-height: var(--touch); padding: 8px 16px 8px 12px; border-radius: var(--radius-md); background: var(--block-2); color: var(--text); font: 600 15px/20px var(--font-sans); cursor: pointer; }
.tb-choices label:has(input:checked) { background: var(--lime-tint); box-shadow: inset 0 0 0 2px var(--lime); }
.tb-choices--stack > div { flex-direction: column; align-items: stretch; }
/* Archivo: aspecto de tb-upload */
.tb-form input[type="file"], .tb-field--file input[type="file"] {
  width: 100%; padding: var(--space-5); border-radius: var(--radius-md); background: var(--block-2); box-shadow: inset 0 0 0 2px var(--line-control);
  color: var(--text-2); font: 600 14px/20px var(--font-sans); cursor: pointer; box-sizing: border-box;
}
.tb-form input[type="file"]::file-selector-button, .tb-field--file input[type="file"]::file-selector-button {
  margin-right: 12px; height: 40px; padding: 0 16px; border: 0; border-radius: var(--radius-pill); background: var(--paper); color: var(--ink); font: 700 13px var(--font-sans); cursor: pointer;
}
.tb-field--file { font: 500 13px/18px var(--font-sans); color: var(--text-2); }
.tb-field--file a { color: var(--lime); }
.tb-field--file label:not(.tb-field__label) { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }

/* ---------- ApexCharts con el tema de la base (tbApex) ---------- */
.apexcharts-tooltip.apexcharts-theme-dark { background: var(--block-2) !important; border: 0 !important; border-radius: var(--radius-md) !important; box-shadow: var(--shadow-float) !important; color: var(--text) !important; }
.apexcharts-tooltip.apexcharts-theme-dark .apexcharts-tooltip-title { background: var(--block) !important; border-bottom: 1px solid var(--line) !important; font-weight: 700; }
.apexcharts-xaxistooltip, .apexcharts-yaxistooltip { background: var(--block-2) !important; border: 0 !important; color: var(--text) !important; }
.apexcharts-xaxistooltip::before, .apexcharts-xaxistooltip::after { display: none; }
.apexcharts-legend-text { color: var(--text-2) !important; }
.apexcharts-canvas text { font-variant-numeric: tabular-nums; }

/* El rótulo del embudo y su chip («Cuello en …») bajan de línea si no caben. */
.tb-embudo .tb-block__head { flex-wrap: wrap; }

/* El contenido largo de cajones y diálogos se desplaza, no se aplasta. */
.tb-drawer__body > *, .tb-modal > *, .tb-modal__body > * { flex-shrink: 0; }

/* .tb-tabs__item también como <button> */
button.tb-tabs__item { border: 0; background: transparent; cursor: pointer; font: 700 14px/18px var(--font-sans); }
button.tb-tabs__item[aria-current="page"], button.tb-tabs__item[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: none; }

/* ---------- Ajustes compartidos (revisión de páginas de administración) ---------- */
a.tb-chip-btn, a.tb-stat, a.tb-stat:hover, a.tb-chip-btn:hover { text-decoration: none; }
.tb-kv { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.tb-form--row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; max-width: none; }
.tb-table td[colspan] .tb-empty { position: sticky; left: 0; max-width: calc(100vw - 72px); }
.tb-alert strong { font-weight: 800; }
@media (max-width: 899px) {
  .tb-hero__value { font-size: clamp(36px, 12vw, 56px); }
  .tb-hero--xl .tb-hero__value { font-size: clamp(40px, 13vw, 84px); }
  .tb-stat__value { font-size: clamp(24px, 9vw, 44px); }
  .tb-stat--sm .tb-stat__value { font-size: clamp(20px, 7vw, 26px); }
}
