:root {
  --display-font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-scale: 1;
  --digit-factor: 1;
  --panel-radius: 20px;
  --turn-accent: #0284c7;
  --blink-color: #0284c7;
  --panel-alpha: 1;
  --panel-bg-rgb: 255, 255, 255;
  --bg-canvas-gradient: none;

  /* Light Theme Palette (60-30-10) */
  --bg-canvas: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-surface-alt: #eef2f6;
  --border-hairline: rgba(15, 23, 42, 0.1);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --sidebar-bg: rgba(255, 255, 255, 0.72);
  --sidebar-border: rgba(15, 23, 42, 0.12);
  --sidebar-ink: #1e293b;
  --modal-bg: #ffffff;
  --modal-overlay: rgba(15, 23, 42, 0.56);
  --input-bg: #f8fafc;
  --popover-bg: #ffffff;
  --popover-ink: #0f172a;
  --popover-muted: #64748b;
  --popover-border: rgba(15, 23, 42, 0.1);
  --popover-hover: #eef2f6;
}

body[data-theme='dark'] {
  --bg-canvas: #0b1120;
  --bg-surface: #131c31;
  --panel-bg-rgb: 19, 28, 49;
  --bg-surface-alt: #1b2640;
  --border-hairline: rgba(248, 250, 252, 0.12);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --sidebar-bg: rgba(19, 28, 49, 0.72);
  --sidebar-border: rgba(248, 250, 252, 0.16);
  --sidebar-ink: #f1f5f9;
  --modal-bg: #111827;
  --modal-overlay: rgba(2, 6, 23, 0.72);
  --input-bg: #1e293b;
  --popover-bg: #111827;
  --popover-ink: #f8fafc;
  --popover-muted: #94a3b8;
  --popover-border: rgba(248, 250, 252, 0.12);
  --popover-hover: #1b2640;
}

/* Presets avanzados de fondo (aplican solo al frontend #tv-app, nunca a los modales de configuración) */
#tv-app[data-bg-preset='corporate'] {
  --bg-canvas: #b8d4f5;
  --bg-canvas-gradient: linear-gradient(135deg, #b5d2f4 0%, #dcebff 55%, #c2dcf9 100%);
  --bg-surface: #ffffff;
  --panel-bg-rgb: 255, 255, 255;
  --bg-surface-alt: #e3eefb;
  --border-hairline: rgba(15, 45, 92, 0.16);
  --text-primary: #0b2545;
  --text-secondary: #1e426e;
  --text-muted: #3b5e8a;
  --sidebar-bg: rgba(255, 255, 255, 0.8);
  --sidebar-border: rgba(15, 45, 92, 0.16);
  --sidebar-ink: #0b2545;
}

#tv-app[data-bg-preset='modern-green'] {
  --bg-canvas: #b6e3cf;
  --bg-canvas-gradient: linear-gradient(135deg, #b3e0cc 0%, #def5eb 55%, #bfe8d6 100%);
  --bg-surface: #ffffff;
  --panel-bg-rgb: 255, 255, 255;
  --bg-surface-alt: #e1f3eb;
  --border-hairline: rgba(6, 78, 59, 0.16);
  --text-primary: #063529;
  --text-secondary: #145341;
  --text-muted: #2d6f5b;
  --sidebar-bg: rgba(255, 255, 255, 0.8);
  --sidebar-border: rgba(6, 78, 59, 0.16);
  --sidebar-ink: #063529;
}

#tv-app[data-bg-preset='slate-dark'] {
  --bg-canvas: #090e1a;
  --bg-canvas-gradient: linear-gradient(135deg, #070b14 0%, #162238 60%, #0d1526 100%);
  --bg-surface: #131c31;
  --panel-bg-rgb: 19, 28, 49;
  --bg-surface-alt: #1e293b;
  --border-hairline: rgba(248, 250, 252, 0.15);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --sidebar-bg: rgba(18, 26, 43, 0.78);
  --sidebar-border: rgba(248, 250, 252, 0.18);
  --sidebar-ink: #f8fafc;
}

