:root {
  color-scheme: dark;
  --app-bg: #07060f;
  --bar: #14121f;
  --panel: #16131f;
  --panel-2: #100e1a;
  --panel-soft: #1e1b30;
  --line: #2c2842;
  --line-soft: rgba(148, 163, 184, 0.18);
  --ink: #eef0ff;
  --muted: #a6a3c4;
  --teal: #6366f1;
  --teal-dark: #4f46e5;
  --blue: #60a5fa;
  --green: #34d399;
  --gold: #fbbf24;
  --pink: #ec4899;
  --water: #38bdf8;
  --red: #f43f5e;
  --violet: #a855f7;
  --accent-1: #6366f1;
  --accent-2: #a855f7;
  /* Signature indigo→violet gradient reused across primary actions. */
  --accent-grad: linear-gradient(135deg, #6366f1, #a855f7);
  --accent-grad-soft: linear-gradient(135deg, #818cf8, #c084fc);
  --shadow: 0 20px 48px rgba(6, 4, 22, 0.55);
  --glow: 0 0 24px rgba(99, 102, 241, 0.28);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--app-bg);
  color: var(--ink);
  font-family: Arial, Tahoma, sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.link-btn {
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--app-bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 5px 10px;
  background: rgba(17, 25, 39, 0.78);
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px) saturate(130%);
  z-index: 900;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 176px;
  color: #5fd4ff;
}

.brand-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--teal);
  background: #1e1b4b;
}

.brand-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand strong {
  font-size: 17px;
  letter-spacing: 0;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  flex: 1;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 1px;
  scrollbar-width: thin;
}

.icon-btn,
.text-btn,
.menu-btn,
.base-select,
.small-primary {
  min-height: 38px;
  border-radius: 6px;
  color: var(--ink);
  background: rgba(23, 34, 53, 0.64);
  border: 1px solid rgba(148, 163, 184, 0.22);
  backdrop-filter: blur(8px);
}

.tool-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: max-content;
  padding: 3px;
  border-radius: 8px;
  background: rgba(4, 10, 20, 0.28);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.base-group {
  gap: 7px;
  padding-left: 9px;
}

.group-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.icon-btn {
  width: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
}

.icon-btn svg,
.menu-btn svg,
.layer-focus svg,
.layer-expand-btn svg,
.layer-opacity-btn svg,
.layer-more-btn svg,
.layer-tool-icon svg,
.layer-symbol svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.light {
  width: 38px;
  min-height: 38px;
  background: rgba(29, 41, 57, 0.62);
}

.icon-btn.active,
.text-btn.active,
.menu-btn.active {
  color: #ffffff;
  background: rgba(99, 102, 241, 0.88);
}

.text-btn,
.link-btn,
.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 58px;
  padding: 0 10px;
  color: #d8e7f7;
  font-weight: 800;
  white-space: nowrap;
}

.text-btn:hover,
.menu-btn:hover,
.icon-btn:hover,
.base-select:hover,
.small-primary:hover {
  border-color: rgba(99, 102, 241, 0.55);
}

.primary-menu {
  color: #ffffff;
  background: rgba(99, 102, 241, 0.88);
}

.base-select {
  width: 132px;
  min-width: 132px;
  padding: 0 10px;
  outline: none;
}

.user-badge {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4f8cff, #6366f1);
  color: #fff;
  font-weight: 900;
}

.map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: #0b101a;
}

.leaflet-control-zoom {
  display: none;
}

.floating-panel,
.layer-panel,
.details-panel {
  position: absolute;
  z-index: 650;
  color: var(--ink);
  background: rgba(17, 24, 39, 0.68);
  border: 1px solid rgba(129, 140, 248, 0.22);
  box-shadow: var(--shadow), 0 0 0 1px rgba(99, 102, 241, 0.08), 0 0 40px rgba(99, 102, 241, 0.1);
  backdrop-filter: blur(12px) saturate(130%);
}

.floating-panel {
  z-index: 760;
  border-radius: 8px;
  top: 14px;
  max-height: calc(100% - 72px);
  overflow: auto;
  transform: translateY(0);
}

.details-panel {
  right: 14px;
  top: 14px;
  width: min(380px, calc(100% - 42px));
  max-height: calc(100% - 72px);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.details-panel[hidden] {
  display: none !important;
}

.details-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(129, 140, 248, 0.2);
  flex-shrink: 0;
}

.details-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.details-title-row h2 {
  margin: 0;
  font-size: 16px;
}

.details-content {
  overflow-y: auto;
  flex: 1;
  padding: 12px 16px;
}

