/* Hoja de estilos única CBSB.
   La clase cbsb-document en <html> separa la interfaz con barra lateral
   del dashboard y login existentes, conservando sus diseños. */

/* ===== Dashboard e inicio de sesión ===== */

:root:where(:not(.cbsb-document)) {
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #162033;
  --bg-glass: rgba(17, 24, 39, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #ef4444;
  --primary: #ef4444;
  --primary-hover: #dc2626;
  --primary-glow: rgba(239, 68, 68, 0.25);
  --accent-gold: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-purple: #8b5cf6;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

:where(html:not(.cbsb-document)),
:where(html:not(.cbsb-document)) * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:where(html:not(.cbsb-document)) body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* Header */

:where(html:not(.cbsb-document)) .navbar {
  background-color: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 2rem;
}

:where(html:not(.cbsb-document)) .nav-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

:where(html:not(.cbsb-document)) .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

:where(html:not(.cbsb-document)) .brand-badge {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  box-shadow: 0 0 15px var(--primary-glow);
}

:where(html:not(.cbsb-document)) .brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}

:where(html:not(.cbsb-document)) .brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

:where(html:not(.cbsb-document)) .nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

:where(html:not(.cbsb-document)) .status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
}

:where(html:not(.cbsb-document)) .status-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
  }

  100% {
    transform: scale(0.95);
    opacity: 0.8;
  }
}

:where(html:not(.cbsb-document)) .btn-admin {
  background-color: var(--primary);
  color: #fff;
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

:where(html:not(.cbsb-document)) .btn-admin:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 0 12px var(--primary-glow);
}

/* Main Container */

:where(html:not(.cbsb-document)) .main-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.2rem 2rem;
  width: 100%;
  flex: 1;
}

/* Hero Section */

:where(html:not(.cbsb-document)) .hero-banner {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(17, 24, 39, 0.8) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

:where(html:not(.cbsb-document)) .hero-text h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 0.4rem;
}

:where(html:not(.cbsb-document)) .hero-text p {
  color: var(--text-muted);
  max-width: 650px;
  font-size: 0.95rem;
}

:where(html:not(.cbsb-document)) .quick-stats-badge {
  display: flex;
  gap: 1rem;
}

:where(html:not(.cbsb-document)) .chip-stat {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  text-align: center;
}

:where(html:not(.cbsb-document)) .chip-number {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  display: block;
}

:where(html:not(.cbsb-document)) .chip-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Metric Cards Grid */

:where(html:not(.cbsb-document)) .kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

:where(html:not(.cbsb-document)) .kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