#tv-app[data-bg-preset='high-contrast'] {
  --bg-canvas: #000000;
  --bg-canvas-gradient: none;
  --bg-surface: #0c0c0c;
  --panel-bg-rgb: 12, 12, 12;
  --bg-surface-alt: #171717;
  --border-hairline: rgba(250, 204, 21, 0.42);
  --text-primary: #facc15;
  --text-secondary: #fef08a;
  --text-muted: #fde047;
  --sidebar-bg: rgba(15, 15, 15, 0.85);
  --sidebar-border: rgba(250, 204, 21, 0.45);
  --sidebar-ink: #facc15;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: var(--display-font);
  background: var(--bg-canvas);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body.mode-tv {
  overflow: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   PANTALLA PRINCIPAL TV / NAVEGADOR (SIN SCROLL)
   ========================================================= */
.tv-viewport {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: var(--bg-canvas);
  background-image: var(--bg-canvas-gradient, none);
  transition: background-color 200ms ease, color 200ms ease;
}

.bg-image-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
  z-index: 0;
}

.bg-image-layer.active {
  opacity: 1;
}

.bg-scrim-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 50% 35%, rgba(2, 132, 199, 0.06), transparent 65%);
}

.bg-image-layer.active + .bg-scrim-layer {
  background: rgba(2, 6, 23, 0.35);
}

/* Barra superior */
.tv-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(10px, 2vh, 22px) clamp(16px, 3vw, 40px);
  flex-shrink: 0;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-logo-img {
  height: calc(clamp(28px, 3.6vw, 46px) * var(--logo-scale, 1));
  width: auto;
  max-width: min(80vw, 860px);
  max-height: 36vh;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  transition: height 0.12s ease;
}

.brand-cube {
  width: clamp(22px, 2.4vw, 34px);
  height: clamp(20px, 2.2vw, 30px);
  flex-shrink: 0;
}

.brand-name {
  font-weight: 800;
  font-size: clamp(1rem, 1.8vw, 1.5rem);
  letter-spacing: -0.025em;
}

.weather-clock-panel {
  display: inline-flex;
  align-items: center;
  gap: clamp(10px, 1.5vw, 20px);
  padding: 6px 14px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: clamp(0.875rem, 1.6vw, 1.35rem);
  font-weight: 600;
  white-space: nowrap;
}

