:root {
  --bg: #e6edf3;
  --panel: #ffffff;
  --panel-2: #f5f8fb;
  --text: #1c2833;
  --muted: #5c6d7e;
  --faint: #8b9aab;
  --lime: #1f5f93;
  --lime-ink: #ffffff;
  --teal: #2d6a9f;
  --danger: #a33b32;
  --line: #d3dde6;
  --line-soft: #e3ebf2;
  --azul: #1f4e79;
  --serif: "Palatino Linotype", Palatino, "Iowan Old Style", Georgia, serif;
  --sans: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
a { color: var(--teal); }
::placeholder { color: var(--faint); }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.hidden { display: none !important; }
body.en-sala { overflow: hidden; }
.muted { color: var(--muted); }
.ayuda, .error { margin: 8px 0 0; font-size: 14px; }
.ayuda { color: var(--muted); }
.error { color: var(--danger); }
.aviso {
  min-height: 1.2em;
  margin: 0;
  color: var(--teal);
  font-size: 14px;
}
.aviso-error { color: var(--danger); }

.login {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(300px, 460px);
  gap: 48px;
  align-items: center;
  padding: 48px clamp(20px, 6vw, 88px);
}
.marca { display: flex; gap: 16px; align-items: center; }
.anillo {
  width: 54px;
  height: 54px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid #8eb4d4;
  box-shadow: 0 0 0 8px rgba(31, 78, 121, 0.08), inset 0 0 0 10px rgba(31, 95, 147, 0.12);
  position: relative;
}
.anillo::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.eyebrow {
  margin: 0;
  color: var(--lime);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
}
h1 {
  margin: 10px 0 0;
  font-size: clamp(40px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-weight: 650;
}
h1 em {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.03em;
}
.lead {
  max-width: 460px;
  font-size: 18px;
  line-height: 1.45;
  color: var(--muted);
}
.puntos { list-style: none; padding: 0; margin: 28px 0 0; max-width: 460px; }
.puntos li {
  position: relative;
  padding: 12px 0 12px 18px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
}
.puntos li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  position: absolute;
  left: 0;
  top: 18px;
}
.login-panel, .card, dialog {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 16px 40px rgba(28, 40, 51, 0.08);
}
.login-panel { padding: 28px; }
.login-panel h2, .card h2, .card h3, dialog h3 { margin: 6px 0 16px; font-size: 28px; letter-spacing: -0.03em; }
.campo { display: block; margin: 0 0 14px; }
.campo span, .check span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
input, textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 46px;
}
textarea {
  min-height: 140px;
  resize: vertical;
  font-family: Consolas, "Cascadia Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.45;
}
.fila { display: grid; grid-template-columns: 120px 1fr; gap: 12px; }
.checks { display: grid; gap: 4px; margin: 8px 0 14px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 36px; }
.check span { margin: 0; color: var(--text); font-size: 15px; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--lime); }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  text-decoration: none;
}
.btn-lima { background: var(--lime); color: var(--lime-ink); font-weight: 700; }
.btn-fantasma { border-color: var(--line-soft); color: var(--text); background: transparent; }
.btn-peligro { border-color: rgba(255, 176, 161, 0.45); color: var(--danger); }
.btn-bloque { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.pie-login { margin: 18px 0 0; font-size: 14px; }
.credito {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 13px;
}
.credito a { color: var(--azul); text-decoration: none; }
.pie-pwa { margin: 12px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pie-pwa .btn { min-height: 36px; padding: 6px 14px; font-size: 13px; }
.credito a:hover { text-decoration: underline; }

.sala {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #d9e2eb;
}
.barra {
  display: grid;
  grid-template-columns: auto minmax(180px, 320px) minmax(0, 1fr);
  align-items: center;
  column-gap: 16px;
  min-height: 64px;
  padding: 8px 16px;
  background: var(--azul);
  color: #f4f7fb;
  position: relative;
  z-index: 4;
}
.barra-marca {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  line-height: 1.15;
  min-width: 0;
}
.barra-marca strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.barra-marca span {
  font-size: 11px;
  color: #c5d7e8;
  white-space: nowrap;
}
.barra-lado { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.barra-quien { margin: 0; font-size: 13px; color: #d5e3f0; white-space: nowrap; }
.barra-quien span + span::before { content: " · "; }
.selector { position: relative; min-width: 0; }
.selector-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  width: 100%;
  min-height: 42px;
  padding: 4px 34px 4px 12px;
  border: 0;
  border-radius: 10px;
  background: #fff;
  color: var(--azul);
  text-align: left;
}
.selector-btn::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--azul);
  border-bottom: 2px solid var(--azul);
  transform: translateY(-70%) rotate(45deg);
}
.selector-btn[aria-expanded="true"]::after { transform: translateY(-20%) rotate(225deg); }
.selector-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
#selectorTitulo {
  max-width: 100%;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selector-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(420px, 70dvh);
  overflow: hidden;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(28, 40, 51, 0.16);
}
.selector-panel[hidden] { display: none; }
.selector-panel .buscador { padding: 10px 10px 0; }
.selector-panel .buscador input {
  min-height: 38px;
  border-radius: 8px;
  background: #f5f8fb;
  color: var(--text);
}
.selector-lista {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: auto;
  padding: 8px;
}
.selector-vacio { margin: 8px 6px 10px; color: var(--muted); font-size: 14px; }
.barra .btn {
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
  color: #f4f7fb;
  border-color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}
