/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Roboto', Arial, sans-serif;
  background: #0A0A0A;
  color: #F3F4F6;
  line-height: 1.6;
  overflow-x: hidden;
  animation: fadeIn 0.5s ease-out;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Header */
header {
  background: linear-gradient(180deg, #1C2526 0%, #0A0A0A 100%);
  padding: 1.5rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  position: sticky;
  top: 0;
  z-index: 1000;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: #F8F8FF;
  text-align: center;
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}

/* Navigation */
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem; /* Consistent 16px spacing between buttons */
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 10px;
}

nav button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.8rem 1.8rem; /* Standard size for all buttons */
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem; /* Standard font size */
  font-weight: 500;
  margin: 0; /* Ensure no individual margins */
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

nav button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

nav button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

nav button:active::after {
  width: 200px;
  height: 200px;
}

/* Reports Dropdown */
#reports-dropdown {
  position: absolute;
  top: 100%;
  background: #1C2526;
  border: 1px solid #3B82F6;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  min-width: 180px;
  margin: 0; /* Ensure no margin affects layout */
}

#reports-dropdown button {
  background: transparent;
  border: none;
  color: #3B82F6;
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

#reports-dropdown button:hover {
  background: rgba(59, 130, 246, 0.2);
}

/* Main Content */
#main-content {
  max-width: 1280px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  animation: fadeIn 0.5s ease-out;
}

h2 {
  font-size: 2rem;
  font-weight: 600;
  color: #F8F8FF;
  margin-bottom: 1.5rem;
  letter-spacing: 0.03em;
}

.collection-header h2 {
  margin: 0;
  flex-shrink: 0;
  text-align: left;
}

.watch-count {
  font-style: italic;
}

/* Hide unexpected elements and text nodes */
.collection-header > *:not(h2):not(span):not(div),
.collection-header > [class*="unexpected"],
.collection-value > span:not(#collection-value) {
  display: none !important;
  visibility: hidden !important;
}

.wish-list-header {
  display: flex;
  flex-direction: row; /* Ensure row layout for desktop */
  align-items: center;
  gap: 0.8rem;
  flex-wrap: nowrap; /* Prevent wrapping on desktop */
  margin-bottom: 1.5rem;
}

.wish-list-header h2 {
  margin: 0;
  flex-shrink: 0;
}

.wish-list-header #jills-wish-list-btn {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.wish-list-header #jills-wish-list-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.collection-header button, .wish-list-header button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.collection-header button:hover, .wish-list-header button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#filter-btn {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

#filter-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Filter Popup Improvements */
/* Filter Popup Styles */
.filter-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  max-width: 900px;
  width: 95%;
  max-height: calc(90vh - 3rem);
  overflow-y: auto;
  animation: scaleIn 0.3s ease-out;
}

.filter-popup .popup-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}

.filter-popup .top-section {
  position: sticky;
  top: 0;
  background: rgba(28, 37, 38, 0.95);
  z-index: 1;
  padding: 1rem 1rem 0 1rem;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.filter-popup h3 {
  font-size: 1.8rem;
  font-weight: 600;
  color: #D4D4D8;
  text-align: center;
  margin-bottom: 0.5rem;
}

.filter-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.filter-buttons button {
  background: #3B82F6; /* Blue for Apply Filters */
  color: #F3F4F6;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.filter-buttons #clear-filters-btn {
  background: #EF4444; /* Red for Clear Filters */
  color: #F3F4F6;
}

.filter-buttons button:hover {
  background: #2563EB; /* Darker blue on hover */
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.filter-buttons #clear-filters-btn:hover {
  background: #DC2626; /* Darker red on hover */
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.filter-buttons button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.filter-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.filter-category {
  background: #2A2D2E;
  padding: 0.8rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.filter-category h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #3B82F6;
  margin-bottom: 0.4rem;
}

.filter-category label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: #F3F4F6;
  cursor: pointer;
  padding: 0.2rem 0;
  transition: background 0.2s;
  line-height: 1.2; /* Adjusted for better vertical alignment with smaller checkboxes */
}

.filter-category label:hover {
  background: rgba(59, 130, 246, 0.1);
  border-radius: 4px;
}

.filter-category .checkbox-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
}

.filter-category input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  background: #4B5563;
  border: 1px solid #3B82F6;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

.filter-category input[type="checkbox"]:checked {
  background: #3B82F6;
  border-color: #3B82F6;
}

.filter-category input[type="checkbox"]:checked::after {
  content: '✔';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #F3F4F6;
  font-size: 10px; /* Reduced font size for checked mark to fit smaller checkbox */
  line-height: 1;
}

.filter-category input[type="checkbox"]:hover {
  border-color: #2563EB;
}

.filter-popup #close-filter-popup {
  position: sticky;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.filter-popup #close-filter-popup:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

#jills-watches-btn {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

#jills-watches-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#clear-filters-home-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Search Bar */
.search-container {
  display: flex;
  align-items: center;
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.button {
  background: #3B82F6;
  color: #F3F4F6;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  margin-left: 0.5rem;
}
.button:hover {
  background: #2563EB;
}

#search-bar {
  width: 100%;
  padding: 0.6rem 2rem 0.6rem 0.8rem; /* Adjusted padding for clear button */
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#search-bar:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}
#search-bar::placeholder {
  color: #6B7280;
}
#clear-search-btn {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #EF4444;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, transform 0.2s;
}
#clear-search-btn:hover {
  color: #DC2626;
  transform: translateY(-50%) scale(1.1);
}

/* Value and Sort Row */
.value-sort-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  width: 100%;
  min-height: 2.5rem; /* Ensure height for alignment */
}

/* Sort Button and Dropdown */
.sort-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#sort-dropdown button {
  background: transparent;
  border: none;
  color: #3B82F6;
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

#sort-dropdown button:hover {
  background: rgba(59, 130, 246, 0.2);
}

#sort-dropdown button[data-sort="Reset"] {
  color: #EF4444;
}

#sort-dropdown button[data-sort="Reset"]:hover {
  background: rgba(239, 68, 68, 0.2);
}

#collection-value {
  order: 2; /* Place after .sort-container */
  margin-left: 20px; /* Space between sort button and total value */
}

.sort-container {
  order: 1; /* Ensure sort button comes first */
}

/* Calendar Header */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.calendar-header h2 {
  flex: 1;
  text-align: center;
  font-size: 1.8rem;
  color: #F8F8FF;
  border-bottom: 1px solid rgba(59, 130, 246, 0.3);
  padding-bottom: 0.5rem;
}

.calendar-header button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.calendar-header button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Watch List */
.watch-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  justify-content: center;
}

.watch-card {
  background: #FFFFFF;
  padding: 0.5rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 210px;
  min-height: 320px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.watch-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 16px rgba(59, 130, 246, 0.2);
}

.image-container {
  width: 190px;
  height: 190px;
  background: #FFFFFF;
  border-radius: 10px;
  overflow: hidden;
  align-self: center;
  position: relative;
}