.weather-widget {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.weather-icon {
  display: inline-flex;
  width: 1.15em;
  height: 1.15em;
  color: var(--turn-accent);
}

.weather-icon svg {
  width: 100%;
  height: 100%;
}

.weather-temp {
  color: var(--text-primary);
  font-weight: 700;
}

.meta-sep {
  opacity: 0.45;
}

.clock-widget {
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Área central de Turno */
.tv-stage {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  width: 100%;
  padding: clamp(6px, 1.2vh, 14px) clamp(12px, 2.2vw, 32px);
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: clamp(12px, 2vw, 28px);
  overflow: hidden;
  cursor: pointer;
  outline: none;
}

.tv-stage:focus-visible {
  box-shadow: inset 0 0 0 2px var(--turn-accent);
}

.turn-card {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: min(1680px, 96vw);
  height: 100%;
  max-height: 100%;
  background: rgba(var(--panel-bg-rgb, 255, 255, 255), var(--panel-alpha, 1));
  border: 1px solid var(--border-hairline);
  border-radius: var(--panel-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 2.5vh, 36px) clamp(20px, 3.5vw, 48px);
  text-align: center;
  box-shadow: 0 20px 50px -24px rgba(15, 23, 42, calc(0.16 * var(--panel-alpha, 1)));
  transition: background-color 180ms ease, border-color 180ms ease, transform 160ms ease;
  overflow: hidden;
}

.tv-stage.with-history .turn-card {
  flex: 1.35;
  max-width: none;
}

.tv-stage.with-media {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
}

.tv-stage.with-media .turn-card {
  flex: none;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-width: none;
  max-height: 100%;
}

.turn-card.is-flashing {
  animation: turn-flash 380ms ease-in-out;
}

@keyframes turn-flash {
  0%, 100% {
    box-shadow: 0 20px 50px -24px rgba(15, 23, 42, 0.16);
    border-color: var(--border-hairline);
  }
  50% {
    box-shadow: 0 0 0 5px var(--blink-color), 0 24px 60px -16px var(--blink-color);
    border-color: var(--blink-color);
  }
}

.turn-group-label {
  font-size: calc(clamp(1.35rem, 3.8vmin, 3.2rem) * var(--font-scale));
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: clamp(4px, 1vh, 12px);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-caption {
  font-size: calc(clamp(1.1rem, 2.8vmin, 2.2rem) * var(--font-scale));
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  margin-bottom: clamp(4px, 1.4vh, 16px);
}

.turn-number-display {
  font-size: min(calc(clamp(5rem, 34vmin, 28rem) * var(--font-scale) * var(--digit-factor)), 78vw);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--turn-accent);
  max-width: 100%;
  white-space: nowrap;
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tv-stage.with-history .turn-number-display,
.tv-stage.with-media .turn-number-display {
  font-size: min(calc(clamp(4.5rem, 30vmin, 24rem) * var(--font-scale) * var(--digit-factor)), 38vw);
}

#tv-app[data-bg-preset='high-contrast'] .turn-number-display {
  color: #facc15;
}

.turn-client-label {
  margin-top: clamp(8px, 2vh, 22px);
  font-size: calc(clamp(1.15rem, 3vmin, 2.4rem) * var(--font-scale));
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* Botones en pantalla (Avanzar / Retroceder) */
.onscreen-controls {
  margin-top: clamp(12px, 2.5vh, 28px);
  display: inline-flex;
  align-items: center;
  gap: clamp(10px, 1.8vw, 20px);
  z-index: 3;
}

.screen-step-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: clamp(8px, 1.2vh, 14px) clamp(16px, 2vw, 26px);
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  font-family: inherit;
  font-size: clamp(0.875rem, 1.4vw, 1.125rem);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 120ms ease, background-color 150ms ease;
}

.screen-step-btn:hover {
  transform: translateY(-1px);
}

.screen-step-btn:active {
  transform: translateY(0);
}

.screen-step-btn svg {
  width: 1.15em;
  height: 1.15em;
}

.screen-step-btn--primary {
  background: var(--turn-accent);
  border-color: transparent;
  color: #ffffff;
}

/* Panel Auxiliar Histórico */
.history-panel {
  flex: 0.85;
  height: 100%;
  max-height: 100%;
  background: rgba(var(--panel-bg-rgb, 255, 255, 255), var(--panel-alpha, 1));
  border: 1px solid var(--border-hairline);
  border-radius: var(--panel-radius);
  padding: clamp(14px, 2.4vh, 28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-header {
  font-size: calc(clamp(0.95rem, 2vmin, 1.5rem) * var(--font-scale));
  font-weight: 700;
  color: var(--text-secondary);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-hairline);
  margin-bottom: 12px;
  flex-shrink: 0;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.4vh, 14px);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(8px, 1.4vh, 14px) 14px;
  border-radius: 12px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
}

.history-item-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.history-item-group {
  font-size: clamp(0.85rem, 1.5vmin, 1.15rem);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-client {
  font-size: clamp(0.75rem, 1.2vmin, 0.95rem);
  color: var(--text-muted);
}

.history-item-code {
  font-size: calc(clamp(1.35rem, 3.2vmin, 2.4rem) * var(--font-scale));
  font-weight: 800;
  color: var(--turn-accent);
  white-space: nowrap;
}

.history-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Panel Auxiliar Multimedia (Carrusel / YouTube) */
.media-panel {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  background: rgba(var(--panel-bg-rgb, 255, 255, 255), var(--panel-alpha, 1));
  border: 1px solid var(--border-hairline);
  border-radius: var(--panel-radius);
  padding: clamp(10px, 1.5vh, 16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: default;
}

.media-panel-body {
  position: relative;
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  border-radius: calc(var(--panel-radius) - 6px);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-carousel-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.media-slide-img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transition: opacity 550ms ease;
  pointer-events: none;
}

.media-carousel-stage[data-fit='cover'] .media-slide-img {
  object-fit: cover;
}

.media-slide-img.is-active {
  opacity: 1;
}

.media-carousel-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
}

.media-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transition: transform 200ms ease, background-color 200ms ease;
}

.media-dot.is-active {
  background: #ffffff;
  transform: scale(1.25);
}

.media-youtube-stage {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #000000;
}

.media-youtube-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.media-empty-state {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

/* Pie de página: Marquesina + Marca de agua turnero.com */
.tv-footer {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  width: 100%;
}

.marquee-bar {
  display: flex;
  align-items: center;
  width: 100%;
  height: clamp(36px, 5.2vh, 52px);
  background: #b91c1c;
  color: #ffffff;
  overflow: hidden;
}

.marquee-track-wrap {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}

.marquee-track {
  display: inline-block;
  padding-left: 100%;
  font-size: clamp(0.95rem, 1.8vmin, 1.35rem);
  font-weight: 600;
  animation: marquee-scroll 18s linear infinite;
}

@keyframes marquee-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

.watermark-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px 8px;
  pointer-events: none;
}

.watermark-text {
  font-size: clamp(0.75rem, 1.3vmin, 0.92rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  opacity: 0.65;
}

/* =========================================================
   BARRA LATERAL IZQUIERDA (SEMITRANSPARENTE + AUTO-OCULTADO 10s)
   ========================================================= */
.left-sidebar {
  position: fixed;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0.42;
  transition: opacity 240ms ease, transform 240ms ease;
}

.left-sidebar:hover,
.left-sidebar:focus-within,
.left-sidebar.is-pinned {
  opacity: 0.96;
}

.left-sidebar.is-hidden {
  opacity: 0 !important;
  pointer-events: none;
  transform: translateY(-50%) translateX(-18px);
}

.sb-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sidebar-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.sb-btn svg {
  width: 18px;
  height: 18px;
}

.sb-btn:hover {
  background: var(--bg-surface-alt);
}

.sb-btn:focus-visible {
  outline: 2px solid var(--turn-accent);
  outline-offset: 1px;
}

.sb-btn.is-active {
  background: rgba(2, 132, 199, 0.14);
  color: var(--turn-accent);
  border-color: rgba(2, 132, 199, 0.32);
}

.sb-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: #0f172a;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.sb-btn:hover::after,
.sb-btn:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.sb-divider {
  width: 22px;
  height: 1px;
  background: var(--border-hairline);
  margin: 2px 0;
}

/* Popovers de la barra lateral */
.sb-popover {
  position: fixed;
  left: 68px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  width: 250px;
  padding: 14px;
  border-radius: 12px;
  background: var(--popover-bg);
  color: var(--popover-ink);
  border: 1px solid var(--popover-border);
  box-shadow: 0 18px 40px -12px rgba(15, 23, 42, 0.32);
}

.popover-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.popover-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.popover-range-row input[type='range'] {
  flex: 1;
  accent-color: #0284c7;
}

.mini-btn {
  padding: 4px 10px;
  min-height: 32px;
  border-radius: 7px;
  border: 1px solid var(--popover-border);
  background: var(--popover-hover);
  color: var(--popover-ink);
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.popover-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--popover-muted);
}

.font-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.font-option {
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--popover-ink);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.font-option:hover {
  background: var(--popover-hover);
}

.font-option.active {
  background: rgba(2, 132, 199, 0.12);
  border-color: rgba(2, 132, 199, 0.3);
  color: #0284c7;
  font-weight: 600;
}

/* Toast */
.toast-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 9px 16px;
  border-radius: 10px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

/* =========================================================
   MODALES (REGISTRO, CONFIGURACIÓN AVANZADA, ACERCA DE)
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--modal-overlay);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-height: 90dvh;
  background: var(--modal-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 28px 64px -18px rgba(0, 0, 0, 0.45);
}

.modal-card--sm {
  max-width: 480px;
}

.modal-card--lg {
  max-width: 780px;
}

.modal-card--adv {
  width: auto;
  min-width: min(740px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-hairline);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-subtitle {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-hairline);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--bg-surface-alt);
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-lead {
  margin: 0 0 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Formularios e Inputs */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-span-2 {
  grid-column: span 2;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field input[type='text'],
.field input[type='email'],
.field input[type='password'],
.field input[type='number'],
.field input[type='date'],
.field textarea,
.field select {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-hairline);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.field input[type='color'] {
  width: 100%;
  height: 40px;
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border-hairline);
  background: var(--input-bg);
  cursor: pointer;
}

.field input:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--turn-accent);
  outline-offset: 1px;
}

