/* =========================================================================
   SUPER ADMIN CONTROL PLANE — Millenium Cloud Hub
   -------------------------------------------------------------------------
   Depende de theme.css, que debe cargarse ANTES que este archivo. Comparte
   con el Panel Operativo la misma paleta, tipografia y geometria; lo que
   cambia es el layout (barra lateral fija en vez de drawer) y la densidad,
   mas alta porque este panel es de administracion, no de operacion diaria.

   No debe haber colores literales aqui: todo sale de tokens de theme.css.
   ========================================================================= */

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* =========================================================================
   1. LAYOUT PRINCIPAL
   -------------------------------------------------------------------------
   La barra lateral fija en carbon se reemplazo por la barra superior con
   mega-menu (2026-09-04), que vive en shell.css compartida con el Panel
   Operativo. Aqui solo queda el contenedor de las vistas.
   ========================================================================= */
.admin-main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-6);
}

.view-pane {
  display: none;
}

.view-pane.active {
  display: block;
  animation: fadeIn var(--dur-base) var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
   3. TARJETAS DE METRICA
   ========================================================================= */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.metric-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-bounce) var(--ease-bounce),
              box-shadow var(--dur-bounce) var(--ease-bounce),
              transform var(--dur-bounce) var(--ease-bounce);
}

.metric-box:hover {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric-box:hover .metric-icon-circle i,
.metric-box:hover .metric-icon-circle svg {
  animation: icon-bounce var(--dur-bounce) var(--ease-bounce);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.metric-label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
}

.metric-val {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: var(--ls-tight);
  color: var(--text);
  line-height: 1.1;
}

.metric-desc {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: var(--sp-1);
}

.metric-icon-circle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  flex-shrink: 0;
  line-height: 1;
}

.metric-icon-circle.c-primary   { background: color-mix(in srgb, var(--cat-1) 14%, transparent); color: var(--cat-1); }
.metric-icon-circle.c-cyan      { background: color-mix(in srgb, var(--cat-6) 14%, transparent); color: var(--cat-6); }
.metric-icon-circle.c-rose      { background: color-mix(in srgb, var(--cat-1) 14%, transparent); color: var(--cat-1); }
.metric-icon-circle.c-emerald   { background: color-mix(in srgb, var(--cat-3) 14%, transparent); color: var(--cat-3); }
.metric-icon-circle.c-amber     { background: color-mix(in srgb, var(--cat-4) 14%, transparent); color: var(--cat-4); }
.metric-icon-circle.c-secondary { background: color-mix(in srgb, var(--cat-5) 14%, transparent); color: var(--cat-5); }

/* =========================================================================
   4. ACTIVIDAD RECIENTE Y ESTADO DE MODULOS
   ========================================================================= */
.overview-side-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--sp-4);
}

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease);
}

.activity-item:hover {
  background: var(--surface-2);
}

.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--text-2);
  line-height: 1;
}

.activity-body {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 1px;
}

.activity-time {
  font-size: var(--fs-2xs);
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

.module-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--sp-2);
}

.module-status-item {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.module-status-item .msi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.module-status-item .msi-icon {
  font-size: var(--fs-base);
  line-height: 1;
}

.module-status-item .msi-count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-xl);
  color: var(--text);
  line-height: 1.1;
}

.module-status-item .msi-label {
  font-size: var(--fs-2xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
}

.module-status-bar {
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--border);
  overflow: hidden;
  margin-top: var(--sp-1);
}

.module-status-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--dur-base) var(--ease);
}

/* =========================================================================
   5. SECCIONES
   ========================================================================= */
/* Los paneles van elevados; los campos de formulario, hundidos. */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-6);
  box-shadow: var(--shadow-xs);
}

/* El encabezado de un panel es SIEMPRE una barra con linea inferior: titulo
   con su emoji a la izquierda, accion primaria a la derecha. Sin excepciones. */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: var(--ls-tight);
  color: var(--text);
}