:where(html:not(.cbsb-document)) .kpi-card:hover {
  transform: translateY(-3px);
  background-color: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

:where(html:not(.cbsb-document)) .kpi-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

:where(html:not(.cbsb-document)) .kpi-red {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

:where(html:not(.cbsb-document)) .kpi-blue {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

:where(html:not(.cbsb-document)) .kpi-emerald {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

:where(html:not(.cbsb-document)) .kpi-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

:where(html:not(.cbsb-document)) .kpi-info h3 {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
}

:where(html:not(.cbsb-document)) .kpi-info span {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Dashboard Sections */

:where(html:not(.cbsb-document)) .dashboard-columns {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  :where(html:not(.cbsb-document)) .dashboard-columns {
    grid-template-columns: 1fr;
  }
}

:where(html:not(.cbsb-document)) .panel-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

:where(html:not(.cbsb-document)) .panel-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Units Table / Cards */

:where(html:not(.cbsb-document)) .units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

:where(html:not(.cbsb-document)) .unit-item {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: var(--transition);
}

:where(html:not(.cbsb-document)) .unit-item:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.03);
}

:where(html:not(.cbsb-document)) .unit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

:where(html:not(.cbsb-document)) .unit-code {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}

:where(html:not(.cbsb-document)) .badge-status {
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

:where(html:not(.cbsb-document)) .badge-0-8 {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

:where(html:not(.cbsb-document)) .badge-0-9 {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

:where(html:not(.cbsb-document)) .badge-0-10 {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

:where(html:not(.cbsb-document)) .badge-0-11 {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

:where(html:not(.cbsb-document)) .unit-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Modules Grid */

:where(html:not(.cbsb-document)) .modules-section {
  margin-top: 1rem;
}

:where(html:not(.cbsb-document)) .modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

:where(html:not(.cbsb-document)) .module-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: var(--transition);
}

:where(html:not(.cbsb-document)) .module-card:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

:where(html:not(.cbsb-document)) .module-icon {
  font-size: 1.8rem;
  margin-bottom: 0.2rem;
}

:where(html:not(.cbsb-document)) .module-title {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}

:where(html:not(.cbsb-document)) .module-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Activity Items */

:where(html:not(.cbsb-document)) .activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

:where(html:not(.cbsb-document)) .activity-item {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

:where(html:not(.cbsb-document)) .activity-title {
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

:where(html:not(.cbsb-document)) .activity-time {
  font-size: 0.72rem;
  color: var(--text-dim);
}

:where(html:not(.cbsb-document)) .activity-body {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Footer */

:where(html:not(.cbsb-document)) footer {
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
  background-color: rgba(9, 13, 22, 0.95);
}

:where(html:not(.cbsb-document)),
:where(html:not(.cbsb-document)) * {
  box-sizing: border-box;
}

:where(html:not(.cbsb-document)) body.login-page {
  margin: 0;
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  background-color: #0f172a;
  font-family: Arial, sans-serif;
  color: #333;
  overflow-x: hidden;
}

:where(html:not(.cbsb-document)) body.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  /* Campana institucional del Cuartel General, fotografía del sitio oficial de CBSB. */
  background-image: url('../img/login-bg.png');
  background-image: image-set(
    url('../img/login-bg.webp') type('image/webp'),
    url('../img/login-bg.png') type('image/png')
  );
  background-size: cover;
  background-position: 70% center;
  background-repeat: no-repeat;
  filter: brightness(0.88);
  z-index: -2;
  pointer-events: none;
}

:where(html:not(.cbsb-document)) body.login-page::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.16) 0%, rgba(15, 23, 42, 0.50) 100%);
  z-index: -1;
  pointer-events: none;
}

:where(html:not(.cbsb-document)) .contenedor {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  position: relative;
  z-index: 1;
}

:where(html:not(.cbsb-document)) .login {
  background-color: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  width: 100%;
  max-width: 440px;
  padding: 32px 28px;
  border-radius: 14px;
  border-top: 4px solid #81243b;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.25);
  text-align: center;
}

:where(html:not(.cbsb-document)) .login h1 {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 6px;
}

:where(html:not(.cbsb-document)) .substitulos {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 20px;
}

/* Vista previa interactiva del logo de la compañía */
:where(html:not(.cbsb-document)) .logo-preview-wrapper {
  margin: 10px auto 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

:where(html:not(.cbsb-document)) .logo-preview-ring {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid rgba(129, 36, 59, 0.2);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

:where(html:not(.cbsb-document)) .logo-preview-ring:hover {
  transform: scale(1.03);
  box-shadow: 0 12px 30px rgba(129, 36, 59, 0.25);
}

:where(html:not(.cbsb-document)) .logo-preview-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.2s ease, transform 0.25s ease;
}

:where(html:not(.cbsb-document)) .compania-nombre-label {
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: #81243b;
  letter-spacing: 0.2px;
}

/* Lista desplegable centralizada de compañías */
:where(html:not(.cbsb-document)) .campo-selector {
  text-align: left;
  margin-bottom: 22px;
}

:where(html:not(.cbsb-document)) .selector-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

:where(html:not(.cbsb-document)) .select-wrapper {
  position: relative;
  width: 100%;
}

:where(html:not(.cbsb-document)) .select-wrapper::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748b' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
}

:where(html:not(.cbsb-document)) .select-compania {
  width: 100%;
  padding: 13px 40px 13px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

:where(html:not(.cbsb-document)) .select-compania:focus {
  border-color: #81243b;
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(129, 36, 59, 0.15);
}

/* Botón principal para abrir el modal */
:where(html:not(.cbsb-document)) .btn-abrir-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background-color: #81243b;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 14px rgba(129, 36, 59, 0.3);
}

:where(html:not(.cbsb-document)) .btn-abrir-modal:hover {
  background-color: #641b2e;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(129, 36, 59, 0.4);
}

/* Modal de autenticación con difuminado de fondo (Backdrop Blur) */
:where(html:not(.cbsb-document)) .login-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

:where(html:not(.cbsb-document)) .login-modal-overlay.activo {
  display: flex;
  animation: fadeInModal 0.22s ease-out;
}

:where(html:not(.cbsb-document)) .login-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

:where(html:not(.cbsb-document)) .login-modal-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 14px;
  padding: 30px 26px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.3);
  border-top: 4px solid #81243b;
  text-align: left;
  animation: scaleUpModal 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

:where(html:not(.cbsb-document)) .modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

:where(html:not(.cbsb-document)) .modal-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

:where(html:not(.cbsb-document)) .modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}

:where(html:not(.cbsb-document)) .modal-company-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

:where(html:not(.cbsb-document)) .modal-header-text h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: #0f172a;
}

:where(html:not(.cbsb-document)) .modal-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: #81243b;
}

:where(html:not(.cbsb-document)) .login-alerta {
  background-color: #fee2e2;
  border-left: 4px solid #b91c1c;
  color: #991b1b;
  padding: 11px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

:where(html:not(.cbsb-document)) .login-alerta-icon {
  font-size: 15px;
  font-weight: bold;
  flex-shrink: 0;
}

:where(html:not(.cbsb-document)) .campo {
  margin-bottom: 16px;
}

:where(html:not(.cbsb-document)) .campo label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

:where(html:not(.cbsb-document)) .campo input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  color: #0f172a;
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

:where(html:not(.cbsb-document)) .campo input:focus {
  border-color: #81243b;
  outline: none;
  box-shadow: 0 0 0 3px rgba(129, 36, 59, 0.15);
}

:where(html:not(.cbsb-document)) .contenedor-contrasena {
  position: relative;
  display: flex;
  align-items: center;
}

:where(html:not(.cbsb-document)) .ver-contrasena {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #64748b;
  padding: 6px;
  border-radius: 4px;
}

:where(html:not(.cbsb-document)) .ver-contrasena:hover {
  color: #0f172a;
}

:where(html:not(.cbsb-document)) .extras {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 16px 0 20px;
  font-size: 12px;
  color: #64748b;
}

:where(html:not(.cbsb-document)) .extras span {
  color: #81243b;
  cursor: pointer;
}

:where(html:not(.cbsb-document)) #btn-ingresar,
:where(html:not(.cbsb-document)) .btn-submit-login {
  display: block;
  width: 100%;
  padding: 13px;
  background-color: #81243b;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  margin-top: 20px;
  box-shadow: 0 4px 12px rgba(129, 36, 59, 0.25);
}

:where(html:not(.cbsb-document)) #btn-ingresar:hover,
:where(html:not(.cbsb-document)) .btn-submit-login:hover {
  background-color: #641b2e;
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUpModal {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

:where(html:not(.cbsb-document)) .aviso {
  text-align: center;
  font-size: 11px;
  color: #999;
  margin-top: 25px;
}

@media (max-width: 480px) {
  :where(html:not(.cbsb-document)) .contenedor {
    padding: 16px 12px;
  }
  :where(html:not(.cbsb-document)) .login {
    padding: 24px 18px;
    border-radius: 12px;
  }
  :where(html:not(.cbsb-document)) .login h1 {
    font-size: 21px;
  }
  :where(html:not(.cbsb-document)) .logo-preview-ring {
    width: 110px;
    height: 110px;
    padding: 10px;
  }
  :where(html:not(.cbsb-document)) .login-modal-card {
    padding: 24px 18px;
    margin: 12px;
  }
  :where(html:not(.cbsb-document)) .select-compania {
    font-size: 13px;
    padding: 12px 34px 12px 14px;
  }
}

:where(html:not(.cbsb-document)) .pie {
  text-align: center;
  font-size: 11px;
  color: #999;
  margin-top:18px;
}

:where(html:not(.cbsb-document)) .opciones .comandancia {
  border-left: 4px solid #922C49;
}

:where(html:not(.cbsb-document)) .opciones .compania1 {
  border-left: 4px solid #922C49;
}

:where(html:not(.cbsb-document)) .opciones .compania2 {
  border-left: 4px solid #3469B3;
}

:where(html:not(.cbsb-document)) .opciones .compania3 {
  border-left: 4px solid #287A70;
}

:where(html:not(.cbsb-document)) .opciones .compania4 {
  border-left: 4px solid #29314F;
}

:where(html:not(.cbsb-document)) .opciones .compania5 {
  border-left: 4px solid #B81450;
}

:where(html:not(.cbsb-document)) .opciones .compania6 {
  border-left: 4px solid #202D57;
}

:where(html:not(.cbsb-document)) .opciones .compania7 {
  border-left: 4px solid #C21852;
}

:where(html:not(.cbsb-document)) .opciones .compania8 {
  border-left: 4px solid #292933;
}

:where(html:not(.cbsb-document)) .opciones .compania10 {
  border-left: 4px solid #31578C;
}

/* ===== Interfaz CBSB - base, componentes y colores de compañías ===== */

/* =====================================================================
   Fondo gris lavanda + superficies marfil/blanco translúcido.
   Granate institucional para acciones primarias.
   Las compañías se diferencian con etiquetas, no con fondos saturados.
   Sin dependencias externas.
   ===================================================================== */

:root:where(.cbsb-document) {
  color-scheme: light;
  --font-ui: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  /* MISMA FAMILIA VISUAL QUE EL LOGIN */

  --page: #f4f4f9;
  --page-bg: var(--page);
  --surface: rgba(255, 255, 255, .86);
  --surface-border: rgba(255, 255, 255, .95);
  --ink: #27282e;
  --ink-strong: #24252d;
  --muted: #777c88;
  --subtle: #9b9faa;
  --line: rgba(88, 86, 102, .125);
  --burgundy: #811c36;
  --burgundy-hover: #681329;
  --primary: var(--burgundy);
  --primary-hover: var(--burgundy-hover);
  --primary-soft: #faedf1;
  --focus: #a84862;
  --focus-ring: rgba(129, 28, 54, .19);

  /* GLASSMORPHISM CLARO — fácil de modificar aquí */

  --glass: rgba(255, 252, 249, .77);
  --glass-soft: rgba(255, 255, 255, .64);
  --glass-hover: rgba(255, 255, 255, .82);
  --glass-border: rgba(255, 255, 255, .88);
  --blur: 20px;
  --shadow: 0 16px 45px rgba(29, 34, 53, .075), 0 2px 10px rgba(29, 34, 53, .04);

  /* Barra lateral sobria, como en el dashboard de referencia */

  --sidebar-bg: #222833;
  --sidebar-text: #f2f3f7;
  --sidebar-muted: #b1b5c1;

  /* Estados de interfaz; no confundir con compañías */

  --positive: #35765a;
  --positive-bg: #e8f5ee;
  --warning: #85622f;
  --warning-bg: #f9f0df;
  --danger: #a23f53;
  --danger-bg: #fff1f3;
  --r-sm: 9px;
  --r-md: 14px;
  --r-lg: 20px;
  --transition: 180ms ease;
}

/* Base y accesibilidad */

:where(html.cbsb-document),
:where(html.cbsb-document) *,
:where(html.cbsb-document)::before,
:where(html.cbsb-document) *::before,
:where(html.cbsb-document)::after,
:where(html.cbsb-document) *::after {
  box-sizing: border-box;
}

html:where(.cbsb-document) {
  min-height: 100%;
  scroll-behavior: auto;
}

:where(html.cbsb-document) body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(ellipse 42% 40% at 46% 26%, rgba(255, 255, 255, .60), transparent 92%), radial-gradient(ellipse 27% 39% at 93% 9%, rgba(239, 217, 224, .24), transparent 87%), linear-gradient(140deg, #f6f6fa 0%, #f2f2f8 61%, #f8f6f4 100%);
  background-attachment: scroll;
}

:where(html.cbsb-document) button,
:where(html.cbsb-document) input,
:where(html.cbsb-document) select,
:where(html.cbsb-document) textarea {
  font: inherit;
}

:where(html.cbsb-document) button {
  cursor: pointer;
}

:where(html.cbsb-document) a {
  color: inherit;
}

:where(html.cbsb-document) :focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

:where(html.cbsb-document) [hidden],
:where(html.cbsb-document) .is-hidden {
  display: none !important;
}

:where(html.cbsb-document) .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
  clip: rect(0,0,0,0);
  clip-path: inset(50%);
}

:where(html.cbsb-document) .skip-link {
  position: fixed;
  top: -60px;
  left: 14px;
  z-index: 100;
  padding: 10px 13px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  text-decoration: none;
}

:where(html.cbsb-document) .skip-link:focus {
  top: 12px;
}

/* Estructura compartida por todos los módulos */

:where(html.cbsb-document) .app-shell {
  display: flex;
  min-height: 100vh;
}

:where(html.cbsb-document) .app-sidebar {
  position: sticky;
  top: 0;
  width: 246px;
  flex: 0 0 246px;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #727987 var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 30;
  padding: 25px 14px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255,255,255,.07);
}

:where(html.cbsb-document) .app-sidebar > * {
  flex-shrink: 0;
}

:where(html.cbsb-document) .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 2px 9px 34px;
  text-decoration: none;
}

:where(html.cbsb-document) .brand-mark {
  width: 41px;
  height: 41px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--burgundy);
  color: white;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .025em;
  box-shadow: 0 8px 20px rgba(45, 12, 26, .20);
}

:where(html.cbsb-document) .brand-logo {
  display: block;
  flex: 0 0 48px;
  width: 48px;
  height: 52px;
  object-fit: contain;
}

:where(html.cbsb-document) .brand-name {
  display: block;
  font-size: 1rem;
  color: white;
  font-weight: 750;
}

:where(html.cbsb-document) .brand-caption {
  display: block;
  margin-top: 3px;
  font-size: .72rem;
  color: var(--sidebar-muted);
}

:where(html.cbsb-document) .sidebar-label {
  margin: 0 12px 10px;
  color: var(--sidebar-muted);
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
}

:where(html.cbsb-document) .sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

:where(html.cbsb-document) .sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-size: .89rem;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

:where(html.cbsb-document) .sidebar-link:hover {
  background: rgba(255,255,255,.085);
}

:where(html.cbsb-document) .sidebar-link[aria-current="page"] {
  color: white;
  background: var(--burgundy);
  font-weight: 650;
}

:where(html.cbsb-document) .sidebar-link[aria-disabled="true"] {
  opacity: .58;
  cursor: default;
}

:where(html.cbsb-document) .sidebar-link-icon {
  flex: 0 0 23px;
  font-size: 1rem;
  text-align: center;
}

:where(html.cbsb-document) .sidebar-footer {
  margin-top: auto;
  padding: 14px 12px 0;
  color: var(--sidebar-muted);
  font-size: .74rem;
  border-top: 1px solid rgba(255,255,255,.10);
}

:where(html.cbsb-document) .sidebar-backdrop {
  display: none;
}

:where(html.cbsb-document) .app-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

:where(html.cbsb-document) .app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 70px;
  padding: 12px clamp(16px, 3vw, 38px);
  background: rgba(255,255,255,.47);
  border-bottom: 1px solid var(--line);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

:where(html.cbsb-document) .topbar-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

:where(html.cbsb-document) .topbar-title {
  color: var(--ink-strong);
  font-size: .88rem;
  font-weight: 750;
}

:where(html.cbsb-document) .topbar-caption {
  margin-top: 3px;
  color: var(--muted);
  font-size: .76rem;
}

:where(html.cbsb-document) .environment-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.55);
  color: var(--muted);
  font-size: .76rem;
}

