:root {
  --page-bg: #1b1e23;
  --panel-bg: #272b31;
  --panel-border: #363c45;
  --text-main: #f3f5f7;
  --text-muted: #aeb6c2;
  --brand: #8c0c5f;
  --brand-strong: #b3147f;
  --accent-blue: #49abff;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(140, 12, 95, 0.18), transparent 28%),
    linear-gradient(180deg, #16191d 0%, #1b1e23 100%);
  color: var(--text-main);
  font-family: Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
select,
input {
  font: inherit;
}

.auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.auth-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(39, 43, 49, 0.96);
  box-shadow: var(--shadow);
}

.auth-panel h2 {
  margin-top: 0.2rem;
  font-size: 1.55rem;
  font-weight: 500;
}

.auth-kicker {
  color: #f2a9d7;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.auth-copy,
.auth-status {
  color: var(--text-muted);
  line-height: 1.4;
}

.auth-status--error {
  color: #ffb4b4;
}

.auth-field {
  display: grid;
  gap: 0.35rem;
  color: var(--text-muted);
}

.auth-field input {
  width: 100%;
  min-height: 42px;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text-main);
  background: #1f2329;
}

.auth-panel button,
.account-bar button {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #fff;
  background: var(--brand-strong);
}

.auth-panel button {
  min-height: 42px;
  padding: 0.65rem 0.85rem;
}

.auth-panel button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.account-bar {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0.8rem 1.2rem 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.7rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.account-membership-status {
  color: #f2a9d7;
}

.account-bar button {
  padding: 0.4rem 0.65rem;
}

.dashboard-container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.2rem;
}

.dashboard-header {
  margin-bottom: 1rem;
}

.dashboard-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: #f2a9d7;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dashboard-header h1 {
  font-size: clamp(2rem, 3vw, 2.6rem);
  font-weight: 400;
}

.header-copy {
  margin-top: 0.45rem;
  color: var(--text-muted);
  max-width: 760px;
  line-height: 1.45;
}

.dashboard-logo-wrap {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  min-width: 140px;
}

.dashboard-logo {
  display: block;
  max-width: 150px;
  max-height: 86px;
  margin-top: 6px;
  width: auto;
  height: auto;
  object-fit: contain;
  transform: translate(90px, -70px) scale(2.4);
  transform-origin: top right;
}

.toolbar {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.78rem 0.9rem;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(39, 43, 49, 0.92);
  box-shadow: var(--shadow);
}

.filter-group,
.toolbar-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.55rem;
  align-items: center;
}

.filter-group {
  min-width: 0;
  flex: 1 1 auto;
}

.toolbar-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.filter-group label {
  color: var(--text-muted);
  font-size: 0.95rem;
}

label[for="monthFilter"],
#monthFilter {
  display: none;
}

.kmz-reference-control,
.kmz-threshold-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.kmz-threshold-control {
  flex: 0 0 auto;
}

.kmz-dual-slider {
  position: relative;
  width: clamp(112px, 12vw, 148px);
  height: 24px;
  flex-shrink: 0;
}

.kmz-dual-slider__track {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: #363c45;
  border-radius: 2px;
  pointer-events: none;
}

.kmz-dual-slider input[type="range"] {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 24px;
  outline: none;
  border: none;
}

.kmz-dual-slider input[type="range"]:disabled {
  opacity: 0.45;
}

.kmz-dual-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand-strong);
  cursor: pointer;
  border: 2px solid #272b31;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.kmz-dual-slider input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 4px;
}

.kmz-dual-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand-strong);
  cursor: pointer;
  border: 2px solid #272b31;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.kmz-dual-slider input[type="range"]::-moz-range-track {
  background: transparent;
  height: 4px;
}

.kmz-reference-control output {
  min-width: 158px;
  color: #ffffff;
  font-size: 0.86rem;
  line-height: 1.25;
  white-space: nowrap;
}

.kmz-threshold-control select {
  min-width: 120px;
}

select,
.toolbar button {
  min-height: 42px;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #454c57;
  background: #20242a;
  color: var(--text-main);
}

select:focus,
button:focus,
input:focus {
  outline: none;
  border-color: var(--brand-strong);
  box-shadow: 0 0 0 2px rgba(179, 20, 127, 0.25);
}

