/* Animation styles for modal transitions */

/* Modal Animations */
.animate-backdrop-fade-in {
  animation: backdropFadeIn 0.25s ease forwards;
}

.animate-backdrop-fade-out {
  animation: backdropFadeOut 0.2s ease forwards;
}

.animate-modal-scale-in {
  animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.animate-modal-enter {
  animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.animate-modal-exit {
  animation: modalExit 0.2s ease-in forwards;
}

.animate-modal-slide-in-right {
  animation: modalSlideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-modal-exit-right {
  animation: modalExitRight 0.2s ease-in forwards;
}

/* Modal backdrop keyframes */
@keyframes backdropFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* Modal content keyframes */
@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes modalExit {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

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

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

/* Simple fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal slide in from bottom with scale */
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  /* Ensure content isn't hidden behind iOS Safari bottom bar */
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  z-index: 50;
}

/* Position variants */
.modal-overlay--center {
  align-items: center;
  justify-content: center;
}

.modal-overlay--right {
  justify-content: flex-end;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Modal container */
.modal {
  position: relative;
  /* Allow width to be controlled by passed Tailwind classes (e.g., w-[70%], w-3/5) */
  width: auto;
  background-color: var(--bg-primary);
  border-radius: var(--border-radius-xl);
  /* Add a clearer drop shadow for better edge visibility */
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), 0 10px 20px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

/* Right position variant */
.modal--right {
  /* Use dynamic viewport to account for mobile browser UI */
  height: 100dvh;
  border-radius: 0;
}

/* Header */
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-primary);
}

.modal__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.modal__close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  background-color: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--border-radius-md);
  transition: background-color 150ms ease;
}

.modal__close-button:hover {
  background-color: var(--bg-secondary);
}

/* Content */
.modal__content {
  overflow-y: auto;
  /* Fallback */
  max-height: calc(100vh - 16rem);
  /* Prefer dynamic viewport on mobile */
  max-height: calc(100dvh - 16rem);
}

.modal__content--padded {
  padding: var(--space-6);
}

/* Footer */
.modal__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-primary);
  /* Keep footer buttons above iOS Safari toolbar */
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}

/* Animation classes are defined in src/design-system/styles/animations.css */

/* Dark mode forced */
.modal--dark {
  background-color: var(--color-gray-900);
  color: var(--color-white);
}

.modal--dark .modal__header {
  border-bottom-color: var(--color-gray-700);
}

.modal--dark .modal__footer {
  border-top-color: var(--color-gray-700);
}

/* Static mode */
.modal--static {
  position: relative;
  box-shadow: none;
}

/* Additional classes */
.modal-container {
  display: flex;
  flex-direction: column;
}

.modal-contextual {
  /* Contextual modals have automatic height */
  height: auto;
}

/* iOS-specific border radius */
.ios-modal-radius {
  border-radius: var(--border-radius-xl);
}

/* Hide scrollbar */
.scrollbar-hide {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Body scroll lock */
body.modal-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}
:root {
  /* Fallback tokens if not provided elsewhere */
  --glass-bg-light: rgba(255, 255, 255, 0.92);
  --glass-bg-dark: rgba(18, 18, 18, 0.42);
  --glass-stroke-light: rgba(0, 0, 0, 0.06);
  --glass-stroke-dark: rgba(255, 255, 255, 0.12);
  --glass-highlight-light: rgba(255, 255, 255, 0.8);
  --glass-highlight-dark: rgba(255, 255, 255, 0.25);
  --shadow-ambient-light: 0 10px 40px rgba(0, 0, 0, 0.08);
  --shadow-ambient-dark: 0 10px 40px rgba(0, 0, 0, 0.4);
  --txt-primary: #0f172a;
  --txt-secondary: rgba(15, 23, 42, 0.7);
  --ok: #22c55e;
  --bad: #ef4444;
}

/* Remove grain entirely in light mode for a clean white sheet */
.ModalGlass_sheet__xrCXH[data-theme='light']::after {
  content: none;
}

/* Ensure internal panels render white in light mode even without data-theme on the panel */
.ModalGlass_sheet__xrCXH[data-theme='light'] .ModalGlass_panel__\+c9gI {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
}
.ModalGlass_sheet__xrCXH[data-theme='light'] .ModalGlass_divider__8g5\+E {
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.06),
    rgba(0,0,0,0.03)
  );
}

/* Backdrop behind the modal */
.ModalGlass_backdrop__aLOYg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Flex frame controlling alignment (center vs right panel) */
.ModalGlass_frameCenter__-TQN9 {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  min-height: 0; /* allow child to compute height correctly */
}