.watch-image {
  width: 190px;
  height: 190px;
  object-fit: contain;
  background: #FFFFFF;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.3s ease;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.watch-image:hover {
  transform: scale(1.05);
}

/* Warranty Indicator Styles */
.warranty-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: bold;
  z-index: 50; /* Lowered to stay below header */
}

.warranty-active {
  background-color: #22C55E;
}

.warranty-expired {
  background-color: #EF4444;
  color: #FFFFFF;
}

.warranty-expiring-soon {
  background-color: #F97316;
  color: #FFFFFF;
}

.watch-info {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.8rem;
  flex-grow: 1;
  justify-content: space-between;
}

.watch-details {
  text-align: center;
  color: #FFFFFF;
}

.watch-brand, .watch-model, .watch-reference {
  font-size: 0.85rem;
  font-weight: 500;
  margin: 0.2rem 0;
  color: #000000;
}

.watch-brand {
  font-weight: 700;
  font-size: 1rem;
}

.watch-model {
  white-space: normal;
}

.watch-reference {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watch-buttons {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}

.watch-buttons button {
  background: rgba(0, 0, 0, 0.4);
  border: none;
  color: #FFFFFF;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  flex: 1;
}

.watch-buttons button:hover {
  background: rgba(0, 0, 0, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Watch Details Popup */
/* Watch Details Popup */
.watch-details-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  max-width: 900px;
  width: 95%;
  max-height: calc(90vh - 4rem);
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.watch-details-popup.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.watch-details-popup .popup-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
}

.watch-details-popup button#close-details {
  position: sticky;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  z-index: 2100;
}

.watch-details-popup button#close-details:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.watch-details-popup .last-worn {
  position: absolute;
  top: 10px;
  left: 10px;
  color: #EF4444;
  font-size: 1rem;
  font-weight: 500;
  z-index: 2100;
}

.watch-details-top {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.watch-details-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.watch-details-left h3 {
  font-size: 2rem;
  font-weight: 700;
  color: #F8F8FF;
  margin: 0;
}

.watch-details-left p {
  font-size: 1rem;
  color: #F3F4F6;
  margin: 0;
}

.watch-details-left p strong {
  color: #D4D4D8;
  font-weight: 600;
}

.watch-details-right {
  flex: 0 0 auto;
}

.watch-details-right img {
  width: 275px;
  height: 275px;
  object-fit: cover;
  background: #2A2D2E;
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.watch-details-sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.details-section {
  background: #2A2D2E;
  border-radius: 8px;
  overflow: hidden;
  transition: background 0.2s ease;
}

.details-section summary {
  font-size: 1.2rem;
  font-weight: 600;
  color: #3B82F6;
  padding: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.details-section summary:hover {
  background: rgba(59, 130, 246, 0.1);
}

.details-section summary::after {
  content: '▼';
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}

.details-section[open] summary::after {
  transform: rotate(180deg);
}

.section-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.section-content p {
  font-size: 1rem;
  color: #F3F4F6;
  margin: 0;
}

.section-content p strong {
  color: #D4D4D8;
  font-weight: 600;
}

.watch-details-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}

.watch-details-buttons button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  flex: 1;
  min-width: 120px;
}

.watch-details-buttons button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.watch-details-buttons button:disabled {
  border: 1px solid #6B7280;
  color: #6B7280;
  cursor: not-allowed;
  opacity: 0.5;
}

/* Two-Column Layout for Large Screens */
@media (min-width: 1024px) {
  .details-section:not(.additional-info) .section-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 2rem;
  }

  .section-content p {
    margin: 0;
  }
}

/* Responsive Adjustments for Watch Details */
@media (max-width: 1024px) {
  .watch-details-top {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  .watch-details-right img {
    width: 250px;
    height: 250px;
  }
}

@media (max-width: 768px) {
  .watch-details-popup {
    padding: 1.2rem;
  }

  .watch-details-left h3 {
    font-size: 1.8rem;
  }

  .watch-details-left p {
    font-size: 0.9rem;
  }

  .watch-details-right img {
    width: 200px;
    height: 200px;
  }

  .details-section summary {
    font-size: 1.1rem;
    padding: 0.8rem;
  }

  .section-content p {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .watch-details-popup {
    padding: 1rem;
  }

  .watch-details-left h3 {
    font-size: 1.6rem;
  }

  .watch-details-left p {
    font-size: 0.85rem;
  }

  .watch-details-right img {
    width: 180px;
    height: 180px;
  }

  .details-section summary {
    font-size: 1rem;
    padding: 0.6rem;
  }

  .section-content {
    padding: 0.8rem;
  }

  .section-content p {
    font-size: 0.85rem;
  }

  .watch-details-buttons button {
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
    min-width: 100px;
  }
}

/* Calendar Grid */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  background: #1C2526;
  padding: 1.2rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  overflow: visible;
}

.calendar-grid .calendar-header {
  text-align: center;
  font-weight: 600;
  color: #D4D4D8;
  padding: 0.6rem;
  font-size: 0.9rem;
}

.calendar-day {
  background: #2A2D2E;
  padding: 1rem;
  border-radius: 10px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
  transition: transform 0.2s ease;
  z-index: 1;
}

.calendar-day:hover {
  transform: translateY(-4px);
}

.calendar-day.empty {
  background: none;
  box-shadow: none;
}

.calendar-day span {
  font-size: 1.2rem;
  font-weight: 500;
  color: #3B82F6;
}

.calendar-day .thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.calendar-day .thumbnail-wrapper {
  position: relative;
  display: inline-block;
}

.calendar-day .thumbnail-wrapper img {
  width: 45px;
  height: 45px;
  object-fit: cover;
  border-radius: 6px;
  transition: transform 0.2s ease;
  cursor: pointer;
}

.calendar-day .thumbnail-wrapper:hover img {
  transform: scale(1.1);
}

.calendar-day .thumbnail-wrapper .thumbnail-popup {
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 0.8rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 100;
  text-align: center;
  width: 180px;
}

.calendar-day .thumbnail-wrapper:hover .thumbnail-popup {
  opacity: 1;
  visibility: visible;
}

.calendar-day .thumbnail-wrapper .thumbnail-popup img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 0.6rem;
  cursor: pointer;
}

.calendar-day .thumbnail-wrapper .thumbnail-popup .delete-wear {
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  line-height: 28px;
  transition: background 0.2s, transform 0.2s;
  display: block;
  margin: 0 auto;
}

.calendar-day .thumbnail-wrapper .thumbnail-popup .delete-wear:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
}