.toolbar button,
.btn-generate {
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.toolbar button:hover,
.btn-generate:hover {
  background: var(--brand-strong);
}

.toolbar .secondary-button,
.btn-modal-cancel,
.btn-clear-map {
  background: transparent;
  color: var(--text-main);
  border: 1px solid #4a515c;
}

.toolbar .secondary-button:hover,
.btn-modal-cancel:hover,
.btn-clear-map:hover {
  background: rgba(255, 255, 255, 0.06);
}

.toolbar button.active-toggle {
  background: rgba(140, 12, 95, 0.45);
  border-color: var(--brand);
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.stat-card,
.chart-section,
.map-section,
.bottom-row {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(39, 43, 49, 0.96);
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 50px;
  padding: 0.35rem 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.stat-card h2 {
  font-size: 0.96rem;
  font-weight: 400;
  color: #dbe1e8;
  margin-bottom: 0.18rem;
}

.stat-card p {
  font-size: 1.1rem;
  color: #ffffff;
  line-height: 1.15;
}

.main-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr);
  gap: 1rem;
  align-items: stretch;
}

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

.chart-section,
.map-section,
.bottom-row {
  padding: 1rem;
}

.map-section {
  display: flex;
  flex-direction: column;
}

.section-heading {
  margin-bottom: 0.75rem;
}

.section-heading h3 {
  font-size: 1.15rem;
  font-weight: 400;
  color: #e5e9ef;
}

.section-note,
.map-status,
.modal-helper-copy,
.muted-copy {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Section notes and map status are hidden — info available via tooltips/popups */
.chart-section .section-note,
.map-section .section-note,
.map-status {
  display: none;
}

.chart-container {
  height: 220px;
  position: relative;
}

.chart-container--tall {
  height: 260px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-stat-display {
  font-size: 1.0rem;
  font-weight: 600;
  color: #e5e9ef;
  letter-spacing: 0.01em;
  margin-bottom: 0.2rem;
  min-height: 1.2em;
}

.map-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid #3a414c;
}

.kmz-legend {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  z-index: 2;
  min-width: 136px;
  padding: 0.52rem 0.6rem;
  border: 1px solid rgba(74, 81, 92, 0.92);
  border-radius: 10px;
  background: rgba(27, 30, 35, 0.9);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.kmz-legend-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #f7f9fc;
}

.kmz-legend-subtitle {
  margin-top: 0.08rem;
  margin-bottom: 0.35rem;
  font-size: 0.68rem;
  color: #b9c1cc;
}

.kmz-legend-items {
  display: grid;
  gap: 0.28rem;
}

.kmz-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  color: #e6ebf1;
  line-height: 1.2;
}

.kmz-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.48);
  flex: 0 0 10px;
}

.kmz-swatch-low {
  background: #800000;
}

.kmz-swatch-medium {
  background: #80ff80;
}

.kmz-swatch-high {
  background: #000080;
}

.map-control-stack {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.map-icon-toggle {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(74, 81, 92, 0.92);
  background: rgba(27, 30, 35, 0.88);
  color: var(--text-main);
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.map-icon-toggle:hover {
  background: rgba(39, 43, 49, 0.98);
}

.map-icon-toggle:focus {
  outline: none;
  border-color: var(--brand-strong);
  box-shadow: 0 0 0 2px rgba(179, 20, 127, 0.25);
}

.map-icon-toggle.is-active {
  background: #275f44;
  border-color: #2f7a55;
}

.map-icon-toggle-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

#dashboardMap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-shell .mapboxgl-ctrl-group {
  overflow: hidden;
  border: 1px solid rgba(74, 81, 92, 0.92);
  background: rgba(27, 30, 35, 0.88);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.map-shell .mapboxgl-ctrl-group button {
  filter: invert(1) brightness(1.18);
}

.map-shell .mapboxgl-ctrl-group button + button {
  border-top-color: rgba(255, 255, 255, 0.15);
}

.map-shell .mapboxgl-popup-content {
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(39, 43, 49, 0.96);
  color: var(--text-main);
  box-shadow: var(--shadow);
}

.map-shell .mapboxgl-popup-close-button {
  color: var(--text-muted);
  right: 6px;
  top: 4px;
  font-size: 1.1rem;
  padding: 2px 6px;
}

.map-shell .mapboxgl-popup-close-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.map-shell .mapboxgl-popup-anchor-top .mapboxgl-popup-tip,
.map-shell .mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip,
.map-shell .mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip {
  border-bottom-color: rgba(39, 43, 49, 0.96);
}

.map-shell .mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip,
.map-shell .mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip,
.map-shell .mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip {
  border-top-color: rgba(39, 43, 49, 0.96);
}

.map-shell .mapboxgl-popup-anchor-left .mapboxgl-popup-tip {
  border-right-color: rgba(39, 43, 49, 0.96);
}

.map-shell .mapboxgl-popup-anchor-right .mapboxgl-popup-tip {
  border-left-color: rgba(39, 43, 49, 0.96);
}

.kmz-popup {
  color: var(--text-main);
  min-width: 190px;
  line-height: 1.25;
}

.kmz-popup h4 {
  margin: 0 0 0.4rem;
  color: #e5e9ef;
  font-size: 0.88rem;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.3rem;
}

.kmz-popup dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.6rem;
  margin: 0;
  font-size: 0.78rem;
}

.kmz-popup dt {
  font-weight: 400;
  color: var(--text-muted);
}

.kmz-popup dd {
  margin: 0;
  color: #f3f5f7;
  font-weight: 500;
}

.map-status {
  margin-top: 0.6rem;
  min-height: 1.2rem;
}

.map-status.error {
  color: #ff9999;
}

.bottom-row {
  display: none;
  margin-top: 1rem;
  border-color: rgba(54, 60, 69, 0.6);
  background: rgba(39, 43, 49, 0.68);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.dataset-panel[open] {
  padding-bottom: 0.8rem;
}

.dataset-panel-summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.8rem 1rem;
  cursor: pointer;
  list-style: none;
}

.dataset-panel-summary::-webkit-details-marker {
  display: none;
}

.dataset-panel-summary h3 {
  font-size: 0.98rem;
  font-weight: 400;
}

.dataset-panel-hint {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(75, 83, 96, 0.75);
  color: #bcc4cf;
  font-size: 0.78rem;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.03);
}