/* Left-docked menu panels: only one opens at a time, so they share one spot. */
.search-panel,
.field-tools-panel,
.gis-panel,
.drone-panel,
.archived-panel {
  left: 14px;
  width: min(420px, calc(100% - var(--layer-panel-width, 484px) - 42px));
  display: none;
}

.search-panel.open,
.field-tools-panel.open,
.gis-panel.open,
.drone-panel.open,
.archived-panel.open {
  display: block;
}

/* Survey Type Menu - Compact */
.survey-type-menu {
  right: 398px;
  width: min(320px, calc(100% - 430px));
  display: none;
}

.survey-type-menu.open {
  display: block;
}

.menu-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.menu-head h2 {
  margin: 0;
  font-size: 16px;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  min-height: 80px;
  border-radius: 8px;
  background: rgba(15, 27, 44, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #d8e7f7;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-item:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
}

.menu-icon {
  font-size: 28px;
}

.menu-item span:last-child {
  font-size: 12px;
  text-align: center;
  line-height: 1.2;
}

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

.editor-panel {
  right: 398px;
  width: min(420px, calc(100% - 430px));
  display: none;
}

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

.survey-mode-btn {
  min-height: 86px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 10px;
  color: #d8e7f7;
  background: rgba(15, 27, 44, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.2);
  text-align: left;
}

.survey-mode-btn svg {
  grid-row: 1 / 3;
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  color: var(--teal);
}

.survey-mode-btn span {
  min-width: 0;
  font-weight: 900;
  white-space: normal;
}

.survey-mode-btn small {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  white-space: normal;
}

.survey-mode-btn.active {
  color: #ecfeff;
  background: rgba(30, 27, 75, 0.78);
  border-color: rgba(129, 140, 248, 0.62);
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.18);
}

.status-mode-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 14px 14px;
}

.field-section-label {
  padding: 0 14px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-mode-btn {
  min-height: 38px;
  border-radius: 6px;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.22);
  font-weight: 900;
}

.status-mode-btn.active {
  color: #ffffff;
  background: var(--accent-grad);
  border-color: rgba(129, 140, 248, 0.7);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.wide-action {
  width: calc(100% - 28px);
  min-height: 42px;
  margin: 0 14px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 9px;
  color: #ffffff;
  background: var(--accent-grad);
  border: 1px solid rgba(129, 140, 248, 0.68);
  font-weight: 900;
}

.wide-action svg,
.gis-dropzone svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.secondary-action {
  color: #d8e7f7;
  background: rgba(15, 27, 44, 0.84);
  border-color: rgba(148, 163, 184, 0.24);
}

.gis-dropzone {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 14px;
  padding: 18px 14px;
  border: 1px dashed rgba(129, 140, 248, 0.38);
  border-radius: 12px;
  background: rgba(8, 47, 73, 0.28);
  text-align: center;
}

.gis-dropzone > svg {
  width: 38px;
  height: 38px;
  color: var(--teal);
}

.gis-dropzone strong {
  color: #f8fafc;
  font-size: 16px;
}

.gis-dropzone span {
  max-width: 340px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.gis-dropzone .wide-action {
  margin: 4px 0 0;
  width: min(220px, 100%);
}

.gis-import-preview {
  display: grid;
  gap: 8px;
  margin: 0 14px 14px;
}

.gis-import-preview div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(8, 15, 28, 0.46);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.gis-import-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.gis-import-preview strong {
  min-width: 0;
  color: #f8fafc;
  overflow-wrap: anywhere;
}

.gis-import-preview.success div {
  border-color: rgba(54, 210, 106, 0.32);
}

.gis-import-preview.error div {
  border-color: rgba(239, 68, 68, 0.36);
}

.land-use-panel {
  margin: 14px;
  padding: 12px 0 14px;
  border: 1px solid rgba(129, 140, 248, 0.22);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.46);
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 2px;
}

.section-title strong {
  color: #f8fafc;
  font-size: 14px;
}

.section-title span {
  max-width: 54%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-align: right;
}

.section-title span.ok {
  color: var(--green);
}

.section-title span.error {
  color: var(--red);
}

.area-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.quick-area-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 14px 0;
}

.quick-area-actions button {
  min-height: 38px;
  border-radius: 8px;
  color: #dbeafe;
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.26);
  font-weight: 900;
}

.photo-panel {
  margin: 14px;
  padding: 12px 0 14px;
  border: 1px solid rgba(129, 140, 248, 0.18);
  border-radius: 10px;
  background: rgba(8, 15, 28, 0.38);
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 14px 0;
}

