:root {
  --app-teal: #0d9488; /* teal-600 */
  --app-teal-dark: #0f766e; /* teal-700 */
  --app-cream: #fff7ed; /* orange-50 */
  --app-cream-2: #fffbeb; /* amber-50 */
  --app-purple: #6f42c1;
}

.text-bg-purple {
  color: #fff !important;
  background-color: var(--app-purple) !important;
}

/* Keep icons readable on saturated backgrounds (purple/orange/chips). */
.text-bg-purple i,
.text-bg-purple svg,
.text-bg-purple .la-icon-wrap,
.text-bg-purple .la-icon,
.text-bg-purple .la-fallback,
.badge.bg-orange i,
.badge.bg-orange svg,
.badge.bg-orange .la-icon-wrap,
.badge.bg-orange .la-icon,
.badge.bg-orange .la-fallback,
.module-icon i,
.module-icon svg,
.module-icon .la-icon-wrap,
.module-icon .la-icon,
.module-icon .la-fallback {
  color: #fff !important;
  stroke: currentColor;
}

.bg-purple-subtle {
  background-color: rgba(111, 66, 193, 0.16) !important;
}

.ra-list-hero-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.ra-list-hero-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ra-photo-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
}

.ra-activity-photo {
  max-width: 100%;
  width: 220px;
  max-height: 160px;
  object-fit: cover;
}

.ra-risk-icon {
  width: 24px;
  height: 24px;
}