.field-hint {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.form-error {
  margin: 0;
  color: #dc2626;
  font-size: 0.85rem;
  font-weight: 600;
}

.form-success {
  margin: 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(22, 163, 74, 0.12);
  border: 1px solid rgba(22, 163, 74, 0.35);
  color: #15803d;
  font-size: 0.85rem;
  font-weight: 600;
}

.toggle-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-primary);
  cursor: pointer;
}

.check-row input[type='checkbox'] {
  width: 17px;
  height: 17px;
  accent-color: var(--turn-accent);
}

.file-row,
.inline-search {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-config-block {
  padding-top: 14px;
  margin-top: 6px;
  border-top: 1px solid var(--border-hairline);
}

.logo-config-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-preview-thumb {
  height: 44px;
  max-width: 150px;
  width: auto;
  object-fit: contain;
  border-radius: 8px;
  padding: 4px 8px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
  flex-shrink: 0;
}

.logo-file-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.logo-file-actions input[type='file'] {
  font-size: 0.82rem;
  color: var(--text-secondary);
  max-width: 100%;
}

.logo-file-actions .btn-secondary {
  align-self: flex-start;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.82rem;
}

.logo-scale-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.logo-scale-row input[type='range'] {
  flex: 1;
  accent-color: var(--turn-accent);
  cursor: pointer;
}

.logo-scale-num-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-weight: 700;
  color: var(--text-primary);
}