/* =========================================================================
   6. BOTONES
   ========================================================================= */
/* Mismo tratamiento que .btn-action del Panel Operativo (2026-09-04): degradado
   a 135 grados + resplandor del propio color, y el hundido al pulsar. Las dos
   pantallas tienen que sentirse iguales al usarlas, no solo parecerse. */
.btn-primary {
  background: linear-gradient(135deg, var(--brand-hover) 0%, var(--brand) 100%);
  color: var(--brand-contrast);
  border: 1px solid transparent;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  box-shadow: 0 4px 14px var(--brand-glow);
  transition: var(--transition-bounce);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px var(--brand-glow);
  filter: brightness(1.08);
}

.btn-primary:hover i.fa-sync, 
.btn-primary:hover i.fa-sync-alt {
  animation: spin-slow 1s linear infinite;
}

.btn-primary:hover i:not(.fa-sync):not(.fa-sync-alt) {
  animation: icon-bounce var(--dur-bounce) var(--ease-bounce);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.94);
  transition: transform 80ms var(--ease-bounce);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  transition: var(--transition-bounce);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-2px) scale(1.02);
}

.btn-secondary:hover i.fa-sync, 
.btn-secondary:hover i.fa-sync-alt {
  animation: spin-slow 1s linear infinite;
}

.btn-secondary:hover i:not(.fa-sync):not(.fa-sync-alt) {
  animation: icon-bounce var(--dur-bounce) var(--ease-bounce);
}

.btn-secondary:active {
  transform: translateY(1px) scale(0.94);
  transition: transform 80ms var(--ease-bounce);
}

/* Destructivo: fantasma, nunca solido. Asi no compite con el boton primario
   de marca, que tambien es rojo, y obliga a un segundo de lectura. */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text-inverse);
  transform: translateY(-2px) scale(1.02);
}

.btn-danger:hover i {
  animation: icon-bounce var(--dur-bounce) var(--ease-bounce);
}

.btn-danger:active {
  transform: translateY(1px) scale(0.94);
  transition: transform 80ms var(--ease-bounce);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--radius-xs);
  transition: var(--transition);
}

.btn-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* =========================================================================
   7. TABLAS
   ========================================================================= */
.table-responsive {
  position: relative;
  width: 100%;
  overflow-x: auto;
}

/* Aviso visual de que hay mas columnas a la derecha -- en movil el
   scrollbar nativo va invisible hasta que se toca, asi que sin esto una
   tabla ancha se ve "cortada a la mala" en vez de "desliza para ver mas".
   Solo aporta cuando SI hay contenido oculto (scrollWidth > clientWidth,
   ver JS abajo); se agrega/quita la clase con eso. */
.table-responsive.has-overflow::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--surface) 85%);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.admin-table th {
  background: var(--surface-2);
  padding: 0.6rem 0.85rem;
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.admin-table th:first-child { border-top-left-radius: var(--radius-sm); }
.admin-table th:last-child  { border-top-right-radius: var(--radius-sm); }

/* Columnas de modulos (interruptor + encabezado-icono): angostas a proposito
   para que la tabla de licenciamiento quepa sin scroll horizontal en un
   monitor normal -- antes cada columna media lo que medía la PALABRA del
   encabezado ("Administrador PBX", "Aprovisionar"), no el interruptor de
   34px que en realidad contenía. */
.admin-table th.col-mod {
  padding: 0.6rem 0.35rem;
  text-align: center;
  font-size: 1rem;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  cursor: default;
}
.admin-table td.col-mod {
  padding: 0.7rem 0.35rem;
  text-align: center;
}

.admin-table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-2);
}

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

.admin-table tbody tr {
  transition: transform var(--dur-base) var(--ease);
}

.admin-table tbody tr:hover {
  background: var(--surface-hover);
  transform: translateX(4px);
}

.admin-table code {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 0.08rem 0.35rem;
  color: var(--text);
}