.menu { position: relative; }
.menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: min(240px, calc(100vw - 16px));
  padding: 6px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(28, 40, 51, 0.14);
}
.menu-panel[hidden] { display: none; }
.menu-panel button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.menu-panel button:hover,
.menu-panel button:focus-visible { background: #e7f0f8; }
.tab-btn {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  text-align: left;
}
.tab-btn strong {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab-btn:hover,
.tab-btn:focus-visible { background: #f3f7fb; }
.tab-btn[aria-selected="true"] { background: #e7f0f8; color: var(--azul); }
.tab-btn[aria-selected="true"] strong { font-weight: 700; }
.tab-btn[aria-selected="true"]::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--azul);
}
.escenario { display: flex; min-width: 0; min-height: 0; position: relative; }
.marco {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  background: #e8eef3;
  border: 0;
}
.marco iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #eef3f7; }
.marco-espera {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 24px;
  text-align: center;
  color: #5c6d7e;
  background: #e8eef3;
}
.espera-giro {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  border-radius: 50%;
  border: 3px solid #c5d3e0;
  border-top-color: var(--azul);
  animation: giro 0.8s linear infinite;
}
.espera-kicker, .espera-titulo { margin: 0; }
.espera-kicker {
  color: var(--azul);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.espera-titulo {
  color: var(--text);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.marco.listo .marco-espera { display: none; }
@keyframes giro { to { transform: rotate(360deg); } }
.aviso-flotante {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 2;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(28, 40, 51, 0.08);
}
.aviso-flotante:empty { display: none; }
.aviso-auth {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 2;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(28, 40, 51, 0.08);
}
.vacio {
  flex: 1;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  margin: 16px;
  padding: 48px 28px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: #f7fafc;
}
.vacio h2 { margin: 0 0 8px; }

.consola { position: relative; z-index: 1; min-height: 100dvh; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(12px);
}
.marca-barra .anillo { width: 42px; height: 42px; box-shadow: 0 0 0 6px rgba(31, 78, 121, 0.08), inset 0 0 0 8px rgba(31, 95, 147, 0.12); }
.topbar h2 { margin: 2px 0 0; font-size: 22px; letter-spacing: -0.03em; }
.topbar em { font-family: var(--serif); font-style: italic; }
.topbar-acciones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quien { margin: 0; color: var(--muted); font-size: 14px; }
.consola-cuerpo { padding: 18px clamp(16px, 3vw, 32px) 40px; }
.secciones { display: flex; gap: 8px; margin-bottom: 16px; }
.secciones button {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: transparent;
  padding: 8px 14px;
}
.secciones button[aria-selected="true"] { background: var(--lime); color: var(--lime-ink); border-color: transparent; font-weight: 700; }
.rejilla { display: grid; grid-template-columns: minmax(280px, 440px) minmax(0, 1fr); gap: 16px; align-items: start; }
.card { padding: 18px; border-radius: 22px; box-shadow: none; }
.card h3 { margin: 0 0 12px; font-size: 20px; }
.lista { display: grid; gap: 10px; }
.item {
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 14px;
  background: #f7fafc;
}
.item h4 { margin: 0 0 4px; font-size: 16px; }
.item p { margin: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip, .estado {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #e7f0f8;
  color: var(--azul);
}
.estado-off { background: rgba(255, 176, 161, 0.1); color: var(--danger); }
.previa { margin-top: 8px; }
.previa-marco {
  margin-top: 8px;
  height: 220px;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}
.previa-marco iframe { width: 100%; height: 100%; border: 0; }
dialog {
  width: min(440px, calc(100% - 24px));
  padding: 22px;
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
dialog p { color: var(--muted); }

@media (max-width: 1100px) {
  .login { grid-template-columns: 1fr; padding: 28px 16px 40px; gap: 20px; align-content: center; }
  h1 { font-size: 40px; }
  .barra {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "marca lado"
      "selector selector";
    row-gap: 8px;
    padding: 10px 12px 12px;
  }
  .barra-marca { grid-area: marca; }
  .selector { grid-area: selector; }
  .selector-panel { width: 100%; }
  .barra-lado { grid-area: lado; justify-content: flex-end; flex-wrap: nowrap; }
  .barra-quien { display: none; }
  .rejilla, .fila { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 640px) {
  .barra {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "marca"
      "selector"
      "lado";
  }
  .barra-lado { justify-content: flex-start; width: 100%; }
  .barra .btn { padding: 0 10px; font-size: 13px; }
  .espera-titulo { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