/* Calendar Day Buttons and Select */
.calendar-day button:not(.add-wear-btn), .calendar-day select {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  margin-top: auto;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.calendar-day button:hover, .calendar-day select:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.calendar-day select {
  width: 100%;
}

/* Updated Add Wear Button */
.add-wear-btn {
  position: absolute;
  bottom: 5px;
  right: 5px;
  color: #3B82F6;
  font-size: 1.2rem;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  border: none !important;
  background: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
  appearance: none !important;
  transition: color 0.2s, transform 0.2s;
}

.add-wear-btn:hover,
.add-wear-btn:focus,
.add-wear-btn:active {
  color: #2563eb;
  transform: scale(1.1);
  border: none !important;
  outline: none !important;
}

/* Thumbnail Styles */
.calendar-thumbnail {
  width: 48px;
  height: 48px;
  object-fit: cover;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease;
  image-rendering: auto;
}

.calendar-thumbnail:hover {
  transform: scale(5);
  z-index: 2500;
}

/* Delete X Button for Wear Popup */
.delete-wear-popup-btn {
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 24px;
  text-align: center;
  transition: background 0.2s, transform 0.2s;
}

.delete-wear-popup-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
}

/* Wear Popup */
.wear-popup {
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 1.2rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  width: 280px;
  animation: scaleIn 0.3s ease-out;
}

.wear-popup select, .wear-popup input[type="range"] {
  width: 100%;
  padding: 0.6rem;
  margin: 0.6rem 0;
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  font-size: 0.9rem;
}

.wear-popup label {
  font-size: 1rem;
  font-weight: 500;
  color: #3B82F6;
}

.wear-popup button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 0.6rem;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.wear-popup button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.wear-popup #close-popup {
  border: 1px solid #EF4444;
  color: #EF4444;
}

.wear-popup #close-popup:hover {
  background: rgba(239, 68, 68, 0.2);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

@media (max-width: 768px) {
  .wear-popup {
    width: 90%;
    left: 5% !important;
    right: 5% !important;
    margin: 0 auto;
  }
}

/* Form */
form {
  background: #1C2526;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  max-width: 700px;
  margin: 0 auto;
}

form img {
  max-width: 200px;
  object-fit: cover;
}

label {
  font-size: 1.1rem;
  font-weight: 500;
  color: #3B82F6;
  margin-top: 1.2rem;
  display: block;
  transition: color 0.2s ease;
}

/* Form Inputs and Selects */
input, select, textarea {
  width: 100%;
  padding: 0.8rem;
  margin-top: 0.4rem;
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  font-size: 1rem;
  transition: border-color 0.2s ease; /* Simplify transition */
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

input#case-number {
  width: 100%;
  padding: 0.8rem;
  margin-top: 0.4rem;
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}
input#case-number:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.insured-checkbox {
  margin: 0.5rem 0;
  accent-color: #3B82F6;
}

.insured-badge {
  background: #3B82F6;
  color: #F3F4F6;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  display: inline-block;
}

.watch-details-popup .fields-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1rem 0;
}

/* Instagram Styles */
.toggle-switch {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
  margin: 0;
  line-height: 1;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  top: 50%; /* Position the top edge at 50% of the slider's height */
  transform: translateY(-50%); /* Shift the ball up by half its height to center it */
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #3B82F6;
}

input:checked + .slider:before {
  transform: translateX(20px) translateY(-50%); /* Maintain vertical centering when sliding */
}

.switch input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.toggle-switch span {
  display: inline-block;
  line-height: 1;
  font-size: 1rem;
  margin: 0;
  padding: 0;
}

/* Dropdown "Add New" Input */
form div[id$="-new-input"] {
  display: none;
  opacity: 0;
  margin-top: 0.4rem;
  transition: opacity 0.2s ease-in-out;
}

form div[id$="-new-input"].visible {
  display: block !important;
  opacity: 1;
  z-index: 1000;
  position: relative;
}

form div[id$="-new-input"] input {
  pointer-events: auto;
  z-index: 1001;
  position: relative;
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  padding: 0.6rem;
  width: 100%;
}

form div[id$="-new-input"] input:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.watch-details-popup .column {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.watch-details-popup .column p {
  margin: 0;
  font-size: 1rem;
  color: #F3F4F6;
}

.watch-details-popup .column p strong {
  color: #D4D4D8;
  font-weight: 600;
}

.watch-details-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.2rem;
  flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
}

.watch-details-buttons button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  flex: 1; /* Equal width for all buttons */
  min-width: 120px; /* Ensure buttons are readable */
}

.watch-details-buttons button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.watch-details-buttons button:disabled {
  border-color: #6B7280;
  color: #6B7280;
  cursor: not-allowed;
  opacity: 0.5;
}

.file-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2100;
  max-width: 700px;
  width: 90%;
  max-height: calc(90vh - 3rem);
  overflow-y: auto;
  animation: scaleIn 0.3s ease-out;
}

.file-popup .popup-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
}

.file-popup h3 {
  font-size: 1.8rem;
  font-weight: 600;
  color: #D4D4D8;
  text-align: center;
}

.file-popup p {
  text-align: center;
  font-size: 1rem;
  color: #F3F4F6;
}

.file-popup a {
  color: #3B82F6;
  text-decoration: none;
}

.file-popup a:hover {
  text-decoration: underline;
}

.file-popup button#close-file-popup {
  position: sticky;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  z-index: 2200;
}

.file-popup button#close-file-popup:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.warranty-file-input {
  width: 100%;
  padding: 0.8rem;
  margin-top: 0.4rem;
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.warranty-file-input:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

form button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 1rem 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 500;
  margin-top: 2rem;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  display: block;
  width: 100%;
}

form button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Warranty Popup */
.warranty-indicator .warranty-popup {
  display: none;
  position: absolute;
  top: 0px; /* Unchanged, your setting */
  left: calc(50% - 135px); /* Unchanged, your setting */
  background: #1C2526;
  border: 1px solid #3B82F6;
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  color: #F3F4F6;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 60; /* Lowered to stay below header, above indicator */
}

.warranty-indicator.warranty-active:hover .warranty-popup,
.warranty-indicator.warranty-expiring-soon:hover .warranty-popup {
  display: block;
}

/* Service Records Popup */
.service-records-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  max-width: 700px;
  width: 95%;
  max-height: calc(90vh - 4rem);
  overflow-y: auto;
  animation: scaleIn 0.3s ease-out;
}

.service-records-popup .popup-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
}

.service-records-popup h3 {
  font-size: 1.8rem;
  font-weight: 600;
  color: #D4D4D8;
  text-align: center;
}

.service-records-popup #add-service-record-btn {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  align-self: center;
}

.service-records-popup #add-service-record-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.service-records-popup ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.service-records-popup li {
  background: #2A2D2E;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.service-records-popup p {
  font-size: 1rem;
  color: #F3F4F6;
  margin: 0;
}

.service-records-popup p strong {
  color: #D4D4D8;
  font-weight: 600;
}

.service-records-popup a {
  color: #3B82F6;
  text-decoration: none;
}

.service-records-popup a:hover {
  text-decoration: underline;
}

