/* ==========================================================================
   App.Common.UI — Theme system (AppCommonUI design tokens)
   Modes:   data-theme-mode="light|dark|system"
   Accents: data-theme-accent="guardian-green|ocean|purple|burgundy|navy|graphite|amber|cyan|lavender|green"
   ========================================================================== */

/* --------------------------------------------------------------------------
   Shared structural tokens
   -------------------------------------------------------------------------- */
html {
  --theme-transition-duration: 250ms;
  --color-primary-shadow: color-mix(in srgb, var(--color-primary) 40%, transparent);
  --color-primary-shadow-soft: color-mix(in srgb, var(--color-primary) 30%, transparent);
  --bs-primary: var(--color-primary);
  --bs-primary-rgb: var(--color-primary-rgb);
  color-scheme: light;
}

html[data-theme-mode="dark"] {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme-mode="system"] {
    color-scheme: dark;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    --theme-transition-duration: 0ms;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html.theme-transitioning,
  html.theme-transitioning body {
    transition:
      background-color var(--theme-transition-duration) ease,
      color var(--theme-transition-duration) ease,
      border-color var(--theme-transition-duration) ease;
  }
}

/* --------------------------------------------------------------------------
   Light mode surfaces (explicit + default)
   -------------------------------------------------------------------------- */