.ModalGlass_frameRight__RddIU {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  padding: 16px;
  box-sizing: border-box;
  min-height: 0; /* allow child to compute height correctly */
}

/* Glass sheet container */
.ModalGlass_sheet__xrCXH {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto; /* header, body, footer */
  overflow: hidden; /* clip rounded corners; body handles scrolling */
  box-sizing: border-box;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border: 1px solid var(--glass-stroke-light);
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  box-shadow: 
    var(--shadow-ambient-light),
    inset 0 1px 0 var(--glass-highlight-light);
  /* Light mode: subtle translucent white with blur */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.88) 100%);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
  color: #0f172a;
  color: var(--txt-primary);
}

.ModalGlass_sheet__xrCXH[data-theme='dark'] {
  background: linear-gradient(135deg, rgba(28, 28, 30, 0.75) 0%, rgba(18, 18, 20, 0.68) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border: 1px solid var(--glass-stroke-dark);
  backdrop-filter: blur(32px) saturate(150%);
  -webkit-backdrop-filter: blur(32px) saturate(150%);
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.05);
  box-shadow: 
    var(--shadow-ambient-dark),
    inset 0 1px 0 var(--glass-highlight-dark),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.05);
  color: rgba(255,255,255,0.94);
}

/* Light theme explicit override */
.ModalGlass_sheet__xrCXH[data-theme='light'] {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.88) 100%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border: 1px solid var(--glass-stroke-light);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  box-shadow: 
    var(--shadow-ambient-light),
    inset 0 1px 0 var(--glass-highlight-light);
  color: #0f172a;
  color: var(--txt-primary);
}

/* Specular highlight line at top for glass effect */
.ModalGlass_sheet__xrCXH::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 0;
  height: 1px;
  border-radius: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 5%, rgba(255, 255, 255, 0.4) 50%, transparent 95%);
  opacity: 0;
  z-index: 10;
}

.ModalGlass_sheet__xrCXH[data-theme='dark']::before {
  opacity: 0.5;
}

/* Subtle inner glow */
.ModalGlass_sheet__xrCXH::after {
  content: none;
}

/* Sticky header/footer */
.ModalGlass_header__UjxGU {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 5; /* ensure above scrolling content */
  padding: 16px 24px;
  /* Glass header with subtle blur */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.75) 100%);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  /* subtle divider below header */
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.ModalGlass_sheet__xrCXH[data-theme='dark'] .ModalGlass_header__UjxGU {
  background: linear-gradient(180deg, rgba(28, 28, 30, 0.85) 0%, rgba(28, 28, 30, 0.7) 100%);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ModalGlass_title__5NA9N {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
  color: #0f172a;
  color: var(--txt-primary);
}

.ModalGlass_sheet__xrCXH[data-theme='dark'] .ModalGlass_title__5NA9N {
  color: rgba(255,255,255,0.92);
}

.ModalGlass_content__nwAeb {
  /* Allow body to take remaining space; scroll happens on the sheet */
  flex: 1 1 auto;
  min-height: 0;
  /* extra bottom padding so last fields aren't hidden behind sticky footer */
  padding: 24px 24px calc(96px + env(safe-area-inset-bottom, 0px)); /* footer height + iOS inset */
  scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); /* keep focused inputs above footer */
  scroll-padding-top: 64px; /* keep first focus below header */
  overflow-y: auto; /* body is the scroll container */
  -webkit-overflow-scrolling: touch; /* smooth iOS scrolling */
  overscroll-behavior: contain;
  position: relative;
}
.ModalGlass_contentNoPad__Om6Sa {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 24px calc(96px + env(safe-area-inset-bottom, 0px));
  scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  scroll-padding-top: 64px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  position: relative;
}

/* Compact content for short, centered modals to avoid excessive empty space */
.ModalGlass_contentCompact__iCyxF {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px 24px calc(72px + env(safe-area-inset-bottom, 0px)); /* smaller bottom padding than full content */
  scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  scroll-padding-top: 56px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  position: relative;
}