.ra-matrix-wrap {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.ra-risk-matrix-canvas {
  border: 2px solid #dee2e6;
  border-radius: 8px;
  background: #fff;
}

.ra-legend-color {
  width: 20px;
  height: 20px;
  border-radius: 3px;
}

.ra-legend-color-green {
  background: #198754;
}

.ra-legend-color-yellow {
  background: #ffc107;
}

.ra-legend-color-orange {
  background: #fd7e14;
}

.ra-legend-color-red {
  background: #dc3545;
}

.ra-ppe-icon {
  height: 50px;
  object-fit: contain;
}

.ra-ghs-icon {
  height: 24px;
  object-fit: contain;
}

.ra-photo-preview-box {
  max-width: 420px;
}

.ra-photo-preview-image {
  max-height: 260px;
  width: 100%;
  object-fit: cover;
}

.is-hidden {
  display: none;
}

.ra-risk-type-card {
  border: none;
}

.ra-risk-type-chemical {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.ra-risk-type-physical {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.ra-risk-type-mechanical {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

.ra-risk-type-electrical {
  background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
}

.ra-risk-type-biological {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.ra-risk-type-ergonomic {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.ra-risk-type-psychosocial {
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
}

.ra-risk-type-environmental {
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
}

.ra-risk-type-icon {
  font-size: 1.2rem;
}

.ra-risk-chip-sm {
  font-size: 0.75rem;
}

.workers-actions-col {
  width: 60px;
}

.worker-select-col {
  width: 40px;
}

.chemical-actions-col {
  width: 80px;
}

.worker-list-scroll {
  max-height: 400px;
  overflow-y: auto;
}

.risk-modal-content-sm {
  max-width: 600px;
}

.risk-modal-content-md {
  max-width: 700px;
}

.risk-modal-content-lg {
  max-width: 800px;
}

.risk-icon-sm {
  width: 22px;
  height: 22px;
}

.risk-icon-md {
  width: 32px;
  height: 32px;
}

.ppe-icon-lg {
  height: 60px;
  object-fit: contain;
}

.ppe-icon-md {
  height: 50px;
  object-fit: contain;
}

.ppe-remove-btn {
  padding: 0.1rem 0.3rem;
}

.ghs-icon-sm {
  height: 25px;
}

.ghs-icon-md {
  height: 30px;
}

.clickable-row {
  cursor: pointer;
}

.col-w-4 {
  width: 4%;
}

.col-w-8 {
  width: 8%;
}

.col-w-10 {
  width: 10%;
}

.col-w-12 {
  width: 12%;
}

.col-w-14 {
  width: 14%;
}

.col-w-15 {
  width: 15%;
}

.col-w-16 {
  width: 16%;
}

.col-w-18 {
  width: 18%;
}

.col-w-19 {
  width: 19%;
}

.col-w-20 {
  width: 20%;
}

.col-w-30 {
  width: 30%;
}

.col-w-34 {
  width: 34%;
}

.col-w-48 {
  width: 48%;
}

.col-w-55 {
  width: 55%;
}

.risk-assessment-list-table table,
.risk-assessment-detail-table table {
  min-width: 700px;
}

.risk-actions-col {
  width: 160px;
}

.risk-icon {
  height: 32px;
  object-fit: contain;
}

.raf-progress,
.fire-progress {
  height: 0.5rem;
  min-width: 180px;
}

.fire-section-na-wrap .form-check-input {
  width: 0.8rem;
  height: 0.8rem;
  margin-top: 0.15rem;
}

.fire-section-na-wrap {
  font-size: 0.7rem !important;
  font-weight: 400 !important;
  color: #8c939c !important;
  line-height: 1 !important;
}

.fire-section-na-label {
  font-size: inherit !important;
  line-height: inherit !important;
  font-weight: inherit !important;
  color: inherit !important;
  letter-spacing: 0.15px !important;
  text-transform: none !important;
}

.fire-section-na-wrap .form-check-input:checked + .fire-section-na-label {
  color: #7b828c !important;
  font-weight: 400 !important;
}

/* Touch-friendly improvements */
* {
  -webkit-tap-highlight-color: transparent;
}

button, a, input, select, textarea {
  touch-action: manipulation;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

.app-bg {
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.45), #ffffff 45%);
  min-height: 100vh;
}

.app-topbar {
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(15, 118, 110, 0.12);
}

.app-topbar-sticky {
  z-index: 1020;
}

.app-main-container {
  padding: 1.25rem 1.5rem;
}

.app-topbar-left,
.app-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-topbar .btn {
  min-height: 2.5rem;
}

.app-topbar .app-topbar-icon-btn {
  width: 2.5rem;
  min-width: 2.5rem;
  height: 2.5rem;
  min-height: 2.5rem;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 0;
}

.app-topbar .app-topbar-icon-btn .la-icon-wrap {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 0;
}

.app-topbar .app-topbar-icon-btn .la-icon,
.app-topbar .app-topbar-icon-btn .lucide {
  display: block;
  vertical-align: middle;
}

.app-topbar .app-topbar-qr-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.38rem;
  line-height: 1;
}

.app-topbar .app-topbar-qr-btn .la-icon-wrap {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 1.22rem;
  height: 1.22rem;
  line-height: 0;
  flex-shrink: 0;
  transform: translateY(1px);
}

.app-topbar .app-topbar-qr-btn .la-icon,
.app-topbar .app-topbar-qr-btn .la-fallback,
.app-topbar .app-topbar-qr-btn .lucide {
  width: 1.08rem;
  height: 1.08rem;
}

.app-topbar .app-topbar-qr-btn .d-lg-inline {
  line-height: 1;
}

/* Global table shell consistency */
.table-responsive {
  border-radius: 0.75rem;
  -webkit-overflow-scrolling: touch;
}

/* Mobile-first baseline for cross-module screens */
@media (max-width: 991px) {
  .app-main-container {
    padding: 1rem;
  }

  .card-header,
  .card-body,
  .card-footer {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }
}

@media (max-width: 768px) {
  .ra-list-hero-row {
    flex-direction: column;
    align-items: stretch;
  }

  .ra-list-hero-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .ra-list-hero-actions .btn {
    flex: 1 1 180px;
  }

  .ra-activity-photo {
    width: 100%;
    max-width: 100%;
  }

  .ra-photo-preview-box {
    max-width: 100%;
  }

  .risk-assessment-list-table table,
  .risk-assessment-detail-table table {
    min-width: 640px;
  }

  .app-topbar .container-fluid {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }

  .app-topbar-left,
  .app-topbar-right {
    gap: 0.375rem;
  }

  .app-topbar .btn {
    min-height: 2.375rem;
    min-width: 2.375rem;
    padding: 0.45rem 0.65rem;
  }

  .app-topbar .app-topbar-icon-btn {
    width: 2.375rem;
    min-width: 2.375rem;
    height: 2.375rem;
    min-height: 2.375rem;
    padding: 0 !important;
  }

  .app-topbar .form-select {
    min-height: 2.375rem;
    font-size: 0.9rem;
  }

  .app-topbar .app-topbar-qr-btn {
    width: 2.375rem;
    min-width: 2.375rem;
    height: 2.375rem;
    min-height: 2.375rem;
    padding: 0 !important;
    border-radius: 0.7rem;
    line-height: 0 !important;
  }

  .app-topbar .app-topbar-qr-btn .la-icon-wrap {
    width: 1.28rem;
    height: 1.28rem;
  }

  .app-topbar .app-topbar-qr-btn .la-icon,
  .app-topbar .app-topbar-qr-btn .la-fallback,
  .app-topbar .app-topbar-qr-btn .lucide {
    width: 1.16rem;
    height: 1.16rem;
  }

  .btn,
  .form-control,
  .form-select,
  .input-group-text {
    min-height: 2.5rem;
  }

  .table-responsive {
    border-radius: 0.625rem;
  }

  .table-responsive table {
    min-width: 640px;
  }

  .modal-dialog {
    margin: 0.65rem;
  }
}

@media (max-width: 576px) {
  .risk-assessment-list-table table,
  .risk-assessment-detail-table table {
    min-width: 560px;
  }

  .app-main-container {
    padding: 0.85rem 0.7rem;
  }

  .app-topbar .btn {
    min-height: 2.25rem;
    min-width: 2.25rem;
    padding: 0.4rem 0.55rem;
  }

  .app-topbar .app-topbar-icon-btn {
    width: 2.25rem;
    min-width: 2.25rem;
    height: 2.25rem;
    min-height: 2.25rem;
    padding: 0 !important;
  }

  .app-topbar .form-select {
    max-width: 140px;
    min-height: 2.25rem;
  }

  .app-topbar .app-topbar-qr-btn {
    width: 2.25rem;
    min-width: 2.25rem;
    height: 2.25rem;
    min-height: 2.25rem;
    padding: 0 !important;
  }

  .app-topbar .app-topbar-qr-btn .la-icon-wrap {
    width: 1.14rem;
    height: 1.14rem;
  }

  .app-topbar .app-topbar-qr-btn .la-icon,
  .app-topbar .app-topbar-qr-btn .la-fallback,
  .app-topbar .app-topbar-qr-btn .lucide {
    width: 1.02rem;
    height: 1.02rem;
  }

  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-content {
    border-radius: 0.85rem;
  }

  .table-responsive table {
    min-width: 560px;
  }
}

.app-sidebar {
  display: flex;
  flex-direction: column;
  width: 264px;
  height: 100dvh;
  min-height: 100vh;
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: width 0.3s ease, transform 0.3s ease;
  position: relative;
  overflow: hidden;
}

.app-sidebar-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0.35rem;
}

.app-sidebar-nav-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.2rem;
}

.app-sidebar-nav {
  margin-bottom: 0 !important;
}

.app-sidebar-footer {
  flex-shrink: 0;
  margin-top: 0.25rem;
}

/* Hide visual separators inside sidebar content blocks. */
.app-sidebar-main hr,
.app-sidebar-footer > hr {
  display: none !important;
}

.app-sidebar-nav-wrap::-webkit-scrollbar {
  width: 6px;
}

.app-sidebar-nav-wrap::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.7);
  border-radius: 999px;
}

.app-sidebar-nav-wrap::-webkit-scrollbar-track {
  background: transparent;
}

/* Reusable side-panel helpers for page-level sidebars */
.sidebar-panel-sticky {
  position: sticky;
  top: var(--sidebar-panel-top, 96px);
  align-self: flex-start;
}

.sidebar-panel-scroll {
  max-height: calc(100dvh - var(--sidebar-panel-offset, 116px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.flex-grow-1 {
  min-width: 0;
}

/* Sidebar colapsado (desktop) */
.app-sidebar.collapsed {
  width: 70px;
  padding-left: 0.5rem !important;
  padding-right: 0.5rem !important;
}

.app-sidebar.collapsed .sidebar-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.app-sidebar.collapsed .nav-link {
  justify-content: center;
}

.app-sidebar.collapsed .module-toggle {
  justify-content: center !important;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

.app-sidebar.collapsed .module-toggle .bi-chevron-down {
  display: none;
}

.app-sidebar.collapsed .module-submenu {
  display: none !important;
  border-left: 0;
  margin-left: 0;
  padding-left: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.app-sidebar.collapsed hr {
  margin: 0.5rem 0;
}

.app-sidebar.collapsed .dropdown {
  display: none;
}

/* Ajustar contenido cuando sidebar está colapsado */
body.sidebar-collapsed .flex-grow-1 {
  margin-left: 0;
}

/* Transición suave para textos */
.sidebar-text {
  transition: opacity 0.3s ease, width 0.3s ease;
}

.sidebar-brand-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: inline-block;
}

.app-sidebar.collapsed .sidebar-brand-link {
  width: 100%;
  justify-content: center;
  margin-right: 0 !important;
}

.app-sidebar.collapsed .sidebar-brand-icon {
  width: 36px;
  height: 36px;
  margin-right: 0 !important;
}

/* Módulos expandibles */
.sidebar-module {
  margin-bottom: 0.25rem;
}

.module-toggle {
  background: transparent;
  border: none;
  padding: 0.42rem 0.62rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.module-toggle:hover {
  background: rgba(13, 148, 136, 0.08);
  border-radius: 0.375rem;
}

.module-toggle.active {
  background: rgba(13, 148, 136, 0.14);
  color: var(--app-teal-dark);
  border-radius: 0.375rem;
}

.module-toggle i.bi-chevron-down {
  transition: transform 0.3s ease;
  font-size: 0.875rem;
}

.module-submenu {
  display: none;
  padding-left: 1.1rem;
  margin-top: 0.2rem;
  margin-bottom: 0.4rem;
  border-left: 2px solid rgba(13, 148, 136, 0.2);
  margin-left: 0.5rem;
}

.module-submenu .nav-link {
  padding: 0.34rem 0.6rem;
  font-size: 0.875rem;
}

.module-submenu .sidebar-module {
  margin-bottom: 0.125rem;
}

.module-submenu .module-toggle {
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
}

.module-submenu .module-submenu {
  padding-left: 1rem;
  margin-left: 0.5rem;
  border-left: 1px dashed rgba(13, 148, 136, 0.35);
}

.app-sidebar .nav-pills .nav-link {
  color: rgba(15, 23, 42, 0.85);
  padding: 0.4rem 0.62rem;
  font-size: 0.9rem;
}

.app-sidebar .nav-pills .nav-link:hover {
  background: rgba(13, 148, 136, 0.08);
}

.app-sidebar .nav-pills .nav-link.active {
  background: rgba(13, 148, 136, 0.14);
  color: var(--app-teal-dark);
}

.app-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 148, 136, 0.14);
  color: var(--app-teal-dark);
  border: 1px solid rgba(15, 118, 110, 0.25);
  font-weight: 600;
}

.app-avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
}

.app-auth-icon {
  font-size: 2.5rem;
}

.app-navbar {
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.app-badge {
  background: var(--app-cream);
  border: 1px solid rgba(15, 118, 110, 0.2);
  color: var(--app-teal-dark);
}

.btn-primary {
  --bs-btn-bg: var(--app-teal);
  --bs-btn-border-color: var(--app-teal);
  --bs-btn-hover-bg: var(--app-teal-dark);
  --bs-btn-hover-border-color: var(--app-teal-dark);
  --bs-btn-active-bg: var(--app-teal-dark);
  --bs-btn-active-border-color: var(--app-teal-dark);
}

.btn-outline-primary {
  --bs-btn-color: var(--app-teal-dark);
  --bs-btn-border-color: rgba(15, 118, 110, 0.35);
  --bs-btn-hover-bg: var(--app-teal);
  --bs-btn-hover-border-color: var(--app-teal);
}

.app-hero {
  background: linear-gradient(
    135deg,
    rgba(13, 148, 136, 0.10),
    rgba(255, 247, 237, 0.55)
  );
  border: 1px solid rgba(15, 118, 110, 0.18);
}

.app-card {
  border: 1px solid rgba(15, 118, 110, 0.12);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.04);
}

.raf-hero {
  padding: 1.5rem;
}

.raf-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.work-permit-actions {
  position: sticky;
  bottom: 0;
  z-index: 15;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), #ffffff 40%);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  padding-bottom: 0.25rem;
}

.work-permit-actions .btn {
  min-height: 2.65rem;
}

.raf-table-actions {
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.raf-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.raf-table-col-index {
  width: 6%;
}

.raf-table-col-response {
  width: 28%;
}

.raf-table-col-check {
  width: 8%;
}

.raf-table-col-comments {
  width: 22%;
}

.raf-choice-btn {
  min-height: 36px;
  min-width: 44px;
  padding: 0.35rem 0.45rem;
  font-size: 0.8rem;
  white-space: normal;
}

.dse-progress {
  height: 0.5rem;
  min-width: 180px;
}

.dse-progress-bar {
  width: 0%;
}

.mac-raf .card {
  border-radius: 1rem;
}

.mac-raf .card-body {
  padding: 1.25rem;
}

.mac-raf .badge {
  font-weight: 600;
}

.mac-raf .form-label {
  font-weight: 600;
}

.mac-raf .form-control,
.mac-raf .form-select {
  border-radius: 0.75rem;
  min-height: 44px;
}

.mac-raf textarea.form-control {
  min-height: 96px;
}

.mac-raf [id^="mac_"][id$="_matrix"] {
  overflow-x: auto;
  padding-bottom: 0.5rem;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.mac-raf .mac-grid {
  display: grid;
  width: max-content;
  min-width: 100%;
  max-width: 100%;
  grid-template-columns: var(--mac-label-width, 140px) repeat(var(--mac-cols, 5), minmax(var(--mac-cell-min, 48px), 1fr));
  gap: var(--mac-gap, 8px);
  font-size: 0.9rem;
}

.mac-raf .mac-grid-label {
  white-space: normal;
  line-height: 1.2;
}

.mac-raf .mac-grid > div {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.mac-raf .mac-grid > div.small {
  justify-content: flex-start;
  text-align: left;
  padding-left: 0.35rem;
}

.mac-raf [id^="mac_"][id$="_matrix"] table {
  min-width: 560px;
  width: max-content;
}

.mac-raf .border.rounded.p-3 {
  background: rgba(15, 118, 110, 0.04);
  border-color: rgba(15, 118, 110, 0.18);
}

.mac-raf .border.rounded.p-2 {
  background: #fff;
}

.mac-raf .mac-semaforo {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mac-raf .mac-semaforo .badge {
  font-size: 0.8rem;
}

.mac-raf .btn-check + .btn {
  white-space: normal;
  text-align: left;
  flex: 1 1 200px;
  min-height: 44px;
  padding: 0.6rem 0.9rem;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  border-radius: 0.75rem;
}

.mac-raf .btn-check + .btn {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 0.5rem;
}

.mac-raf .border.rounded.p-2 {
  padding: 0.75rem !important;
}

.mac-raf .fw-semibold {
  font-size: 0.95rem;
}

.mac-raf .btn-check + .btn .badge {
  min-width: 2.4rem;
  text-align: center;
}

.mac-raf .d-flex.flex-wrap.gap-2 {
  row-gap: 0.6rem;
}

.mac-raf .border.rounded.p-2 > .mt-2.d-flex,
.mac-raf .border.rounded.p-2 > .mt-2.d-flex.flex-wrap {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}

.mac-raf .mt-2.d-flex.flex-wrap.gap-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}

.mac-raf .border.rounded.p-2 > .mt-2.d-flex .btn,
.mac-raf .border.rounded.p-2 > .mt-2.d-flex.flex-wrap .btn {
  width: 100%;
}

.raf-header,
.fire-raf-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

#fireRafAccordion .accordion-header,
.raf-accordion .accordion-header {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fire-question > .d-flex {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fire-question {
  border: 1px solid rgba(15, 118, 110, 0.15);
  border-radius: 0.85rem;
  padding: 0.85rem;
  background: rgba(15, 118, 110, 0.04);
}

.fire-question .fw-semibold {
  font-size: 0.98rem;
}

.fire-question .btn-group {
  width: 100%;
}

.fire-question .btn-group .btn {
  min-height: 44px;
  white-space: normal;
  text-align: center;
  padding: 0.55rem 0.75rem;
}

.fire-question .fire-na-toggle {
  min-height: 40px;
}

.fire-question .btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fire-question .btn-group .btn {
  border-radius: 0.5rem !important;
}

.fire-question .row.g-2,
.fire-question .row.g-3 {
  --bs-gutter-x: 0.75rem;
  --bs-gutter-y: 0.75rem;
}

.fire-question .fire-noncompliance {
  margin-top: 0.75rem;
}

.chem-hero {
  padding: 1.5rem;
}

.chem-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.chem-table-actions {
  display: inline-flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 767.98px) {
  .raf-hero {
    padding: 1rem;
  }

  .raf-action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .raf-action-row .btn {
    width: 100%;
  }

  .work-permit-actions {
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }

  .work-permit-actions .btn {
    flex: 1 1 auto;
  }

  .raf-table-actions {
    display: grid;
    justify-items: stretch;
  }

  .raf-table-actions .btn,
  .raf-table-actions form {
    width: 100%;
  }

  .raf-toggle-group .btn {
    width: 100%;
  }

  .raf-choice-btn {
    min-height: 44px;
    font-size: 0.85rem;
    width: 100%;
  }

  .raf-header,
  .fire-raf-header {
    flex-direction: column;
    align-items: stretch;
  }

  .raf-header .text-end,
  .fire-raf-header .text-end {
    text-align: left !important;
  }

  .raf-progress,
  .fire-progress {
    width: 100%;
  }

  #fireRafAccordion .accordion-header .accordion-button,
  .raf-accordion .accordion-header .accordion-button {
    width: 100%;
  }

  #fireRafAccordion .fire-section-na-wrap,
  .raf-accordion .fire-section-na-wrap {
    width: 100%;
  }

  #fireRafAccordion .fire-section-na-wrap .form-check-label,
  .raf-accordion .fire-section-na-wrap .form-check-label {
    width: 100%;
  }

  #fireRafAccordion .accordion-body,
  .raf-accordion .accordion-body {
    padding: 0.75rem;
  }

  #fireRafAccordion .accordion-button,
  .raf-accordion .accordion-button {
    padding: 0.75rem 1rem;
  }

  .fire-question .row.g-2 > [class*="col-"],
  .fire-question .row.g-3 > [class*="col-"] {
    width: 100%;
  }

  .fire-question .fire-noncompliance {
    padding: 0.75rem;
  }

  .fire-question .fire-noncompliance .form-control,
  .fire-question .fire-noncompliance .form-select {
    width: 100%;
  }

  .fire-question .btn-group {
    width: 100%;
  }

  .fire-question .btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .fire-question .btn-group .btn {
    width: 100%;
  }

  .fire-question .fire-na-toggle {
    width: 100%;
  }

  .mac-raf .card-body {
    padding: 1rem;
  }

  .mac-raf .btn-check + .btn {
    width: 100%;
    font-size: 0.9rem;
  }

  .mac-raf .fw-semibold {
    font-size: 0.9rem;
  }

  .mac-raf .border.rounded.p-2 > .mt-2.d-flex,
  .mac-raf .border.rounded.p-2 > .mt-2.d-flex.flex-wrap {
    grid-template-columns: 1fr;
  }

  .mac-raf .mt-2.d-flex.flex-wrap.gap-2 {
    grid-template-columns: 1fr;
  }

  .mac-raf .badge {
    font-size: 0.85rem;
  }

  .mac-raf [id^="mac_"][id$="_matrix"] table {
    min-width: 520px;
  }

  .mac-raf .mac-grid {
    font-size: 0.8rem;
  }

  .mac-raf .mac-grid > div {
    min-height: 40px;
  }


  .fire-question .btn-group .btn {
    width: 100%;
  }

  .fire-question .fire-na-toggle {
    width: 100%;
  }

  .chem-hero {
    padding: 1rem;
  }

  .chem-action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .chem-action-row .btn,
  .chem-action-row .btn-group,
  .chem-action-row .btn-group .btn {
    width: 100%;
  }

  .chem-table-actions {
    display: grid;
    justify-items: stretch;
  }

  .chem-table-actions .btn,
  .chem-table-actions form {
    width: 100%;
  }
}

.form-signin {
  width: 100%;
  max-width: 330px;
  padding: 1rem;
  margin: auto;
}

.app-progress-bar {
  background-color: var(--app-teal);
}

.w-0 {
  width: 0% !important;
}

/* ========================================
   MODERN AUTH STYLES (Login/Signup)
   ======================================== */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 3rem 2.5rem;
  box-shadow: 
    0 20px 60px rgba(13, 148, 136, 0.08),
    0 4px 16px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.8);
  position: relative;
  z-index: 10;
  animation: fadeInUp 0.6s ease-out;
}

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

.auth-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.auth-icon-wrapper {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, var(--app-teal), var(--app-teal-dark));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(13, 148, 136, 0.25);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 10px 30px rgba(13, 148, 136, 0.25);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(13, 148, 136, 0.35);
  }
}

.auth-icon {
  font-size: 2.5rem;
  color: white;
}

.auth-title {
  font-size: 2rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 1rem;
  color: #64748b;
  margin: 0;
  font-weight: 400;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.auth-alert {
  padding: 1rem 1.25rem;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 12px;
  color: #dc2626;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  animation: shake 0.4s ease-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.auth-label i {
  font-size: 1rem;
  color: var(--app-teal);
}

.auth-input {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: white;
  transition: all 0.2s ease;
  outline: none;
}

.auth-input:focus {
  border-color: var(--app-teal);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.1);
  transform: translateY(-1px);
}

.auth-input::placeholder {
  color: #94a3b8;
}

.auth-button {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--app-teal), var(--app-teal-dark));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.25);
  margin-top: 0.5rem;
}

