:root {
  --bs-primary: #008080;
  --bs-primary-rgb: 0, 128, 128;
  --bs-link-color: var(--bs-primary);
  --bs-link-hover-color: #006d6d;
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 88px;
  --topbar-height: 72px;
  --shell-surface: linear-gradient(160deg, #f4f7fb 0%, #eef2f8 100%);
  --shell-sidebar-bg: #008080;
  --shell-sidebar-border: rgba(148, 163, 184, 0.35);
  --shell-sidebar-text: #ffffff;
  --shell-topbar-bg: #008080;
  --shell-topbar-border: rgba(15, 23, 42, 0.08);
}

[data-bs-theme="dark"] {
  --bs-primary: #008080;
  --bs-primary-rgb: 0, 128, 128;
  --bs-link-color: #33b3b3;
  --bs-link-hover-color: #5bc7c7;
  --shell-surface: radial-gradient(circle at top left, #1f2733 0%, #10151d 65%);
  --shell-sidebar-bg: #008080;
  --shell-sidebar-border: rgba(148, 163, 184, 0.28);
  --shell-sidebar-text: #ffffff;
  --shell-topbar-bg: #008080;
  --shell-topbar-border: rgba(148, 163, 184, 0.24);
}

html,
body {
  min-height: 100%;
}

body.app-shell-body {
  margin: 0;
  background: var(--shell-surface);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-width);
  background: var(--shell-sidebar-bg);
  border-right: 1px solid var(--shell-sidebar-border);
  color: var(--shell-sidebar-text);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.3s ease, transform 0.3s ease;
  z-index: 1040;
}

[data-bs-theme="dark"] .app-sidebar {
  border-color: var(--shell-sidebar-border);
}

.sidebar-head {
  height: var(--topbar-height);
  padding: 0.95rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--shell-sidebar-border);
}

[data-bs-theme="dark"] .sidebar-head {
  border-bottom-color: var(--shell-sidebar-border);
}

.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.brand-icon {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-primary);
  color: #fff;
}

.brand-text {
  white-space: nowrap;
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-y: auto;
}

.sidebar-link,
.sidebar-group-toggle,
.sidebar-sublink {
  border: none;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  width: 100%;
  border-radius: 0.8rem;
  transition: all 0.2s ease;
}

.sidebar-link,
.sidebar-group-toggle {
  padding: 0.7rem 0.8rem;
}

.sidebar-sublink {
  padding: 0.5rem 0.8rem 0.5rem 2.35rem;
  font-size: 0.92rem;
}

.sidebar-link:hover,
.sidebar-group-toggle:hover,
.sidebar-sublink:hover {
  background: rgba(var(--bs-primary-rgb), 0.26);
  color: #fff;
}

.sidebar-link.active,
.sidebar-sublink.active {
  background: var(--bs-black);
  color: #fff;
  box-shadow: 0 8px 22px rgba(var(--bs-primary-rgb), 0.35);
}

.sidebar-group-toggle {
  background: transparent;
  justify-content: space-between;
}

.sidebar-group-toggle.expanded {
  background: rgba(var(--bs-primary-rgb), 0.26);
  color: #fff;
}

.sidebar-chevron {
  transition: transform 0.2s ease;
}

.sidebar-group-toggle.expanded .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.sidebar-submenu.expanded {
  max-height: 240px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 0.85rem 0.95rem;
  border-top: 1px solid var(--shell-sidebar-border);
  font-size: 0.78rem;
  color: #fff;
}

[data-bs-theme="dark"] .sidebar-foot {
  border-top-color: var(--shell-sidebar-border);
}

.app-content {
  flex: 1;
  min-width: 0;
}

.app-topbar {
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--shell-topbar-border);
  background: var(--shell-topbar-bg);
  color: #fff;
  backdrop-filter: blur(8px);
}

[data-bs-theme="dark"] .app-topbar {
  background: var(--shell-topbar-bg);
  border-bottom-color: var(--shell-topbar-border);
}

.app-page-title {
  font-size: 0.98rem;
  margin: 0;
  font-weight: 700;
}

.app-page-subtitle {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.9);
}

.app-topbar .app-page-title,
.app-topbar .app-page-subtitle {
  color: #fff;
}

.app-sidebar .btn-outline-secondary,
.app-topbar .btn-outline-secondary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.72);
}

.app-sidebar .btn-outline-secondary:hover,
.app-sidebar .btn-outline-secondary:focus,
.app-topbar .btn-outline-secondary:hover,
.app-topbar .btn-outline-secondary:focus {
  color: #fff;
  border-color: #fff;
  background: rgba(255, 255, 255, 0.2);
}