.photo-thumb {
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.photo-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.photo-thumb span {
  display: block;
  padding: 6px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pin-placement-mode {
  cursor: crosshair !important;
}

.parcel-info-panel {
  position: absolute;
  z-index: 720;
  left: 18px;
  top: 18px;
  width: min(520px, calc(100% - 570px));
  max-height: calc(100% - 72px);
  overflow: auto;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(9, 19, 34, 0.82), rgba(9, 19, 34, 0.64));
  border: 1px solid rgba(99, 102, 241, 0.32);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(14px) saturate(135%);
}

.parcel-info-panel[hidden] {
  display: none;
}

.parcel-info-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.parcel-info-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.parcel-info-head h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
  color: #f4fbff;
}

.parcel-area-card,
.parcel-owner-card {
  margin: 14px 16px;
  background: rgba(15, 27, 46, 0.68);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
}

.parcel-area-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.parcel-area-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--teal);
  background: rgba(99, 102, 241, 0.13);
}

.parcel-area-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.parcel-area-card span,
.parcel-owner-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.parcel-area-card strong,
.parcel-owner-card strong {
  display: block;
  margin-top: 4px;
  color: #f4fbff;
  font-size: 23px;
  line-height: 1.2;
}

.parcel-area-card small,
.parcel-owner-card small {
  display: block;
  margin-top: 4px;
  color: #b9c6d8;
  font-size: 13px;
  line-height: 1.4;
}

.parcel-crs {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  color: #e5edf8 !important;
  font-size: 11px !important;
}

.parcel-owner-card {
  padding: 15px 16px;
  border-left: 4px solid var(--teal);
}

.parcel-info-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 16px 14px;
}

.parcel-info-actions:empty {
  display: none;
}

.parcel-info-actions button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 8px;
  color: #dffcf8;
  background: rgba(79, 70, 229, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.28);
  font-weight: 900;
}

.parcel-info-actions svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.parcel-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0 16px 16px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 12px;
}

.parcel-info-row {
  min-width: 0;
  padding: 11px 12px;
  background: rgba(8, 15, 28, 0.46);
}

.parcel-info-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.parcel-info-row strong {
  display: block;
  margin-top: 4px;
  color: #f4fbff;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.layer-panel {
  top: 0;
  right: 0;
  width: min(532px, 96vw);
  height: 100%;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  transition: transform 160ms ease;
}

.layer-panel.closed {
  transform: translateX(100%);
}

.panel-head,
.layer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: rgba(12, 20, 34, 0.56);
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.floating-panel .panel-head {
  padding: 12px 14px;
}

.panel-head h2,
.layer-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.layer-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.count-badge {
  display: inline-flex;
  min-width: 24px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--teal);
  background: #241b52;
  font-size: 12px;
}

.small-primary {
  padding: 0 12px;
  color: var(--teal);
  background: rgba(30, 27, 75, 0.68);
  font-weight: 800;
}

label {
  display: block;
  margin: 12px 14px 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: calc(100% - 28px);
  margin: 0 14px;
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(11, 18, 32, 0.68);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.field-grid > div {
  min-width: 0;
}

.record-list,
.layer-list {
  overflow: auto;
}

.record-list {
  max-height: 360px;
  padding: 12px 14px 14px;
  display: grid;
  gap: 8px;
}

.record-item,
.layer-item {
  width: 100%;
  color: var(--ink);
  background: rgba(17, 28, 45, 0.62);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  text-align: left;
}

.record-item {
  padding: 10px;
  border-left: 4px solid var(--teal);
}

.record-item.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.35);
}

.record-title,
.layer-title {
  font-weight: 900;
  line-height: 1.3;
}

.record-meta,
.record-sub,
.layer-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.layer-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-content: start;
  align-items: stretch;
  gap: 10px;
}

.layer-item {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
  border-radius: 14px;
  background: rgba(20, 19, 34, 0.6);
  border: 1px solid rgba(129, 140, 248, 0.12);
  box-shadow: 0 8px 22px rgba(6, 4, 22, 0.3);
  overflow: hidden;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.layer-item:hover {
  border-color: rgba(129, 140, 248, 0.3);
}

.layer-main {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  cursor: pointer;
}

.layer-item.expanded {
  z-index: 2;
  border-color: rgba(129, 140, 248, 0.5);
  background: rgba(30, 27, 60, 0.66);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.16), 0 12px 32px rgba(15, 10, 45, 0.4);
  overflow: hidden;
}

.layer-tools {
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 2px 14px 16px;
}

.layer-item.expanded .layer-tools {
  position: relative;
  z-index: 3;
  display: flex;
  background: rgba(30, 27, 60, 0.92);
  border-top: 1px solid rgba(129, 140, 248, 0.16);
  border-radius: 0 0 14px 14px;
}

.layer-expand-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
}

.layer-expand-btn:hover {
  color: #c7d2fe;
  background: rgba(129, 140, 248, 0.12);
}