/* =========================================================================
   8. INTERRUPTORES (feature flags por central)
   ========================================================================= */
.switch-container {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 19px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: var(--transition);
  border-radius: var(--radius-full);
}

.slider:before {
  position: absolute;
  content: "";
  height: 13px;
  width: 13px;
  left: 2px;
  bottom: 2px;
  background-color: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--brand);
  border-color: var(--brand);
}

input:checked + .slider:before {
  transform: translateX(15px);
  background-color: var(--brand-contrast);
}

.switch input:focus-visible + .slider {
  box-shadow: var(--ring);
}

/* =========================================================================
   9. INSIGNIAS
   ========================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-online {
  background: color-mix(in srgb, var(--success) 13%, transparent);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 26%, transparent);
}

.badge-offline {
  background: color-mix(in srgb, var(--text-3) 12%, transparent);
  color: var(--text-3);
  border-color: var(--border);
}

.badge-role-admin {
  background: color-mix(in srgb, var(--cat-5) 13%, transparent);
  color: var(--cat-5);
  border-color: color-mix(in srgb, var(--cat-5) 26%, transparent);
}

.badge-role-super {
  background: color-mix(in srgb, var(--cat-1) 13%, transparent);
  color: var(--cat-1);
  border-color: color-mix(in srgb, var(--cat-1) 26%, transparent);
}

.badge-role-user {
  background: color-mix(in srgb, var(--cat-6) 13%, transparent);
  color: var(--cat-6);
  border-color: color-mix(in srgb, var(--cat-6) 26%, transparent);
}

/* .pulse-dot vive en shell.css (compartido con el Panel Operativo) */

@keyframes pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}

/* =========================================================================
   10. MODALES
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-5);
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  padding: var(--sp-6);
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform var(--dur-base) var(--ease);
  margin: auto;
}

.modal-backdrop.active .modal-box {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 650;
  letter-spacing: var(--ls-tight);
  color: var(--text);
}

/* =========================================================================
   11. FORMULARIOS
   ========================================================================= */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-group {
  margin-bottom: var(--sp-4);
}

.form-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}

.form-control {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-md);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.form-control::placeholder { color: var(--text-3); }

.form-control:hover { border-color: var(--border-strong); }

.form-control:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--ring);
}

