/* ==========================================================================
   Metal Detecting Site Tracker - Design System
   A responsive, earth-toned CSS framework for field use on desktop and mobile.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Custom Properties / Theming
   -------------------------------------------------------------------------- */
:root {
  /* Brand colors */
  --color-primary: #5c4033;
  --color-primary-light: #7a5c4f;
  --color-primary-dark: #3e2a22;
  --color-secondary: #8B7355;
  --color-secondary-light: #a8956f;
  --color-secondary-dark: #6e5a42;
  --color-accent: #2d5016;
  --color-accent-light: #3d6b1e;
  --color-accent-dark: #1e3a0e;

  /* Surfaces */
  --color-bg: #faf6f1;
  --color-card: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b6b;
  --color-text-light: #999999;
  --color-border: #d9d0c7;
  --color-border-light: #e8e2db;

  /* Status colors */
  --color-status-green: #22c55e;
  --color-status-green-bg: #dcfce7;
  --color-status-yellow: #eab308;
  --color-status-yellow-bg: #fef9c3;
  --color-status-red: #ef4444;
  --color-status-red-bg: #fee2e2;
  --color-status-blue: #3b82f6;
  --color-status-blue-bg: #dbeafe;
  --color-status-gray: #6b7280;
  --color-status-gray-bg: #f3f4f6;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Borders & Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.16);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* Layout */
  --nav-height: 56px;
  --sidebar-width: 280px;
  --container-max: 1200px;
  --tap-target-min: 44px;
}

/* --------------------------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-dark);
  text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  color: var(--color-primary-dark);
  font-weight: 600;
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

/* --------------------------------------------------------------------------
   3. Navigation Bar
   -------------------------------------------------------------------------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  padding: 0 var(--space-md);
  background-color: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  white-space: nowrap;
}

.navbar__brand:hover {
  color: #ffffff;
  text-decoration: none;
  opacity: 0.9;
}

.navbar__links {
  display: none;
  list-style: none;
  gap: var(--space-xs);
}

.navbar__links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target-min);
  padding: var(--space-sm) var(--space-md);
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}

.navbar__links a:hover,
.navbar__links a.active {
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  text-decoration: none;
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Hamburger menu toggle */
.navbar__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-target-min);
  height: var(--tap-target-min);
  padding: 0;
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.navbar__toggle:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.navbar__toggle-icon {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 22px;
  height: 22px;
}

.navbar__toggle-icon span {
  display: block;
  height: 2px;
  width: 100%;
  background-color: #ffffff;
  border-radius: 1px;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

/* Active hamburger state */
.navbar__toggle.is-active .navbar__toggle-icon span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.navbar__toggle.is-active .navbar__toggle-icon span:nth-child(2) {
  opacity: 0;
}

.navbar__toggle.is-active .navbar__toggle-icon span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile nav drawer */
.navbar__mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-primary);
  z-index: 999;
  overflow-y: auto;
  padding: var(--space-md);
}

.navbar__mobile-menu.is-open {
  display: block;
}

.navbar__mobile-menu a {
  display: flex;
  align-items: center;
  min-height: var(--tap-target-min);
  padding: var(--space-md);
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--font-size-lg);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
  text-decoration: none;
}

.navbar__mobile-menu a:hover,
.navbar__mobile-menu a.active {
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  text-decoration: none;
}

/* ---- Alias rules for .nav-brand / .nav-links / .nav-toggle (used in HTML) ---- */
.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  white-space: nowrap;
}

.nav-links {
  display: none;
  list-style: none;
  gap: var(--space-xs);
  align-items: center;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target-min);
  padding: var(--space-sm) var(--space-md);
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a.active {
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  text-decoration: none;
}

.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-target-min);
  height: var(--tap-target-min);
  padding: 0;
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
  font-size: 24px;
}

.nav-toggle:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

/* Mobile open state */
.nav-links.open {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  background-color: var(--color-primary);
  z-index: 999;
  padding: var(--space-md);
  box-shadow: var(--shadow-lg);
}

.nav-links.open a {
  display: flex;
  width: 100%;
  padding: var(--space-md);
  font-size: var(--font-size-lg);
}

/* Body offset for fixed nav */
.page-body {
  padding-top: var(--nav-height);
}

/* --------------------------------------------------------------------------
   4. Cards
   -------------------------------------------------------------------------- */
.card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card--clickable {
  cursor: pointer;
}

.card--clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
}

.card__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-primary-dark);
}

.card__body {
  padding: var(--space-lg);
}

.card__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border-light);
  background-color: var(--color-bg);
}

/* --------------------------------------------------------------------------
   5. Status Badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px 10px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.8;
}

.badge--green,
.badge--granted,
.badge--approved {
  color: #166534;
  background-color: var(--color-status-green-bg);
  border: 1px solid #bbf7d0;
}

.badge--yellow,
.badge--pending,
.badge--requested {
  color: #854d0e;
  background-color: var(--color-status-yellow-bg);
  border: 1px solid #fde68a;
}

.badge--red,
.badge--denied {
  color: #991b1b;
  background-color: var(--color-status-red-bg);
  border: 1px solid #fecaca;
}

.badge--blue,
.badge--not_required,
.badge--identified {
  color: #1e40af;
  background-color: var(--color-status-blue-bg);
  border: 1px solid #bfdbfe;
}

.badge--gray,
.badge--not_requested,
.badge--exhausted {
  color: #374151;
  background-color: var(--color-status-gray-bg);
  border: 1px solid #e5e7eb;
}

/* --------------------------------------------------------------------------
   6. Priority Stars
   -------------------------------------------------------------------------- */
.priority-stars {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--font-size-lg);
  line-height: 1;
}

.priority-stars__star {
  color: var(--color-border);
}

.priority-stars__star--filled {
  color: #d97706;
}

/* --------------------------------------------------------------------------
   7. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--tap-target-min);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.4;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

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

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

.btn--primary:hover {
  background-color: var(--color-primary-dark);
  color: #ffffff;
  text-decoration: none;
}

.btn--secondary {
  background-color: var(--color-secondary);
  color: #ffffff;
}

.btn--secondary:hover {
  background-color: var(--color-secondary-dark);
  color: #ffffff;
  text-decoration: none;
}

.btn--accent {
  background-color: var(--color-accent);
  color: #ffffff;
}

.btn--accent:hover {
  background-color: var(--color-accent-dark);
  color: #ffffff;
  text-decoration: none;
}

.btn--outline {
  background-color: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn--outline:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  text-decoration: none;
}

.btn--danger {
  background-color: var(--color-status-red);
  color: #ffffff;
}

.btn--danger:hover {
  background-color: #dc2626;
  color: #ffffff;
  text-decoration: none;
}

.btn--ghost {
  background-color: transparent;
  color: var(--color-text-muted);
}

.btn--ghost:hover {
  background-color: var(--color-border-light);
  color: var(--color-text);
  text-decoration: none;
}

.btn--sm {
  min-height: 36px;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-xs);
}

.btn--lg {
  min-height: 52px;
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-lg);
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* --------------------------------------------------------------------------
   8. Forms
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-label--required::after {
  content: " *";
  color: var(--color-status-red);
}

.form-hint {
  display: block;
  margin-top: var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.form-input,
.form-select,
.form-textarea,
.form-control,
input.form-control,
select.form-control,
textarea.form-control {
  display: block;
  width: 100%;
  min-height: var(--tap-target-min);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder,
.form-control::placeholder {
  color: var(--color-text-light);
}

.form-input.is-error,
.form-select.is-error,
.form-textarea.is-error,
.form-control.is-error {
  border-color: var(--color-status-red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6b6b' d='M6 8.825L.35 3.175l.7-.7L6 7.425l4.95-4.95.7.7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

.form-error-msg {
  display: block;
  margin-top: var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--color-status-red);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6b6b' d='M6 8.825L.35 3.175l.7-.7L6 7.425l4.95-4.95.7.7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: var(--tap-target-min);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.form-row .form-group {
  flex: 1;
  min-width: 200px;
}

/* --------------------------------------------------------------------------
   9. Modals
   -------------------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal-overlay.is-open,
.modal-overlay.open {
  display: flex;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: calc(100vh - 2 * var(--space-xl));
  display: flex;
  flex-direction: column;
  background-color: var(--color-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modal-enter var(--transition-base);
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal--lg {
  max-width: 800px;
}

.modal--sm {
  max-width: 400px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

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

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.modal__close:hover {
  background-color: var(--color-border-light);
  color: var(--color-text);
}

.modal__body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border-light);
  background-color: var(--color-bg);
  flex-shrink: 0;
}

/* ---- Dash-style aliases for modal inner classes (HTML uses .modal-header etc) ---- */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-primary-dark);
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background-color: var(--color-border-light);
  color: var(--color-text);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border-light);
  background-color: var(--color-bg);
  flex-shrink: 0;
}