.logo-scale-num-wrap input[type='number'] {
  width: 74px;
  text-align: right;
  padding: 6px 8px;
}

.inline-search input {
  flex: 1;
}

.preview-strip {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}

.preview-strip strong {
  font-size: 1.35rem;
  color: var(--turn-accent);
}

/* Tabs Configuración Avanzada */
.adv-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border-hairline);
  overflow-x: auto;
  flex-shrink: 0;
}

.adv-tab {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.adv-tab:hover {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
}

.adv-tab.active {
  background: rgba(2, 132, 199, 0.14);
  color: var(--turn-accent);
}

.adv-body {
  flex: 1;
  min-height: 0;
}

.adv-panel {
  display: none;
}

.adv-panel.active {
  display: block;
}

.adv-section-block {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-hairline);
}

.adv-section-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.adv-section-block h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

/* Botones generales */
.btn-primary,
.btn-secondary,
.btn-danger-outline {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 140ms ease, background-color 140ms ease;
}

.btn-primary {
  border: none;
  background: #0284c7;
  color: #ffffff;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  border: 1px solid var(--border-hairline);
  background: var(--bg-surface-alt);
  color: var(--text-primary);
}

.btn-danger-outline {
  border: 1px solid rgba(220, 38, 38, 0.35);
  background: transparent;
  color: #dc2626;
}