.auth-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.35);
}

.auth-button:active {
  transform: translateY(0);
}

.auth-button i {
  font-size: 1.25rem;
  transition: transform 0.3s ease;
}

.auth-button:hover i {
  transform: translateX(4px);
}

.auth-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #64748b;
}

.auth-link {
  color: var(--app-teal-dark);
  text-decoration: none;
  font-weight: 600;
  margin-left: 0.25rem;
  transition: color 0.2s ease;
}

.auth-link:hover {
  color: var(--app-teal);
  text-decoration: underline;
}

/* ========================================
   GLOBAL MATRIX CONSISTENCY
   ======================================== */

:root {
  --app-matrix-font-size: 0.9rem;
  --app-matrix-cell-py: 0.34rem;
  --app-matrix-cell-px: 0.42rem;
  --app-matrix-heading-weight: 600;
  --app-matrix-label-size: 0.7rem;
  --app-matrix-value-size: 1.1rem;
}

.table-responsive > .table > :not(caption) > * > * {
  padding: var(--app-matrix-cell-py) var(--app-matrix-cell-px);
  font-size: var(--app-matrix-font-size);
}

.table-responsive > .table > thead > tr > th {
  font-weight: var(--app-matrix-heading-weight);
  letter-spacing: 0.01em;
}

