html, body, #map {
  height: 100%;
  width: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { overflow: hidden; background: #f5f7fb; }
*, *::before, *::after { box-sizing: border-box; }

.tenant-label {
  position: fixed;
  left: 12px;
  top: calc(12px + env(safe-area-inset-top));
  z-index: 1200;
  max-width: min(72vw, 360px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255,255,255,.94);
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.16);
  color: #172033;
  font-size: 13px;
  font-weight: 800;
}


.map-legend {
  position: fixed;
  left: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 1000;
  display: grid;
  gap: 6px;
  background: rgba(255,255,255,.92);
  border-radius: 14px;
  padding: 9px 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  color: #172033;
  font-size: 13px;
  font-weight: 700;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(15,23,42,.18);
}
.legend-dot.own { background: #16a34a; }
.legend-dot.other { background: #f97316; }
.field-note-marker {
  background: transparent;
  border: none;
}
.field-note-pin {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px 999px 999px 0;
  transform: rotate(-45deg);
  border: 3px solid white;
  box-shadow: 0 5px 14px rgba(0,0,0,.32);
}
.field-note-marker-own .field-note-pin { background: #16a34a; }
.field-note-marker-other .field-note-pin { background: #f97316; }
.field-note-label {
  transform: rotate(45deg);
  color: white;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}


.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 1000;
  width: 60px;
  height: 60px;
  border-radius: 999px;
  border: none;
  background: #1264d8;
  color: white;
  font-size: 36px;
  line-height: 60px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.locate-btn {
  position: fixed;
  right: 24px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 1000;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: none;
  background: white;
  color: #1264d8;
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop.hidden, .hidden { display: none !important; }

.modal {
  width: min(720px, calc(100vw - 12px));
  max-height: min(90vh, 780px);
  overflow: auto;
  background: white;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 35px rgba(0,0,0,.25);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: white;
  padding-bottom: 8px;
  z-index: 1;
}

.modal-header h1 { font-size: 20px; margin: 0; }
.close-btn { border: none; background: #eef2f7; border-radius: 999px; width: 38px; height: 38px; font-size: 24px; }
.form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 700; color: #172033; min-width: 0; }
input, textarea, select, button { font: inherit; }
input, textarea, select { width: 100%; max-width: 100%; min-width: 0; }
input[type="text"], input[type="file"], textarea, select {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
}
textarea { resize: vertical; }
.location-box {
  display: grid;
  gap: 8px;
  border: 1px solid #d8e0eb;
  border-radius: 14px;
  padding: 10px;
  background: #f8fafc;
}
.location-box p { margin: 2px 0 0; color: #475569; font-size: 13px; line-height: 1.35; }
.location-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.location-actions button, .primary {
  border: none;
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 800;
}
.location-actions button { background: #e0ecff; color: #124a9c; }
.primary { background: #1264d8; color: white; width: auto; margin-top: 0; }
.primary:disabled { opacity: .55; }
.status { min-height: 1.4em; color: #475569; font-size: 14px; }
.form-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
}
.form-actions:has(.secondary:not(.hidden)) {
  grid-template-columns: 1fr 1fr;
}
.form-actions .primary,
.form-actions .secondary {
  width: 100%;
  margin: 0;
  padding: 11px 10px;
  white-space: nowrap;
}

.view-content { display: grid; gap: 10px; color: #172033; }
.view-content img { width: 100%; max-height: 55vh; object-fit: contain; border-radius: 14px; background: #f1f5f9; }
.meta { color: #64748b; font-size: 14px; }
.memo { white-space: pre-wrap; line-height: 1.65; }
.selecting-banner {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 1500;
  background: #172033;
  color: white;
  border-radius: 999px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.current-location-marker {
  background: transparent;
  border: none;
}
.current-location-dot {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #1264d8;
  border: 3px solid white;
  box-shadow: 0 0 0 3px rgba(18,100,216,.22), 0 3px 10px rgba(0,0,0,.35);
}
.selection-crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1400;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,.86);
  color: #dc2626;
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
.selection-controls {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1500;
  width: min(420px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}
.selection-controls button {
  border: none;
  border-radius: 14px;
  padding: 14px 12px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0,0,0,.24);
}
.selection-cancel {
  background: white;
  color: #334155;
}
.selection-confirm {
  background: #1264d8;
  color: white;
}
.help-text {
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
}
.existing-photo {
  display: grid;
  gap: 8px;
  border: 1px solid #d8e0eb;
  border-radius: 14px;
  padding: 10px;
  background: #f8fafc;
}
.existing-photo.hidden { display: none; }
.existing-photo img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  background: #f1f5f9;
}
.secondary, .danger {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 800;
  width: 100%;
}
.secondary { background: #e2e8f0; color: #172033; }
.danger { background: #dc2626; color: white; }
.view-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.view-actions.hidden { display: none; }

@media (max-width: 380px) {
  .modal {
    width: calc(100vw - 8px);
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
  }
  .modal-header h1 { font-size: 18px; }
  .form { gap: 10px; }
  input[type="text"], input[type="file"], textarea, select { padding: 10px; }
  textarea { min-height: 96px; }
  .location-box { padding: 9px; }
  .location-actions button, .form-actions .primary, .form-actions .secondary {
    padding: 10px 8px;
    font-size: 14px;
  }
  .tenant-label { max-width: calc(100vw - 104px); }
}
.status-label, .completed-label {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 900;
  font-size: 13px;
}
.status-label-completed, .completed-label {
  background: #dcfce7;
  color: #166534;
}
.status-label-accepted {
  background: #cffafe;
  color: #155e75;
}

.status-label-new {
  background: #fef3c7;
  color: #92400e;
}
