/* Token-driven overrides (keep the “plant-friendly” look, but derive from design tokens). */
:root {
  /* Background + surfaces lean green (reduce “big white” feel). */
  --bg-soft: linear-gradient(
    180deg,
    rgb(var(--mdc-color-background)) 0%,
    rgb(var(--mdc-color-primary-container)) 55%,
    rgb(var(--mdc-color-background)) 100%
  );

  /* Surfaces should track tokens (dark mode will switch tokens). */
  --surface: rgb(var(--mdc-color-surface));
  --surface-90: rgb(var(--mdc-color-surface) / 0.90);
  --surface-80: rgb(var(--mdc-color-surface) / 0.80);
  --surface-70: rgb(var(--mdc-color-surface) / 0.70);
  --surface-60: rgb(var(--mdc-color-surface) / 0.60);
  --surface-50: rgb(var(--mdc-color-surface) / 0.50);

  /* Safe-area insets (iOS notch + home indicator). */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html.dark {
  --bg-soft: linear-gradient(
    180deg,
    rgb(var(--mdc-color-background)) 0%,
    rgb(var(--mdc-color-surface)) 55%,
    rgb(var(--mdc-color-background)) 100%
  );
}

body {
  background-image: var(--bg-soft);
}

/* Toggle switch fallback when peer styles fail. */
.toggle-switch .toggle-track {
  transition: background-color var(--mdc-motion-duration-medium) var(--mdc-motion-easing-standard);
}

.toggle-switch .toggle-thumb {
  transform: translateX(0);
  transition: transform var(--mdc-motion-duration-medium) var(--mdc-motion-easing-standard);
}

.toggle-switch input:checked ~ .toggle-track {
  background-color: #059669; /* emerald-600 */
}

.toggle-switch input:checked ~ .toggle-thumb {
  transform: translateX(1.25rem);
}

/* Prevent background scroll when mobile sheet is open. */
body.mobile-sheet-open {
  overflow: hidden;
}

/* Mobile staff shell spacing: ensure content isn't hidden behind bottom tab bar. */
@media (max-width: 639px) {
  body.has-mobile-tabbar main > div {
    padding-bottom: calc(6.25rem + var(--safe-bottom));
  }

  /* Keep footer above the fixed bottom tab bar. */
  body.has-mobile-tabbar footer {
    padding-bottom: calc(6.25rem + var(--safe-bottom));
  }

  /* On mobile, use only bottom tab bar; hide the hamburger and side drawer. */
  .mobile-nav-sticky,
  .mobile-nav-drawer {
    display: none !important;
  }

  /* Mobile typography improvements for readability */
  body {
    font-size: 15px; /* was 14px */
    line-height: 1.5;
  }

  .text-sm {
    font-size: 0.8125rem; /* 13px */
  }

  .text-xs {
    font-size: 0.6875rem; /* 11px */
  }

  /* Buttons always 14px minimum; ensure 44px minimum touch target */
  button,
  .btn,
  a.inline-flex {
    font-size: 0.875rem; /* 14px */
  }

  /* Touch targets: minimum 44px height for tap areas (WCAG 2.5.5) */
  button:not(.mobile-tab):not(.mobile-sheet-close),
  .btn {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
  }

  /* Action buttons in tables/cards: ensure tappable */
  main td button,
  main td a.inline-flex,
  main .mobile-card-actions button,
  main .mobile-card-actions a.inline-flex {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 0.75rem;
  }

  main .mobile-card-actions .flex-1 {
    min-width: 0;
  }

  /* Form UX (Task 3.4): improved spacing + touch targets */
  .space-y-1\.5 > * + * {
    margin-top: 0.625rem; /* 10px instead of 6px */
  }

  .space-y-4 > * + * {
    margin-top: 1.25rem; /* 20px instead of 16px */
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="search"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom */
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }
}

/* Mobile bottom tab bar primitives (token-driven). */
.mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  padding-bottom: var(--safe-bottom);
  background-color: var(--surface);
  border-top: 2px solid rgb(var(--mdc-color-outline));
  box-shadow: 0 -4px 16px -8px rgb(0 0 0 / 0.15);
}

.mobile-tabbar-inner {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.25rem;
  max-width: 48rem;
  margin: 0 auto;
  padding: 0.5rem 0.5rem;
}

.mobile-tab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  min-height: 2.75rem; /* 44px minimum touch target */
  padding: 0.375rem 0.25rem;
  border-radius: 0.75rem;
  font-weight: 600;
  color: rgb(var(--mdc-color-on-surface-muted));
  background: transparent;
  border: 1px solid transparent;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-tab:active {
  transform: scale(0.95);
}

.mobile-tab:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgb(var(--mdc-focus-ring) / 0.25);
}

.mobile-tab.is-active {
  color: rgb(var(--mdc-color-primary));
  background-color: rgb(var(--mdc-color-primary-container) / 0.75);
  border-color: rgb(var(--mdc-color-primary) / 0.30);
  font-weight: 700;
  transform: scale(1.02);
  box-shadow: 0 4px 12px -2px rgb(var(--mdc-color-primary) / 0.25);
}

.mobile-tab.is-active:active {
  transform: scale(0.98);
}

.mobile-tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-tab-label {
  font-size: 0.6875rem;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

/* Mobile “More” sheet. */
.mobile-sheet {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.mobile-sheet:not(.hidden) {
  pointer-events: auto;
}

.mobile-sheet.hidden {
  display: none;
}

.mobile-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 0.45);
  animation: mobile-sheet-backdrop-in 200ms ease-out;
}