.ModalGlass_footer__05Um- {
  position: -webkit-sticky;
  position: sticky;
  bottom: 0;
  z-index: 5; /* ensure above scrolling content */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 24px;
  /* Browser default: give a comfortable cushion below footer */
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  /* Glass footer with subtle blur */
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.75) 100%);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  /* subtle divider above footer */
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.ModalGlass_sheet__xrCXH[data-theme='dark'] .ModalGlass_footer__05Um- {
  background: linear-gradient(0deg, rgba(28, 28, 30, 0.85) 0%, rgba(28, 28, 30, 0.7) 100%);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Size presets (used for right-positioned wide modals) */
.ModalGlass_width50__B-oiQ { width: min(960px, 50vw); }
.ModalGlass_width60__HpqZE { width: min(1056px, 60vw); }
.ModalGlass_width70__0msl\+ { width: min(1200px, 70vw); }
.ModalGlass_full__aZadK    { width: 100%; max-width: 100%; }
.ModalGlass_contextual__mFSDV { width: 100%; max-width: 640px; }

/* Tablet responsive sizing (641px to 1023px) */
@media (min-width: 641px) and (max-width: 1023px) {
  .ModalGlass_width50__B-oiQ,
  .ModalGlass_width60__HpqZE,
  .ModalGlass_width70__0msl\+ {
    width: 90vw;
    max-width: 90vw;
  }
  
  .ModalGlass_frameCenter__-TQN9,
  .ModalGlass_frameRight__RddIU {
    padding: 12px;
  }
}
.ModalGlass_heightScreen__aKWvj {
  /* Fill the padded frame completely and never exceed it */
  height: 100vh;     /* fallback */
  max-height: 100vh; /* fallback */
  height: 100dvh;    /* iOS/modern browsers */
  max-height: 100dvh;
  /* Account for frame padding (16px top + 16px bottom) in browser */
  height: calc(100dvh - 32px);
  max-height: calc(100dvh - 32px);
}

/* Auto-height for contextual, center modals: size to content with a comfortable cap */
.ModalGlass_heightAuto__AsElO {
  height: auto;
  /* Ensure the modal never exceeds the viewport minus the frame padding */
  max-height: min(90dvh, calc(100dvh - 32px - env(safe-area-inset-bottom, 0px)));
}

/* Full height for settings and other content-heavy modals */
.ModalGlass_heightFull__LUEZj {
  height: min(95dvh, calc(100dvh - 32px - env(safe-area-inset-bottom, 0px)));
  max-height: min(95dvh, calc(100dvh - 32px - env(safe-area-inset-bottom, 0px)));
}

/* Mobile full-screen override for ALL modals */
@media (max-width: 640px) {
  .ModalGlass_frameCenter__-TQN9,
  .ModalGlass_frameRight__RddIU {
    padding: 0;          /* remove margins around the modal */
  }
  .ModalGlass_sheet__xrCXH {
    width: 100vw;        /* full width */
    height: 100vh;       /* fallback */
    height: 100dvh;      /* full height accounting for dynamic viewport */
    max-width: none;
    max-height: none;
    border-radius: 0;    /* edge-to-edge */
  }
  
  /* Reduce padding on mobile for better space usage */
  .ModalGlass_content__nwAeb,
  .ModalGlass_contentNoPad__Om6Sa {
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    scroll-padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
  
  .ModalGlass_header__UjxGU,
  .ModalGlass_footer__05Um- {
    padding-left: 16px;
    padding-right: 16px;
  }
  .ModalGlass_footer__05Um- {
    /* Mobile browser: same comfortable spacing */
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
}

/* PWA standalone: tighter bottom spacing (cap the safe-area) */
@media (display-mode: standalone) {
  .ModalGlass_footer__05Um- {
    /* Cap the bottom inset so footer isn't overly elevated in PWA */
    padding-bottom: clamp(8px, env(safe-area-inset-bottom, 0px), 16px);
  }
  .ModalGlass_content__nwAeb, .ModalGlass_contentNoPad__Om6Sa {
    /* Keep scroll affordance but reduce excess space in PWA */
    padding-bottom: calc(64px + clamp(8px, env(safe-area-inset-bottom, 0px), 16px));
    scroll-padding-bottom: calc(64px + clamp(8px, env(safe-area-inset-bottom, 0px), 16px));
  }
  /* PWA: use full dynamic viewport height (no browser toolbar) */
  .ModalGlass_heightScreen__aKWvj {
    height: 100dvh;
    max-height: 100dvh;
  }
}

/* Panels inside modal (sections) */
.ModalGlass_panel__\+c9gI {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.4) 100%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.ModalGlass_sheet__xrCXH[data-theme='dark'] .ModalGlass_panel__\+c9gI {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 
    0 2px 12px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.ModalGlass_panel__\+c9gI[data-theme='light'] {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.4) 100%);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Etched divider (can be added to rows inside panels) */
.ModalGlass_divider__8g5\+E {
  height: 1px;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.10),
    rgba(255,255,255,0.04)
  );
}

/* Image scrims */
.ModalGlass_scrimTop__sWtca {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 96px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0));
  pointer-events: none;
}