:where(html.cbsb-document) .environment-tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #559b7a;
}

:where(html.cbsb-document) .menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.76);
  color: var(--ink);
  font-size: 20px;
}

:where(html.cbsb-document) .app-content {
  width: 100%;
  max-width: 1680px;
  flex: 1;
  margin-inline: auto;
  padding: 30px clamp(16px, 3vw, 38px) 44px;
}

:where(html.cbsb-document) .app-footer {
  padding: 0 clamp(16px, 3vw, 38px) 20px;
  color: var(--muted);
  font-size: .75rem;
}

/* Paneles: cristal marfil ligero, sin brillos excesivos */

:where(html.cbsb-document) .glass-panel,
:where(html.cbsb-document) .glass-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  /* Se conserva la transparencia sin recalcular desenfoques al desplazar. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

:where(html.cbsb-document) .glass-panel {
  padding: clamp(18px, 2.5vw, 30px);
}

:where(html.cbsb-document) .glass-card {
  padding: 20px;
  background: var(--glass-soft);
  box-shadow: 0 7px 25px rgba(29,34,53,.047);
}

:where(html.cbsb-document) .glass-card--muted {
  background: rgba(255,255,255,.42);
}

:where(html.cbsb-document) .page-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

:where(html.cbsb-document) .page-heading h1 {
  margin: 0 0 7px;
  color: var(--ink-strong);
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1.2;
}

:where(html.cbsb-document) .page-heading p {
  margin: 0;
  max-width: 660px;
  color: var(--muted);
  font-size: .91rem;
  line-height: 1.55;
}

:where(html.cbsb-document) .section-heading {
  margin: 0 0 14px;
  color: var(--ink-strong);
  font-size: 1.06rem;
}

:where(html.cbsb-document) .section-caption {
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.5;
}

:where(html.cbsb-document) .kicker {
  margin: 0 0 7px;
  color: var(--burgundy);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .10em;
  text-transform: uppercase;
}

:where(html.cbsb-document) .toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin: 17px 0;
}

:where(html.cbsb-document) .toolbar > .field-group {
  flex: 1 1 190px;
}

:where(html.cbsb-document) .stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

:where(html.cbsb-document) .row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

:where(html.cbsb-document) .grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

:where(html.cbsb-document) .stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 21px;
}

:where(html.cbsb-document) .stat-label {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: .78rem;
}

:where(html.cbsb-document) .stat-value {
  margin: 0;
  color: var(--ink-strong);
  font-size: 1.7rem;
  font-weight: 750;
}

:where(html.cbsb-document) .muted {
  color: var(--muted);
}

/* Formularios, botones y filtros */

:where(html.cbsb-document) .field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

:where(html.cbsb-document) .field-label {
  color: #70727f;
  font-size: .75rem;
  font-weight: 720;
}