.modal-footer-right {
  display: flex;
  gap: var(--space-sm);
  margin-left: auto;
}

/* Fieldset in modals */
.form-fieldset {
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.form-fieldset legend {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-primary);
  padding: 0 var(--space-sm);
}

.form-group-btn {
  display: flex;
  align-items: flex-end;
}

/* --------------------------------------------------------------------------
   10. Split View Layout (List + Map)
   -------------------------------------------------------------------------- */
.split-view {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--nav-height));
}

.split-view__list {
  width: 100%;
  overflow-y: auto;
  padding: var(--space-md);
  background-color: var(--color-bg);
}

.split-view__map {
  width: 100%;
  height: 50vh;
  min-height: 300px;
  position: relative;
}

/* --------------------------------------------------------------------------
   11. Map Container (Leaflet compatible)
   -------------------------------------------------------------------------- */
.map-container {
  width: 100%;
  height: 100%;
  min-height: 300px;
  background-color: #e5e1da;
  z-index: 1;
}

/* Crosshair cursor mode for pin placement */
.map-container--crosshair,
.map-container--crosshair .leaflet-container {
  cursor: crosshair !important;
}

.map-container--crosshair .leaflet-grab {
  cursor: crosshair !important;
}

.map-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background-color: var(--color-card);
  border-bottom: 1px solid var(--color-border-light);
}

/* Make Leaflet popups match our theme */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font-family) !important;
}

.leaflet-popup-content {
  margin: var(--space-md) !important;
  font-size: var(--font-size-sm) !important;
  line-height: 1.5 !important;
}

.leaflet-popup-content .popup-title {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--color-primary-dark);
  margin-bottom: var(--space-xs);
}

.leaflet-popup-content .popup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.leaflet-popup-content .popup-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 600;
  color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   12. Stat Cards
   -------------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background-color: var(--color-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.stat-card-link:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-secondary);
  transform: translateY(-2px);
}

.stat-card__value {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  line-height: 1.1;
  color: var(--color-primary);
}

.stat-card__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.stat-card--accent .stat-card__value {
  color: var(--color-accent);
}

.stat-card--warning .stat-card__value {
  color: var(--color-status-yellow);
}

.stat-card--danger .stat-card__value {
  color: var(--color-status-red);
}

/* --------------------------------------------------------------------------
   13. Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  background-color: var(--color-card);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table th,
.table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.table th {
  font-weight: 700;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background-color: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background-color: rgba(250, 246, 241, 0.6);
}

.table--striped tbody tr:nth-child(even) {
  background-color: rgba(250, 246, 241, 0.4);
}

.table--clickable tbody tr {
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   14. Tag Pills
   -------------------------------------------------------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px 10px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-secondary-dark);
  background-color: #f0ebe3;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.8;
}

.tag--removable {
  padding-right: 6px;
}

.tag__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 14px;
  line-height: 1;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.tag__remove:hover {
  background-color: rgba(0, 0, 0, 0.1);
  color: var(--color-status-red);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* --------------------------------------------------------------------------
   15. Image Upload / Drag-Drop Area
   -------------------------------------------------------------------------- */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 160px;
  padding: var(--space-xl);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background-color: var(--color-bg);
  color: var(--color-text-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.upload-area:hover {
  border-color: var(--color-secondary);
  background-color: #f5f0e8;
}

.upload-area.is-dragover {
  border-color: var(--color-accent);
  background-color: rgba(45, 80, 22, 0.05);
}

.upload-area__icon {
  font-size: 2rem;
  color: var(--color-secondary);
}

.upload-area__text {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.upload-area__hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
}

/* Preview thumbnails */
.upload-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.upload-preview__item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border-light);
}

.upload-preview__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-preview__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}

/* File input styling */
.file-input-wrap {
  position: relative;
  display: inline-flex;
}

.file-input-wrap input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

/* --------------------------------------------------------------------------
   16. Container & Layout Helpers
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.page-content {
  padding: var(--space-lg) 0;
}

.section {
  margin-bottom: var(--space-2xl);
}

.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

/* --------------------------------------------------------------------------
   17. Loading / Empty States
   -------------------------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--color-text);
}

.empty-state__text {
  font-size: var(--font-size-sm);
  max-width: 400px;
}

/* --------------------------------------------------------------------------
   18. Alerts / Toasts
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  border: 1px solid transparent;
  margin-bottom: var(--space-md);
}

.alert--info {
  color: #1e40af;
  background-color: var(--color-status-blue-bg);
  border-color: #bfdbfe;
}

.alert--success {
  color: #166534;
  background-color: var(--color-status-green-bg);
  border-color: #bbf7d0;
}

.alert--warning {
  color: #854d0e;
  background-color: var(--color-status-yellow-bg);
  border-color: #fde68a;
}

.alert--error {
  color: #991b1b;
  background-color: var(--color-status-red-bg);
  border-color: #fecaca;
}

/* --------------------------------------------------------------------------
   19. Utility Classes
   -------------------------------------------------------------------------- */

/* Text alignment */
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

/* Font sizing */
.text-xs   { font-size: var(--font-size-xs); }
.text-sm   { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg   { font-size: var(--font-size-lg); }
.text-xl   { font-size: var(--font-size-xl); }

/* Font weight */
.font-normal   { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* Colors */
.text-muted   { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-accent  { color: var(--color-accent); }
.text-danger  { color: var(--color-status-red); }
.text-success { color: var(--color-status-green); }

/* Display */
.hidden     { display: none !important; }
.block      { display: block; }
.inline     { display: inline; }
.flex       { display: flex; }
.inline-flex { display: inline-flex; }
.grid       { display: grid; }

/* Flex helpers */
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.flex-1 { flex: 1; }

/* Spacing - margin */
.m-0   { margin: 0; }
.m-1   { margin: var(--space-md); }
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: var(--space-md); }
.mt-2  { margin-top: var(--space-lg); }
.mt-3  { margin-top: var(--space-xl); }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: var(--space-md); }
.mb-2  { margin-bottom: var(--space-lg); }
.mb-3  { margin-bottom: var(--space-xl); }
.ml-1  { margin-left: var(--space-md); }
.mr-1  { margin-right: var(--space-md); }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Spacing - padding */
.p-0  { padding: 0; }
.p-1  { padding: var(--space-md); }
.p-2  { padding: var(--space-lg); }
.pt-1 { padding-top: var(--space-md); }
.pb-1 { padding-bottom: var(--space-md); }
.px-1 { padding-left: var(--space-md); padding-right: var(--space-md); }
.py-1 { padding-top: var(--space-md); padding-bottom: var(--space-md); }

/* Width */
.w-full { width: 100%; }
.w-auto { width: auto; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }

/* Border */
.border     { border: 1px solid var(--color-border-light); }
.border-t   { border-top: 1px solid var(--color-border-light); }
.border-b   { border-bottom: 1px solid var(--color-border-light); }
.rounded    { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }

/* Truncation */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   20. Responsive Breakpoints
   -------------------------------------------------------------------------- */

/* Tablet (768px+) */
@media (min-width: 768px) {
  :root {
    --nav-height: 60px;
  }

  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .navbar__links,
  .nav-links {
    display: flex;
  }

  .navbar__toggle,
  .nav-toggle {
    display: none;
  }

  .split-view__map {
    height: 55vh;
    min-height: 400px;
  }

  .modal {
    max-height: calc(100vh - 4rem);
  }

  .upload-preview {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .split-view {
    flex-direction: row;
    height: calc(100vh - var(--nav-height));
  }

  .split-view__list {
    width: 40%;
    height: 100%;
    overflow-y: auto;
    border-right: 1px solid var(--color-border-light);
  }

  .split-view__map {
    width: 60%;
    height: 100%;
    min-height: unset;
  }

  .container {
    padding: 0 var(--space-lg);
  }

  .table th,
  .table td {
    padding: var(--space-md) var(--space-lg);
  }
}

/* Large desktop (1280px+) */
@media (min-width: 1280px) {
  .stat-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Touch-friendly overrides for coarse pointer devices (phones, tablets) */
@media (pointer: coarse) {
  .btn {
    min-height: var(--tap-target-min);
  }

  .form-input,
  .form-select,
  .form-textarea {
    min-height: var(--tap-target-min);
    font-size: 16px; /* Prevent iOS zoom on focus */
  }

  .navbar__mobile-menu a {
    min-height: 48px;
  }

  .table th,
  .table td {
    padding: var(--space-md);
  }

  .tag {
    padding: 4px 12px;
    min-height: 32px;
  }
}

/* Print */
@media print {
  .navbar,
  .navbar__mobile-menu,
  .map-container,
  .btn,
  .modal-overlay {
    display: none !important;
  }

  .page-body {
    padding-top: 0;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .card {
    box-shadow: none;
    border: 1px solid #cccccc;
    break-inside: avoid;
  }
}

/* ==========================================================================
   ADDITIONAL STYLES - Dashboard, Legal, Permissions, Finds pages
   ========================================================================== */

/* Page titles and sections */
.page-title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-primary);
  margin: 0 0 var(--space-lg) 0;
}

.section-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 var(--space-md) 0;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-md);
}

