.map-dataset-page {
  height: 100%;
  overflow: auto;
  padding: 28px;
  color: #e5edf7;
  background:
    radial-gradient(circle at 85% 5%, rgba(14, 165, 233, .12), transparent 34%),
    linear-gradient(180deg, #0b1220 0%, #080e18 100%);
}

.map-dataset-page [hidden],
.map-dataset-modal [hidden],
#map-dataset-preview-map[hidden],
#map-dataset-preview-image[hidden],
#map-dataset-preview-empty[hidden] {
  display: none !important;
}

.map-dataset-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

#tab-live .live-map-layer-button[data-live-map-layer="private"]:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.map-dataset-header,
.map-dataset-section-title,
.map-dataset-header-actions,
.map-dataset-upload-form,
.map-dataset-upload-progress > div,
.map-dataset-modal-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.map-dataset-header {
  max-width: 1440px;
  margin: 0 auto 20px;
}

.map-dataset-header h2,
.map-dataset-section-title h3,
.map-dataset-modal-card h3 {
  margin: 0;
  color: #f8fafc;
}

.map-dataset-header h2 {
  margin-top: 4px;
  font-size: 26px;
}

.map-dataset-header p,
.map-dataset-section-title p,
.map-dataset-modal-card header p {
  margin: 7px 0 0;
  color: #8da0b7;
  line-height: 1.6;
}

.map-dataset-header code {
  color: #7dd3fc;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.map-dataset-eyebrow {
  color: #38bdf8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
}

.map-dataset-header-actions {
  flex: none;
}

.map-dataset-header-actions > span {
  color: #70839b;
  font-size: 12px;
}

.map-dataset-upload-card,
.map-dataset-list-card {
  max-width: 1440px;
  margin: 0 auto 20px;
  padding: 22px;
  border: 1px solid rgba(71, 98, 130, .48);
  border-radius: 14px;
  background: rgba(13, 23, 38, .92);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .2);
}

.map-dataset-section-title {
  margin-bottom: 18px;
}

.map-dataset-section-title h3 {
  font-size: 17px;
}

.map-dataset-section-title p {
  font-size: 12px;
}

.map-dataset-format-chip {
  flex: none;
  padding: 6px 10px;
  border: 1px solid rgba(56, 189, 248, .35);
  border-radius: 999px;
  color: #7dd3fc;
  background: rgba(14, 165, 233, .08);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.map-dataset-upload-form {
  align-items: stretch;
}

.map-dataset-name-field {
  width: min(320px, 30%);
  color: #9fb0c5;
  font-size: 12px;
}

.map-dataset-name-field input {
  width: 100%;
  height: 46px;
  margin-top: 7px;
  padding: 0 13px;
  border: 1px solid #30445d;
  border-radius: 8px;
  outline: none;
  color: #f8fafc;
  background: #09111e;
}

.map-dataset-name-field input:focus,
.map-dataset-file-field:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .12);
}

.map-dataset-file-field {
  display: flex;
  flex: 1;
  min-width: 280px;
  flex-direction: column;
  justify-content: center;
  padding: 10px 15px;
  border: 1px dashed #3e5f7d;
  border-radius: 9px;
  cursor: pointer;
  background: rgba(7, 18, 31, .7);
  transition: border-color .18s, background .18s;
}

.map-dataset-file-field:hover,
.map-dataset-file-field.dragging {
  border-color: #38bdf8;
  background: rgba(14, 165, 233, .08);
}

.map-dataset-file-field[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .58;
}

.map-dataset-file-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.map-dataset-file-field strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #dce9f7;
  font-size: 13px;
}

.map-dataset-file-field span {
  margin-top: 4px;
  color: #70839b;
  font-size: 11px;
}

.map-dataset-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #36506b;
  border-radius: 7px;
  color: #c8d6e5;
  background: #152237;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.map-dataset-button:hover:not(:disabled):not([aria-disabled="true"]) {
  border-color: #4f7599;
  background: #1b2d46;
}

.map-dataset-button.primary {
  border-color: #0284c7;
  color: #fff;
  background: #0369a1;
}

.map-dataset-button.danger {
  border-color: rgba(248, 113, 113, .48);
  color: #fca5a5;
  background: rgba(127, 29, 29, .22);
}

.map-dataset-button:disabled,
.map-dataset-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .5;
}