.layer-expand-btn svg {
  transition: transform 160ms ease;
}

.layer-item.expanded .layer-expand-btn {
  color: #c7d2fe;
}

.layer-item.expanded .layer-expand-btn svg {
  transform: rotate(90deg);
}

.layer-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

/* Keep each layer row to two tidy lines so tall titles never clip the meta. */
.layer-title,
.layer-title span,
.layer-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.layer-meta {
  font-size: 12px;
  color: var(--muted);
}

.layer-field {
  display: grid;
  gap: 8px;
}

.layer-field-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.layer-swatch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.layer-swatch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: rgba(8, 7, 18, 0.5);
  border: 1px solid rgba(129, 140, 248, 0.14);
  cursor: pointer;
}

.layer-swatch input {
  width: 30px;
  height: 30px;
  min-height: 30px;
  margin: 0;
  padding: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.layer-slider {
  display: grid;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(8, 7, 18, 0.5);
  border: 1px solid rgba(129, 140, 248, 0.12);
}

.layer-slider + .layer-slider {
  margin-top: 8px;
}

.layer-slider-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.layer-slider-top b {
  color: #c7d2fe;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.layer-slider input[type="range"] {
  width: 100%;
  margin: 0;
  min-height: 22px;
  accent-color: var(--teal);
}

.layer-inline-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.layer-search-input {
  width: 100%;
  margin: 0;
  min-height: 40px;
  border-radius: 10px;
}

.layer-search-btn {
  width: 44px;
  min-height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.layer-search-btn:hover {
  background: rgba(99, 102, 241, 0.26);
}

.layer-search-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layer-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.archived-panel {
  width: min(430px, calc(100vw - 24px));
  max-height: min(680px, calc(100vh - 86px));
  overflow: hidden;
}

.archived-panel .panel-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.archived-list {
  display: grid;
  gap: 8px;
  padding: 12px;
  overflow: auto;
  max-height: calc(100vh - 170px);
}

.archived-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.58);
}

.archived-item div {
  min-width: 0;
}

.archived-item strong,
.archived-item span {
  display: block;
}

.archived-item strong {
  overflow-wrap: anywhere;
}

.archived-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.restore-record-btn {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 7px;
  background: #16a34a;
  color: #fff;
  font-weight: 800;
}

.muted-tools {
  color: var(--muted);
  font-size: 12px;
}

.layer-symbol {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--layer-color);
  background: color-mix(in srgb, var(--layer-color), transparent 76%);
}

.layer-symbol svg {
  width: 23px;
  height: 23px;
  stroke-width: 2.3;
}

.layer-symbol-system {
  color: #fff;
  background: var(--layer-color);
}

.layer-symbol-official {
  color: #f8fafc;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--layer-color), transparent 24%), rgba(15, 23, 42, 0.48));
  border: 1px solid color-mix(in srgb, var(--layer-color), transparent 38%);
}

.toggle {
  width: 54px;
  height: 30px;
  border-radius: 999px;
  padding: 2px;
  background: rgba(71, 84, 103, 0.62);
  border: 0;
  transition: background 120ms ease;
}

.toggle span {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  transition: transform 120ms ease;
}

.toggle.on {
  background: rgba(99, 102, 241, 0.88);
}

.toggle.on span {
  transform: translateX(24px);
}

.layer-focus {
  width: 100%;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.28);
  font-size: 13px;
  font-weight: 800;
}

.layer-focus:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(129, 140, 248, 0.5);
}

.layer-focus:disabled {
  opacity: 0.4;
  cursor: default;
}

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

.form-actions.two {
  grid-template-columns: 1fr 1fr;
}

.form-actions button {
  min-height: 40px;
  border-radius: 7px;
  color: #fff;
  font-weight: 900;
}