.service-records-popup .delete-service-btn {
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  align-self: flex-start;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.service-records-popup .delete-service-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.service-records-popup .edit-service-btn {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.service-records-popup .service-record-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-start;
  margin-top: 0.5rem;
}

.service-records-popup .edit-service-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.service-records-popup #close-service-popup {
  position: sticky;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  z-index: 2100;
}

.service-records-popup #close-service-popup:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Service Record Form Popup */
.service-record-form-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  max-width: 500px;
  width: 95%;
  max-height: calc(90vh - 4rem);
  overflow-y: auto;
  animation: scaleIn 0.3s ease-out;
}

.service-record-form-popup .popup-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
}

.service-record-form-popup h3 {
  font-size: 1.8rem;
  font-weight: 600;
  color: #D4D4D8;
  text-align: center;
}

.service-record-form-popup form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: none;
  padding: 0;
  box-shadow: none;
}

.service-record-form-popup label {
  font-size: 1rem;
  font-weight: 500;
  color: #3B82F6;
}

.service-record-form-popup input,
.service-record-form-popup textarea {
  width: 100%;
  padding: 0.6rem;
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  font-size: 0.9rem;
}

.service-record-form-popup textarea {
  min-height: 100px;
  resize: vertical;
}

.service-record-form-popup input[type="file"] {
  padding: 0.4rem;
}

.service-record-form-popup button[type="submit"] {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.service-record-form-popup button[type="submit"]:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.service-record-form-popup #close-service-form {
  position: sticky;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  z-index: 2100;
}

.service-record-form-popup #close-service-form:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Storage Header */
.storage-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.storage-header h2 {
  margin: 0;
  flex-shrink: 0;
}

.storage-header button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.storage-header button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Storage Unit */
.storage-unit {
  margin-bottom: 2rem;
  background: #1C2526;
  padding: 1rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.storage-unit-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.storage-unit-header h3 {
  font-size: 1.5rem;
  color: #F8F8FF;
  margin: 0;
  flex-grow: 1;
}

.storage-unit-header button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.storage-unit-header button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.storage-unit-header .delete-storage-btn {
  border-color: #EF4444;
  color: #EF4444;
}

.storage-unit-header .delete-storage-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Storage Grid */
.storage-grid {
  display: grid;
  gap: 8px;
  background: #1C2526;
  padding: 1.2rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  overflow: visible;
}

/* Dynamically set grid columns via inline style */
.grid-header, .grid-row-label {
  font-size: 1rem;
  font-weight: 500;
  color: #D4D4D8;
  text-align: center;
  padding: 0.5rem;
}

.grid-header.empty {
  background: none;
}

.grid-row-label {
  padding: 0.5rem;
}

.storage-slot {
  background: #2A2D2E;
  padding: min(0.5rem, 2vw);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-height: 180px; /* Base min-height, will scale in media queries */
  aspect-ratio: 1 / 1; /* Maintain square shape */
  position: relative;
  transition: transform 0.2s ease;
  box-sizing: border-box;
}

.storage-slot:hover {
  transform: translateY(-4px);
}

.storage-slot p {
  font-size: min(0.9rem, 2.5vw);
  color: #F3F4F6;
  text-align: center;
  margin: 0;
}

.slot-watch-image {
  width: 60%; /* Scale relative to the slot */
  height: auto;
  max-width: 100px; /* Cap the maximum size */
  object-fit: contain;
  border-radius: 6px;
}

.slot-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

.slot-buttons button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.slot-buttons button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.slot-buttons .delete-watch-btn {
  border-color: #EF4444;
  color: #EF4444;
}

.slot-buttons .delete-watch-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Storage Form Popup */
.storage-form-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  max-width: 500px;
  width: 95%;
  max-height: calc(90vh - 4rem);
  overflow-y: auto;
  animation: scaleIn 0.3s ease-out;
}

.storage-form-popup .popup-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
}

.storage-form-popup h3 {
  font-size: 1.8rem;
  font-weight: 600;
  color: #D4D4D8;
  text-align: center;
}

.storage-form-popup form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: none;
  padding: 0;
  box-shadow: none;
}

.storage-form-popup label {
  font-size: 1rem;
  font-weight: 500;
  color: #3B82F6;
}

.storage-form-popup input,
.storage-form-popup select {
  width: 100%;
  padding: 0.6rem;
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  font-size: 0.9rem;
}

.storage-form-popup button[type="submit"] {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.storage-form-popup button[type="submit"]:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.storage-form-popup #close-storage-form {
  position: sticky;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  z-index: 2100;
}

.storage-form-popup #close-storage-form:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Reports Header */
.reports-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem;
}

.reports-header h2 {
  font-size: 2rem;
  font-weight: 700;
  color: #F3F4F6;
  margin: 0;
}

.report-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem; /* Space between label and dropdown */
  white-space: nowrap; /* Prevent label text from wrapping */
}

.report-filter label {
  font-size: 1rem;
  font-weight: 500;
  color: #F3F4F6;
}

.report-filter select#report-owner-filter {
  margin-left: 0.75rem; /* Shift dropdown to the right */
  padding: 0.5rem;
  font-size: 1rem;
  border: 1px solid #4B5563;
  border-radius: 4px;
  background: #2A2D2E;
  color: #F3F4F6;
  cursor: pointer;
}

.report-filter select:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

/* Reports List */
.reports-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.report-card {
  background: #1C2526;
  padding: 1rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.report-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(59, 130, 246, 0.2);
}

.report-card h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #F8F8FF;
  margin: 0 0 0.5rem;
}

.report-card p {
  font-size: 1rem;
  color: #D4D4D8;
  margin: 0 0 1rem;
}

.report-card button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  width: 100%;
}

.report-card button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Assign Watch Popup */
.assign-watch-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2100;
  max-width: 400px;
  width: 90%;
  animation: scaleIn 0.3s ease-out;
}

.assign-watch-popup .popup-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
}

.assign-watch-popup h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #D4D4D8;
  text-align: center;
}

.assign-watch-popup select {
  width: 100%;
  padding: 0.6rem;
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  font-size: 0.9rem;
}

.assign-watch-popup button {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.assign-watch-popup button:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.assign-watch-popup #close-assign-popup {
  position: sticky;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  z-index: 2200;
}

.assign-watch-popup #close-assign-popup:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Stats Page Styles */
.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.stats-header h2 {
  font-size: 2rem;
  font-weight: 600;
  color: #F8F8FF;
}

.stat-btn {
  background: #3B82F6; /* Match .button background */
  color: #F3F4F6; /* Match .button text color */
  padding: 0.8rem 1.8rem; /* Match .button padding */
  border: none; /* Match .button no border */
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  text-align: center;
  text-decoration: none;
  margin: 0.5rem; /* Ensure spacing in flex layout */
}
.stat-btn:hover {
  background: #60A5FA; /* Match .button hover */
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.stat-btn.active {
  background: #1E3A8A; /* Darker blue for active state to stand out */
  color: #F3F4F6;
  transform: translateY(0); /* No lift when active */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); /* Subtle shadow */
}