.dataset-panel[open] .dataset-panel-hint::after {
  content: "Hide catalog";
}

.dataset-panel[open] .dataset-panel-hint {
  font-size: 0;
}

.dataset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  padding: 0 0.85rem;
}

.dataset-card {
  border: 1px solid rgba(57, 65, 76, 0.72);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(36, 40, 47, 0.72) 0%, rgba(22, 25, 29, 0.72) 100%);
  padding: 0.9rem;
}

.dataset-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 400;
  color: #ffffff;
}

.dataset-card-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.dataset-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid #4b5360;
  background: rgba(255, 255, 255, 0.04);
  color: #d6dbe3;
  font-size: 0.76rem;
}

.dataset-badge.status-loaded {
  border-color: #2d7d57;
  color: #9ce4be;
}

.dataset-badge.status-pending {
  border-color: #78653a;
  color: #f3db9d;
}

.dataset-badge.status-error {
  border-color: #8d4646;
  color: #ffb2b2;
}

.dataset-description {
  margin-bottom: 0.7rem;
  color: var(--text-muted);
  line-height: 1.45;
  font-size: 0.85rem;
}

.dataset-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.84rem;
}

.dataset-card dt {
  color: #e8b7d7;
}

.dataset-card dd {
  margin: 0;
  color: #d3d8df;
}

#rasterCanvasHost {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-panel {
  width: 100%;
  max-width: 980px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #1d2025;
  overflow: hidden;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--panel-border);
}

.modal-footer {
  border-top: 1px solid var(--panel-border);
  border-bottom: none;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 400;
}

.modal-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #c7ced8;
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.modal-cols {
  display: flex;
  gap: 1.25rem;
}

.modal-col-map {
  flex: 0 0 300px;
}

.modal-col-fields {
  flex: 1;
}

.modal-section-title {
  font-size: 0.78rem;
  color: #f1a9d8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0.9rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--panel-border);
}

.map-upload-area {
  position: relative;
  min-height: 220px;
  border: 2px dashed #434b57;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.map-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-placeholder {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
}

#mapPreview {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#photoPreview {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-clear-map {
  display: none;
  margin-top: 0.6rem;
  min-height: 40px;
  cursor: pointer;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
}


.field-group {
  display: flex;
  flex-direction: column;
}

.field-group label {
  margin-bottom: 0.22rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.field-group--full {
  grid-column: 1 / -1;
}

.field-group textarea {
  min-height: 72px;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #454c57;
  background: #23272d;
  color: var(--text-main);
  resize: vertical;
  line-height: 1.45;
}

.field-group input,
.field-group select {
  min-height: 40px;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #454c57;
  background: #23272d;
  color: var(--text-main);
}

.field-readonly {
  opacity: 0.78;
}

.optional-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0.55rem 0 0.25rem;
  text-align: left;
  width: 100%;
}

.optional-toggle:hover {
  color: var(--text-main);
}

#optionalSection {
  padding-top: 0.5rem;
}