.table-responsive > .table td,
.table-responsive > .table th {
  vertical-align: middle;
}

/* Normalize KPI/matrix cards across modules */
[class*="kpi-card"] {
  border-radius: 0.78rem;
  padding: 0.58rem 0.72rem;
  min-height: 60px;
}

[class*="kpi-card"] .kpi-label {
  font-size: var(--app-matrix-label-size);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

[class*="kpi-card"] .kpi-value {
  font-size: var(--app-matrix-value-size);
  font-weight: 700;
  line-height: 1;
}

[class*="kpi-card"] .la-icon-wrap {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

[class*="kpi-card"] .la-icon,
[class*="kpi-card"] .lucide {
  width: 16px;
  height: 16px;
}

/* ========================================
   GLOBAL MOBILE HARDENING
   ======================================== */

@media (max-width: 768px) {
  .btn.btn-sm {
    min-height: 40px;
  }

  .form-control,
  .form-select,
  .form-check-input {
    min-height: 42px;
  }

  .table-responsive > .table {
    min-width: 640px;
    font-size: 0.9rem;
  }

  .table-responsive th,
  .table-responsive td {
    white-space: nowrap;
    vertical-align: middle;
  }

  .table-responsive th[style*="width"],
  .table-responsive td[style*="width"] {
    width: auto !important;
    min-width: 110px;
  }

  .table-responsive th.text-center[style*="width"],
  .table-responsive td.text-center[style*="width"] {
    min-width: 96px;
  }
}

/* Decorative elements */
.auth-decoration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.decoration-circle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.15), transparent 70%);
  filter: blur(40px);
  animation: float 20s ease-in-out infinite;
}

.decoration-circle-1 {
  width: 500px;
  height: 500px;
  top: -250px;
  right: -250px;
  animation-delay: 0s;
}

.decoration-circle-2 {
  width: 400px;
  height: 400px;
  bottom: -200px;
  left: -200px;
  animation-delay: 7s;
}

.decoration-circle-3 {
  width: 300px;
  height: 300px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: 14s;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(30px, -30px) scale(1.1);
  }
  66% {
    transform: translate(-30px, 30px) scale(0.9);
  }
}

/* ========================================
   RESPONSIVE STYLES - MOBILE FIRST
   ======================================== */

/* Base responsive adjustments */
@media (max-width: 1200px) {
  .app-sidebar {
    width: 240px;
  }
}

/* Tablet (768px - 991px) */
@media (max-width: 991px) {
  .main-dashboard {
    padding: 1.5rem;
  }

  .tenants-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }

  .modules-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .sidebar-panel-sticky {
    position: static;
    top: auto;
  }

  .sidebar-panel-scroll {
    max-height: none;
    overflow: visible;
  }
}

