:root {
  --bg: #05070a;
  --surface: #0d1117;
  --surface-2: #151b24;
  --border: #232c3b;
  --text: #f4f5f6;
  --muted: #9ba5b4;
  --accent: #ff3b2f;
  --accent-hover: #e02f24;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 12px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Martian Mono", ui-monospace, SFMono-Regular, monospace;
}

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

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

/* Regla obligatoria para que display propio nunca pise [hidden] */
#staff-aviso[hidden],
#pantalla-arranque[hidden],
#pantalla-login[hidden],
#pantalla-sin-senal[hidden],
#app-shell[hidden],
#form-correo[hidden],
#form-codigo[hidden],
#btn-demo-local[hidden],
.tab-mod[hidden] {
  display: none;
}

/* Aviso superior */
.staff-aviso {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 10px 14px;
  max-width: calc(100vw - 24px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.staff-aviso button {
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

/* Pantallas base */
.staff-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  background: var(--bg);
}

/* Arranque */
.arranque-centro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.arranque-icono {
  border-radius: 26px;
}

.arranque-titulo {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.arranque-lema {
  font-size: 0.8125rem;
  color: var(--muted);
  letter-spacing: 0.12em;
}

.arranque-progreso {
  width: 180px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.arranque-barra {
  width: 45%;
  height: 100%;
  background: var(--accent);
  animation: pulso-barra 1.2s ease-in-out infinite;
}

@keyframes pulso-barra {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(260%);
  }
}

/* Login */
.login-centro {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-cab {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-icono {
  border-radius: 16px;
  flex-shrink: 0;
}

.login-marca {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.login-marca b {
  color: var(--accent);
}

.login-cab h1 {
  margin: 4px 0 0;
  font-size: 1.375rem;
  line-height: 1.2;
}

.login-tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-desc {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--muted);
}

.login-desc strong {
  color: var(--text);
}

.campo-lbl {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
}

.campo-inp {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
}

.campo-codigo {
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: 0.28em;
  text-align: center;
}

.campo-inp:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    opacity 0.12s ease;
}

.btn:focus-visible,
.btn-salir:focus-visible,
.tab-mod:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.btn:active,
.btn-salir:active,
.tab-mod:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primario {
  background: var(--accent);
  color: var(--text);
}

.btn.primario:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn.secundario {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn.fantasma {
  min-height: 44px;
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  font-weight: 600;
  flex: 1;
}

.btn.fantasma:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--muted);
}

.login-acciones-sec {
  display: flex;
  gap: 10px;
}

.login-msg {
  margin: 0;
  min-height: 20px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--err);
}

.login-msg.ok {
  color: var(--ok);
}

/* Sin señal */
.sin-senal-centro {
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.sin-senal-centro h1 {
  margin: 0;
  font-size: 1.375rem;
}

.sin-senal-centro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.45;
}

/* Shell operativo */
.app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.barra-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.top-izq {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.top-izq img {
  border-radius: 7px;
  flex-shrink: 0;
}

.top-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-marca {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.top-oficial {
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-der {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pill-red {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ok);
}

.pill-red.sin-red {
  color: var(--warn);
}

.btn-salir {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
}

.marco-modulos {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--bg);
}

#app-modulo {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--bg);
}

.barra-modulos {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

.barra-modulos::-webkit-scrollbar {
  display: none;
}

.tab-mod {
  min-width: 72px;
  min-height: 48px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: var(--font);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    transform 0.12s ease,
    opacity 0.12s ease;
}

.tab-mod:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tab-mod.activa {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--accent);
}

.tab-ic {
  font-size: 1rem;
  line-height: 1;
}

.tab-tx {
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .barra-modulos {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .arranque-barra {
    animation: none;
  }
  .btn,
  .btn-salir,
  .tab-mod {
    transition: none;
  }
}