.ModalGlass_scrimBottom__A6foK {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 160px;
  background: linear-gradient(0deg, rgba(0,0,0,0.55), rgba(0,0,0,0));
  pointer-events: none;
}

/* Reduced motion handling for entrance/exit animations; JS controls classes */
@media (prefers-reduced-motion: reduce) {
  .ModalGlass_reduceMotion__fQA3H {
    animation: none !important;
    transition: none !important;
  }
}

/* BottomSheet backdrop */
.bottom-sheet__backdrop {
  position: fixed;
  inset: 0;
  z-index: 70000;
  display: flex;
  min-height: 100vh;
  width: 100%;
  align-items: flex-end;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
}

@media (min-width: 640px) {
  .bottom-sheet__backdrop {
    align-items: center;
  }
}

/* BottomSheet content */
.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70001;
  width: 100%;
  border-top-left-radius: var(--border-radius-xl);
  border-top-right-radius: var(--border-radius-xl);
  background-color: var(--bg-primary);
  padding: var(--space-3);
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  transition: transform 500ms ease-out;
}

.bottom-sheet--dragging {
  transition: none;
}

.bottom-sheet--visible {
  transform: translateY(0);
}

.bottom-sheet--hidden {
  transform: translateY(100%);
}

/* Drag area */
.bottom-sheet__drag-area {
  cursor: grab;
  touch-action: none;
  padding-bottom: var(--space-3);
}

.bottom-sheet__drag-area:active {
  cursor: grabbing;
}

/* Grabber handle */
.bottom-sheet__grabber {
  margin: 0 auto var(--space-3);
  height: 0.25rem;
  width: 2.5rem;
  border-radius: var(--border-radius-full);
  background-color: var(--color-gray-300);
}

.dark .bottom-sheet__grabber {
  background-color: var(--color-gray-700);
}

/* Header */
.bottom-sheet__header {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-1);
}

.bottom-sheet__title {
  flex-grow: 1;
  text-align: center;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

/* Dropdown container */
.dropdown {
  position: relative;
}

.dropdown__trigger {
  cursor: pointer;
}

/* Desktop dropdown menu */
.dropdown__menu {
  position: absolute;
  z-index: 50;
  margin-top: var(--space-1);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-primary);
  background-color: var(--bg-primary);
  padding: var(--space-1) 0;
  box-shadow: var(--shadow-lg);
  overflow-x: hidden;
  display: block;
}

/* Width variants */
.dropdown__menu--auto {
  min-width: 180px;
}

.dropdown__menu--sm {
  width: 12rem;
}

.dropdown__menu--md {
  width: 14rem;
}

.dropdown__menu--lg {
  width: 16rem;
}

.dropdown__menu--xl {
  width: 18rem;
}

.dropdown__menu--full {
  width: 100%;
}

/* Alignment variants */
.dropdown__menu--left {
  left: 0;
}

.dropdown__menu--right {
  right: 0;
}

.dropdown__menu--center {
  left: 50%;
  transform: translateX(-50%);
}

/* Dropdown Item */
.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  text-align: left;
  transition: background-color 150ms ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: none;
  background: transparent;
  cursor: pointer;
}

.dropdown-item--enabled {
  color: var(--text-secondary);
}

.dropdown-item--enabled:hover {
  background-color: var(--bg-secondary);
}

.dropdown-item--disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.dropdown-item__icon {
  margin-right: var(--space-2);
  flex-shrink: 0;
}

.dropdown-item__content {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

/* Dropdown Divider */
.dropdown-divider {
  margin: var(--space-1) 0;
  border-top: 1px solid var(--border-primary);
}

/* Mobile styles */
.dropdown--mobile .dropdown__content {
  padding: var(--space-1) var(--space-2);
  gap: var(--space-2);
}

.dropdown--mobile .dropdown__cancel-button {
  margin-top: var(--space-3);
  display: block;
  width: 100%;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--color-gray-700);
  background-color: var(--color-black);
  padding: var(--space-3) var(--space-4);
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-gray-300);
  cursor: pointer;
  transition: opacity 150ms ease;
}

.dropdown--mobile .dropdown__cancel-button:hover {
  opacity: 0.9;
}