.primary { background: var(--teal-dark); }
.secondary { background: #475467; }
.danger { background: var(--red); }

.coordinate-bar {
  position: absolute;
  z-index: 540;
  left: 12px;
  bottom: 12px;
  min-height: 36px;
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(17, 24, 39, 0.58);
  border: 1px solid rgba(148, 163, 184, 0.24);
  backdrop-filter: blur(10px) saturate(130%);
  color: #d9e6f8;
  box-shadow: var(--shadow);
  max-width: calc(100% - 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: absolute;
  z-index: 900;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(460px, calc(100% - 28px));
  background: rgba(248, 250, 252, 0.88);
  color: #101828;
  border-radius: 7px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.empty {
  border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  text-align: center;
  background: rgba(11, 18, 32, 0.32);
}

.linked-parcel-context {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid #86efac;
  border-radius: 8px;
  background: #f0fdf4;
  color: #166534;
}
.linked-parcel-context[hidden] { display: none; }
.linked-parcel-context.not-found { border-color: #fdba74; background: #fff7ed; color: #9a3412; }
.linked-parcel-context.duplicate { border-color: #facc15; background: #fefce8; color: #854d0e; }
.linked-parcel-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 7px; background: rgba(255,255,255,.8); }
.linked-parcel-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.linked-parcel-context strong, .linked-parcel-context span { display: block; min-width: 0; overflow-wrap: anywhere; }
.linked-parcel-context strong { font-size: 13px; }
.linked-parcel-context span { margin-top: 2px; font-size: 12px; line-height: 1.45; color: inherit; opacity: .86; }

.help-text {
  margin: 7px 14px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #111827;
  color: var(--ink);
}

.leaflet-popup-content {
  min-width: 220px;
}

.popup-title {
  font-weight: 900;
  margin-bottom: 5px;
}

.popup-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.popup-row {
  display: grid;
  grid-template-columns: minmax(76px, 0.8fr) minmax(110px, 1.2fr);
  gap: 8px;
  padding: 4px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 12px;
}

.popup-row span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.popup-row strong {
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.popup-action {
  width: 100%;
  min-height: 34px;
  border-radius: 6px;
  background: var(--teal);
  color: #ffffff;
  font-weight: 900;
}

@media (max-width: 1180px) {
  .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .map-stage {
    min-height: 0;
  }

  .layer-panel {
    width: min(500px, 94vw);
  }

  .editor-panel {
    right: 14px;
    width: min(420px, calc(100% - 28px));
    top: 72px;
  }

  .drone-panel {
    left: 14px;
    width: min(420px, calc(100% - 28px));
    top: 72px;
  }

  .parcel-info-panel {
    top: 72px;
    left: 14px;
    width: min(430px, calc(100% - 530px));
  }

  .coordinate-bar {
    max-width: calc(100% - 28px);
  }
}

@media (max-width: 680px) {
  .brand {
    min-width: 116px;
  }

  .brand strong {
    font-size: 13px;
  }

  .toolbar {
    gap: 6px;
  }

  .icon-btn {
    width: 32px;
    min-width: 32px;
  }

  .text-btn {
    min-width: 54px;
    padding: 0 8px;
  }

  .menu-btn {
    min-width: 34px;
    padding: 0 8px;
  }

  .menu-btn span {
    display: none;
  }

  .group-label {
    display: none;
  }

  .base-select {
    width: 112px;
    min-width: 112px;
  }

  .field-grid,
  .form-actions,
  .form-actions.two {
    grid-template-columns: 1fr;
  }

  .layer-main {
    gap: 10px;
    padding: 10px;
  }

  .layer-tools {
    padding: 2px 12px 14px;
  }

  .photo-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .parcel-info-panel {
    left: 10px;
    top: 66px;
    width: calc(100% - 20px);
    max-height: calc(100% - 84px);
  }

  .parcel-info-head h2 {
    font-size: 28px;
  }

  .parcel-info-grid {
    grid-template-columns: 1fr;
  }

  .parcel-info-actions {
    grid-template-columns: 1fr;
  }

  .layer-slider-grid,
  .layer-search-row {
    grid-template-columns: 1fr;
  }

  .layer-color-row {
    flex-wrap: wrap;
  }
}

/* Responsive field console */
button,
.link-btn,
select,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
.link-btn:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(129, 140, 248, 0.92);
  outline-offset: 2px;
}

.topbar {
  padding: 6px 10px;
  gap: 8px;
  background: rgba(10, 14, 22, 0.74);
}

.brand {
  min-width: 190px;
  color: #f8fafc;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: #ffffff;
  background: var(--accent-grad);
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand strong {
  font-size: 16px;
  background: linear-gradient(90deg, #e9e7ff, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-version {
  -webkit-text-fill-color: initial;
  margin-left: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: #c4b5fd;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.35);
  vertical-align: 2px;
}

.toolbar {
  justify-content: flex-start;
  gap: 8px;
  padding: 0 2px;
  scrollbar-width: none;
}

.toolbar::-webkit-scrollbar {
  display: none;
}

.tool-group {
  gap: 5px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.06);
  border-color: rgba(226, 232, 240, 0.14);
}

.icon-btn,
.text-btn,
.menu-btn,
.base-select,
.small-primary {
  min-height: 38px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.74);
  border-color: rgba(226, 232, 240, 0.16);
}

.icon-btn {
  width: 38px;
  min-width: 38px;
}

.menu-btn,
.link-btn {
  min-width: 78px;
  padding: 0 12px;
}

.menu-btn svg,
.icon-btn svg {
  width: 18px;
  height: 18px;
}

.primary-menu,
.icon-btn.active,
.text-btn.active,
.menu-btn.active {
  color: #ffffff;
  background: var(--accent-grad);
  border-color: rgba(129, 140, 248, 0.72);
}

.base-select {
  width: 164px;
  min-width: 164px;
  color: #f8fafc;
  background: rgba(2, 6, 23, 0.62);
}

.user-badge {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
}

.floating-panel,
.layer-panel,
.parcel-info-panel,
.coordinate-bar {
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}

.floating-panel {
  top: 16px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.76);
}

:root {
  --layer-panel-width: clamp(360px, 30vw, 484px);
}

.layer-panel {
  width: var(--layer-panel-width);
  background: rgba(11, 18, 32, 0.72);
}

.editor-panel {
  right: calc(var(--layer-panel-width) + 14px);
  width: min(420px, calc(100% - var(--layer-panel-width) - 28px));
}

.layer-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.layer-fab {
  display: none;
  position: absolute;
  z-index: 700;
  right: 12px;
  bottom: 56px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent-grad);
  border: 1px solid rgba(129, 140, 248, 0.72);
  box-shadow: var(--shadow);
  place-items: center;
}

.layer-fab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layer-fab[hidden] {
  display: none;
}

/* Below 1500px the labelled menu buttons overflow the topbar; fall back to icon-only. */
@media (max-width: 1500px) {
  .menu-btn span,
  .link-btn span,
  .group-label {
    display: none;
  }

  .menu-btn,
  .link-btn {
    min-width: 40px;
    padding: 0 10px;
  }
}

.layer-head {
  padding: 16px;
}

.layer-item {
  border-radius: 14px;
  background: rgba(20, 19, 34, 0.6);
}

.layer-main {
  grid-template-columns: 42px minmax(0, 1fr) auto auto;
  gap: 12px;
}

.layer-symbol {
  width: 42px;
  height: 42px;
  border-radius: 11px;
}

.toggle {
  width: 50px;
  height: 28px;
}

.toggle span {
  width: 24px;
  height: 24px;
}

.toggle.on span {
  transform: translateX(22px);
}

.parcel-info-panel {
  width: min(500px, calc(100% - 532px));
  background: linear-gradient(180deg, rgba(6, 15, 28, 0.78), rgba(15, 23, 42, 0.64));
  border-radius: 12px;
}

.panel-head h2,
.layer-head h2 {
  font-size: 17px;
}

@media (max-width: 1024px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .brand {
    width: 100%;
    min-width: 0;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    overflow: visible;
  }

  .layer-panel {
    width: min(440px, 92vw);
  }

  .editor-panel {
    right: 14px;
    width: min(430px, calc(100% - 28px));
    top: 14px;
  }

  .drone-panel {
    left: 14px;
    width: min(430px, calc(100% - 28px));
    top: 14px;
  }

  .field-tools-panel,
  .gis-panel,
  .archived-panel {
    left: 14px;
    width: min(430px, calc(100% - 28px));
    top: 14px;
  }

  .parcel-info-panel {
    left: 14px;
    top: 14px;
    width: min(430px, calc(100% - 486px));
  }
}

@media (max-width: 760px) {
  html,
  body {
    font-size: 13px;
  }

  .app-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    padding: max(8px, env(safe-area-inset-top)) 8px 8px;
    border-bottom-color: rgba(226, 232, 240, 0.14);
  }

  .brand {
    gap: 8px;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
  }

  .brand strong {
    font-size: 14px;
  }

  .toolbar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    /* Fade the right edge so users notice the toolbar scrolls horizontally. */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }

  .layer-close-btn {
    display: inline-grid;
    width: 42px;
    min-width: 42px;
    min-height: 42px;
  }

  .layer-fab:not([hidden]) {
    display: grid;
  }

  .tool-group {
    padding: 3px;
  }

  .icon-btn,
  .menu-btn,
  .base-select,
  .small-primary {
    min-height: 42px;
  }

  .icon-btn {
    width: 42px;
    min-width: 42px;
  }

  .icon-btn.light {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
  }

  .menu-btn,
  .link-btn {
    min-width: 42px;
    padding: 0 10px;
  }

  .menu-btn span,
  .link-btn span,
  .group-label {
    display: none;
  }

  .base-group {
    padding-left: 3px;
  }

  .base-select {
    width: 150px;
    min-width: 150px;
    padding: 0 9px;
  }

  .user-badge {
    display: none;
  }

  .floating-panel,
  .parcel-info-panel {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 8px;
    width: auto;
    max-height: min(72dvh, calc(100% - 16px));
    border-radius: 12px;
  }

  .editor-panel,
  .drone-panel,
  .field-tools-panel,
  .gis-panel,
  .archived-panel {
    left: 8px;
    right: 8px;
    width: auto;
  }

  .search-panel {
    width: auto;
  }

  .layer-panel {
    top: auto;
    right: 0;
    bottom: 0;
    width: 100%;
    height: min(62dvh, 540px);
    border-left: 0;
    border-top: 1px solid rgba(226, 232, 240, 0.18);
    border-radius: 14px 14px 0 0;
    transform: translateY(0);
  }

  .layer-panel.closed {
    transform: translateY(100%);
  }

  .layer-head {
    padding: 12px 14px;
  }

  .layer-list {
    padding: 10px;
    gap: 8px;
    align-items: stretch;
  }

  .layer-main {
    grid-template-columns: 38px minmax(0, 1fr) auto auto;
    gap: 10px;
    padding: 10px;
  }

  .layer-symbol {
    width: 40px;
    height: 40px;
  }

  .layer-tools {
    gap: 10px;
    padding: 10px 12px 14px;
  }

  .toggle {
    width: 46px;
    height: 28px;
  }

  .toggle.on span {
    transform: translateX(18px);
  }

  .parcel-info-head {
    padding: 14px;
  }

  .parcel-info-head h2 {
    font-size: 24px;
  }

  .parcel-area-card {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .parcel-area-card strong,
  .parcel-owner-card strong {
    font-size: 20px;
  }

  .record-list {
    max-height: 42dvh;
  }

  .coordinate-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    max-width: none;
    min-height: 34px;
    padding: 8px 12px;
    font-size: 12px;
  }

  .layer-panel:not(.closed) ~ .coordinate-bar,
  .floating-panel.open ~ .coordinate-bar,
  .parcel-info-panel:not([hidden]) ~ .coordinate-bar {
    display: none;
  }
}