.modal-status {
  margin-right: auto;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 1180px) {
  .main-row {
    grid-template-columns: 1fr;
  }

  .map-section {
    min-height: min(72vh, 680px);
  }

  .map-shell {
    height: min(62vh, 560px);
    min-height: 460px;
  }

  .stats-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile-only dashboard layout. Larger desktop and laptop rules remain the baseline. */
@media (max-width: 820px) {
  body {
    overflow-x: hidden;
  }

  .dashboard-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0.85rem;
    overflow: hidden;
  }

  .dashboard-header {
    order: 0;
  }

  .toolbar {
    order: 1;
  }

  .main-row {
    order: 2;
  }

  .stats-bar {
    order: 3;
  }

  .bottom-row {
    order: 4;
  }

  .dashboard-header {
    margin-bottom: 0.75rem;
  }

  .dashboard-header h1 {
    font-size: 1.55rem;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .header-copy {
    font-size: 0.9rem;
    overflow-wrap: anywhere;
  }

  .toolbar,
  .chart-section,
  .map-section,
  .bottom-row {
    border-radius: 10px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .filter-group {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
    gap: 0.5rem;
    align-items: stretch;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    gap: 0.5rem;
    align-items: stretch;
  }

  select,
  .toolbar button {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 42px;
  }

  .kmz-reference-control,
  .kmz-threshold-control {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
    gap: 0.35rem;
  }

  .kmz-dual-slider {
    width: 100%;
  }

  .kmz-reference-control output {
    min-width: 0;
    white-space: normal;
  }

  .kmz-threshold-control select {
    min-width: 0;
  }

  .main-row {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }

  .map-section {
    order: -1;
    min-height: min(74dvh, 640px);
    padding: 0.75rem;
  }

  .map-shell {
    flex: 0 0 auto;
    height: min(62dvh, 540px);
    min-height: min(62dvh, 540px);
    border-radius: 8px;
  }

  #dashboardMap {
    height: 100%;
    min-height: min(62dvh, 540px);
  }

  .kmz-legend {
    top: 0.55rem;
    left: 0.55rem;
    max-width: 148px;
    padding: 0.46rem 0.54rem;
    border-radius: 8px;
  }

  .kmz-legend-title {
    font-size: 0.72rem;
  }

  .kmz-legend-subtitle {
    display: none;
  }

  .kmz-legend-item {
    font-size: 0.73rem;
  }

  .map-control-stack {
    top: 0.55rem;
    right: 0.55rem;
  }

  .map-icon-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
  }

  .chart-section {
    padding: 0.75rem;
  }

  .chart-container {
    height: 210px;
  }

  .dashboard-header-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.55rem;
    width: 100%;
  }

  .dashboard-header-inner > :first-child {
    min-width: 0;
    flex: 1 1 auto;
  }

  .dashboard-logo-wrap {
    justify-content: flex-end;
    align-self: flex-start;
    min-width: 0;
    margin-top: 0;
    flex: 0 0 auto;
  }

  .dashboard-logo {
    max-width: 52px;
    max-height: 52px;
    margin-top: 0;
    transform: translateY(-8px) scale(2);
  }

  .stats-bar {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .stat-card {
    min-height: 48px;
    padding: 0.4rem 0.7rem;
  }

  .section-heading h3 {
    font-size: 1.02rem;
    overflow-wrap: anywhere;
  }

  .section-note,
  .map-status,
  .modal-helper-copy,
  .muted-copy {
    font-size: 0.84rem;
  }

  .mapboxgl-popup {
    max-width: calc(100vw - 28px) !important;
  }

  .mapboxgl-popup-content {
    max-height: 68dvh;
    overflow-y: auto;
  }

  .kmz-popup {
    min-width: 0;
    max-width: calc(100vw - 56px);
  }

  .kmz-popup dl {
    grid-template-columns: 1fr;
    gap: 0.18rem;
  }

  .dataset-panel-summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-cols,
  .fields-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .modal-overlay {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
  }

  .modal-panel {
    max-width: none;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 0.9rem;
  }

  .modal-footer {
    flex-wrap: wrap;
  }

  .modal-status {
    flex: 1 1 100%;
  }

  .btn-modal-cancel,
  .btn-generate {
    flex: 1 1 0;
    min-height: 42px;
  }

  .modal-col-map {
    flex: initial;
  }

  .map-upload-area {
    min-height: 180px;
  }
}

@media print {
  .toolbar,
  .modal-overlay {
    display: none !important;
  }

  body {
    background: #fff;
    color: #111;
  }

  .dashboard-container {
    max-width: none;
    padding: 0;
  }
}