html[data-theme-mode="light"],
html:not([data-theme-mode]) {
  --color-surface: #f5f7fb;
  --color-surface-elevated: #ffffff;
  --color-surface-muted: #f1f5f9;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-sidebar-active-bg: color-mix(in srgb, var(--color-primary) 12%, transparent);
  --color-sidebar-active-text: var(--color-primary);
  --color-sidebar-bg: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface-elevated, #ffffff));
  --color-badge-tint: color-mix(in srgb, var(--color-primary) 14%, #ffffff);
  --color-focus-ring: color-mix(in srgb, var(--color-primary) 35%, transparent);
  --color-chart-1: var(--color-primary);
  --color-chart-2: var(--color-accent);
  --color-chart-3: #22c55e;
  --color-chart-4: #f59e0b;
  --color-chart-5: #8b5cf6;
  --color-chart-6: #06b6d4;
  --color-chart-grid: color-mix(in srgb, var(--color-border) 75%, transparent);
  --color-chart-axis: var(--color-text-muted);
  --color-chart-label: var(--color-text-muted);
  --color-chart-tooltip-bg: var(--color-surface-elevated);
  --color-chart-tooltip-border: var(--color-border);
  --color-chart-tooltip-title: var(--color-text);
  --color-chart-tooltip-body: var(--color-text-muted);
  --color-primary-subtle: color-mix(in srgb, var(--color-primary) 14%, var(--color-surface-elevated));
}

/* --------------------------------------------------------------------------
   Dark mode surfaces
   -------------------------------------------------------------------------- */
html[data-theme-mode="dark"] {
  --color-surface: #0f172a;
  --color-surface-elevated: #1e293b;
  --color-surface-muted: #1b2434;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-border: #334155;
  --illustration-paper: #243247;
  --illustration-tint: color-mix(in srgb, var(--color-primary) 28%, #1e293b);
  --illustration-tint-soft: color-mix(in srgb, var(--color-primary) 18%, #1e293b);
  --color-sidebar-active-bg: color-mix(in srgb, var(--color-primary) 22%, transparent);
  --color-sidebar-active-text: color-mix(in srgb, var(--color-primary) 65%, #ffffff);
  --color-sidebar-bg: color-mix(in srgb, var(--color-primary) 16%, var(--color-surface));
  --color-badge-tint: color-mix(in srgb, var(--color-primary) 28%, #1e293b);
  --color-focus-ring: color-mix(in srgb, var(--color-primary) 55%, transparent);
  --color-chart-1: color-mix(in srgb, var(--color-primary) 80%, #ffffff);
  --color-chart-2: var(--color-accent);
  --color-chart-3: #4ade80;
  --color-chart-4: #fbbf24;
  --color-chart-5: #a78bfa;
  --color-chart-6: #22d3ee;
  --color-chart-grid: color-mix(in srgb, var(--color-border) 65%, transparent);
  --color-chart-axis: var(--color-text-muted);
  --color-chart-label: var(--color-text-muted);
  --color-chart-tooltip-bg: var(--color-surface-elevated);
  --color-chart-tooltip-border: var(--color-border);
  --color-chart-tooltip-title: var(--color-text);
  --color-chart-tooltip-body: var(--color-text-muted);
  --color-primary-subtle: color-mix(in srgb, var(--color-primary) 22%, var(--color-surface-elevated));
}

@media (prefers-color-scheme: dark) {
  html[data-theme-mode="system"] {
    --color-surface: #0f172a;
    --color-surface-elevated: #1e293b;
    --color-surface-muted: #1b2434;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-border: #334155;
    --illustration-paper: #243247;
    --illustration-tint: color-mix(in srgb, var(--color-primary) 28%, #1e293b);
    --illustration-tint-soft: color-mix(in srgb, var(--color-primary) 18%, #1e293b);
    --color-sidebar-active-bg: color-mix(in srgb, var(--color-primary) 22%, transparent);
    --color-sidebar-active-text: color-mix(in srgb, var(--color-primary) 65%, #ffffff);
    --color-sidebar-bg: color-mix(in srgb, var(--color-primary) 16%, var(--color-surface));
    --color-badge-tint: color-mix(in srgb, var(--color-primary) 28%, #1e293b);
    --color-focus-ring: color-mix(in srgb, var(--color-primary) 55%, transparent);
    --color-chart-1: color-mix(in srgb, var(--color-primary) 80%, #ffffff);
    --color-chart-2: var(--color-accent);
    --color-chart-3: #4ade80;
    --color-chart-4: #fbbf24;
    --color-chart-5: #a78bfa;
    --color-chart-6: #22d3ee;
    --color-chart-grid: color-mix(in srgb, var(--color-border) 65%, transparent);
    --color-chart-axis: var(--color-text-muted);
    --color-chart-label: var(--color-text-muted);
    --color-chart-tooltip-bg: var(--color-surface-elevated);
    --color-chart-tooltip-border: var(--color-border);
    --color-chart-tooltip-title: var(--color-text);
    --color-chart-tooltip-body: var(--color-text-muted);
    --color-primary-subtle: color-mix(in srgb, var(--color-primary) 22%, var(--color-surface-elevated));
  }
}

@media (prefers-color-scheme: light) {
  html[data-theme-mode="system"] {
    --color-surface: #f5f7fb;
    --color-surface-elevated: #ffffff;
    --color-surface-muted: #f1f5f9;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-sidebar-active-bg: color-mix(in srgb, var(--color-primary) 12%, transparent);
    --color-sidebar-active-text: var(--color-primary);
    --color-sidebar-bg: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface-elevated, #ffffff));
    --color-badge-tint: color-mix(in srgb, var(--color-primary) 14%, #ffffff);
    --color-focus-ring: color-mix(in srgb, var(--color-primary) 35%, transparent);
    --color-chart-1: var(--color-primary);
    --color-chart-2: var(--color-accent);
    --color-chart-3: #22c55e;
    --color-chart-4: #f59e0b;
    --color-chart-5: #8b5cf6;
    --color-chart-6: #06b6d4;
    --color-chart-grid: color-mix(in srgb, var(--color-border) 75%, transparent);
    --color-chart-axis: var(--color-text-muted);
    --color-chart-label: var(--color-text-muted);
    --color-chart-tooltip-bg: var(--color-surface-elevated);
    --color-chart-tooltip-border: var(--color-border);
    --color-chart-tooltip-title: var(--color-text);
    --color-chart-tooltip-body: var(--color-text-muted);
    --color-primary-subtle: color-mix(in srgb, var(--color-primary) 14%, var(--color-surface-elevated));
  }
}

/* --------------------------------------------------------------------------
   Accent palettes (enterprise procurement themes)
   -------------------------------------------------------------------------- */
html[data-theme-accent="guardian-green"] {
  --color-primary: #146C4A;
  --color-primary-hover: #073B2B;
  --color-accent: #1a8a62;
  --color-primary-rgb: 20, 108, 74;
  --color-sidebar-start: #073B2B;
  --color-sidebar-end: #146C4A;
}

html[data-theme-accent="ocean"],
html[data-theme-accent="default"],
html:not([data-theme-accent]) {
  --color-primary: #0F6B94;
  --color-primary-hover: #083B55;
  --color-accent: #1490c4;
  --color-primary-rgb: 15, 107, 148;
  --color-sidebar-start: #083B55;
  --color-sidebar-end: #0F6B94;
}

html[data-theme-accent="purple"] {
  --color-primary: #5B2C91;
  --color-primary-hover: #301653;
  --color-accent: #7a45b8;
  --color-primary-rgb: 91, 44, 145;
  --color-sidebar-start: #301653;
  --color-sidebar-end: #5B2C91;
}

html[data-theme-accent="burgundy"] {
  --color-primary: #8B1538;
  --color-primary-hover: #50081E;
  --color-accent: #a81a45;
  --color-primary-rgb: 139, 21, 56;
  --color-sidebar-start: #50081E;
  --color-sidebar-end: #8B1538;
}

html[data-theme-accent="navy"] {
  --color-primary: #1E3A5F;
  --color-primary-hover: #0B1F3A;
  --color-accent: #2d5080;
  --color-primary-rgb: 30, 58, 95;
  --color-sidebar-start: #0B1F3A;
  --color-sidebar-end: #1E3A5F;
}

html[data-theme-accent="graphite"] {
  --color-primary: #374151;
  --color-primary-hover: #1F2937;
  --color-accent: #4b5563;
  --color-primary-rgb: 55, 65, 81;
  --color-sidebar-start: #1F2937;
  --color-sidebar-end: #374151;
}

html[data-theme-accent="amber"] {
  --color-primary: #D97706;
  --color-primary-hover: #92400E;
  --color-accent: #f59e0b;
  --color-primary-rgb: 217, 119, 6;
  --color-sidebar-start: #92400E;
  --color-sidebar-end: #D97706;
}

html[data-theme-accent="cyan"] {
  --color-primary: #0E7490;
  --color-primary-hover: #164E63;
  --color-accent: #0891b2;
  --color-primary-rgb: 14, 116, 144;
  --color-sidebar-start: #164E63;
  --color-sidebar-end: #0E7490;
}

html[data-theme-accent="lavender"] {
  --color-primary: #6D6AB7;
  --color-primary-hover: #433E7C;
  --color-accent: #8b88cc;
  --color-primary-rgb: 109, 106, 183;
  --color-sidebar-start: #433E7C;
  --color-sidebar-end: #6D6AB7;
}

html[data-theme-accent="green"] {
  --color-primary: #15803D;
  --color-primary-hover: #14532D;
  --color-accent: #22c55e;
  --color-primary-rgb: 21, 128, 61;
  --color-sidebar-start: #14532D;
  --color-sidebar-end: #15803D;
}

/* Legacy accent aliases (mapped in theme.js; CSS fallback if JS not loaded) */
html[data-theme-accent="sunset"] {
  --color-primary: #D97706;
  --color-primary-hover: #92400E;
  --color-accent: #f59e0b;
  --color-primary-rgb: 217, 119, 6;
  --color-sidebar-start: #92400E;
  --color-sidebar-end: #D97706;
}

html[data-theme-accent="khaki"] {
  --color-primary: #374151;
  --color-primary-hover: #1F2937;
  --color-accent: #4b5563;
  --color-primary-rgb: 55, 65, 81;
  --color-sidebar-start: #1F2937;
  --color-sidebar-end: #374151;
}

/* --------------------------------------------------------------------------
   Bridge to AppCommonUI variables
   -------------------------------------------------------------------------- */
html {
  --AppCommonUI-primary: var(--color-primary);
  --AppCommonUI-primary-rgb: var(--color-primary-rgb);
  --AppCommonUI-body-color: var(--color-text);
  --AppCommonUI-body-bg: var(--color-surface);
  --AppCommonUI-border-color: var(--color-border);
  --AppCommonUI-card-bg: var(--color-surface-elevated);
  --AppCommonUI-muted: var(--color-text-muted);
}

html[data-theme-mode="light"] body,
html:not([data-theme-mode]) body,
html[data-theme-mode="system"] body {
  color: var(--color-text);
  background-color: var(--color-surface);
}

html[data-theme-mode="dark"] body {
  color: var(--color-text);
  background-color: var(--color-surface);
}

/* Component hooks — AppCommonUI overrides (load after AppCommonUI.css) */
.btn-primary,
.btn-outline-primary,
.btn-ghost-primary {
  --AppCommonUI-btn-color: var(--color-primary);
  --AppCommonUI-btn-color-interactive: var(--color-primary-hover);
  --AppCommonUI-btn-color-text: #fafbfc;
}

.btn:focus:not([disabled]):not(.disabled),
.btn-primary:focus:not([disabled]):not(.disabled) {
  border-color: var(--color-primary);
}

.btn-primary,
.btn-outline-primary {
  --bs-btn-bg: var(--color-primary);
  --bs-btn-border-color: var(--color-primary);
  --bs-btn-hover-bg: var(--color-primary-hover);
  --bs-btn-hover-border-color: var(--color-primary-hover);
  --bs-btn-active-bg: var(--color-primary-hover);
  --bs-btn-active-border-color: var(--color-primary-hover);
}

a:not(.btn):not(.nav-link):not(.navbar-brand):not(.btn-landing-secondary):not(.btn-get-started):not(.getstarted):not(.back-to-top) {
  color: var(--color-primary);
}

a:not(.btn):not(.nav-link):not(.navbar-brand):not(.btn-landing-secondary):not(.btn-get-started):not(.getstarted):not(.back-to-top):hover {
  color: var(--color-primary-hover);
}

.text-primary,
.bg-primary-lt {
  color: var(--color-primary) !important;
}

.bg-primary-lt {
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface-elevated)) !important;
}

.bg-primary {
  background-color: var(--color-primary) !important;
}

.form-control:focus {
  outline-color: var(--color-focus-ring);
  background-color: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface-elevated));
}

.form-check-input:checked,
.form-check-input:checked[type=checkbox],
.form-check-input:checked[type=radio],
.form-check-input[type=checkbox]:indeterminate {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.form-switch .form-check-input:checked {
  background-color: var(--color-primary);
}

.page.page-center {
  background-color: var(--color-surface);
  color: var(--color-text);
}

.card,
.card-md {
  background-color: var(--color-surface-elevated);
  color: var(--color-text);
  border-color: var(--color-border);
}

.card-title,
.form-label,
.form-footer {
  color: var(--color-text);
}

.text-muted {
  color: var(--color-text-muted) !important;
}

.form-label-description,
.form-label-description a {
  color: var(--color-primary);
}

.form-label-description a:hover {
  color: var(--color-primary-hover);
}

.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
  background-color: var(--color-sidebar-active-bg);
  color: var(--color-sidebar-active-text);
}

.badge.bg-primary,
.badge-primary {
  background-color: var(--color-badge-tint) !important;
  color: var(--color-primary) !important;
}

.border-primary,
body.border-primary,
.border-top-wide.border-primary {
  border-color: var(--color-primary) !important;
}

.text-primary {
  color: var(--color-primary) !important;
}

.bg-primary {
  background-color: var(--color-primary) !important;
}

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

.page-item.active .page-link,
.page-item.active .page-link:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.page-link {
  color: var(--color-primary);
}

.page-link:hover {
  color: var(--color-primary-hover);
}

.table tr.table-active,
.table-active > td,
.table-active > th {
  background-color: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface-elevated));
}

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

.navbar.navbar-top,
.page-wrapper > .navbar {
  border-bottom: none;
}

.navbar.navbar-top .navbar-brand,
.page-wrapper > .navbar .navbar-brand {
  color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.theme-segment:focus-visible,
.theme-swatch:focus-visible .theme-swatch__inner,
.theme-panel__close:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Theme selector UI
   -------------------------------------------------------------------------- */
.theme-selector--toolbar {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.theme-selector--auth {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1050;
}

/* Landing header: inline in navbar on desktop, beside menu toggle on mobile */
.theme-selector--header {
  position: relative;
  top: auto;
  right: auto;
  z-index: auto;
}

body.layout-landing #header .navbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

body.layout-landing .navbar-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

@media (min-width: 992px) {
  body.layout-landing #header .navbar .navbar-nav {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
  }

  body.layout-landing #header .navbar .navbar-nav .nav-item {
    display: flex;
    align-items: center;
  }

  body.layout-landing #header .navbar .navbar-nav .nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    padding: 0;
    line-height: 1;
  }
}

@media (max-width: 991px) {
  body.layout-landing .navbar-mobile .navbar-header-actions {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 9999;
  }

  body.layout-landing .navbar-mobile .navbar-header-actions .theme-selector--header {
    position: relative;
  }
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-surface-elevated);
  color: var(--color-text);
  cursor: pointer;
}

.theme-toggle-btn:hover {
  background: var(--color-surface-muted);
}

.theme-toggle-btn .theme-toggle-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.theme-toggle-btn .theme-toggle-icon--dark,
.theme-toggle-btn .theme-toggle-icon--system,
html[data-theme-mode="dark"] .theme-toggle-btn .theme-toggle-icon--light,
html[data-theme-mode="dark"] .theme-toggle-btn .theme-toggle-icon--system,
html[data-theme-mode="system"] .theme-toggle-btn .theme-toggle-icon--light,
html[data-theme-mode="system"] .theme-toggle-btn .theme-toggle-icon--dark {
  display: none;
}

html[data-theme-mode="light"] .theme-toggle-btn .theme-toggle-icon--light,
html:not([data-theme-mode]) .theme-toggle-btn .theme-toggle-icon--light {
  display: block;
}

html[data-theme-mode="dark"] .theme-toggle-btn .theme-toggle-icon--dark {
  display: block;
}

html[data-theme-mode="system"] .theme-toggle-btn .theme-toggle-icon--system {
  display: block;
}

.theme-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1055;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(2px);
}

.theme-panel-backdrop[hidden] {
  display: none !important;
}

.theme-panel {
  position: fixed;
  top: calc(var(--app-header-height, 3.5rem) + 0.75rem);
  right: 1rem;
  width: min(360px, calc(100vw - 2rem));
  max-height: calc(100vh - var(--app-header-height, 3.5rem) - 1.5rem);
  padding: 1rem 1.125rem;
  border: 1px solid color-mix(in srgb, var(--color-border) 65%, transparent);
  border-radius: 16px;
  background: var(--color-surface-elevated);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14);
  z-index: 1060;
  overflow-x: hidden;
  overflow-y: auto;
  opacity: 0;
  transform: translateX(1rem);
  transition:
    opacity var(--theme-transition-duration) ease,
    transform var(--theme-transition-duration) ease;
  pointer-events: none;
}

.theme-panel.theme-panel--open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.theme-selector--toolbar .theme-panel,
.theme-selector--auth .theme-panel,
.theme-selector--header .theme-panel {
  top: calc(var(--app-header-height, 3.5rem) + 0.75rem);
  right: 1rem;
}

@media (max-width: 575.98px) {
  .theme-panel {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    max-height: calc(100vh - 1.5rem);
  }
}

.theme-panel[hidden] {
  display: block !important;
  visibility: hidden;
}

.theme-panel[hidden]:not(.theme-panel--open) {
  opacity: 0;
  pointer-events: none;
}

.theme-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.theme-panel__heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.theme-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.theme-panel__close:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.theme-panel__title {
  margin: 0 0 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.theme-panel__section + .theme-panel__section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.theme-segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.375rem;
}

.theme-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.55rem 0.35rem;
  border: 2px solid var(--color-border);
  border-radius: 0.625rem;
  background: var(--color-surface-elevated);
  color: var(--color-text-muted);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color var(--theme-transition-duration) ease,
    background-color var(--theme-transition-duration) ease,
    color var(--theme-transition-duration) ease;
}

.theme-segment[aria-pressed="true"],
.theme-segment.active {
  border-color: var(--color-primary);
  background: rgba(var(--color-primary-rgb), 0.04);
  color: var(--color-primary);
  box-shadow: none;
}

.theme-segment svg {
  width: 1.125rem;
  height: 1.125rem;
}

.theme-swatch-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.45rem;
  align-items: center;
  padding: 0.1rem;
  overflow: hidden;
}