@media (max-width: 420px) {
  .base-select {
    width: 132px;
    min-width: 132px;
  }

  .layer-main {
    grid-template-columns: 36px minmax(0, 1fr) 46px 32px;
    gap: 8px;
  }

  .layer-symbol {
    width: 36px;
    height: 36px;
  }

  .layer-title {
    font-size: 14px;
  }

  .layer-meta {
    font-size: 11px;
  }

  input,
  select,
  textarea {
    min-height: 42px;
  }
}

/* ===== Survey markers: type icon + status-coloured ring ===== */
.survey-pin-wrap {
  background: none;
  border: 0;
}

.survey-pin {
  position: relative;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transform-origin: 20px 48px;
  background: #fff;
  border: 3px solid var(--ring, #38bdf8);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.38);
  transition: transform 120ms ease;
}

.survey-pin::after {
  content: '';
  position: absolute;
  top: 35px;
  left: 10px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid var(--ring);
}

.survey-pin-face {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--pin);
}

.survey-pin-status {
  position: absolute;
  top: -5px;
  right: -8px;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 21px;
  height: 21px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ring);
  color: #fff;
  box-shadow: 0 1px 4px #0006;
}

.survey-pin .survey-pin-status svg { width: 13px; height: 13px; stroke-width: 2.6; }
.survey-pin-status b { font: 800 14px/1 sans-serif; }

