:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #3b82f6;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 800px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
}

.logo-icon {
  font-size: 1.5rem;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* Update Banner */
.update-banner {
  background: var(--primary);
  color: white;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.update-banner.hidden {
  display: none;
}

/* Main Container */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  background: white;
  padding: 0.25rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
}

.tab {
  flex: 1;
  padding: 0.75rem;
  border: none;
  background: transparent;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--gray-900);
}

.tab.active {
  background: var(--primary);
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Cards */
.card {
  background: white;
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

/* Location Cards */
.location-card {
  background: white;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.location-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.location-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--gray-800);
}

.location-badge {
  background: var(--warning);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
}

.location-actions {
  display: flex;
  gap: 0.5rem;
}

/* Location header icon buttons (dashboard) */
.location-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.location-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: var(--gray-100);
  color: var(--gray-700);
  border: none;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
}

.location-icon-btn:hover {
  background: var(--gray-200);
}

.location-icon-btn:active {
  transform: scale(0.95);
}

/* Notes button in locations list */
.notes-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  margin-left: 0.25rem;
  border-radius: 0.375rem;
  background: transparent;
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s;
}

.notes-btn:hover,
.notes-btn.has-notes {
  opacity: 1;
  background: var(--gray-100);
}

.notes-btn:active {
  transform: scale(0.95);
}

/* Location notes preview shown in locations list */
.location-notes-preview {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--gray-50);
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: var(--gray-600);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  border-left: 3px solid var(--gray-300);
}

.pickup-list {
  padding: 0.5rem;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--gray-400);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

/* Pickup Items */
.pickup-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  background: var(--gray-50);
  transition: background 0.2s;
}

.pickup-item:last-child {
  margin-bottom: 0;
}

.pickup-item:hover {
  background: var(--gray-100);
}

.pickup-info {
  flex: 1;
  min-width: 0;
}

.pickup-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.pickup-number {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-900);
}

.pickup-desc {
  font-size: 0.875rem;
  color: var(--gray-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pickup-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.pickup-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.badge-paid {
  background: #dbeafe;
  color: #1e40af;
}

.badge-picked {
  background: #d1fae5;
  color: #065f46;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fecaca;
}

.btn-sm {
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 0.5rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
}

.btn-icon-only {
  padding: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 0.375rem;
  color: var(--gray-500);
}

.btn-icon-only:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.625rem center;
  background-repeat: no-repeat;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  border-radius: 1rem 1rem 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--gray-200);
}

.modal-footer .btn {
  flex: 1;
}

/* Location List */
.location-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: white;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.location-list-item.default .location-list-name {
  color: var(--primary);
  font-weight: 600;
}

.location-list-name {
  font-size: 0.9375rem;
}

.location-list-badge {
  font-size: 0.625rem;
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  margin-left: 0.5rem;
  text-transform: uppercase;
}

/* FAB - Fixed positioning to stay bottom-right regardless of tab content */
.fab-container {
  position: fixed !important;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 50;
  /* Ensure fixed positioning is respected */
  transform: translateZ(0);
  will-change: transform;
}

.fab-btn {
  position: fixed !important;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
}

.fab {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s, box-shadow 0.2s;
  /* Ensure consistent sizing */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

/* Location details styles */
.location-details {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-200);
  font-size: 0.875rem;
  color: var(--gray-600);
}

.location-details-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}

.location-details-row:last-child {
  margin-bottom: 0;
}

.location-details-icon {
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
}

.location-details-text {
  word-break: break-word;
}

.location-actions-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-200);
}

.location-actions-row .btn {
  flex: 1;
  font-size: 0.75rem;
  padding: 0.5rem 0.75rem;
}

/* Clickable status badge */
.status-clickable {
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s;
}

.status-clickable:hover {
  transform: scale(1.05);
}

.status-clickable:active {
  transform: scale(0.95);
}

/* Picked History Section */
.picked-history-card {
  background: white;
  border-radius: 0.75rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.picked-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.picked-history-header:hover {
  background: var(--gray-100);
}

.picked-history-header:active {
  background: var(--gray-200);
}

.picked-history-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--gray-700);
}

.picked-history-chevron {
  font-size: 0.875rem;
  color: var(--gray-500);
  transition: transform 0.2s;
}

.picked-history-content {
  padding: 0.5rem;
  animation: slideDown 0.3s ease;
}

.picked-history-content.hidden {
  display: none;
}

.picked-location-group {
  margin-bottom: 0.75rem;
}

.picked-location-group:last-child {
  margin-bottom: 0;
}

.picked-location-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-500);
  padding: 0.5rem 0.75rem;
  background: var(--gray-100);
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
}

.picked-list {
  padding: 0 0.25rem;
}

.picked-list .pickup-item {
  opacity: 0.75;
}

.picked-list .pickup-item:hover {
  opacity: 1;
}

/* Import/Export section */
.data-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.data-actions .btn {
  flex: 1;
  min-width: 120px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 90%;
  max-width: 400px;
}

.toast {
  background: var(--gray-800);
  color: white;
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  animation: slideUp 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

/* Utility classes */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

/* Desktop adjustments */
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
  
  .modal {
    border-radius: 1rem;
    max-height: 85vh;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
/* Location notes placeholder */
.location-notes-placeholder {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--gray-400);
  font-style: italic;
}

/* Picked history in locations list */
.location-picked-history {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-200);
}

.location-picked-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0.5rem 0;
}

.location-picked-toggle:hover {
  opacity: 0.8;
}

.location-picked-toggle .picked-history-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
}

.location-picked-toggle .picked-history-chevron {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.location-picked-history .picked-history-content {
  margin-top: 0.5rem;
}

.location-picked-history .picked-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.location-picked-history .picked-list .pickup-item {
  background: var(--gray-50);
  border-radius: 0.375rem;
  padding: 0.625rem;
}