/* Perfil y Acerca de */
.profile-summary,
.about-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-row,
.about-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
  font-size: 0.86rem;
}

.profile-row span,
.about-item span {
  color: var(--text-muted);
}

/* Tabla de Clientes */
.clients-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.clients-zero-notice {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.28);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 500;
}

.inline-add-client {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.clients-table-wrap {
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  overflow-x: auto;
}

.clients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.clients-table th,
.clients-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-hairline);
  text-align: left;
}

.clients-table th {
  background: var(--bg-surface-alt);
  font-weight: 700;
  color: var(--text-secondary);
}

.clients-table tr:last-child td {
  border-bottom: none;
}

.text-right {
  text-align: right !important;
}

.client-link-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--turn-accent);
  text-decoration: none;
}

.client-link-code:hover {
  text-decoration: underline;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.mini-action-btn {
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.mini-action-btn--danger {
  color: #dc2626;
}

/* =========================================================
   VISTA TERMINAL CLIENTE DE LLAMADO (?cliente=...)
   ========================================================= */
.client-viewport {
  min-height: 100dvh;
  background: var(--bg-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.client-shell {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.client-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.client-exit-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--turn-accent);
  text-decoration: none;
}

.client-exit-link:hover {
  text-decoration: underline;
}

.client-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 18px 40px -20px rgba(15, 23, 42, 0.2);
}

.client-station-title {
  font-size: 1.5rem;
  font-weight: 800;
}

.client-station-sector {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.client-visor {
  margin: 18px 0;
  padding: 22px 16px;
  border-radius: 12px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
}

.client-visor-sector {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.client-visor-number {
  font-size: clamp(2.8rem, 11vw, 4.4rem);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.05;
  margin: 6px 0;
}

.client-visor-puesto {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.client-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.client-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.client-btn {
  min-height: 48px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffffff;
  cursor: pointer;
  transition: transform 110ms ease, opacity 140ms ease;
}

.client-btn:active {
  transform: scale(0.99);
}

.client-btn--next {
  background: #16a34a;
  min-height: 56px;
  font-size: 1rem;
}

.client-btn--prev {
  background: #64748b;
}

.client-btn--reannounce {
  background: #0284c7;
}

.client-btn--reset {
  background: #ea580c;
}

.client-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* =========================================================
   TABS LOGIN / REGISTRO Y MENÚ ADMINISTRADOR (?admin=1)
   ========================================================= */
.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 10px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
}

.auth-switch-btn {
  min-height: 36px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.auth-switch-btn.active {
  background: var(--modal-bg);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.admin-viewport {
  min-height: 100dvh;
  background: var(--bg-canvas);
  color: var(--text-primary);
}

.admin-gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.admin-gate-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 16px;
  padding: 26px;
}

.admin-workspace {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
  flex-wrap: wrap;
}

.admin-nav-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
}

.admin-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.admin-nav-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.admin-nav-btn:hover {
  color: var(--text-primary);
}

.admin-nav-btn.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.28);
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-source-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.admin-main {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 18px 20px;
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-value {
  margin-top: 6px;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.kpi-meta {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 18px;
  align-items: start;
}

.admin-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 20px;
}

.admin-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.admin-panel-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.daily-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  padding: 12px 6px 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-hairline);
  overflow-x: auto;
}

.chart-col {
  flex: 1;
  min-width: 28px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.chart-bar-wrap {
  width: 100%;
  max-width: 34px;
  flex: 1;
  display: flex;
  align-items: flex-end;
}

.chart-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 5px 5px 0 0;
  background: #0284c7;
}

.chart-val {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.chart-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}

.admin-filters input[type='text'] {
  min-width: 240px;
  flex: 1;
  max-width: 340px;
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-hairline);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
}

.segmented-filter {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
}

.seg-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
}