.survey-pin svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.survey-pin.selected {
  transform: scale(1.12);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35), 0 10px 22px rgba(6, 4, 22, 0.55);
}

/* ===== Parcel-shape row inside the editor ===== */
.geometry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 14px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.32);
}

.geometry-row[hidden] {
  display: none;
}

.geometry-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

#geometryStatus {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 800;
}

#geometryStatus.has-shape {
  color: #86efac;
}

.geometry-draw-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  color: #ffffff;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  border: 1px solid rgba(34, 197, 94, 0.6);
  font-weight: 800;
  white-space: nowrap;
}

.geometry-draw-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== Floating parcel-draw toolbar ===== */
.draw-toolbar {
  position: absolute;
  z-index: 780;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: grid;
  gap: 12px;
  width: min(420px, calc(100% - 28px));
  padding: 14px 16px;
  border-radius: 14px;
  color: var(--ink);
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(34, 197, 94, 0.4);
  box-shadow: var(--shadow), 0 0 40px rgba(34, 197, 94, 0.16);
  backdrop-filter: blur(16px) saturate(140%);
}

.draw-toolbar[hidden] {
  display: none;
}

.draw-toolbar-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.draw-toolbar-head svg {
  width: 30px;
  height: 30px;
  padding: 6px;
  border-radius: 10px;
  color: #ffffff;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  box-sizing: content-box;
}

.draw-toolbar-head strong {
  display: block;
  font-size: 14px;
}

.draw-toolbar-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.draw-toolbar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 8px;
}