/* Tablet Portrait & Mobile Landscape (576px - 768px) */
@media (max-width: 768px) {
  /* Sidebar collapse */
  .app-sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    z-index: 1030;
    transition: left 0.3s ease;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    width: 86vw;
    max-width: 320px;
  }

  .app-sidebar-main {
    margin-top: 0.25rem;
  }

  .app-sidebar.show {
    left: 0 !important;
  }

  body:not(.sidebar-open) .app-sidebar.show {
    left: -100% !important;
  }

  /* Mobile backdrop */
  body.sidebar-open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1029;
    animation: fadeIn 0.3s ease;
  }

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

  body.sidebar-open {
    overflow: hidden;
  }

  /* Dashboard adjustments */
  .main-dashboard {
    padding: 1rem;
  }

  .dashboard-hero {
    padding: 1.5rem;
    flex-direction: column;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-actions {
    width: 100%;
  }

  .btn-hero {
    flex: 1;
  }

  .tenants-grid,
  .modules-grid {
    grid-template-columns: 1fr;
  }

  .section-title {
    font-size: 1.25rem;
  }

  /* Auth form grid */
  .auth-form-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .password-requirements {
    position: static;
    order: -1;
  }


  .welcome-features {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Mobile (< 576px) */
@media (max-width: 576px) {
  /* Container spacing */
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Auth pages */
  .auth-container {
    padding: 1rem;
  }

  .auth-card {
    padding: 2rem 1.5rem;
    border-radius: 20px;
  }
  
  .auth-title {
    font-size: 1.75rem;
  }

  .auth-subtitle {
    font-size: 0.9375rem;
  }
  
  .auth-icon-wrapper {
    width: 70px;
    height: 70px;
  }
  
  .auth-icon {
    font-size: 2rem;
  }

  .auth-card-wide {
    max-width: 100%;
  }

  .auth-input {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
  }

  .auth-button {
    padding: 0.875rem 1.25rem;
    font-size: 0.9375rem;
  }

  .auth-label {
    font-size: 0.8125rem;
  }

  /* Password requirements */
  .password-requirements {
    padding: 1.25rem;
  }

  .requirements-title {
    font-size: 0.9375rem;
  }

  .requirement-item {
    font-size: 0.8125rem;
  }

  /* Welcome page */
  .welcome-features {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .feature-item {
    padding: 0.75rem;
  }

  .welcome-subtitle {
    font-size: 1.25rem;
  }

  /* Dashboard */
  .main-dashboard {
    padding: 1rem 0.5rem;
  }

  .dashboard-hero {
    padding: 1.25rem;
    border-radius: 16px;
  }

  .hero-badge {
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .btn-hero {
    padding: 0.875rem 1.25rem;
    font-size: 0.9375rem;
  }

  .btn-hero i {
    font-size: 1.125rem;
  }

  /* Tenant cards */
  .tenant-card {
    padding: 1.25rem;
  }

  .tenant-icon {
    width: 40px;
    height: 40px;
  }

  .tenant-icon i {
    font-size: 1.25rem;
  }

  .tenant-name {
    font-size: 1rem;
  }

  .tenant-slug {
    font-size: 0.8125rem;
  }

  .tenant-action {
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
  }

  /* Module cards */
  .module-card {
    padding: 1.5rem;
  }

  .module-icon {
    width: 56px;
    height: 56px;
  }

  .module-icon i {
    font-size: 1.75rem;
  }

  .module-name {
    font-size: 1.125rem;
  }

  .module-description {
    font-size: 0.8125rem;
  }

  .module-link {
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
  }

  /* Section adjustments */
  .section-title {
    font-size: 1.125rem;
  }

  .section-title i {
    font-size: 1.5rem;
  }

  .section-tip {
    padding: 0.875rem;
    font-size: 0.8125rem;
  }

  /* Decorative circles - reduce size on mobile */
  .decoration-circle-1 {
    width: 300px;
    height: 300px;
  }

  .decoration-circle-2 {
    width: 250px;
    height: 250px;
  }

  .decoration-circle-3 {
    width: 200px;
    height: 200px;
  }
}

/* Extra small devices (< 375px) */
@media (max-width: 374px) {
  .auth-card {
    padding: 1.5rem 1rem;
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .btn-hero {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .tenant-card,
  .module-card {
    padding: 1rem;
  }

  .hero-actions {
    flex-direction: column;
  }

  .btn-hero {
    width: 100%;
  }
}

/* Landscape mobile devices */
@media (max-height: 600px) and (orientation: landscape) {
  .auth-container {
    padding: 1rem;
    min-height: auto;
  }

  .auth-icon-wrapper {
    width: 60px;
    height: 60px;
    margin-bottom: 1rem;
  }

  .auth-icon {
    font-size: 1.75rem;
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .auth-card {
    padding: 1.5rem;
  }

  .password-requirements {
    position: static;
  }

  .dashboard-hero {
    padding: 1rem;
  }
}

/* Large screens optimization */
@media (min-width: 1400px) {
  .main-dashboard {
    max-width: 1600px;
  }

  .tenants-grid {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  }

  .modules-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Print styles */
@media print {
  .app-sidebar,
  .app-topbar,
  .hero-actions,
  .btn,
  button {
    display: none !important;
  }

  .main-dashboard {
    max-width: 100%;
    padding: 0;
  }

  .auth-decoration,
  .decoration-circle {
    display: none !important;
  }
}


/* ========================================
   PASSWORD REQUIREMENTS SIDEBAR
   ======================================== */

.auth-card-wide {
  max-width: 900px;
}

.auth-form-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 3rem;
  align-items: start;
}

.auth-form-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.password-requirements {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.04), rgba(13, 148, 136, 0.08));
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 16px;
  padding: 1.5rem;
  position: sticky;
  top: 2rem;
}

.requirements-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.requirements-title i {
  color: var(--app-teal);
  font-size: 1.25rem;
}

.requirements-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.requirement-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: #64748b;
  transition: all 0.3s ease;
}

.requirement-item i {
  font-size: 1rem;
  color: #cbd5e1;
  transition: all 0.3s ease;
}

.requirement-item.valid {
  color: #059669;
}

.requirement-item.valid i {
  color: #059669;
}

.requirement-item.valid i::before {
  content: "\f26b";
  font-family: "bootstrap-icons";
}

.requirement-item i {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.requirement-item.valid i {
  background: rgba(5, 150, 105, 0.1);
}

.requirements-note {
  padding: 0.75rem;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 0.8rem;
  color: #475569;
  display: flex;
  align-items: start;
  gap: 0.5rem;
}

.requirements-note i {
  color: #3b82f6;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

@media (max-width: 768px) {
  .auth-form-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .password-requirements {
    position: static;
    order: -1;
  }
}

/* ========================================
   WELCOME PAGE STYLES
   ======================================== */

.welcome-message {
  text-align: center;
  padding: 2rem 0;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(99, 102, 241, 0.1));
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.welcome-icon i {
  font-size: 2.5rem;
  color: #3b82f6;
}

.welcome-subtitle {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 1rem;
}

.welcome-text {
  font-size: 1rem;
  color: #64748b;
  line-height: 1.6;
  margin: 0;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(13, 148, 136, 0.04);
  border: 1px solid rgba(13, 148, 136, 0.1);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.feature-item:hover {
  background: rgba(13, 148, 136, 0.08);
  border-color: rgba(13, 148, 136, 0.2);
  transition: border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.feature-item i {
  font-size: 1.5rem;
  color: var(--app-teal);
}

.feature-item span {
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
}

@media (max-width: 576px) {
  .welcome-features {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   MAIN DASHBOARD STYLES
   ======================================== */

.main-dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Hero Section */
.dashboard-hero {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.08), rgba(255, 255, 255, 0.9));
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 14px;
  padding: 0.76rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.56rem;
  flex-wrap: wrap;
}

.hero-content {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 0.4rem;
  row-gap: 0.16rem;
  min-width: 240px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0;
  grid-column: 1;
  grid-row: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.24rem 0.54rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  color: #3b82f6;
}

.hero-badge-env {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.hero-badge-superuser {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.hero-badge-staff {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.hero-badge-user {
  background: rgba(13, 148, 136, 0.1);
  border-color: rgba(13, 148, 136, 0.2);
  color: #0d9488;
}

.hero-badge i {
  font-size: 0.86rem;
}

.hero-title {
  grid-column: 2;
  grid-row: 1;
  font-size: 1.34rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero-subtitle {
  grid-column: 1 / -1;
  grid-row: 2;
  font-size: 0.78rem;
  color: #64748b;
  margin: 0;
}

.hero-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn-hero {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.72rem 1.05rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  transition: all 0.3s ease;
  border: none;
}

.btn-hero i {
  font-size: 1rem;
}

.btn-hero-primary {
  background: linear-gradient(135deg, var(--app-teal), var(--app-teal-dark));
  color: white;
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.25);
}

.btn-hero-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.35);
  color: white;
}

.btn-hero-secondary {
  background: white;
  color: var(--app-teal-dark);
  border: 2px solid rgba(13, 148, 136, 0.2);
}

.btn-hero-secondary:hover {
  background: rgba(13, 148, 136, 0.05);
  border-color: var(--app-teal);
  transform: translateY(-2px);
  color: var(--app-teal-dark);
}

/* Dashboard Sections */
.dashboard-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section-toggle-btn {
  margin-left: 0.35rem;
  width: 30px;
  height: 30px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #ffffff;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.section-toggle-btn:hover {
  border-color: rgba(13, 148, 136, 0.45);
  color: var(--app-teal-dark);
  background: rgba(240, 253, 250, 0.95);
}

.section-toggle-btn i {
  font-size: 0.78rem;
  transition: transform 0.2s ease;
}

#modules-dashboard-section.is-collapsed .section-toggle-btn i {
  transform: rotate(180deg);
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.section-title i {
  color: var(--app-teal);
  font-size: 1.08rem;
}

.ascii-brand-section {
  margin-top: 0.2rem;
}

.ascii-cube-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  height: clamp(240px, 30vw, 360px);
  max-height: 360px;
  padding: 0.6rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.15), transparent 42%),
    radial-gradient(circle at 80% 80%, rgba(56, 189, 248, 0.12), transparent 38%),
    linear-gradient(145deg, #030617 0%, #020b22 55%, #03122f 100%);
}

.ascii-cube-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(148, 163, 184, 0.2) 1px, transparent 1px);
  background-size: 14px 14px;
  opacity: 0.35;
}

.ascii-cube {
  display: none;
}

.ascii-cube-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.ascii-cube-controls {
  position: absolute;
  top: auto;
  left: auto;
  bottom: 0.8rem;
  right: 0.85rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ascii-cube-btn {
  border: 1px solid rgba(148, 163, 184, 0.38);
  background: rgba(2, 6, 23, 0.72);
  color: rgba(226, 232, 240, 0.95);
  border-radius: 8px;
  padding: 0.32rem 0.52rem;
  font-size: 0.76rem;
  line-height: 1;
  min-width: 30px;
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.ascii-cube-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(125, 211, 252, 0.6);
  background: rgba(8, 21, 46, 0.88);
}

.ascii-cube-btn:active {
  transform: translateY(0);
}

.ascii-cube-speed-control {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(2, 6, 23, 0.68);
  border-radius: 10px;
  padding: 0.18rem 0.4rem;
}

#ascii-cube-speed {
  width: 92px;
  accent-color: #7dd3fc;
  cursor: pointer;
}

.ascii-cube-speed-value {
  display: inline-block;
  min-width: 42px;
  text-align: right;
  font-size: 0.68rem;
  color: rgba(226, 232, 240, 0.94);
  letter-spacing: 0.01em;
}

.quick-tools-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.76rem;
  display: block;
}

.quick-tools-zone {
  position: relative;
  border: 1px dashed rgba(13, 148, 136, 0.25);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.75);
  padding: 0.62rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 88px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.quick-tools-zone.is-over {
  border-color: rgba(13, 148, 136, 0.78);
  background: linear-gradient(135deg, rgba(240, 253, 250, 0.95), rgba(236, 253, 245, 0.95));
  box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.28);
}

.quick-tools-zone.is-snap-grid-active {
  background-image:
    linear-gradient(to right, rgba(13, 148, 136, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(13, 148, 136, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, rgba(240, 253, 250, 0.98), rgba(236, 253, 245, 0.98));
  background-size: 24px 24px, 24px 24px, 100% 100%;
  border-style: solid;
}

.quick-tools-zone.has-placeholder-target::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  border-top: 2px dashed rgba(13, 148, 136, 0.75);
  pointer-events: none;
  animation: quickTargetDashPulse 0.9s ease-in-out infinite;
}

.quick-tools-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.quick-tools-heading {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
}

.quick-tools-meta {
  font-size: 0.64rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.quick-tools-empty {
  display: none;
  font-size: 0.72rem;
  color: #64748b;
}

.quick-tools-dropzone.is-empty .quick-tools-empty {
  display: block;
}

.quick-tools-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.58rem;
  align-items: stretch;
  position: relative;
}

.quick-tools-zone.is-drop-hints-active .quick-tools-items::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 10px;
  border: 1px dashed rgba(13, 148, 136, 0.24);
  background:
    radial-gradient(circle, rgba(13, 148, 136, 0.12) 1.1px, transparent 1.2px) 0 0 / 16px 16px,
    linear-gradient(135deg, rgba(240, 253, 250, 0.45), rgba(236, 253, 245, 0.2));
  opacity: 0.8;
  animation: quickDropGridPulse 1.1s ease-in-out infinite;
}

.quick-tools-items.is-live-reordering .quick-access-card:not(.is-dragging) {
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 180ms ease, border-color 180ms ease;
}

.quick-access-card {
  position: relative;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  cursor: grab;
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.26s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease, opacity 0.2s ease;
  animation: quickAccessFadeIn 0.32s ease;
  will-change: transform;
}

.quick-tools-zone.is-drop-hints-active .quick-access-card:not(.is-dragging)::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 9px;
  border: 1px dashed rgba(13, 148, 136, 0.5);
  opacity: 0.52;
  pointer-events: none;
  animation: quickDropSlotBlink 0.95s ease-in-out infinite;
}

.quick-access-placeholder {
  height: 64px;
  border-radius: 12px;
  border: 2px dashed rgba(13, 148, 136, 0.6);
  background: linear-gradient(135deg, rgba(204, 251, 241, 0.62), rgba(240, 253, 250, 0.92));
  box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.15);
  animation: quickPlaceholderPulse 1s ease-in-out infinite;
}

.quick-access-card:active {
  cursor: grabbing;
}

.quick-access-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--quick-access-accent, linear-gradient(90deg, #0d9488, #0f766e));
  opacity: 0;
  transition: opacity 0.24s ease;
}

.quick-access-card:hover {
  transform: translateY(-2px);
  border-color: rgba(13, 148, 136, 0.45);
  box-shadow: 0 12px 32px rgba(13, 148, 136, 0.16);
}

.quick-access-card:hover::before {
  opacity: 1;
}

.quick-access-card.is-dragging {
  opacity: 0.72;
  transform: scale(0.985);
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.18);
}