:where(html.cbsb-document) .input,
:where(html.cbsb-document) .select,
:where(html.cbsb-document) .textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255,255,255,.77);
  border: 1px solid #e6e3e9;
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

:where(html.cbsb-document) .input::placeholder,
:where(html.cbsb-document) .textarea::placeholder {
  color: #a1a4ae;
}

:where(html.cbsb-document) .input:focus,
:where(html.cbsb-document) .select:focus,
:where(html.cbsb-document) .textarea:focus {
  background: white;
  border-color: #c98697;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

:where(html.cbsb-document) .input[aria-invalid="true"],
:where(html.cbsb-document) .select[aria-invalid="true"] {
  border-color: #c76a7d;
}

:where(html.cbsb-document) .textarea {
  min-height: 95px;
  resize: vertical;
}

:where(html.cbsb-document) .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 41px;
  padding: 9px 15px;
  background: rgba(255,255,255,.72);
  color: var(--ink);
  border: 1px solid #e5e2e7;
  border-radius: var(--r-sm);
  text-align: center;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}

:where(html.cbsb-document) .btn:hover {
  background: rgba(255,255,255,.96);
}

:where(html.cbsb-document) .btn-primary {
  color: white;
  border-color: var(--burgundy);
  background: var(--burgundy);
}

:where(html.cbsb-document) .btn-primary:hover {
  background: var(--burgundy-hover);
  border-color: var(--burgundy-hover);
}

:where(html.cbsb-document) .btn-quiet {
  background: rgba(255,255,255,.30);
}

:where(html.cbsb-document) .btn-danger {
  border-color: #edc9d0;
  color: var(--danger);
  background: #fff5f6;
}

:where(html.cbsb-document) .btn-sm {
  min-height: 32px;
  padding: 5px 10px;
  font-size: .82rem;
}

:where(html.cbsb-document) .btn:disabled {
  opacity: .52;
  cursor: not-allowed;
}

/* Tablas reutilizables */

:where(html.cbsb-document) .table-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

:where(html.cbsb-document) .data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: .88rem;
}

:where(html.cbsb-document) .data-table th,
:where(html.cbsb-document) .data-table td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

:where(html.cbsb-document) .data-table th {
  background: rgba(255,255,255,.44);
  color: #696e7c;
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
}

:where(html.cbsb-document) .data-table tbody tr:last-child td {
  border-bottom: 0;
}

:where(html.cbsb-document) .data-table tbody tr:hover {
  background: rgba(255,255,255,.48);
}

:where(html.cbsb-document) .data-table td {
  color: var(--ink);
}

/* Etiquetas y colores: clase company-chip--N en cualquier HTML. */

:where(html.cbsb-document) .chip {
  --chip-ink: #616574;
  --chip-bg: #eff0f3;
  --chip-line: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--chip-line);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-ink);
  font-size: .77rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

:where(html.cbsb-document) .chip-success {
  --chip-ink: var(--positive);
  --chip-bg: var(--positive-bg);
}

:where(html.cbsb-document) .chip-warning {
  --chip-ink: var(--warning);
  --chip-bg: var(--warning-bg);
}

:where(html.cbsb-document) .chip-danger {
  --chip-ink: var(--danger);
  --chip-bg: var(--danger-bg);
}

/* 1: GRANATE — de la imagen de login */

:where(html.cbsb-document) .company-chip--1 {
  --company-color:#70344b;
  --chip-ink:#70344b;
  --chip-bg:#f3e8ed;
  --chip-line:#ebd7e0;
}

/* 2: AZUL CLÁSICO — más vivo que 6, pero sin saturación */

:where(html.cbsb-document) .company-chip--2 {
  --company-color:#3672aa;
  --chip-ink:#306596;
  --chip-bg:#e8f1fa;
  --chip-line:#d8e6f3;
}

/* 3: VERDE */

:where(html.cbsb-document) .company-chip--3 {
  --company-color:#448467;
  --chip-ink:#347153;
  --chip-bg:#e9f5ee;
  --chip-line:#d6e9dd;
}

/* 4: AZUL OSCURO / MARINO */

:where(html.cbsb-document) .company-chip--4 {
  --company-color:#283f78;
  --chip-ink:#283f78;
  --chip-bg:#e9ecf5;
  --chip-line:#dce1ef;
}

/* 5: ROJO MEDIO — del login */

:where(html.cbsb-document) .company-chip--5 {
  --company-color:#ba4c55;
  --chip-ink:#aa424b;
  --chip-bg:#faecee;
  --chip-line:#f1dadd;
}

/* 6: AZUL INTERMEDIO / ACERO; interpretación de “azul entre” */

:where(html.cbsb-document) .company-chip--6 {
  --company-color:#577c97;
  --chip-ink:#4b6f8a;
  --chip-bg:#eaf0f4;
  --chip-line:#dce6ed;
}

/* 7: ROJO INTENSO/PROFUNDO, distinto del granate y del rojo medio */

:where(html.cbsb-document) .company-chip--7 {
  --company-color:#a52f36;
  --chip-ink:#a02b34;
  --chip-bg:#f9e9ea;
  --chip-line:#edd1d4;
}

/* 8: NEGRO / GRAFITO */

:where(html.cbsb-document) .company-chip--8 {
  --company-color:#343941;
  --chip-ink:#343941;
  --chip-bg:#eaebee;
  --chip-line:#d7d9dd;
}

/* 9: AZUL CON MATIZ ÍNDIGO, distinguible de 2, 4, 6 y 10 */

:where(html.cbsb-document) .company-chip--9 {
  --company-color:#5967b6;
  --chip-ink:#4a58a0;
  --chip-bg:#eceefd;
  --chip-line:#dce0f5;
}

/* Solo para valores inexistentes o por confirmar */

:where(html.cbsb-document) .company-chip--pending {
  --company-color:#7c8390;
  --chip-ink:#6f7580;
  --chip-bg:#eff0f2;
  --chip-line:#e3e5e9;
}

/* 10: AZUL PETRÓLEO/CIAN, claramente distinto de los demás azules */

:where(html.cbsb-document) .company-chip--10 {
  --company-color:#1688a5;
  --chip-ink:#156e86;
  --chip-bg:#e4f3f6;
  --chip-line:#d2e9ef;
}

:where(html.cbsb-document) .company-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Borde discreto para una fila o tarjeta asignada a una compañía. */

:where(html.cbsb-document) .company-accent {
  border-left: 3px solid var(--company-color, #afb1ba);
}

/* También puedes usar data-company con JS: no requiere CSS particular. */

/* Avisos y diálogos reutilizables */

:where(html.cbsb-document) .alert {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  position: relative;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.74);
  border: 1px solid var(--line);
  font-size: .87rem;
}

:where(html.cbsb-document) .alert--success {
  border-color: #c3dfce;
  background: #f1faf4;
  color: #276849;
}

:where(html.cbsb-document) .alert--error {
  border-color: #f1c9d0;
  background: #fff1f3;
  color: #94354b;
}

:where(html.cbsb-document) .alert--warning {
  border-color: #ecdcb8;
  background: #fffbf1;
  color: #80632f;
}

:where(html.cbsb-document) .alert-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  padding: 1px 4px;
}

:where(html.cbsb-document) .modal {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 40px);
  overflow: auto;
  padding: 25px;
  color: var(--ink);
  background: rgba(255,253,251,.98);
  border: 1px solid #fff;
  border-radius: var(--r-lg);
  box-shadow: 0 25px 80px rgba(25,25,35,.23);
}