.owner-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.owner-filter label {
  font-size: 1rem;
  font-weight: 500;
  color: #3B82F6;
}
.owner-filter select {
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  padding: 0.6rem;
  font-size: 0.9rem;
}
.owner-filter select:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.chart-container {
  position: relative;
  height: 500px; /* Increased from 400px for better visibility */
  width: 100%;
  margin: 1rem 0;
  padding: 1rem;
  background: #1C2526;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Time Period Selector for Wear Frequency by Brand */
.time-period-selector {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.time-period-selector select {
  background: #1C2526;
  color: #F3F4F6;
  border: 1px solid #3B82F6;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 1rem;
}

/* Watch List for Brand Value Graph */
#brand-watch-list {
  margin-top: 1rem;
  padding: 1rem;
  background: #1C2526; /* Match .watch-card background */
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  display: none; /* Hidden by default */
}
.brand-watch-item {
  padding: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.brand-watch-item:last-child {
  border-bottom: none;
}
.brand-watch-item h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
  color: #3B82F6; /* Blue to indicate clickability */
  cursor: pointer; /* Hand cursor for clickable */
  transition: color 0.2s ease;
}
.brand-watch-item h4:hover {
  color: #60A5FA; /* Lighter blue on hover, matches .button hover */
}
.brand-watch-item p {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: #D1D5DB;
}

.divest-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 2100; /* Above watch-details-popup (z-index: 2000) */
  opacity: 0;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.divest-popup.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.divest-popup .popup-content {
  padding: 1.5rem; /* Align with other popups */
  background: rgba(28, 37, 38, 0.95); /* Match watch-details-popup */
  backdrop-filter: blur(8px); /* Match watch-details-popup */
  border: 1px solid #3B82F6; /* Consistent border color */
  border-radius: 16px; /* Match watch-details-popup */
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); /* Match watch-details-popup */
  max-width: 400px;
  width: 90%;
  color: #F3F4F6;
  position: relative; /* Ensure children respect this context */
  margin: 0; /* Remove margin to prevent offset */
}

.divest-popup label {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.divest-popup input,
.divest-popup textarea,
.divest-popup select {
  width: 100%;
  margin-bottom: 10px;
  padding: 5px;
  border: 1px solid #007bff;
  border-radius: 3px;
  background: #333;
  color: #f3f4f6;
}

.divest-popup textarea {
  height: 80px;
  resize: vertical;
}

.divest-popup button {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 3px;
  cursor: pointer;
  margin-right: 10px;
}

.divest-popup button:hover {
  background-color: #0056b3;
}

.divest-popup #close-divest-popup {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: 1px solid #EF4444;
  color: #EF4444;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  z-index: 2150; /* Above popup content */
}

.divest-popup #close-divest-popup:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.undo-btn {
  background-color: #ffcc00;
  color: #000;
  border: none;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
}

.undo-btn:hover {
  background-color: #e6b800;
}

.watch-details-buttons #divested-btn {
  background-color: #dc3545;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 3px;
  cursor: pointer;
  margin-right: 10px;
}

.watch-details-buttons #divested-btn:hover {
  background-color: #c82333;
}

.watch-details-buttons #divested-btn:disabled {
  background-color: #6c757d;
  cursor: not-allowed;
}

.watch-details-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: rgba(28, 37, 38, 0.95);
  backdrop-filter: blur(8px);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  max-width: 900px;
  width: 95%;
  max-height: calc(90vh - 4rem);
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.watch-details-popup.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.watch-details-popup .popup-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
}

.watch-details-buttons {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 20px;
  z-index: 950;
}  

/* Responsive */
@media (max-width: 1024px) {
  .watch-list {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
  }

  .watch-card {
    max-width: 200px;
    min-height: 300px;
  }

  .image-container {
    width: 180px;
    height: 180px;
  }

  .watch-image {
    width: 180px;
    height: 180px;
    object-fit: contain;
    background: #1C2526;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }

  .watch-brand, .watch-model, .watch-reference {
    font-size: 0.95rem;
  }

  .watch-buttons button {
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
  }

  .warranty-indicator {
    width: 11px;
    height: 11px;
    font-size: 7px;
    top: 7px;
    right: 7px;
  }

  #reports-dropdown {
    min-width: 160px;
  }

  #search-bar {
    max-width: 350px;
  }

  .search-container {
    width: 100%;
    justify-content: flex-end;
  }

  .watch-details-popup .fields-container {
    grid-template-columns: 1fr;
  }

  .storage-grid {
    gap: 6px;
    padding: 1rem;
  }

  .storage-slot {
    min-height: 150px;
  }

  .slot-watch-image {
    max-width: 80px;
  }

  .grid-header, .grid-row-label {
    font-size: 0.9rem;
    padding: 0.4rem;
  }

  .slot-buttons button {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
  }

  /* Ensure row layout for tablets */
  .wish-list-header {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.6rem;
  }
}