/* Hide scrollbar */
.dropdown__menu {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dropdown__menu::-webkit-scrollbar {
  display: none;
}

.dropdown {
  position: relative;
  width: 100%;
  overflow: visible;
}

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

.dropdown__trigger {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--border-radius-lg);
  background-color: transparent;
  /* Subtle inner stroke to read on glass */
  box-shadow: inset 0 0 0 1px var(--border-primary);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
  position: relative;
  overflow: hidden;
}

.dropdown__trigger:hover:not(:disabled) {
  box-shadow: inset 0 0 0 1px var(--border-secondary);
}

.dropdown__trigger:focus {
  outline: none;
  border-color: transparent;
  /* Use info color to enforce blue ring */
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), inset 0 0 0 1px var(--color-info-500);
}

.dropdown__trigger:disabled {
  cursor: not-allowed;
  background-color: var(--bg-secondary);
}

.dropdown__trigger--open {
  border-color: transparent;
  /* Use info color to enforce blue ring when open */
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), inset 0 0 0 1px var(--color-info-500);
}

.dropdown__label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
}

.dropdown__value {
  flex: 1 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown__placeholder {
  color: var(--text-tertiary);
}

.dropdown__chevron {
  margin-left: var(--space-2);
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  transition: transform 150ms ease;
  color: var(--text-secondary);
}

.dropdown__chevron--open {
  transform: rotate(180deg);
}

/* Ensure SVG chevron stays within bounds */
.dropdown__trigger svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

/* Dropdown menu (portal) */
.dropdown__menu {
  position: fixed;
  z-index: 60001; /* Above modal z-index */
  max-height: 300px;
  overflow: auto;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  overscroll-behavior: contain;
}

.dropdown__menu--bottom {
  margin-top: var(--space-1);
}

.dropdown__menu--top {
  margin-bottom: var(--space-1);
}

.dropdown__search {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  padding: var(--space-2);
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-primary);
  margin-bottom: var(--space-1);
}

.dropdown__search-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius-md);
  background-color: var(--bg-primary);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.dropdown__search-input::placeholder {
  color: var(--text-tertiary);
}

.dropdown__search-input:focus {
  outline: none;
  border-color: var(--color-info-500);
}

.dropdown__option {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  background-color: transparent;
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: background-color 150ms ease;
  min-height: var(--pwa-touch-target-min);
}

.dropdown__option:hover {
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius-md) !important;
}

.dropdown__option:focus {
  outline: none;
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius-md) !important;
}

.dropdown__option--selected {
  /* Blue selection in light theme */
  background-color: var(--color-info-50);
  color: var(--color-info-700);
}

.dark .dropdown__option--selected {
  /* Deep blue selection in dark theme */
  background-color: var(--color-info-900);
  color: var(--color-info-200);
}

.dropdown__option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropdown__no-options {
  padding: var(--space-3);
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--font-size-sm);
}

/* Divider for grouped options */
.dropdown__divider {
  height: 1px;
  margin: var(--space-1) 0;
  background-color: var(--border-primary);
}

/* Error state */
.dropdown--error .dropdown__trigger {
  border-color: var(--color-error);
}

.dropdown__error {
  margin-top: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--color-error);
}

.dropdown__required {
  color: var(--color-error);
  margin-left: var(--space-1);
}

/* Size variants */
.dropdown__trigger--sm {
  height: 2rem;
  font-size: var(--font-size-sm);
  padding: 0 var(--space-2);
}

.dropdown__trigger--md {
  height: 2.5rem;
  font-size: var(--font-size-base);
  padding: 0 var(--space-3);
}

.dropdown__trigger--lg {
  height: 3rem;
  font-size: var(--font-size-lg);
  padding: 0 var(--space-4);
}

/* Variant styles */
.dropdown__trigger--primary {
  border-color: var(--color-primary-300);
  background-color: var(--color-primary-50);
  color: var(--color-primary-900);
}

.dark .dropdown__trigger--primary {
  border-color: var(--color-primary-600);
  background-color: rgba(59, 130, 246, 0.1);
  background-color: var(--color-info-500-10, rgba(59, 130, 246, 0.1));
  color: var(--color-primary-100);
}

.dropdown__trigger--danger {
  border-color: var(--color-error-300);
  background-color: var(--color-error-50);
  color: var(--color-error-900);
}

.dark .dropdown__trigger--danger {
  border-color: var(--color-error-600);
  background-color: var(--color-error-500-10);
  color: var(--color-error-100);
}