.quick-access-card.quick-access-drop-before {
  box-shadow: inset 4px 0 0 rgba(13, 148, 136, 0.82), 0 8px 18px rgba(13, 148, 136, 0.16);
  transform: translateX(2px);
}

.quick-access-card.quick-access-drop-after {
  box-shadow: inset -4px 0 0 rgba(13, 148, 136, 0.82), 0 8px 18px rgba(13, 148, 136, 0.16);
  transform: translateX(-2px);
}

.quick-access-card.is-preview-target {
  border-color: rgba(13, 148, 136, 0.55);
  box-shadow: 0 10px 24px rgba(13, 148, 136, 0.2);
}

.quick-access-card.quick-access-drop-before::after,
.quick-access-card.quick-access-drop-after::after {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: rgba(13, 148, 136, 0.9);
  border-radius: 999px;
  animation: quickDropHintPulse 0.9s ease-in-out infinite;
}

.quick-access-card.quick-access-drop-before::after {
  left: 2px;
}

.quick-access-card.quick-access-drop-after::after {
  right: 2px;
}

.quick-access-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.58rem;
  align-items: center;
  text-decoration: none;
  padding: 0.64rem 0.68rem;
  color: inherit;
}

.quick-access-handle {
  width: 18px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #4c5d74;
  opacity: 0.9;
  cursor: grab;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.quick-access-handle i {
  font-size: 0.95rem;
}

.quick-access-card:hover .quick-access-handle {
  background: rgba(13, 148, 136, 0.12);
  color: #0f766e;
}

.quick-access-card:active .quick-access-handle,
.quick-access-card.is-dragging .quick-access-handle {
  cursor: grabbing;
  transform: scale(0.96);
}

.quick-access-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--quick-access-icon-bg, linear-gradient(135deg, rgba(13, 148, 136, 0.14), rgba(13, 148, 136, 0.26)));
  color: var(--quick-access-icon-color, #0f766e);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.24s ease;
  will-change: transform;
}

