.animate-in {
  animation: fadeIn 0.4s ease-out, riseIn 0.4s ease-out;
}

.qk-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 14% 18%, rgba(249, 115, 22, 0.2), transparent 26%),
    radial-gradient(circle at 86% 16%, rgba(59, 130, 246, 0.16), transparent 26%),
    rgba(4, 10, 20, 0.8);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.qk-loader-overlay[hidden] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.qk-loader-panel {
  width: min(540px, calc(100vw - 2rem));
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 2rem 2.25rem 1.65rem;
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(155deg, rgba(20, 34, 61, 0.92), rgba(8, 15, 29, 0.96)),
    rgba(8, 15, 29, 0.95);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.52),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(249, 115, 22, 0.12);
  text-align: center;
}

.qk-loader-mark {
  position: relative;
  width: 5.25rem;
  height: 5.25rem;
  display: grid;
  place-items: center;
  border-radius: 1.5rem;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 214, 170, 0.36), transparent 38%),
    linear-gradient(135deg, #ff9d1b 0%, #f97316 45%, #2563eb 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 20px 44px rgba(249, 115, 22, 0.32);
  overflow: hidden;
}

.qk-loader-mark::before,
.qk-loader-mark::after {
  content: '';
  position: absolute;
  inset: -18%;
  border-radius: 1.75rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  animation: qk-loader-orbit 2.8s linear infinite;
}

.qk-loader-mark::after {
  inset: -35%;
  border-color: rgba(96, 165, 250, 0.22);
  animation-direction: reverse;
  animation-duration: 3.6s;
}

.qk-loader-mark-core {
  position: relative;
  z-index: 1;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #1d4ed8;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.24);
}

.qk-loader-copy {
  display: grid;
  gap: 0.45rem;
}

.qk-loader-kicker {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.9);
}

.qk-loader-title {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  line-height: 1.05;
  color: var(--text);
}

.qk-loader-detail {
  margin: 0;
  max-width: 30rem;
  color: var(--text-soft);
  line-height: 1.6;
}

.qk-loader-track {
  width: min(22rem, 100%);
  height: 0.35rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.qk-loader-track > span {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.85), rgba(96, 165, 250, 0.9));
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.28);
  animation: qk-loader-track-shift 1.2s ease-in-out infinite;
}

body.qk-loader-active {
  overflow: hidden;
}

@keyframes qk-loader-orbit {
  to {
    transform: rotate(360deg);
  }
}

@keyframes qk-loader-track-shift {
  0% {
    transform: translateX(-110%);
  }
  55% {
    transform: translateX(115%);
  }
  100% {
    transform: translateX(115%);
  }
}

.icon {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  flex: 0 0 auto;
}

.icon-sm {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.svg-icon {
  width: 1em;
  height: 1em;
  display: block;
  flex: 0 0 auto;
}

.text-amber { color: var(--amber); }
.text-emerald { color: var(--emerald); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.text-soft { color: var(--text-soft); }
.text-faint { color: var(--text-faint); }

.stat-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 1.1rem;
}

.icon-key {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.icon-key.blue { color: var(--blue); }
.icon-key.amber { color: var(--amber); }
.icon-key.red { color: var(--red); }
.icon-key.emerald { color: var(--emerald); }

.custom-scrollbar::-webkit-scrollbar { width: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: var(--bg); }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #334155; }

.module-surface-hero {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.02);
  padding: 2rem;
}

.module-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.module-card-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.module-contract-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.02);
  padding: 1rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.module-contract-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-strong);
}

.module-contract-card-invalid {
  border-color: rgba(239, 68, 68, 0.3);
}

.module-contract-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: var(--blue);
  background: rgba(96, 165, 250, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.module-contract-description {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-soft);
  line-height: 1.4;
}

.module-control-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  align-items: center;
  overflow-x: auto;
}

.module-control-row .btn {
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 1;
}

.module-control-row .icon-btn {
  flex-shrink: 0;
}

.module-settings-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  padding-top: 0.75rem;
}

.module-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

/* Module filter bar (shown on the standalone Modules surface) */
.module-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.module-filter-search {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.module-filter-search-input {
  flex: 1;
}

/* Star/pin button — filled amber when a module is pinned to the home dashboard */
.module-pin-active .svg-icon,
.module-pin-active svg {
  fill: var(--amber);
  color: var(--amber);
}

/* Empty state shown when active filters produce zero results */
.module-filter-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
}

.module-submodule-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  padding-top: 0.75rem;
}

.module-submodule-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.02);
  padding: 1rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.module-submodule-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-strong);
}

/* Operations group cards - enhanced gradient styling for visual consistency */
.operations-group-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(148, 163, 184, 0.24);
  background:
    radial-gradient(circle at 85% 15%, rgba(56, 189, 248, 0.12), transparent 50%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.8));
}

.operations-group-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.04) 50%, transparent 80%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.operations-group-card:hover::before {
  opacity: 1;
}

/* Operations group card variants with accent colors */
.operations-group-card.group-running-services {
  border-color: rgba(16, 185, 129, 0.25);
  background:
    radial-gradient(circle at 85% 15%, rgba(16, 185, 129, 0.15), transparent 50%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.8));
}

.operations-group-card.group-data-analytics {
  border-color: rgba(96, 165, 250, 0.25);
  background:
    radial-gradient(circle at 85% 15%, rgba(96, 165, 250, 0.15), transparent 50%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.8));
}