.mobile-sheet-panel {
  position: relative;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  border-top-left-radius: 1.25rem;
  border-top-right-radius: 1.25rem;
  border: 1px solid rgb(var(--mdc-color-outline));
  border-bottom: 0;
  background-color: var(--surface);
  padding-bottom: calc(0.75rem + var(--safe-bottom));
  box-shadow: 0 20px 70px -40px rgb(0 0 0 / 0.45);
  animation: mobile-sheet-slide-up 250ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes mobile-sheet-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes mobile-sheet-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.5rem 1rem;
  border-bottom: 1px solid rgb(var(--mdc-color-outline));
}

.mobile-sheet-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  color: rgb(var(--mdc-color-on-surface-muted));
}

.mobile-sheet-close:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.4);
  color: rgb(var(--mdc-color-on-surface));
}

.mobile-sheet-body {
  padding: 0.75rem 1rem;
}

.mobile-sheet-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgb(var(--mdc-color-outline));
  background-color: rgb(var(--mdc-color-background) / 0.35);
  padding: 0.625rem 0.75rem;
  font-weight: 600;
  color: rgb(var(--mdc-color-on-surface));
  transition: background-color 150ms ease, border-color 150ms ease;
}

.mobile-sheet-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgb(var(--mdc-color-on-surface-muted));
}

.mobile-sheet-link:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.45);
  border-color: rgb(var(--mdc-color-primary) / 0.20);
}

.mobile-sheet-link:hover .mobile-sheet-link-icon {
  color: rgb(var(--mdc-color-primary));
}

/* Floating Action Button (FAB) for mobile */
.fab {
  position: fixed;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem; /* 56px */
  height: 3.5rem; /* 56px */
  border-radius: 9999px;
  background-color: rgb(var(--mdc-color-primary));
  color: white;
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.25), 0 8px 10px -6px rgb(0 0 0 / 0.25);
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.fab:hover {
  box-shadow: 0 20px 35px -8px rgb(0 0 0 / 0.35), 0 10px 15px -8px rgb(0 0 0 / 0.35);
  transform: scale(1.05);
}

.fab:active {
  transform: scale(0.95);
}

/* Position FAB above mobile tabs + safe area */
@media (max-width: 639px) {
  .fab {
    bottom: calc(7rem + var(--safe-bottom)); /* 112px tabs + iOS indicator */
    right: 1rem;
  }
}

/* Hide FAB on desktop (sm breakpoint and up) */
@media (min-width: 640px) {
  .fab {
    display: none;
  }
}

/* List filter bar: token-based primary button and clear button */
.list-filter-submit {
  background-color: rgb(var(--mdc-color-primary));
  border-color: rgb(var(--mdc-color-primary));
  color: white;
}
.list-filter-submit:hover {
  opacity: 0.95;
}
.list-filter-submit:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--mdc-focus-ring) / 0.4);
}
.list-filter-input:focus,
.list-filter-input.focus {
  border-color: rgb(var(--mdc-color-primary));
  box-shadow: 0 0 0 1px rgb(var(--mdc-color-primary) / 0.25);
}

/* ========================================
   Filter bar: token-based, accessible
   (list pages: Inventory, Catalog, Products, Seasons)
   ======================================== */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid rgb(var(--mdc-color-outline));
  border-radius: 0.75rem;
  background-color: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
@media (min-width: 640px) {
  .filter-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
}

.filter-bar-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
  width: 100%;
}
@media (min-width: 640px) {
  .filter-bar-field {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    width: auto;
    flex-shrink: 0;
  }
}

.filter-bar-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgb(var(--mdc-color-on-surface));
  white-space: nowrap;
}
.filter-bar-label.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.filter-bar-input {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: rgb(var(--mdc-color-on-surface));
  background-color: var(--surface);
  border: 1px solid rgb(var(--mdc-color-outline));
  border-radius: 0.5rem;
  width: 100%;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.filter-bar-input::placeholder {
  color: rgb(var(--mdc-color-on-surface-muted));
  opacity: 1;
}
.filter-bar-input:focus {
  outline: none;
  border-color: rgb(var(--mdc-color-primary));
  box-shadow: 0 0 0 2px rgb(var(--mdc-color-primary) / 0.25);
}
@media (min-width: 640px) {
  .filter-bar-input {
    min-height: 40px;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
  }
}

.filter-bar .filter-bar-field input[type="search"].filter-bar-input {
  min-width: 0;
}
@media (min-width: 640px) {
  .filter-bar .filter-bar-field input[type="search"].filter-bar-input {
    width: 12rem;
  }
}

.filter-bar .filter-bar-field select.filter-bar-input {
  min-width: 0;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.25em 1.25em;
  padding-right: 2rem;
}
@media (min-width: 640px) {
  .filter-bar .filter-bar-field select.filter-bar-input {
    width: 8rem;
  }
}

.filter-bar .filter-bar-field input[type="number"].filter-bar-input {
  width: 100%;
}
@media (min-width: 640px) {
  .filter-bar .filter-bar-field input[type="number"].filter-bar-input {
    width: 4rem;
  }
}

.filter-bar .filter-bar-field .filter-bar-date-wrap {
  position: relative;
  width: 100%;
}
@media (min-width: 640px) {
  .filter-bar .filter-bar-field .filter-bar-date-wrap {
    width: 8.5rem;
  }
}
.filter-bar .filter-bar-field .filter-bar-date-wrap .filter-bar-input {
  padding-left: 2.25rem;
}
.filter-bar .filter-bar-date-icon {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  padding-left: 0.75rem;
  pointer-events: none;
  z-index: 10;
  color: rgb(var(--mdc-color-on-surface-muted));
  display: flex;
  align-items: center;
}

.filter-bar-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  min-height: 44px;
  padding: 0.25rem 0;
}
@media (min-width: 640px) {
  .filter-bar-checkbox-wrap {
    min-height: 0;
  }
}
.filter-bar-checkbox-wrap input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  accent-color: rgb(var(--mdc-color-primary));
  border-radius: 0.25rem;
}
.filter-bar-checkbox-wrap .filter-bar-label {
  margin: 0;
}