@media (max-width: 768px) {
  nav {
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 8px;
  }
  nav button {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
  }
  header {
    padding: 0.4rem;
  }
  header h1 {
    font-size: 1.3rem;
    margin-bottom: 0.4rem;
  }
  .watch-list {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }
  .watch-card {
    max-width: 180px;
    min-height: 280px;
  }
  .image-container {
    width: 160px;
    height: 160px;
  }
  .watch-image {
    width: 160px;
    height: 160px;
    object-fit: contain;
    background: #1C2526;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
  .watch-brand, .watch-model, .watch-reference {
    font-size: 0.9rem;
  }
  .watch-buttons button {
    font-size: 0.7rem;
    padding: 0.3rem 0.4rem;
  }
  .calendar-grid {
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 0.6rem;
  }
  .calendar-grid > div:not(.calendar-day) {
    font-size: 0.65rem;
    padding: 0.2rem;
    text-align: center;
    color: #D4D4D8;
    font-weight: 600;
  }
  .calendar-day {
    min-height: 100px;
    padding: 0.3rem;
    font-size: 0.65rem;
  }
  .calendar-day span.day-number {
    font-size: 0.9rem;
  }
  .calendar-day .thumbnails {
    gap: 4px;
  }
  .calendar-day .thumbnail-wrapper img {
    width: 30px;
    height: 30px;
    border-radius: 3px;
  }
  .calendar-day .add-wear-btn {
    width: 20px;
    height: 20px;
    font-size: 0.9rem;
  }
  .calendar-day .thumbnail-wrapper .thumbnail-popup {
    top: -150px;
    width: 140px;
  }
  .calendar-day .thumbnail-wrapper .thumbnail-popup img {
    width: 120px;
    height: 120px;
    object-fit: cover;
  }
  .calendar-day .thumbnail-wrapper .thumbnail-popup .delete-wear {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }
  .wear-popup {
    width: 90%;
    max-width: 260px;
    left: 50% !important;
    transform: translateX(-50%);
  }
  .watch-details-popup {
    width: 95%;
    padding: 1.2rem;
    max-height: calc(95vh - 2.4rem);
  }
  .watch-details-popup img {
    width: 300px;
    height: 300px;
    object-fit: cover;
  }
  form {
    padding: 1.5rem;
  }
  form img {
    max-width: 180px;
    object-fit: cover;
  }
  
  .warranty-indicator {
    width: 10px;
    height: 10px;
    font-size: 6px;
    top: 6px;
    right: 6px;
  }
  #reports-dropdown {
    min-width: 140px;
    font-size: 0.85rem;
  }
  #search-bar {
    max-width: 300px;
  }
  .search-container {
    width: 100%;
    justify-content: flex-start;
  }
  #clear-search-btn {
    font-size: 0.7rem;
  }
  .service-records-popup {
    width: 95%;
    padding: 1.2rem;
    max-height: calc(95vh - 2.4rem);
  }
  .service-records-popup h3 {
    font-size: 1.6rem;
  }
  .service-records-popup #add-service-record-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
  .service-records-popup li {
    padding: 0.8rem;
  }
  .service-records-popup p {
    font-size: 0.9rem;
  }
  .service-records-popup .delete-service-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }
  .service-records-popup .edit-service-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }
  .service-records-popup .service-record-actions {
    gap: 0.4rem;
  }
  .service-record-form-popup {
    width: 95%;
    padding: 1.2rem;
    max-height: calc(95vh - 2.4rem);
  }
  .service-record-form-popup h3 {
    font-size: 1.6rem;
  }
  .service-record-form-popup input,
  .service-record-form-popup textarea {
    padding: 0.5rem;
    font-size: 0.85rem;
  }
  .service-record-form-popup button[type="submit"] {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
  .filter-popup {
    padding: 1.2rem;
    max-height: calc(95vh - 2.4rem);
  }
  .filter-popup h3 {
    font-size: 1.6rem;
  }
  .filter-buttons button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
  .filter-options {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 0.5rem;
  }
  .filter-category h4 {
    font-size: 0.85rem;
    font-weight: bold;
  }
  .filter-category label {
    font-size: 0.7rem;
    line-height: 1;
  }
  .filter-category .checkbox-wrapper {
    height: 8px;
  }
  .filter-category input[type="checkbox"] {
    transform: scale(0.5);
  }
  .filter-category input[type="checkbox"]:checked::after {
    font-size: 8px;
    transform: translate(-50%, -50%) scale(2);
  }
  /* Adjust alignment for mobile portrait */
  .filter-category label span.checkbox-wrapper + * {
    transform: translateY(1.6px);
  }

  .storage-grid {
    gap: 4px;
    padding: 0.8rem;
    overflow-x: auto;
  }

  .storage-slot {
    min-height: 120px;
  }

  .slot-watch-image {
    max-width: 60px;
  }

  .grid-header, .grid-row-label {
    font-size: min(0.8rem, 2.5vw);
    padding: min(0.3rem, 1.5vw);
    min-width: 30px;
  }

  .slot-buttons button {
    font-size: min(0.7rem, 2vw);
    padding: min(0.3rem, 1vw) min(0.5rem, 1.5vw);
  }

  .header-row h2 {
    font-size: 1.6rem;
  }

  .watch-count {
    font-size: 0.9rem;
  }

  .left-header-group h2 {
    width: 100%;
  }

  .left-header-group button {
    min-width: 120px;
    text-align: center;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  #sort-dropdown button {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
  }

  .value-sort-row {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  #collection-value {
    margin-left: 10px;
    margin-top: 5px; /* Add spacing if wrapped */
  }

  .wish-list-header {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
  }

  .reports-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .report-filter {
    width: 100%;
    justify-content: flex-start;
  }

  .report-filter select#report-owner-filter {
    margin-left: 0.5rem; /* Slightly less shift on mobile */
  }
}