/* Auto width */
.dropdown__trigger--auto-width {
  width: auto;
}

/* Mobile clamping: keep menu within viewport and align with trigger width */
@media (max-width: 640px) {
  .dropdown__menu {
    max-width: calc(100vw - 16px); /* 8px gutters on both sides */
    border-radius: 12px;
  }
}

.form-field {
  width: 100%;
}

.form-field--error {
  border-color: var(--color-error);
}

.form-field__inline-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.form-field__input-wrapper {
  flex: 1 1;
}

.form-field__additional-content {
  margin-top: var(--space-2);
  display: flex;
  justify-content: flex-end;
}

.form-field__error {
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-error);
}

.color-category {
  margin-bottom: var(--space-8);
}

.color-category__title {
  margin-bottom: var(--space-4);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
}

.color-category__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: var(--space-4);
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .color-category__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .color-category__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.component-section {
  margin-bottom: var(--space-12);
  border-radius: var(--border-radius-lg);
  background-color: var(--bg-primary);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
}

.component-section__title {
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-primary);
  padding-bottom: var(--space-2);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.settings-panel {
  margin-bottom: var(--space-6);
}

.settings-panel__title {
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.settings-panel__description {
  margin-bottom: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
}

.settings-panel__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.invoice-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-primary);
  background-color: var(--bg-primary);
}

.invoice-card__header {
  border-bottom: 1px solid var(--border-primary);
  padding: var(--space-3);
}

.invoice-card__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.invoice-card__financial {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: var(--space-3);
}

.invoice-card__metric {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.invoice-card__metric--bordered {
  border-left: 1px solid var(--border-primary);
  border-right: 1px solid var(--border-primary);
}

.invoice-card__metric-label {
  margin-bottom: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

.invoice-card__metric-value {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.invoice-card__metric-value--profit {
  color: var(--color-success-500);
}

.invoice-card__metric-value--loss {
  color: var(--color-error);
}

.invoice-header {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: var(--space-4);
  background-color: var(--bg-secondary);
  cursor: pointer;
  transition: background-color 150ms ease;
}

.invoice-header:hover {
  background-color: var(--bg-tertiary);
}

@media (min-width: 640px) {
  .invoice-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5);
  }
}

/* Left side content */
.invoice-header__left {
  display: flex;
  min-width: 0;
  flex: 1 1;
  align-items: center;
  gap: var(--space-3);
}

.invoice-header__expand-icon {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.invoice-header__info {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.invoice-header__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.invoice-header__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* Right side content */
.invoice-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Financial summary */
.invoice-header__financial {
  display: none;
  align-items: center;
  gap: var(--space-6);
}

@media (min-width: 640px) {
  .invoice-header__financial {
    display: flex;
  }
}

.invoice-header__financial-mobile {
  display: flex;
  text-align: right;
}

@media (min-width: 640px) {
  .invoice-header__financial-mobile {
    display: none;
  }
}

.invoice-header__metric {
  text-align: right;
}

.invoice-header__metric-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.invoice-header__metric-value {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.invoice-header__metric-value--profit {
  color: var(--color-success-500);
}

.invoice-header__metric-value--loss {
  color: var(--color-error);
}

/* Action buttons */
.invoice-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  border-left: 1px solid var(--border-primary);
  padding-left: var(--space-4);
}

.invoice-header__action-button {
  padding: var(--space-2);
  color: var(--text-secondary);
}

.invoice-header__action-button:hover {
  color: var(--text-primary);
}

.invoice-header__action-button--delete:hover {
  color: var(--color-error);
}

.confirm-dialog__message {
  color: var(--text-secondary);
}

.filter-menu {
  position: relative;
  display: inline-block;
}

.filter-menu__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-3);
  border: none;
  border-radius: var(--border-radius-lg);
  background-color: transparent;
  box-shadow: inset 0 0 0 1px var(--border-primary);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}

.filter-menu__trigger:hover {
  box-shadow: inset 0 0 0 1px var(--border-secondary);
}

.filter-menu__trigger:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), inset 0 0 0 1px var(--color-info-500);
}

.filter-menu__trigger--open {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), inset 0 0 0 1px var(--color-info-500);
}

.filter-menu__trigger-icon {
  width: 18px;
  height: 18px;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.filter-menu__trigger-text {
  font-weight: 500;
}

.filter-menu__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background-color: var(--color-info-500);
  color: white;
  font-size: 11px;
  font-weight: 600;
}

.filter-menu__chevron {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  transition: transform 150ms ease;
}