.quick-access-icon i,
.quick-access-icon svg,
.quick-access-icon .la-icon-wrap,
.quick-access-icon .la-icon {
  display: inline-block;
  font-size: 1rem;
  color: currentColor;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.quick-access-card:hover .quick-access-icon {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 8px 18px rgba(13, 148, 136, 0.24);
}

.quick-access-link:hover .quick-access-icon,
.quick-access-link:focus-visible .quick-access-icon {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 8px 18px rgba(13, 148, 136, 0.24);
}

.quick-access-card:hover .quick-access-icon i,
.quick-access-card:hover .quick-access-icon svg,
.quick-access-card:hover .quick-access-icon .la-icon-wrap,
.quick-access-card:hover .quick-access-icon .la-icon {
  transform: translateY(-1px);
}

.quick-access-link:hover .quick-access-icon i,
.quick-access-link:hover .quick-access-icon svg,
.quick-access-link:hover .quick-access-icon .la-icon-wrap,
.quick-access-link:hover .quick-access-icon .la-icon,
.quick-access-link:focus-visible .quick-access-icon i,
.quick-access-link:focus-visible .quick-access-icon svg,
.quick-access-link:focus-visible .quick-access-icon .la-icon-wrap,
.quick-access-link:focus-visible .quick-access-icon .la-icon {
  transform: translateY(-1px);
}

/* Progressive enhancement: apply hover state even if parent card hover does not propagate as expected. */
@supports selector(.quick-access-card:has(.quick-access-link:hover)) {
  .quick-access-card:has(.quick-access-link:hover) .quick-access-icon,
  .quick-access-card:has(.quick-access-link:focus-visible) .quick-access-icon {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 8px 18px rgba(13, 148, 136, 0.24);
  }

  .quick-access-card:has(.quick-access-link:hover) .quick-access-icon i,
  .quick-access-card:has(.quick-access-link:hover) .quick-access-icon svg,
  .quick-access-card:has(.quick-access-link:hover) .quick-access-icon .la-icon-wrap,
  .quick-access-card:has(.quick-access-link:hover) .quick-access-icon .la-icon,
  .quick-access-card:has(.quick-access-link:focus-visible) .quick-access-icon i,
  .quick-access-card:has(.quick-access-link:focus-visible) .quick-access-icon svg,
  .quick-access-card:has(.quick-access-link:focus-visible) .quick-access-icon .la-icon-wrap,
  .quick-access-card:has(.quick-access-link:focus-visible) .quick-access-icon .la-icon {
    transform: translateY(-1px);
  }
}

.quick-access-icon svg {
  stroke: currentColor;
}

.quick-access-body {
  min-width: 0;
}

.quick-access-module {
  margin: 0 !important;
  font-size: 0.66rem;
  font-weight: 400;
  color: #64748b;
  line-height: 1.1;
  letter-spacing: 0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.quick-access-title {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.1;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.quick-access-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.66rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quick-access-remove {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.9);
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.quick-access-card:hover .quick-access-remove,
.quick-access-card:focus-within .quick-access-remove {
  opacity: 1;
}

.quick-access-remove:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  transform: scale(1.05);
}

.quick-access-card-default {
  --quick-access-accent: linear-gradient(90deg, #0d9488, #0f766e);
}

.quick-access-card-safety {
  --quick-access-accent: linear-gradient(90deg, #0d9488, #0f766e);
}

.quick-access-card-health {
  --quick-access-accent: linear-gradient(90deg, #ef4444, #dc2626);
  --quick-access-icon-bg: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(220, 38, 38, 0.24));
  --quick-access-icon-color: #dc2626;
}

.quick-access-card-environment {
  --quick-access-accent: linear-gradient(90deg, #16a34a, #15803d);
  --quick-access-icon-bg: linear-gradient(135deg, rgba(22, 163, 74, 0.14), rgba(21, 128, 61, 0.25));
  --quick-access-icon-color: #15803d;
}

.quick-access-card-hr {
  --quick-access-accent: linear-gradient(90deg, #f59e0b, #d97706);
  --quick-access-icon-bg: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(217, 119, 6, 0.24));
  --quick-access-icon-color: #d97706;
}

.quick-access-card-maintenance {
  --quick-access-accent: linear-gradient(90deg, #6366f1, #4f46e5);
  --quick-access-icon-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(79, 70, 229, 0.24));
  --quick-access-icon-color: #4f46e5;
}

.quick-access-card-sustainability {
  --quick-access-accent: linear-gradient(90deg, #22c55e, #16a34a);
  --quick-access-icon-bg: linear-gradient(135deg, rgba(34, 197, 94, 0.14), rgba(22, 163, 74, 0.24));
  --quick-access-icon-color: #15803d;
}

.quick-access-card-quality {
  --quick-access-accent: linear-gradient(90deg, #3b82f6, #2563eb);
  --quick-access-icon-bg: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(37, 99, 235, 0.24));
  --quick-access-icon-color: #2563eb;
}

.quick-access-card-asset {
  --quick-access-accent: linear-gradient(90deg, #8b5cf6, #7c3aed);
  --quick-access-icon-bg: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(124, 58, 237, 0.24));
  --quick-access-icon-color: #7c3aed;
}

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

#sidebar a.nav-link[draggable="true"].is-dragging {
  opacity: 0.65;
}

body.qa-dragging-sidebar .quick-tools-card,
body.qa-dragging-quickaccess .quick-tools-card {
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

body.qa-dragging-sidebar .quick-tools-card {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(13, 148, 136, 0.12);
}

body.qa-dragging-sidebar .quick-tools-items .quick-access-card,
body.qa-dragging-sidebar .quick-tools-items .quick-access-link,
body.qa-dragging-sidebar .quick-tools-items .quick-access-remove {
  pointer-events: none;
}

body.qa-dragging-quickaccess .quick-tools-card {
  box-shadow: 0 8px 18px rgba(13, 148, 136, 0.1);
}

body.qa-dragging-sidebar .quick-access-card:not(.is-dragging),
body.qa-dragging-quickaccess .quick-access-card:not(.is-dragging) {
  animation: quickCardWiggle 0.52s ease-in-out infinite;
}

@keyframes quickDropHintPulse {
  0% {
    opacity: 0.35;
    transform: scaleY(0.94);
  }
  50% {
    opacity: 1;
    transform: scaleY(1);
  }
  100% {
    opacity: 0.35;
    transform: scaleY(0.94);
  }
}

@keyframes quickDropGridPulse {
  0% {
    opacity: 0.52;
  }
  50% {
    opacity: 0.92;
  }
  100% {
    opacity: 0.52;
  }
}

@keyframes quickDropSlotBlink {
  0% {
    opacity: 0.24;
    transform: scale(0.998);
  }
  50% {
    opacity: 0.62;
    transform: scale(1);
  }
  100% {
    opacity: 0.24;
    transform: scale(0.998);
  }
}

@keyframes quickCardWiggle {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-1px) rotate(-0.8deg);
  }
  50% {
    transform: translateY(0) rotate(0deg);
  }
  75% {
    transform: translateY(1px) rotate(0.8deg);
  }
  100% {
    transform: translateY(0) rotate(0deg);
  }
}

@keyframes quickPlaceholderPulse {
  0% {
    opacity: 0.7;
    transform: scale(0.985);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0.7;
    transform: scale(0.985);
  }
}

@keyframes quickTargetDashPulse {
  0% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.65;
  }
}

@media (prefers-reduced-motion: reduce) {
  .quick-tools-zone,
  .quick-access-card,
  .quick-access-card::before,
  .quick-access-remove,
  .quick-access-placeholder,
  .quick-tools-zone.has-placeholder-target::after,
  .quick-access-card.quick-access-drop-before::after,
  .quick-access-card.quick-access-drop-after::after,
  .quick-tools-card {
    transition: none !important;
    animation: none !important;
  }
}

.section-badge {
  padding: 0.25rem 0.75rem;
  background: rgba(13, 148, 136, 0.1);
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--app-teal-dark);
}

.section-tip {
  display: flex;
  align-items: start;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 12px;
  font-size: 0.875rem;
  color: #475569;
}

.section-tip i {
  color: #3b82f6;
  font-size: 1.125rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.section-tip code {
  background: rgba(59, 130, 246, 0.1);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.8125rem;
}

/* Tenants Grid */
.tenants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
}

.tenant-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.3s ease;
}

.tenant-card:hover {
  border-color: var(--app-teal);
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.1);
  transform: translateY(-2px);
}

.tenant-header {
  display: flex;
  align-items: start;
  gap: 1rem;
}

.tenant-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.1), rgba(13, 148, 136, 0.15));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tenant-icon i {
  font-size: 1.5rem;
  color: var(--app-teal);
}

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

.tenant-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 0.25rem;
}

.tenant-slug {
  display: inline-block;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Courier New', monospace;
  font-size: 0.875rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 0.125rem 0.5rem;
  border-radius: 6px;
}

.tenant-status {
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.status-active {
  background: rgba(5, 150, 105, 0.1);
  color: #059669;
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.status-inactive {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
  border: 1px solid rgba(107, 114, 128, 0.2);
}

.tenant-body {
  padding: 0.75rem 0;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.tenant-subscription {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #475569;
}

.tenant-subscription i {
  color: var(--app-teal);
  font-size: 1rem;
}

.tenant-subscription code {
  background: rgba(13, 148, 136, 0.08);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: var(--app-teal-dark);
}

.tenant-no-sub {
  color: #94a3b8;
}

.tenant-no-sub i {
  color: #f59e0b;
}

.tenant-footer {
  display: flex;
  gap: 0.75rem;
}

.tenant-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(13, 148, 136, 0.05);
  border: 1px solid rgba(13, 148, 136, 0.15);
  border-radius: 10px;
  color: var(--app-teal-dark);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.tenant-action:hover {
  background: rgba(13, 148, 136, 0.1);
  border-color: var(--app-teal);
  color: var(--app-teal-dark);
}

.tenant-action i:first-child {
  font-size: 1rem;
}

.tenant-action i:last-child {
  font-size: 0.875rem;
}

/* Modules Grid */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.62rem;
}

.module-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.78rem;
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: start;
  gap: 0.36rem 0.5rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--app-teal), var(--app-teal-dark));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.module-card:hover::before {
  opacity: 1;
}

.module-card:hover {
  border-color: var(--app-teal);
  box-shadow: 0 14px 34px rgba(13, 148, 136, 0.18);
  transform: translateY(-4px);
}