.theme-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.15rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: background-color var(--theme-transition-duration) ease;
}

.theme-swatch:hover {
  background: color-mix(in srgb, var(--color-text) 4%, transparent);
}

.theme-swatch__inner {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 999px;
  overflow: visible;
  transition:
    border-color var(--theme-transition-duration) ease,
    background-color var(--theme-transition-duration) ease;
}

.theme-swatch[aria-pressed="true"] .theme-swatch__inner,
.theme-swatch.active .theme-swatch__inner {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.theme-swatch[aria-pressed="true"] .theme-swatch__ring,
.theme-swatch.active .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated);
}

.theme-swatch[aria-pressed="true"][data-accent="guardian-green"] .theme-swatch__ring,
.theme-swatch.active[data-accent="guardian-green"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #146C4A;
}

.theme-swatch[aria-pressed="true"][data-accent="ocean"] .theme-swatch__ring,
.theme-swatch.active[data-accent="ocean"] .theme-swatch__ring,
.theme-swatch[aria-pressed="true"][data-accent="default"] .theme-swatch__ring,
.theme-swatch.active[data-accent="default"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #0F6B94;
}

.theme-swatch[aria-pressed="true"][data-accent="purple"] .theme-swatch__ring,
.theme-swatch.active[data-accent="purple"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #5B2C91;
}