:where(html.cbsb-document) .modal::backdrop {
  background: rgba(26,29,42,.39);
  backdrop-filter: blur(5px);
}

/* Ventana de compañías: mantiene fijo el listado mientras se completa el formulario. */
html.cbsb-document.company-dialog-open {
  overflow: hidden;
}

:where(html.cbsb-document) .company-dialog::backdrop {
  backdrop-filter: none;
}

/* Formularios compartidos: ventanas con desplazamiento propio y fondo inmóvil. */
html.cbsb-document.form-dialog-open {
  overflow: hidden;
}

:where(html.cbsb-document) .form-dialog {
  max-height: calc(100dvh - 40px);
  overscroll-behavior: contain;
}

:where(html.cbsb-document) .form-dialog--wide {
  width: min(860px, calc(100% - 32px));
}

:where(html.cbsb-document) .form-dialog::backdrop {
  backdrop-filter: none;
}

:where(html.cbsb-document) .form-dialog .grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

:where(html.cbsb-document) .form-dialog .field-group {
  min-width: 0;
}

:where(html.cbsb-document) .form-launcher {
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  :where(html.cbsb-document) .form-dialog {
    padding: 20px;
  }

  :where(html.cbsb-document) .form-dialog .grid {
    grid-template-columns: 1fr;
  }
}

:where(html.cbsb-document) .modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 16px;
}

:where(html.cbsb-document) .modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

:where(html.cbsb-document) .empty-state {
  padding: 25px;
  text-align: center;
  color: var(--muted);
}

/* Adaptación a dispositivos */

@media (max-width: 1180px) {
  :where(html.cbsb-document) .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  :where(html.cbsb-document) .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform var(--transition);
  }

  :where(html.cbsb-document) body.sidebar-open .app-sidebar,
  :where(html.cbsb-document) #menu-visible:checked ~ .app-shell .app-sidebar {
    transform: translateX(0);
  }

  :where(html.cbsb-document) body.sidebar-open {
    overflow: hidden;
  }

  :where(html.cbsb-document) .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    opacity: 0;
    visibility: hidden;
    background: rgba(20,24,35,.42);
    transition: opacity var(--transition), visibility var(--transition);
  }

  :where(html.cbsb-document) body.sidebar-open .sidebar-backdrop,
  :where(html.cbsb-document) #menu-visible:checked ~ .app-shell .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  :where(html.cbsb-document) .menu-toggle {
    display: inline-grid;
    place-items: center;
  }
}

@media (max-width: 600px) {
  :where(html.cbsb-document) .app-content {
    padding-top: 20px;
  }

  :where(html.cbsb-document) .stat-grid,
  :where(html.cbsb-document) .grid {
    grid-template-columns: 1fr;
  }

  :where(html.cbsb-document) .glass-panel {
    padding: 16px;
  }

  :where(html.cbsb-document) .environment-tag {
    display: none;
  }

  :where(html.cbsb-document) .page-heading h1 {
    font-size: 1.4rem;
  }

  :where(html.cbsb-document) .app-topbar {
    padding-block: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :where(html.cbsb-document),
  :where(html.cbsb-document) *,
  :where(html.cbsb-document)::before,
  :where(html.cbsb-document) *::before,
  :where(html.cbsb-document)::after,
  :where(html.cbsb-document) *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :where(html.cbsb-document) .glass-panel,
  :where(html.cbsb-document) .glass-card {
    background: rgba(255,252,249,.97);
  }

  :where(html.cbsb-document) .app-topbar {
    background: #f6f6fa;
  }
}

/* ===== Cuentas - usuarios y asignación de roles ===== */

/* CBSB | Complementos compartidos para BSB-9 y BSB-10.
   El diseño principal continúa en la sección de interfaz CBSB de styles.css. */

:where(html.cbsb-document) .account-section-top {
  margin-bottom: 8px;
}

:where(html.cbsb-document) .account-filters {
  align-items: end;
}

:where(html.cbsb-document) .account-filters .field-group {
  min-width: 155px;
}

:where(html.cbsb-document) .account-filter-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 1px;
}

:where(html.cbsb-document) .account-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

:where(html.cbsb-document) .account-inline-form {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

:where(html.cbsb-document) .account-inline-form button {
  white-space: nowrap;
}

:where(html.cbsb-document) .account-role-label {
  font-weight: 600;
}

:where(html.cbsb-document) .account-pagination {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 12px;
  margin-top: 16px;
}

:where(html.cbsb-document) .account-note {
  margin-top: 20px;
}

:where(html.cbsb-document) .account-modal {
  width: min(680px, calc(100% - 32px));
}

:where(html.cbsb-document) .account-edit-form {
  gap: 14px;
}

:where(html.cbsb-document) .account-form-actions {
  justify-content: flex-end;
}

:where(html.cbsb-document) .account-error-list {
  margin: 8px 0 0;
  padding-left: 22px;
}

:where(html.cbsb-document) .account-role-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(285px, .8fr);
  align-items: start;
}

:where(html.cbsb-document) .account-role-form {
  margin-top: 18px;
}

:where(html.cbsb-document) .account-role-picker {
  margin: 0;
  padding: 0;
  border: 0;
}

:where(html.cbsb-document) .account-role-picker > legend {
  padding: 0;
  color: var(--ink);
  font-size: .9rem;
}

:where(html.cbsb-document) .account-role-hint {
  margin: 0;
  color: #535768;
  font-size: .8rem;
}

:where(html.cbsb-document) .roles-checkbox-container {
  display: grid;
  gap: .4rem;
  max-height: 15rem;
  overflow-y: auto;
  padding: .55rem;
  background: var(--page);
  border: 1px solid #c8c6d1;
  border-radius: 8px;
}

:where(html.cbsb-document) .role-checkbox-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .1rem .65rem;
  align-items: center;
  min-height: 44px;
  padding: .45rem .6rem;
  color: var(--ink-strong);
  background: #fff;
  border: 1px solid #d4d1da;
  border-radius: 6px;
  font-size: .88rem;
  font-weight: 650;
  overflow-wrap: anywhere;
  cursor: pointer;
}

:where(html.cbsb-document) .role-checkbox-item input {
  grid-row: span 2;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

:where(html.cbsb-document) .role-checkbox-scope {
  grid-column: 2;
  color: #535768;
  font-size: .75rem;
  font-weight: 500;
}

:where(html.cbsb-document) .role-checkbox-item:hover,
:where(html.cbsb-document) .role-checkbox-item:has(input:checked) {
  border-color: var(--primary);
}

:where(html.cbsb-document) .role-checkbox-item:has(input:checked) {
  background: var(--primary-soft);
}

:where(html.cbsb-document) .role-checkbox-item:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

:where(html.cbsb-document) .account-assignment-preview {
  min-height: 240px;
}

:where(html.cbsb-document) .account-summary {
  display: grid;
  gap: 13px;
  margin: 14px 0 20px;
}

:where(html.cbsb-document) .account-summary div {
  padding: 9px 0 12px;
  border-bottom: 1px solid var(--line);
}

:where(html.cbsb-document) .account-summary dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .78rem;
}

:where(html.cbsb-document) .account-summary dd {
  margin: 0;
  color: var(--ink);
  font-weight: 650;
  word-break: break-word;
}

:where(html.cbsb-document) .account-preview-notice {
  margin: 0;
  font-size: .85rem;
}

:where(html.cbsb-document) .account-table-section {
  margin-top: 20px;
}