.form-group input[type="checkbox"] {
  accent-color: var(--brand);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* =========================================================================
   12. BLOQUE DE TERMINAL (tokens, comandos de instalacion)
   ========================================================================= */
.terminal-box {
  background: var(--terminal-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--terminal-text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  word-break: break-all;
}

.terminal-box .btn-secondary {
  background: color-mix(in srgb, var(--terminal-text) 12%, transparent);
  border-color: color-mix(in srgb, var(--terminal-text) 22%, transparent);
  color: var(--terminal-text);
  flex-shrink: 0;
}

.terminal-box .btn-secondary:hover {
  background: color-mix(in srgb, var(--terminal-text) 20%, transparent);
  color: var(--terminal-text);
}

/* =========================================================================
   13. SELECTOR DE TEMA
   ========================================================================= */
/* .theme-switch vive en shell.css (compartido entre los dos paneles) */

/* =========================================================================
   14. RESPONSIVE
   -------------------------------------------------------------------------
   La barra lateral fija (.admin-sidebar y companeros) que este bloque
   ajustaba ya no existe -- se reemplazo por la barra superior compartida
   (shell.css) en el rediseno de 2026-09. Lo que sigue es responsive real
   para lo que hoy compone la pantalla: el contenedor de vistas y las
   tarjetas/tabla de administracion.
   ========================================================================= */
@media (max-width: 900px) {
  .admin-main { padding: var(--sp-4); }
  .content-viewport { padding: var(--sp-4); }
}

/* Telefono: se reduce densidad en vez de ocultar controles */
@media (max-width: 480px) {
  .admin-main { padding: var(--sp-3); }
  .metric-box { padding: var(--sp-4); }
  .metric-val { font-size: var(--fs-xl); }
  .admin-table th,
  .admin-table td { padding: 0.5rem 0.6rem; }
}

/* =========================================================================
   15. REDISEÑO: MÓDULOS DE CENTRALES & DRAWER DE LICENCIAMIENTO (2026-09-28)
   ========================================================================= */
.mod-summary-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-width: 270px;
}

.mod-badge-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mod-count-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

.mod-count-full {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
}

.mod-count-partial {
  background: color-mix(in srgb, var(--accent-cyan, #06b6d4) 14%, transparent);
  color: var(--accent-cyan, #06b6d4);
  border: 1px solid color-mix(in srgb, var(--accent-cyan, #06b6d4) 30%, transparent);
}

.mod-count-none {
  background: color-mix(in srgb, var(--text-3) 10%, transparent);
  color: var(--text-3);
  border: 1px solid var(--border);
}

.mod-categories-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mod-cat-tag {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}

.btn-manage-modules {
  padding: 0.35rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-bounce);
}

.btn-manage-modules:hover {
  background: var(--surface-3);
  border-color: var(--accent-cyan, #06b6d4);
  color: var(--accent-cyan, #06b6d4);
  transform: translateY(-1px);
}

/* --- DRAWER LATERAL DE LICENCIAS --- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-modal) var(--ease-modal);
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 500px;
  max-width: 95vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-modal) var(--ease-modal);
  z-index: 1051;
}

.drawer-backdrop.active .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--surface-2);
}

.drawer-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-cyan, #06b6d4);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  margin-bottom: 3px;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.25;
}

.drawer-code-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--accent-cyan, #06b6d4) 15%, transparent);
  color: var(--accent-cyan, #06b6d4);
  margin-top: 4px;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  line-height: 1;
  transition: var(--transition);
}

.drawer-close-btn:hover {
  color: var(--text);
  background: var(--surface-3);
}

.drawer-master-card {
  margin: var(--sp-4) var(--sp-6) 0;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--brand-500) 7%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--brand-500) 25%, var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.master-switch-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  display: block;
}

.master-switch-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.switch-lg {
  width: 44px;
  height: 24px;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.switch-lg input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-lg .slider {
  border-radius: 9999px;
}

.switch-lg .slider:before {
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
}

.switch-lg input:checked + .slider:before {
  transform: translateX(20px);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.drawer-category {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.drawer-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--border);
}

.drawer-category-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.drawer-module-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.drawer-module-item:hover {
  border-color: color-mix(in srgb, var(--text) 22%, var(--border));
  background: var(--surface-3);
}

.drawer-module-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.drawer-module-info {
  flex: 1;
  min-width: 0;
}

.drawer-module-name {
  font-weight: 650;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.3;
}

.drawer-module-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 2px;
}

.drawer-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.drawer-sync-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

/* Formularios como panel lateral (mismo estilo que el editor de extensiones del
   Administrador PBX, 2026-10-09). El login sigue siendo ventana centrada. */
.modal-backdrop:not(#login-overlay) {
  padding: 0;
  justify-content: flex-end;
  align-items: stretch;
  overflow: hidden;
}
.modal-backdrop:not(#login-overlay) > .modal-box {
  margin: 0;
  width: min(640px, 100vw) !important;
  max-width: 100vw !important;
  height: 100vh;
  overflow-y: auto;
  border-radius: 0;
  border: 0;
  border-left: 1px solid var(--border);
  padding-top: 0;
  transform: translateX(48px);
}
.modal-backdrop.active:not(#login-overlay) > .modal-box { transform: none; }
.modal-backdrop:not(#login-overlay) > .modal-box > .modal-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  margin: 0 calc(-1 * var(--sp-6)) var(--sp-5);
  padding: var(--sp-5) var(--sp-6) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle, var(--border));
}
