* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f3f4f6; color: #111827; height: 100vh; overflow: hidden; }
.hidden { display: none !important; }

/* Login overlay */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a56db, #1e429f);
}
.login-card {
  background: #fff; padding: 2rem; border-radius: 12px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-card h1 { font-size: 1.2rem; margin-bottom: .25rem; }
.login-card p { color: #6b7280; font-size: .875rem; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8125rem; font-weight: 500; margin-bottom: .375rem; }
.form-group input, .form-group select {
  width: 100%; padding: .5rem .75rem; border: 1px solid #e5e7eb; border-radius: 6px; font-size: .875rem;
}
.btn {
  padding: .5rem 1rem; border: none; border-radius: 6px; font-size: .875rem; font-weight: 500;
  cursor: pointer; background: #e5e7eb; color: #111827;
}
.btn-primary { background: #1a56db; color: #fff; width: 100%; margin-top: .5rem; }
.btn-primary:hover { background: #1e429f; }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }
.btn-success { background: #059669; color: #fff; width: 100%; margin-top: .5rem; }
.error-msg { color: #dc2626; font-size: .8125rem; margin-top: .5rem; }

/* Landing / workspace gate */
#workspace-gate-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #0f3d8c 0%, #1a56db 45%, #1e3a8a 100%);
  padding: 1.25rem;
}
.workspace-gate-card {
  background: #fff; width: 100%; max-width: 520px; border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28); padding: 1.5rem 1.5rem 1.25rem;
}
.workspace-gate-topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.1rem;
}
.workspace-gate-brand h1 { font-size: 1.2rem; margin-bottom: .35rem; line-height: 1.35; }
.workspace-gate-brand p { color: #6b7280; font-size: .875rem; line-height: 1.45; margin: 0; }
.workspace-signin-btn {
  width: auto !important; margin-top: 0 !important; flex-shrink: 0;
  padding: .45rem .9rem;
}
.workspace-gate-user {
  font-size: .8125rem; color: #4b5563; margin-bottom: .85rem;
  padding: .5rem .65rem; background: #f3f4f6; border-radius: 8px;
}
.workspace-gate-dropdown { margin-bottom: .75rem; }
.workspace-gate-dropdown select {
  font-size: .9375rem; padding: .65rem .75rem;
}
#btn-guest-enter-region { margin-top: 0; }
.workspace-gate-divider {
  display: flex; align-items: center; gap: .75rem;
  margin: 1.1rem 0 .85rem; color: #9ca3af; font-size: .75rem;
}
.workspace-gate-divider::before,
.workspace-gate-divider::after {
  content: ''; flex: 1; height: 1px; background: #e5e7eb;
}
.workspace-gate-list {
  display: flex; flex-direction: column; gap: .55rem;
  max-height: min(36vh, 280px); overflow: auto; margin-bottom: .5rem;
}
.workspace-gate-empty { color: #9ca3af; font-size: .875rem; padding: .75rem 0; text-align: center; }
.workspace-area-row {
  display: flex; align-items: stretch; gap: .45rem;
}
.workspace-area-row .workspace-area-card { flex: 1; min-width: 0; }
.workspace-area-row.is-current .workspace-area-card {
  border-color: #059669; background: #ecfdf5;
}
.workspace-area-card {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  width: 100%; text-align: left; padding: .75rem .9rem;
  border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.workspace-area-card:hover, .workspace-area-card:focus-visible {
  border-color: #1a56db; box-shadow: 0 0 0 3px rgba(26,86,219,.12); outline: none;
}
.workspace-area-card .wa-name { font-weight: 600; font-size: .9375rem; }
.workspace-area-card .wa-meta { font-size: .75rem; color: #6b7280; margin-top: .15rem; }
.workspace-area-card .wa-enter {
  flex-shrink: 0; font-size: .8125rem; font-weight: 600; color: #1a56db;
}
.wa-delete {
  flex-shrink: 0; align-self: center;
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
  border-radius: 8px; padding: .45rem .65rem; font-size: .75rem; cursor: pointer;
}
.wa-delete:hover { background: #fee2e2; }
.workspace-gate-create {
  border-top: 1px solid #e5e7eb; padding-top: 1rem; margin-top: 1rem;
}
.workspace-gate-create h2 { font-size: .9375rem; margin-bottom: .35rem; }
.workspace-gate-hint { font-size: .75rem; color: #6b7280; margin-bottom: .65rem; }
.workspace-gate-back { width: 100%; margin-top: .85rem; background: transparent; color: #6b7280; }
.workspace-gate-back:hover { color: #111827; background: #f3f4f6; }

#btn-workspace-switch { flex-shrink: 0; }

/* App layout */
#app-screen { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: 270px; background: #1f2937; color: #e5e7eb; display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-header {
  padding: 1.25rem; border-bottom: 1px solid #374151;
  display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem;
}
.sidebar-header h1 { font-size: 1rem; line-height: 1.4; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem; }
.nav-item {
  display: block; width: 100%; text-align: left; padding: .625rem .875rem; border-radius: 6px;
  color: #e5e7eb; background: none; border: none; font-size: .875rem; cursor: pointer; margin-bottom: .25rem;
}
.nav-item:hover, .nav-item.active { background: #374151; }
.sidebar-footer { padding: 1rem; border-top: 1px solid #374151; font-size: .8125rem; color: #9ca3af; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid #e5e7eb; padding: .75rem 1.25rem;
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.topbar h2 { font-size: 1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.workspace-picker {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  color: #4b5563;
  min-width: 0;
}
.workspace-picker-label { white-space: nowrap; font-weight: 600; }
.workspace-picker select {
  max-width: min(220px, 36vw);
  padding: .3rem .45rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: .8125rem;
}
body.workspace-required .workspace-picker select {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, .15);
}
#btn-workspace-new { flex-shrink: 0; }
.page { flex: 1; overflow: auto; padding: 1rem; }
.panel {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem; margin-bottom: .75rem;
}
.panel h3 { font-size: .875rem; font-weight: 600; margin-bottom: .75rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border: 1px solid #e5e7eb; border-radius: 8px;
  background: #fff; color: #111827; font-size: 1.125rem; cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: #f3f4f6; }
.sidebar-close { background: #374151; border-color: #4b5563; color: #e5e7eb; display: none !important; }
body.compact-chrome .sidebar-close { display: inline-flex !important; }
.chrome-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 2400;
}
.chrome-only { display: none !important; }
.desktop-only { display: block; }
body.compact-chrome .chrome-only { display: inline-flex !important; }
body.compact-chrome .chrome-only.hidden { display: none !important; }
.layer-panel-head {
  display: none; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; border-bottom: 1px solid #e5e7eb; background: #fff;
}

/* Map */
.map-layout { display: flex; flex: 1; overflow: hidden; }
.layer-panel { width: 250px; padding: .75rem; background: #f9fafb; border-right: 1px solid #e5e7eb; overflow-y: auto; flex-shrink: 0; }
.map-stage { flex: 1; position: relative; min-width: 0; min-height: 0; }
#map { width: 100%; height: 100%; min-height: 280px; }
#map.road-review-cursor-active,
#map.road-review-cursor-active.leaflet-grab,
#map.road-review-cursor-active .leaflet-pane canvas {
  cursor: pointer !important;
}
.layer-item { display: flex; align-items: center; gap: .5rem; padding: .375rem 0; font-size: .8125rem; }
.layer-count { margin-left: auto; color: #6b7280; font-size: .75rem; }
.gps-btn {
  position: absolute; bottom: 2rem; right: 1rem; z-index: 1000; background: #fff;
  border: 2px solid rgba(0,0,0,.2); border-radius: 6px; padding: .5rem .75rem; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.map-search {
  position: absolute; top: .75rem; left: .75rem; z-index: 1000;
  width: min(320px, calc(100% - 10rem));
  font-size: .875rem;
}
.map-search input {
  width: 100%; box-sizing: border-box;
  padding: .55rem .75rem; border-radius: 8px;
  border: 2px solid rgba(0,0,0,.18); background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  font: inherit;
}
.map-search input:focus {
  outline: none; border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.2);
}
.map-search-results {
  margin-top: .35rem; max-height: min(50vh, 320px); overflow: auto;
  background: #fff; border-radius: 8px;
  border: 1px solid rgba(0,0,0,.12);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
}
.map-search-results.hidden { display: none; }
.map-search-item {
  display: block; width: 100%; text-align: left;
  padding: .55rem .75rem; border: 0; border-bottom: 1px solid #f3f4f6;
  background: #fff; cursor: pointer; font: inherit;
}
.map-search-item:last-child { border-bottom: 0; }
.map-search-item:hover, .map-search-item.is-active { background: #eff6ff; }
.map-search-item .map-search-label {
  display: block; font-weight: 600; color: #111827; line-height: 1.3;
}
.map-search-item .map-search-sub {
  display: block; font-size: .75rem; color: #6b7280; margin-top: .15rem;
}
.map-search-item .map-search-kind {
  display: inline-block; font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  padding: .1rem .35rem; border-radius: 4px; margin-right: .35rem;
  vertical-align: middle;
}
.map-search-kind.is-address { background: #dcfce7; color: #166534; }
.map-search-kind.is-road { background: #dbeafe; color: #1e40af; }
.map-search-kind.is-alley { background: #ffedd5; color: #9a3412; }
.map-search-kind.is-village { background: #cffafe; color: #0e7490; }
.map-search-kind.is-parcel { background: #f3e8ff; color: #6b21a8; }
.map-search-parcel {
  display: flex; gap: .35rem; margin-top: .35rem; align-items: stretch;
}
.map-search-parcel input {
  flex: 1; min-width: 0; padding: .4rem .55rem; font-size: .8125rem;
}
.map-search-parcel button {
  flex: 0 0 auto; border: 2px solid #6d28d9; background: #7c3aed; color: #fff;
  border-radius: 8px; padding: .4rem .65rem; font: inherit; font-size: .75rem;
  font-weight: 700; cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(109,40,217,.2);
}
.map-search-parcel button:hover { background: #6d28d9; }
.map-search-empty, .map-search-hint {
  padding: .65rem .75rem; color: #6b7280; font-size: .8125rem;
}
body.compact-chrome .map-search { top: .5rem; left: .5rem; width: min(280px, calc(100% - 1rem)); }
.map-search-parcel-hl {
  animation: map-search-parcel-pulse 1.1s ease-in-out 4;
}
@keyframes map-search-parcel-pulse {
  0%, 100% { fill-opacity: 0.38; stroke-width: 3px; }
  50% { fill-opacity: 0.68; stroke-width: 5px; }
}
.gps-btn.is-busy { opacity: .75; cursor: wait; }
.gps-status {
  position: absolute; left: 50%; bottom: 5.5rem; transform: translateX(-50%) translateY(8px);
  z-index: 1000; max-width: min(92vw, 340px); padding: .55rem .85rem;
  background: rgba(17, 24, 39, .88); color: #fff; border-radius: 10px;
  font-size: .8125rem; line-height: 1.35; text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.gps-status.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.gps-status.is-error { background: rgba(146, 64, 14, .94); }
body.compact-chrome .gps-status { bottom: 4.75rem; }
.map-export-btn {
  position: absolute; top: .75rem; right: .75rem; z-index: 1000; background: #fff;
  border: 2px solid rgba(0,0,0,.2); border-radius: 6px; padding: .45rem .7rem; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.15); font-size: .8125rem; font-weight: 600;
}
.map-export-btn:disabled { opacity: .65; cursor: wait; }
.map-tool-stack {
  position: absolute; top: 3.15rem; right: .75rem; z-index: 1000;
  display: flex; flex-direction: column; gap: .4rem; align-items: flex-end;
}
.map-tool-btn {
  position: relative; background: #fff;
  border: 2px solid rgba(0,0,0,.2); border-radius: 6px; padding: .45rem .7rem; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.15); font-size: .8125rem; font-weight: 600;
  white-space: nowrap;
}
.map-tool-btn.is-active {
  background: #1d4ed8; color: #fff; border-color: #1d4ed8;
}
#btn-road-renumber.is-active {
  background: #b45309; color: #fff; border-color: #b45309;
}
#btn-swap-reserved.is-active {
  background: #0f766e; color: #fff; border-color: #0f766e;
}
#btn-remove-road-number.is-active {
  background: #b91c1c; color: #fff; border-color: #b91c1c;
}
#btn-remove-road-number-pick-road.is-active {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}
.map-tool-hint {
  position: absolute; top: .75rem; left: 50%; transform: translateX(-50%);
  z-index: 1000; max-width: min(28rem, calc(100vw - 2rem));
  background: rgba(15, 118, 110, 0.95); color: #ecfdf5;
  font-size: .78rem; font-weight: 600; line-height: 1.35;
  padding: .45rem .7rem; border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2); text-align: center;
  pointer-events: none;
}
.map-tool-hint.is-success {
  background: rgba(5, 150, 105, 0.97);
  color: #fff;
}
.map-tool-hint.is-error {
  background: rgba(217, 119, 6, 0.97);
  color: #fffbeb;
}
.map-tool-hint.is-pulse {
  animation: dxPickBannerPulse 0.55s ease-out 2;
}
@keyframes dxPickBannerPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.03); }
}
.leaflet-tooltip.map-dx-start-marker-label {
  background: rgba(3, 105, 161, 0.96);
  color: #fff;
  border: 1px solid #0ea5e9;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(3, 105, 161, 0.35);
}
#road-start-markers-toggle {
  position: absolute;
  top: 3.15rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: .4rem;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.88);
  color: #e2e8f0;
  font-size: .75rem;
  font-weight: 600;
  padding: .35rem .65rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  white-space: nowrap;
}
#road-start-markers-toggle.hidden {
  display: none;
}
.extra-number-panel {
  position: absolute;
  top: 8.6rem;
  right: .75rem;
  bottom: 1rem;
  z-index: 1000;
  width: min(340px, calc(100% - 1.5rem));
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  padding: 0;
}
.extra-number-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: .55rem .85rem .85rem;
}
.extra-number-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-shrink: 0;
  background: #fff;
  padding: .75rem .85rem .55rem;
  border-bottom: 1px solid #e5e7eb;
  border-radius: 10px 10px 0 0;
}
#road-edit-panel {
  width: min(380px, calc(100% - 1.5rem));
}
.road-edit-status-banner {
  margin: 0 0 .45rem;
  padding: .4rem .5rem;
  border-radius: 6px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  min-height: 1.25em;
}
.road-edit-status-banner.is-error {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}
.extra-number-hint { font-size: .75rem; color: #6b7280; margin: 0 0 .45rem; line-height: 1.35; }
.extra-number-count { font-size: .8125rem; margin-bottom: .35rem; }
.extra-number-list {
  max-height: 120px; overflow: auto; font-size: .72rem; color: #374151;
  border: 1px solid #f3f4f6; border-radius: 6px; padding: .35rem .45rem; background: #f9fafb;
}
.extra-number-status { font-size: .75rem; margin: .55rem 0 0; color: #065f46; min-height: 1.1em; }
.extra-number-status.is-error { color: #b45309; }
.road-tool-section {
  margin-top: .7rem;
  padding: .55rem .6rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
}
.road-tool-section-title {
  font-size: .78rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 .3rem;
}
#btn-extra-number-pick-road.is-active,
#btn-road-review-pick-road.is-active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}
body.compact-chrome .map-tool-stack { top: 3rem; right: .75rem; }
body.compact-chrome .extra-number-panel { top: 7.5rem; bottom: .75rem; }

/* Compact chrome: khách (mọi kích thước) + điện thoại đã đăng nhập */
body.compact-chrome .desktop-only { display: none !important; }
body.compact-chrome .topbar-docs { display: none; }
body.compact-chrome .sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 2500;
  width: min(300px, 88vw);
  transform: translateX(-105%);
  transition: transform .22s ease;
  box-shadow: 8px 0 28px rgba(0,0,0,.25);
}
body.compact-chrome .sidebar.is-open { transform: translateX(0); }
body.compact-chrome .layer-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2500;
  width: auto; max-height: min(72vh, 560px);
  padding: 0; border: none; border-radius: 16px 16px 0 0;
  background: #fff;
  box-shadow: 0 -8px 28px rgba(0,0,0,.18);
  transform: translateY(110%);
  transition: transform .22s ease;
  overflow: hidden;
  display: flex; flex-direction: column;
}
body.compact-chrome .layer-panel.is-open { transform: translateY(0); }
body.compact-chrome .layer-panel-head { display: flex; }
body.compact-chrome .layer-panel > .panel { overflow-y: auto; flex: 1; margin: 0; border-radius: 0; }
body.compact-chrome .map-layout { flex-direction: column; }
body.compact-chrome .gps-btn { bottom: 1.25rem; right: .75rem; }

/* Login mobile */
@media (max-width: 600px) {
  #login-screen { padding: 1rem; align-items: flex-start; padding-top: 10vh; }
  .login-card { padding: 1.25rem; border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.18); }
  .topbar { padding: .625rem .75rem; }
  .page { padding: .75rem; }
  .wizard-steps { margin: 0 0 .75rem; flex-wrap: wrap; }
  .wizard-step { flex: 1 1 40%; border-right: none; border-bottom: 1px solid #e5e7eb; }
  .layer-picker-layout { flex-direction: column; min-height: 320px; }
  .modal { padding: 1rem; max-height: 88vh; width: 94%; }
  .pipeline-preview-panel { left: .5rem; right: .5rem; width: auto; }
}

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.table th, .table td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid #e5e7eb; }
.table th { background: #f9fafb; font-weight: 600; }
.table-wrap { overflow-x: auto; }

.alert { padding: .75rem 1rem; border-radius: 6px; font-size: .8125rem; margin-bottom: .75rem; }
.alert-info { background: #eff6ff; color: #1e40af; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-warning { background: #fffbeb; color: #92400e; }

.upload-zone {
  border: 2px dashed #e5e7eb; border-radius: 8px; padding: 2rem; text-align: center; cursor: pointer;
}
.upload-zone:hover,
.upload-zone.dragover { border-color: #1a56db; background: #eff6ff; }
.upload-zone p { color: #6b7280; font-size: .875rem; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex;
  align-items: center; justify-content: center; z-index: 2000;
}
.modal {
  background: #fff; border-radius: 12px; padding: 1.5rem; max-width: 500px; width: 90%;
  max-height: 80vh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
#modal-body .form-group input[type="text"],
#modal-body .form-group textarea {
  pointer-events: auto !important;
  user-select: text !important;
  -webkit-user-select: text !important;
}
#pdf-title {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  border: 2px solid #1d4ed8;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: #111827;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}
#pdf-title:focus {
  outline: 2px solid #93c5fd;
  border-color: #1e40af;
}
#pdf-filename-preview {
  font-size: 0.75rem;
  color: #374151;
  margin: 0.35rem 0 0;
  word-break: break-all;
}
.modal.modal-pdf-form {
  max-width: 760px;
  max-height: 90vh;
}
.pdf-mode-tabs {
  display: flex;
  gap: .4rem;
  margin: 0 0 .75rem;
}
.pdf-mode-tabs button {
  flex: 1;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  border-radius: 8px;
  padding: .45rem .6rem;
  font-size: .8125rem;
  font-weight: 600;
  cursor: pointer;
}
.pdf-mode-tabs button.is-active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}
.pdf-village-list {
  max-height: 9.5rem;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: .35rem .5rem;
  background: #fff;
  font-size: .8125rem;
}
.pdf-village-list label {
  display: flex;
  gap: .4rem;
  align-items: center;
  padding: .15rem 0;
}
.excel-match-village-list {
  max-height: 11rem;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: .35rem .5rem;
  background: #fff;
  font-size: .8125rem;
}
.excel-match-village-list label {
  display: flex;
  gap: .4rem;
  align-items: center;
  padding: .15rem 0;
}
.pdf-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .2rem .75rem;
  font-size: .8125rem;
}
.modal-drag-handle {
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
  margin: -0.5rem -0.5rem 0.75rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: #f3f4f6;
  color: #374151;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
#modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#modal-close {
  flex-shrink: 0;
}
.modal-drag-handle:active { cursor: grabbing; }
#modal.modal-user-moved {
  align-items: flex-start;
  justify-content: flex-start;
  background: transparent;
  pointer-events: none;
}
#modal.modal-user-moved .modal {
  position: fixed;
  margin: 0;
  pointer-events: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}
#modal.modal-user-moved.modal-preview-dock {
  padding: 0;
}
.popup-row { display: flex; justify-content: space-between; gap: .75rem; padding: .25rem 0; font-size: .8125rem; border-bottom: 1px solid #f3f4f6; }
.popup-label { color: #6b7280; flex-shrink: 0; min-width: 7.5rem; }
.popup-section-title {
  margin: .75rem 0 .35rem;
  font-size: .8125rem;
  font-weight: 700;
  color: #111827;
}

.badge { display: inline-block; padding: .125rem .5rem; border-radius: 9999px; font-size: .75rem; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-editor { background: #dbeafe; color: #1e40af; }
.badge-contributor { background: #ecfdf5; color: #065f46; }
.role-parcel { color: #1d4ed8; }
.role-annotation { color: #059669; }
.role-frame { color: #9ca3af; text-decoration: line-through; }
.role-other { color: #6b7280; }
.layer-role-badge {
  font-size: .65rem; padding: .1rem .35rem; border-radius: 4px;
  background: #f3f4f6; margin-left: .25rem;
}

/* Wizard */
.wizard-steps {
  display: flex; gap: 0; margin: 0 1rem 1rem; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden;
}
.wizard-step {
  flex: 1; padding: .75rem 1rem; text-align: center; font-size: .8125rem;
  color: #6b7280; background: #f9fafb; border-right: 1px solid #e5e7eb;
}
.wizard-step:last-child { border-right: none; }
.wizard-step.active { background: #1a56db; color: #fff; font-weight: 600; }
.wizard-step.done { background: #ecfdf5; color: #065f46; }

.progress-log {
  background: #1f2937; color: #e5e7eb; border-radius: 8px; padding: 1rem;
  font-family: Consolas, monospace; font-size: .75rem; line-height: 1.7;
  max-height: 200px; overflow-y: auto; min-height: 80px;
}
.progress-log .ok { color: #34d399; }
.progress-log .err { color: #f87171; }
.progress-log .info { color: #93c5fd; }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: #059669; color: #fff; }

.result-card {
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px;
  padding: 1rem; margin-bottom: .75rem;
}
.result-stat { display: inline-block; margin-right: 1.5rem; font-size: .875rem; }
.result-stat strong { font-size: 1.25rem; color: #1a56db; display: block; }

.badge-viewer { background: #f3f4f6; color: #374151; }

.layer-picker-layout {
  display: flex; gap: .75rem; min-height: 420px;
  border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden;
}
.map-label-toggle {
  display: flex; align-items: center; gap: .375rem;
  font-size: .8125rem; color: #374151; margin: .25rem 0 .5rem; cursor: pointer;
}
.basemap-switcher {
  margin: 0 0 .75rem;
}
.basemap-switcher label {
  display: block; font-size: .75rem; font-weight: 600; color: #4b5563; margin-bottom: .25rem;
}
.basemap-switcher select {
  width: 100%; padding: .375rem .5rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: .8125rem;
}
.leaflet-tooltip.map-feature-label {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #94a3b8;
  color: #1e293b;
  font-size: .5625rem;
  font-weight: 600;
  line-height: 1.1;
  padding: .0625rem .25rem;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.leaflet-tooltip.map-road-label {
  background: rgba(254, 242, 242, 0.95);
  border: 1px solid #ef4444;
  color: #991b1b;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.leaflet-tooltip.map-road-label.level-tx { border-color: #b91c1c; color: #7f1d1d; background: rgba(254,226,226,.95); }
.leaflet-tooltip.map-road-label.level-1 { border-color: #ea580c; color: #9a3412; background: rgba(255,237,213,.95); }
.leaflet-tooltip.map-road-label.level-2 { border-color: #ca8a04; color: #854d0e; background: rgba(254,249,195,.95); }
.leaflet-tooltip.map-road-label.level-3 { border-color: #16a34a; color: #166534; background: rgba(220,252,231,.95); }
.leaflet-tooltip.map-road-label.level-4 { border-color: #2563eb; color: #1e40af; background: rgba(219,234,254,.95); }
.leaflet-tooltip.map-road-label.level-5 { border-color: #7c3aed; color: #5b21b6; background: rgba(237,233,254,.95); }
.leaflet-div-icon.map-road-label-marker {
  background: transparent;
  border: none;
  width: 0 !important;
  height: 0 !important;
}
.map-road-label-text {
  display: inline-block;
  transform: translate(-50%, -50%);
  background: rgba(254, 242, 242, 0.95);
  border: 1px solid #ef4444;
  color: #991b1b;
  font-size: .65rem;
  font-weight: 600;
  line-height: 1.15;
  padding: 1px 4px;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.map-road-label-text .road-label-main {
  font-weight: 800;
}
.map-road-label-text .road-label-parent {
  display: block;
  font-size: .78em;
  font-weight: 600;
  opacity: .82;
  margin-top: 1px;
}
.map-road-label-text.level-tx {
  border-color: #b91c1c;
  color: #7f1d1d;
  background: rgba(254,226,226,.95);
  font-size: .72rem;
  font-weight: 700;
}
.map-road-label-text.level-1 {
  border-color: #c2410c;
  color: #7c2d12;
  background: rgba(255, 237, 213, .97);
  font-size: .78rem;
  font-weight: 800;
  padding: 2px 6px;
  border-width: 1.5px;
  box-shadow: 0 1px 3px rgba(194, 65, 12, .28);
}
.map-road-label-text.level-2 {
  border-color: #a16207;
  color: #713f12;
  background: rgba(254, 249, 195, .97);
  font-size: .74rem;
  font-weight: 700;
  padding: 2px 5px;
}
.map-road-label-text.level-3 { border-color: #16a34a; color: #166534; background: rgba(220,252,231,.95); }
.map-road-label-text.level-4 { border-color: #2563eb; color: #1e40af; background: rgba(219,234,254,.95); }
.map-road-label-text.level-5 { border-color: #7c3aed; color: #5b21b6; background: rgba(237,233,254,.95); }
.leaflet-div-icon.map-village-label-marker {
  background: transparent;
  border: none;
  width: 0 !important;
  height: 0 !important;
}
.map-village-label-text {
  display: inline-block;
  transform: translate(-50%, -50%);
  background: rgba(207, 250, 254, 0.94);
  border: 1px solid #0891b2;
  color: #155e75;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  user-select: none;
  box-shadow: 0 1px 3px rgba(8, 145, 178, .25);
}
.leaflet-tooltip.map-parcel-address-label {
  background: rgba(219, 234, 254, 0.95);
  border: 1px solid #3b82f6;
  color: #1d4ed8;
  font-size: .6rem;
  font-weight: 600;
  line-height: 1.1;
  padding: .0625rem .22rem;
  border-radius: 2px;
}
.leaflet-tooltip.map-address-point-label {
  background: rgba(209, 250, 229, 0.95);
  border: 1px solid #10b981;
  color: #047857;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.15;
  padding: .08rem .28rem;
  border-radius: 2px;
  white-space: nowrap;
}
.map-address-point-marker {
  background: transparent !important;
  border: none !important;
}
.leaflet-div-icon.map-house-num-marker,
.leaflet-div-icon.map-road-label-marker,
.leaflet-div-icon.map-parcel-attr-marker,
.leaflet-div-icon.map-village-label-marker,
.leaflet-div-icon.map-search-hl-label {
  pointer-events: none !important;
}
/* Highlight tìm kiếm chỉ để nhìn — không chặn hover/click thửa bên dưới */
.leaflet-pane.map-search-hl-pane,
.leaflet-pane.map-search-hl-pane *,
.leaflet-pane.map-search-hl-pane > svg,
.leaflet-pane.map-search-hl-pane path {
  pointer-events: none !important;
  cursor: inherit;
}
.map-search-hl-label {
  background: transparent !important;
  border: none !important;
}
.map-search-hl-label-text {
  display: inline-block;
  transform: translate(-50%, calc(-100% - 8px));
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ea580c;
  color: #9a3412;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.2;
  padding: .12rem .35rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.map-address-point-marker .map-address-point-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(4, 120, 87, 0.35);
  vertical-align: middle;
  margin-right: 3px;
}
.map-address-point-marker .map-address-point-num {
  display: inline-block;
  vertical-align: middle;
  background: rgba(209, 250, 229, 0.96);
  border: 1.5px solid #059669;
  color: #064e3b;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.15;
  padding: .08rem .28rem;
  border-radius: 3px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
  letter-spacing: 0.01em;
}
.leaflet-tooltip.map-preview-label {
  background: rgba(254, 243, 199, 0.96);
  border: 1px solid #d97706;
  color: #92400e;
  font-size: .65rem;
  font-weight: 700;
}
.map-preview-alley-label {
  background: transparent !important;
  border: none !important;
}
.map-preview-alley-label-text {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.15;
  color: #9a3412;
  background: rgba(255, 237, 213, 0.96);
  border: 1.5px solid #ea580c;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  white-space: nowrap;
  transform: translate(-50%, -50%);
}
.map-preview-alley-label-text small {
  font-size: 0.62rem;
  font-weight: 600;
  color: #c2410c;
  opacity: 0.9;
}
.map-preview-number-marker {
  background: transparent !important;
  border: none !important;
}
.map-preview-number-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  padding: 0 .28rem;
  height: 1.15rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  white-space: nowrap;
}
.map-preview-number-badge.is-preview {
  background: #f59e0b;
  color: #111827;
  border: 1px solid #b45309;
}
/* Thửa bổ sung: vẫn nhãn cam, viền đậm hơn để nổi trên thửa chọn */
.map-preview-number-badge.is-forced {
  background: #f59e0b;
  color: #111827;
  border: 3px solid #9a3412;
  font-size: .8rem;
  min-width: 1.55rem;
  height: 1.35rem;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 2px 6px rgba(0,0,0,.4);
}
/* Số bị tịnh tiến (thửa sau điểm chèn) */
.map-preview-number-badge.is-shifted {
  background: #fb923c;
  color: #111827;
  border: 2px solid #c2410c;
  font-size: .7rem;
  min-width: 2.4rem;
}
.map-preview-number-badge.is-removed {
  background: #fecaca;
  color: #7f1d1d;
  border: 2px solid #b91c1c;
  font-size: .7rem;
  min-width: 2.6rem;
  text-decoration: line-through;
}
/* Khi xem trước: ẩn hộp nhãn trắng của thửa (số tờ/thửa/chủ) — chúng đè kín
   số nhà cam. Giữ nhãn đường và nhãn preview. */
body.pipeline-preview-active .map-address-point-marker,
body.pipeline-preview-active .map-address-point-num,
body.pipeline-preview-active .map-address-point-dot,
body.pipeline-preview-active .leaflet-tooltip.map-address-point-label,
body.pipeline-preview-active .leaflet-tooltip.map-parcel-address-label,
body.pipeline-preview-active .map-house-num-badge {
  opacity: 0.22 !important;
  filter: grayscale(0.35);
  pointer-events: none !important;
}
body.pipeline-preview-active .map-parcel-label-box,
body.pipeline-preview-active .map-parcel-attr-text,
body.pipeline-preview-active .leaflet-tooltip.map-parcel-attr-label,
body.pipeline-preview-active .leaflet-div-icon.map-parcel-attr-marker {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
/* Modal địa chỉ khi đang xem trước: không phủ overlay lên bản đồ */
#modal.modal-preview-dock {
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0.75rem;
  background: transparent;
  pointer-events: none;
}
#modal.modal-preview-dock .modal {
  max-width: min(380px, 92vw);
  max-height: min(48vh, 420px);
  margin: 0;
  overflow: hidden;
  pointer-events: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}
/* Số dự trữ trên đường thôn cho thửa góc đã có số ĐX */
.map-preview-number-badge.is-reserved {
  background: #e0e7ff;
  color: #312e81;
  border: 2px dashed #6366f1;
  font-style: italic;
}
.map-preview-number-badge.is-saved {
  background: #10b981;
  color: #fff;
  border: 1px solid #047857;
}
.pipeline-preview-panel {
  position: absolute;
  z-index: 1100;
  left: 12px;
  bottom: 16px;
  width: min(400px, calc(100% - 24px));
  max-height: min(36vh, 280px);
  overflow: auto;
  background: rgba(255,255,255,.96);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
  padding: .55rem .7rem;
  pointer-events: auto;
}
.pipeline-preview-panel.is-preview-unsaved {
  border-color: #f59e0b;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.28);
}
.pipeline-preview-panel.is-saved {
  border-color: #10b981;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.22);
}
.pipeline-preview-panel.is-running {
  border-color: #3b82f6;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.28);
}
.pipeline-preview-state.is-running {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #60a5fa;
}
.pipeline-step-progress-wrap {
  margin-top: .55rem;
}
.pipeline-step-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
  font-size: .75rem;
  color: #1e3a8a;
  margin-bottom: .3rem;
}
.pipeline-step-progress-meta strong {
  font-variant-numeric: tabular-nums;
  font-size: .875rem;
  color: #1d4ed8;
}
.pipeline-step-progress-track {
  height: 10px;
  border-radius: 999px;
  background: #dbeafe;
  overflow: hidden;
}
.pipeline-step-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa 60%, #93c5fd);
  transition: width .28s ease-out;
}
.pipeline-step-progress-bar.is-save {
  background: linear-gradient(90deg, #2563eb, #7c3aed 55%, #a78bfa);
}
.pipeline-step-progress-elapsed {
  margin: .3rem 0 0;
  font-size: .7rem;
  color: #64748b;
}
.pipeline-progress-toast {
  position: absolute;
  z-index: 1200;
  left: 50%;
  top: 1rem;
  transform: translateX(-50%);
  width: min(360px, calc(100% - 24px));
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #93c5fd;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.22);
  padding: .7rem .85rem;
  pointer-events: none;
}
.pipeline-progress-toast-title {
  font-size: .875rem;
  font-weight: 800;
  color: #1e40af;
  margin-bottom: .35rem;
}
.pipeline-step-banner.pipeline-step-running {
  border-color: #3b82f6;
  background: #eff6ff;
}
.pipeline-step-banner.pipeline-step-running .pipeline-step-banner-badge {
  background: #2563eb;
  color: #fff;
  min-width: 6.2rem;
}
.pipeline-preview-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255,255,255,.98);
  margin: -.75rem -.875rem .35rem;
  padding: .75rem .875rem .35rem;
  border-bottom: 1px solid #e5e7eb;
}
.pipeline-preview-state {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
  padding: .4rem .55rem;
  border-radius: 8px;
  margin: 0 0 .45rem;
  line-height: 1.35;
}
.pipeline-preview-state.is-preview-unsaved {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fbbf24;
}
.pipeline-preview-state.is-saved {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #34d399;
}
.pipeline-preview-msg {
  font-size: .8125rem;
  color: #374151;
  margin-bottom: .5rem;
  line-height: 1.4;
}
.pipeline-step-banner {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  margin-top: 1rem;
  padding: .75rem .9rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}
.pipeline-step-banner-badge {
  flex: 0 0 auto;
  min-width: 5.5rem;
  text-align: center;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .03em;
  padding: .35rem .45rem;
  border-radius: 6px;
  background: #e5e7eb;
  color: #4b5563;
}
.pipeline-step-banner-body {
  min-width: 0;
  flex: 1;
}
.pipeline-step-banner-body strong {
  display: block;
  font-size: .875rem;
  color: #111827;
  margin-bottom: .2rem;
}
.pipeline-step-banner-body p {
  margin: 0;
  font-size: .78rem;
  color: #4b5563;
  line-height: 1.4;
}
.pipeline-step-banner.pipeline-step-preview {
  border-color: #f59e0b;
  background: #fffbeb;
}
.pipeline-step-banner.pipeline-step-preview .pipeline-step-banner-badge {
  background: #f59e0b;
  color: #fff;
}
.pipeline-step-banner.pipeline-step-saved {
  border-color: #10b981;
  background: #ecfdf5;
}
.pipeline-step-banner.pipeline-step-saved .pipeline-step-banner-badge {
  background: #059669;
  color: #fff;
}
.pipeline-step-banner.pipeline-step-idle .pipeline-step-banner-badge {
  background: #e5e7eb;
  color: #6b7280;
}
.layer-catalog {
  width: 42%; max-height: 480px; overflow-y: auto; padding: .5rem;
  background: #f9fafb; border-right: 1px solid #e5e7eb;
}
.gis-import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: .75rem;
}
.gis-source-col { min-width: 0; }
.gis-layer-toolbar {
  display: flex;
  gap: .5rem;
  margin-bottom: .5rem;
  flex-wrap: wrap;
}
.gis-mode-hint {
  font-size: .75rem;
  color: #92400e;
  margin-top: .375rem;
  line-height: 1.4;
}
.gis-source-catalog {
  width: 100%;
  min-height: 100px;
  max-height: 260px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: .25rem 0;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-sizing: border-box;
}
.gis-layer-row {
  padding: .5rem .625rem;
  border-bottom: 1px solid #e5e7eb;
  font-size: .8125rem;
}
.gis-layer-row:last-child { border-bottom: none; }
.gis-layer-row:hover { background: #fff; }
.gis-layer-row-inner {
  display: grid;
  grid-template-columns: 1.25rem 1rem minmax(0, 1fr) 1.75rem;
  column-gap: .5rem;
  row-gap: .125rem;
  align-items: start;
}
.gis-layer-row-inner .gis-layer-order {
  font-size: .75rem;
  color: #9ca3af;
  padding-top: .125rem;
}
.gis-layer-row-inner .gis-layer-chk {
  margin-top: .2rem;
}
.gis-layer-row .gis-layer-name {
  font-size: .8125rem;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-break: normal;
  white-space: normal;
}
.gis-layer-row .gis-layer-name strong {
  font-weight: 600;
  display: inline;
}
.gis-layer-row .layer-meta {
  font-size: .7rem;
  color: #6b7280;
  margin-top: .15rem;
  white-space: normal;
}
.gis-layer-row .gis-layer-actions {
  display: flex;
  flex-direction: column;
  gap: .125rem;
}
.gis-layer-row .gis-layer-actions .btn {
  padding: .125rem .25rem;
  min-width: 1.5rem;
  line-height: 1;
}
.layer-preview-wrap { flex: 1; display: flex; flex-direction: column; }
#dgn-preview-map { flex: 1; min-height: 400px; background: #e5e7eb; }
#gis-preview-map { height: 360px; background: #e5e7eb; border-radius: 8px; border: 1px solid #d1d5db; }
#overlay-preview-map { height: 360px; background: #e5e7eb; border-radius: 8px; border: 1px solid #d1d5db; }

.excel-match-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 960px) {
  .excel-match-grid { grid-template-columns: 1fr; }
}
.excel-match-side { min-width: 0; }
.excel-match-mode-btn.active { box-shadow: inset 0 0 0 2px #1a56db; }
.excel-match-row-matched { background: #ecfdf5; }
.excel-match-row-unmatched { background: #fef2f2; }
.excel-match-gaps {
  margin: 0 0 .75rem;
  padding: .65rem .75rem;
  border: 1px solid #fecaca;
  background: #fff7ed;
  border-radius: 8px;
}
.excel-match-gaps-bar {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.excel-match-gaps details { margin-top: .4rem; }
.excel-match-gaps summary {
  cursor: pointer;
  font-size: .8125rem;
  font-weight: 600;
  color: #9a3412;
}
.excel-match-gaps-table {
  max-height: 220px;
  margin-top: .35rem;
  background: #fff;
}
.excel-match-row-ambiguous { background: #fffbeb; }
.excel-match-row-selected { outline: 2px solid #2563eb; }
.excel-match-row-clickable { cursor: pointer; }
.excel-match-action-bar {
  padding: .75rem 1rem;
  margin-bottom: .75rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
}
.excel-match-action-bar .btn-lg {
  width: 100%;
  padding: .65rem 1rem;
  font-size: .9375rem;
  font-weight: 600;
}
.excel-match-action-bar .btn-success:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.excel-match-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem 1rem;
  font-size: .75rem;
  color: #4b5563;
  margin: .45rem 0 0;
}
.excel-match-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  vertical-align: -2px;
  margin-right: .3rem;
  border: 1px solid rgba(0,0,0,.18);
}
.excel-match-swatch.is-named { background: #10b981; border-color: #047857; }
.excel-match-swatch.is-sel { background: #fbbf24; border-color: #c2410c; }
.excel-match-swatch.is-applied { background: #fde68a; border-color: #d97706; }
.excel-match-swatch.is-plain { background: #93c5fd; border-color: #2563eb; }
.excel-match-label-marker {
  background: transparent !important;
  border: none !important;
  filter: drop-shadow(0 0 4px rgba(234, 88, 12, 0.85));
}
.excel-match-label-marker .map-parcel-label-box {
  font-size: .62rem;
  line-height: 1.25;
  max-width: 11rem;
  pointer-events: none;
}
.gis-preview-wrap { margin-top: .75rem; }
.layer-row {
  display: grid; grid-template-columns: 24px 14px 1fr auto; gap: .5rem;
  align-items: start; padding: .5rem; border-bottom: 1px solid #e5e7eb;
  font-size: .8125rem;
}
.layer-row:hover { background: #fff; }
.layer-color { width: 14px; height: 14px; border-radius: 3px; margin-top: 3px; }
.layer-role-select {
  font-size: .7rem; padding: .2rem .35rem; border: 1px solid #d1d5db; border-radius: 4px;
}
.layer-meta { font-size: .7rem; color: #6b7280; margin-top: .15rem; }

.parcel-label-fields { margin-bottom: .5rem; }
.parcel-label-fields .map-label-toggle { display: block; font-size: .75rem; }
#parcel-review-table .table select,
#parcel-review-table .table input[type=number] {
  font-size: .8125rem; padding: .25rem .35rem;
}
.leaflet-tooltip.map-parcel-attr-label {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #93c5fd;
  color: #1e3a5f;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  padding: 1px 4px;
  box-shadow: none;
  white-space: nowrap;
}
.leaflet-tooltip.map-extra-number-hover-tip {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #2563eb;
  color: #1e3a5f;
  font-size: .75rem;
  font-weight: 500;
  line-height: 1.35;
  padding: .28rem .45rem;
  border-radius: 4px;
  white-space: normal;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .12);
}
.leaflet-tooltip.map-extra-number-hover-tip::before { display: none; }
.map-extra-number-hover .map-extra-number-elig {
  margin-top: .12rem;
  font-weight: 700;
}
.map-extra-number-hover.is-yes .map-extra-number-elig { color: #15803d; }
.map-extra-number-hover.is-no .map-extra-number-elig { color: #b91c1c; }
.leaflet-div-icon.map-parcel-attr-marker {
  background: transparent;
  border: none;
  width: 0 !important;
  height: 0 !important;
}
.map-parcel-attr-text {
  display: inline-block;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #93c5fd;
  color: #1e3a5f;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  padding: 1px 4px;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}
.map-parcel-dot {
  display: block;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  background: #2563eb;
  border: 1px solid #fff;
  box-shadow: 0 0 0 1px rgba(30, 58, 95, 0.35);
  pointer-events: none;
}
.map-parcel-dot.is-yes { background: #16a34a; }
.map-parcel-dot.is-no { background: #dc2626; }
.map-parcel-label-box {
  display: inline-block;
  transform: translate(-50%, -50%);
  min-width: 72px;
  max-width: 180px;
  padding: 3px 5px;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid #2563eb;
  color: #1e3a5f;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}
.map-parcel-label-box.is-yes { border-color: #16a34a; }
.map-parcel-label-box.is-no { border-color: #dc2626; }
.map-parcel-label-box > div { overflow: hidden; text-overflow: ellipsis; }
.leaflet-div-icon.map-house-num-marker {
  background: transparent !important;
  border: none !important;
  width: 0 !important;
  height: 0 !important;
}
.map-house-num-badge {
  display: inline-block;
  transform: translate(-50%, -50%);
  min-width: 1.15rem;
  padding: 0.05rem 0.28rem;
  background: rgba(209, 250, 229, 0.96);
  border: 1.5px solid #059669;
  color: #064e3b;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
  border-radius: 3px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  user-select: none;
}
.leaflet-div-icon.map-house-num-marker.is-overview .map-house-num-badge {
  min-width: 0;
  padding: 0 2px;
  background: rgba(236, 253, 245, 0.62);
  border: 0;
  color: #065f46;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.05;
  border-radius: 2px;
  box-shadow: none;
}
.map-parcel-label-box .map-house-num-line {
  display: block;
  font-weight: 800;
  font-size: 10px;
  color: #064e3b;
  letter-spacing: 0.01em;
}
.map-parcel-label-box .map-house-road-line {
  display: block;
  font-weight: 500;
  font-size: 8.5px;
  color: #475569;
  line-height: 1.15;
  margin-top: 1px;
  max-width: 9.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.parcel-label-fields .map-label-toggle input:disabled {
  opacity: 0.7;
}