@media (max-width: 1050px) {
  :where(html.cbsb-document) .account-role-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 650px) {
  :where(html.cbsb-document) .account-filters .field-group {
    min-width: 100%;
  }

  :where(html.cbsb-document) .account-filter-buttons {
    width: 100%;
  }

  :where(html.cbsb-document) .account-filter-buttons > * {
    flex: 1;
  }

  :where(html.cbsb-document) .account-pagination {
    justify-content: center;
  }
}

/* Formularios POST reales BSB-9 y BSB-10. Colores en la sección de interfaz CBSB */

:where(html.cbsb-document) .account-server-note {
  border-color: var(--line);
  background: rgba(255,255,255,.55);
  color: var(--muted);
}

:where(html.cbsb-document) .account-validation {
  margin: 0 0 12px;
}

:where(html.cbsb-document) .account-assignment-preview {
  align-self: start;
}

:where(html.cbsb-document) .account-row-actions .account-inline-form {
  display: inline-flex;
}

/* ===== Sprint 1 - compañías, acceso y catálogo ===== */

/* CBSB · Sprint 1: BSB-8, BSB-11 y BSB-14. Solo complementos.
   Paleta global: la sección de interfaz CBSB de styles.css. */

:where(html.cbsb-document) .sidebar-section-heading {
  margin-top: 18px;
  margin-bottom: 7px;
}

:where(html.cbsb-document) .sprint1-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 14px;
}

:where(html.cbsb-document) .sprint1-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

:where(html.cbsb-document) .sprint1-actions--end {
  justify-content: flex-end;
}

:where(html.cbsb-document) .sprint1-inline-form {
  display: inline-flex;
  margin: 0;
}

:where(html.cbsb-document) .sprint1-errors {
  margin: 0 0 0 20px;
  padding: 0;
}

:where(html.cbsb-document) .sprint1-modal {
  width: min(600px, calc(100% - 28px));
}

:where(html.cbsb-document) .sprint1-modal--wide {
  width: min(800px, calc(100% - 28px));
}

:where(html.cbsb-document) .sprint1-modal .stack {
  gap: 15px;
}

:where(html.cbsb-document) .sprint1-modal .grid {
  gap: 12px;
}

:where(html.cbsb-document) .sprint1-modal .modal-head {
  margin-bottom: 20px;
}

:where(html.cbsb-document) .sprint1-modal .field-group {
  min-width: 0;
}

:where(html.cbsb-document) .sprint1-bottom-note {
  margin-top: 20px;
}

:where(html.cbsb-document) .sprint1-scope-note {
  padding: 11px 13px;
  border-radius: 10px;
  background: rgba(129,28,54,.055);
  font-size: .88rem;
}

:where(html.cbsb-document) .sprint1-stat-text {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 720;
  color: var(--ink-strong);
  overflow-wrap: anywhere;
}

@media (max-width: 780px) {
  :where(html.cbsb-document) .sprint1-actions .btn {
    flex: 0 1 auto;
  }

  :where(html.cbsb-document) .sprint1-modal .grid {
    grid-template-columns: 1fr;
  }

  :where(html.cbsb-document) .sprint1-section-header {
    align-items: start;
  }
}

/* Formularios desplegables nativos de los módulos. */
:where(html.cbsb-document) .native-form {
  margin-top: 24px;
  scroll-margin-top: 24px;
}

:where(html.cbsb-document) .native-form > summary {
  cursor: pointer;
}

:where(html.cbsb-document) #menu-visible:focus-visible ~ .app-shell .menu-toggle {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

:where(html.cbsb-document) .stat-grid.inventario-resumen {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

:where(html.cbsb-document) .inventario-panel {
    margin-inline: -8px;
}

.contenedor-contrasena {
    position: relative;
}

.contenedor-contrasena input {
    width: 100%;
    box-sizing: border-box;
    padding-right: 40px;
}

.login .contenedor-contrasena button.ver-contrasena {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    color: #666;
    font-size: 18px;
    cursor: pointer;
}

.login .contenedor-contrasena button.ver-contrasena:hover {
    background: transparent;
    color: #81243b;
}

/* Operaciones de inventario: estilos limitados a estas pantallas. */

:where(html.cbsb-document) .material-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .6);
}

:where(html.cbsb-document) .material-tabs button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 170px;
    gap: 10px;
    min-height: 50px;
    padding: 12px 16px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 650;
}

:where(html.cbsb-document) .material-tabs button:hover {
    background: #f3e8eb;
    color: #81243b;
}

:where(html.cbsb-document) .material-tabs button[aria-selected="true"] {
    background: #81243b;
    color: #fff;
}

:where(html.cbsb-document) .material-panel {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

:where(html.cbsb-document) .material-panel h2,
:where(html.cbsb-document) #panel-disponibilidad h2 {
    margin-bottom: 24px;
}

:where(html.cbsb-document) .material-summary {
    margin-block: 24px;
}

:where(html.cbsb-document) #gestion-materiales[aria-busy="true"] {
    cursor: progress;
}

:where(html.cbsb-document) .inventory-workspace {
    display: grid;
    gap: 24px;
    min-width: 0;
}

:where(html.cbsb-document) .inventory-heading,
:where(html.cbsb-document) .inventory-results-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

:where(html.cbsb-document) .inventory-heading h1 {
    margin: 6px 0 10px;
    font-size: clamp(1.6rem, 2.5vw, 2.15rem);
    letter-spacing: -.035em;
    color: var(--ink-strong);
}

:where(html.cbsb-document) .inventory-eyebrow {
    display: block;
    margin: 0;
    color: #81243b;
    font-size: .7rem;
    font-weight: 750;
    letter-spacing: .12em;
    text-transform: uppercase;
}

:where(html.cbsb-document) .inventory-description,
:where(html.cbsb-document) .inventory-muted {
    margin: 0;
    color: var(--muted);
    font-size: .9rem;
    line-height: 1.65;
}

:where(html.cbsb-document) .inventory-scope,
:where(html.cbsb-document) .inventory-readonly-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255, 255, 255, .7);
    font-size: .78rem;
}

:where(html.cbsb-document) .inventory-scope-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #539275;
}

:where(html.cbsb-document) .inventory-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, .43fr);
    align-items: start;
    gap: 24px;
}

:where(html.cbsb-document) .inventory-workspace .inventory-card {
    min-width: 0;
    margin: 0;
    padding: 26px;
}

:where(html.cbsb-document) .inventory-card-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

:where(html.cbsb-document) .inventory-card h2 {
    margin: 0;
    color: var(--ink-strong);
    font-size: 1rem;
}

:where(html.cbsb-document) .inventory-card-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #f3e8eb;
    color: #81243b;
    font-size: 1.2rem;
}

:where(html.cbsb-document) .inventory-form,
:where(html.cbsb-document) .inventory-aside {
    display: grid;
    gap: 22px;
    margin: 0;
}

:where(html.cbsb-document) .inventory-card > .inventory-form + .inventory-form {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

:where(html.cbsb-document) .inventory-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

:where(html.cbsb-document) .inventory-workspace .field-group {
    min-width: 0;
    margin: 0;
}

:where(html.cbsb-document) .inventory-workspace .field-hint {
    color: var(--muted);
    font-size: .76rem;
    line-height: 1.6;
}

:where(html.cbsb-document) .inventory-workspace .textarea {
    min-height: 110px;
    resize: vertical;
}

:where(html.cbsb-document) .inventory-workspace .btn:disabled {
    cursor: not-allowed;
    opacity: .5;
    box-shadow: none;
}

:where(html.cbsb-document) .inventory-choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 0;
    border: 0;
    margin: 0;
}

:where(html.cbsb-document) .inventory-choice-group legend {
    margin-bottom: 10px;
    font-size: .84rem;
    font-weight: 650;
}