.app-main {
  padding: 1rem;
}

.btn-icon {
  width: 2.35rem;
  height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
}

.notification-pill {
  position: absolute;
  top: -0.2rem;
  right: -0.25rem;
  font-size: 0.68rem;
  min-width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #dc3545;
}

.notification-menu {
  min-width: 320px;
  max-width: 360px;
}

.notification-item {
  display: grid;
  grid-template-columns: 1.2rem 1fr;
  column-gap: 0.7rem;
  align-items: start;
  padding-top: 0.72rem;
  padding-bottom: 0.72rem;
}

.notification-item.unread {
  background: rgba(var(--bs-primary-rgb), 0.1);
}

.zip-results {
  border-left: 4px solid #198754;
}

.image-preview-trigger {
  width: 100%;
  border: 0;
  padding: 0;
  cursor: zoom-in;
}

.image-preview-trigger:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.thumbnail-frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thumbnail-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #fff;
}

.duplicate-of-strip {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

[data-bs-theme="dark"] .duplicate-of-strip {
  border-top-color: rgba(148, 163, 184, 0.2);
}

.duplicate-of-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  object-position: center;
  border-radius: 0.35rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  flex-shrink: 0;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(2, 8, 23, 0.86);
}

.gallery-lightbox.show {
  display: flex;
}

.gallery-lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  max-width: min(94vw, 1280px);
  max-height: 90vh;
  width: 100%;
}

.gallery-lightbox-image {
  max-width: 100%;
  max-height: calc(90vh - 2.25rem);
  object-fit: contain;
  border-radius: 0.5rem;
  box-shadow: 0 24px 52px rgba(2, 8, 23, 0.55);
  background: #0b1220;
}

.gallery-lightbox-caption {
  color: #e2e8f0;
  font-size: 0.9rem;
  text-align: center;
  max-width: 95%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.gallery-lightbox-close,
.gallery-lightbox-nav {
  position: absolute;
  border: 0;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(15, 23, 42, 0.72);
  transition: background 0.2s ease;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-nav:hover {
  background: rgba(15, 23, 42, 0.95);
}

.gallery-lightbox-close {
  top: 1rem;
  right: 1rem;
}

.gallery-lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
}

.gallery-lightbox-nav-prev {
  left: 1rem;
}

.gallery-lightbox-nav-next {
  right: 1rem;
}

body.lightbox-open {
  overflow: hidden;
}

.compare-panels {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: center;
  max-width: min(96vw, 1600px);
  max-height: 90vh;
  width: 100%;
}

.compare-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 0;
  min-width: 0;
}

.compare-panel-label {
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.compare-panel-image {
  max-width: 100%;
  max-height: 62vh;
  object-fit: contain;
  border-radius: 0.5rem;
  box-shadow: 0 24px 52px rgba(2, 8, 23, 0.55);
  background: #0b1220;
}

.compare-panel-caption {
  color: #e2e8f0;
  font-size: 0.85rem;
  text-align: center;
  max-width: 95%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.compare-candidate-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

/* The nav buttons reuse .gallery-lightbox-nav for their circular button look, but sit inline
   next to the candidate image here instead of floating absolutely over the whole modal. */
.compare-nav {
  position: static;
  transform: none;
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .compare-panels {
    flex-direction: column;
    align-items: center;
  }

  .compare-panel-image {
    max-height: 38vh;
  }
}

#zip-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#zip-links .zip-link {
  white-space: nowrap;
}

#toast-container>.toast {
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.2);
  border-radius: 0.75rem;
}

.toast-fallback-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.toast-fallback {
  min-width: 260px;
  max-width: 360px;
  border-radius: 0.7rem;
  padding: 0.7rem 0.85rem;
  color: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.25);
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-fallback.hide {
  opacity: 0;
  transform: translateY(-4px);
}

.toast-fallback.success {
  background: #198754;
}

.toast-fallback.info {
  background: var(--bs-primary);
}

.toast-fallback.warning {
  background: #ffc107;
  color: #212529;
}

.toast-fallback.error {
  background: #dc3545;
}

.toast-fallback-title {
  font-weight: 700;
  font-size: 0.86rem;
}

.toast-fallback-message {
  font-size: 0.8rem;
  line-height: 1.35;
}

