.dm-overlay {
  position: fixed;
  inset: var(--portal-chrome-h, 94px) 0 0 0;
  background: #e8eef5;
  z-index: 3500;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

.dm-overlay[hidden] {
  display: none !important;
}

.dm-panel {
  width: 100%;
  height: 100%;
  max-height: none;
  overflow: hidden;
  background: #f8fafc;
  border-radius: 0;
  box-shadow: none;
  border: 0;
  border-top: 1px solid #d7e0ea;
  display: flex;
  flex-direction: column;
}

.dm-main {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  align-items: stretch;
}

.dm-tabs {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 10px;
  border-bottom: 0;
  border-right: 1px solid #e2e8f0;
  min-height: 0;
  scrollbar-width: thin;
  background: #fff;
  flex-shrink: 0;
}

.dm-tabs::before {
  content: "Sections";
  display: block;
  padding: 0.15rem 0.65rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.dm-tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 0.65rem 0.75rem 0.65rem 1.35rem;
  cursor: pointer;
  white-space: normal;
  text-align: left;
  min-height: 0;
  line-height: 1.3;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.dm-tab::before {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transform: translateY(-50%);
  background: #cbd5e1;
}

.dm-tab:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.dm-tab.is-active {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
  box-shadow: none;
}

.dm-tab.is-active::before {
  background: #0284c7;
}

.dm-body {
  padding: 18px 20px 24px;
  overflow: auto;
  display: grid;
  gap: 14px;
  flex: 1;
  min-height: 0;
  align-content: start;
  background: #f8fafc;
}

.dm-tab-panel {
  display: grid;
  gap: 12px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

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

.dm-tab-panel label {
  display: grid;
  gap: 4px;
  color: #243447;
  font-size: 13px;
}

.dm-tab-panel input,
.dm-tab-panel select,
.dm-tab-panel textarea {
  border: 1px solid #c8d4e4;
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
}

.dm-note {
  margin: 0;
  color: #4b5563;
  font-size: 12px;
}

.dm-upload-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.dm-upload-row-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dm-upload-row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dm-progress-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 36rem;
}

.dm-progress-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.dm-progress-block[hidden] {
  display: none !important;
}

.dm-progress-block__title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.dm-progress-block__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dm-upload-progress__track {
  flex: 1;
  min-width: 0;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.dm-upload-progress__fill {
  height: 100%;
  width: 0%;
  background: #0284c7;
  border-radius: 4px;
  transition: width 0.12s ease-out;
}

.dm-upload-progress__fill.dm-upload-progress__fill--busy {
  width: 40% !important;
  opacity: 0.55;
  animation: dm-upload-progress-busy 0.95s ease-in-out infinite alternate;
}

@keyframes dm-upload-progress-busy {
  to {
    opacity: 0.95;
  }
}

.dm-upload-progress__label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: #475569;
  min-width: 2.35rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dm-upload-file-id,
.dm-analyze-status {
  margin: 0;
  font-size: 0.82rem;
  color: #0f172a;
  word-break: break-all;
}

.dm-analyze-warnings {
  margin: 0.4rem 0 0;
  padding: 0.45rem 0.65rem 0.45rem 1.35rem;
  list-style: disc;
  color: #8a5a00;
  background: #fff8e8;
  border: 1px solid #e6c96a;
  border-radius: 4px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.dm-analyze-warnings[hidden] {
  display: none !important;
}

.dm-analyze-warnings li + li {
  margin-top: 0.25rem;
}

.dm-upload-file-id[hidden],
.dm-analyze-status[hidden] {
  display: none !important;
}

.dm-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dm-shp-filename {
  color: #4b5563;
  font-size: 0.9rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Import Dataset: shared light-blue button style for all panel actions */
.dm-tab-panel[data-panel="import"] .btn.dm-btn-shp {
  width: auto;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.9rem;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.2;
  cursor: pointer;
  filter: none;
  white-space: nowrap;
  box-sizing: border-box;
  background: #bae6fd;
  color: #0c4a6e;
  border: 1px solid #7dd3fc;
}

.dm-tab-panel[data-panel="import"] .btn.dm-btn-shp:hover {
  filter: none;
  background: #7dd3fc;
  color: #ffffff;
}

.dm-error {
  margin: 0;
  min-height: 1em;
  color: #b91c1c;
  font-size: 13px;
}

.dm-review-output {
  margin: 0;
  background: #0f172a;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  min-height: 120px;
  overflow: auto;
  font-size: 12px;
}

.dm-import-fields-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.dm-import-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.dm-tab-panel[data-panel="import"] .dm-import-actions .btn.dm-btn-shp {
  width: auto;
  margin-top: 0;
}

.dm-publish-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.dm-tab-panel[data-panel="publish"] .dm-publish-actions .btn.dm-btn-shp {
  width: auto;
  margin-top: 0;
}

.dm-import-fields-table {
  width: 100%;
  min-width: 42rem;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.dm-import-select-th,
.dm-import-select-td {
  width: 2.5rem;
  text-align: center;
  vertical-align: middle;
}

.dm-import-select-all-label {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  margin: 0;
  gap: 0;
}

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

.dm-import-schema-th {
  min-width: 12rem;
}

.dm-import-th-label {
  display: block;
  margin-bottom: 0.25rem;
}

.dm-import-default-schema-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.dm-import-default-schema-select {
  flex: 1 1 100%;
  width: 100%;
  min-width: 8rem;
  max-width: 14rem;
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
}

.dm-import-default-schema {
  flex: 1 1 auto;
  width: 100%;
  min-width: 6rem;
  max-width: 11rem;
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
}

.dm-import-default-schema-apply {
  flex: 0 0 auto;
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  line-height: 1.2;
  white-space: nowrap;
}

.dm-import-fields-table th,
.dm-import-fields-table td {
  border: 1px solid #c8d4e4;
  padding: 6px 8px;
  vertical-align: middle;
  text-align: left;
}

.dm-import-fields-table th {
  background: #eef2f7;
  color: #243447;
  font-weight: 600;
}

.dm-import-fields-table td input,
.dm-import-fields-table td select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
}

.dm-publish-fields-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.dm-publish-actions-col {
  width: 4.75rem;
  white-space: nowrap;
  vertical-align: middle;
  text-align: center;
}

.dm-publish-row-acts {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.dm-publish-icon-btn {
  box-sizing: border-box;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dm-publish-icon-btn.dm-publish-remove-row {
  background: #dc2626;
  color: #000;
  border-color: #b91c1c;
}

.dm-publish-icon-btn.dm-publish-add-row {
  background: #16a34a;
  color: #000;
  border-color: #15803d;
}

.dm-publish-icon-btn.dm-publish-add-row[hidden] {
  display: none !important;
}

.dm-publish-fields-table {
  width: 100%;
  min-width: 44rem;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.dm-publish-fields-table th,
.dm-publish-fields-table td {
  border: 1px solid #c8d4e4;
  padding: 6px 8px;
  vertical-align: middle;
  text-align: left;
}

.dm-publish-fields-table th {
  background: #eef2f7;
  color: #243447;
  font-weight: 600;
}

.dm-publish-fields-table td input,
.dm-publish-fields-table td select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
}

.dm-publish-sld-cell {
  vertical-align: middle;
  min-width: 8.5rem;
}

.dm-publish-sld-cell .dm-publish-sld-browse {
  margin-bottom: 4px;
  padding: 4px 8px;
  font-size: 0.85rem;
}

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

.dm-publish-sld-filename {
  display: inline;
  font-size: 0.75rem;
  color: #64748b;
  word-break: break-all;
  max-width: 8rem;
  margin-right: 0.25rem;
}

.dm-publish-sld-clear {
  box-sizing: border-box;
  width: 1.2rem;
  height: 1.2rem;
  padding: 0;
  margin: 0;
  border: 1px solid #94a3b8;
  border-radius: 2px;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}

.dm-publish-sld-clear[hidden] {
  display: none !important;
}

.dm-access-fields-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.dm-access-fields-table {
  width: 100%;
  min-width: 52rem;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.dm-access-fields-table th,
.dm-access-fields-table td {
  border: 1px solid #c8d4e4;
  padding: 6px 8px;
  vertical-align: middle;
  text-align: left;
}

.dm-access-fields-table th {
  background: #eef2f7;
  color: #243447;
  font-weight: 600;
}

.dm-access-fields-table td input,
.dm-access-fields-table td select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
}

.dm-access-fields-table td.dm-checkbox-cell {
  text-align: center;
}

.dm-access-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.dm-tab-panel[data-panel="access"] .dm-access-actions .btn.dm-btn-shp {
  width: auto;
  margin-top: 0;
}

.dm-catalogue-subtitle {
  margin: 12px 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.dm-catalogue-scroll {
  overflow-x: auto;
  max-width: 100%;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

.dm-catalogue-matrix-table {
  width: 100%;
  min-width: 44rem;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: auto;
}

.dm-catalogue-matrix-table th,
.dm-catalogue-matrix-table td {
  border: 1px solid #c8d4e4;
  padding: 6px 8px;
  vertical-align: top;
  text-align: left;
  color: #334155;
}

.dm-catalogue-matrix-table th {
  background: #eef2f7;
  color: #243447;
  font-weight: 600;
}

.dm-catalogue-matrix-table .dm-matrix-loading {
  color: #64748b;
  font-style: italic;
}

.dm-catalogue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.btn.dm-btn-danger.dm-btn-compact {
  background: #b91c1c;
  color: #fff;
  border: none;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.btn.dm-btn-danger.dm-btn-compact:hover {
  background: #991b1b;
}

.dm-tab-panel[data-panel="catalogue"] #dm-catalogue-refresh {
  margin-bottom: 8px;
}

/* Historical layers tab */
.dm-tab-panel[data-panel="historical"]:not([hidden]) {
  display: grid;
  gap: 10px;
}

.dm-hl-title {
  margin: 0 0 4px;
  font-size: 15px;
  color: #0f172a;
}

.dm-hl-step {
  border: 1px solid #c8d4e4;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.dm-hl-step-summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  font-size: 13px;
  color: #0f172a;
  font-weight: 600;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}

.dm-hl-step-summary::-webkit-details-marker {
  display: none;
}

.dm-hl-step-summary::before {
  content: "▾";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.15s ease;
}

.dm-hl-step:not([open]) .dm-hl-step-summary::before {
  transform: rotate(-90deg);
}

.dm-hl-step:not([open]) .dm-hl-step-summary {
  padding: 7px 11px;
  border-bottom: none;
}

.dm-hl-step:not([open]) .dm-hl-step-body {
  display: none !important;
}

.dm-hl-step-body {
  padding: 10px 12px;
  display: grid;
  gap: 10px;
}

.dm-hl-step--disabled .dm-hl-step-summary {
  cursor: not-allowed;
  opacity: 0.65;
}

.dm-hl-step--disabled .dm-hl-step-body {
  opacity: 0.65;
  pointer-events: none;
}

.dm-hl-subsection {
  display: grid;
  gap: 6px;
  padding: 8px 0 0;
  border-top: 1px solid #e5eaf1;
}

.dm-hl-subsection-title {
  margin: 0;
  font-size: 12px;
  color: #334155;
  font-weight: 600;
}

.dm-hl-srid-block label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: #243447;
}

.dm-hl-inline-agree {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
}

.dm-hl-inline-agree input {
  margin-top: 2px;
}

.dm-hl-date-rows {
  display: grid;
  gap: 8px;
}

.dm-hl-date-row {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 160px);
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #243447;
}

.dm-hl-date-row span {
  font-family: ui-monospace, Consolas, monospace;
  color: #1f2937;
}

.dm-hl-select-label {
  display: grid;
  gap: 6px;
  color: #243447;
  font-size: 13px;
}

.dm-hl-table-picker {
  border: 1px solid #c8d4e4;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.dm-hl-table-summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 10px;
  font-size: 12px;
  color: #243447;
  font-weight: 600;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.dm-hl-table-summary::-webkit-details-marker {
  display: none;
}

.dm-hl-table-summary::before {
  content: "▾";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.dm-hl-table-picker:not([open]) .dm-hl-table-summary::before {
  transform: rotate(-90deg);
}

.dm-hl-table-list {
  max-height: 230px;
  overflow: auto;
  padding: 6px 8px;
  display: grid;
  gap: 4px;
}

.dm-hl-table-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}

.dm-hl-table-row input {
  margin: 0;
}

.dm-hl-table-name {
  font-family: ui-monospace, Consolas, monospace;
  color: #1f2937;
}

.dm-hl-table-tag {
  font-size: 11px;
  color: #4b5563;
  background: #e5e7eb;
  border-radius: 999px;
  padding: 1px 7px;
}

.dm-hl-empty {
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
  padding: 4px 2px;
}

.dm-hl-loading {
  font-size: 12px;
  color: #475569;
  font-style: italic;
  padding: 4px 2px;
}

.dm-hl-error {
  font-size: 12px;
  color: #b91c1c;
  padding: 4px 2px;
}

.dm-hl-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dm-hl-report {
  margin: 0;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #1e293b;
  max-height: 140px;
  overflow: auto;
}

.dm-hl-hint {
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.45;
}

.dm-hl-hint--warn {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #78350f;
}

.dm-hl-field-block {
  display: grid;
  gap: 6px;
}

.dm-hl-field-picker {
  border: 1px solid #c8d4e4;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.dm-hl-field-summary-toggle {
  cursor: pointer;
  list-style: none;
  padding: 8px 10px;
  font-size: 12px;
  color: #243447;
  font-weight: 600;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.dm-hl-field-summary-toggle::-webkit-details-marker {
  display: none;
}

.dm-hl-field-summary-toggle::before {
  content: "▾";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.dm-hl-field-picker:not([open]) .dm-hl-field-summary-toggle::before {
  transform: rotate(-90deg);
}

.dm-hl-field-checkboxes {
  max-height: 180px;
  overflow: auto;
  padding: 6px 8px;
  display: grid;
  gap: 4px;
}

.dm-hl-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}

.dm-hl-field-row input {
  margin: 0;
}

.dm-hl-field-summary {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  color: #0f172a;
}

.dm-hl-field-null-note {
  color: #92400e;
}


/* Full-workspace polish */
.dm-tab-panel > .dm-upload-stack,
.dm-tab-panel > .dm-fieldset,
.dm-tab-panel > table,
.dm-tab-panel > .dm-table-wrap,
.dm-tab-panel > section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.dm-tab-panel > .dm-upload-stack,
.dm-tab-panel > .dm-fieldset,
.dm-tab-panel > section {
  padding: 14px 16px;
}

@media (max-width: 820px) {
  .dm-main {
    grid-template-columns: minmax(160px, 180px) minmax(0, 1fr);
  }

  .dm-tab {
    font-size: 0.8rem;
    padding: 0.55rem 0.55rem 0.55rem 1.2rem;
  }
}
