/* ============================
   Wyre Survey Tool
   Modern glassmorphic design
   ============================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Ink */
  --primary: #0b1120;
  --primary-hover: #1e293b;

  /* Teal accent — professional, mint-bright, works well on fiber/telco context */
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-light: #ccfbf1;
  --accent-soft: #f0fdfa;

  /* Info / secondary blue */
  --info: #2563eb;
  --info-hover: #1d4ed8;
  --info-light: #dbeafe;

  /* Warm + danger */
  --warn: #f59e0b;
  --warn-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #10b981;
  --success-light: #d1fae5;

  /* Surfaces + background (a touch warmer than pure slate for less sterile feel) */
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-subtle: #f6f8fa;
  --surface-glass: rgba(255,255,255,0.78);
  --bg: #f4f6fa;

  --border: #e4e7ec;
  --border-hover: #cdd2d9;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Softer, layered shadows for depth without heaviness */
  --shadow-sm: 0 1px 2px rgba(13, 18, 30, 0.04);
  --shadow: 0 2px 6px rgba(13, 18, 30, 0.06), 0 1px 2px rgba(13, 18, 30, 0.04);
  --shadow-md: 0 4px 10px -2px rgba(13, 18, 30, 0.08), 0 2px 4px -2px rgba(13, 18, 30, 0.04);
  --shadow-lg: 0 14px 28px -8px rgba(13, 18, 30, 0.14), 0 4px 10px -4px rgba(13, 18, 30, 0.06);
  --shadow-xl: 0 24px 44px -12px rgba(13, 18, 30, 0.18), 0 8px 14px -6px rgba(13, 18, 30, 0.08);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* Wyre semantic tokens (kept for compatibility; remapped to palette) */
  --wyre-blue: var(--info);
  --wyre-green: var(--success);
  --wyre-red: var(--danger);
  --wyre-yellow: var(--warn);
  --wyre-orange: #f97316;

  /* Brand gradients */
  --brand-gradient: linear-gradient(135deg, #0b1120 0%, #1e293b 45%, #0d9488 120%);
  --brand-logo-gradient: linear-gradient(135deg, #0b1120 0%, #0d9488 100%);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px) saturate(180%);
  background: var(--surface-glass);
  border-bottom: 1px solid rgba(226,232,240,0.6);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 56px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-brand img { height: 28px; }

.header-brand .divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.header-brand h1 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: var(--text);
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.header-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--text);
  background: var(--surface-subtle);
}

/* ===== HERO SECTION ===== */
.hero-section {
  background: var(--brand-gradient);
  padding: 40px 32px;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(13,148,136,0.22) 0%, transparent 65%);
  pointer-events: none;
}

.hero-section::after {
  content: '';
  position: absolute;
  bottom: -60%;
  left: -5%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(37,99,235,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero-inner {
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
}

.hero-section h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  margin-bottom: 4px;
}

.hero-section p {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  max-width: 520px;
}

/* ===== CONTAINER ===== */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border);
  transition: background var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
}

.stat-value.draft { color: var(--wyre-orange); }
.stat-value.completed { color: var(--accent); }
.stat-value.surveys { color: var(--wyre-blue); }

.stat-card:nth-child(2)::after { background: var(--wyre-orange); }
.stat-card:nth-child(3)::after { background: var(--accent); }
.stat-card:nth-child(4)::after { background: var(--wyre-blue); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 6px;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 22px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  background: var(--surface-subtle);
  border-color: var(--border-hover);
}

.btn-danger {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn-danger:hover {
  background: #fef2f2;
  color: var(--wyre-red);
  border-color: #fecaca;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}
.btn-ghost:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2394a3b8' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; }

/* ===== TOGGLE SWITCH ===== */
.toggle-group { display: flex; align-items: center; gap: 10px; }

.toggle-switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-label { font-size: 13px; color: var(--text-secondary); }

/* ===== VIEW TABS ===== */
.view-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.view-tab {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: transparent;
  font-family: inherit;
}

.view-tab:hover { color: var(--text-secondary); }

.view-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ===== DATA TABLE ===== */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table td {
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover td { background: var(--surface-subtle); }

.data-table .actions {
  display: flex;
  gap: 4px;
  white-space: nowrap;
}

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-progress { background: #fef3c7; color: #92400e; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-field-ok { background: #dbeafe; color: #1e40af; }
.badge-sdu { background: #fce7f3; color: #9d174d; }
.badge-cancel { background: #fee2e2; color: #991b1b; }
.badge-ssv-done { background: #d1fae5; color: #065f46; }

/* ===== STATUS SELECT (inline) ===== */
.status-select {
  padding: 4px 24px 4px 8px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 10 10'%3E%3Cpath fill='%2394a3b8' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  max-width: 160px;
}

.status-select:hover {
  border-color: var(--border);
  background-color: var(--surface-subtle);
}

.status-select:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--surface);
  box-shadow: 0 0 0 2px rgba(13,148,136,0.1);
}

/* ===== SDU ATTEMPTS ===== */
.sdu-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sdu-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
}

.sdu-dot:hover {
  border-color: var(--wyre-orange);
  color: var(--wyre-orange);
}

.sdu-dot.filled {
  background: var(--wyre-orange);
  border-color: var(--wyre-orange);
  color: white;
}

.sdu-dot[title] { position: relative; }

/* ===== MAP ===== */
.map-container {
  height: 500px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  isolation: isolate; /* contains Leaflet's internal z-indexes (controls go up to 1000) */
  z-index: 0;
}

.map-container .leaflet-popup-content-wrapper {
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
}

.map-popup {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

.map-popup strong { font-weight: 600; }

.map-popup .map-popup-status {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== SURVEY LAYOUT ===== */
.survey-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

.survey-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.survey-sidebar::-webkit-scrollbar { width: 4px; }
.survey-sidebar::-webkit-scrollbar-track { background: transparent; }
.survey-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.survey-sidebar .nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 18px 12px 6px;
}

.survey-sidebar .nav-item {
  display: block;
  padding: 7px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 1px;
  transition: all var(--transition);
  cursor: pointer;
  border-left: 2px solid transparent;
}

.survey-sidebar .nav-item:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.survey-sidebar .nav-item.active {
  background: var(--surface-subtle);
  color: var(--text);
  font-weight: 500;
  border-left-color: var(--accent);
}

.survey-content {
  padding: 28px 36px;
  max-width: 880px;
  background: var(--bg);
}

/* ===== SURVEY SECTIONS ===== */
.survey-section {
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.2px;
}

.section-title .section-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  font-size: 15px;
}

/* ===== IMAGE UPLOAD ===== */
.image-section { margin-bottom: 28px; }

.image-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface-subtle);
}

.upload-zone:hover {
  border-color: var(--accent);
  background: #f0fdf4;
}

.upload-zone.dragover {
  border-color: var(--accent);
  background: #f0fdf4;
}

.upload-zone .upload-icon { font-size: 28px; margin-bottom: 8px; color: var(--text-muted); opacity: 0.6; }
.upload-zone .upload-text { font-size: 13px; color: var(--text-muted); }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.image-thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 4/3;
  cursor: pointer;
  transition: all var(--transition);
}

.image-thumb:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.image-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }

.image-thumb .image-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition);
}

.image-thumb:hover .image-overlay { opacity: 1; }

.image-thumb .image-overlay .btn {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.image-annotated-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-backdrop.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px) scale(0.98);
  transition: transform var(--transition);
}

.modal-backdrop.active .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 24px 24px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.modal-close:hover { background: var(--surface-subtle); color: var(--text); }

.modal-body { padding: 0 24px 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-xl);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--accent); }
.toast.error { background: var(--wyre-red); }

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== SEARCH ===== */
.search-bar {
  position: relative;
  max-width: 320px;
  flex: 1;
}

.search-bar input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  transition: all var(--transition);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}

.search-bar::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
  background-size: contain;
}

/* ===== FILTER SELECTS ===== */
.filter-select {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 10 10'%3E%3Cpath fill='%2394a3b8' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13,148,136,0.1);
}

/* ===== RESULT COUNT ===== */
.result-count {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-secondary);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 16px; opacity: 0.3; }

.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: var(--text); }

.empty-state p {
  font-size: 13px;
  max-width: 340px;
  margin: 0 auto 20px;
  color: var(--text-muted);
}

/* ===== LOADING ===== */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== BOTTOM ACTION BAR ===== */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.action-bar .action-group { display: flex; gap: 8px; }

/* ===== ADDRESS DETAIL PANEL ===== */
.detail-panel {
  position: fixed;
  top: 56px;
  right: -460px;
  width: 440px;
  height: calc(100vh - 56px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 950; /* above Leaflet (controls go up to 1000 inside .map-container, but isolation contains them) and below modals (1000) */
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 24px;
}

.detail-panel.open { right: 0; }

.detail-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.detail-panel-header h3 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.detail-panel-header .detail-address {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.detail-row:last-child { border-bottom: none; }
.detail-row .detail-label { color: var(--text-secondary); }
.detail-row .detail-value { font-weight: 500; color: var(--text); }

/* ===== SDU PANEL IN DETAIL ===== */
.sdu-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sdu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.sdu-item.active {
  border-color: var(--wyre-orange);
  background: #fff7ed;
}

.sdu-item .sdu-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sdu-item.active .sdu-num {
  background: var(--wyre-orange);
  color: white;
}

.sdu-item input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  flex: 1;
  color: var(--text);
}

.sdu-item input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .survey-layout { grid-template-columns: 1fr; }

  .survey-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .survey-content { padding: 20px 16px; }
  .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .header-inner { padding: 0 16px; height: 52px; }
  .container { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom) + 64px); }
  .hero-section { padding: 24px 16px; }
  .hero-section h2 { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-bar { max-width: none; }
  .detail-panel { width: 100%; right: -100%; }
  .map-container { height: 350px; }

  /* Bigger touch targets */
  .btn { min-height: 44px; padding: 10px 18px; font-size: 14px; }
  .btn-sm { min-height: 36px; padding: 8px 12px; }
  .form-control, input, select, textarea { font-size: 16px; min-height: 44px; } /* 16px prevents iOS zoom */

  /* Hide desktop nav text on mobile, keep avatar + dropdown */
  .header-nav > a:not(.user-menu-item) { display: none; }
  .header-nav .btn { display: none; }
  .user-menu { margin-left: 0; }
  .user-name { display: none; }
  .user-menu-btn { padding: 4px; }

  /* Mobile-friendly modal: full sheet from bottom */
  .modal {
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%; max-width: 100%;
  }
  .modal-backdrop { align-items: flex-end; }

  /* Detail panel as full-screen sheet */
  .detail-panel.open { right: 0; }

  /* Stack table rows as cards */
  .address-row td { padding: 8px 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-value { font-size: 26px; }
  .stat-card { padding: 14px; }
  .hero-section h2 { font-size: 20px; }
  .container { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom) + 64px); }
}

/* ===== BOTTOM NAVIGATION (mobile) ===== */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  gap: 4px;
  justify-content: space-around;
}
.bottom-nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px;
  border: 0; background: transparent;
  font-family: inherit; font-size: 11px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  min-width: 0;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--text); background: var(--surface-subtle); }
.bottom-nav-item:active { background: var(--surface-subtle); }
.bottom-nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

@media (max-width: 768px) {
  .bottom-nav { display: flex; }
}

/* ===== PENDING PHOTO BADGE ===== */
.image-thumb-wrapper.pending-photo .image-thumb {
  outline: 2px dashed var(--wyre-orange);
  outline-offset: -2px;
}
.pending-badge {
  position: absolute; top: 6px; left: 6px;
  background: var(--wyre-orange); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.18);
  z-index: 2;
}
.pending-badge.failed { background: var(--wyre-red); }
.pending-badge::before {
  content: ''; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff;
  margin-right: 5px; vertical-align: middle;
  animation: pulse 1.4s infinite;
}

/* ===== BUILDING LAYOUT (v2) ===== */
.bl-root { display: flex; flex-direction: column; gap: 20px; }

.bl-head {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px;
  padding: 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-subtle) 100%);
}
.bl-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.bl-count-field { display: flex; flex-direction: column; gap: 4px; }
.bl-count-field label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-secondary); }
.bl-count-field input {
  width: 100%; padding: 10px 12px; font-size: 18px; font-weight: 700;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-family: inherit;
}
.bl-count-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,148,136,0.15); }
.bl-hint { font-size: 11px; color: var(--text-muted); }

.bl-summary {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
}
.bl-summary-stat { text-align: center; }
.bl-summary-value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); line-height: 1; }
.bl-summary-value.lu { color: var(--accent); }
.bl-summary-value.bu { color: var(--info); }
.bl-summary-value.sh { color: #7c3aed; } /* purple for shafts */
.bl-summary-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-top: 4px; }