.filter-menu__chevron--open {
  transform: rotate(180deg);
}

/* Dropdown Panel - Light Mode */
.filter-menu__panel {
  position: fixed;
  z-index: 60001;
  min-width: 300px;
  max-width: 340px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 4px 24px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.08);
  overflow: visible;
}

/* Dropdown Panel - Dark Mode */
[data-theme="dark"] .filter-menu__panel,
.dark .filter-menu__panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(28, 28, 32, 0.85);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Panel Header with Clear button - Light Mode */
.filter-menu__panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background-color: rgba(0, 0, 0, 0.02);
}

/* Panel Header - Dark Mode */
[data-theme="dark"] .filter-menu__panel-header,
.dark .filter-menu__panel-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background-color: rgba(255, 255, 255, 0.03);
}

.filter-menu__panel-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.filter-menu__clear-btn {
  padding: var(--space-1) var(--space-2);
  border: none;
  border-radius: var(--border-radius-sm);
  background-color: transparent;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-info-500);
  cursor: pointer;
  transition: background-color 150ms ease;
}

.filter-menu__clear-btn:hover {
  background-color: var(--color-info-50);
}

.dark .filter-menu__clear-btn:hover {
  background-color: var(--color-info-900);
}

.filter-menu__clear-btn:disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.filter-menu__clear-btn:disabled:hover {
  background-color: transparent;
}

/* Sections - Light Mode */
.filter-menu__section {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.filter-menu__section:last-child {
  border-bottom: none;
}

/* Sections - Dark Mode */
[data-theme="dark"] .filter-menu__section,
.dark .filter-menu__section {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.filter-menu__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 150ms ease;
  min-height: 52px;
  gap: var(--space-3);
}

/* Section Header Hover - Light Mode */
.filter-menu__section-header:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.filter-menu__section-header:focus {
  outline: none;
  background-color: rgba(0, 0, 0, 0.03);
}

/* Section Header Hover - Dark Mode */
[data-theme="dark"] .filter-menu__section-header:hover,
.dark .filter-menu__section-header:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .filter-menu__section-header:focus,
.dark .filter-menu__section-header:focus {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Section Label - Light Mode */
.filter-menu__section-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  min-width: 90px;
  text-align: left;
}

/* Section Label - Dark Mode */
[data-theme="dark"] .filter-menu__section-label,
.dark .filter-menu__section-label {
  color: rgba(255, 255, 255, 0.5);
}

.filter-menu__section-value {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  flex: 1 1;
  justify-content: flex-end;
  min-width: 0;
}

.filter-menu__section-value-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

.filter-menu__section-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  transition: transform 150ms ease;
  flex-shrink: 0;
}

.filter-menu__section-chevron--open {
  transform: rotate(180deg);
}

/* Section Content - Light Mode */
.filter-menu__section-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 200ms ease-out;
  background-color: rgba(0, 0, 0, 0.02);
}

/* Section Content - Dark Mode */
[data-theme="dark"] .filter-menu__section-content,
.dark .filter-menu__section-content {
  background-color: rgba(0, 0, 0, 0.25);
}

.filter-menu__section-inner {
  overflow: hidden;
}

.filter-menu__section-content--open {
  grid-template-rows: 1fr;
}

.filter-menu__options {
  padding: var(--space-2);
}

.filter-menu__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background-color: transparent;
  border: none;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 150ms ease;
  text-align: left;
  min-height: 40px;
}

/* Option Hover - Light Mode */
.filter-menu__option:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.filter-menu__option:focus {
  outline: none;
  background-color: rgba(0, 0, 0, 0.04);
}

/* Option Hover - Dark Mode */
[data-theme="dark"] .filter-menu__option:hover,
.dark .filter-menu__option:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .filter-menu__option:focus,
.dark .filter-menu__option:focus {
  background-color: rgba(255, 255, 255, 0.08);
}

.filter-menu__option--selected {
  background-color: var(--color-info-50);
  color: var(--color-info-700);
}

.dark .filter-menu__option--selected {
  background-color: var(--color-info-900);
  color: var(--color-info-200);
}

.filter-menu__option-check {
  width: 16px;
  height: 16px;
  color: var(--color-info-500);
  flex-shrink: 0;
}

/* Action Button - Light Mode */
.filter-menu__option--action {
  color: var(--color-info-500);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin-top: var(--space-1);
  padding-top: var(--space-3);
}

.filter-menu__option--action:hover {
  background-color: rgba(59, 130, 246, 0.08);
}