.map-dataset-button:focus-visible,
.map-dataset-table-wrap:focus-visible,
.map-dataset-name-field input:focus-visible,
.map-dataset-file-field:focus-within {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.map-dataset-upload-actions {
  display: flex;
  align-self: flex-end;
  flex: none;
  gap: 8px;
}

.map-dataset-upload-actions .map-dataset-button {
  align-self: flex-end;
  min-height: 46px;
}

.map-dataset-upload-progress {
  margin-top: 15px;
  color: #b9c7d7;
  font-size: 12px;
}

.map-dataset-upload-progress progress,
.map-dataset-row-progress progress {
  width: 100%;
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #162438;
}

.map-dataset-upload-progress progress::-webkit-progress-bar,
.map-dataset-row-progress progress::-webkit-progress-bar { background: #162438; }
.map-dataset-upload-progress progress::-webkit-progress-value,
.map-dataset-row-progress progress::-webkit-progress-value { background: linear-gradient(90deg, #0284c7, #38bdf8); }
.map-dataset-upload-progress progress::-moz-progress-bar,
.map-dataset-row-progress progress::-moz-progress-bar { background: linear-gradient(90deg, #0284c7, #38bdf8); }

.map-dataset-inline-state {
  min-height: 18px;
  margin: 10px 0 0;
  color: #7f93aa;
  font-size: 12px;
}

.map-dataset-inline-state.error { color: #fca5a5; }
.map-dataset-inline-state.success { color: #86efac; }

.map-dataset-composition-state {
  min-height: 18px;
  margin: -5px 0 14px;
  padding: 9px 11px;
  border: 1px solid rgba(56, 189, 248, .18);
  border-radius: 7px;
  color: #9fb5cc;
  background: rgba(14, 165, 233, .055);
  font-size: 11px;
  line-height: 1.55;
}

.map-dataset-composition-state.warning {
  border-color: rgba(251, 191, 36, .24);
  color: #fcd34d;
  background: rgba(146, 64, 14, .12);
}

.map-dataset-layer-stack {
  margin: -2px 0 14px;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, .22);
  border-radius: 9px;
  background: rgba(7, 18, 31, .68);
}

.map-dataset-layer-stack-head,
.map-dataset-list-feedback,
.map-dataset-log-actions,
.map-dataset-elevation-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.map-dataset-layer-stack-head strong { color: #dce9f7; font-size: 12px; }
.map-dataset-layer-stack-head span { flex: 1; color: #7f93aa; font-size: 11px; }
.map-dataset-layer-stack ol {
  display: flex;
  margin: 10px 0 0;
  padding: 0;
  overflow-x: auto;
  gap: 7px;
  list-style: none;
}
.map-dataset-layer-stack li {
  display: inline-flex;
  min-width: 0;
  max-width: 240px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid rgba(71, 98, 130, .48);
  border-radius: 7px;
  gap: 6px;
  background: #0d1726;
}
.map-dataset-layer-stack li > span {
  display: grid;
  width: 20px;
  height: 20px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  color: #dff5ff;
  background: #0369a1;
  font-size: 10px;
}
.map-dataset-layer-stack li strong {
  min-width: 0;
  overflow: hidden;
  color: #cbd9e8;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-dataset-layer-stack li small { color: #7f93aa; }

.map-dataset-list-feedback { align-items: flex-start; }
.map-dataset-list-feedback .map-dataset-inline-state { flex: 1; }
.map-dataset-list-feedback .map-dataset-button { margin-top: 6px; }

.map-dataset-scroll-hint {
  display: none;
  margin: 0 0 8px;
  color: #7f93aa;
  font-size: 11px;
}

.map-dataset-legend {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #72869e;
  font-size: 11px;
}

.map-dataset-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, .75);
}

.map-dataset-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.map-dataset-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.map-dataset-table th {
  padding: 10px 12px;
  border-bottom: 1px solid #2b3d52;
  color: #71849b;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.map-dataset-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(44, 62, 82, .65);
  color: #bbc9d8;
  vertical-align: middle;
}

.map-dataset-table tr:last-child td { border-bottom: 0; }
.map-dataset-table tr.active-map { background: rgba(34, 197, 94, .035); }

.map-dataset-name {
  display: flex;
  min-width: 190px;
  flex-direction: column;
  gap: 4px;
}

.map-dataset-name strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #eef6ff;
  font-size: 13px;
}
.map-dataset-name span,
.map-dataset-spatial span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #71849b;
  font-size: 11px;
}

.map-dataset-name .map-dataset-error {
  max-width: 280px;
  overflow-wrap: anywhere;
  color: #fca5a5;
  line-height: 1.45;
}

.map-dataset-spatial {
  display: flex;
  min-width: 155px;
  flex-direction: column;
  gap: 4px;
}

.map-dataset-elevation-summary {
  display: flex;
  margin-top: 3px;
  padding-top: 7px;
  border-top: 1px solid rgba(71, 98, 130, .34);
  flex-direction: column;
  gap: 4px;
}

.map-dataset-spatial .map-dataset-elevation-state {
  width: fit-content;
  padding: 3px 7px;
  border: 1px solid rgba(100, 116, 139, .42);
  border-radius: 999px;
  color: #a8b5c4;
  background: rgba(51, 65, 85, .28);
  font-size: 10px;
  font-weight: 700;
}

.map-dataset-spatial .map-dataset-elevation-state.ready {
  border-color: rgba(34, 197, 94, .32);
  color: #86efac;
  background: rgba(22, 101, 52, .2);
}

.map-dataset-spatial .map-dataset-elevation-state.processing {
  border-color: rgba(56, 189, 248, .32);
  color: #7dd3fc;
  background: rgba(3, 105, 161, .2);
}

.map-dataset-spatial .map-dataset-elevation-state.cancelled {
  border-color: rgba(251, 191, 36, .34);
  color: #fcd34d;
  background: rgba(120, 53, 15, .2);
}

.map-dataset-spatial .map-dataset-elevation-state.failed {
  border-color: rgba(248, 113, 113, .32);
  color: #fca5a5;
  background: rgba(127, 29, 29, .2);
}

.map-dataset-status {
  display: inline-flex;
  align-items: center;
  min-width: 64px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  color: #b9c7d7;
  background: #243247;
  font-size: 11px;
  font-weight: 700;
}

.map-dataset-status.ready,
.map-dataset-status.active { color: #86efac; background: rgba(22, 101, 52, .3); }
.map-dataset-status.processing,
.map-dataset-status.uploading,
.map-dataset-status.queued { color: #7dd3fc; background: rgba(3, 105, 161, .3); }
.map-dataset-status.failed,
.map-dataset-status.error { color: #fca5a5; background: rgba(127, 29, 29, .3); }
.map-dataset-status.cancelled,
.map-dataset-status.archived { color: #a8b5c4; background: rgba(71, 85, 105, .3); }

.map-dataset-tile-health {
  display: inline-flex;
  margin-left: 6px;
  padding: 4px 7px;
  border: 1px solid rgba(248, 113, 113, .32);
  border-radius: 999px;
  color: #fca5a5;
  background: rgba(127, 29, 29, .2);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.map-dataset-health-reason {
  display: block;
  max-width: 220px;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: #fda4af;
  font-size: 10px;
  line-height: 1.45;
}

.map-dataset-row-progress {
  width: min(180px, 100%);
  margin-top: 6px;
  color: #7f93aa;
  font-size: 10px;
}

.map-dataset-row-progress small {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: #9fb2c8;
  line-height: 1.45;
}

.map-dataset-load-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.map-dataset-load-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
}

.map-dataset-load-state.active { color: #86efac; }
.map-dataset-load-state.active i { background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, .65); }

.map-dataset-actions {
  display: flex;
  min-width: 330px;
  flex-wrap: wrap;
  gap: 7px;
}

.map-dataset-actions .map-dataset-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
}

.map-dataset-opacity-control {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid #36506b;
  border-radius: 7px;
  gap: 6px;
  color: #9fb0c5;
  background: #101d2f;
  font-size: 11px;
  white-space: nowrap;
}
.map-dataset-opacity-control input { width: 74px; accent-color: #38bdf8; }
.map-dataset-opacity-control output { min-width: 30px; color: #dce9f7; text-align: right; }

.map-dataset-empty {
  padding: 38px !important;
  color: #6f8299 !important;
  text-align: center !important;
}

.map-dataset-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 7, 14, .78);
  backdrop-filter: blur(5px);
}

.map-dataset-modal.open { display: flex; }

.map-dataset-modal-card {
  width: min(1100px, 94vw);
  max-height: calc(100vh - 48px);
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #34506b;
  border-radius: 14px;
  background: #0d1726;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .48);
}

.map-dataset-modal-card > header {
  padding: 16px 18px;
  border-bottom: 1px solid #283b51;
  background: #111f31;
}

.map-dataset-modal-card header h3 { font-size: 17px; }
.map-dataset-modal-card header p { font-size: 11px; }

.map-dataset-preview-stage {
  position: relative;
  height: min(68vh, 680px);
  min-height: 260px;
  background: #07101b;
}

#map-dataset-preview-map,
#map-dataset-preview-image {
  width: 100%;
  height: 100%;
}

#map-dataset-preview-image {
  object-fit: contain;
  background: #07101b;
}

#map-dataset-preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #73879e;
}

.map-dataset-log-card { width: min(900px, 94vw); }

.map-dataset-log-actions { flex-wrap: wrap; justify-content: flex-end; }
.map-dataset-log-actions label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #9fb0c5;
  font-size: 11px;
}
.map-dataset-log-status,
.map-dataset-elevation-status {
  min-height: 20px;
  padding: 8px 18px;
  color: #8da0b7;
  background: #0a1422;
  font-size: 11px;
}

#map-dataset-log-content {
  flex: 1;
  max-height: 68vh;
  min-height: 260px;
  margin: 0;
  overflow: auto;
  padding: 18px;
  color: #b9c9d9;
  background: #07101b;
  font: 12px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.map-dataset-elevation-card { width: min(760px, 94vw); }
.map-dataset-elevation-details {
  overflow: auto;
  padding: 18px;
}
.map-dataset-elevation-details dl { margin: 0; }
.map-dataset-elevation-details dl > div {
  display: grid;
  grid-template-columns: minmax(130px, .35fr) minmax(0, 1fr);
  padding: 10px 0;
  border-bottom: 1px solid rgba(44, 62, 82, .65);
  gap: 16px;
}
.map-dataset-elevation-details dt { color: #7f93aa; font-size: 12px; }
.map-dataset-elevation-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #d5e2ef;
  font-size: 12px;
  line-height: 1.55;
}

@media (pointer: coarse) {
  .map-dataset-button,
  .map-dataset-actions .map-dataset-button,
  .map-dataset-opacity-control { min-height: 44px; }
  .map-dataset-opacity-control input { min-height: 32px; }
}

@media (max-width: 980px) {
  .map-dataset-page { padding: 18px; }
  .map-dataset-header,
  .map-dataset-upload-form { align-items: stretch; flex-direction: column; }
  .map-dataset-header-actions { justify-content: flex-start; }
  .map-dataset-name-field { width: 100%; }
  .map-dataset-file-field { min-width: 0; }
  .map-dataset-upload-actions { width: 100%; align-self: stretch; }
  .map-dataset-upload-actions .map-dataset-button { flex: 1; }
  .map-dataset-scroll-hint { display: block; }
}

@media (max-width: 720px) {
  .map-dataset-table-wrap {
    overflow: visible;
    scrollbar-gutter: auto;
  }

  .map-dataset-table,
  .map-dataset-table tbody,
  .map-dataset-table tr,
  .map-dataset-table td {
    display: block;
    width: 100%;
  }

  .map-dataset-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .map-dataset-table tr {
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid rgba(71, 98, 130, .48);
    border-radius: 10px;
    background: rgba(8, 17, 30, .72);
  }

  .map-dataset-table tr.active-map {
    border-color: rgba(34, 197, 94, .34);
    background: rgba(22, 101, 52, .08);
  }

  .map-dataset-table td {
    display: grid;
    grid-template-columns: minmax(76px, .34fr) minmax(0, 1fr);
    gap: 12px;
    padding: 11px 12px;
  }

  .map-dataset-table td::before {
    content: attr(data-label);
    color: #71849b;
    font-size: 11px;
    font-weight: 700;
  }

  .map-dataset-table td.map-dataset-empty {
    display: block;
  }

  .map-dataset-table td.map-dataset-empty::before { content: none; }
  .map-dataset-name,
  .map-dataset-spatial,
  .map-dataset-actions { min-width: 0; }
  .map-dataset-button { min-height: 44px; }
  .map-dataset-actions .map-dataset-button {
    flex: 1 1 calc(50% - 7px);
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  .map-dataset-page { padding: 12px; }
  .map-dataset-upload-card,
  .map-dataset-list-card { padding: 16px; }
  .map-dataset-section-title { align-items: flex-start; flex-direction: column; }
  .map-dataset-layer-stack-head { align-items: flex-start; flex-wrap: wrap; }
  .map-dataset-layer-stack-head span { flex-basis: 100%; }
  .map-dataset-modal { padding: 8px; }
  .map-dataset-modal-card { width: 100%; max-height: calc(100vh - 16px); }
  .map-dataset-modal-card > header { align-items: flex-start; flex-wrap: wrap; gap: 10px; }
  .map-dataset-preview-stage { height: 62vh; min-height: 220px; }
  #map-dataset-log-content { min-height: 220px; }
  .map-dataset-elevation-details dl > div { grid-template-columns: 1fr; gap: 5px; }
}

@media (max-width: 360px) {
  .map-dataset-page { padding: 8px; }
  .map-dataset-upload-card,
  .map-dataset-list-card { padding: 10px; border-radius: 10px; }
  .map-dataset-header h2 { font-size: 20px; }
  .map-dataset-table td { grid-template-columns: 62px minmax(0, 1fr); gap: 7px; padding: 9px 8px; }
  .map-dataset-actions { flex-direction: column; }
  .map-dataset-actions .map-dataset-button { width: 100%; flex-basis: auto; }
  .map-dataset-upload-actions { align-items: stretch; flex-direction: column; }
  .map-dataset-upload-actions .map-dataset-button { width: 100%; }
}