.filter-bar-select-multi-wrap {
  width: 100%;
  min-width: 0;
}
@media (min-width: 640px) {
  .filter-bar-select-multi-wrap {
    min-width: 18rem;
    width: 18rem;
    flex-shrink: 0;
  }
}

.filter-bar-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .filter-bar-actions {
    flex-direction: row;
    align-items: center;
    margin-left: auto;
  }
}

.filter-bar-submit {
  display: inline-flex;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(var(--mdc-color-on-primary));
  background-color: rgb(var(--mdc-color-primary));
  border: 1px solid rgb(var(--mdc-color-primary));
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard),
    border-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard);
}
.filter-bar-submit:hover {
  background-color: rgb(var(--mdc-color-primary-hover));
  border-color: rgb(var(--mdc-color-primary-hover));
}
.filter-bar-submit:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--mdc-focus-ring) / 0.4);
}
@media (min-width: 640px) {
  .filter-bar-submit {
    height: 40px;
    padding: 0.375rem 1rem;
  }
}

.filter-bar-clear {
  display: inline-flex;
  height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(var(--mdc-color-on-surface));
  background-color: var(--surface);
  border: 1px solid rgb(var(--mdc-color-outline));
  border-radius: 0.5rem;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.filter-bar-clear:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.35);
  border-color: rgb(var(--mdc-color-primary) / 0.25);
}
.filter-bar-clear:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--mdc-focus-ring) / 0.4);
}
@media (min-width: 640px) {
  .filter-bar-clear {
    height: 40px;
    padding: 0.375rem 1rem;
  }
}

/* Filter bar wrapper (e.g. inventory page) — token-based container and toggle */
.filter-bar-container {
  border: 1px solid rgb(var(--mdc-color-outline));
  border-radius: 0.75rem;
  background-color: var(--surface);
}
.filter-bar-toggle-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-size: 0.875rem;
  color: rgb(var(--mdc-color-on-surface));
  background: none;
  border: none;
  cursor: pointer;
}
@media (min-width: 768px) {
  .filter-bar-toggle-btn {
    display: none;
  }
}
.filter-bar-container-inner {
  padding: 0.5rem 0.75rem;
}
@media (min-width: 640px) {
  .filter-bar-container-inner {
    padding: 0.5rem 0.75rem;
  }
}
.filter-bar--embedded {
  padding: 0.5rem !important;
  border: none !important;
  border-radius: 0.5rem !important;
  box-shadow: none !important;
}
@media (min-width: 640px) {
  .filter-bar--embedded {
    padding: 0.5rem 0.75rem !important;
    gap: 0.5rem !important;
  }
}

/* Accessibility utility (Tailwind's `sr-only`) — keep in overrides so it works even if Tailwind isn't rebuilt. */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border-width: 0 !important;
}

/* User menu avatar sizing: keep it visually aligned with the header theme toggle button. */
.user-menu-avatar {
  width: 34px;
  height: 34px;
}

a {
  color: rgb(var(--mdc-color-primary));
}

a:hover {
  color: rgb(var(--mdc-color-primary));
}

/* Ensure semantic Tailwind classes are token-driven even if Tailwind can't be rebuilt locally. */
.bg-background {
  background-color: rgb(var(--mdc-color-background) / var(--tw-bg-opacity, 1)) !important;
}
.bg-primary {
  background-color: rgb(var(--mdc-color-primary) / var(--tw-bg-opacity, 1)) !important;
}
.focus\:ring-primary:focus {
  --tw-ring-color: rgb(var(--mdc-focus-ring) / var(--tw-ring-opacity, 1)) !important;
}
.focus\:border-primary:focus {
  border-color: rgb(var(--mdc-color-primary) / var(--tw-border-opacity, 1)) !important;
}
/* Primary button hover: distinct shade in light and dark, smooth transition */
.bg-primary.hover\:bg-primary,
a.hover\:bg-primary,
button.hover\:bg-primary {
  transition: background-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard);
}
.hover\:bg-primary:hover {
  background-color: rgb(var(--mdc-color-primary-hover) / var(--tw-bg-opacity, 1)) !important;
}

.bg-primaryContainer {
  background-color: rgb(var(--mdc-color-primary-container) / var(--tw-bg-opacity, 1)) !important;
}
.text-primary {
  color: rgb(var(--mdc-color-primary) / var(--tw-text-opacity, 1)) !important;
}
.text-onPrimaryContainer {
  color: rgb(var(--mdc-color-on-primary-container) / var(--tw-text-opacity, 1)) !important;
}

.bg-danger {
  background-color: rgb(var(--mdc-color-danger) / var(--tw-bg-opacity, 1)) !important;
}
.bg-danger.hover\:bg-danger,
a.hover\:bg-danger,
button.hover\:bg-danger {
  transition: background-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard);
}
.hover\:bg-danger:hover {
  background-color: rgb(var(--mdc-color-danger-hover) / var(--tw-bg-opacity, 1)) !important;
}
.focus\:ring-danger:focus {
  --tw-ring-color: rgb(var(--mdc-color-danger) / var(--tw-ring-opacity, 1)) !important;
}

/* Action button text: use on-primary/on-danger for WCAG contrast (light and dark) */
.text-on-primary {
  color: rgb(var(--mdc-color-on-primary) / var(--tw-text-opacity, 1)) !important;
}
.text-on-danger {
  color: rgb(var(--mdc-color-on-danger) / var(--tw-text-opacity, 1)) !important;
}

