* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root {
  --bg: #0b0f19;
  --panel: #111927;
  --panel-2: #161c2a;
  --border: rgba(255,255,255,.08);
  --accent: #6366f1;
  --accent-ink: #0d0a2b;
  --text: #f5f7fb;
  --text-soft: #a6b0c3;
  --green: #10b981;
  --amber: #ffca28;
  --mail-color: #ffca28;
  --form-color: #00d9d9;
}
html, body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; margin: 0; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-bottom: 1px solid var(--border); }
.back-link { color: var(--text-soft); text-decoration: none; font-size: .85rem; }
.back-link:hover { color: var(--accent); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .9rem; }
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 40px 24px 80px; }

.intro { max-width: 720px; margin: 0 auto 40px; text-align: center; }
.intro-eyebrow { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.intro h1 { font-size: 1.9rem; margin: 0 0 14px; line-height: 1.25; }
.intro p { color: var(--text-soft); line-height: 1.6; font-size: .96rem; }
.intro-actions { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 24px; flex-wrap: wrap; }

.btn-play { background: linear-gradient(135deg, var(--accent), #4f46e5); color: #fff; border: none; border-radius: 10px; padding: 13px 26px; font-weight: 700; font-size: .95rem; cursor: pointer; transition: transform .15s ease, opacity .15s ease; }
.btn-play:hover { transform: translateY(-1px); }
.btn-play:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.subtitle-toggle { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--text-soft); cursor: pointer; }
.subtitle-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.mode-toggle { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.mode-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text-soft); border-radius: 8px; padding: 8px 14px; font-size: .82rem; font-weight: 600; cursor: pointer; transition: color .15s ease, border-color .15s ease; }
.mode-btn:hover { color: var(--text); }
.mode-btn.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.mode-btn-fullscreen { background: var(--panel-2); border: 1px solid var(--border); color: var(--text-soft); border-radius: 8px; padding: 8px 14px; font-size: .82rem; cursor: pointer; }
.mode-btn-fullscreen:hover { color: var(--accent); border-color: var(--accent); }

.stage-wrap { max-width: 1080px; margin: 0 auto; }
.stage-wrap.pseudo-fullscreen { position: fixed; inset: 0; z-index: 9999; max-width: none; overflow: auto; background: var(--bg); display: flex; flex-direction: column; justify-content: center; padding: 24px; }
body.pseudo-fullscreen-lock { overflow: hidden; }

.stage { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--border); border-radius: 16px; overflow: hidden; border: 1px solid var(--border); min-height: 580px; }
@media (max-width: 860px) { .stage:not([data-mode="mobile"]) { grid-template-columns: 1fr; } }

/* ---------- Modo mobile: un solo marco de teléfono; la bandeja de tickets y el panel de
   configuración son "pantallas" secuenciales dentro del mismo marco (una visible a la vez).
   script.js alterna la clase .mob-screen-active entre ambas. ---------- */
.stage[data-mode="mobile"] {
  display: block;
  position: relative;
  width: 320px; height: 640px;
  margin: 0 auto;
  background: #05070c;
  border: 10px solid #1c2536;
  border-radius: 42px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px var(--border);
  overflow: hidden;
  min-height: 0;
}
.stage[data-mode="mobile"]::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 120px; height: 22px; background: #1c2536; border-radius: 0 0 14px 14px; z-index: 5;
}
.stage[data-mode="mobile"] .stage-half {
  position: absolute; inset: 0;
  padding-top: 22px; /* despeja el notch del marco de teléfono */
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateX(16px);
  transition: opacity .28s ease, transform .28s ease, visibility .28s;
}
.stage[data-mode="mobile"] .stage-half.mob-screen-active {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(0); z-index: 2;
}
@media (max-width: 480px) {
  #btnModeDesktop { display: none; }
  .stage[data-mode="mobile"] { width: 100%; max-width: 100%; height: 78vh; border-radius: 0; border-width: 6px; }
}

.stage-half { position: relative; background: var(--panel); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.device-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }

/* ---------- Escritorio de tickets ---------- */
.tickets-topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tickets-topbar h4 { margin: 0; font-size: .88rem; }
.tickets-filtro { display: flex; gap: 4px; }
.tickets-filtro span { font-size: .68rem; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); color: var(--text-soft); }
.tickets-filtro span.active { border-color: var(--accent); color: var(--accent); }