@media (max-width: 480px) {
  header {
    padding: 0.4rem;
  }
  header h1 {
    font-size: 1.3rem;
    margin-bottom: 0.4rem;
  }
  nav {
    gap: 0.3rem;
    padding: 5px;
  }
  nav button {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
  }
  h2 {
    font-size: 1.6rem;
  }
  .watch-list {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
  }
  .watch-card {
    max-width: 160px;
    min-height: 260px;
  }
  .image-container {
    width: 140px;
    height: 140px;
  }
  .watch-image {
    width: 140px;
    height: 140px;
    object-fit: contain;
    background: #1C2526;
    image-rendering: -webkit-terminate-contrast;
    image-rendering: crisp-edges;
  }
  .watch-brand, .watch-model, .watch-reference {
    font-size: 0.85rem;
  }
  .watch-buttons button {
    padding: 0.3rem 0.4rem;
    font-size: 0.7rem;
  }
  .calendar-grid {
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 0.4rem;
    overflow-x: auto;
  }
  .calendar-grid > div:not(.calendar-day) {
    font-size: 0.6rem;
    padding: 0.15rem;
    text-align: center;
    color: #D4D4D8;
    font-weight: 600;
  }
  .calendar-day {
    min-height: 80px;
    padding: 0.3rem;
    font-size: 0.6rem;
  }
  .calendar-day span.day-number {
    font-size: 0.8rem;
  }
  .calendar-day .thumbnails {
    gap: 4px;
  }
  .calendar-day .thumbnail-wrapper img {
    width: 24px;
    height: 24px;
    border-radius: 3px;
  }
  .calendar-day .add-wear-btn {
    width: 18px;
    height: 18px;
    font-size: 0.8rem;
  }
  .calendar-day .thumbnail-wrapper .thumbnail-popup {
    top: -120px;
    width: 120px;
  }
  .calendar-day .thumbnail-wrapper .thumbnail-popup img {
    width: 100px;
    height: 100px;
    object-fit: cover;
  }
  .calendar-day .thumbnail-wrapper .thumbnail-popup .delete-wear {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }
  .wear-popup {
    width: 90%;
    max-width: 260px;
    left: 50% !important;
    transform: translateX(-50%);
  }
  .watch-details-popup {
    padding: 1rem;
    max-height: calc(95vh - 2rem);
  }
  .watch-details-popup img {
    width: 240px;
    height: 240px;
    object-fit: cover;
  }
  form {
    padding: 1.5rem;
  }
  form img {
    max-width: 160px;
    object-fit: cover;
  }
  
  .warranty-indicator {
    width: 9px;
    height: 9px;
    font-size: 5px;
    top: 5px;
    right: 5px;
  }
  #reports-dropdown {
    min-width: 120px;
    font-size: 0.8rem;
  }
  #search-bar {
    max-width: 100%;
  }
  .search-container {
    width: 100%;
    justify-content: flex-start;
  }
  #clear-search-btn {
    font-size: 0.6rem;
  }
  .warranty-indicator .warranty-popup {
    font-size: 0.6rem;
    padding: 0.15rem 0.3rem;
    top: 0px;
    left: calc(50% - 108px);
    z-index: 60;
  }
  .service-records-popup {
    padding: 1rem;
    max-height: calc(95vh - 2rem);
  }
  .service-records-popup h3 {
    font-size: 1.4rem;
  }
  .service-records-popup #add-service-record-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
  }
  .service-records-popup li {
    padding: 0.6rem;
  }
  .service-records-popup p {
    font-size: 0.85rem;
  }
  .service-records-popup .delete-service-btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }
  .service-records-popup .edit-service-btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }
  .service-records-popup .service-record-actions {
    gap: 0.3rem;
  }
  .service-record-form-popup {
    padding: 1rem;
    max-height: calc(95vh - 2rem);
  }
  .service-record-form-popup h3 {
    font-size: 1.4rem;
  }
  .service-record-form-popup input,
  .service-record-form-popup textarea {
    padding: 0.4rem;
    font-size: 0.8rem;
  }
  .service-record-form-popup button[type="submit"] {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
  }
  .filter-popup {
    max-height: calc(95vh - 2rem);
    padding: 0.6rem;
  }
  .filter-options {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.4rem;
  }
  .filter-category {
    gap: 0.1rem;
  }
  .filter-category h4 {
    font-size: 0.75rem;
    font-weight: bold;
    margin-bottom: 0.2rem;
  }
  .filter-category label {
    font-size: 0.65rem;
    gap: 0.2rem;
    line-height: 1;
  }
  .filter-category .checkbox-wrapper {
    height: 8px;
  }
  .filter-category input[type="checkbox"] {
    transform: scale(0.5);
  }
  .filter-category input[type="checkbox"]:checked::after {
    font-size: 8px;
    transform: translate(-50%, -50%) scale(2);
  }
  /* Adjust alignment for smaller mobile portrait */
  .filter-category label span.checkbox-wrapper + * {
    transform: translateY(1.2px);
  }
  #clear-filters-home-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
  #filter-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }

  .storage-grid {
    gap: 2px;
    padding: 0.5rem;
    overflow-x: auto;
  }

  .storage-slot {
    min-height: 100px;
  }

  .slot-watch-image {
    max-width: 50px;
  }

  .grid-header, .grid-row-label {
    font-size: min(0.7rem, 2vw);
    padding: min(0.2rem, 1vw);
    min-width: 25px;
  }

  .slot-buttons {
    flex-direction: column;
    gap: 0.3rem;
  }

  .slot-buttons button {
    font-size: min(0.6rem, 1.8vw);
    padding: min(0.2rem, 0.8vw) min(0.4rem, 1.2vw);
  }

  .header-row h2 {
    font-size: 1.4rem;
  }

  .header-row button {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  .watch-count {
    font-size: 0.85rem;
  }

  .left-header-group h2 {
    width: 100%;
  }

  .left-header-group button {
    min-width: 120px;
    text-align: center;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
  }

  #jills-watches-btn {
    min-width: 120px;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
  }

  /* Mobile portrait: stack button below */
  .wish-list-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .wish-list-header #jills-wish-list-btn {
    min-width: 120px;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
  }

  #sort-dropdown button {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }

  .value-sort-row {
    position: relative;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    min-height: 0;
  }

}

@media (max-width: 896px) and (orientation: landscape) {
  header {
    padding: 0.15rem;
  }
  header h1 {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
  }
  nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.15rem;
    padding: 3px;
    white-space: nowrap;
  }
  nav button {
    padding: 0.2rem 0.4rem;
    font-size: 0.65rem;
    min-width: 50px;
  }
  .main-content {
    margin-top: 1rem;
  }
  .watch-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.8rem;
  }
  .watch-card {
    max-width: 140px;
    min-height: 220px;
  }
  .image-container {
    width: 120px;
    height: 120px;
  }
  .watch-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
  }
  .watch-brand, .watch-model, .watch-reference {
    font-size: 0.75rem;
  }
  .watch-buttons button {
    padding: 0.2rem 0.3rem;
    font-size: 0.6rem;
  }
  .calendar-grid {
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    padding: 0.4rem;
    overflow-x: auto;
    max-width: 100%;
  }
  .calendar-grid > div:not(.calendar-day) {
    font-size: 0.6rem;
    padding: 0.15rem;
    text-align: center;
    color: #D4D4D8;
    font-weight: 600;
    background: #1C2526;
  }
  .calendar-day {
    min-height: 60px;
    padding: 0.15rem;
    font-size: 0.55rem;
    border-radius: 6px;
  }
  .calendar-day span.day-number {
    font-size: 0.7rem;
  }
  .calendar-day .thumbnails {
    gap: 2px;
    flex-wrap: wrap;
  }
  .calendar-day .thumbnail-wrapper img {
    width: 20px;
    height: 20px;
    border-radius: 3px;
  }
  .calendar-day .add-wear-btn {
    width: 16px;
    height: 16px;
    font-size: 0.7rem;
    bottom: 2px;
    right: 2px;
  }
  .calendar-day .thumbnail-wrapper .thumbnail-popup {
    top: -80px;
    width: 80px;
  }
  .calendar-day .thumbnail-wrapper .thumbnail-popup img {
    width: 60px;
    height: 60px;
    object-fit: cover;
  }
  .calendar-day .thumbnail-wrapper .thumbnail-popup .delete-wear {
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
  }
  .watch-details-popup {
    max-height: calc(80vh - 1rem);
    padding: 0.8rem;
  }
  .watch-details-popup img {
    width: 200px;
    height: 200px;
  }
  .wear-popup {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 200px;
    padding: 0.8rem;
    z-index: 2000;
  }
  .wear-popup select, .wear-popup input[type="range"] {
    padding: 0.4rem;
    font-size: 0.8rem;
  }
  .wear-popup button {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }
  .warranty-indicator .warranty-popup {
    font-size: 0.55rem;
    padding: 0.15rem 0.3rem;
    top: 0px;
    left: calc(50% - 98px);
    z-index: 60;
  }
  .service-records-popup {
    padding: 0.8rem;
    max-height: calc(80vh - 1rem);
  }
  .service-records-popup h3 {
    font-size: 1.3rem;
  }
  .service-records-popup #add-service-record-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }
  .service-records-popup li {
    padding: 0.5rem;
  }
  .service-records-popup p {
    font-size: 0.8rem;
  }
  .service-records-popup .delete-service-btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
  }
  .service-records-popup .edit-service-btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
  }
  .service-records-popup .service-record-actions {
    gap: 0.3rem;
  }
  .service-record-form-popup {
    padding: 0.8rem;
    max-height: calc(80vh - 1rem);
  }
  .service-record-form-popup h3 {
    font-size: 1.3rem;
  }
  .service-record-form-popup input,
  .service-record-form-popup textarea {
    padding: 0.3rem;
    font-size: 0.75rem;
  }
  .service-record-form-popup button[type="submit"] {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }
  .filter-popup {
    max-height: calc(80vh - 1rem);
    padding: 0.6rem;
  }
  .filter-options {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.4rem;
  }
  .filter-category {
    gap: 0.1rem;
  }
  .filter-category h4 {
    font-size: 0.75rem;
    font-weight: bold;
    margin-bottom: 0.2rem;
  }
  .filter-category label {
    font-size: 0.65rem;
    gap: 0.2rem;
    line-height: 1;
  }
  .filter-category .checkbox-wrapper {
    height: 8px;
  }
  .filter-category input[type="checkbox"] {
    transform: scale(0.5);
  }
  .filter-category input[type="checkbox"]:checked::after {
    font-size: 8px;
    transform: translate(-50%, -50%) scale(2);
  }
  /* Adjust alignment for landscape */
  .filter-category label span.checkbox-wrapper + * {
    transform: translateY(1.2px);
  }

  #search-bar {
    max-width: 100%;
  }

  .search-container {
    width: 100%;
    justify-content: flex-end;
  }

  /* Mobile landscape: keep button to the right */
  .wish-list-header {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.3rem;
  }
}