/* Sell button: primary-container fill (consistent with design tokens) */
.bg-primaryContainer.hover\:bg-primaryContainer,
a.hover\:bg-primaryContainer,
button.hover\:bg-primaryContainer {
  transition: background-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard);
}
.hover\:bg-primaryContainer:hover {
  background-color: rgb(var(--mdc-color-primary-container-hover) / var(--tw-bg-opacity, 1)) !important;
}
.focus\:ring-primaryContainer:focus {
  --tw-ring-color: rgb(var(--mdc-color-primary) / 0.5) !important;
}

/* Secondary (outline) action buttons: surface + outline + on-surface — works in light and dark */
.btn-action-outline {
  background-color: rgb(var(--mdc-color-surface)) !important;
  color: rgb(var(--mdc-color-on-surface)) !important;
  border: 1px solid rgb(var(--mdc-color-outline)) !important;
}
.btn-action-outline:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.35) !important;
  border-color: rgb(var(--mdc-color-primary) / 0.25) !important;
  color: rgb(var(--mdc-color-on-surface)) !important;
}

/* ============================================
   Table actions: sleek, premium, compact
   (every Actions column across the app)
   ============================================ */
.inventory-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
/* Actions in a 2-column grid: consistent alignment across all tables */
.table-actions--grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.375rem 0.5rem;
  align-items: stretch;
  justify-items: stretch;
}
.table-actions--grid a,
.table-actions--grid button {
  min-width: 0;
}
.table-actions--grid a,
.table-actions--grid button {
  width: 100%;
}
.table-actions--grid form.inline {
  width: 100%;
  min-width: 0;
  display: block;
}
.table-actions--grid form.inline button {
  width: 100%;
}
.inventory-actions a,
.inventory-actions button,
.table-actions a,
.table-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 0.25rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  text-decoration: none;
  min-width: 4rem;
  box-sizing: border-box;
}
.inventory-actions a:hover,
.inventory-actions button:hover,
.table-actions a:hover,
.table-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px -1px rgb(0 0 0 / 0.2);
}
.inventory-actions a:focus,
.inventory-actions button:focus,
.table-actions a:focus,
.table-actions button:focus {
  outline: none;
}
/* Compact icon-only row: single line, square buttons (inventory table) */
.table-actions--compact {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.25rem;
  align-items: center;
  width: auto;
}
.table-actions--compact a,
.table-actions--compact button {
  position: relative;
  width: 1.75rem;
  min-width: 1.75rem;
  height: 1.75rem;
  min-height: 1.75rem;
  padding: 0;
  border-radius: 0.25rem;
  flex-shrink: 0;
}
.table-actions--compact a svg,
.table-actions--compact button svg,
.table-actions--compact a .w-4,
.table-actions--compact a .h-4,
.table-actions--compact button .w-4,
.table-actions--compact button .h-4 {
  width: 0.875rem;
  height: 0.875rem;
}
/* Visually hide label; keep for screen readers and tooltips */
.table-actions--compact a span,
.table-actions--compact button span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Actions cell: allow dropdown to extend outside without clipping */
td.table-actions-cell {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  overflow: visible;
  position: relative;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
/* Split layout: primary button + kebab dropdown (sized to match row/panel) */
.table-actions--split {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  width: auto;
}
.table-actions--split .table-actions__primary {
  flex-shrink: 0;
  min-width: 0;
}
.table-actions--split .table-actions__primary a,
.table-actions--split .table-actions__primary button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  min-height: 36px;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 0.375rem;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.table-actions--split .table-actions__primary a svg,
.table-actions--split .table-actions__primary a .w-4,
.table-actions--split .table-actions__primary a .h-4,
.table-actions--split .table-actions__primary button svg,
.table-actions--split .table-actions__primary button .w-4,
.table-actions--split .table-actions__primary button .h-4 {
  width: 1rem;
  height: 1rem;
}
.table-actions--split .table-actions__kebab {
  position: relative;
  flex-shrink: 0;
  z-index: 1;
}
/* When dropdown is open (Flowbite removes .hidden), lift above row dividers */
.table-actions--split .table-actions__kebab:focus-within,
.table-actions--split .table-actions__kebab:has(.table-actions__dropdown:not(.hidden)) {
  z-index: 10000;
}
.table-actions--split .table-actions__kebab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 0.375rem;
  border: 1px solid rgb(var(--mdc-color-outline) / 0.4);
  background: rgb(var(--mdc-color-surface));
  color: rgb(var(--mdc-color-on-surface));
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.table-actions--split .table-actions__kebab-btn:hover {
  background: rgb(var(--mdc-color-outline) / 0.08);
  border-color: rgb(var(--mdc-color-outline) / 0.6);
}
.table-actions--split .table-actions__kebab-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--mdc-color-primary) / 0.4);
}
.table-actions--split .table-actions__kebab-btn svg,
.table-actions--split .table-actions__kebab-btn .w-4,
.table-actions--split .table-actions__kebab-btn .h-4 {
  width: 1.125rem;
  height: 1.125rem;
}
/* Dropdown menu for table row actions: opaque so row dividers don’t show through */
.table-actions__dropdown {
  min-width: 7.5rem;
  padding: 0.125rem 0;
  border-radius: 0.375rem;
  border: 1px solid rgb(var(--mdc-color-outline) / 0.3);
  background-color: rgb(var(--mdc-color-surface));
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.2);
  z-index: 9999;
  isolation: isolate;
}
.table-actions__dropdown a,
.table-actions__dropdown button {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  color: rgb(var(--mdc-color-on-surface));
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.1s ease;
}
.table-actions__dropdown a:hover,
.table-actions__dropdown button:hover {
  background: rgb(var(--mdc-color-outline) / 0.08);
}
.table-actions__dropdown a.danger,
.table-actions__dropdown button.danger {
  color: rgb(var(--mdc-color-error));
}
.table-actions__dropdown form {
  display: block;
}
.table-actions__dropdown form button {
  width: 100%;
  justify-content: flex-start;
}
.table-actions__dropdown .divider {
  height: 1px;
  margin: 0.125rem 0;
  background: rgb(var(--mdc-color-outline) / 0.2);
}
/* Match primary button size to kebab for visual balance */
.table-actions--split .table-actions__primary a,
.table-actions--split .table-actions__primary button {
  padding: 0.375rem 0.625rem;
  min-height: 36px;
}