.module-card-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.module-card-disabled:hover {
  transform: none;
  box-shadow: none;
  border-color: #e2e8f0;
}

.module-icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: #ffffff;
  transition: transform 0.2s ease;
}

.module-card:hover .module-icon {
  transform: translateY(-1px) scale(1.04);
}

/* Progressive enhancement only where :has() is supported. */
@supports selector(.module-card:has(.module-link:hover)) {
  .module-card:has(.module-link:hover)::before,
  .module-card:has(.module-link:focus-visible)::before {
    opacity: 1;
  }

  .module-card:has(.module-link:hover),
  .module-card:has(.module-link:focus-visible) {
    border-color: var(--app-teal);
    box-shadow: 0 14px 34px rgba(13, 148, 136, 0.18);
    transform: translateY(-4px);
  }

  .module-card:has(.module-link:hover) .module-icon,
  .module-card:has(.module-link:focus-visible) .module-icon {
    transform: translateY(-1px) scale(1.04);
  }
}

.module-icon i,
.module-icon svg,
.module-icon .la-icon-wrap,
.module-icon .la-icon {
  font-size: 1.04rem;
  color: currentColor;
}

.module-icon svg {
  stroke: currentColor;
}

.module-icon-safety {
  background: linear-gradient(135deg, #10b981, #059669);
}

.module-icon-accounts {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.module-icon-quality {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
}

.module-icon-hr {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.module-icon-asset {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.module-icon-environment {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.module-icon-health {
  background: linear-gradient(135deg, #ec4899, #db2777);
}

.module-icon-warehouse {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.module-icon-maintenance {
  background: linear-gradient(135deg, #64748b, #475569);
}

.module-icon-sustainability {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.module-icon-sheq {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.module-icon-audit {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.module-icon-actions {
  background: linear-gradient(135deg, #eab308, #ca8a04);
}

.module-icon-notifications {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.module-icon-billing {
  background: linear-gradient(135deg, #a855f7, #9333ea);
}

.module-icon-rbac {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
}

.module-icon-tenants {
  background: linear-gradient(135deg, #0d9488, #0f766e);
}

.module-name {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.module-description {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.7rem;
  color: #64748b;
  line-height: 1.3;
  margin: 0;
}

.module-tags {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}

.module-tag {
  padding: 0.14rem 0.4rem;
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.15);
  border-radius: 20px;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--app-teal-dark);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.module-link {
  position: absolute;
  inset: 0;
  z-index: 5;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  background: transparent;
  text-decoration: none;
  color: transparent;
  display: block;
}

.module-link span,
.module-link i {
  display: none;
}

/* Keep the Lucide arrow visible and animate it on hover/focus. */
.module-link .la-icon-wrap {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  color: var(--app-teal-dark);
  opacity: 0.9;
  transition: transform 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}

.module-link .la-icon,
.module-link .la-icon svg {
  color: currentColor;
  stroke: currentColor;
}

.module-card:hover .module-link .la-icon-wrap,
.module-link:hover .la-icon-wrap,
.module-link:focus-visible .la-icon-wrap {
  transform: translateX(4px);
  opacity: 1;
  color: var(--app-teal);
}

.module-link:focus-visible {
  outline: 2px solid rgba(13, 148, 136, 0.5);
  outline-offset: 2px;
}

.module-card > *:not(.module-link) {
  position: relative;
  z-index: 1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  background: rgba(248, 250, 252, 0.5);
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
}

.empty-state i {
  font-size: 3rem;
  color: #cbd5e1;
  margin-bottom: 1rem;
}

.empty-state p {
  font-size: 1rem;
  color: #94a3b8;
  margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .main-dashboard {
    padding: 0.5rem;
    gap: 0.6rem;
  }

  .dashboard-hero {
    padding: 0.56rem 0.62rem;
    gap: 0.4rem;
  }

  .hero-content {
    min-width: 0;
    grid-template-columns: 1fr;
    row-gap: 0.2rem;
  }

  .hero-badges {
    grid-column: 1;
    grid-row: 1;
  }

  .hero-title {
    grid-column: 1;
    grid-row: 2;
    font-size: 1.04rem;
  }

  .hero-subtitle {
    grid-column: 1;
    grid-row: 3;
    font-size: 0.68rem;
  }

  .hero-badge {
    font-size: 0.58rem;
    padding: 0.16rem 0.38rem;
  }

  .quick-tools-card {
    padding: 0.62rem;
  }

  .quick-tools-zone {
    min-height: auto;
    padding: 0.5rem;
  }

  .quick-tools-items {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .quick-access-link {
    padding: 0.58rem 0.6rem;
    gap: 0.48rem;
  }

  .quick-access-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .quick-access-icon i {
    font-size: 0.9rem;
  }

  .quick-access-title {
    font-size: 0.7rem;
  }

  .quick-access-module {
    font-size: 0.6rem;
  }

  .quick-access-subtitle {
    font-size: 0.6rem;
  }

  .btn-hero {
    padding: 0.52rem 0.72rem;
    font-size: 0.72rem;
    gap: 0.42rem;
  }

  .btn-hero i {
    font-size: 0.82rem;
  }

  .tenants-grid,
  .modules-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .module-card {
    padding: 0.6rem;
    gap: 0.34rem;
    border-radius: 10px;
  }

  .module-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .module-icon i {
    font-size: 0.92rem;
  }

  .module-name {
    font-size: 0.8rem;
  }

  .module-description {
    font-size: 0.66rem;
    line-height: 1.28;
  }

  .module-tag {
    font-size: 0.56rem;
    padding: 0.12rem 0.34rem;
  }

  .module-link {
    border-radius: 10px;
  }
}

@media (min-width: 769px) and (max-width: 1200px) {
  .modules-grid {
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    gap: 0.58rem;
  }

  .module-card {
    padding: 0.72rem;
  }
}

/* Risk Assessment Colors - 5x5 Matrix */
.bg-orange {
  background-color: #fd7e14 !important;
  color: white !important;
}

.badge.bg-orange {
  background-color: #fd7e14 !important;
  color: white !important;
}

/* ========================================
   GLOBAL COMPACT MOBILE MODE
   ======================================== */

@media (max-width: 768px) {
  html {
    font-size: 15.5px;
  }

  body {
    line-height: 1.35;
  }

  h1,
  .h1 {
    font-size: 1.55rem;
  }

  h2,
  .h2 {
    font-size: 1.35rem;
  }

  h3,
  .h3 {
    font-size: 1.2rem;
  }

  h4,
  .h4,
  h5,
  .h5,
  h6,
  .h6 {
    font-size: 1.05rem;
  }

  .btn {
    --bs-btn-padding-y: 0.35rem;
    --bs-btn-padding-x: 0.65rem;
    --bs-btn-font-size: 0.86rem;
    --bs-btn-border-radius: 0.55rem;
    min-height: 2.2rem;
  }

  .btn.btn-sm {
    --bs-btn-padding-y: 0.24rem;
    --bs-btn-padding-x: 0.5rem;
    --bs-btn-font-size: 0.78rem;
    min-height: 2rem;
  }

  .form-label,
  .form-text,
  .small {
    font-size: 0.82rem;
  }

  .form-control,
  .form-select,
  .input-group-text {
    font-size: 0.9rem;
    min-height: 2.2rem;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .badge {
    font-size: 0.72rem;
    padding: 0.26em 0.5em;
  }

  .card-header,
  .card-body,
  .card-footer,
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 0.75rem;
  }

  .table,
  .table > :not(caption) > * > * {
    font-size: 0.82rem;
    padding-top: 0.42rem;
    padding-bottom: 0.42rem;
  }

  .pagination .page-link {
    padding: 0.3rem 0.55rem;
    font-size: 0.82rem;
  }
}

@media (max-width: 576px) {
  html {
    font-size: 15px;
  }

  .container,
  .container-fluid {
    --bs-gutter-x: 0.85rem;
  }

  .btn {
    --bs-btn-font-size: 0.83rem;
    --bs-btn-padding-y: 0.3rem;
    --bs-btn-padding-x: 0.58rem;
    min-height: 2.1rem;
  }

  .btn.btn-sm {
    --bs-btn-font-size: 0.75rem;
    min-height: 1.9rem;
  }

  .table,
  .table > :not(caption) > * > * {
    font-size: 0.78rem;
  }

  .modal-dialog {
    margin: 0.45rem;
  }
}

