: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;

  /* 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;
}

body[data-theme='dark'] {
  --bg-canvas: #0b1120;
  --bg-surface: #131c31;
  --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;
}

/* Presets avanzados de fondo (para usuarios registrados) */
body[data-bg-preset='corporate'] {
  --bg-canvas: #e8f0f8;
  --bg-surface: rgba(255, 255, 255, 0.92);
  --bg-surface-alt: rgba(232, 240, 248, 0.85);
  --border-hairline: rgba(15, 23, 42, 0.1);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
}

body[data-bg-preset='modern-green'] {
  --bg-canvas: #ecf5f1;
  --bg-surface: rgba(255, 255, 255, 0.92);
  --bg-surface-alt: rgba(226, 242, 235, 0.85);
  --border-hairline: rgba(6, 78, 59, 0.14);
  --text-primary: #062e24;
  --text-secondary: #1b4d3e;
  --text-muted: #3b6e5e;
}

body[data-bg-preset='slate-dark'] {
  --bg-canvas: #090d16;
  --bg-surface: rgba(18, 26, 43, 0.92);
  --bg-surface-alt: rgba(30, 41, 59, 0.85);
  --border-hairline: rgba(248, 250, 252, 0.14);
  --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;
}

body[data-bg-preset='high-contrast'] {
  --bg-canvas: #000000;
  --bg-surface: #0a0a0a;
  --bg-surface-alt: #171717;
  --border-hairline: rgba(250, 204, 21, 0.35);
  --text-primary: #facc15;
  --text-secondary: #fef08a;
  --text-muted: #d4d4d8;
  --sidebar-bg: rgba(15, 15, 15, 0.82);
  --sidebar-border: rgba(250, 204, 21, 0.4);
  --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);
  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-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-height: 0;
  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);
  cursor: pointer;
  outline: none;
}

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

.turn-card {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: min(1680px, 96vw);
  height: 100%;
  max-height: 100%;
  background: var(--bg-surface);
  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, 0.16);
  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;
}

.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 {
  font-size: min(calc(clamp(4.5rem, 30vmin, 24rem) * var(--font-scale) * var(--digit-factor)), 48vw);
}

body[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: var(--bg-surface);
  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;
}

/* 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-brand-chip {
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  font-weight: 700;
  font-size: clamp(0.8rem, 1.4vmin, 1rem);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  z-index: 2;
}

.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(--modal-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
  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: var(--turn-accent);
}

.mini-btn {
  padding: 4px 10px;
  min-height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.popover-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-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(--text-primary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.font-option:hover {
  background: var(--bg-surface-alt);
}

.font-option.active {
  background: rgba(2, 132, 199, 0.12);
  border-color: rgba(2, 132, 199, 0.3);
  color: var(--turn-accent);
  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-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;
}

.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 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 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 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;
}

.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;
}

.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 */
.inline-add-client {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

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

.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;
}

@media (max-width: 960px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .tv-stage.with-history {
    flex-direction: column;
  }
  .history-panel {
    width: 100%;
    max-height: 28dvh;
  }
  .form-grid-2,
  .inline-add-client,
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .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;
  }
}