/* Action Button - Dark Mode */
[data-theme="dark"] .filter-menu__option--action,
.dark .filter-menu__option--action {
  border-top-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .filter-menu__option--action:hover,
.dark .filter-menu__option--action:hover {
  background-color: rgba(59, 130, 246, 0.15);
}

/* Sort Direction Section */
.filter-menu__direction-section {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: var(--space-2);
  margin-top: var(--space-1);
}

[data-theme="dark"] .filter-menu__direction-section,
.dark .filter-menu__direction-section {
  border-top-color: rgba(255, 255, 255, 0.08);
}

/* Sort Direction Label - Light Mode */
.filter-menu__direction-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(0, 0, 0, 0.5);
  padding: 0 var(--space-2) var(--space-1) var(--space-2);
}

/* Sort Direction Label - Dark Mode */
[data-theme="dark"] .filter-menu__direction-label,
.dark .filter-menu__direction-label {
  color: rgba(255, 255, 255, 0.5);
}

/* Sort Direction Toggle - Light Mode */
.filter-menu__direction-toggle {
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-2) var(--space-2) var(--space-2);
  background-color: transparent;
}


/* Direction Button - Light Mode */
.filter-menu__direction-btn {
  flex: 1 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius-md);
  background-color: rgba(255, 255, 255, 0.6);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  min-height: 40px;
}

.filter-menu__direction-btn:hover {
  border-color: rgba(0, 0, 0, 0.2);
  background-color: rgba(255, 255, 255, 0.8);
  color: var(--text-primary);
}

/* Direction Button - Dark Mode */
[data-theme="dark"] .filter-menu__direction-btn,
.dark .filter-menu__direction-btn {
  border-color: rgba(255, 255, 255, 0.12);
  background-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .filter-menu__direction-btn:hover,
.dark .filter-menu__direction-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background-color: rgba(255, 255, 255, 0.1);
}

.filter-menu__direction-btn--active {
  border-color: var(--color-info-500);
  background-color: var(--color-info-50);
  color: var(--color-info-700);
}

[data-theme="dark"] .filter-menu__direction-btn--active,
.dark .filter-menu__direction-btn--active {
  background-color: rgba(59, 130, 246, 0.25);
  border-color: var(--color-info-500);
  color: var(--color-info-200);
}

.filter-menu__direction-icon {
  font-size: 16px !important;
  width: 16px;
  height: 16px;
  line-height: 1;
}

/* View Mode Toggle */
.filter-menu__view-toggle {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-2);
}

/* View Button - Light Mode */
.filter-menu__view-btn {
  flex: 1 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius-md);
  background-color: rgba(255, 255, 255, 0.6);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  min-height: 56px;
}

.filter-menu__view-btn:hover {
  border-color: rgba(0, 0, 0, 0.2);
  background-color: rgba(255, 255, 255, 0.8);
  color: var(--text-primary);
}

/* View Button - Dark Mode */
[data-theme="dark"] .filter-menu__view-btn,
.dark .filter-menu__view-btn {
  border-color: rgba(255, 255, 255, 0.12);
  background-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .filter-menu__view-btn:hover,
.dark .filter-menu__view-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background-color: rgba(255, 255, 255, 0.1);
}

.filter-menu__view-btn--active {
  border-color: var(--color-info-500);
  background-color: var(--color-info-50);
  color: var(--color-info-700);
}

[data-theme="dark"] .filter-menu__view-btn--active,
.dark .filter-menu__view-btn--active {
  background-color: rgba(59, 130, 246, 0.25);
  border-color: var(--color-info-500);
  color: var(--color-info-200);
}

.filter-menu__view-icon {
  font-size: 20px;
}

/* Mobile Styles */
@media (max-width: 640px) {
  /* Icon-only trigger button on mobile */
  .filter-menu__trigger {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .filter-menu__trigger-icon {
    margin: 0;
  }

  .filter-menu__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    font-size: 10px;
  }

  .filter-menu {
    position: relative;
  }

  .filter-menu__panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-width: 100%;
    min-width: 100%;
    border-radius: 16px 16px 0 0;
  }

  .filter-menu__section-value-text {
    max-width: 180px;
  }

  /* Add safe area padding for iOS */
  .filter-menu__panel::after {
    content: '';
    display: block;
    height: env(safe-area-inset-bottom, 0);
  }
}

/* Backdrop for mobile */
.filter-menu__backdrop {
  display: none;
}

@media (max-width: 640px) {
  .filter-menu__backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 60000;
  }
}