.draw-btn {
  min-height: 40px;
  border-radius: 9px;
  color: #e2e8f0;
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.28);
  font-weight: 800;
}

.draw-btn.primary {
  color: #ffffff;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  border-color: rgba(34, 197, 94, 0.6);
}

.draw-btn.danger {
  color: #fecdd3;
  background: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.4);
}

@media (max-width: 760px) {
  .draw-toolbar {
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
  }
}

/* Final layer panel guard: keeps rows readable and prevents stacked layer cards. */
.layer-panel {
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr);
}

.layer-list {
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  align-items: stretch;
}

.layer-item {
  flex: 0 0 auto;
  min-height: 74px;
  overflow: hidden;
}

.layer-main {
  min-height: 74px;
  grid-template-columns: 48px minmax(0, 1fr) 54px 32px;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
}

.layer-text {
  align-self: center;
  min-width: 0;
  min-height: 42px;
  overflow: hidden;
}

.layer-title,
.layer-title span,
.layer-meta {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-title {
  font-size: 16px;
  line-height: 1.25;
}

.layer-meta {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
}

.layer-symbol {
  width: 48px;
  height: 48px;
}

.layer-item.expanded .layer-main {
  border-bottom: 1px solid rgba(129, 140, 248, 0.16);
}

.layer-item.expanded .layer-tools {
  overflow: hidden;
}

@media (max-width: 760px) {
  .layer-item {
    min-height: 72px;
  }

  .layer-main {
    min-height: 72px;
    grid-template-columns: 42px minmax(0, 1fr) 50px 30px;
    gap: 10px;
    padding: 10px 12px;
  }

  .layer-symbol {
    width: 42px;
    height: 42px;
  }

  .layer-title {
    font-size: 15px;
  }

  .layer-meta {
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .layer-main {
    grid-template-columns: 38px minmax(0, 1fr) 46px 28px;
    gap: 8px;
  }

  .layer-symbol {
    width: 38px;
    height: 38px;
  }
}

/* ===== NEW: VALIDATION STYLES ===== */
input.error,
select.error,
textarea.error {
  border-color: #ef4444 !important;
  background-color: #fee2e2;
}

input.warning,
select.warning,
textarea.warning {
  border-color: #f59e0b !important;
  background-color: #fef3c7;
}

.error-message {
  color: #dc2626;
  font-size: 12px;
  margin-top: 4px;
  font-weight: 500;
}

.warning-message {
  color: #d97706;
  font-size: 12px;
  margin-top: 4px;
}

#parcelCode-error,
#parcelCode-warning {
  min-height: 20px;
  margin-bottom: 8px;
  display: none;
}

/* ===== NEW: PHOTO DROP ZONE ===== */
.photo-drop-zone {
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #f9fafb;
  margin-bottom: 16px;
}

.photo-drop-zone:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.photo-drop-zone.dragover {
  border-color: #3b82f6;
  background: #dbeafe;
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.photo-drop-zone p {
  margin: 8px 0 12px 0;
  color: #333;
  font-weight: 500;
}

.photo-drop-zone small {
  display: block;
  color: #999;
  font-size: 12px;
  margin-top: 8px;
}

.photo-drop-zone svg {
  color: #999;
  margin-bottom: 8px;
}

.button-link {
  display: inline-block;
  padding: 8px 16px;
  background: #3b82f6;
  color: white;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.button-link:hover {
  background: #2563eb;
}

/* ===== NEW: PHOTO GALLERY ===== */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.photo-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  background: white;
}

.photo-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.photo-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f3f4f6;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 4px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 100%;
  overflow: hidden;
}

.photo-info small {
  color: white;
}

.photo-meta {
  padding: 8px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  color: #666;
  line-height: 1.4;
}

.delete-photo-btn {
  width: 100%;
  padding: 6px 4px;
  border: none;
  background: #fee2e2;
  color: #dc2626;
  cursor: pointer;
  font-size: 12px;
  border-top: 1px solid #e5e7eb;
  transition: background 0.2s;
  font-weight: 500;
}

.delete-photo-btn:hover {
  background: #fecaca;
}

.delete-photo-btn:active {
  background: #fca5a5;
}

.empty {
  padding: 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.offline-area-control { display:grid; gap:8px; margin-top:12px; }
.offline-area-control small { color:var(--muted); line-height:1.45; }
.sync-issue-list { display:grid; gap:6px; }
.sync-issue { display:grid; gap:5px; padding:9px; border:1px solid #f59e0b; border-radius:6px; background:#fffbeb; color:#78350f; font-size:12px; }
.sync-issue button { min-height:34px; padding:0 10px; border-color:#f59e0b; background:#fff; color:#92400e; font-weight:800; }