.bl-legend {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  font-size: 11px; color: var(--text-secondary);
  padding: 8px 12px; background: var(--surface-subtle); border-radius: var(--radius-sm);
}
.bl-chip {
  display: inline-block; width: 14px; height: 14px; border-radius: 4px;
  margin-right: 4px; vertical-align: middle;
}
.bl-chip.lu { background: var(--accent); }
.bl-chip.bu { background: var(--info); }
.bl-chip.common { background: #94a3b8; }
.bl-chip.service { background: var(--warn); }
.bl-chip.empty { background: #e5e7eb; border: 1px dashed #cbd5e1; }
.bl-chip.shaft { background: #7c3aed; }
.bl-chip-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid; margin-right: 4px; vertical-align: middle;
}

.bl-building-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.bl-building-head {
  padding: 14px 16px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.bl-building-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.bl-building-idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.bl-hn, .bl-label {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; background: var(--surface);
}
.bl-hn { width: 90px; font-weight: 600; }
.bl-label { flex: 1; min-width: 120px; color: var(--text-secondary); }
.bl-hn:focus, .bl-label:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(13,148,136,0.15); }

.bl-building-stats {
  display: flex; gap: 12px; font-size: 12px; color: var(--text-secondary);
}
.bl-building-stats span.lu { color: var(--accent); font-weight: 600; }
.bl-building-stats span.bu { color: var(--info); font-weight: 600; }

.bl-col-head {
  display: grid;
  grid-template-columns: 110px 130px 1fr;
  gap: 12px; padding: 8px 16px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}
.bl-counts-head { display: flex; align-items: center; gap: 6px; }
.bl-count-lbl { width: 42px; text-align: center; }
.bl-count-lbl.lu { color: var(--accent); }
.bl-count-lbl.bu { color: var(--info); }

.bl-floor-row {
  display: grid;
  grid-template-columns: 110px 130px 1fr;
  gap: 12px; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.bl-floor-row:hover { background: var(--surface-subtle); }
.bl-floor-row:last-child { border-bottom: 0; }
.bl-floor-label { font-size: 13px; font-weight: 600; color: var(--text); }
.bl-count-inputs { display: flex; align-items: center; gap: 6px; }
.bl-inline-count {
  width: 42px; padding: 6px 4px; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 600;
  background: var(--surface);
}
.bl-inline-count.lu { border-color: var(--accent-light); color: var(--accent-hover); }
.bl-inline-count.bu { border-color: #bfdbfe; color: var(--info); }
.bl-inline-count:focus { outline: none; box-shadow: 0 0 0 2px rgba(13,148,136,0.15); }
.bl-floor-copy {
  width: 28px; height: 28px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all var(--transition);
}
.bl-floor-copy:hover { background: var(--surface-subtle); color: var(--text); }

.bl-cells { display: flex; flex-wrap: wrap; gap: 6px; }
.bl-cell {
  position: relative;
  min-width: 62px; padding: 8px 10px;
  border: 2px solid; border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
  font-family: inherit; text-align: left;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex; flex-direction: column; gap: 2px;
}
.bl-cell:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); z-index: 2; }
.bl-cell:active { transform: translateY(0); }
.bl-cell.lu      { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); }
.bl-cell.bu      { border-color: var(--info); background: var(--info-light); color: var(--info-hover); }
.bl-cell.common  { border-color: #cbd5e1; background: #f1f5f9; color: #475569; }
.bl-cell.service { border-color: var(--warn); background: var(--warn-light); color: #92400e; }
.bl-cell.empty   { border-color: #e5e7eb; background: var(--surface); color: var(--text-muted); border-style: dashed; }
.bl-cell-code { font-size: 13px; font-weight: 700; letter-spacing: -0.2px; }
.bl-cell-sub { font-size: 10px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.bl-cell-mark { position: absolute; top: 3px; right: 4px; font-size: 10px; }
.bl-cell-edited {
  position: absolute; bottom: 3px; right: 3px;
  width: 6px; height: 6px; background: var(--accent); border-radius: 50%;
}
.bl-cell.has-pos::after {
  content: ''; position: absolute; left: 4px; top: 4px;
  width: 6px; height: 6px; border-radius: 50%; border: 2px solid transparent;
}
.bl-cell.pos-front::after { border-color: var(--accent); background: #fff; }
.bl-cell.pos-rear::after  { border-color: var(--info); background: #fff; }
.bl-cell.pos-side::after  { border-color: var(--warn); background: #fff; }
.bl-cell-empty { color: var(--text-muted); font-size: 12px; font-style: italic; padding: 4px; }

.bl-type-row { display: flex; flex-wrap: wrap; gap: 8px; }
.bl-type-opt {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 13px; cursor: pointer;
  user-select: none; transition: all var(--transition);
}
.bl-type-opt:hover { background: var(--surface-subtle); }
.bl-type-opt input { accent-color: var(--accent); }
.bl-type-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-light); }
.bl-type-opt.shaft:has(input:checked) { border-color: #7c3aed; background: #ede9fe; }
.bl-type-specific { transition: opacity 0.2s; }
.bl-field-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.bl-hint-big {
  padding: 20px; background: var(--surface-subtle); border: 1px dashed var(--border);
  border-radius: var(--radius); font-size: 13px; color: var(--text-secondary); text-align: center;
}

@media (max-width: 768px) {
  .bl-head { grid-template-columns: 1fr; }
  .bl-counts { grid-template-columns: 1fr 1fr; }
  .bl-summary { grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 8px; }
  .bl-summary-value { font-size: 18px; }
  .bl-col-head, .bl-floor-row { grid-template-columns: 90px 110px 1fr; gap: 8px; padding-left: 10px; padding-right: 10px; }
  .bl-cell { min-width: 58px; padding: 6px 8px; }
  .bl-cell-code { font-size: 12px; }
}
@media (max-width: 520px) {
  .bl-counts { grid-template-columns: 1fr; }
  .bl-col-head, .bl-floor-row { grid-template-columns: 1fr; gap: 6px; padding: 10px; }
  .bl-col-head { display: none; }
  .bl-floor-row { border-bottom: 2px solid var(--border); }
  .bl-count-inputs { justify-content: flex-start; }
  .bl-inline-count { width: 56px; }
}

/* ----- Building card (v2) ----- */
.bl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.bl-card:hover { box-shadow: var(--shadow); }
.bl-card.is-named { border-color: var(--accent-light); }
.bl-card.is-collapsed .bl-card-body { display: none; }
.bl-card.is-collapsed .bl-card-head [data-action="toggle-card"] svg { transform: rotate(-90deg); }

.bl-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 14px 16px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-subtle) 100%);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.bl-card-title { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.bl-title-fields { min-width: 0; overflow: hidden; }
.bl-title-row { min-width: 0; }

.bl-building-avatar {
  position: relative;
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--brand-logo-gradient);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px -2px rgba(13,148,136,0.35);
  flex-shrink: 0;
}
.bl-building-avatar svg { width: 24px; height: 24px; }
.bl-card-idx {
  position: absolute; bottom: -4px; right: -4px;
  background: #fff; color: var(--primary);
  border: 2px solid var(--surface);
  border-radius: 999px; padding: 1px 6px;
  font-size: 10px; font-weight: 800;
  box-shadow: var(--shadow-sm);
}
.bl-title-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.bl-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bl-hn-prefix {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-muted);
}
.bl-hn, .bl-label {
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; background: var(--surface);
  transition: border var(--transition), box-shadow var(--transition);
}
.bl-hn { width: 86px; font-weight: 700; font-size: 14px; }
.bl-label { flex: 1; min-width: 140px; color: var(--text-secondary); }
.bl-hn:focus, .bl-label:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,148,136,0.15); }

.bl-title-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.bl-meta-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-subtle); border: 1px solid var(--border);
  font-size: 11px; color: var(--text-secondary);
}
.bl-meta-chip b { font-weight: 700; color: var(--text); }
.bl-meta-chip.lu b { color: var(--accent-hover); }
.bl-meta-chip.bu b { color: var(--info-hover); }
.bl-meta-chip.sh b { color: #7c3aed; }

.bl-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.bl-icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.bl-icon-btn svg { width: 16px; height: 16px; }
.bl-icon-btn:hover { background: var(--surface-subtle); color: var(--text); border-color: var(--border-hover); }
.bl-icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); border-color: #fecaca; }
.bl-icon-btn.small { width: 28px; height: 28px; }
.bl-icon-btn.small svg { width: 14px; height: 14px; }

.bl-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 14px;
  padding: 10px 16px 16px;
  align-items: start;
}
.bl-floor-stack {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}

