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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0e1a;
  color: #e0e0e0;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */

#sidebar {
  width: 280px;
  min-width: 280px;
  height: 100vh;
  background: #0d1117;
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  height: 28px;
  width: auto;
}

.sidebar-header .subtitle {
  font-size: 11px;
  color: #EBCA9C;
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* Search */
#search-container {
  position: relative;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

#search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

#search-input:focus { border-color: rgba(127, 168, 201, 0.5); }
#search-input::placeholder { color: rgba(176, 184, 196, 0.4); }

#search-results {
  position: absolute;
  top: 100%;
  left: 14px;
  right: 14px;
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  margin-top: 2px;
  max-height: 220px;
  overflow-y: auto;
  display: none;
  z-index: 30;
}

#search-results.visible { display: block; }

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.search-recent-header {
  padding: 6px 12px 4px;
  font-size: 9px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.search-result-item:hover { background: rgba(127, 168, 201, 0.1); }
.search-result-item .place-name { color: #ddd; }
.search-result-item .place-context { color: #8893A0; font-size: 11px; margin-top: 1px; }

/* Sidebar sections */
.sidebar-section {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-section h3 {
  font-size: 10px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

/* Collapsible sections */
h3.collapsible {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

h3.collapsible::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #EBCA9C;
  transition: transform 0.2s;
}

h3.collapsible.collapsed::before {
  transform: rotate(-90deg);
}

.collapsible-content {
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.collapsible-content.collapsed {
  max-height: 0 !important;
  overflow: hidden;
}

/* Checkbox filters */
.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  font-size: 12px;
  color: #aab;
  transition: color 0.1s;
}

.filter-item:hover { color: #fff; }

.filter-item input[type="checkbox"] {
  accent-color: #7FA8C9;
  flex-shrink: 0;
}

.filter-item .legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-toggle-all {
  font-size: 11px;
  color: #7FA8C9;
  cursor: pointer;
  margin-bottom: 6px;
  display: inline-block;
}

.filter-toggle-all:hover { color: #A4C4DE; }

/* Overlay toggles */
.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  color: #aab;
  font-size: 12px;
}

.sidebar-toggle:hover { color: #fff; }
.sidebar-toggle input[type="checkbox"] { accent-color: #7FA8C9; }

/* Sub-toggles (collector sources under Property Corners) */
.sub-toggles {
  padding-left: 22px;
  display: none;
}
.sub-toggles.visible { display: block; }
.sub-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  cursor: pointer;
  color: #8893A0;
  font-size: 11px;
}
.sub-toggle:hover { color: #ccd; }
.sub-toggle input[type="checkbox"] { accent-color: #7FA8C9; }
.sub-toggle .sub-count {
  color: rgba(176, 184, 196, 0.35);
  font-size: 10px;
  margin-left: auto;
}

.zoom-hint {
  color: rgba(176, 184, 196, 0.4);
  font-size: 10px;
}

/* Stats */
.sidebar-stats {
  font-size: 12px;
  color: #8893A0;
  margin-top: auto;
}

.sidebar-stats strong { color: #B0B8C4; }

.stat-detail {
  margin-top: 4px;
  font-size: 11px;
  color: #606A78;
  line-height: 1.5;
}

/* --- Map --- */

#map {
  flex: 1;
  height: 100vh;
}

/* --- Popups --- */

.mapboxgl-popup-content {
  background: rgba(13, 17, 23, 0.96) !important;
  color: #e0e0e0 !important;
  border-radius: 8px !important;
  padding: 14px 16px !important;
  border: 1px solid rgba(201, 158, 80, 0.2) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
  max-width: 320px !important;
  font-size: 13px !important;
}

.mapboxgl-popup-close-button {
  color: #8893A0 !important;
  font-size: 18px !important;
  right: 6px !important;
  top: 4px !important;
}

.mapboxgl-popup-close-button:hover { color: #fff !important; }

.mapboxgl-popup-tip {
  border-top-color: rgba(13, 17, 23, 0.96) !important;
}

.popup-title {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  margin-bottom: 2px;
  padding-right: 16px;
}

.popup-subtitle {
  font-size: 12px;
  color: #B0B8C4;
  margin-bottom: 8px;
}

.popup-field {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.popup-label {
  color: #EBCA9C;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 65px;
  flex-shrink: 0;
}

.popup-value { color: #ccd; }

.popup-link {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(127, 168, 201, 0.12);
  color: #7FA8C9;
  border-radius: 4px;
  text-decoration: none;
  font-size: 11px;
  transition: background 0.15s;
}

.popup-link:hover { background: rgba(127, 168, 201, 0.25); }

.popup-field-data-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(80, 200, 120, 0.15);
  color: #50c878;
  border: 1px solid rgba(80, 200, 120, 0.3);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.popup-field-data-btn:hover:not(:disabled) {
  background: rgba(80, 200, 120, 0.25);
  border-color: rgba(80, 200, 120, 0.5);
}
.popup-field-data-btn:disabled {
  cursor: default;
  opacity: 0.7;
}
.popup-field-data-btn.loaded {
  background: rgba(80, 200, 120, 0.08);
  color: rgba(80, 200, 120, 0.6);
  border-color: rgba(80, 200, 120, 0.15);
}

/* Corner coordinate block */
.corner-coords {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.corner-coord-label {
  font-size: 10px !important;
  color: #6b7280 !important;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}
.corner-coord-label .popup-label { display: none; }

/* Individual copyable field values */
.corner-copy-field {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 3px;
  color: #ccd;
  font-size: 12px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  padding: 3px 24px 3px 7px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.4;
  position: relative;
}
.corner-copy-field::after {
  content: '\2398';
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0.3;
  font-family: sans-serif;
  transition: opacity 0.15s;
}
.corner-copy-field:hover {
  background: rgba(201, 158, 80, 0.1);
  border-color: rgba(201, 158, 80, 0.3);
  color: #fff;
}
.corner-copy-field:hover::after { opacity: 0.7; }
.corner-copy-field:active {
  background: rgba(201, 158, 80, 0.2);
}
.corner-copy-field.copied {
  background: rgba(201, 158, 80, 0.15);
  border-color: rgba(201, 158, 80, 0.4);
  color: #EBCA9C;
}
.corner-copy-field.copied::after {
  content: '\2713';
  opacity: 0.8;
  color: #EBCA9C;
}

/* Copy All button */
.corner-copy-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 5px 0;
  background: rgba(201, 158, 80, 0.12);
  color: #EBCA9C;
  border: 1px solid rgba(201, 158, 80, 0.25);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.corner-copy-btn:hover { background: rgba(201, 158, 80, 0.25); }
.corner-copy-btn:active { background: rgba(201, 158, 80, 0.35); }

/* --- Mobile top bar --- */

#mobile-bar {
  display: none;
}

#sidebar-overlay {
  display: none;
}

.sidebar-close-btn {
  display: none;
}

.mobile-btn {
  background: none;
  border: none;
  color: #B0B8C4;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-btn.sidebar-close-btn {
  display: none;
}

.mobile-btn:hover { background: rgba(127, 168, 201, 0.1); }

/* --- Mobile search panel --- */

#mobile-search-panel {
  display: none;
}

#mobile-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

#mobile-search-input:focus { border-color: rgba(127, 168, 201, 0.5); }
#mobile-search-input::placeholder { color: rgba(176, 184, 196, 0.4); }

#mobile-search-results {
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}

#mobile-search-results.visible { display: block; }

/* --- Responsive: screens under 768px --- */

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  #mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #0d1117;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    z-index: 20;
    height: 48px;
    flex-shrink: 0;
  }

  .mobile-logo {
    height: 24px;
    width: auto;
  }

  .mobile-actions {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  #mobile-search-panel {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    z-index: 25;
    background: #0d1117;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }

  #mobile-search-panel.visible {
    display: block;
  }

  #mobile-search-panel #search-results {
    left: 12px;
    right: 12px;
  }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 300px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 40;
    overflow-y: auto;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  /* Hide the search inside sidebar on mobile — it's in the top bar */
  #sidebar #search-container {
    display: none;
  }

  .sidebar-close-btn {
    display: flex;
    margin-left: auto;
  }

  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
  }

  #sidebar-overlay.visible {
    display: block;
  }

  #map {
    height: calc(100vh - 48px);
  }

  .mapboxgl-ctrl-bottom-right {
    bottom: 16px;
    right: 8px;
  }

  .modal-content {
    width: 95vw !important;
    max-width: 95vw !important;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .form-field.span-2 {
    grid-column: 1 !important;
  }

  .pill-dropdown {
    max-height: 150px;
  }
}

/* --- Intake Form Modal --- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-overlay.visible {
  display: flex;
}

.modal-content {
  background: #0d1117;
  border: 1px solid rgba(201, 158, 80, 0.2);
  border-radius: 10px;
  width: 680px;
  max-width: 100%;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  margin-bottom: 40px;
  flex-shrink: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #8893A0;
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.modal-close-btn:hover { color: #fff; background: rgba(255,255,255,0.06); }

.modal-body {
  padding: 8px 20px 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.form-section {
  margin-bottom: 16px;
}

.form-section h4 {
  font-size: 10px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(235, 202, 156, 0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.form-field.span-2 {
  grid-column: 1 / -1;
}

.form-field label {
  display: block;
  font-size: 11px;
  color: #B0B8C4;
  margin-bottom: 4px;
}

.field-hint {
  color: #606A78;
  font-size: 10px;
  font-weight: 400;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: rgba(127, 168, 201, 0.5);
}

.form-field select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

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

/* Flatpickr overrides */
.flatpickr-calendar {
  background: #161b22 !important;
  border-color: rgba(201, 158, 80, 0.2) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: #161b22 !important;
  color: #e0e0e0 !important;
}

.flatpickr-current-month input.cur-year { color: #e0e0e0 !important; }
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month { fill: #B0B8C4 !important; }
.flatpickr-months .flatpickr-prev-month:hover, .flatpickr-months .flatpickr-next-month:hover { fill: #EBCA9C !important; }
span.flatpickr-weekday { color: #EBCA9C !important; font-size: 10px !important; }
.flatpickr-day { color: #ccc !important; border-radius: 4px !important; }
.flatpickr-day:hover { background: rgba(127, 168, 201, 0.15) !important; border-color: transparent !important; }
.flatpickr-day.selected { background: rgba(201, 158, 80, 0.8) !important; border-color: transparent !important; color: #0d1117 !important; }
.flatpickr-day.today { border-color: rgba(127, 168, 201, 0.4) !important; }

.form-field input.flatpickr-input[readonly] {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
}

/* Job type pill multi-select */
.pill-select {
  position: relative;
}

.pill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  cursor: text;
  transition: border-color 0.2s;
}

.pill-tags.focused { border-color: rgba(127, 168, 201, 0.5); }
.pill-tags.empty::before {
  content: 'Select job types...';
  color: rgba(176, 184, 196, 0.4);
  font-size: 13px;
  line-height: 24px;
}

.pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(127, 168, 201, 0.15);
  border: 1px solid rgba(127, 168, 201, 0.25);
  border-radius: 12px;
  font-size: 11px;
  color: #B0B8C4;
  white-space: nowrap;
}

.pill-tag .pill-x {
  cursor: pointer;
  color: #8893A0;
  font-size: 13px;
  line-height: 1;
  margin-left: 2px;
}

.pill-tag .pill-x:hover { color: #e74c6f; }

.pill-search {
  border: none;
  background: none;
  color: #fff;
  font-size: 12px;
  outline: none;
  flex: 1;
  min-width: 80px;
  padding: 2px 0;
}

.pill-search::placeholder { color: rgba(176, 184, 196, 0.3); }

.pill-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: #161b22;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 110;
}

.pill-dropdown.open { display: block; }

.pill-option {
  padding: 6px 10px;
  font-size: 12px;
  color: #aab;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.pill-option:hover { background: rgba(127, 168, 201, 0.1); color: #fff; }
.pill-option.selected { color: #606A78; }
.pill-option.hidden { display: none; }

/* Buttons */
.btn-cancel {
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: transparent;
  color: #B0B8C4;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cancel:hover { border-color: rgba(255,255,255,0.2); color: #fff; }

.btn-submit {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  background: rgba(201, 158, 80, 0.9);
  color: #0d1117;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-submit:hover { background: rgba(201, 158, 80, 1); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Error / Success states */
.intake-error {
  margin: 0 20px;
  padding: 8px 12px;
  background: rgba(231, 76, 111, 0.15);
  border: 1px solid rgba(231, 76, 111, 0.3);
  border-radius: 6px;
  color: #e74c6f;
  font-size: 12px;
}

.intake-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.intake-success svg { margin-bottom: 16px; }
.intake-success h3 { font-size: 18px; color: #fff; margin-bottom: 6px; }
.intake-success p { font-size: 13px; color: #B0B8C4; }

/* Quote button in parcel popup */
.intake-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 10px;
  padding: 6px 12px;
  background: rgba(201, 158, 80, 0.15);
  color: #C99E50;
  border: 1px solid rgba(201, 158, 80, 0.3);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
}

.intake-btn:hover {
  background: rgba(201, 158, 80, 0.3);
  color: #EBCA9C;
}

/* --- Measure Tool --- */

.measure-ctrl {
  position: absolute;
  top: 10px;
  right: 56px;
  z-index: 5;
  display: flex;
  gap: 4px;
  background: rgba(13, 17, 23, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 4px;
  backdrop-filter: blur(8px);
}

.measure-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #B0B8C4;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.measure-btn:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.measure-btn.active {
  background: rgba(201, 158, 80, 0.18);
  border-color: rgba(201, 158, 80, 0.35);
  color: #EBCA9C;
}

.measure-btn.active svg { stroke: #EBCA9C; }

.measure-btn-clear {
  color: #8893A0;
}

.measure-btn-clear:hover {
  background: rgba(231, 76, 111, 0.12);
  color: #e74c6f;
}

.measure-btn-clear:hover svg { stroke: #e74c6f; }

.measure-result {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: rgba(13, 17, 23, 0.94);
  border: 1px solid rgba(201, 158, 80, 0.2);
  border-radius: 8px;
  padding: 10px 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  font-size: 13px;
  color: #e0e0e0;
  text-align: center;
  min-width: 180px;
  max-width: 320px;
}

.measure-total {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.measure-label {
  font-size: 10px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.measure-value {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

.measure-alt {
  font-size: 11px;
  color: #8893A0;
  margin-top: 2px;
}

/* Segment label popups on the line */
.measure-popup .mapboxgl-popup-content {
  background: rgba(13, 17, 23, 0.88) !important;
  padding: 3px 8px !important;
  border-radius: 4px !important;
  border: 1px solid rgba(201, 158, 80, 0.15) !important;
  box-shadow: none !important;
  min-width: 0 !important;
  max-width: none !important;
}

.measure-popup .mapboxgl-popup-tip {
  display: none !important;
}

.measure-segment {
  font-size: 10px;
  font-weight: 600;
  color: #EBCA9C;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  white-space: nowrap;
}

/* Hide default Draw controls (we use our own) */
.mapbox-gl-draw_ctrl-draw-btn {
  display: none !important;
}

.mapboxgl-ctrl-group.mapboxgl-ctrl {
  /* keep nav controls visible but hide draw control group */
}

/* Mobile adjustments for measure — sit beside zoom controls at bottom-right */
@media (max-width: 768px) {
  .measure-ctrl {
    top: auto;
    bottom: 16px;
    right: auto;
    left: 10px;
  }

  .measure-btn span {
    display: none;
  }

  .measure-btn {
    padding: 8px;
  }

  .measure-result {
    bottom: 60px;
    max-width: 260px;
  }
}

/* --- Upload & Review: Sidebar action buttons --- */

.upload-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(201, 158, 80, 0.2);
  border-radius: 6px;
  background: rgba(201, 158, 80, 0.08);
  color: #EBCA9C;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-action-btn:hover {
  background: rgba(201, 158, 80, 0.18);
  border-color: rgba(201, 158, 80, 0.35);
  color: #fff;
}

.sidebar-action-btn--secondary {
  background: rgba(127, 168, 201, 0.08);
  border-color: rgba(127, 168, 201, 0.2);
  color: #7FA8C9;
}

.sidebar-action-btn--secondary:hover {
  background: rgba(127, 168, 201, 0.18);
  border-color: rgba(127, 168, 201, 0.35);
  color: #fff;
}

/* --- Field Panel (shared upload + review) --- */

.field-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 200;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  background: #0d1117;
  border: 1px solid rgba(201, 158, 80, 0.2);
  border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.field-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.field-panel--wide {
  width: 780px;
}

.field-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.field-panel-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.field-panel-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.field-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.field-panel-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* --- Upload Panel --- */

.upload-metadata {
  margin-bottom: 14px;
}

.upload-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Upload dropzone */
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  border: 2px dashed rgba(201, 158, 80, 0.25);
  border-radius: 10px;
  background: rgba(201, 158, 80, 0.03);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: rgba(201, 158, 80, 0.5);
  background: rgba(201, 158, 80, 0.08);
}

.upload-dropzone-icon {
  color: #C99E50;
  margin-bottom: 10px;
  opacity: 0.6;
}

.upload-dropzone-text {
  font-size: 14px;
  color: #EBCA9C;
  font-weight: 500;
  margin-bottom: 4px;
}

.upload-dropzone-sub {
  font-size: 11px;
  color: #606A78;
  margin-bottom: 12px;
}

.upload-browse-btn {
  padding: 6px 16px;
  border: 1px solid rgba(201, 158, 80, 0.3);
  border-radius: 5px;
  background: rgba(201, 158, 80, 0.1);
  color: #EBCA9C;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.upload-browse-btn:hover {
  background: rgba(201, 158, 80, 0.2);
  border-color: rgba(201, 158, 80, 0.5);
}

/* File queue */
.upload-queue {
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  overflow: hidden;
}

.upload-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 12px;
  color: #B0B8C4;
}

.upload-file-row:last-child {
  border-bottom: none;
}

.upload-file-row svg {
  flex-shrink: 0;
  opacity: 0.5;
}

.upload-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-status {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.upload-file-status.ok { color: #50c878; }
.upload-file-status.parsing { color: #e8c547; }
.upload-file-status.pending { color: #606A78; }

.upload-file-remove {
  background: none;
  border: none;
  color: #606A78;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

.upload-file-remove:hover { color: #e74c6f; }

/* Upload status message */
.upload-status {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
}

.upload-status.success {
  background: rgba(80, 200, 120, 0.12);
  border: 1px solid rgba(80, 200, 120, 0.3);
  color: #50c878;
}

.upload-status.error {
  background: rgba(231, 76, 111, 0.12);
  border: 1px solid rgba(231, 76, 111, 0.3);
  color: #e74c6f;
}

/* Upload footer */
.upload-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* --- PM Review Panel --- */

.review-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.review-filter-input {
  flex: 1;
  min-width: 120px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.review-filter-input:focus {
  border-color: rgba(127, 168, 201, 0.5);
}

.review-filter-input::placeholder { color: rgba(176, 184, 196, 0.4); }

.review-btn-clear {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: transparent;
  color: #8893A0;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.review-btn-clear:hover { color: #fff; border-color: rgba(255,255,255,0.2); }

/* Review toolbar */
.review-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.review-count-label {
  font-size: 12px;
  color: #8893A0;
  white-space: nowrap;
}

.review-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.review-select-all-label {
  font-size: 12px;
  color: #B0B8C4;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.review-select-all-label input[type="checkbox"] { accent-color: #7FA8C9; }

.review-export-btn {
  padding: 5px 12px;
  font-size: 11px;
  white-space: nowrap;
}

/* Review table */
.review-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.review-table thead {
  background: rgba(255, 255, 255, 0.03);
}

.review-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.review-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #B0B8C4;
  vertical-align: middle;
}

.review-batch-row:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.review-th-check { width: 32px; }
.review-th-num { text-align: right; }
.review-td-num { text-align: right; font-weight: 600; color: #fff; }
.review-td-check { width: 32px; }

.review-td-date {
  white-space: nowrap;
}

.review-date {
  display: block;
  color: #ccd;
}

.review-time {
  display: block;
  font-size: 10px;
  color: #606A78;
}

.review-td-crew { color: #ccd; font-weight: 500; }
.review-td-job { color: #ccd; }
.review-muted { color: #606A78; }

.review-source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.review-src-upload {
  background: rgba(201, 158, 80, 0.12);
  color: #C99E50;
}

.review-src-email {
  background: rgba(127, 168, 201, 0.12);
  color: #7FA8C9;
}

/* Review action buttons */
.review-td-actions {
  white-space: nowrap;
}

.review-btn-action {
  padding: 3px 8px;
  margin-right: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: transparent;
  color: #7FA8C9;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.review-btn-action:hover {
  background: rgba(127, 168, 201, 0.12);
  border-color: rgba(127, 168, 201, 0.3);
  color: #fff;
}

.review-btn-danger {
  color: #8893A0;
}

.review-btn-danger:hover {
  background: rgba(231, 76, 111, 0.12);
  border-color: rgba(231, 76, 111, 0.3);
  color: #e74c6f;
}

/* Expanded batch points */
.review-expand-row td {
  padding: 0 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.review-expand-td {
  background: rgba(0, 0, 0, 0.2);
}

.review-points-table-wrap {
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
}

.review-points-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.review-points-table th {
  padding: 4px 8px;
  text-align: left;
  font-size: 9px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.review-points-table td {
  padding: 3px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  color: #B0B8C4;
}

.review-mono {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 11px;
}

/* Empty state */
.review-empty {
  text-align: center;
  padding: 40px 20px;
  color: #606A78;
}

.review-empty p {
  margin-top: 8px;
  font-size: 13px;
}

.review-empty-sub {
  font-size: 12px;
  color: #4a5568;
}

/* --- Mobile responsive for upload/review panels --- */
@media (max-width: 768px) {
  .field-panel {
    width: 95vw;
    max-height: 85vh;
  }

  .field-panel--wide {
    width: 95vw;
  }

  .upload-meta-grid {
    grid-template-columns: 1fr;
  }

  .review-filters {
    flex-direction: column;
  }

  .review-filter-input {
    min-width: 0;
  }

  .review-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .review-toolbar-actions {
    flex-wrap: wrap;
  }

  .review-table {
    font-size: 11px;
  }

  .review-table th,
  .review-table td {
    padding: 6px 6px;
  }
}

/* ===================================================================
   View Tab Navigation (Map ↔ PM Review)
   =================================================================== */

.view-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: #0d1117;
}

.view-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #8893A0;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.view-tab:hover {
  color: #ccd;
  background: rgba(255,255,255,0.04);
}

.view-tab.view-tab-active {
  color: #EBCA9C;
  background: rgba(201, 158, 80, 0.12);
  border-color: rgba(201, 158, 80, 0.2);
}

/* Mobile review button highlight when active */
#mobile-review-btn.view-tab-active {
  color: #EBCA9C;
}

/* ===================================================================
   PM Review Page — Full-screen dedicated view
   =================================================================== */

.pm-review-page {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #0a0e1a;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Header bar */
.pm-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: #0d1117;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.pm-review-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pm-review-logo {
  height: 26px;
  width: auto;
  opacity: 0.9;
}

.pm-review-title-block {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.pm-review-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.2px;
}

.pm-review-subtitle {
  font-size: 10px;
  color: #EBCA9C;
  font-weight: 400;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pm-review-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pm-select-all-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #8893A0;
  cursor: pointer;
  white-space: nowrap;
}

.pm-select-all-label input[type="checkbox"] { accent-color: #7FA8C9; }

.pm-btn-primary {
  padding: 5px 12px;
  background: rgba(201, 158, 80, 0.12);
  border: 1px solid rgba(201, 158, 80, 0.25);
  border-radius: 5px;
  color: #EBCA9C;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.pm-btn-primary:hover:not(:disabled) {
  background: rgba(201, 158, 80, 0.22);
  border-color: rgba(201, 158, 80, 0.4);
  color: #fff;
}

.pm-btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pm-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: rgba(127, 168, 201, 0.1);
  border: 1px solid rgba(127, 168, 201, 0.2);
  border-radius: 5px;
  color: #7FA8C9;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.pm-back-btn:hover {
  background: rgba(127, 168, 201, 0.2);
  border-color: rgba(127, 168, 201, 0.35);
  color: #fff;
}

/* Filters bar */
.pm-review-filters-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: #0d1117;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.pm-filters-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pm-filter-input {
  padding: 5px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  color: #e0e0e0;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  min-width: 120px;
  transition: border-color 0.2s;
}

.pm-filter-input:focus { border-color: rgba(127, 168, 201, 0.4); }
.pm-filter-input::placeholder { color: rgba(176, 184, 196, 0.35); }

input[type="date"].pm-filter-input {
  min-width: 130px;
  color-scheme: dark;
}

.pm-filter-select {
  padding: 5px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  color: #e0e0e0;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.pm-filter-select option { background: #161b22; }

.pm-filter-clear-btn {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  color: #8893A0;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.pm-filter-clear-btn:hover { color: #fff; border-color: rgba(255,255,255,0.2); }

.pm-count-label {
  font-size: 12px;
  color: #8893A0;
  white-space: nowrap;
}

/* Table area */
.pm-review-table-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.pm-table-scroll {
  flex: 1;
  overflow: auto;
}

/* Main review table */
.pm-review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pm-review-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0d1117;
}

.pm-review-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}

.pm-review-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
  color: #ccd;
}

.pm-batch-row:hover td { background: rgba(255,255,255,0.025); }

.pm-th-check { width: 36px; }
.pm-th-num   { text-align: right; }

.pm-td-check { width: 36px; }
.pm-td-check input[type="checkbox"] { accent-color: #7FA8C9; }

.pm-td-date  { white-space: nowrap; }
.pm-date     { display: block; font-size: 12px; color: #ccd; }
.pm-time     { display: block; font-size: 11px; color: #606A78; margin-top: 1px; }

.pm-td-crew  { font-weight: 500; color: #e0e0e0; }
.pm-td-job   { color: #ccd; }
.pm-td-file  { color: #606A78; font-size: 12px; }
.pm-td-num   { text-align: right; font-weight: 600; color: #fff; }

.pm-td-actions { white-space: nowrap; }

/* Source badges */
.pm-source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.pm-src-upload {
  background: rgba(127, 168, 201, 0.15);
  color: #7FA8C9;
}

.pm-src-email {
  background: rgba(80, 200, 120, 0.15);
  color: #50c878;
}

/* Action buttons in table */
.pm-btn-action {
  padding: 3px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  color: #8893A0;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  margin-right: 4px;
}

.pm-btn-action:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.pm-btn-danger {
  border-color: rgba(231, 76, 111, 0.2);
  color: #e74c6f;
}

.pm-btn-danger:hover {
  background: rgba(231, 76, 111, 0.15);
  border-color: rgba(231, 76, 111, 0.35);
}

/* Expand row */
.pm-expand-row td {
  padding: 0;
  background: rgba(0,0,0,0.2);
}

.pm-expand-td {
  padding: 0 !important;
}

/* Inner points table */
.pm-points-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin: 0;
}

.pm-points-table th {
  padding: 6px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: #7FA8C9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(13, 17, 23, 0.8);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.pm-points-table td {
  padding: 5px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: #aab;
}

.pm-mono {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 11px;
  color: #8893A0;
}

/* Loading / error states */
.pm-loading {
  text-align: center;
  color: #606A78;
  padding: 40px;
}

.pm-error {
  text-align: center;
  color: #e74c6f;
  padding: 40px;
}

/* Empty state */
.pm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: #606A78;
  gap: 4px;
}

.pm-empty p { font-size: 14px; }
.pm-empty-sub { font-size: 12px; color: #4a5568; }

/* ===================================================================
   PM Review — Mobile responsive (390px)
   =================================================================== */

@media (max-width: 768px) {
  .pm-review-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .pm-review-logo { height: 22px; }
  .pm-review-title { font-size: 13px; }

  .pm-review-header-right {
    gap: 6px;
  }

  .pm-select-all-label { display: none; }

  .pm-btn-primary {
    padding: 5px 8px;
    font-size: 11px;
  }

  .pm-review-filters-bar {
    padding: 8px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .pm-filters-inner {
    gap: 6px;
  }

  .pm-filter-input,
  .pm-filter-select {
    min-width: 0;
    flex: 1;
    font-size: 13px; /* prevent iOS zoom */
  }

  .pm-review-table {
    font-size: 12px;
  }

  .pm-review-table th,
  .pm-review-table td {
    padding: 8px 8px;
  }

  /* Hide less critical columns on mobile */
  .pm-td-file,
  .pm-review-table thead th:nth-child(5) {
    display: none;
  }

  .pm-btn-action {
    padding: 3px 6px;
    font-size: 11px;
    margin-right: 2px;
  }
}

@media (max-width: 480px) {
  .pm-review-header-right .pm-btn-primary:last-of-type {
    display: none; /* hide Corners Only on very small screens */
  }
}

/* ======================================================================
   F2F — Field to Finish
   ====================================================================== */

/* --- F2F Sidebar section --- */
.f2f-sidebar-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.f2f-sidebar-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(235, 202, 156, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.f2f-empty-hint {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  padding: 2px 0;
  display: block;
}

.f2f-job-toggle .f2f-job-name {
  flex: 1;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.f2f-opacity-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 4px;
}

.f2f-opacity-hint {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
}

.f2f-opacity-slider {
  flex: 1;
  height: 3px;
  accent-color: #EBCA9C;
}

/* --- F2F Review Page --- */
.f2f-review-page {
  position: fixed;
  inset: 0;
  background: #0d1117;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.f2f-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #0a0e1a;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.f2f-review-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.f2f-review-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Stats bar --- */
.f2f-stats-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
  overflow-x: auto;
}

.f2f-stat-item {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
}

.f2f-stat-item strong {
  color: #EBCA9C;
  font-weight: 600;
}

.f2f-stat-issues strong {
  color: #F59E0B;
}

/* --- Controls bar (opacity) --- */
.f2f-controls-bar {
  display: flex;
  align-items: center;
  padding: 6px 20px;
  background: rgba(255,255,255,0.015);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

.f2f-opacity-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

.f2f-opacity-slider-wide {
  width: 160px;
  height: 3px;
  accent-color: #EBCA9C;
}

/* --- Review body (two-column layout) --- */
.f2f-review-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.f2f-sidebar-panel {
  width: 240px;
  min-width: 200px;
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.f2f-panel-title {
  font-size: 10px;
  font-weight: 700;
  color: rgba(235,202,156,0.7);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 14px 6px;
}

.f2f-main-panel {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px 24px;
}

.f2f-section-title {
  font-size: 10px;
  font-weight: 700;
  color: rgba(235,202,156,0.7);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

/* --- Job list --- */
.f2f-job-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px 8px;
}

.f2f-empty-state {
  padding: 20px 12px;
  text-align: center;
}

.f2f-empty-state p {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

.f2f-empty-sub {
  font-size: 11px !important;
  margin-top: 4px;
}

.f2f-job-card {
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.f2f-job-card:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(235,202,156,0.2);
}

.f2f-job-card.selected {
  background: rgba(235,202,156,0.06);
  border-color: rgba(235,202,156,0.35);
}

.f2f-job-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.f2f-job-card-name {
  font-size: 12px;
  font-weight: 600;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.f2f-issue-badge {
  font-size: 9px;
  background: rgba(245, 158, 11, 0.2);
  color: #F59E0B;
  border-radius: 3px;
  padding: 1px 4px;
  white-space: nowrap;
}

.f2f-job-card-stats {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.f2f-job-card-stats span {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
}

/* --- Category breakdown table --- */
.f2f-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.f2f-breakdown-table th {
  text-align: left;
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.f2f-th-num {
  text-align: right !important;
}

.f2f-breakdown-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.75);
}

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

.f2f-breakdown-table td:nth-child(3),
.f2f-breakdown-table td:nth-child(4),
.f2f-breakdown-table td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,0.5);
}

.f2f-cat-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.f2f-cat-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.f2f-cat-label {
  font-size: 12px;
}

/* --- Issues panel --- */
.f2f-issues-panel {
  font-size: 12px;
}

.f2f-no-issues {
  color: rgba(255,255,255,0.3);
  font-size: 12px;
}

.f2f-issues-header {
  font-size: 11px;
  font-weight: 600;
  color: #F59E0B;
  margin-bottom: 6px;
}

.f2f-issues-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.f2f-issue-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
  border-left: 2px solid rgba(255,255,255,0.1);
  font-size: 11px;
}

.f2f-issue-orphan { border-left-color: #F59E0B; }
.f2f-issue-unclosed_polygon { border-left-color: #EF4444; }

.f2f-issue-type {
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  font-size: 9px;
  padding-top: 1px;
  white-space: nowrap;
}

.f2f-issue-msg {
  color: rgba(255,255,255,0.6);
  line-height: 1.4;
}

/* --- Third tab in view-tabs (narrower) --- */
.view-tabs {
  /* Allow three tabs */
}

.view-tab {
  /* Already styled by existing CSS */
}

/* --- Mobile responsive --- */
@media (max-width: 768px) {
  .f2f-review-body {
    flex-direction: column;
  }
  .f2f-sidebar-panel {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    max-height: 200px;
  }
  .f2f-job-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
  }
  .f2f-job-card {
    min-width: 150px;
    flex: 1;
    margin-bottom: 0;
  }
  .f2f-opacity-slider-wide { width: 100px; }
  .f2f-review-header-right .pm-btn-primary:last-of-type { display: none; }
}

@media (max-width: 480px) {
  .f2f-review-header { padding: 8px 12px; }
  .f2f-stats-bar { padding: 6px 12px; gap: 10px; }
  .f2f-controls-bar { padding: 5px 12px; }
  .f2f-main-panel { padding: 10px 12px 20px; }
}