/* Desktop: slimmer buttons for grid layouts */
@media (min-width: 640px) {
  .inventory-actions,
  .table-actions {
    gap: 0.375rem;
  }
  .inventory-actions a,
  .inventory-actions button,
  .table-actions a,
  .table-actions button {
    min-height: 28px;
    padding: 0.25rem 0.5rem;
  }
  .table-actions--grid a,
  .table-actions--grid button {
    min-height: 26px;
    padding: 0.25rem 0.375rem;
    font-size: 0.6875rem;
  }
  .inventory-actions a .w-4,
  .inventory-actions a .h-4,
  .inventory-actions a svg,
  .table-actions a .w-4,
  .table-actions a .h-4,
  .table-actions a svg,
  .table-actions button .w-4,
  .table-actions button .h-4,
  .table-actions button svg {
    width: 0.875rem;
    height: 0.875rem;
  }
}
/* Mobile: keep 44px touch target for card action rows */
@media (max-width: 639px) {
  .mobile-card-actions.inventory-actions a,
  .mobile-card-actions.inventory-actions button,
  .mobile-card-actions.table-actions a,
  .mobile-card-actions.table-actions button {
    min-height: 44px;
    min-width: 4.5rem; /* same as desktop so all buttons uniform */
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
  .mobile-card-actions.inventory-actions .flex-1,
  .mobile-card-actions.table-actions .flex-1 {
    min-width: 4.5rem; /* flex-1 still grows equally but with same minimum */
  }
}

/* Tailwind “white” utilities appear throughout templates; tint them green. */
.bg-white {
  background-color: var(--surface) !important;
}
.bg-white\/90 {
  background-color: var(--surface-90) !important;
}
.bg-white\/80 {
  background-color: var(--surface-80) !important;
}
.bg-white\/70 {
  background-color: var(--surface-70) !important;
}
.bg-white\/60 {
  background-color: var(--surface-60) !important;
}
.bg-white\/50 {
  background-color: var(--surface-50) !important;
}
.hover\:bg-white:hover {
  background-color: var(--surface) !important;
}

/* Common near-white “neutral” backgrounds → green-tinted too. */
.bg-slate-50 {
  background-color: rgb(var(--mdc-color-background) / 0.65) !important;
}
.bg-slate-100 {
  background-color: rgb(var(--mdc-color-primary-container) / 0.55) !important;
}
.hover\:bg-slate-50:hover {
  background-color: rgb(var(--mdc-color-background) / 0.85) !important;
}
.hover\:bg-slate-100:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.75) !important;
}

/* Dark mode overrides for gray table headers */
html.dark .bg-gray-50 {
  background-color: rgb(var(--mdc-color-surface)) !important;
}
html.dark .bg-gray-100 {
  background-color: rgb(var(--mdc-color-primary-container) / 0.55) !important;
}

/* Dark mode hover states */
html.dark .hover\:bg-slate-100:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.75) !important;
}

html.dark .hover\:bg-gray-50:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.55) !important;
}

/* Dark mode for emerald "Current State" cards */
html.dark .bg-emerald-50 {
  background-color: rgb(var(--mdc-color-primary-container) / 0.5) !important;
}

html.dark .border-emerald-200 {
  border-color: rgb(var(--mdc-color-primary) / 0.3) !important;
}

html.dark .text-emerald-700 {
  color: rgb(var(--mdc-color-primary)) !important;
}

html.dark .text-emerald-900 {
  color: rgb(var(--mdc-color-on-surface)) !important;
}

html.dark .text-emerald-600 {
  color: rgb(var(--mdc-color-primary)) !important;
}

html.dark .border-emerald-600 {
  border-color: rgb(var(--mdc-color-primary)) !important;
}

html.dark .bg-emerald-600 {
  background-color: rgb(var(--mdc-color-primary)) !important;
}

html.dark .hover\:bg-emerald-700:hover {
  background-color: rgb(var(--mdc-color-primary-dark)) !important;
}

/* Dark mode for blue inventory depth highlights */
html.dark .text-blue-700 {
  color: rgb(139, 193, 232) !important; /* Lighter blue for dark mode */
}

html.dark .text-blue-600 {
  color: rgb(139, 193, 232) !important; /* Lighter blue for dark mode */
}

/* Dark mode for white stat cards */
html.dark .bg-white {
  background-color: rgb(var(--mdc-color-surface)) !important;
}

html.dark .border-slate-200 {
  border-color: rgb(var(--mdc-color-outline) / 0.3) !important;
}

/* Dark mode for badge styles */
html.dark .bg-amber-100 {
  background-color: rgb(217, 119, 6, 0.2) !important; /* amber-600 with opacity */
}

html.dark .text-amber-800 {
  color: rgb(252, 211, 77) !important; /* amber-300 */
}

html.dark .bg-slate-100 {
  background-color: rgb(var(--mdc-color-surface-variant)) !important;
}

html.dark .text-slate-700 {
  color: rgb(var(--mdc-color-on-surface-variant)) !important;
}

/* Dark mode for tab navigation and borders */
html.dark .hover\:border-emerald-300:hover {
  border-color: rgb(var(--mdc-color-primary) / 0.5) !important;
}

/* Owner console table scrolling enhancements */
.owner-clients-table-container {
  /* Smooth scrolling */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Sticky first column for name */
html body [data-cy="owner-clients-table"] th:first-child,
html body [data-cy="owner-clients-table"] td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background-color: inherit;
}