/* Add print styles for Storage page (add at the end or in a new @media print block) */
@media print {
  body * {
    visibility: hidden;
  }

  #storage-list, #storage-list * {
    visibility: visible;
  }

  #storage-list {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .storage-header, .storage-unit-header button, .slot-buttons {
    display: none; /* Hide buttons and headers for print */
  }

  .storage-unit {
    page-break-inside: avoid; /* Avoid breaking units across pages */
    margin-bottom: 20mm; /* Space between units */
  }

  .storage-unit-header {
    margin-bottom: 5mm; /* Reduced spacing for print */
  }

  .storage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(30mm, 1fr)); /* Shrink columns to fit letter paper */
    gap: 5mm; /* Reduced gap for compactness */
    padding: 5mm; /* Reduced padding */
    border-radius: 0; /* Simplify for print */
    box-shadow: none; /* Remove shadow for print */
  }

  .grid-header, .grid-row-label {
    font-size: 8pt; /* Smaller font for print */
    padding: 2mm; /* Reduced padding */
  }

  .storage-slot {
    min-height: 30mm; /* Shrink height to fit more on page */
    padding: 2mm; /* Reduced padding */
    border-radius: 0; /* Simplify for print */
    font-size: 8pt; /* Smaller text */
  }

  .slot-watch-image {
    width: 25mm; /* Shrink images to fit */
    height: auto;
  }

  @page {
    size: letter portrait;
    margin: 10mm; /* Minimal margins for 8.5x11 paper */
  }
}

/* Settings Page Styles */
.settings-header {
  display: flex;
  justify-content: space-between; /* Align h2 left, button right */
  align-items: center; /* Vertically center */
  margin-bottom: 1.5rem;
  flex-wrap: nowrap; /* Prevent wrapping */
}

.settings-header h2 {
  font-size: 2rem;
  font-weight: 600;
  color: #F8F8FF;
  margin: 0; /* Remove default margin for alignment */
}

.settings-header-buttons {
  display: flex;
  gap: 0.5rem; /* Space between buttons */
}

.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-section {
  background: #1C2526;
  padding: 1rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.settings-section summary {
  font-size: 1.5rem;
  font-weight: 600;
  color: #F8F8FF;
  cursor: pointer;
}

.field-manager {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-category {
  background: #2A2D2E;
  padding: 1rem;
  border-radius: 8px;
}

.field-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.edit-input {
  flex: 1;
  padding: 0.4rem;
  background: #4B5563;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.audit-watch {
  background: #2A2D2E;
  padding: 1rem;
  border-radius: 8px;
}

.document-group {
  margin-bottom: 0.5rem;
}

.save-audit-btn {
  background: transparent;
  border: 1px solid #3B82F6; /* Match other buttons */
  color: #3B82F6;
  padding: 0.6rem 1.2rem; /* Match padding */
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem; /* Match font size */
  font-weight: 500; /* Match font weight */
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.save-audit-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.audit-results {
  margin-top: 1rem;
  background: #2A2D2E;
  padding: 1rem;
  border-radius: 8px;
}

.audit-results h3 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.audit-results ul {
  list-style: none;
  padding: 0;
}

.audit-results li {
  margin-bottom: 0.5rem;
}

#run-document-audit-btn,
#clear-document-audit-btn {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

#run-document-audit-btn:hover,
#clear-document-audit-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Collection Header */
.collection-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #1C2526; /* Match other headers */
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header-top h2 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 600;
  color: #F8F8FF;
}
.header-actions {
  display: flex;
  gap: 0.5rem;
}
.header-bottom {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.owner-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.owner-btn {
  background: #2A2D2E;
  color: #F3F4F6;
  padding: 0.6rem 1rem;
  border: 1px solid #3B82F6;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}
.owner-btn:hover {
  background: #3B82F6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.owner-btn.active {
  background: #3B82F6;
  color: #F3F4F6;
}
.sort-filter-container {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.sort-selector select, .filter-selector select {
  background: #2A2D2E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #F3F4F6;
  padding: 0.6rem;
  font-size: 0.9rem;
}
.sort-selector select:focus, .filter-selector select:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}
.clear-filter-btn {
  background: transparent;
  color: #EF4444;
  border: none;
  padding: 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.2s, transform 0.2s;
}
.clear-filter-btn:hover {
  color: #DC2626;
  transform: scale(1.1);
}
#collection-value {
  font-size: 1.2rem;
  font-weight: 500;
  color: #D4D4D8;
  margin: 0;
}
@media (max-width: 768px) {
  .collection-header {
    padding: 0.8rem;
  }
  .header-top h2 {
    font-size: 1.6rem;
  }
  .header-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .owner-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
  }
  .sort-selector select, .filter-selector select {
    padding: 0.5rem;
    font-size: 0.85rem;
  }
  .clear-filter-btn {
    padding: 0.5rem;
    font-size: 0.85rem;
  }
  #collection-value {
    font-size: 1.1rem;
  }
}
@media (max-width: 480px) {
  .collection-header {
    padding: 0.6rem;
  }
  .header-top h2 {
    font-size: 1.4rem;
  }
  .owner-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
  .sort-selector select, .filter-selector select {
    padding: 0.4rem;
    font-size: 0.8rem;
  }
  .clear-filter-btn {
    padding: 0.4rem;
    font-size: 0.8rem;
  }
  #collection-value {
    font-size: 1rem;
  }
}

.document-upload {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.add-document-btn {
  background: transparent;
  border: 1px solid #3B82F6;
  color: #3B82F6;
  padding: 0.4rem 0.8rem; /* Smaller than header buttons */
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.add-document-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Accordion Styles */
details.settings-section {
  transition: all 0.2s ease;
}

details.settings-section[open] summary {
  margin-bottom: 0.5rem;
}