.tickets-body { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.ticket-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; margin-bottom: 4px; background: #0f1522; border: 1px solid transparent; cursor: default; }
.ticket-row.selected { border-color: var(--accent); background: rgba(99,102,241,.1); }
.ticket-row.entering { animation: rowPulse 1.1s ease; }
@keyframes rowPulse { 0% { background: rgba(99,102,241,.35); } 100% { background: #0f1522; } }
.ticket-badge { font-size: .62rem; font-weight: 700; padding: 3px 7px; border-radius: 6px; flex-shrink: 0; text-transform: uppercase; letter-spacing: .03em; }
.ticket-badge.badge-mail { background: rgba(255,202,40,.14); color: var(--mail-color); }
.ticket-badge.badge-formulario { background: rgba(0,217,217,.14); color: var(--form-color); }
.ticket-info { flex: 1; min-width: 0; }
.ticket-nombre { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-preview { font-size: .72rem; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-estado { font-size: .68rem; color: var(--text-soft); flex-shrink: 0; }

.ticket-detalle { position: absolute; inset: 0; background: var(--panel); display: flex; flex-direction: column; animation: slideIn .25s ease; z-index: 10; }
@keyframes slideIn { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.ticket-detalle-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.ticket-detalle-head h5 { margin: 0; font-size: .86rem; }
.ticket-detalle-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: .85rem; line-height: 1.45; animation: msgIn .2s ease; }
.msg-in { align-self: flex-start; background: #1b2333; color: var(--text); border-bottom-left-radius: 3px; }
.msg-out { align-self: flex-end; background: linear-gradient(135deg, var(--accent), #4f46e5); color: #fff; border-bottom-right-radius: 3px; }
.ticket-detalle-input { border-top: 1px solid var(--border); padding: 10px; }
.ticket-detalle-input input { width: 100%; background: #0b0f19; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; color: var(--text); font-size: .85rem; }
.ticket-detalle-nota { padding: 8px 16px; font-size: .72rem; color: var(--green); display: flex; align-items: center; gap: 6px; }

/* ---------- Panel de configuración ---------- */
.config-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.config-tabs { display: flex; gap: 4px; padding: 8px 12px; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.config-tab { padding: 7px 12px; border-radius: 8px; font-size: .74rem; font-weight: 600; color: var(--text-soft); }
.config-tab.active { color: #fff; background: var(--accent); }
.config-body { flex: 1; overflow-y: auto; padding: 16px; }

.config-field { margin-bottom: 12px; }
.config-field label { display: block; font-size: .72rem; color: var(--text-soft); margin-bottom: 5px; }
.config-field input, .config-field select { width: 100%; background: #0b0f19; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: .82rem; }
.config-row-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.config-subtitle { font-size: .76rem; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; margin: 16px 0 8px; }

.theme-row { display: flex; gap: 8px; margin-bottom: 8px; }
.theme-card { flex: 1; border: 1px solid var(--border); border-radius: 9px; padding: 8px; text-align: center; font-size: .68rem; color: var(--text-soft); }
.theme-card .swatch { width: 100%; height: 34px; border-radius: 6px; margin-bottom: 6px; }
.theme-card.active { border-color: var(--accent); color: var(--accent); }

.color-field { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.color-field .dot { flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); transition: background .3s ease; }
.color-field span:not(.dot):not(.hex) { font-size: .78rem; color: var(--text-soft); flex: 1; }
.color-field .hex { font-size: .72rem; color: var(--text); font-family: monospace; }

.form-preview { position: sticky; bottom: 0; margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 16px; transition: background .3s ease, color .3s ease; }
.form-preview-title { font-weight: 700; margin-bottom: 8px; transition: color .3s ease; font-size: .88rem; }
.form-preview-field { font-size: .74rem; margin-bottom: 4px; transition: color .3s ease; }
.form-preview-field span { display: block; font-size: .68rem; opacity: .7; margin-bottom: 2px; }
.form-preview-input { height: 22px; border-radius: 5px; background: rgba(120,120,120,.15); }
.form-preview-btn { display: inline-block; margin-top: 8px; padding: 6px 14px; border-radius: 7px; font-size: .74rem; font-weight: 700; background: var(--form-color); color: #06222a; }

.stage-half, .config-body, .tickets-body, .ticket-detalle-body { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.stage-half::-webkit-scrollbar, .config-body::-webkit-scrollbar, .tickets-body::-webkit-scrollbar { width: 8px; }
.stage-half::-webkit-scrollbar-thumb, .config-body::-webkit-scrollbar-thumb, .tickets-body::-webkit-scrollbar-thumb { background-color: rgba(255,255,255,.25); border-radius: 8px; }

@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.subtitle-bar { position: fixed; left: 50%; top: 38vh; transform: translateX(-50%); z-index: 500; max-width: min(560px, 88vw); text-align: center; font-size: .9rem; line-height: 1.5; color: var(--text); background: rgba(10, 14, 22, .88); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 14px 20px; box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: subtitleIn .2s ease; }
@keyframes subtitleIn { from { opacity: 0; transform: translateX(-50%) translateY(6px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.replay-wrap { text-align: center; margin-top: 24px; }
.btn-replay { background: transparent; border: 1px solid var(--accent); color: var(--accent); }

.footnote { max-width: 720px; margin: 40px auto 0; text-align: center; }
.footnote p { color: var(--text-soft); font-size: .78rem; line-height: 1.6; }