html.dark [data-cy="owner-clients-table"] th:first-child,
html.dark [data-cy="owner-clients-table"] td:first-child {
  background-color: rgb(var(--mdc-color-surface)) !important;
}

/* Add shadow to sticky column when scrolled */
[data-cy="owner-clients-table"] th:first-child::after,
[data-cy="owner-clients-table"] td:first-child::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to right, rgba(0,0,0,0.1), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

/* Dark mode text color overrides – ensure adequate contrast on dark surfaces. */
html.dark {
  /* Map common Tailwind slate text utilities to on-surface tokens. */
  --_on-surface: rgb(var(--mdc-color-on-surface));
  --_on-surface-muted: rgb(var(--mdc-color-on-surface-muted));
}

html.dark .text-slate-900,
html.dark .text-slate-800,
html.dark .text-slate-700,
html.dark .text-gray-900,
html.dark .text-gray-800,
html.dark .text-gray-700 {
  color: var(--_on-surface) !important;
}

html.dark .text-slate-600,
html.dark .text-slate-500,
html.dark .text-slate-400,
html.dark .text-gray-600,
html.dark .text-gray-500,
html.dark .text-gray-400 {
  color: var(--_on-surface-muted) !important;
}

/* Adjust border utilities to use outline token for sufficient contrast */
html.dark .border-slate-200,
html.dark .border-slate-300,
html.dark .border-slate-400,
html.dark .border-gray-200,
html.dark .border-gray-300,
html.dark .border-gray-400 {
  border-color: rgb(var(--mdc-color-outline)) !important;
}

/* Override ring colors that are hard to see in dark mode */
html.dark .ring-slate-200,
html.dark .ring-slate-300 {
  --tw-ring-color: rgb(var(--mdc-color-outline) / var(--tw-ring-opacity, 1)) !important;
}

/* Dark mode: header uses green surface (forest-green theme, not slate) */
html.dark .app-header {
  background-color: rgb(var(--mdc-color-surface)) !important;
  border-bottom-color: rgb(var(--mdc-color-outline)) !important;
}
html.dark .app-header .header-nav-btn {
  background-color: rgb(var(--mdc-color-surface)) !important;
  color: rgb(var(--mdc-color-on-surface)) !important;
  border-color: rgb(var(--mdc-color-outline)) !important;
}
html.dark .app-header .header-nav-btn:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.35) !important;
  border-color: rgb(var(--mdc-color-primary) / 0.25) !important;
  color: rgb(var(--mdc-color-on-surface)) !important;
}

/* Dark mode: status badges – muted, non‑jarring (avoid bright pastel bg) */
html.dark [data-cy="status-badge"] {
  background-color: rgb(var(--mdc-color-surface)) !important;
  color: rgb(var(--mdc-color-on-surface)) !important;
  border: 1px solid rgb(var(--mdc-color-outline)) !important;
  box-shadow: none !important;
}
html.dark [data-cy="status-badge"]::before {
  border-color: transparent !important;
}
/* Subtle tint per status so badges stay distinguishable */
html.dark [data-cy="status-badge"][data-status-key="ready-for-sale"] {
  background-color: rgb(20 83 45 / 0.5) !important;
  color: rgb(167 243 208) !important;
  border-color: rgb(36 69 52) !important;
}
html.dark [data-cy="status-badge"][data-status-key="planted"] {
  background-color: rgb(14 116 144 / 0.35) !important;
  color: rgb(165 243 252) !important;
  border-color: rgb(36 69 52) !important;
}
html.dark [data-cy="status-badge"][data-status-key="budded"] {
  background-color: rgb(3 105 161 / 0.35) !important;
  color: rgb(186 230 253) !important;
  border-color: rgb(36 69 52) !important;
}
html.dark [data-cy="status-badge"][data-status-key="cracking-color"] {
  background-color: rgb(146 64 14 / 0.35) !important;
  color: rgb(254 215 170) !important;
  border-color: rgb(36 69 52) !important;
}
html.dark [data-cy="status-badge"][data-status-key="dumped"] {
  background-color: rgb(91 33 182 / 0.35) !important;
  color: rgb(221 214 254) !important;
  border-color: rgb(36 69 52) !important;
}
html.dark [data-cy="status-badge"][data-status-key="sold"] {
  background-color: rgb(159 18 57 / 0.35) !important;
  color: rgb(254 205 211) !important;
  border-color: rgb(36 69 52) !important;
}
html.dark [data-cy="status-badge"][data-status-key="archived"],
html.dark [data-cy="status-badge"][data-status-key="active"] {
  background-color: rgb(var(--mdc-color-surface)) !important;
  color: rgb(var(--mdc-color-on-surface)) !important;
  border-color: rgb(var(--mdc-color-outline)) !important;
}

/* Dark mode: pagination "Show X per page" – readable text and select */
html.dark #per-page-select {
  background-color: rgb(var(--mdc-color-surface)) !important;
  color: rgb(var(--mdc-color-on-surface)) !important;
  border-color: rgb(var(--mdc-color-outline)) !important;
}
html.dark .pagination-per-page .text-slate-600,
html.dark .pagination-per-page .text-slate-700 {
  color: rgb(var(--mdc-color-on-surface)) !important;
}

/* Dark mode gradient overrides – replace white gradient stops with surface color */
html.dark .from-white {
  --tw-gradient-from: rgb(var(--mdc-color-surface)) !important;
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
}
html.dark .via-white {
  --tw-gradient-stops: var(--tw-gradient-from), rgb(var(--mdc-color-surface)), var(--tw-gradient-to) !important;
}
html.dark .to-white {
  --tw-gradient-to: rgb(var(--mdc-color-surface)) !important;
}