.user-subtext {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-ok {
  color: #16a34a;
  font-weight: 600;
}

.status-blocked {
  color: #dc2626;
  font-weight: 600;
}

/* =========================================================
   IDIOMA, CLIENTE REMOTO, CONTACTO Y ESTADÍSTICAS DE USUARIO
   ========================================================= */
.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lang-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.72;
}

.client-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.client-gate-heading {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 700;
}

.client-uid-tag {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.client-pass-editor {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.client-pass-editor input {
  flex: 1;
  min-width: 120px;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--border-hairline);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.78rem;
}

.contact-divider {
  height: 1px;
  background: var(--border-hairline);
  margin: 18px 0 16px;
}

.contact-section h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
}

.auth-forgot-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -4px;
}

.text-link-btn {
  border: none;
  background: transparent;
  padding: 2px 0;
  color: var(--turn-accent);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.text-link-btn:hover {
  text-decoration: underline;
}

.forgot-heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.client-company-badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(2, 132, 199, 0.12);
  color: var(--turn-accent);
  font-size: 0.84rem;
  font-weight: 700;
}

.shared-link-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 9px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
  flex-wrap: wrap;
}

.shared-link-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Modal Estadísticas */
.stats-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-hairline);
}

.stats-toolbar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.stats-presets {
  display: inline-flex;
  gap: 6px;
}

.stats-presets .mini-action-btn.active {
  background: rgba(2, 132, 199, 0.14);
  border-color: rgba(2, 132, 199, 0.4);
  color: var(--turn-accent);
}

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stats-kpi-grid .kpi-card {
  padding: 14px 16px;
}

.stats-kpi-grid .kpi-value {
  font-size: 1.55rem;
}

.stats-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stats-chart-box {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 14px;
}

.stats-chart-box h3 {
  margin: 0 0 12px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.stats-bars-24 {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 3px;
  height: 150px;
  align-items: end;
  padding-top: 8px;
  border-bottom: 1px solid var(--border-hairline);
}

.stats-bar-24-col {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.stats-bar-24-wrap {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
}

.stats-bar-24-fill {
  width: 100%;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
  background: rgba(2, 132, 199, 0.55);
}

.stats-bar-24-fill.is-peak {
  background: #0284c7;
}

.stats-bar-24-lbl {
  font-size: 0.62rem;
  color: var(--text-muted);
}

@media (max-width: 960px) {
  .kpi-grid,
  .stats-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-grid-2,
  .stats-charts-grid {
    grid-template-columns: 1fr;
  }
  .stats-toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .stats-toolbar-actions {
    grid-column: span 2;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

@media (max-width: 760px) {
  .tv-stage.with-history {
    flex-direction: column;
  }
  .tv-stage.with-media {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }
  .tv-stage.with-history .turn-number-display,
  .tv-stage.with-media .turn-number-display {
    font-size: min(calc(clamp(3.6rem, 22vmin, 14rem) * var(--font-scale) * var(--digit-factor)), 72vw);
  }
  .history-panel {
    width: 100%;
    max-height: 28dvh;
  }
  .tv-stage.with-media .media-panel {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
  }
  .form-grid-2,
  .inline-add-client,
  .kpi-grid,
  .stats-kpi-grid,
  .stats-toolbar {
    grid-template-columns: 1fr;
  }
  .stats-toolbar-actions {
    grid-column: span 1;
  }
  .form-span-2 {
    grid-column: span 1;
  }
  .admin-topbar,
  .admin-main {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .turn-card.is-flashing {
    animation: none;
  }
  .marquee-track {
    animation: none;
    padding-left: 16px;
  }
}

/* =========================================================
   SUSCRIPCIÓN DE EMPRESA (BANNER, BLOQUEO, VENTAJAS Y ADMIN)
   ========================================================= */
.sub-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 10px;
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.28);
}

.sub-banner.is-active {
  background: rgba(22, 163, 74, 0.1);
  border-color: rgba(22, 163, 74, 0.34);
}

.sub-banner.is-expired {
  background: rgba(234, 88, 12, 0.1);
  border-color: rgba(234, 88, 12, 0.35);
}

.sub-banner-copy {
  min-width: 0;
  flex: 1;
}

.sub-banner-copy strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.sub-banner-copy p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.sub-lock-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 9px;
  background: rgba(234, 88, 12, 0.08);
  border: 1px solid rgba(234, 88, 12, 0.3);
  color: var(--text-primary);
  font-size: 0.83rem;
  font-weight: 500;
  flex-wrap: wrap;
}

.sub-is-locked {
  opacity: 0.56;
}

.sub-lock-card,
.about-sub-card {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 11px;
  background: rgba(2, 132, 199, 0.07);
  border: 1px solid rgba(2, 132, 199, 0.26);
}

.sub-lock-card {
  margin-top: 0;
  padding: 20px;
}

.sub-lock-card h3,
.about-sub-card h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sub-benefits-list {
  margin: 0 0 14px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.admin-sub-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
}

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

.seg-sub-btn {
  min-height: 30px;
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.seg-sub-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.sub-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
}

.sub-pill.is-active {
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
}

.sub-pill.is-expired {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.sub-pill.is-free {
  background: var(--bg-surface-alt);
  color: var(--text-muted);
}

body[data-theme='dark'] .sub-pill.is-active {
  color: #4ade80;
}

body[data-theme='dark'] .sub-pill.is-expired {
  color: #f87171;
}

.admin-sub-inline-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-sub-inline-date input[type='date'] {
  min-height: 34px;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid var(--border-hairline);
  background: var(--modal-input-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.84rem;
}

@media (max-width: 760px) {
  .sub-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .kpi-grid-3 {
    grid-template-columns: 1fr;
  }
}

.admin-stats-filter-panel {
  margin-bottom: 18px;
  padding: 14px 18px;
}

.admin-stats-toolbar {
  margin-bottom: 0;
}

.admin-filter-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.seg-stats-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.seg-stats-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.admin-period-input {
  min-height: 36px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-hairline);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.86rem;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.84rem;
}

.country-cell-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
}

.country-flag-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14);
  line-height: 0;
}