.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.profile-avatar {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: var(--bs-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

/* .settings-compact .card {
  margin-bottom: 0.75rem !important;
}

.settings-compact .card-header {
  padding: 0.48rem 0.75rem;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.settings-compact .card-body {
  padding: 0.78rem;
}

.settings-compact .form-label {
  font-size: 0.82rem;
  margin-bottom: 0.2rem;
}

.settings-compact .form-text {
  font-size: 0.74rem;
}

.settings-compact .mb-3 {
  margin-bottom: 0.6rem !important;
}

.settings-compact .alert {
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.7rem;
} */

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 1035;
}

body.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-group-label,
body.sidebar-collapsed .sidebar-chevron,
body.sidebar-collapsed .sidebar-footer-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

body.sidebar-collapsed .sidebar-submenu {
  display: none;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 0 15px 40px rgba(15, 23, 42, 0.25);
  }

  body.sidebar-mobile-open .app-sidebar {
    transform: translateX(0);
  }

  body.sidebar-mobile-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-width);
  }

  .notification-menu {
    min-width: 280px;
    max-width: 88vw;
  }

  .gallery-lightbox {
    padding: 1rem 0.7rem;
  }

  .gallery-lightbox-nav {
    width: 2.25rem;
    height: 2.25rem;
  }

  .gallery-lightbox-nav-prev {
    left: 0.55rem;
  }

  .gallery-lightbox-nav-next {
    right: 0.55rem;
  }

  .gallery-lightbox-close {
    top: 0.55rem;
    right: 0.55rem;
  }
}

@media (min-width: 992px) {
  .app-main {
    padding: 1.2rem 1.25rem;
  }
}

/* =========================================
   Modern Settings Page Styles
   ========================================= */
.settings-modern .card {
  border: 1px solid rgba(var(--bs-primary-rgb), 0.12);
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

[data-bs-theme="dark"] .settings-modern .card {
  background: rgba(30, 41, 59, 0.65);
  border-color: rgba(148, 163, 184, 0.15);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

.settings-modern .card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

.settings-modern .card-header {
  background: transparent;
  border-bottom: 1px solid rgba(var(--bs-primary-rgb), 0.1);
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--bs-primary);
}

[data-bs-theme="dark"] .settings-modern .card-header {
  border-bottom-color: rgba(148, 163, 184, 0.15);
}

.settings-modern .card-body {
  padding: 1.25rem;
}

.settings-modern .form-control,
.settings-modern .form-select {
  border-radius: 0.6rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 0.5rem 0.85rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  background-color: rgba(255, 255, 255, 0.7);
}

[data-bs-theme="dark"] .settings-modern .form-control,
[data-bs-theme="dark"] .settings-modern .form-select {
  background-color: rgba(15, 23, 42, 0.4);
  border-color: rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
}

.settings-modern .form-control:focus,
.settings-modern .form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.15);
}

.settings-modern .form-label {
  font-weight: 600;
  color: var(--bs-body-color);
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
}

.settings-modern .form-text {
  font-size: 0.78rem;
  opacity: 0.8;
}

.settings-modern .btn {
  border-radius: 0.6rem;
  padding: 0.5rem 1.25rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.settings-modern .btn-primary {
  background: linear-gradient(135deg, var(--bs-primary) 0%, #006666 100%);
  border: none;
  box-shadow: 0 4px 6px rgba(var(--bs-primary-rgb), 0.25);
}

.settings-modern .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(var(--bs-primary-rgb), 0.35);
  background: linear-gradient(135deg, #009999 0%, var(--bs-primary) 100%);
}

.settings-modern .btn-outline-secondary {
  border-width: 2px;
}

.settings-modern .alert {
  border-radius: 0.6rem;
  border: none;
  padding: 0.85rem 1rem;
}

.settings-modern .alert-info {
  background: rgba(var(--bs-primary-rgb), 0.1);
  color: var(--bs-primary);
}

.settings-modern hr {
  opacity: 0.15;
}

/* Modern ZIP Export Button */
.btn-zip-export {
  position: relative;
  padding: 0.6rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #008080 0%, #006666 100%);
  border: none;
  border-radius: 0.6rem;
  box-shadow: 0 4px 12px rgba(0, 128, 128, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-zip-export::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.btn-zip-export:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 128, 128, 0.45);
  color: #fff;
}

.btn-zip-export:hover::before {
  left: 100%;
}

.btn-zip-export:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 128, 128, 0.3);
}

.btn-zip-export:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}

[data-bs-theme="dark"] .btn-zip-export {
  background: linear-gradient(135deg, #009999 0%, #008080 100%);
  box-shadow: 0 4px 12px rgba(0, 153, 153, 0.4);
}

[data-bs-theme="dark"] .btn-zip-export:hover {
  box-shadow: 0 6px 20px rgba(0, 153, 153, 0.55);
}