/* ========================================
   ACCESSIBILITY: WCAG AA COLOR CONTRAST
   ======================================== */

/* Improve contrast for slate text utilities (light mode) */
.text-slate-500 {
  color: rgb(100 116 139) !important; /* Darker than default for better contrast */
}

.text-slate-400 {
  color: rgb(148 163 184) !important; /* Slightly darker */
}

/* Placeholder text contrast */
::placeholder {
  color: rgb(100 116 139);
  opacity: 1;
}

/* Status badge text: improve contrast by using darker shades */
.text-emerald-700 {
  color: rgb(4 120 87) !important; /* Darker emerald for better contrast on light bg */
}

.text-amber-700 {
  color: rgb(146 64 14) !important; /* Darker amber for better contrast */
}

.text-sky-700 {
  color: rgb(3 105 161) !important; /* Darker sky for better contrast */
}

.text-cyan-700 {
  color: rgb(14 116 144) !important; /* Darker cyan for better contrast */
}

.text-rose-800 {
  color: rgb(159 18 57) !important; /* Rose-800 instead of rose-700 for better contrast */
}

.text-violet-800 {
  color: rgb(91 33 182) !important; /* Violet-800 instead of violet-700 for better contrast */
}

/* Current page in pagination - improve contrast */
.border-emerald-300.bg-emerald-500\/10 {
  background-color: rgb(16 185 129 / 0.20) !important;
  border-color: rgb(16 185 129) !important;
}

.text-emerald-800 {
  color: rgb(6 95 70) !important; /* Darker for better contrast */
}

/* Ensure focus rings are visible (WCAG 2.4.7); dark mode uses background for ring offset */
.focus\:ring-2:focus {
  --tw-ring-offset-width: 2px;
  --tw-ring-offset-color: #fff;
}
html.dark .focus\:ring-2:focus,
html.dark .focus\:ring-offset-1:focus {
  --tw-ring-offset-color: rgb(var(--mdc-color-background)) !important;
}

/* Button hover states: sleek lift + subtle shadow (smooth in AND out). */
.inventory-actions .bg-primary,
.inventory-actions .bg-danger,
.inventory-actions .bg-primaryContainer,
.inventory-actions .btn-action-outline,
.table-actions .bg-primary,
.table-actions .bg-danger,
.table-actions .bg-primaryContainer,
.table-actions .btn-action-outline {
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
.inventory-actions .bg-primary:hover,
.inventory-actions .bg-danger:hover,
.table-actions .bg-primary:hover,
.table-actions .bg-danger:hover {
  filter: brightness(0.96);
}
.inventory-actions .bg-primaryContainer:hover,
.table-actions .bg-primaryContainer:hover {
  filter: brightness(0.95);
}
.inventory-actions .btn-action-outline:hover,
.table-actions .btn-action-outline:hover {
  box-shadow: 0 2px 6px -2px rgb(0 0 0 / 0.1);
}

/* Subtle lift on card hovers (smooth in AND out). */
.hover\:shadow-lg {
  transition: box-shadow 200ms ease, transform 200ms ease;
}

.hover\:shadow-lg:hover {
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  transform: translateY(-1px);
}

/* Improve border/link hover feedback (smooth in AND out). */
.border.hover\:bg-slate-50 {
  transition: transform 150ms ease;
}

.border.hover\:bg-slate-50:hover {
  transform: translateY(-1px);
}

/* ===============================
   Tom Select compact toolbar theme
   =============================== */
.ts-wrapper {
  font-size: 0.875rem;
}

.ts-control {
  min-height: 2rem !important;
  height: 2rem !important;
  padding: 0 0.5rem !important;
  border-radius: 0.375rem !important;
  border-color: rgb(var(--mdc-color-outline)) !important;
  background-color: var(--surface) !important;
  box-shadow: none !important;
  align-items: center !important;
  gap: 0.25rem !important;
}

.ts-control input {
  font-size: 0.875rem !important;
  line-height: 1.25rem !important;
}

.ts-wrapper.focus .ts-control {
  border-color: rgb(var(--mdc-color-primary)) !important;
  box-shadow: 0 0 0 1px rgb(var(--mdc-focus-ring)) !important;
}

.ts-dropdown {
  border-color: rgb(var(--mdc-color-outline)) !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 10px 25px -12px rgb(0 0 0 / 0.25);
}

/* Multi-select: let control grow to fit tags and never clip */
.ts-wrapper.multi {
  min-width: 0 !important; /* allow flex parent to size us */
}
.ts-wrapper.multi .ts-control {
  flex-wrap: wrap !important;
  min-height: 2rem !important;
  height: auto !important;
  overflow: visible !important;
  align-content: center !important;
  width: 100% !important;
}

.ts-wrapper.multi .ts-control > div {
  display: inline-flex !important;
  align-items: center !important;
  max-width: 14rem;
  overflow: visible !important;
  white-space: nowrap;
  border-radius: 0.25rem !important;
  background: rgb(var(--mdc-color-primary-container) / 0.6) !important;
  color: rgb(var(--mdc-color-on-primary-container)) !important;
}

/* Keep remove (x) button always visible and clickable */
.ts-wrapper.multi .ts-control > div .remove {
  flex-shrink: 0 !important;
}

.ts-wrapper.multi .ts-control > div[data-value] {
  margin: 0 0.25rem 0 0 !important;
}

/* Bulk Select Mode Styling */
.bulk-select-active {
  @apply ring-2 ring-primary ring-opacity-50 bg-primary/5;
}

.bulk-select-active .bulk-checkbox {
  @apply opacity-100;
}

/* Hide bulk checkboxes by default */
.bulk-checkbox {
  @apply opacity-0 transition-opacity duration-200;
}

/* Show bulk checkboxes in bulk select mode */
.bulk-select-active .bulk-checkbox {
  @apply opacity-100;
}

/* =======================================
   Mobile Hamburger Navigation Drawer
   ======================================= */

/* Prevent body scroll when drawer is open */
body.mobile-nav-open {
  overflow: hidden;
}

/* Mobile menu button: sticky bar at top of content (start at top, stick on scroll) */
.mobile-nav-sticky {
  position: sticky;
  top: 0;
  z-index: 140;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.5rem 0 0.75rem 1rem; /* left padding for title */
  margin-bottom: -0.25rem; /* pull content up slightly so no double gap */
  background: rgb(var(--mdc-color-surface) / 0.97);
  -webkit-backdrop-filter: saturate(1.1) blur(6px);
  backdrop-filter: saturate(1.1) blur(6px);
  border-radius: 0 0 0.75rem 0.75rem;
}

.mobile-nav-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  background-color: rgb(var(--mdc-color-primary));
  color: white;
  box-shadow: 0 2px 8px -2px rgb(0 0 0 / 0.2), 0 4px 12px -4px rgb(0 0 0 / 0.15);
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  cursor: pointer;
}

