:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --primary-soft: #ccfbf1;
  --accent: #ea580c;
  --accent-soft: #ffedd5;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 12px 28px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.08), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.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;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1.25rem 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--primary), #0b4f4a);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.25);
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2.4vw, 1.45rem);
  letter-spacing: -0.03em;
}

.pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.4rem 0.7rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem 1.5rem;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.card-head h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
}

.status.ok {
  color: var(--green);
}

.status.warn {
  color: var(--amber);
}

.status.error {
  color: var(--red);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 150px;
  padding: 1.25rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: #f0fdfa;
}

.dropzone:active {
  transform: scale(0.995);
}

.dropzone strong {
  color: var(--text);
  font-size: 0.95rem;
}

.dropzone span {
  font-size: 0.84rem;
}

.drop-icon {
  font-size: 1.8rem;
  line-height: 1;
  color: var(--primary);
}

.preview {
  position: relative;
  margin-top: 0.8rem;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.preview img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.preview-action {
  position: absolute;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
}

.preview-retake {
  top: 0.85rem;
  right: 0.85rem;
}

.preview-retake:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.preview-remove {
  bottom: 0.85rem;
  left: 0.85rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.65rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-strong);
}

.btn.secondary {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--text);
}

.btn.secondary:hover {
  border-color: var(--primary);
  background: #f0fdfa;
}

.btn.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn.small {
  min-height: 36px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}