/* ----- Floor row (v2) ----- */
.bl-row {
  display: grid;
  grid-template-columns: 120px 200px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  min-width: 0;
}
.bl-row:hover { background: var(--surface-subtle); }
.bl-row-head { display: flex; align-items: center; gap: 10px; }
.bl-floor-badge {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; letter-spacing: 0.3px;
  flex-shrink: 0;
  border: 2px solid;
}
.bl-floor-badge.above    { background: var(--surface); border-color: var(--border-hover); color: var(--text); }
.bl-floor-badge.ground   { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 6px -1px rgba(13,148,136,0.4); }
.bl-floor-badge.basement { background: #f1f5f9; border-color: #cbd5e1; color: #64748b; }
.bl-floor-name { font-size: 13px; font-weight: 600; color: var(--text); }

.bl-row-counts { display: flex; align-items: center; gap: 8px; }
.bl-count-wrap {
  display: inline-flex; align-items: center;
  border: 1.5px solid; border-radius: var(--radius-sm);
  padding: 2px 4px 2px 8px;
  background: var(--surface);
  transition: box-shadow var(--transition);
}
.bl-count-wrap.lu { border-color: var(--accent); color: var(--accent-hover); }
.bl-count-wrap.bu { border-color: var(--info); color: var(--info-hover); }
.bl-count-wrap.sh { border-color: #a78bfa; color: #7c3aed; }
.bl-count-wrap:focus-within { box-shadow: 0 0 0 3px rgba(13,148,136,0.15); }
.bl-count-icon { display: inline-flex; }
.bl-count-icon svg { width: 14px; height: 14px; }
.bl-count-in {
  width: 38px; padding: 4px 2px; text-align: center;
  border: 0; background: transparent;
  font-family: inherit; font-size: 14px; font-weight: 700;
  color: inherit;
}
.bl-count-in:focus { outline: none; }
.bl-count-in::-webkit-inner-spin-button,
.bl-count-in::-webkit-outer-spin-button { margin-left: 2px; }

.bl-row-menu {
  display: flex; gap: 3px;
  flex-shrink: 0;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.bl-row-cells {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-width: 0; max-width: 100%;
  overflow: hidden;
  margin-left: 16px; /* extra breathing room between schachten-input and first cell */
}
.bl-row-head { min-width: 0; }
.bl-floor-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ----- Cell (v2) ----- */
.bl-cell {
  position: relative;
  min-width: 72px;
  padding: 8px 10px 6px;
  border: 1.5px solid; border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit; text-align: left;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex; flex-direction: column; gap: 3px;
}
.bl-cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); z-index: 2; }
.bl-cell:active { transform: translateY(0); }
.bl-cell-head { display: flex; align-items: center; gap: 6px; }
.bl-cell-icon svg { width: 12px; height: 12px; }
.bl-cell-code { font-weight: 800; font-size: 12px; letter-spacing: -0.2px; flex: 1; }
.bl-cell-sub {
  font-size: 10px; opacity: 0.85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; line-height: 1.2;
}
.bl-cell-flag {
  position: absolute; top: 4px; right: 4px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 2px var(--surface);
}
.bl-cell-edited {
  position: absolute; bottom: 4px; right: 4px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}
.bl-cell-pos {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  border: 2px solid; background: var(--surface);
  flex-shrink: 0;
}
.bl-cell-pos.front { border-color: var(--accent); }
.bl-cell-pos.rear  { border-color: var(--info); }
.bl-cell-pos.side  { border-color: var(--warn); }

.bl-cell.lu      { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), #ecfdf5); color: var(--accent-hover); }
.bl-cell.bu      { border-color: var(--info); background: linear-gradient(180deg, #eff6ff, var(--info-light)); color: var(--info-hover); }
.bl-cell.shaft   { border-color: #7c3aed; background: linear-gradient(180deg, #f5f3ff, #ede9fe); color: #6d28d9; }
.bl-cell.common  { border-color: #cbd5e1; background: linear-gradient(180deg, #f8fafc, #f1f5f9); color: #475569; }
.bl-cell.service { border-color: var(--warn); background: linear-gradient(180deg, #fff7ed, var(--warn-light)); color: #92400e; }
.bl-cell.empty   { border-color: #e5e7eb; background: var(--surface); color: var(--text-muted); border-style: dashed; }

.bl-cell-empty {
  padding: 10px 0;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  width: 100%;
}

/* ----- Silhouette ----- */
.bl-silhouette {
  background: linear-gradient(180deg, #e0f2fe 0%, #f1f5f9 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 8px 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 100px;
  position: relative;
  overflow: hidden;
  align-self: stretch;
}
/* Hide the silhouette when the card is narrow so cells have room */
@media (min-width: 901px) and (max-width: 1200px) {
  .bl-card-body { grid-template-columns: minmax(0, 1fr); }
  .bl-silhouette { display: none; }
}
.bls-inner { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.bls-roof {
  height: 10px; width: 85%; margin: 0 auto 0;
  background: linear-gradient(180deg, #64748b, #334155);
  clip-path: polygon(6% 100%, 0 100%, 50% 0, 100% 100%, 94% 100%);
}
.bls-floor {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  padding: 4px 6px; min-height: 22px;
}
.bls-label {
  font-size: 9px; font-weight: 800;
  width: 22px; text-align: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.bls-units { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.bls-units.is-empty::before {
  content: '—'; color: var(--text-muted); font-size: 10px;
}
.bls-unit {
  width: 10px; height: 10px; border-radius: 2px;
  background: #cbd5e1;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}
.bls-unit.lu      { background: var(--accent); }
.bls-unit.bu      { background: var(--info); }
.bls-unit.shaft   { background: #7c3aed; position: relative; }
.bls-unit.common  { background: #94a3b8; }
.bls-unit.service { background: var(--warn); }
.bls-unit.empty   { background: #e5e7eb; }

/* Vertical connectors between stacked shafts so users can see a shaft runs
   continuously through adjacent floors. The ::before and ::after pseudo-
   elements reach up and down into the gap between floor rows. */
.bls-unit.shaft.shaft-up::before,
.bls-unit.shaft.shaft-down::after {
  content: '';
  position: absolute;
  left: 50%; transform: translateX(-50%);
  width: 3px;
  background: #7c3aed;
}
.bls-unit.shaft.shaft-up::before { top: -7px; height: 7px; }
.bls-unit.shaft.shaft-down::after { bottom: -7px; height: 7px; }
.bls-ground {
  height: 6px; margin-top: 4px;
  background: linear-gradient(180deg, #84cc16, #65a30d);
  border-radius: 0 0 6px 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}

/* ----- Template popover ----- */
.bl-popover {
  position: absolute;
  z-index: 1200;
  width: 260px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-xl);
  padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  animation: popIn 0.15s cubic-bezier(0.4,0,0.2,1);
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.bl-popover-item {
  display: flex; flex-direction: column; gap: 2px;
  text-align: left; padding: 10px 12px;
  background: transparent; border: 0; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; color: var(--text);
  cursor: pointer; transition: background var(--transition);
}
.bl-popover-item:hover { background: var(--surface-subtle); }
.bl-popover-item strong { font-weight: 600; }
.bl-popover-item small { color: var(--text-muted); font-size: 11px; }

/* ----- Overview / export table ----- */
.bl-overview {
  position: relative;
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.bl-overview-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.bl-overview-title { font-size: 14px; font-weight: 700; color: var(--text); }
.bl-overview-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.bl-overview-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bl-overview-scroll { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.bl-overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--surface);
}
.bl-overview-table th, .bl-overview-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: center;
  vertical-align: middle;
}
.bl-overview-table thead th {
  background: var(--surface-subtle);
  font-weight: 700; color: var(--text);
  font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.bl-overview-table .bl-ov-corner { border-top: 0; border-left: 0; background: transparent; }
.bl-overview-table .bl-ov-building {
  color: #fff; background: var(--primary);
  border-color: var(--primary);
}
.bl-overview-table .bl-ov-building small {
  font-weight: 500; opacity: 0.75;
  text-transform: none; letter-spacing: 0;
  font-size: 10px;
}
.bl-overview-table .bl-ov-sub {
  background: var(--accent-soft); color: var(--accent-hover);
  font-size: 10px;
}
.bl-overview-table .bl-ov-floor {
  background: var(--surface-subtle);
  font-weight: 700; text-align: left; padding-left: 14px;
  width: 100px;
}
.bl-overview-table .bl-ov-count { font-weight: 600; min-width: 110px; white-space: nowrap; }
.bl-overview-table .bl-ov-bus { text-align: left; color: var(--text-secondary); min-width: 180px; font-size: 12px; }
.bl-overview-table tbody tr:nth-child(odd) td,
.bl-overview-table tbody tr:nth-child(odd) th { background: #fafbfd; }
.bl-overview-table .bl-ov-schacht-row {
  background: #ede9fe;
}
.bl-overview-table .bl-ov-schacht-row th,
.bl-overview-table .bl-ov-schacht-row td {
  background: #f5f3ff !important;
  color: #6d28d9;
  font-weight: 700;
}
.bl-overview-flash {
  position: absolute; right: 16px; top: 16px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: popIn 0.15s ease-out;
}
.bl-overview-flash.error { background: var(--danger); }

/* Mobile responsive for v2 */
@media (max-width: 900px) {
  .bl-card-body { grid-template-columns: 1fr; }
  .bl-silhouette { min-height: 80px; max-height: 160px; }
  .bl-row { grid-template-columns: 100px 240px 1fr; gap: 10px; }
  .bl-overview-table { font-size: 12px; }
  .bl-overview-table th, .bl-overview-table td { padding: 6px 8px; }
}
@media (max-width: 640px) {
  .bl-card-head { flex-wrap: wrap; gap: 10px; }
  .bl-card-actions { order: 3; width: 100%; justify-content: flex-end; }
  .bl-title-fields { width: 100%; }
  .bl-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px 8px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
  }
  .bl-row:hover { background: var(--surface); }
  .bl-row-head { justify-content: space-between; }
  .bl-row-counts { justify-content: space-between; }
  .bl-row-cells { border-top: 1px dashed var(--border); padding-top: 8px; }
  .bl-card-body { padding: 10px; }
}

/* ================================================================
   SURVEY FORM v3 — tab-based layout (inspired by Proximus LST)
   ================================================================ */

.sv-breadcrumb {
  position: sticky;
  top: 56px;
  z-index: 90;
  background: var(--primary);
  color: #fff;
  padding: 8px 32px;
  font-size: 12px;
  letter-spacing: 0.2px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}
.sv-breadcrumb-inner {
  max-width: 1600px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.sv-crumb { opacity: 0.85; white-space: nowrap; }
.sv-crumb.strong { opacity: 1; font-weight: 600; }
.sv-sep { opacity: 0.35; }

.sv-tabs {
  position: sticky;
  top: 88px; /* below header + breadcrumb */
  z-index: 89;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px 0;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.sv-tabs::-webkit-scrollbar { height: 0; }
.sv-tab {
  flex-shrink: 0;
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 18px 12px;
  background: transparent;
  border: 0; border-bottom: 3px solid transparent;
  font-family: inherit; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  margin-bottom: -1px;
}
.sv-tab svg { width: 22px; height: 22px; stroke: currentColor; }
.sv-tab:hover { color: var(--text); background: var(--surface-subtle); }
.sv-tab.active {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
}
.sv-tab.active svg { stroke: var(--accent-hover); }

.sv-main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px 80px;
}
.sv-panel { display: none; animation: svFade 0.18s ease-out; }
.sv-panel.active { display: block; }
@keyframes svFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.sv-subtabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.sv-subtab {
  padding: 10px 18px;
  background: transparent;
  border: 0;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: all var(--transition);
}
.sv-subtab:hover { color: var(--text); }
.sv-subtab.active {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.sv-subpanel { display: none; }
.sv-subpanel.active { display: block; }

/* Grey section header bar (Proximus-style) */
.sv-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.sv-section-head {
  padding: 10px 18px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.sv-section-body { padding: 18px; }

.sv-hint { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; }

/* Field rows with 2 / 3 column YN controls */
.sv-field-row {
  display: grid; gap: 14px;
  margin-bottom: 14px;
}
.sv-field-row.cols-2 { grid-template-columns: 1fr 1fr; }
.sv-field-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.sv-field { display: flex; flex-direction: column; gap: 6px; }
.sv-field > label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--text-secondary);
}

/* YES / NO pill buttons (Proximus-style) */
.sv-yn {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
  background: var(--surface);
}
.sv-yn-btn {
  padding: 8px 18px;
  border: 0;
  background: transparent;
  font-family: inherit; font-size: 12px; font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 36px; min-width: 60px;
}
.sv-yn-btn:not(:last-child) { border-right: 1px solid var(--border); }
.sv-yn-btn:hover { background: var(--surface-subtle); color: var(--text); }
.sv-yn-btn.active {
  background: var(--primary); color: #fff;
}
.sv-yn-btn[data-val="1"].active { background: var(--accent); }
.sv-yn-btn[data-val="0"].active { background: var(--primary); }

/* Address card (top of ADRES tab) */
.sv-addr-card {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 100%);
  border: 1px solid var(--accent-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.sv-addr-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--brand-logo-gradient);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}
.sv-addr-icon svg { width: 28px; height: 28px; }
.sv-addr-info { flex: 1; min-width: 0; }
.sv-addr-title { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; color: var(--text); }
.sv-addr-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.sv-addr-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sv-tag {
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 11px; color: var(--text-secondary);
}
.sv-tag b { color: var(--text); font-weight: 700; }

.sv-footer {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sv-footer-actions { display: flex; gap: 10px; }

@media (max-width: 900px) {
  .sv-breadcrumb { padding: 7px 16px; font-size: 11px; }
  .sv-tabs { padding: 4px 8px 0; }
  .sv-tab { padding: 8px 12px 10px; font-size: 10px; }
  .sv-tab svg { width: 20px; height: 20px; }
  .sv-main { padding: 16px 14px 100px; }
  .sv-field-row.cols-2, .sv-field-row.cols-3 { grid-template-columns: 1fr; }
  .sv-footer { flex-direction: column; align-items: stretch; }
  .sv-footer-actions { flex-direction: column; }
  .sv-footer .btn { width: 100%; min-height: 48px; }
  .sv-addr-card { padding: 14px; }
  .sv-addr-title { font-size: 16px; }
  .sv-subtabs { margin-bottom: 12px; }
  .sv-subtab { padding: 10px 12px; font-size: 11px; }
  .sv-tabs { top: 0; /* on mobile, the breadcrumb scrolls away so tabs stick to top */ }
  .sv-breadcrumb { top: 0; }
  .sv-section-head { padding: 9px 14px; font-size: 10px; }
  .sv-section-body { padding: 14px; }
}

/* Hide the old sidebar-nav if somehow still rendered */
.survey-sidebar, .survey-layout { display: none !important; }
.survey-content { max-width: none; }

/* ===== OWNER BADGE ===== */
.owner-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 10px;
  padding: 3px 10px 3px 3px;
  background: #f1f5f9; border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  vertical-align: middle;
}
.owner-badge.unassigned { color: var(--wyre-orange); border-color: #fed7aa; background: #fff7ed; }
.owner-avatar {
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, #0a0a0a, #1F4E79);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; text-transform: uppercase;
}
.owner-avatar.empty { background: #cbd5e1; color: #475569; }
@media (max-width: 768px) { .owner-badge { display: none; } }

/* ===== CAPTURED INDICATOR ===== */
.captured-indicator {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  font-size: 12px; font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  display: inline-block;
}

/* ===== WIZARD MODE (mobile field flow) ===== */
.wizard-bar {
  position: sticky;
  top: 52px; /* below header */
  z-index: 80;
  background: var(--surface-glass);
  backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  margin: -20px -16px 16px;
}
.wizard-progress {
  height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.wizard-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #34d399);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.wizard-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px;
}
.wizard-step-label {
  flex: 1; text-align: center;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.wizard-nav {
  width: 36px; height: 36px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 50%; cursor: pointer;
  font-size: 18px; line-height: 1;
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.wizard-nav:hover:not(:disabled) { background: var(--surface-subtle); }
.wizard-nav:disabled { opacity: 0.3; cursor: not-allowed; }

.wizard-nav-buttons {
  display: flex; gap: 12px; margin: 16px 0 24px;
}
.wizard-nav-buttons .btn { flex: 1; min-height: 52px; font-size: 15px; }

/* Mobile: pin the Vorige/Volgende bar just above the fixed bottom-nav so it's always reachable */
@media (max-width: 768px) {
  body.wizard-mode .wizard-nav-buttons {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom)); /* stack above bottom-nav */
    margin: 0;
    padding: 10px 12px;
    background: var(--surface-glass);
    backdrop-filter: blur(12px) saturate(180%);
    border-top: 1px solid var(--border);
    z-index: 90;
  }
  body.wizard-mode .wizard-nav-buttons .btn { min-height: 48px; }

  /* Make room at the bottom of the form so nothing lives behind either bar */
  body.wizard-mode .survey-content {
    padding-bottom: calc(72px + 64px + 24px + env(safe-area-inset-bottom));
  }
}

/* In wizard mode: hide all sections except the current one and a couple housekeeping ones */
body.wizard-mode .survey-sidebar { display: none; }
body.wizard-mode .survey-layout { grid-template-columns: 1fr; }
body.wizard-mode .survey-section { display: none; }
body.wizard-mode .survey-section.wizard-current { display: block; }
body.wizard-mode .survey-section .section-title { cursor: default; }
body.wizard-mode .survey-section .section-chevron { display: none; }
body.wizard-mode #activity { display: none !important; } /* activity log not field-relevant */
body.wizard-mode .action-bar { display: none; }
body.wizard-mode .survey-section .section-body { display: block !important; }

/* ===== USER LOCATION (Leaflet) ===== */
.leaflet-locate-btn {
  background: #fff;
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  font-size: 18px; line-height: 1;
  cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 8px;
  color: #3b82f6;
}
.leaflet-locate-btn:hover { background: var(--surface-subtle); }

.user-location-icon { background: transparent !important; border: 0; }
.user-location-dot {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  background: #3b82f6;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(59,130,246,0.4);
}
.user-location-pulse {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 22px; height: 22px;
  background: #3b82f6;
  border-radius: 50%;
  opacity: 0.6;
  animation: locatePulse 2s ease-out infinite;
}
@keyframes locatePulse {
  0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(2.4); opacity: 0; }
}

/* Distance pill in address rows */
.distance-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid #bfdbfe;
}

/* ===== ACTION SHEET (mobile-first bottom sheet) ===== */
.action-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  z-index: 1100;
  opacity: 0; visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.action-sheet-backdrop.open { opacity: 1; visibility: visible; }
.action-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.18);
  z-index: 1101;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85vh; overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.action-sheet.open { transform: translateY(0); }
.action-sheet-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border-hover);
  margin: 10px auto 0;
}
.action-sheet-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 20px 8px;
}
.action-sheet-title {
  font-size: 17px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--text);
}
.action-sheet-subtitle {
  font-size: 13px; color: var(--text-secondary); margin-top: 2px;
}
.action-sheet-body {
  padding: 8px 20px 24px;
}
.action-sheet-section {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.action-sheet-section:first-child { border-top: 0; padding-top: 0; }
.action-sheet-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-muted); margin-bottom: 10px;
}
.action-sheet-actions { display: flex; gap: 8px; }
.action-sheet-actions .btn { min-height: 48px; }

.quick-status-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.quick-status-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text);
  cursor: pointer; text-align: left;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  min-height: 48px;
}
.quick-status-btn:hover { background: var(--surface-subtle); border-color: var(--border-hover); }
.quick-status-btn:active { transform: scale(0.97); }
.quick-status-btn.applied {
  background: var(--accent-light); border-color: var(--accent); color: var(--accent-hover);
}
.quick-status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.6);
}
@media (max-width: 480px) {
  .quick-status-grid { grid-template-columns: repeat(2, 1fr); }
}

/* On desktop, render as a centered card instead of full-bleed bottom */
@media (min-width: 769px) {
  .action-sheet {
    left: auto; right: 24px; bottom: 24px;
    max-width: 420px; width: 90vw;
    border-radius: var(--radius-lg);
    transform: translateY(calc(100% + 24px));
  }
  .action-sheet.open { transform: translateY(0); }
}

/* ===== DETAIL PANEL: notes + address photos ===== */
.detail-notes-status {
  font-size: 11px; color: var(--text-muted);
  margin-top: 4px; min-height: 14px;
}
.detail-photo-count {
  background: var(--accent-light); color: var(--accent-hover);
  padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.detail-photo-actions {
  display: flex; gap: 8px; margin-bottom: 10px;
}
.detail-photo-actions .btn { flex: 1; }
.detail-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.detail-photo-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
}
.detail-photo-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.detail-photo-del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(220, 38, 38, 0.9);
  color: #fff; border: 0; cursor: pointer;
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition);
}
.detail-photo-del:hover { background: var(--danger); }
.detail-photo-empty {
  grid-column: 1 / -1;
  padding: 16px;
  font-size: 12px; font-style: italic;
  color: var(--text-muted);
  text-align: center;
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}
.detail-photos-hint {
  margin-top: 8px; font-size: 11px; color: var(--text-muted); line-height: 1.5;
}

/* ===== ADDRESS-PHOTO PICKER MODAL ===== */
.addr-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 2px;
}
.addr-pick-item {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface-subtle);
  cursor: pointer;
  padding: 0;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.addr-pick-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.addr-pick-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.addr-pick-hint {
  position: absolute; inset: auto 6px 6px 6px;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 3px 8px; border-radius: 999px;
  opacity: 0; transform: translateY(4px);
  transition: opacity var(--transition), transform var(--transition);
}
.addr-pick-item:hover .addr-pick-hint { opacity: 1; transform: translateY(0); }
.addr-picker-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--surface-subtle);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* ===== GEOCODE STATUS ===== */
.geocode-status {
  display: none;
  position: fixed;
  bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 950;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  font-size: 12px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px;
  box-shadow: var(--shadow-lg);
}
.geocode-status.show { display: block; }
@media (max-width: 768px) {
  .geocode-status { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* ===== ONLINE/OFFLINE BADGE ===== */
.net-badge {
  display: none;
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 50%; transform: translateX(-50%);
  z-index: 200;
  background: var(--wyre-orange); color: #fff;
  font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 0 0 12px 12px;
  box-shadow: var(--shadow-md);
}
.net-badge.show { display: block; }

/* ===== INSTALL PROMPT ===== */
.install-prompt {
  display: none;
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 16px; right: 16px;
  z-index: 150;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-xl);
  display: none;
  align-items: center; gap: 12px;
}
.install-prompt.show { display: flex; }
.install-prompt-text { flex: 1; font-size: 13px; color: var(--text); }
.install-prompt-text strong { display: block; font-weight: 600; margin-bottom: 2px; }
.install-prompt-text small { color: var(--text-muted); }

@media print {
  .header, .survey-sidebar, .btn, .upload-zone, .toast, .detail-panel { display: none; }
  .survey-layout { grid-template-columns: 1fr; }
  .survey-section { break-inside: avoid; }
}

/* ===== SURVEY FORM SPECIFICS ===== */
.survey-section .sub-section {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 20px;
}

.survey-section .sub-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 14px;
}

.checkbox-row { display: flex; gap: 20px; margin-top: 6px; }

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ===== ZONE GRID ===== */
.zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.zone-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.zone-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.zone-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.zone-card:hover::before { opacity: 1; }

.zone-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  margin-bottom: 2px;
}

.zone-card-city {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.zone-card-stats {
  display: flex;
  gap: 16px;
}

.zone-card-stat {
  text-align: center;
}

.zone-card-stat-value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.zone-card-stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.zone-card-progress {
  margin-top: 16px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.zone-card-progress-bar {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.5s ease;
}

/* ===== COLLAPSIBLE SECTIONS ===== */
.collapsible .section-title {
  cursor: pointer;
  user-select: none;
}

.collapsible .section-title:hover {
  color: var(--accent);
}

.section-chevron {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.collapsible.collapsed .section-chevron {
  transform: rotate(-90deg);
}

.collapsible.collapsed .section-body {
  display: none;
}

/* ===== NAV DOTS (section progress) ===== */
.nav-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--border);
  vertical-align: middle;
  transition: background var(--transition);
}

.nav-dot.dot-complete { background: var(--accent); }
.nav-dot.dot-partial { background: var(--wyre-orange); }
.nav-dot.dot-empty { background: var(--border); }

/* ===== SIDEBAR PROGRESS ===== */
.sidebar-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.sidebar-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.sidebar-progress-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== UNIT TABLE ===== */
.unit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.unit-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.unit-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.unit-table tr:last-child td { border-bottom: none; }
.unit-table tr:hover td { background: var(--surface-subtle); }

.unit-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.unit-badge-living { background: #dbeafe; color: #1e40af; }
.unit-badge-business { background: #fef3c7; color: #92400e; }
.unit-badge-common { background: #f3e8ff; color: #6b21a8; }

/* ===== PHOTO CAPTION ===== */
.image-caption {
  margin-top: 6px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.image-caption input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}

.image-caption input:focus {
  outline: none;
  border-color: var(--accent);
}

.image-order-btns {
  display: flex;
  gap: 2px;
}

.image-order-btn {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}

.image-order-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== ACTIVITY LOG ===== */
.activity-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.activity-item:last-child { border-bottom: none; }

.activity-time {
  color: var(--text-muted);
  font-size: 11px;
  min-width: 120px;
  flex-shrink: 0;
}

.activity-action {
  color: var(--text-secondary);
}

.activity-action strong {
  color: var(--text);
  font-weight: 600;
}

.activity-field {
  color: var(--accent);
  font-weight: 500;
}

.address-row { cursor: pointer; }
.address-row:hover td { background: var(--surface-subtle); }

/* Scrollbar for card overflow */
.card-scroll {
  max-height: 600px;
  overflow-y: auto;
}

.card-scroll::-webkit-scrollbar { width: 6px; }
.card-scroll::-webkit-scrollbar-track { background: transparent; }
.card-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.card-scroll::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ===== SAVE STATUS PILL ===== */
.save-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit; font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  min-height: 32px;
}
.save-status:hover { background: var(--surface-subtle); }
.save-status::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}
.save-status[data-state="pending"]::before { background: var(--wyre-orange); }
.save-status[data-state="pending"] { color: var(--wyre-orange); }
.save-status[data-state="saving"]::before { background: var(--wyre-blue); animation: pulse 1s infinite; }
.save-status[data-state="saving"] { color: var(--wyre-blue); }
.save-status[data-state="saved"]::before { background: var(--accent); }
.save-status[data-state="saved"] { color: var(--accent); border-color: var(--accent-light); background: var(--accent-light); }
.save-status[data-state="queued"]::before { background: var(--wyre-orange); }
.save-status[data-state="queued"] { color: var(--wyre-orange); border-color: #fed7aa; background: #fff7ed; }
.save-status[data-state="error"]::before { background: var(--wyre-red); }
.save-status[data-state="error"] { color: var(--wyre-red); border-color: #fecaca; background: #fef2f2; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== USER MENU ===== */
.user-menu { position: relative; margin-left: 16px; }
.user-menu-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--border);
  padding: 6px 10px 6px 6px; border-radius: 999px;
  font-family: inherit; font-size: 13px; color: var(--text);
  cursor: pointer; transition: background var(--transition), border-color var(--transition);
}
.user-menu-btn:hover { background: var(--surface-subtle); border-color: var(--border-hover); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-logo-gradient);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; text-transform: uppercase;
}
.user-name { font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px;
  display: none; z-index: 200;
}
.user-menu-dropdown.open { display: block; }
.user-menu-info {
  padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.user-menu-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-menu-role { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 2px; }
.user-menu-item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 9px 12px;
  border-radius: var(--radius-sm); font-family: inherit; font-size: 13px;
  color: var(--text); cursor: pointer; text-decoration: none;
  transition: background var(--transition);
}
.user-menu-item:hover { background: var(--surface-subtle); }

/* =====================================================================
   UI POLISH PASS
   Unified mobile + desktop refinements.
   Breakpoints: tablet ≤900px, phone ≤640px, small phone ≤400px.
   Rules in this block intentionally override earlier declarations.
   ===================================================================== */

/* ---- Accessibility + scroll ---- */
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html, body { overscroll-behavior-y: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---- Consistent button sizing ---- */
.btn { min-height: 36px; line-height: 1.2; }
.btn-sm { min-height: 32px; }
.btn-lg { min-height: 44px; }
button, input, select, textarea { font-family: inherit; }

/* ---- Desktop container breathing room ---- */
@media (min-width: 1200px) {
  .container { padding: 32px 32px; }
}

/* ---- Tablet (≤900px): start tightening ---- */
@media (max-width: 900px) {
  .header-inner { padding: 0 20px; }
  .container { padding: 20px; }
  .hero-section { padding: 28px 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row-3, .form-row-4 { grid-template-columns: repeat(2, 1fr); }
  .toolbar { gap: 10px; }
  .zone-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
  .zone-card { padding: 18px; }
}

/* ---- Phone (≤640px): full mobile layout ---- */
@media (max-width: 640px) {
  body { font-size: 14px; }

  /* Header — compact, tight, clear hierarchy */
  .header-inner {
    padding: 0 14px;
    height: 54px;
    gap: 10px;
  }
  .header-brand { gap: 8px; min-width: 0; flex: 1; }
  .header-brand img { height: 22px; }
  .header-brand .divider { display: none; }
  .header-brand h1 {
    font-size: 11px;
    letter-spacing: 1.5px;
  }
  .header-subtitle {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
  }
  .header-nav {
    gap: 4px;
    flex-shrink: 0;
  }
  .header-nav > a { display: none; } /* dashboard link not needed on mobile; bottom nav has it */
  .header-nav .btn:not(.btn-accent) { display: none; } /* hide secondary header buttons on mobile */
  .header-nav .save-status { padding: 5px 10px; font-size: 11px; }
  .header-nav .btn-accent { padding: 7px 12px; font-size: 12px; min-height: 36px; }

  /* Hero + containers */
  .hero-section { padding: 20px 14px; }
  .hero-section h2 { font-size: 19px; letter-spacing: -0.3px; }
  .hero-section p { font-size: 13px; }
  .container {
    padding: 14px;
    padding-bottom: calc(14px + 72px + env(safe-area-inset-bottom));
  }

  /* Stats: 2 cols, compact */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; letter-spacing: -1px; }
  .stat-label { font-size: 10px; letter-spacing: 0.6px; }

  /* Toolbar stacks full-width, filters wrap cleanly */
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar > * { width: 100%; }
  .search-bar { max-width: none; }
  .search-bar input { padding: 12px 14px 12px 38px; font-size: 16px; }
  .toolbar-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .toolbar-filters > .btn { grid-column: 1 / -1; }

  /* View tabs full width */
  .view-tabs { width: 100%; }
  .view-tabs .view-tab { flex: 1; }

  /* Zones: single column */
  .zone-grid { grid-template-columns: 1fr; gap: 10px; }
  .zone-card { padding: 16px; }
  .zone-card-title { font-size: 15px; }
  .zone-card-stats { gap: 12px; }

  /* Forms: always single column under 640px, bigger inputs, 16px to prevent iOS zoom */
  .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; gap: 12px; }
  .form-control, input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    font-size: 16px;
    padding: 12px 14px;
    min-height: 44px;
    border-radius: var(--radius-sm);
  }
  textarea.form-control { min-height: 88px; }
  .form-group label { font-size: 11px; margin-bottom: 6px; }

  /* Buttons: chunkier on mobile, no tiny tap targets */
  .btn { min-height: 42px; padding: 10px 16px; font-size: 14px; }
  .btn-sm { min-height: 36px; padding: 8px 12px; font-size: 12px; }

  /* Card padding */
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }

  /* Address/data table → stacked card rows on mobile */
  .data-table, .data-table thead, .data-table tbody, .data-table tr, .data-table td, .data-table th { display: block; }
  .data-table thead { display: none; }
  .data-table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 14px;
    box-shadow: var(--shadow-sm);
  }
  .data-table td {
    padding: 4px 0 !important;
    border: 0 !important;
    display: grid;
    grid-template-columns: 92px 1fr;
    align-items: center;
    font-size: 13px;
    gap: 10px;
  }
  .data-table td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
  }
  .data-table td:first-child { font-weight: 600; font-size: 15px; grid-template-columns: 1fr; }
  .data-table td:first-child::before { display: none; }
  .data-table td.actions {
    grid-template-columns: 1fr;
    gap: 6px;
    padding-top: 10px !important;
    border-top: 1px solid var(--border) !important;
    margin-top: 6px;
  }
  .data-table td.actions::before { display: none; }
  .data-table td.actions .btn { width: 100%; }
  .result-count { padding: 6px 2px; font-size: 12px; color: var(--text-muted); }

  /* Section titles on survey */
  .section-title { padding: 14px 16px; font-size: 15px; }
  .section-title .section-icon { font-size: 18px; }
  .section-body { padding: 16px; }

  /* Modals → full-bleed bottom sheets */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-header { padding: 18px 16px 12px; position: sticky; top: 0; background: var(--surface); z-index: 2; border-bottom: 1px solid var(--border); }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; display: flex; gap: 10px; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); }
  .modal-footer .btn { flex: 1; }

  /* Detail panel as full bottom sheet */
  .detail-panel {
    top: auto !important;
    bottom: -100vh;
    right: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 86vh;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    transition: bottom 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .detail-panel.open { bottom: 0; right: 0; }

  /* Upload zone */
  .upload-zone { padding: 22px 14px; }
  .upload-icon { font-size: 32px; }
  .upload-text { font-size: 13px; }

  /* Image thumbs */
  .image-grid { gap: 10px; }

  /* Activity log */
  .activity-item { padding: 12px 14px; font-size: 13px; }

  /* Bottom nav — less top line friction */
  .bottom-nav { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav-item { padding: 6px 4px; font-size: 10px; }
  .bottom-nav-item svg { width: 20px; height: 20px; }

  /* Save status pill lives in header — already sized above */
  .save-status { min-height: 28px; }
}

/* ---- Small phone (≤400px) extra tightening ---- */
@media (max-width: 400px) {
  .stat-value { font-size: 20px; }
  .hero-section h2 { font-size: 17px; }
  .bottom-nav-item span { font-size: 9px; }
  .quick-status-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- Consistent focus rings for form controls (both platforms) ---- */
input:focus-visible, select:focus-visible, textarea:focus-visible, .form-control:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.2);
}

/* ---- Better disabled states ---- */
.btn:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.form-control:disabled, input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ---- Small consistency fixes ---- */
.card { box-shadow: var(--shadow-sm); }
.card:hover { box-shadow: var(--shadow); }
.view-tabs .view-tab { min-height: 36px; }
.detail-panel { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---- Typography scale on larger screens ---- */
@media (min-width: 1024px) {
  body { font-size: 14px; }
  .hero-section h2 { font-size: 32px; }
  .hero-section p { font-size: 15px; }
}