.operations-group-card.group-automation-profiles {
  border-color: rgba(245, 158, 11, 0.25);
  background:
    radial-gradient(circle at 85% 15%, rgba(245, 158, 11, 0.12), transparent 50%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.8));
}

.operations-group-card.group-other-modules {
  border-color: rgba(148, 163, 184, 0.24);
  background:
    radial-gradient(circle at 85% 15%, rgba(148, 163, 184, 0.1), transparent 50%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.8));
}

.security-firewall-create-form {
  border: 1px solid rgba(96, 165, 250, 0.24);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background:
    radial-gradient(circle at 100% 0%, rgba(96, 165, 250, 0.12), transparent 42%),
    rgba(255, 255, 255, 0.02);
}

.security-firewall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.security-firewall-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem;
  border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 0.85rem;
}

.security-gatewatch-live-shell {
  display: grid;
  gap: 0.9rem;
}

.security-gatewatch-live-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 12px;
  background:
    radial-gradient(circle at 88% 12%, rgba(56, 189, 248, 0.14), transparent 48%),
    rgba(15, 23, 42, 0.7);
}

.security-gatewatch-live-frame-wrap {
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.7);
}

.security-gatewatch-live-frame {
  display: block;
  width: 100%;
  min-height: 68vh;
  border: 0;
  background: #020617;
}

.security-gatewatch-live-status {
  border-color: rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.55);
}

.security-lane-power-form {
  border: 1px solid rgba(96, 165, 250, 0.24);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background:
    radial-gradient(circle at 100% 0%, rgba(56, 189, 248, 0.14), transparent 44%),
    rgba(15, 23, 42, 0.64);
}

.security-lane-power-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.security-lane-power-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.security-lane-partial-picker {
  border: 1px dashed rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 0.8rem;
  background: rgba(2, 6, 23, 0.4);
}

.security-lane-module-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.55rem;
}

.security-lane-module-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.security-lane-module-option input {
  accent-color: var(--blue);
}

.security-lane-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
}

.security-lane-preview {
  border-color: rgba(56, 189, 248, 0.28);
  background:
    radial-gradient(circle at 96% 10%, rgba(56, 189, 248, 0.12), transparent 42%),
    rgba(2, 6, 23, 0.56);
}

/* Activity panel cards - gradient styling for consistency */
.activity-panel-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(96, 165, 250, 0.2);
  background:
    radial-gradient(circle at 90% 10%, rgba(56, 189, 248, 0.1), transparent 52%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.93), rgba(15, 23, 42, 0.8));
}

.activity-panel-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.03) 50%, transparent 80%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.activity-panel-card:hover::before {
  opacity: 1;
}

.automation-jobs-toolbar {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.automation-jobs-toolbar-btn {
  min-width: 0;
  min-height: 2.35rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  line-height: 1.1;
  flex: 0 0 auto;
  padding: 0.55rem 0.8rem;
}

@media (max-width: 900px) {
  .automation-jobs-toolbar-btn {
    min-width: 0;
    padding: 0.5rem 0.72rem;
  }

  .security-lane-power-actions {
    width: 100%;
  }

  .security-lane-power-actions .btn {
    flex: 1 1 calc(50% - 0.35rem);
  }
}

.settings-discovery-grid,
.settings-tools-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.settings-bullets {
  display: grid;
  gap: 0.55rem;
}

.settings-bullet {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.settings-bullet-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
  flex: 0 0 auto;
}

.settings-password-note {
  color: var(--text-faint);
  line-height: 1.45;
}

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

@keyframes riseIn {
  from { transform: translateY(10px); }
  to { transform: translateY(0); }
}

body[data-theme='light'] .icon,
body[data-theme='light'] .icon-key,
body[data-theme='light'] .module-surface-hero,
body[data-theme='light'] .module-contract-card,
body[data-theme='light'] .module-submodule-card,
body[data-theme='light'] .operations-group-card,
body[data-theme='light'] .security-firewall-create-form,
body[data-theme='light'] .security-gatewatch-live-bar,
body[data-theme='light'] .security-gatewatch-live-status,
body[data-theme='light'] .security-lane-power-form,
body[data-theme='light'] .security-lane-partial-picker,
body[data-theme='light'] .security-lane-preview {
  background: var(--bg-card);
}

body[data-theme='light'] .module-contract-card:hover,
body[data-theme='light'] .module-submodule-card:hover,
body[data-theme='light'] .operations-group-card:hover {
  background: var(--bg-card-hover);
}

body[data-theme='light'] .module-contract-card,
body[data-theme='light'] .module-submodule-card,
body[data-theme='light'] .module-surface-hero,
body[data-theme='light'] .operations-group-card,
body[data-theme='light'] .security-firewall-create-form,
body[data-theme='light'] .security-gatewatch-live-bar,
body[data-theme='light'] .security-gatewatch-live-status,
body[data-theme='light'] .security-lane-power-form,
body[data-theme='light'] .security-lane-partial-picker,
body[data-theme='light'] .security-lane-module-option,
body[data-theme='light'] .security-lane-preview {
  border-color: var(--border-soft);
  box-shadow: none;
}

body[data-theme='light'] .module-contract-description,
body[data-theme='light'] .db-subtitle,
body[data-theme='light'] .qk-card-meta,
body[data-theme='light'] .settings-bullet,
body[data-theme='light'] .settings-password-note {
  color: var(--text-soft);
}

body[data-theme='light'] .operations-group-card::before {
  background: linear-gradient(120deg, transparent 20%, rgba(15, 23, 42, 0.04) 50%, transparent 80%);
}