:where(html.cbsb-document) .inventory-choice,
:where(html.cbsb-document) .inventory-check-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .5);
    cursor: pointer;
}

:where(html.cbsb-document) .inventory-choice {
    flex: 1;
}

:where(html.cbsb-document) .inventory-check-card input,
:where(html.cbsb-document) .inventory-choice input {
    width: 16px;
    height: 16px;
    margin: 3px 0 0;
    accent-color: #81243b;
}

:where(html.cbsb-document) .inventory-check-card strong,
:where(html.cbsb-document) .inventory-choice strong {
    display: block;
    margin-bottom: 4px;
    font-size: .86rem;
}

:where(html.cbsb-document) .inventory-check-card span span,
:where(html.cbsb-document) .inventory-choice span span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.5;
}

:where(html.cbsb-document) .inventory-note {
    margin: 0;
    padding: 13px 16px;
    border-left: 3px solid #b98794;
    border-radius: 0 9px 9px 0;
    background: #f7f0f2;
    color: #795462;
    font-size: .8rem;
    line-height: 1.6;
}

:where(html.cbsb-document) .inventory-form-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

:where(html.cbsb-document) .inventory-placeholder-title,
:where(html.cbsb-document) .inventory-item-name {
    margin: 0 0 8px;
    font-size: .95rem;
    font-weight: 700;
}

:where(html.cbsb-document) .inventory-item-code,
:where(html.cbsb-document) .inventory-cell-secondary {
    display: block;
    color: var(--muted);
    font-size: .77rem;
}

:where(html.cbsb-document) .inventory-facts {
    margin: 24px 0 0;
}

:where(html.cbsb-document) .inventory-facts > div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 13px 0;
    border-top: 1px solid var(--line);
    font-size: .79rem;
}

:where(html.cbsb-document) .inventory-facts dt {
    color: var(--muted);
}

:where(html.cbsb-document) .inventory-facts dd {
    margin: 0;
    text-align: right;
    overflow-wrap: anywhere;
}

:where(html.cbsb-document) .inventory-back-link {
    padding: 0 6px;
    color: #81243b;
    font-size: .82rem;
    text-decoration: none;
}

:where(html.cbsb-document) .inventory-workspace .inventory-empty {
    padding: 38px 20px;
    text-align: center;
    white-space: normal;
}

:where(html.cbsb-document) .inventory-empty strong,
:where(html.cbsb-document) .inventory-empty span {
    display: block;
    margin-bottom: 6px;
}

:where(html.cbsb-document) .inventory-empty span {
    color: var(--muted);
    font-size: .8rem;
}

:where(html.cbsb-document) .inventory-location-flow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
    align-items: center;
    gap: 16px;
}

:where(html.cbsb-document) .inventory-location-origin,
:where(html.cbsb-document) .inventory-current-value {
    display: grid;
    gap: 9px;
    padding: 18px;
    border: 1px dashed #d9c7cd;
    border-radius: 12px;
    color: var(--muted);
    font-size: .8rem;
}

:where(html.cbsb-document) .inventory-location-arrow {
    color: #81243b;
    font-size: 1.5rem;
}

:where(html.cbsb-document) .inventory-search-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 18px;
    padding: 0;
    border: 0;
    margin: 0;
}

:where(html.cbsb-document) .inventory-search-text {
    grid-column: span 2;
}

:where(html.cbsb-document) .inventory-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

:where(html.cbsb-document) .inventory-metric {
    margin: 0;
    padding: 20px;
}

:where(html.cbsb-document) .inventory-metric span {
    color: var(--muted);
    font-size: .8rem;
}

:where(html.cbsb-document) .inventory-metric strong {
    display: block;
    margin-top: 10px;
    font-size: 1.7rem;
}

:where(html.cbsb-document) .inventory-metric-available strong {
    color: #377754;
}

:where(html.cbsb-document) .inventory-results-heading {
    margin-bottom: 22px;
}

:where(html.cbsb-document) .inventory-result-detail summary {
    color: #81243b;
    cursor: pointer;
}

:where(html.cbsb-document) .inventory-card > .inventory-note {
    margin-top: 20px;
}

@media (max-width: 1000px) {
    :where(html.cbsb-document) .inventory-heading {
        flex-direction: column;
        gap: 14px;
    }

    :where(html.cbsb-document) .inventory-columns {
        grid-template-columns: minmax(0, 1fr);
    }

    :where(html.cbsb-document) .inventory-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    :where(html.cbsb-document) .inventory-heading,
    :where(html.cbsb-document) .inventory-results-heading {
        flex-direction: column;
        gap: 14px;
    }

    :where(html.cbsb-document) .inventory-field-grid,
    :where(html.cbsb-document) .inventory-search-fields,
    :where(html.cbsb-document) .inventory-location-flow {
        grid-template-columns: minmax(0, 1fr);
    }

    :where(html.cbsb-document) .inventory-search-text {
        grid-column: auto;
    }

    :where(html.cbsb-document) .inventory-location-arrow {
        text-align: center;
        transform: rotate(90deg);
    }

    :where(html.cbsb-document) .inventory-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :where(html.cbsb-document) .inventory-workspace .inventory-card {
        padding: 20px;
    }
}


/* Adaptación común para PC, tablet y teléfono. Las tablas se desplazan dentro de su panel. */
:where(html.cbsb-document) .record-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

:where(html.cbsb-document) .record-tabs > button {
  min-height: 44px;
}

:where(html.cbsb-document) .grid > *,
:where(html.cbsb-document) .glass-panel,
:where(html.cbsb-document) .glass-card,
:where(html.cbsb-document) .topbar-left {
  min-width: 0;
}

:where(html.cbsb-document) .table-scroll {
  width: 100%;
  overscroll-behavior-x: contain;
}

:where(html.cbsb-document) .menu-toggle {
  flex-shrink: 0;
  cursor: pointer;
}