.theme-swatch[aria-pressed="true"][data-accent="burgundy"] .theme-swatch__ring,
.theme-swatch.active[data-accent="burgundy"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #8B1538;
}

.theme-swatch[aria-pressed="true"][data-accent="navy"] .theme-swatch__ring,
.theme-swatch.active[data-accent="navy"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #1E3A5F;
}

.theme-swatch[aria-pressed="true"][data-accent="graphite"] .theme-swatch__ring,
.theme-swatch.active[data-accent="graphite"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #374151;
}

.theme-swatch[aria-pressed="true"][data-accent="amber"] .theme-swatch__ring,
.theme-swatch.active[data-accent="amber"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #D97706;
}

.theme-swatch[aria-pressed="true"][data-accent="cyan"] .theme-swatch__ring,
.theme-swatch.active[data-accent="cyan"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #0E7490;
}

.theme-swatch[aria-pressed="true"][data-accent="green"] .theme-swatch__ring,
.theme-swatch.active[data-accent="green"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #15803D;
}

.theme-swatch[aria-pressed="true"][data-accent="lavender"] .theme-swatch__ring,
.theme-swatch.active[data-accent="lavender"] .theme-swatch__ring {
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.22),
    0 0 0 2px var(--color-surface-elevated),
    0 0 0 3px #6D6AB7;
}