/* Dashboard page */
.dashboard-page {
  padding: calc(var(--nav-height) + var(--space-lg)) var(--space-md) var(--space-xl);
  max-width: 1200px;
  margin: 0 auto;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

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

.stat-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-primary);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* Dashboard map */
.dashboard-map-section {
  margin-bottom: var(--space-xl);
}

.dashboard-map {
  width: 100%;
  height: 450px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

/* Map legend */
.map-legend {
  padding: var(--space-md);
  background: var(--color-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  margin-top: var(--space-md);
}

.map-legend h3 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-sm) 0;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
}

.legend-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

/* Recent activity */
.recent-activity-section {
  margin-bottom: var(--space-xl);
}

.recent-activity-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.activity-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--color-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.activity-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-secondary);
}

.activity-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.activity-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.activity-date {
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
}

.empty-text, .loading-text, .error-text {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  padding: var(--space-lg);
  text-align: center;
}

.error-text { color: var(--color-status-red); }

/* Custom map pin (no default leaflet icon background) */
.custom-pin { background: none !important; border: none !important; }
.map-popup strong { color: var(--color-primary); }
.map-popup p { margin: 2px 0; font-size: var(--font-size-sm); color: var(--color-text-muted); }
.map-popup-actions { margin-top: 6px; }
.map-popup-actions .popup-link {
  display: inline-block;
  padding: 3px 10px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: white;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}
.map-popup-actions .popup-link:hover { opacity: 0.85; }

/* Site type marker icons */
.site-type-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: white;
  border: 3px solid #95a5a6;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  transition: transform 0.15s ease;
}

.site-type-marker:hover {
  transform: scale(1.15);
}

.site-type-emoji {
  font-size: 18px;
  line-height: 1;
}

/* Legend icon for site types */
.legend-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

/* Activity card with icon */
.activity-type-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

/* Clickable URLs in detail sections */
.detail-link {
  color: var(--color-accent);
  text-decoration: underline;
  word-break: break-all;
}
.detail-link:hover {
  color: var(--color-primary);
}

/* Active state for clicked activity card */
.activity-card-active {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 2px var(--color-accent), var(--shadow-md) !important;
  background: rgba(45, 80, 22, 0.04);
}

/* ==========================================================================
   Legal Page
   ========================================================================== */
.legal-page {
  padding-top: calc(var(--nav-height) + var(--space-lg));
}

.legal-page h1 {
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

.legal-disclaimer {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
  margin-bottom: var(--space-xl);
  padding: var(--space-md);
  background: var(--color-status-yellow-bg);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-status-yellow);
}

/* Accordion */
.accordion {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.accordion-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-card);
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-card);
  border: none;
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-primary);
  text-align: left;
  transition: background var(--transition-fast);
}

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

.accordion-icon {
  font-size: var(--font-size-xl);
  font-weight: 700;
  transition: transform var(--transition-fast);
}

.accordion-item.open .accordion-icon {
  transform: rotate(45deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
  padding: 0 var(--space-lg);
}

.accordion-item.open .accordion-body {
  max-height: 2000px;
  padding: var(--space-md) var(--space-lg) var(--space-lg);
}

.accordion-body ul {
  margin: var(--space-sm) 0;
  padding-left: var(--space-lg);
}

.accordion-body li {
  margin-bottom: var(--space-xs);
  line-height: 1.5;
}

/* Legal cards */
.legal-card {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.legal-card h3 {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-base);
}

.legal-warning {
  background: var(--color-status-yellow-bg);
  border-left: 4px solid var(--color-status-yellow);
}

.legal-danger {
  background: var(--color-status-red-bg);
  border-left: 4px solid var(--color-status-red);
}

.legal-ok {
  background: var(--color-status-green-bg);
  border-left: 4px solid var(--color-status-green);
}

.legal-caution {
  background: var(--color-status-yellow-bg);
  border-left: 4px solid var(--color-status-yellow);
}

.contact-card {
  background: var(--color-status-blue-bg);
  border-left: 4px solid var(--color-status-blue);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin: var(--space-md) 0;
}

.contact-card h4 {
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-primary);
}

.contact-card p {
  margin: var(--space-xs) 0;
  font-size: var(--font-size-sm);
}

.contact-card a {
  color: var(--color-status-blue);
}

/* Legal table */
.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  margin-top: var(--space-md);
}

.legal-table th, .legal-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
}

.legal-table th {
  background: var(--color-bg);
  font-weight: 700;
}

.row-ok { background: var(--color-status-green-bg); }
.row-caution { background: var(--color-status-yellow-bg); }
.row-danger { background: var(--color-status-red-bg); }

/* ==========================================================================
   Sites / Finds / Permissions pages shared styles
   ========================================================================== */

/* Sites page layout */
.sites-page, .finds-page, .permissions-page {
  padding-top: var(--nav-height);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  align-items: center;
}

.filter-bar select, .filter-bar input {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  background: white;
  min-height: 40px;
}

/* Split view */
.split-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.list-panel {
  overflow-y: auto;
  padding: var(--space-md);
  background: var(--color-bg);
}

.map-panel {
  height: 50vh;
  min-height: 300px;
}

.map-panel #sites-map,
.map-panel .map-full {
  width: 100%;
  height: 100%;
}

@media (min-width: 768px) {
  .split-view {
    flex-direction: row;
  }
  .list-panel {
    width: 40%;
    order: 1;
  }
  .map-panel {
    width: 60%;
    height: auto;
    order: 2;
  }
}

/* Site/Find/Permission cards */
.site-card, .find-card, .permission-card {
  background: var(--color-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.site-card:hover, .find-card:hover, .permission-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-secondary);
}

.site-card.active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent);
}

.site-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-xs);
}

.site-card-header h3 {
  font-size: var(--font-size-base);
  margin: 0;
  color: var(--color-primary);
}

.site-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.site-card-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
}

/* Priority stars */
.priority-stars {
  color: var(--color-status-yellow);
  letter-spacing: 2px;
}

/* Tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: capitalize;
}

.badge.status-granted, .badge.status-approved { background: var(--color-status-green-bg); color: #166534; }
.badge.status-requested, .badge.status-pending { background: var(--color-status-yellow-bg); color: #854d0e; }
.badge.status-denied, .badge.status-expired { background: var(--color-status-red-bg); color: #991b1b; }
.badge.status-not-required, .badge.status-identified { background: var(--color-status-blue-bg); color: #1e40af; }
.badge.status-not-requested, .badge.status-exhausted, .badge.status-scouted { background: var(--color-status-gray-bg); color: #374151; }
.badge.status-detecting { background: var(--color-status-green-bg); color: #166534; }

/* Material badges */
.badge-iron { background: #d1d5db; color: #374151; }
.badge-copper { background: #fed7aa; color: #9a3412; }
.badge-brass { background: #fef3c7; color: #92400e; }
.badge-silver { background: #e5e7eb; color: #1f2937; }
.badge-gold { background: #fef9c3; color: #854d0e; }
.badge-lead { background: #d1d5db; color: #4b5563; }

/* Find cards */
.find-card {
  display: flex;
  gap: var(--space-md);
}

.find-card-photo {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--color-bg);
}

.find-card-photo-placeholder {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--color-text-light);
  flex-shrink: 0;
}

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

.find-card-info h3 {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--font-size-base);
  color: var(--color-primary);
}

.find-card-detail {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Permission cards */
.permission-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}

.permission-card-header h3 {
  margin: 0;
  font-size: var(--font-size-base);
  color: var(--color-primary);
}

.permission-card-dates {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.expiring-warning {
  background: var(--color-status-yellow-bg);
  border: 1px solid var(--color-status-yellow);
  color: #854d0e;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

/* Status tabs */
.status-tabs {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.status-tab {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: white;
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.status-tab:hover { background: var(--color-bg); }
.status-tab.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Card grid for finds */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
}

/* Permission/Finds list container */
.card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
}

/* Image upload area */
.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--color-accent);
  background: rgba(45, 80, 22, 0.05);
}

.upload-preview {
  max-width: 200px;
  max-height: 150px;
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
}

/* Tag suggestions */
.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.tag-suggestion {
  padding: 2px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  cursor: pointer;
  background: var(--color-bg);
  transition: all var(--transition-fast);
}

.tag-suggestion:hover, .tag-suggestion.selected {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.confirm-dialog {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.confirm-dialog h3 { margin: 0 0 var(--space-md); }
.confirm-dialog p { margin: 0 0 var(--space-lg); color: var(--color-text-muted); }

.confirm-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

/* Geolocation button */
.btn-location {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-status-blue);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
}

.btn-location:hover { background: #2563eb; }

/* Tag chips (site cards, find cards) */
.tag-chip {
  display: inline-block;
  padding: 2px 8px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: white;
  background-color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.6;
  margin-right: 4px;
  margin-bottom: 4px;
}

/* Tags on cards (read-only display) */
.site-card-tags .tag-chip {
  color: var(--color-secondary-dark);
  background-color: #f0ebe3;
  border-color: var(--color-border);
}

/* Suggestion tags in the modal - muted style */
.tag-chip.suggestion {
  cursor: pointer;
  color: var(--color-text-muted);
  background-color: var(--color-bg);
  border-color: var(--color-border);
  transition: all var(--transition-fast);
}

.tag-chip.suggestion:hover {
  background-color: var(--color-secondary);
  color: white;
  border-color: var(--color-secondary);
}

.tag-chip .tag-remove {
  display: inline;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 0 0 4px;
  font-size: 14px;
}

.tag-chip .tag-remove:hover {
  color: var(--color-status-red);
}

.site-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--space-xs);
}

.site-card-image {
  margin-bottom: var(--space-sm);
}

.site-card-thumb-placeholder {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-sm);
  font-size: 32px;
}

/* Site card action buttons */
.site-card-actions {
  display: flex;
  gap: 6px;
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border-light);
}

.btn-sm {
  padding: 4px 12px;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-card);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.btn-sm:hover {
  background: var(--color-bg-subtle);
}

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

.btn-sm.btn-view:hover {
  opacity: 0.85;
}

.btn-sm.btn-edit {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.btn-sm.btn-edit:hover {
  opacity: 0.85;
}

.btn-sm.btn-map-focus {
  background: var(--color-status-blue);
  color: white;
  border-color: var(--color-status-blue);
}

.btn-sm.btn-map-focus:hover {
  opacity: 0.85;
}

.site-status-label {
  text-transform: capitalize;
  font-style: italic;
  color: var(--color-text-muted);
}

/* Badge styling for permission status */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: capitalize;
  white-space: nowrap;
}

.status-granted { background: #d4edda; color: #155724; }
.status-requested { background: #fff3cd; color: #856404; }
.status-denied { background: #f8d7da; color: #721c24; }
.status-not-required { background: #d1ecf1; color: #0c5460; }
.status-not-requested { background: #e9ecef; color: #495057; }

/* Page header with actions */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.page-header-actions {
  display: flex;
  gap: var(--space-sm);
}

/* ---- Site Detail Panel (slide-in from right) ---- */
/* Old slide-in panel hidden */
.detail-panel {
  display: none;
}

/* Inline card detail expansion */
.card-detail-expansion {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.3s ease;
  opacity: 0;
  background: var(--color-card);
  border: 2px solid var(--color-accent);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-top: -8px;
  margin-bottom: var(--space-sm);
}

.card-detail-expansion.open {
  max-height: 2000px;
  opacity: 1;
}

.card-detail-inner {
  padding: var(--space-md);
}

.card-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: var(--space-sm);
}

.card-detail-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  color: var(--color-primary);
}

.card-expanded {
  border-color: var(--color-accent);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
}

.btn-close-detail {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.btn-close-detail:hover {
  background: var(--color-bg-subtle);
  color: var(--color-primary);
}

.detail-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.detail-body {
  padding: var(--space-md);
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-sm);
}

.detail-badges .badge {
  padding: 4px 10px;
  font-size: var(--font-size-xs);
}

.badge-status { background: #e8f0fe; color: #1a73e8; }
.badge-land { background: #fef7e0; color: #8a6d3b; }
.badge-perm { background: #e9ecef; color: #495057; }

.detail-priority {
  margin-bottom: var(--space-md);
}

.detail-section {
  margin-bottom: var(--space-md);
}

.detail-section h4 {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0 0 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-section p {
  margin: 0;
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

.detail-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

/* ---- Bulk Import ---- */
.bulk-help {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.bulk-preview {
  margin-top: var(--space-md);
  padding: var(--space-sm);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
}

.bulk-preview h4 {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-sm);
}

.bulk-preview-list {
  font-size: var(--font-size-xs);
}

.bulk-preview-item {
  padding: 4px 0;
  border-bottom: 1px solid var(--color-border-light);
}

.bulk-preview-item:last-child {
  border-bottom: none;
}

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: linear-gradient(135deg, var(--color-bg) 0%, #e8dfd4 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-xl);
}

.login-brand {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-brand h1 {
  font-size: var(--font-size-2xl);
  color: var(--color-primary);
  margin: 0;
}

.login-brand p {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-top: var(--space-xs);
}

/* Auth tabs (Login / Register) */
.auth-tabs {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-lg);
}

.auth-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: var(--color-bg);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
  text-align: center;
}

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

.auth-tab:hover:not(.active) {
  background: var(--color-border-light);
}

.login-error {
  background: var(--color-status-red-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}

.invite-code-input {
  font-family: monospace;
  font-size: var(--font-size-lg) !important;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
}

/* ==========================================================================
   ADMIN PAGE
   ========================================================================== */
.admin-page {
  padding: calc(var(--nav-height) + var(--space-lg)) var(--space-md) var(--space-xl);
  max-width: 1200px;
  margin: 0 auto;
}

.admin-section {
  margin-bottom: var(--space-2xl);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  background: var(--color-card);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.admin-table th,
.admin-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.admin-table th {
  font-weight: 700;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background-color: var(--color-bg);
  white-space: nowrap;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background-color: rgba(250, 246, 241, 0.6);
}

/* Role badges */
.badge-admin {
  background: var(--color-status-red-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.badge-user {
  background: var(--color-status-blue-bg);
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Invite code display */
.invite-code {
  font-family: monospace;
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--color-primary);
}

.invite-code-display {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-status-green-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.badge-active {
  background: var(--color-status-green-bg);
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-used {
  background: var(--color-status-gray-bg);
  color: #374151;
  border: 1px solid #e5e7eb;
}

.badge-expired {
  background: var(--color-status-yellow-bg);
  color: #854d0e;
  border: 1px solid #fde68a;
}

/* Role select in admin table */
.role-select,
.form-control-sm {
  padding: 4px 8px;
  font-size: var(--font-size-xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: white;
  min-height: 32px;
}

/* ==========================================================================
   NAVBAR USER INFO
   ========================================================================== */
.nav-user-info {
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--font-size-sm);
  padding: var(--space-sm);
  white-space: nowrap;
}

.nav-logout-btn {
  color: rgba(255, 255, 255, 0.7) !important;
  font-size: var(--font-size-sm) !important;
}

.nav-logout-btn:hover {
  color: #ffffff !important;
}

/* ==========================================================================
   SHARE MODAL
   ========================================================================== */
.modal-sm {
  max-width: 420px;
}

.share-list-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: var(--space-lg) 0 var(--space-sm) 0;
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

.share-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.share-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
}

.share-user {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.badge-view {
  background: var(--color-status-blue-bg);
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.badge-edit {
  background: var(--color-status-green-bg);
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* Shared badge on site cards */
.badge-shared {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */
.print-toolbar {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.print-page {
  max-width: 800px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 60px + var(--space-lg)) var(--space-lg) var(--space-xl);
}

.print-header {
  text-align: center;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--color-primary);
}

.print-header h1 {
  font-size: var(--font-size-2xl);
  color: var(--color-primary);
  margin: 0;
}

.print-date {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.print-section {
  margin-bottom: var(--space-xl);
  page-break-inside: avoid;
}

.print-section h2 {
  font-size: var(--font-size-lg);
  color: var(--color-primary);
  margin: 0 0 var(--space-sm) 0;
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border-light);
}

.print-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xs);
}

@media (min-width: 480px) {
  .print-detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.print-detail-row {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
}

.print-label {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  min-width: 140px;
  flex-shrink: 0;
}

.print-value {
  font-size: var(--font-size-sm);
}

.print-site-image {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
}

.print-map {
  width: 100%;
  height: 300px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
}

.print-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.print-finds-table {
  margin-bottom: var(--space-sm);
}

.print-finds-summary {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 600;
}

/* Permission Letter Styles */
.print-letter {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.7;
  font-size: 14px;
}

.letter-from {
  margin-bottom: var(--space-xl);
}

.letter-date {
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-base);
}

.letter-to {
  margin-bottom: var(--space-lg);
}

.letter-subject {
  margin-bottom: var(--space-lg);
}

.letter-body p {
  margin: 0 0 var(--space-md) 0;
}

.letter-body ul {
  margin: var(--space-sm) 0 var(--space-md) var(--space-xl);
}

.letter-body li {
  margin-bottom: var(--space-xs);
}

.letter-signature {
  margin-top: var(--space-2xl);
}

.signature-line {
  width: 250px;
  border-bottom: 1px solid var(--color-text);
  margin-bottom: var(--space-xs);
  height: var(--space-xl);
}

.editable-field {
  outline: none;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  border: 1px dashed transparent;
  transition: border-color var(--transition-fast);
}

.editable-field:hover,
.editable-field:focus {
  border-color: var(--color-border);
  background: rgba(250, 246, 241, 0.5);
}

/* Print media query */
@media print {
  .no-print,
  .navbar,
  .print-toolbar {
    display: none !important;
  }

  body {
    background: white;
    padding: 0;
    margin: 0;
    color: #000;
  }

  .print-page {
    padding: 0.5in;
    max-width: none;
    margin: 0;
  }

  .print-header {
    border-bottom: 2px solid #333;
  }

  .print-map {
    width: 100%;
    height: 300px;
    page-break-inside: avoid;
  }

  .print-section {
    page-break-inside: avoid;
    margin-bottom: 1em;
  }

  .print-letter {
    max-width: 7in;
    margin: 0 auto;
  }

  .editable-field {
    border: none !important;
    background: none !important;
  }

  .no-print-border {
    border: none !important;
  }

  .btn {
    display: none !important;
  }

  .admin-table,
  .print-finds-table {
    font-size: 10pt;
  }
}

/* ==========================================================================
   FILTER TABS (Permissions page)
   ========================================================================== */
.filter-tabs {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.filter-tab {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: white;
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.filter-tab:hover {
  background: var(--color-bg);
}

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

/* ==========================================================================
   DETAIL ACTION BUTTONS (Share, Print, Letter)
   ========================================================================== */
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

/* Small danger button (for admin, share modals) */
.btn-danger {
  background: var(--color-status-red);
  color: white;
  border-color: var(--color-status-red);
}

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

/* ==========================================================================
   DOCUMENT PREVIEW (Permissions page)
   ========================================================================== */
.doc-preview {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
}

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

.doc-name {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  word-break: break-all;
}

.upload-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: var(--space-xs);
}

.upload-input {
  display: none;
}

/* ==========================================================================
   MISC FIXES
   ========================================================================== */

/* Find card grid layout */
.finds-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
}

.find-card-image {
  flex-shrink: 0;
}

.find-card-body {
  flex: 1;
  min-width: 0;
}

.find-card-title {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--font-size-base);
  color: var(--color-primary);
}

.find-card-site {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.find-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.find-card-details {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.find-card-date {
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
}

.find-card-value {
  font-weight: 600;
  color: var(--color-accent);
}

.material-badge {
  text-transform: capitalize;
}

/* Permission card list layout */
.permissions-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
}

/* Material-specific badge colors */
.material-iron { background: #d1d5db; color: #374151; }
.material-copper { background: #fed7aa; color: #9a3412; }
.material-brass { background: #fef3c7; color: #92400e; }
.material-silver { background: #e5e7eb; color: #1f2937; }
.material-gold { background: #fef9c3; color: #854d0e; }
.material-lead { background: #d1d5db; color: #4b5563; }
.material-aluminum { background: #e0e7ff; color: #3730a3; }
.material-unknown { background: var(--color-status-gray-bg); color: #374151; }

/* ==========================================================================
   Color Themes
   ========================================================================== */

/* Theme: Prairie (default - earth tones, already set in :root) */
/* No overrides needed - uses the base :root values */

/* Theme: Forest */
[data-theme="forest"] {
  --color-primary: #2d5016;
  --color-primary-light: #3d6b1e;
  --color-primary-dark: #1e3a0e;
  --color-secondary: #5a7247;
  --color-secondary-light: #6f8a5a;
  --color-secondary-dark: #455a36;
  --color-accent: #8B6914;
  --color-accent-light: #a57e1a;
  --color-accent-dark: #6e530f;
  --color-bg: #f4f7f2;
  --color-card: #ffffff;
  --color-border: #c8d5c0;
  --color-border-light: #dce5d6;
}

/* Theme: Slate */
[data-theme="slate"] {
  --color-primary: #334155;
  --color-primary-light: #475569;
  --color-primary-dark: #1e293b;
  --color-secondary: #64748b;
  --color-secondary-light: #94a3b8;
  --color-secondary-dark: #475569;
  --color-accent: #0369a1;
  --color-accent-light: #0284c7;
  --color-accent-dark: #075985;
  --color-bg: #f1f5f9;
  --color-card: #ffffff;
  --color-border: #cbd5e1;
  --color-border-light: #e2e8f0;
}

/* Theme: Desert */
[data-theme="desert"] {
  --color-primary: #92400e;
  --color-primary-light: #b45309;
  --color-primary-dark: #78350f;
  --color-secondary: #a16207;
  --color-secondary-light: #ca8a04;
  --color-secondary-dark: #854d0e;
  --color-accent: #b91c1c;
  --color-accent-light: #dc2626;
  --color-accent-dark: #991b1b;
  --color-bg: #fef7ed;
  --color-card: #ffffff;
  --color-border: #e5d5c0;
  --color-border-light: #f0e6d6;
}

/* Theme: Midnight */
[data-theme="midnight"] {
  --color-primary: #7c3aed;
  --color-primary-light: #8b5cf6;
  --color-primary-dark: #6d28d9;
  --color-secondary: #6366f1;
  --color-secondary-light: #818cf8;
  --color-secondary-dark: #4f46e5;
  --color-accent: #06b6d4;
  --color-accent-light: #22d3ee;
  --color-accent-dark: #0891b2;
  --color-bg: #f5f3ff;
  --color-card: #ffffff;
  --color-border: #d4d0ea;
  --color-border-light: #e8e5f5;
}

/* ==========================================================================
   Dark Mode - Applied via [data-dark="true"] or OS preference
   ========================================================================== */
[data-dark="true"] {
  --color-bg: #1a1a2e;
  --color-card: #242440;
  --color-text: #e5e5e5;
  --color-text-muted: #a0a0b0;
  --color-text-light: #7a7a8e;
  --color-border: #3a3a55;
  --color-border-light: #2e2e48;
  --color-bg-subtle: #2a2a45;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-xl: 0 8px 32px rgba(0,0,0,0.6);
  --color-status-green-bg: #14532d;
  --color-status-yellow-bg: #422006;
  --color-status-red-bg: #450a0a;
  --color-status-blue-bg: #172554;
  --color-status-gray-bg: #2a2a45;
}

/* Dark mode theme-specific overrides */
[data-dark="true"][data-theme="prairie"],
[data-dark="true"]:not([data-theme]) {
  --color-primary: #a88b7a;
  --color-primary-light: #c4a999;
  --color-primary-dark: #8a6e5e;
  --color-secondary: #b09d87;
  --color-secondary-light: #c9b9a5;
  --color-secondary-dark: #8a7a66;
  --color-accent: #5a9a3a;
  --color-accent-light: #6cb348;
  --color-accent-dark: #48802e;
}

[data-dark="true"][data-theme="forest"] {
  --color-primary: #5a9a3a;
  --color-primary-light: #6cb348;
  --color-primary-dark: #48802e;
  --color-secondary: #7a9a6a;
  --color-secondary-light: #8fb37f;
  --color-secondary-dark: #5f7e52;
  --color-accent: #c9a84c;
  --color-accent-light: #dbbf62;
  --color-accent-dark: #a68b38;
}

[data-dark="true"][data-theme="slate"] {
  --color-primary: #8ba3c4;
  --color-primary-light: #a4b9d6;
  --color-primary-dark: #6b8bb2;
  --color-secondary: #94a3b8;
  --color-secondary-light: #b0bdd0;
  --color-secondary-dark: #7a8ea5;
  --color-accent: #38bdf8;
  --color-accent-light: #5cc8f9;
  --color-accent-dark: #0ea5e9;
}

[data-dark="true"][data-theme="desert"] {
  --color-primary: #d97706;
  --color-primary-light: #f59e0b;
  --color-primary-dark: #b45309;
  --color-secondary: #ca8a04;
  --color-secondary-light: #eab308;
  --color-secondary-dark: #a16207;
  --color-accent: #ef4444;
  --color-accent-light: #f87171;
  --color-accent-dark: #dc2626;
}

[data-dark="true"][data-theme="midnight"] {
  --color-primary: #a78bfa;
  --color-primary-light: #c4b5fd;
  --color-primary-dark: #8b5cf6;
  --color-secondary: #818cf8;
  --color-secondary-light: #a5b4fc;
  --color-secondary-dark: #6366f1;
  --color-accent: #22d3ee;
  --color-accent-light: #67e8f9;
  --color-accent-dark: #06b6d4;
}

/* Dark mode element fixes */
[data-dark="true"] .navbar {
  background-color: var(--color-primary-dark);
}

[data-dark="true"] .tag-chip {
  color: white;
  background-color: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
}

[data-dark="true"] .site-card-tags .tag-chip {
  color: #e5e5e5;
  background-color: #2e2e48;
  border-color: #3a3a55;
}

[data-dark="true"] .tag-chip.suggestion {
  color: var(--color-text-muted);
  background-color: var(--color-bg);
  border-color: var(--color-border);
}

[data-dark="true"] img {
  opacity: 0.92;
}

[data-dark="true"] .badge {
  opacity: 0.9;
}

[data-dark="true"] .badge.status-granted,
[data-dark="true"] .badge.status-approved { color: #86efac; }
[data-dark="true"] .badge.status-requested,
[data-dark="true"] .badge.status-pending { color: #fde68a; }
[data-dark="true"] .badge.status-denied,
[data-dark="true"] .badge.status-expired { color: #fca5a5; }
[data-dark="true"] .badge.status-not-required,
[data-dark="true"] .badge.status-identified { color: #93c5fd; }
[data-dark="true"] .badge.status-not-requested,
[data-dark="true"] .badge.status-exhausted,
[data-dark="true"] .badge.status-scouted,
[data-dark="true"] .badge.status-detecting { color: #d1d5db; }

[data-dark="true"] .star.active {
  color: #eab308;
}

[data-dark="true"] .leaflet-control-layers,
[data-dark="true"] .leaflet-bar {
  background: var(--color-card) !important;
  border-color: var(--color-border) !important;
}

[data-dark="true"] .leaflet-bar a {
  color: var(--color-text) !important;
  background: var(--color-card) !important;
  border-color: var(--color-border) !important;
}

[data-dark="true"] .leaflet-popup-content-wrapper,
[data-dark="true"] .leaflet-popup-tip {
  background: var(--color-card) !important;
  color: var(--color-text) !important;
}

/* ==========================================================================
   Theme Switcher UI
   ========================================================================== */
.theme-switcher {
  position: fixed;
  bottom: var(--space-md);
  right: var(--space-md);
  z-index: 999;
}

.theme-toggle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-text);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  box-shadow: var(--shadow-lg);
  transform: scale(1.05);
}

.theme-panel {
  display: none;
  position: absolute;
  bottom: 52px;
  right: 0;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-md);
  min-width: 220px;
}

.theme-panel.open {
  display: block;
}

.theme-panel-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.theme-colors {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.theme-swatch:hover {
  transform: scale(1.15);
}

.theme-swatch.active {
  border-color: var(--color-text);
  box-shadow: 0 0 0 2px var(--color-card), 0 0 0 4px var(--color-text);
}

.theme-swatch[data-theme="prairie"] { background: linear-gradient(135deg, #5c4033, #8B7355); }
.theme-swatch[data-theme="forest"] { background: linear-gradient(135deg, #2d5016, #5a7247); }
.theme-swatch[data-theme="slate"] { background: linear-gradient(135deg, #334155, #64748b); }
.theme-swatch[data-theme="desert"] { background: linear-gradient(135deg, #92400e, #a16207); }
.theme-swatch[data-theme="midnight"] { background: linear-gradient(135deg, #7c3aed, #6366f1); }

.theme-dark-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border-light);
}

.theme-dark-label {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--color-border);
  border-radius: 12px;
  transition: background-color var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--color-accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Dark mode select styling */
.theme-dark-select {
  font-size: var(--font-size-sm);
  padding: 2px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  color: var(--color-text);
  cursor: pointer;
}

@media print {
  .theme-switcher { display: none !important; }
}

@media (max-width: 767px) {
  .has-bottom-tabs .theme-switcher {
    display: none;
  }
}

/* ==========================================================================
   LANDING PAGE
   ========================================================================== */
.landing-page {
  padding-top: var(--nav-height);
}

/* Hero */
.landing-hero {
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
  background: linear-gradient(135deg, var(--color-bg) 0%, #e8dfd4 50%, var(--color-bg) 100%);
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-hero-content {
  max-width: 700px;
  margin: 0 auto;
}

.landing-hero-title {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.2;
  margin: 0 0 var(--space-lg) 0;
}

.landing-hero-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0 0 var(--space-xl) 0;
}

.landing-hero-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* Features */
.landing-features {
  padding: var(--space-2xl) var(--space-md);
  max-width: 1100px;
  margin: 0 auto;
}

.landing-section-title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-primary);
  text-align: center;
  margin: 0 0 var(--space-xl) 0;
}

.landing-features-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

@media (min-width: 600px) {
  .landing-features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .landing-features-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.landing-feature-card {
  background: var(--color-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.landing-feature-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.landing-feature-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
  line-height: 1;
}

.landing-feature-card h3 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 var(--space-sm) 0;
}

.landing-feature-card p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0;
}

/* How it works */
.landing-how-it-works {
  padding: var(--space-2xl) var(--space-md);
  background: var(--color-bg);
  max-width: 100%;
}

.landing-how-it-works .landing-section-title {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.landing-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  max-width: 800px;
  margin: 0 auto;
}

@media (min-width: 700px) {
  .landing-steps {
    flex-direction: row;
    gap: var(--space-xl);
  }
}

.landing-step {
  flex: 1;
  text-align: center;
}

.landing-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-size: var(--font-size-xl);
  font-weight: 800;
  margin-bottom: var(--space-md);
}

.landing-step h3 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 var(--space-sm) 0;
}

.landing-step p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0;
}

/* CTA */
.landing-cta {
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.landing-cta h2 {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-primary);
  margin: 0 0 var(--space-sm) 0;
}

.landing-cta p {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-xl) 0;
  line-height: 1.6;
}

/* Footer */
.landing-footer {
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  border-top: 1px solid var(--color-border-light);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.landing-footer p {
  margin: 0;
}

/* Landing navbar adjustments */
.landing-page .navbar .nav-links {
  gap: var(--space-md);
  align-items: center;
}

@media (min-width: 768px) {
  .landing-hero-title {
    font-size: 2.5rem;
  }
}

/* Dark mode landing adjustments */
[data-dark="true"] .landing-hero {
  background: linear-gradient(135deg, var(--color-bg) 0%, #2a2a45 50%, var(--color-bg) 100%);
}

/* ==========================================================================
   BOTTOM TAB NAVIGATION (Mobile)
   ========================================================================== */
.bottom-tabs {
  display: none;
}

@media (max-width: 767px) {
  .bottom-tabs {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1010;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .bottom-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 0 4px;
    min-height: 56px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 10px;
    font-weight: 500;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }

  .bottom-tab:hover,
  .bottom-tab:active {
    text-decoration: none;
    color: var(--color-primary);
  }

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

  .bottom-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 3px;
    background: var(--color-primary);
    border-radius: 0 0 3px 3px;
  }

  .bottom-tab-icon {
    font-size: 20px;
    line-height: 1;
    display: block;
  }

  .bottom-tab-label {
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
  }

  .bottom-tab-more {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
  }

  /* Hide hamburger menu toggle on mobile when tabs are present */
  .has-bottom-tabs .nav-toggle {
    display: none;
  }

  /* Add bottom padding to body for tab bar */
  .has-bottom-tabs {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  /* Adjust main content pages to not hide behind bottom tabs */
  .has-bottom-tabs .sites-page .split-view {
    max-height: calc(100vh - var(--nav-height) - 56px - env(safe-area-inset-bottom, 0px));
  }

  /* Move feedback widget above bottom tabs */
  .has-bottom-tabs .feedback-widget {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
}

/* Dark mode bottom tabs */
[data-dark="true"] .bottom-tabs {
  background: var(--color-card);
  border-top-color: var(--color-border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   MORE MENU PANEL (Mobile overflow menu from bottom tabs)
   ========================================================================== */
.more-menu-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1020;
}

.more-menu-panel.open {
  display: block;
}

.more-menu-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  animation: moreBackdropIn 200ms ease-out;
}

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

.more-menu-content {
  position: absolute;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  background: var(--color-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  padding: var(--space-md) 0 var(--space-sm);
  animation: moreSlideUp 200ms ease-out;
  max-height: 70vh;
  overflow-y: auto;
}

@keyframes moreSlideUp {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

.more-menu-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
  margin-bottom: var(--space-xs);
}

.more-menu-user-icon {
  font-size: 24px;
  line-height: 1;
}

.more-menu-user-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
}

.more-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  min-height: var(--tap-target-min);
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--font-size-base);
  font-weight: 500;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.more-menu-item:hover,
.more-menu-item:active {
  background-color: var(--color-bg);
  text-decoration: none;
  color: var(--color-text);
}

.more-menu-item.active {
  color: var(--color-primary);
  font-weight: 600;
}

.more-menu-item-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
  line-height: 1;
}

.more-menu-item-label {
  flex: 1;
}

.more-menu-divider {
  height: 1px;
  background: var(--color-border-light);
  margin: var(--space-xs) var(--space-lg);
}

.more-menu-logout {
  color: var(--color-status-red);
}

/* Dark mode more menu */
[data-dark="true"] .more-menu-content {
  background: var(--color-card);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

[data-dark="true"] .more-menu-backdrop {
  background: rgba(0, 0, 0, 0.6);
}

/* Hide more-menu-panel on desktop */
@media (min-width: 768px) {
  .more-menu-panel {
    display: none !important;
  }
}

/* ==========================================================================
   FLOATING ACTION BUTTON (FAB)
   ========================================================================== */
.fab {
  display: none;
}

@media (max-width: 767px) {
  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    z-index: 1005;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
  }

  .fab:hover,
  .fab:active {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  }

  .fab-icon {
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
  }

  /* Hide the desktop add buttons on mobile when FAB is present */
  .has-bottom-tabs .page-header-actions .btn-primary,
  .has-bottom-tabs .page-header .btn-primary:not(.btn-secondary) {
    display: none;
  }

  /* Keep bulk import visible */
  .has-bottom-tabs .page-header-actions .btn-secondary {
    display: inline-flex;
  }
}

/* ==========================================================================
   EMPTY STATES
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  min-height: 300px;
}

.empty-state-icon {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: var(--space-lg);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 var(--space-sm) 0;
}

.empty-state-text {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-lg) 0;
  max-width: 400px;
  line-height: 1.5;
}

.empty-state .btn {
  min-height: 48px;
  padding: var(--space-sm) var(--space-xl);
  font-size: var(--font-size-base);
}

/* ==========================================================================
   LANDING PAGE CTA BUTTON FIXES
   ========================================================================== */
.landing-hero-actions .btn {
  min-height: 52px;
  padding: 14px 32px;
  font-size: var(--font-size-lg);
  font-weight: 700;
  border-radius: var(--radius-lg);
  min-width: 160px;
  text-align: center;
}

.landing-hero-actions .btn-primary,
.landing-cta .btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border: 2px solid var(--color-primary);
  box-shadow: 0 4px 14px rgba(92, 64, 51, 0.3);
}

.landing-hero-actions .btn-primary:hover,
.landing-cta .btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: #ffffff;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(92, 64, 51, 0.4);
}

.landing-hero-actions .btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.landing-hero-actions .btn-outline:hover {
  background: var(--color-primary);
  color: #ffffff;
  text-decoration: none;
  transform: translateY(-1px);
}

.landing-cta .btn {
  min-height: 52px;
  padding: 14px 40px;
  font-size: var(--font-size-lg);
  font-weight: 700;
  border-radius: var(--radius-lg);
}

/* Landing navbar Sign Up button fix */
.nav-links .btn-primary,
#nav-register {
  background: var(--color-accent);
  color: #ffffff !important;
  border: 2px solid var(--color-accent);
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-weight: 700;
}

.nav-links .btn-primary:hover,
#nav-register:hover {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
  color: #ffffff !important;
  text-decoration: none;
}

/* Reset password button */
.btn-reset-pw {
  background: var(--color-info, #3498db);
  color: #ffffff;
  border: 1px solid var(--color-info, #3498db);
}
.btn-reset-pw:hover {
  background: #2980b9;
  border-color: #2980b9;
  color: #ffffff;
}

/* ==========================================================================
   TOUCH TARGET IMPROVEMENTS
   ========================================================================== */
@media (pointer: coarse) {
  /* Filter bar elements */
  .filter-input,
  .filter-bar select,
  .filter-bar input {
    min-height: 48px;
    font-size: 16px;
  }

  /* Filter tabs */
  .filter-tab {
    min-height: 44px;
    padding: 10px 16px;
    font-size: var(--font-size-sm);
  }

  /* Card action buttons */
  .btn-sm {
    min-height: 40px;
    padding: 8px 14px;
    font-size: var(--font-size-sm);
  }

  /* Modal buttons */
  .modal-footer .btn {
    min-height: 48px;
    padding: var(--space-sm) var(--space-lg);
  }

  /* Accordion headers (legal page) */
  .accordion-header {
    min-height: 48px;
    padding: var(--space-md);
  }

  /* Star selector */
  .star-selector .star {
    font-size: 28px;
    padding: 4px;
    cursor: pointer;
  }

  /* Nav links in mobile menu */
  .nav-links.open a {
    min-height: 52px;
  }

  /* Tags */
  .tag-chip,
  .tag-chip.suggestion {
    min-height: 36px;
    padding: 6px 14px;
  }
}

/* ==========================================================================
   SITE CARD ACTION BUTTON REFINEMENT
   ========================================================================== */
.btn-sm.btn-view,
.btn-sm.btn-edit,
.btn-sm.btn-map-focus {
  background: var(--color-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  font-weight: 600;
}

.btn-sm.btn-view:hover {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

.btn-sm.btn-edit:hover {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}

.btn-sm.btn-map-focus:hover {
  background: var(--color-status-blue);
  color: #ffffff;
  border-color: var(--color-status-blue);
}

/* ==========================================================================
   LOGIN PAGE BACK LINK
   ========================================================================== */
.login-back-link {
  display: block;
  text-align: center;
  margin-top: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.login-back-link a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}

.login-back-link a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   INVITE SHARE BUTTONS
   ========================================================================== */
.invite-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.btn-share {
  background: var(--color-secondary, #6b7280);
  color: #ffffff;
  border-color: var(--color-secondary, #6b7280);
}
.btn-share:hover {
  background: var(--color-secondary-dark, #4b5563);
  border-color: var(--color-secondary-dark, #4b5563);
}

.btn-share-sms {
  background: var(--color-status-green, #22c55e);
  color: #ffffff;
  border-color: var(--color-status-green, #22c55e);
}
.btn-share-sms:hover {
  background: #16a34a;
  border-color: #16a34a;
}

.btn-share-email {
  background: var(--color-status-blue, #3b82f6);
  color: #ffffff;
  border-color: var(--color-status-blue, #3b82f6);
}
.btn-share-email:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.invite-table-actions {
  display: inline-flex;
  gap: 4px;
  margin-right: var(--space-sm);
}

.invite-table-actions .btn-sm {
  padding: 4px 8px;
  font-size: var(--font-size-xs, 0.75rem);
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .invite-code-display {
    flex-direction: column;
    align-items: stretch;
  }

  .invite-actions {
    justify-content: stretch;
  }

  .invite-actions .btn-sm {
    flex: 1;
    min-height: 44px;
    justify-content: center;
  }

  .invite-table-actions {
    display: flex;
    gap: 4px;
    margin-right: 0;
    margin-bottom: 4px;
  }

  .invite-table-actions .btn-sm {
    min-height: 40px;
    min-width: 40px;
  }
}

/* ==========================================================================
   ADMIN SETTINGS
   ========================================================================== */
.settings-card {
  background: var(--color-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-label {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.setting-description {
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--color-text-muted);
}

/* ==========================================================================
   INVITE REQUESTS
   ========================================================================== */
.badge-pending {
  background: var(--color-status-amber, #f59e0b);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: 600;
  white-space: nowrap;
}

.btn-approve-request {
  background: var(--color-status-green, #22c55e);
  color: #ffffff;
  border: 1px solid var(--color-status-green, #22c55e);
}
.btn-approve-request:hover {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.request-message {
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--color-text-muted);
  max-width: 200px;
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   MOBILE MAP TOGGLE (Sites page)
   ========================================================================== */
.mobile-map-toggle {
  display: none;
}

@media (max-width: 767px) {
  .mobile-map-toggle {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border-light);
  }

  .mobile-map-toggle-btn,
  .mobile-quick-add-btn {
    flex: 1;
    min-height: 40px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
  }

  .map-panel.map-panel-collapsed {
    height: 0;
    min-height: 0;
    overflow: hidden;
    transition: height var(--transition-base), min-height var(--transition-base);
  }

  .map-panel.map-panel-expanded {
    height: 50vh;
    min-height: 250px;
    transition: height var(--transition-base), min-height var(--transition-base);
  }
}

/* On desktop, map is always visible — remove collapsed class behavior */
@media (min-width: 768px) {
  .map-panel.map-panel-collapsed {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
}

/* ==========================================================================
   FEEDBACK WIDGET
   ========================================================================== */
.feedback-widget {
  position: fixed;
  bottom: 80px;
  left: 16px;
  z-index: 998;
}

@media (min-width: 768px) {
  .feedback-widget {
    bottom: 20px;
    left: 20px;
  }
}

.feedback-widget-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--color-card);
  box-shadow: var(--shadow-md);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  color: var(--color-text);
}

.feedback-widget-btn:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-lg);
}

.feedback-panel {
  display: none;
  position: absolute;
  bottom: 56px;
  left: 0;
  width: 320px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.feedback-panel.open {
  display: block;
  animation: feedbackSlideUp 200ms ease-out;
}

@keyframes feedbackSlideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-bg);
}

.feedback-panel-title {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--color-primary);
}

.feedback-panel-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0;
  line-height: 1;
}

.feedback-form {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.feedback-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feedback-field label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}

.feedback-field .form-control {
  font-size: var(--font-size-sm);
}

.feedback-field textarea {
  resize: vertical;
  min-height: 80px;
}

.feedback-submit-btn {
  width: 100%;
  min-height: 44px;
  margin-top: var(--space-xs);
}

.feedback-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  gap: var(--space-sm);
}

.feedback-success-icon {
  font-size: 48px;
  color: var(--color-status-green);
  line-height: 1;
}

.feedback-success p {
  font-weight: 600;
  color: var(--color-text);
}

/* Mobile: full-width bottom sheet */
@media (max-width: 767px) {
  .feedback-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 80vh;
    overflow-y: auto;
  }

  .feedback-panel.open {
    animation: feedbackSheetUp 250ms ease-out;
  }

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

/* Dark mode feedback */
[data-dark="true"] .feedback-widget-btn {
  background: var(--color-card);
  color: var(--color-text);
}

[data-dark="true"] .feedback-panel {
  background: var(--color-card);
  border-color: var(--color-border);
}

/* ==========================================================================
   QUICK ADD SITE OVERLAY
   ========================================================================== */
.quick-add-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  background: var(--color-bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
}

.quick-add-overlay.open {
  display: block;
}

.quick-add-container {
  max-width: 500px;
  margin: 0 auto;
  padding: var(--space-md);
  padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom, 0px));
}

.quick-add-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.quick-add-header h2 {
  font-size: var(--font-size-xl);
  color: var(--color-primary);
  margin: 0;
}

.quick-add-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: var(--space-xs);
  line-height: 1;
}

.quick-add-photo-area {
  width: 100%;
  height: 200px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  cursor: pointer;
  background: var(--color-card);
  margin-bottom: var(--space-md);
  overflow: hidden;
  position: relative;
  transition: border-color var(--transition-fast);
}

.quick-add-photo-area:hover {
  border-color: var(--color-primary);
}

.quick-add-photo-icon {
  font-size: 48px;
  opacity: 0.4;
  line-height: 1;
}

.quick-add-photo-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.quick-add-photo-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.quick-add-gps {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.quick-add-gps.gps-searching {
  background: var(--color-status-blue-bg);
  color: #1e40af;
}

.quick-add-gps.gps-found {
  background: var(--color-status-green-bg);
  color: #166534;
}

.quick-add-gps.gps-error {
  background: var(--color-status-yellow-bg);
  color: #854d0e;
}

.quick-add-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.quick-add-form .form-group {
  margin-bottom: 0;
}

.quick-add-form .form-control {
  font-size: 16px;
}

.quick-add-submit {
  width: 100%;
  min-height: 52px;
  font-size: var(--font-size-lg);
  font-weight: 700;
  margin-top: var(--space-sm);
}

/* ==========================================================================
   ADMIN FEEDBACK STYLES
   ========================================================================== */
.badge-feedback-type {
  background: var(--color-secondary-light, #a8956f);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: 600;
  white-space: nowrap;
}

.badge-feedback-new {
  background: var(--color-status-blue, #3b82f6);
  color: #ffffff;
}

.badge-feedback-reviewed {
  background: var(--color-status-yellow, #eab308);
  color: #ffffff;
}

.badge-feedback-resolved {
  background: var(--color-status-green, #22c55e);
  color: #ffffff;
}

.feedback-status-select {
  font-size: var(--font-size-xs, 0.75rem);
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  min-height: 32px;
}