.btn.wide {
  width: 100%;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

a.btn[aria-disabled="true"] {
  pointer-events: none;
}

.btn.is-loading {
  cursor: wait;
  opacity: 0.8;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.field select,
.field input,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}

.field select:focus,
.field input:focus,
textarea:focus,
.coord-table input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  outline-offset: 1px;
  border-color: var(--primary);
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.segmented-wrap {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented-wrap .segment {
  padding-left: 0.3rem;
  padding-right: 0.3rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.segment {
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.segment:hover {
  color: var(--text);
}

.segment.is-active {
  background: var(--primary);
  color: #fff;
}

.segment:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.segment:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.45);
  outline-offset: 1px;
}

.hint {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.hint.warn {
  color: var(--amber);
  font-weight: 600;
}

.hint.ok {
  color: var(--green);
  font-weight: 600;
}

/* ── Upload band (desktop concept B) ───────────────────────── */

.upload-band {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
}

.upload-band[hidden] {
  display: none !important;
}

.band-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.band-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.band-kicker svg {
  flex: 0 0 auto;
  color: var(--primary);
}

.band-checks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.band-checks li {
  display: flex;
  gap: 8px;
  color: #7b8794;
  font-size: 0.66rem;
  line-height: 1.35;
}

.band-checks .n {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.58rem;
  font-weight: 800;
}

.band-checks b {
  display: block;
  color: #334155;
  font-size: 0.72rem;
  font-weight: 800;
}

.band-hint {
  display: none;
  margin: 9px 0 0;
  padding-top: 8px;
  border-top: 1px solid #e8edf2;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.band-checks span span {
  display: block;
  color: #7b8794;
  font-size: 0.66rem;
}

.ocr-band-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ocr-progress-meta {
  flex: 1;
  min-width: 0;
}

.band-progress-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
}

.band-pct {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.band-pct small {
  margin-left: 1px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
}

.band-progress-line .band-progress {
  flex: 1;
  height: 7px;
  margin-top: 0;
}

.band-peek {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  min-width: 154px;
  margin: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.band-peek dt {
  color: #94a3b8;
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.band-peek dd {
  margin: 0;
  color: #334155;
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.band-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 10px;
}

.band-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #475569;
  font-size: 0.56rem;
  font-weight: 700;
  white-space: nowrap;
}

.band-chip i {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.5rem;
  font-style: normal;
  font-weight: 800;
}

.band-chip.pending {
  border-style: dashed;
  background: transparent;
  color: #94a3b8;
}

.band-chip.pending i {
  background: #eef2f6;
  color: #94a3b8;
}

.band-chip.more {
  justify-content: center;
  border-style: dashed;
  background: transparent;
  color: #94a3b8;
}

.band-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.band-cta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 190px;
  margin-left: auto;
  text-align: center;
}

.band-cta .btn {
  width: 100%;
}

.band-caption {
  color: #94a3b8;
  font-size: 0.56rem;
  line-height: 1.35;
}

.upload-card .dz-cta,
.upload-card .dz-micro {
  display: none;
}

.upload-card .dz-cta {
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  margin-top: 12px;
  padding: 0 18px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  box-shadow: 0 6px 16px -8px rgba(15, 118, 110, 0.9);
}

.upload-card .dz-cta svg {
  flex: 0 0 auto;
}

.upload-card .dz-micro {
  color: #94a3b8;
  font-size: 0.68rem;
}

.preview-badge {
  display: none;
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 2;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--green);
  font-size: 0.62rem;
  font-weight: 800;
  box-shadow: 0 3px 10px -2px rgba(0, 0, 0, 0.35);
}

.preview-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.centroid-box {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.8rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.centroid-title {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.centroid-value {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.centroid-status {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.centroid-status.ok {
  color: var(--green);
}

.centroid-status.warn {
  color: var(--amber);
}

.dialog {
  width: min(30rem, calc(100vw - 2rem));
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.dialog-title {
  margin: 0 0 0.6rem;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.dialog-body {
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.dialog-values {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.dialog-values dt {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.dialog-values dd {
  margin: 0.05rem 0 0;
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.dialog-actions .btn {
  min-height: 44px;
  padding-inline: 0.4rem;
  font-size: 0.8rem;
  line-height: 1.2;
}

.btn:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.5);
  outline-offset: 2px;
}

.card.locked > *:not(.card-head) {
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
}

.card.locked .card-head .step {
  background: var(--line);
  color: var(--muted);
}

.table-wrap {
  margin-top: 0.8rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.coord-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.coord-table th,
.coord-table td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.coord-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.coord-table tr:last-child td {
  border-bottom: 0;
}

.coord-table td:first-child {
  width: 2.2rem;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.coord-table input {
  width: 100%;
  min-width: 108px;
  min-height: 36px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.coord-table input.input-error {
  border-color: var(--red);
  background: var(--red-soft);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.details {
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.details summary {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.details summary:hover {
  color: var(--text);
}

.details textarea {
  margin-top: 0.65rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.details .btn {
  margin-top: 0.55rem;
}

.raw-text {
  max-height: 220px;
  margin: 0.65rem 0 0;
  padding: 0.75rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.progress {
  height: 8px;
  margin-top: 0.8rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress > div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #2dd4bf);
  transition: width 180ms ease;
}

.results {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.result-empty {
  padding: 0.85rem;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
}

.result-empty p {
  margin: 0;
}

.result-empty .btn {
  margin-top: 0.6rem;
}

.result-card {
  position: relative;
  display: grid;
  gap: 0.55rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.result-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.result-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
}

.result-sub {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge.high {
  background: var(--green-soft);
  color: var(--green);
}

.badge.medium {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.low {
  background: var(--red-soft);
  color: var(--red);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.7rem;
  margin: 0;
}

.result-grid div {
  min-width: 0;
}

.result-grid dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.result-grid dd {
  margin: 0.05rem 0 0;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  font-weight: 600;
}

.result-card .btn {
  justify-self: start;
}

.map-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: min(62vh, 560px);
  min-height: 360px;
  background: #dfe7ec;
}

.map-legend {
  position: absolute;
  z-index: 500;
  left: 0.75rem;
  bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(6px);
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
}

.swatch.uploaded {
  background: var(--accent);
}

.swatch.official {
  background: var(--blue);
}

.swatch.centroid {
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--green);
}

.map-nav {
  position: absolute;
  z-index: 700;
  right: 0.75rem;
  bottom: 3.1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.8rem;
  max-width: calc(100% - 1.5rem);
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(6px);
}

.map-nav-info {
  display: flex;
  flex: 1 1 10rem;
  flex-direction: column;
  min-width: 0;
}

.map-nav-coords {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.map-nav-caption {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-nav .btn {
  min-height: 38px;
  padding: 0.45rem 0.95rem;
}

@media (min-width: 900px) {
  .topbar,
  .app {
    max-width: none;
    padding-inline: 1.5rem;
  }

  .app {
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    align-items: start;
    padding-bottom: 1rem;
  }

  .stage-nav {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    margin-bottom: 0.75rem;
  }

  .controls {
    grid-column: 1;
    grid-row: 2;
    align-self: stretch;
    max-height: calc(100dvh - 11rem);
    overflow-y: auto;
    padding-right: 0.25rem;
    scrollbar-width: thin;
  }

  .controls .stage-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
  }

  .controls .stage-panel > .card {
    flex: 0 0 auto;
  }

  .map-panel {
    grid-column: 2;
    grid-row: 1 / span 2;
    position: sticky;
    top: 1rem;
  }

  .stage-tab-map,
  .stage-line-map,
  .map-expand-btn {
    display: none !important;
  }

  .coord-pager,
  .results-dots {
    display: none !important;
  }

  #map {
    height: calc(100vh - 6.25rem);
    height: calc(100dvh - 6.25rem);
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 0.75rem 0.9rem 0.35rem;
  }

  .pill {
    display: none;
  }

  .app {
    padding: 0.55rem 0.9rem 1.25rem;
  }

  .card {
    padding: 0.85rem;
  }

  .preview img {
    max-height: 200px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  #map {
    height: 52vh;
    min-height: 300px;
  }
}

/* ── Staged workflow (Concept A) ────────────────────────────── */

.stage-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stage-tab {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.4rem;
  min-height: 32px;
  padding: 0.2rem 0.15rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms ease, opacity 150ms ease;
}

.stage-tab:hover {
  color: var(--text);
}

.stage-tab:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.45);
  outline-offset: 2px;
}

.stage-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stage-dot {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: #eef2f6;
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 800;
  transition: background 150ms ease, color 150ms ease;
}

.stage-tab.is-active {
  color: var(--primary-strong);
}

.stage-tab.is-active .stage-dot {
  background: var(--primary);
  color: #fff;
}

.stage-tab.is-done {
  color: var(--primary);
}

.stage-tab.is-done .stage-dot {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.stage-line {
  flex: 1;
  min-width: 0.5rem;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
}

.stage-line.is-done {
  background: #99f6e4;
}

.stage-tab-map {
  margin-left: auto;
}

.stage-panel {
  min-width: 0;
}

.coord-tools {
  display: none;
}

.tools-dialog {
  max-height: 86dvh;
  overflow-y: auto;
}

.tools-dialog .dialog-actions {
  grid-template-columns: 1fr;
}

.tools-body .details {
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.tools-body .details:first-child {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

.coord-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.coord-pager .icon-btn {
  width: 36px;
  height: 32px;
}

.coord-pager-label {
  min-width: 5.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.results-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 0.55rem;
}

.results-dots button {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: width 150ms ease, background 150ms ease;
}

.results-dots button.is-active {
  width: 18px;
  background: var(--primary);
}

.map-expand-btn {
  display: none;
  position: absolute;
  z-index: 650;
  bottom: 0.6rem;
  left: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 0.4rem 0.6rem;
  color: #334155;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
  cursor: pointer;
}

/* ── Mobile: fixed, non-scrolling shell ─────────────────────── */

@media (max-width: 899px) {
  body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .topbar {
    flex: 0 0 auto;
    width: 100%;
    padding: calc(0.55rem + env(safe-area-inset-top)) 0.9rem 0.4rem;
  }

  .topbar .pill {
    display: none;
  }

  .brand-mark {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-size: 1.15rem;
  }

  .brand-copy h1 {
    font-size: 1rem;
  }

  .app {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0;
    width: 100%;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .stage-nav {
    order: 0;
    flex: 0 0 auto;
    gap: 3px;
    padding: 0.35rem 0.7rem;
    border-width: 1px 0;
    border-radius: 0;
    box-shadow: none;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .stage-nav::-webkit-scrollbar {
    display: none;
  }

  .stage-tab {
    min-height: 34px;
    font-size: 0.66rem;
  }

  .stage-label {
    display: inline;
  }

  .stage-line {
    min-width: 0.4rem;
  }

  .stage-tab-map {
    margin-left: 0;
  }

  .map-panel {
    order: 1;
    flex: 0 0 142px;
    min-height: 0;
    padding: 0.4rem 0.55rem 0;
  }

  .map-panel .map-card {
    height: 100%;
    border-radius: 14px;
  }

  #map {
    height: 100%;
    min-height: 0;
  }

  .map-panel .map-legend,
  .map-panel #mapNav {
    display: none !important;
  }

  .map-panel .leaflet-control-attribution,
  .map-panel .leaflet-control-scale {
    display: none !important;
  }

  .stage-nav {
    width: 100%;
  }

  .map-expand-btn {
    display: inline-flex;
    z-index: 1000;
  }

  .app[data-stage="4"] .map-panel {
    flex: 1 1 auto;
    padding: 0;
  }

  .app[data-stage="4"] .map-panel .map-card {
    height: 100%;
    border: 0;
    border-radius: 0;
  }

  .app[data-stage="4"] .map-panel .map-legend {
    top: auto;
    bottom: 7.2rem;
    display: flex !important;
  }

  .app[data-stage="4"] .map-panel #mapNav:not([hidden]) {
    display: flex !important;
  }



  .app[data-stage="4"] .controls {
    display: none;
  }

  .controls {
    order: 2;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 0;
    overflow: hidden;
    gap: 0;
  }

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

  .stage-panel.is-active {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
  }

  .stage-panel .card {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0.8rem 0.9rem calc(0.9rem + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 0;
    box-shadow: none;
  }

  .stage-panel .card-head {
    position: sticky;
    top: 0;
    z-index: 3;
    align-items: flex-start;
    padding-bottom: 0.4rem;
    background: var(--surface);
  }

  .stage-panel .card-head h2 {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .stage-panel .card-head .status {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.72rem;
    line-height: 1.35;
  }

  .stage-panel .dropzone {
    flex: 1 1 auto;
    min-height: 180px;
  }

  .stage-panel .preview img {
    max-height: 220px;
  }

  .stage-panel .field {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }

  .stage-panel .field select {
    min-height: 36px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
  }

  .stage-panel .field.projection-field {
    flex-direction: column;
    align-items: stretch;
  }

  .stage-panel .segmented-wrap {
    flex: 1 1 auto;
    min-width: 0;
  }

  .stage-panel .centroid-box {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin-top: 0.55rem;
    padding: 0.45rem 0.55rem;
  }

  .stage-panel .centroid-title {
    display: none;
  }

  .stage-panel .centroid-value {
    font-size: 0.85rem;
    line-height: 1.35;
  }

  .stage-panel .centroid-value.is-empty {
    display: none;
  }

  .stage-panel .centroid-status {
    font-size: 0.7rem;
    line-height: 1.3;
  }

  .stage-panel[data-stage="3"] .results {
    flex: 1 1 auto;
    min-height: 0;
    align-items: flex-start;
  }

  .stage-panel .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem 0.6rem;
  }

  .stage-panel .result-card {
    gap: 0.45rem;
    padding: 0.7rem;
  }

  .stage-panel[data-stage="3"] .result-empty {
    display: flex;
    flex: 0 0 100%;
    flex-direction: column;
    justify-content: center;
    min-height: 100%;
  }

  .stage-panel .hint {
    margin-top: 0.5rem;
    font-size: 0.74rem;
    line-height: 1.4;
  }

  .stage-panel .button-row {
    margin-top: 0.55rem;
  }

  #areaHint {
    display: none;
  }

  /* Corner table becomes a compact card list */
  .button-row.table-actions {
    display: none;
  }

  .coord-tools {
    display: flex;
    gap: 0.45rem;
    margin-top: 0.4rem;
  }

  .coord-tools .btn {
    flex: 1;
    min-height: 34px;
  }

  .stage-panel[data-stage="2"] .details {
    display: none;
  }

  .table-wrap {
    margin-top: 0.45rem;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .coord-table {
    display: block;
    font-size: inherit;
  }

  .coord-table thead {
    display: none;
  }

  .coord-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .coord-table tr {
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr) minmax(0, 1fr) 2rem;
    align-items: end;
    gap: 0.35rem;
    padding: 0.28rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
  }

  .coord-table tr.page-hidden {
    display: none;
  }

  .coord-table th,
  .coord-table td {
    padding: 0;
    border: 0;
    white-space: normal;
  }

  .coord-table td {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    min-width: 0;
  }

  .coord-table td:first-child {
    grid-column: 1;
    align-self: center;
    width: auto;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
  }

  .coord-table td:nth-child(2)::before,
  .coord-table td:nth-child(3)::before {
    color: #94a3b8;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .coord-table td:nth-child(2)::before {
    content: "Easting";
  }

  .coord-table td:nth-child(3)::before {
    content: "Northing";
  }

  .coord-table td:last-child {
    grid-column: 4;
    align-self: center;
    width: auto;
  }

  .coord-table input {
    width: 100%;
    min-width: 0;
    min-height: 26px;
    padding: 0.1rem 0.25rem;
    border: 0;
    border-radius: 4px;
    background: transparent;
    font-size: 0.86rem;
    font-weight: 700;
  }

  .coord-table input.input-error {
    background: var(--red-soft);
  }

  .coord-pager:not([hidden]) {
    display: flex;
  }

  .coord-pager {
    margin-top: 0.35rem;
  }

  .coord-pager .icon-btn {
    width: 32px;
    height: 26px;
  }

  .coord-pager-label {
    font-size: 0.72rem;
  }

  /* Candidate results become a horizontal carousel */
  .results {
    position: relative;
    display: flex;
    gap: 0.65rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding: 0.1rem 0 0.25rem;
  }

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

  .results .result-card {
    flex: 0 0 88%;
    scroll-snap-align: center;
  }

  .results .result-empty {
    flex: 0 0 100%;
  }

  .results-dots:not([hidden]) {
    display: flex;
  }

  .app[data-stage="4"] .map-expand-btn {
    bottom: calc(0.6rem + env(safe-area-inset-bottom));
  }
}

/* ── Desktop concept B: full-width photo, inspector below ── */

@media (min-width: 900px) {
  .app {
    grid-template-columns: clamp(430px, 42vw, 580px) minmax(0, 1fr);
  }

  .upload-card .dropzone {
    min-height: 330px;
    gap: 0.3rem;
  }

  .upload-card .card-head {
    align-items: flex-start;
  }

  .upload-card .card-head .status {
    flex: 0 1 auto;
    max-width: 62%;
    line-height: 1.35;
  }

  .upload-card .drop-icon {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    margin-bottom: 0.35rem;
    border-radius: 15px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 1.4rem;
  }

  .upload-card .dropzone strong {
    font-size: 1.1rem;
  }

  .upload-card .dz-cta {
    display: inline-flex;
  }

  .upload-card .dz-micro {
    display: block;
  }

  .upload-card .preview {
    margin-top: 0;
    padding: 10px;
    border-color: #1b232d;
    border-radius: 14px;
    background:
      radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.06), transparent 24rem),
      #1b232d;
  }

  .upload-card .preview img {
    max-height: 340px;
    border-radius: 10px;
    background: transparent;
  }

  .upload-card .preview-badge:not([hidden]) {
    display: inline-flex;
  }

  .upload-card .upload-legacy,
  .upload-card > #ocrProgress {
    display: none;
  }

  .upload-band {
    display: block;
  }
}

@media (min-width: 900px) and (max-width: 1099px) {
  .upload-card .band-checks {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* The empty upload card fills the rail; the drop target absorbs the surplus. */
@media (min-width: 900px) {
  .controls .stage-panel > .upload-card.is-empty {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
  }

  .upload-card.is-empty #dropZone {
    flex: 1 1 auto;
  }
}

/* ── Mobile upload card mirrors the desktop composition ── */

@media (max-width: 899px) {
  .upload-card .drop-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin-bottom: 0.15rem;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 1.3rem;
  }

  .upload-card .dropzone {
    flex: 1 1 auto;
    min-height: 230px;
    max-height: 320px;
    gap: 0.25rem;
  }

  .upload-card .dropzone strong {
    font-size: 1.05rem;
  }

  .upload-card .dz-cta {
    display: inline-flex;
  }

  .upload-card .dz-micro {
    display: block;
  }

  .upload-card .upload-guide {
    display: block;
    flex: 0 0 auto;
    margin-top: 12px;
    padding: 11px 12px;
  }

  .upload-card .band-head {
    margin-bottom: 2px;
  }

  .upload-card .band-checks {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .upload-card .band-checks li {
    align-items: flex-start;
  }

  .upload-card .band-hint {
    display: block;
  }
}