.theme-swatch__label {
  display: none;
}

.theme-swatch__ring {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: none;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

.theme-swatch__check {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.8rem;
  height: 0.8rem;
  padding: 0.12rem;
  border-radius: 999px;
  background: #fff;
  color: var(--color-text);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
  pointer-events: none;
}

.theme-swatch[aria-pressed="true"] .theme-swatch__check,
.theme-swatch.active .theme-swatch__check {
  opacity: 1;
  visibility: visible;
}

.theme-swatch[aria-pressed="true"][data-accent="guardian-green"] .theme-swatch__check,
.theme-swatch.active[data-accent="guardian-green"] .theme-swatch__check { color: #146C4A; }

.theme-swatch[aria-pressed="true"][data-accent="ocean"] .theme-swatch__check,
.theme-swatch.active[data-accent="ocean"] .theme-swatch__check,
.theme-swatch[aria-pressed="true"][data-accent="default"] .theme-swatch__check,
.theme-swatch.active[data-accent="default"] .theme-swatch__check { color: #0F6B94; }

.theme-swatch[aria-pressed="true"][data-accent="purple"] .theme-swatch__check,
.theme-swatch.active[data-accent="purple"] .theme-swatch__check { color: #5B2C91; }

.theme-swatch[aria-pressed="true"][data-accent="burgundy"] .theme-swatch__check,
.theme-swatch.active[data-accent="burgundy"] .theme-swatch__check { color: #8B1538; }

.theme-swatch[aria-pressed="true"][data-accent="navy"] .theme-swatch__check,
.theme-swatch.active[data-accent="navy"] .theme-swatch__check { color: #1E3A5F; }

.theme-swatch[aria-pressed="true"][data-accent="graphite"] .theme-swatch__check,
.theme-swatch.active[data-accent="graphite"] .theme-swatch__check { color: #374151; }

.theme-swatch[aria-pressed="true"][data-accent="amber"] .theme-swatch__check,
.theme-swatch.active[data-accent="amber"] .theme-swatch__check { color: #D97706; }

.theme-swatch[aria-pressed="true"][data-accent="cyan"] .theme-swatch__check,
.theme-swatch.active[data-accent="cyan"] .theme-swatch__check { color: #0E7490; }

.theme-swatch[aria-pressed="true"][data-accent="green"] .theme-swatch__check,
.theme-swatch.active[data-accent="green"] .theme-swatch__check { color: #15803D; }

.theme-swatch[aria-pressed="true"][data-accent="lavender"] .theme-swatch__check,
.theme-swatch.active[data-accent="lavender"] .theme-swatch__check { color: #6D6AB7; }

.theme-swatch[data-accent="guardian-green"] .theme-swatch__ring { background: #146C4A; }
.theme-swatch[data-accent="ocean"] .theme-swatch__ring,
.theme-swatch[data-accent="default"] .theme-swatch__ring { background: #0F6B94; }
.theme-swatch[data-accent="navy"] .theme-swatch__ring { background: #1E3A5F; }
.theme-swatch[data-accent="green"] .theme-swatch__ring { background: #15803D; }
.theme-swatch[data-accent="burgundy"] .theme-swatch__ring { background: #8B1538; }
.theme-swatch[data-accent="graphite"] .theme-swatch__ring { background: #374151; }
.theme-swatch[data-accent="purple"] .theme-swatch__ring { background: #5B2C91; }
.theme-swatch[data-accent="amber"] .theme-swatch__ring { background: #D97706; }
.theme-swatch[data-accent="cyan"] .theme-swatch__ring { background: #0E7490; }
.theme-swatch[data-accent="lavender"] .theme-swatch__ring { background: #6D6AB7; }

.theme-swatch-selected {
  margin: 0.65rem 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

.theme-sidebar-preview--compact {
  margin-top: 0.5rem;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.theme-sidebar-preview__strip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem;
  min-height: 2.5rem;
  overflow: hidden;
  background: var(--color-sidebar-bg);
  color: var(--color-text);
  font-size: 0.625rem;
  font-weight: 500;
}

.theme-sidebar-preview__strip-logo {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.4rem;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

.theme-sidebar-preview__strip-item {
  padding: 0.15rem 0.3rem;
  border-radius: 0.25rem;
  opacity: 0.75;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.theme-sidebar-preview__strip-item--active {
  background: var(--color-sidebar-active-bg);
  border-left: 3px solid var(--color-primary);
  color: var(--color-sidebar-active-text);
  padding: 0.25rem 0.45rem 0.25rem 0.35rem;
  border-radius: 0.25rem;
  opacity: 1;
}

.theme-panel__footer {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
}

.theme-settings-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}

.card {
  background-color: var(--color-surface-elevated);
  color: var(--color-text);
  border-color: var(--color-border);
}

body.layout-landing .navbar,
body.layout-landing #header .navbar {
  background-color: transparent !important;
}

.navbar:not(.navbar-vertical):not(.app-sidebar) {
  background-color: var(--color-surface-elevated) !important;
}

body.layout-landing #header.header {
  background-color: transparent;
}

body.layout-landing #header.header-scrolled {
  background-color: var(--color-surface-elevated, #fff);
  box-shadow: 0 2px 16px color-mix(in srgb, var(--color-primary) 10%, transparent);
}

body.layout-landing #header .theme-toggle-btn {
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
  border-color: color-mix(in srgb, var(--color-primary) 22%, var(--color-border));
}

.navbar .nav-link,
.navbar .navbar-brand {
  color: var(--color-text);
}

/* Landing dark/system: #hero keeps a light PNG via Welcome.css — clear it below in landing.css */
html[data-theme-mode="dark"] body.layout-landing #header,
html[data-theme-mode="dark"] body.layout-landing #footer {
  background-color: var(--color-surface);
  color: var(--color-text);
}

@media (prefers-color-scheme: dark) {
  html[data-theme-mode="system"] body.layout-landing #header,
  html[data-theme-mode="system"] body.layout-landing #footer {
    background-color: var(--color-surface);
    color: var(--color-text);
  }
}

/* Landing page (Welcome.css) — ensure themed buttons, links, and shadows */
body.layout-landing #header .navbar-brand a,
body.layout-landing #header .navbar-brand svg,
body.layout-landing #footer .logo,
body.layout-landing #footer .logo svg,
body.layout-landing #footer .footer-links ul i,
body.layout-landing .hero .hero-img svg {
  color: var(--color-primary);
}

/* Simple logo/icon SVGs use currentColor; detailed illustrations use inline var(--color-primary). */
body.layout-landing #header .navbar-brand svg,
body.layout-landing #footer .logo svg {
  fill: currentColor;
}

body.layout-landing #header .navbar-brand svg path[fill="none"],
body.layout-landing #footer .logo svg path[fill="none"] {
  fill: none;
}

body.layout-landing .hero .hero-img svg path[fill="currentColor"],
body.layout-landing .hero .hero-img svg path[fill='#4C94FF'] {
  fill: currentColor;
}

html.theme-transitioning body.layout-landing #header .navbar-brand svg,
html.theme-transitioning body.layout-landing #footer .logo svg,
html.theme-transitioning body.layout-landing .hero .hero-img svg path[fill="currentColor"],
html.theme-transitioning body.layout-landing .hero .hero-img svg path[fill='#4C94FF'] {
  transition:
    fill var(--theme-transition-duration) ease,
    color var(--theme-transition-duration) ease;
}

body.layout-landing #header .navbar a.nav-link:hover,
body.layout-landing .navbar a.nav-link:hover,
body.layout-landing .navbar .active,
body.layout-landing .navbar li:hover > a.nav-link {
  color: var(--color-primary);
}

body.layout-landing .hero h1,
body.layout-landing .section-header p,
body.layout-landing .breadcrumbs h2 {
  color: var(--color-text);
}

body.layout-landing .hero .btn-get-started,
body.layout-landing .navbar .getstarted,
body.layout-landing .navbar .getstarted:focus,
body.layout-landing .navbar .getstarted:hover,
body.layout-landing .navbar .getstarted.active,
body.layout-landing .navbar li:hover > a.getstarted,
body.layout-landing .back-to-top,
body.layout-landing .footer .social-links a:hover {
  background: var(--color-primary);
  color: #fff;
}

body.layout-landing .hero .btn-get-started span,
body.layout-landing .hero .btn-get-started i,
body.layout-landing .navbar .getstarted,
body.layout-landing .navbar .getstarted:focus,
body.layout-landing .navbar .getstarted:hover,
body.layout-landing .navbar .getstarted.active,
body.layout-landing .navbar li:hover > a.getstarted {
  color: #fff;
}

body.layout-landing .hero .btn-get-started,
body.layout-landing .navbar .getstarted,
body.layout-landing .navbar .getstarted:focus {
  box-shadow: 0 5px 30px var(--color-primary-shadow);
}

body.layout-landing .hero .btn-get-started:hover,
body.layout-landing .navbar .getstarted:hover,
body.layout-landing .navbar .getstarted:focus:hover,
body.layout-landing .back-to-top:hover,
body.layout-landing .footer .social-links a:hover {
  background: var(--color-primary-hover);
  color: #fff;
}

body.layout-landing a:not(.btn):not(.btn-get-started):not(.getstarted):not(.back-to-top):not(.btn-landing-secondary) {
  color: var(--color-primary);
}

body.layout-landing a:not(.btn):not(.btn-get-started):not(.getstarted):not(.back-to-top):not(.btn-landing-secondary):hover {
  color: var(--color-primary-hover);
}

/* --------------------------------------------------------------------------
   Manage account: sessions & devices
   -------------------------------------------------------------------------- */
.sessions-manage__header {
  margin-bottom: 1.25rem;
}

.sessions-manage__actions {
  margin-bottom: 1.5rem;
}

.sessions-manage__section + .sessions-manage__section {
  margin-top: 2rem;
}

.sessions-manage__section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  color: var(--color-text);
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.session-card,
.device-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: var(--color-surface-elevated);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.session-card:hover {
  border-color: color-mix(in srgb, var(--color-primary) 35%, var(--color-border));
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}

.session-card--current {
  border-color: color-mix(in srgb, var(--color-primary) 45%, var(--color-border));
  background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface-elevated));
}

.session-card__body,
.device-card__body {
  flex: 1;
  min-width: 0;
}

.session-card__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.session-card__meta,
.session-card__timestamps,
.device-card__stats {
  font-size: 0.875rem;
}

.session-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  color: var(--color-text-muted, #6c757d);
}

.session-card__location,
.device-card__location {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.session-card__dot {
  opacity: 0.65;
}

.session-card__actions {
  flex-shrink: 0;
}

.session-card--device {
  align-items: flex-start;
}

.session-card__apps {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0.65rem 0 0;
  border-top: 1px solid var(--color-border);
}

.session-card__app {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0 0;
}

.session-card__app + .session-card__app {
  margin-top: 0.4rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--color-border);
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.device-card {
  align-items: flex-start;
}

.session-empty-state {
  padding: 1.25rem;
  border: 1px dashed var(--color-border);
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--color-surface) 70%, transparent);
}

.device-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.85rem;
  flex-shrink: 0;
}

.device-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.device-icon--windows {
  color: #0078d4;
  background: rgba(0, 120, 212, 0.12);
}

.device-icon--mac {
  color: #555;
  background: rgba(80, 80, 80, 0.1);
}

.device-icon--linux {
  color: #e95420;
  background: rgba(233, 84, 32, 0.12);
}

.device-icon--android {
  color: #3ddc84;
  background: rgba(61, 220, 132, 0.14);
}

.device-icon--iphone {
  color: #111;
  background: rgba(0, 0, 0, 0.08);
}

.device-icon--tablet {
  color: #6f42c1;
  background: rgba(111, 66, 193, 0.12);
}

.device-icon--unknown {
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
}

.theme-dark .device-icon--iphone {
  color: #f5f5f7;
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 767px) {
  .session-card {
    flex-wrap: wrap;
  }

  .session-card__actions {
    width: 100%;
    padding-left: 3.75rem;
  }
}