.country-flag-svg {
  width: 15px;
  height: 10px;
  display: block;
}

.sub-logo-free-note {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(234, 88, 12, 0.08);
  border: 1px solid rgba(234, 88, 12, 0.25);
  color: var(--text-secondary);
}

.media-gallery-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.media-thumb-card {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  background: var(--bg-surface-alt);
}

.media-thumb-img {
  width: 100%;
  height: 86px;
  object-fit: cover;
  display: block;
  background: rgba(15, 23, 42, 0.08);
}

.media-thumb-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 6px 8px;
}

.media-thumb-actions .mini-action-btn {
  padding: 3px 7px;
  font-size: 0.72rem;
}

.admin-users-feedback {
  margin: -4px 0 12px;
  min-height: 18px;
}

.admin-users-feedback.is-ok {
  color: #16a34a;
  font-weight: 600;
}

.admin-users-feedback.is-error {
  color: #dc2626;
  font-weight: 600;
}

/* Modal de bienvenida visual (Onboarding) */
.onb-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  min-width: 0;
}

.onb-visual-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  padding: 10px;
  border-radius: 14px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-hairline);
  overflow: hidden;
}

.onb-hero-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 240px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border-hairline);
}

.onb-keys-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.onb-key-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.onb-key-hint--next {
  background: rgba(2, 132, 199, 0.14);
  color: #0369a1;
  border: 1px solid rgba(2, 132, 199, 0.32);
}

.onb-key-hint--prev {
  background: rgba(71, 85, 105, 0.12);
  color: var(--text-primary);
  border: 1px solid rgba(71, 85, 105, 0.25);
}

body[data-theme='dark'] .onb-key-hint--next {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.35);
}

body[data-theme='dark'] .onb-key-hint--prev {
  background: rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.3);
}

.onb-short-copy {
  margin: 0;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