@media (max-width: 900px) {
  :where(html.cbsb-document) .app-topbar .chip {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  :where(html.cbsb-document) .menu-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  :where(html.cbsb-document) .app-topbar {
    gap: 12px;
  }

  :where(html.cbsb-document) .topbar-left {
    width: 100%;
  }

  :where(html.cbsb-document) .toolbar > .field-group {
    flex-basis: 100%;
    min-width: 0;
  }

  :where(html.cbsb-document) .toolbar > .btn,
  :where(html.cbsb-document) .record-tabs > button {
    flex: 1 1 auto;
  }

  :where(html.cbsb-document) .btn {
    min-height: 44px;
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  :where(html.cbsb-document) .input,
  :where(html.cbsb-document) .select,
  :where(html.cbsb-document) .textarea {
    min-width: 0;
    font-size: 16px;
  }

  :where(html.cbsb-document) .form-dialog,
  :where(html.cbsb-document) .company-dialog {
    max-height: calc(100dvh - 24px);
  }

  :where(html.cbsb-document) .modal-head {
    align-items: center;
  }

  :where(html.cbsb-document) .account-form-actions,
  :where(html.cbsb-document) .sprint1-actions--end {
    flex-wrap: wrap;
  }

  :where(html.cbsb-document) .account-form-actions > .btn,
  :where(html.cbsb-document) .sprint1-actions--end > .btn {
    flex: 1 1 auto;
  }

  :where(html:not(.cbsb-document)) .nav-container,
  :where(html:not(.cbsb-document)) .nav-actions {
    flex-wrap: wrap;
    gap: 12px;
  }

  :where(html:not(.cbsb-document)) .navbar {
    padding-inline: 16px;
  }

  :where(html:not(.cbsb-document)) .brand {
    min-width: 0;
  }

  :where(html:not(.cbsb-document)) .main-wrapper {
    padding: 20px 16px;
  }

  :where(html:not(.cbsb-document)) .login {
    padding: 24px 20px;
  }

  :where(html:not(.cbsb-document)) .opciones {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  :where(html:not(.cbsb-document)) .opciones label {
    min-width: 0;
    min-height: 44px;
    overflow-wrap: anywhere;
  }

  :where(html:not(.cbsb-document)) .campo input {
    font-size: 16px;
  }

  :where(html:not(.cbsb-document)) .extras {
    flex-wrap: wrap;
  }
}

@media (max-width: 380px) {
  :where(html:not(.cbsb-document)) .opciones {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :where(html.cbsb-document) .chip {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  :where(html.cbsb-document) .account-summary dd {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

/* Ventanas resueltas por Django: sin controladores JavaScript. */
:where(html.cbsb-document) .equipment-section-heading,
:where(html.cbsb-document) .equipment-filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

:where(html.cbsb-document) .equipment-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  margin-bottom: 22px;
}

:where(html.cbsb-document) .equipment-filters .field-group {
  flex: 1 1 240px;
  min-width: 0;
}

:where(html.cbsb-document) .equipment-filter-actions {
  justify-content: flex-start;
  margin-bottom: 0;
}

:where(html.cbsb-document) .equipment-cell-detail {
  display: block;
  margin-top: 6px;
  color: var(--text-muted, #697182);
  font-size: .85em;
  overflow-wrap: anywhere;
}

:where(html.cbsb-document) .equipment-table {
  min-width: 900px;
}

:where(html.cbsb-document) .equipment-form-wide {
  grid-column: 1 / -1;
}

:where(html.cbsb-document) .form-window {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 12px;
  place-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(26,29,42,.39);
}

:where(html.cbsb-document) .form-window--open {
  display: grid;
}

:where(html.cbsb-document) .form-window-backdrop {
  position: absolute;
  inset: 0;
}

:where(html.cbsb-document) .form-window > dialog[open] {
  position: relative;
  inset: auto;
  z-index: 1;
  margin: 0;
  max-height: calc(100dvh - 24px);
}

:where(html.cbsb-document) .material-tabs > a {
  flex: 1 1 150px;
  min-height: 50px;
  text-align: center;
  white-space: normal;
}

:where(html.cbsb-document) .material-tabs > a[aria-current="page"] {
  background: var(--burgundy);
  border-color: var(--burgundy);
  color: white;
}

:where(html.cbsb-document) .gestion-material-tabs > a {
  font-size: 1rem;
  font-weight: 600;
}

:where(html.cbsb-document) .record-tabs > label {
  cursor: pointer;
  min-height: 44px;
}

@media (max-width: 640px) {
  :where(html.cbsb-document) .record-tabs > label {
    flex: 1 1 auto;
  }
}

/* Alternancia entre las dos tablas del inventario, conservando los filtros GET. */
:where(html.cbsb-document) .history-optional-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 20px;
  align-items: start;
}

:where(html.cbsb-document) .history-date-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  min-width: 0;
}

:where(html.cbsb-document) .history-optional-label {
  color: var(--muted);
  font-weight: 400;
}

@media (max-width: 800px) {
  :where(html.cbsb-document) .history-optional-filters {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  :where(html.cbsb-document) .history-date-range {
    grid-template-columns: 1fr;
  }
}

:where(html.cbsb-document) .history-record-link {
  display: inline-block;
  margin-top: 6px;
  max-width: 100%;
  color: #b5293b;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: normal;
}

:where(html.cbsb-document) .history-record-link:hover {
  color: #932133;
}

:where(html.cbsb-document) .history-record-link:focus-visible {
  outline: 2px solid var(--burgundy);
  outline-offset: 2px;
}

:where(html.cbsb-document) .history-metric-link {
  color: var(--ink);
  text-decoration: none;
}

:where(html.cbsb-document) .history-metric-link:hover,
:where(html.cbsb-document) .history-metric-link:focus-visible {
  outline: 2px solid var(--burgundy);
  outline-offset: 2px;
}

:where(html.cbsb-document) .inventory-table-workspace > .material-tabs > label {
  flex: 1 1 240px;
  text-align: center;
  white-space: normal;
}

:where(html.cbsb-document) #vista-inventario-materiales:checked ~ .record-tabs [for="vista-inventario-materiales"],
:where(html.cbsb-document) #vista-inventario-series:checked ~ .record-tabs [for="vista-inventario-series"] {
  background: var(--burgundy);
  border-color: var(--burgundy);
  color: white;
}

:where(html.cbsb-document) #vista-inventario-materiales:checked ~ #panel-inventario-series,
:where(html.cbsb-document) #vista-inventario-series:checked ~ #panel-inventario-materiales {
  display: none;
}

:where(html.cbsb-document) #vista-inventario-materiales:focus-visible ~ .record-tabs [for="vista-inventario-materiales"],
:where(html.cbsb-document) #vista-inventario-series:focus-visible ~ .record-tabs [for="vista-inventario-series"] {
  outline: 2px solid var(--burgundy);
  outline-offset: 3px;
}


/* Características dentro de la ficha del catálogo. */
:where(html.cbsb-document) .catalog-characteristics {
    border-top: 1px solid var(--border, #e2e2e7);
    padding-top: 20px;
}

:where(html.cbsb-document) .catalog-characteristics h3 {
    margin: 0 0 8px;
}

:where(html.cbsb-document) .catalog-characteristic-row {
    border: 1px solid var(--border, #e2e2e7);
    border-radius: 12px;
    margin: 16px 0;
    min-width: 0;
    padding: 16px;
}

:where(html.cbsb-document) .catalog-characteristic-row legend {
    font-weight: 600;
    padding: 0 8px;
}

:where(html.cbsb-document) .catalog-characteristic-row > button {
    justify-self: start;
}

/* Presentación de transferencias definitivas. */
:where(html.cbsb-document) .transfer-fields {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

:where(html.cbsb-document) .transfer-fields legend {
    font-size: 1rem;
    font-weight: 650;
    margin-bottom: 16px;
}

:where(html.cbsb-document) .transfer-summary {
    background: var(--surface, #f5f5f8);
    border: 1px solid var(--border, #e2e2e7);
    border-radius: 12px;
    padding: 20px;
}

:where(html.cbsb-document) .transfer-summary h3 {
    margin: 0 0 16px;
    font-size: 1rem;
}

:where(html.cbsb-document) .transfer-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
    margin: 0;
}

:where(html.cbsb-document) .transfer-summary-grid dt {
    color: var(--text-muted, #697182);
    font-size: .85rem;
    margin-bottom: 4px;
}

:where(html.cbsb-document) .transfer-summary-grid dd {
    font-weight: 600;
    margin: 0;
    overflow-wrap: anywhere;
}

:where(html.cbsb-document) .transfer-empty {
    padding: 24px 12px;
    text-align: center;
}

:where(html.cbsb-document) .transfer-empty p {
    color: var(--text-muted, #697182);
    margin: 8px 0 0;
}

@media (max-width: 640px) {
    :where(html.cbsb-document) .transfer-summary-grid {
        grid-template-columns: 1fr;
    }
}
:where(html.cbsb-document) #abrir-adquisicion {
    align-self: flex-start;
    max-width: 100%;
    border-color: #81243b;
    color: #81243b;
    font-weight: 700;
}


:where(html.cbsb-document) .dashboard-consulta {
    margin-bottom: 20px;
    padding: 18px 24px;
}

:where(html.cbsb-document) .dashboard-consulta .toolbar {
    margin: 10px 0;
}