.mobile-nav-menu-btn:hover {
  box-shadow: 0 4px 14px -4px rgb(0 0 0 / 0.25), 0 8px 20px -8px rgb(0 0 0 / 0.2);
  transform: scale(1.05);
}

.mobile-nav-menu-btn:active {
  transform: scale(0.95);
}

.mobile-nav-menu-btn:focus {
  outline: none;
  box-shadow: 0 2px 8px -2px rgb(0 0 0 / 0.2), 0 0 0 3px rgb(var(--mdc-focus-ring) / 0.4);
}

/* Mobile nav drawer container - full screen overlay */
.mobile-nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 150;
  align-items: stretch;
  justify-content: flex-start;
  pointer-events: none;
}

.mobile-nav-drawer.hidden {
  display: none;
}

.mobile-nav-drawer:not(.hidden) {
  display: flex;
  pointer-events: auto;
}

/* Dark overlay backdrop */
.mobile-nav-overlay {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 0.5);
  animation: mobile-nav-overlay-in 250ms ease-out;
}

@keyframes mobile-nav-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* The drawer panel that slides in from left */
.mobile-nav-panel {
  position: relative;
  width: 80%;
  max-width: 320px;
  height: 100%;
  background-color: var(--surface);
  border-right: 1px solid rgb(var(--mdc-color-outline));
  box-shadow: 4px 0 20px -4px rgb(0 0 0 / 0.25);
  display: flex;
  flex-direction: column;
  animation: mobile-nav-slide-in 300ms cubic-bezier(0.32, 0.72, 0, 1);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

@keyframes mobile-nav-slide-in {
  from { 
    transform: translateX(-100%);
    opacity: 0;
  }
  to { 
    transform: translateX(0);
    opacity: 1;
  }
}

/* Drawer header with close button */
.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem 1rem;
  border-bottom: 1px solid rgb(var(--mdc-color-outline));
  flex-shrink: 0;
}

.mobile-nav-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  color: rgb(var(--mdc-color-on-surface-muted));
  transition: background-color 150ms ease, color 150ms ease;
}

.mobile-nav-close-btn:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.4);
  color: rgb(var(--mdc-color-on-surface));
}

.mobile-nav-close-btn:active {
  transform: scale(0.95);
}

/* Navigation links container - scrollable */
.mobile-nav-links {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* Individual nav link styling */
.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px; /* WCAG touch target */
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.9375rem;
  color: rgb(var(--mdc-color-on-surface));
  background-color: transparent;
  border: 1px solid transparent;
  transition: all 150ms ease;
}

.mobile-nav-link:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.3);
  border-color: rgb(var(--mdc-color-primary) / 0.15);
}

.mobile-nav-link:active {
  transform: scale(0.98);
}

.mobile-nav-link.is-active {
  color: rgb(var(--mdc-color-primary));
  background-color: rgb(var(--mdc-color-primary-container) / 0.6);
  border-color: rgb(var(--mdc-color-primary) / 0.3);
  font-weight: 700;
}

/* Desktop app nav tabs (Dashboard, Inventory, Plant Types, etc.) - token-based for light and dark */
.app-nav-tab {
  border: 1px solid rgb(var(--mdc-color-outline));
  background-color: rgb(var(--mdc-color-surface));
  color: rgb(var(--mdc-color-on-surface));
  transition: background-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard),
    border-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard),
    color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard);
}

.app-nav-tab:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.35);
  border-color: rgb(var(--mdc-color-primary) / 0.25);
  color: rgb(var(--mdc-color-on-surface));
}

.app-nav-tab[aria-current="page"] {
  background-color: rgb(var(--mdc-color-primary-container) / 0.6);
  border-color: rgb(var(--mdc-color-primary) / 0.35);
  color: rgb(var(--mdc-color-primary));
  font-weight: 700;
}

/* Hide mobile nav drawer on desktop */
@media (min-width: 640px) {
  .mobile-nav-drawer {
    display: none !important;
  }
  
  .mobile-nav-sticky {
    display: none !important;
  }
}

/* Dark mode adjustments for nav drawer */
html.dark .mobile-nav-overlay {
  background: rgb(0 0 0 / 0.65);
}

html.dark .mobile-nav-panel {
  border-right-color: rgb(var(--mdc-color-outline));
  box-shadow: 4px 0 24px -4px rgb(0 0 0 / 0.5);
}

html.dark .mobile-nav-link {
  color: rgb(var(--mdc-color-on-surface));
}

html.dark .mobile-nav-link:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.25);
}

html.dark .mobile-nav-link.is-active {
  color: rgb(var(--mdc-color-primary));
  background-color: rgb(var(--mdc-color-primary-container) / 0.4);
}



