:root {
  color-scheme: light;
  --blue: #0b5f8a;
  --blue-dark: #063f5f;
  --panel-head: #e8edf1;
  --panel-bg: #ffffff;
  --panel-line: #b8c4cc;
  --tree-line: #dbe3e8;
  --text: #111820;
  --muted: #5f6b75;
  --danger: #b42318;
  --ok: #0f7a36;
  --active: #e8f4ff;
  --shadow: 0 2px 10px rgba(0,0,0,.20);
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: #fff;
  overflow: hidden;
  font-size: 12px;
}

#app { position: relative; height: 100%; width: 100%; }
#map { position: absolute; inset: 0; z-index: 1; background: #fff; }
.leaflet-container { cursor: default; }
.leaflet-container.identify-active { cursor: crosshair; }

button, input, summary { font-family: inherit; }
button { cursor: pointer; }

.top-toolbar {
  position: absolute;
  top: 9px;
  left: 8px;
  z-index: 900;
  display: flex;
  align-items: center;
  height: 35px;
  padding: 2px;
  background: rgba(255,255,255,.96);
  border: 1px solid #a9b7c0;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.top-tool {
  width: 32px;
  height: 30px;
  min-width: 32px;
  padding: 0;
  border: 0;
  border-right: 1px solid #d0d8de;
  border-radius: 0;
  background: transparent;
  color: #24313b;
  font-size: 17px;
  font-weight: 700;
  line-height: 30px;
  text-align: center;
}
.top-tool:last-child { border-right: 0; }
.top-tool:hover,
.top-tool.active { background: var(--blue); color: #fff; }
.top-tool.disabled { opacity: .38; cursor: default; }
.emblem-btn {
  background: #f7f9fa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.emblem-btn img { width: 24px; height: 24px; display: block; }

.territory-search {
  height: 30px;
  min-width: 335px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px 28px;
  align-items: center;
  gap: 0;
  margin-left: 5px;
  border-left: 1px solid #d0d8de;
}
.territory-search input {
  height: 25px;
  margin-left: 7px;
  border: 1px solid #b7c2ca;
  border-radius: 0;
  padding: 3px 7px;
  font-size: 12px;
}
.search-small {
  width: 28px;
  height: 28px;
  border: 0;
  border-left: 1px solid #d0d8de;
  background: transparent;
  font-size: 15px;
  color: #2b3943;
}
.search-small:hover { background: #e6eef3; }
.login-btn {
  height: 30px;
  min-width: 82px;
  border: 0;
  border-left: 1px solid #d0d8de;
  background: transparent;
  color: #4d5961;
  font-size: 12px;
}
.login-btn:hover { background: #e6eef3; }

/* Desktop: compact toolbar at its natural width.
   If the viewport becomes narrow, toolbar-overflow.js moves secondary tools
   behind the small arrow instead of stretching the bar across the screen. */
@media (min-width: 701px) {
  .top-toolbar {
    right: auto;
    width: max-content;
    max-width: calc(100vw - 16px);
    min-width: 0;
    overflow: visible;
  }

  .top-toolbar > .top-tool {
    flex: 0 0 32px;
  }

  .territory-search {
    flex: 0 1 335px;
    width: 335px;
    min-width: 190px;
    max-width: 335px;
  }

  #activeProjectIndicator.project-indicator {
    flex: 0 1 250px;
    width: 250px;
    min-width: 115px;
    max-width: 250px;
  }

  .login-btn {
    flex: 0 1 auto;
    min-width: 82px;
    max-width: 150px;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .toolbar-overflow-hidden { display: none !important; }

  .toolbar-overflow-toggle {
    display: inline-block;
    width: 30px;
    min-width: 30px;
    font-size: 15px;
  }
  .toolbar-overflow-toggle[hidden] { display: none !important; }

  .toolbar-overflow-menu {
    position: fixed;
    z-index: 4900;
    width: 188px;
    padding: 4px;
    background: rgba(255,255,255,.98);
    border: 1px solid #a9b7c0;
    box-shadow: var(--shadow);
  }
  .toolbar-overflow-menu[hidden] { display: none !important; }
  .toolbar-overflow-item {
    width: 100%;
    min-height: 32px;
    display: grid;
    grid-template-columns: 30px minmax(0,1fr);
    align-items: center;
    gap: 5px;
    padding: 2px 6px;
    border: 0;
    border-bottom: 1px solid #e0e6ea;
    background: #fff;
    color: #24313b;
    text-align: left;
    font-size: 11px;
  }
  .toolbar-overflow-item:last-child { border-bottom: 0; }
  .toolbar-overflow-item:hover:not(:disabled) { background: #e6eef3; }
  .toolbar-overflow-item:disabled { opacity: .38; cursor: default; }
  .toolbar-overflow-icon {
    font-size: 17px;
    font-weight: 700;
    text-align: center;
  }
  .toolbar-overflow-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .territory-search {
    width: 245px;
    min-width: 165px;
    max-width: 245px;
  }

  #activeProjectIndicator.project-indicator {
    width: 190px;
    min-width: 105px;
    max-width: 190px;
  }

  .login-btn { max-width: 120px; }
}

@media (min-width: 701px) and (max-width: 900px) {
  .territory-search {
    width: 195px;
    min-width: 145px;
    max-width: 195px;
  }

  #activeProjectIndicator.project-indicator {
    width: 145px;
    min-width: 95px;
    max-width: 145px;
    padding-left: 6px;
    padding-right: 6px;
  }

  .login-btn {
    min-width: 70px;
    max-width: 100px;
    padding-left: 5px;
    padding-right: 5px;
  }
}

.left-dock {
  position: absolute;
  top: 51px;
  left: 8px;
  z-index: 910;
  width: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,.96);
  border: 1px solid #a9b7c0;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.dock-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-bottom: 1px solid #d0d8de;
  border-radius: 0;
  background: transparent;
  color: #25323b;
  font-size: 19px;
  font-weight: 700;
  line-height: 36px;
  text-align: center;
}
.dock-btn:hover,
.dock-btn.active { background: var(--blue); color: #fff; }
.dock-dot {
  width: 12px;
  height: 12px;
  margin: 8px 0;
  border-radius: 50%;
  background: #1287bf;
}

.floating-panel {
  position: absolute;
  z-index: 850;
  display: none;
  background: var(--panel-bg);
  border: 1px solid #a9b7c0;
  box-shadow: var(--shadow);
  border-radius: 0;
  pointer-events: auto;
}
.floating-panel.visible { display: block; }

.layer-window {
  top: 72px;
  left: 50px;
  width: 430px;
  max-width: calc(100vw - 64px);
  height: calc(100vh - 94px);
  overflow: hidden;
}
.search-window {
  top: 70px;
  left: 52px;
  width: 760px;
  max-width: calc(100vw - 72px);
  min-height: 305px;
}
.basemap-window,
.mini-window,
.legend-window {
  top: 70px;
  left: 52px;
  width: 390px;
  max-width: calc(100vw - 72px);
}
.legend-window { max-height: calc(100vh - 98px); overflow: hidden; }
.identify-window {
  top: 70px;
  left: 52px;
  width: 460px;
  max-width: calc(100vw - 72px);
  max-height: calc(100vh - 98px);
  overflow: hidden;
}
.basemap-window {
  top: 70px;
  left: 52px;
  width: 430px;
  max-width: calc(100vw - 72px);
  max-height: calc(100vh - 98px);
  overflow: hidden;
}
.print-window {
  top: 70px;
  right: 24px;
  left: auto;
  width: 440px;
  max-width: calc(100vw - 72px);
  max-height: calc(100vh - 98px);
  overflow-y: auto;
}
#printPanel > .panel-titlebar { position: sticky; top: 0; z-index: 2; height: auto; min-height: 52px; flex-shrink: 0; }
#printCollapse { margin-left: auto; min-height: 44px; padding: 5px 9px; border: 1px solid #9dafba; background: #eef3f5; color: #29404e; font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; }
body #printPanel.print-collapsed > :not(.panel-titlebar) { display: none !important; }
body #printPanel.print-collapsed {
  top: auto !important; bottom: calc(30px + env(safe-area-inset-bottom, 0px)) !important;
  left: auto !important; right: 8px !important; width: auto !important;
  max-width: calc(100vw - 64px) !important; height: auto !important; max-height: none !important;
  overflow: visible !important;
}
#printPanel.print-collapsed .panel-titlebar { gap: 8px; }
#printPanel.print-collapsed .window-close { min-width: 36px; min-height: 44px; }
.print-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--panel-line);
  background: #f8fafb;
}
.print-tab {
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  border-right: 1px solid var(--panel-line);
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #334550;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
}
.print-tab:last-child { border-right: 0; }
.print-tab:hover { background: #edf3f6; }
.print-tab.active {
  border-bottom-color: var(--blue);
  background: #fff;
  color: var(--blue-dark);
}
.print-pane { display: none; padding: 10px; background: #fff; }
.print-pane.active { display: block; }
.print-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}
.print-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  color: #334550;
  font-size: 11px;
  font-weight: 700;
}
.print-field-wide { grid-column: 1 / -1; }
.print-field input,
.print-field select {
  width: 100%;
  height: 29px;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid #b8c4cc;
  border-radius: 0;
  background: #fff;
  color: #17252e;
  font: inherit;
  font-size: 12px;
  font-weight: 400;
}
.print-field input:focus,
.print-field select:focus {
  outline: 2px solid rgba(11,95,138,.18);
  border-color: var(--blue);
}
.print-check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 27px;
  color: #334550;
  font-size: 11.5px;
}
.print-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.print-actions button {
  min-height: 31px;
  padding: 5px 11px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 700;
}
.print-secondary {
  border: 1px solid #9dafba;
  background: #eef3f5;
  color: #29404e;
}
.print-secondary:hover { background: #dfe8ed; }
.print-primary {
  border: 1px solid var(--blue-dark);
  background: var(--blue);
  color: #fff;
}
.print-primary:hover { background: var(--blue-dark); }
.print-actions button:disabled { opacity: .55; cursor: wait; }
.report-actions { flex-wrap: wrap; }
.report-frame-list {
  margin-top: 10px;
  max-height: 152px;
  overflow-y: auto;
  border: 1px solid var(--panel-line);
  background: #f7f9fa;
  color: #52616b;
  font-size: 11px;
}
.report-frame-row {
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--panel-line);
  background: #fff;
}
.report-frame-row:last-child { border-bottom: 0; }
.report-frame-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 21px;
  border: 1px solid #9f1b2c;
  background: #b01e2f;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.report-frame-name { overflow: hidden; color: #263a46; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.report-frame-action {
  min-height: 24px;
  padding: 2px 6px;
  border: 1px solid #aab8c1;
  background: #eef3f5;
  color: #29404e;
  font-size: 10px;
  font-weight: 700;
}
.report-frame-action.remove { color: #9f1b2c; font-size: 15px; line-height: 16px; }
.print-note,
.print-frame-help,
.print-frame-summary,
.print-status {
  padding: 7px 10px;
  border-top: 1px solid var(--panel-line);
  color: #52616b;
  font-size: 11px;
  line-height: 1.35;
}
.print-note {
  margin: -10px -10px 10px;
  border-top: 0;
  border-bottom: 1px solid var(--panel-line);
  background: #f4f7f9;
}
.print-frame-help { background: #f4f7f9; }
.print-frame-summary { background: #fff; color: #263a46; }
.print-status { display: none; font-weight: 700; }
.print-status.visible { display: block; }
.print-status.ok { color: var(--ok); background: #eef9f1; }
.print-status.err { color: var(--danger); background: #fff2f1; }
.print-status.busy { color: var(--blue-dark); background: #edf6fb; }
.print-handle-icon {
  position: relative;
  display: block;
  width: 15px;
  height: 15px;
  border: 2px solid #fff;
  background: var(--blue);
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
  cursor: nwse-resize;
}
.print-handle-icon.move {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--blue);
  color: var(--blue-dark);
  cursor: move;
}
.print-handle-icon.move::before,
.print-handle-icon.move::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 10px;
  height: 1px;
  background: var(--blue-dark);
}
.print-handle-icon.move::after {
  left: 10px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  height: auto;
}
.report-corner-icon {
  display: block;
  width: 13px;
  height: 13px;
  border: 2px solid #fff;
  background: #b01e2f;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
  cursor: nwse-resize;
}
.report-frame-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 26px;
  border: 2px solid #b01e2f;
  border-radius: 3px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 1px 5px rgba(0,0,0,.4);
  color: #b01e2f;
  cursor: move;
  font-size: 11px;
  font-weight: 800;
}
.report-frame-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #b01e2f;
  box-shadow: 0 1px 5px rgba(0,0,0,.45);
  color: #fff;
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
  line-height: 18px;
}
.basemap-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 9px;
  padding: 12px;
  max-height: calc(100vh - 152px);
  overflow-y: auto;
  background: #fff;
}
.basemap-card {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #26343e;
  text-align: center;
}
.basemap-thumbnail {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 2px solid transparent;
  background: #e8edf1;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.basemap-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .15s ease;
}
.basemap-empty-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, transparent calc(50% - 1px), #aeb8bf 50%, transparent calc(50% + 1px)),
    repeating-conic-gradient(#f8fafb 0 25%, #e8edf1 0 50%) 50% / 18px 18px;
}
.basemap-empty-preview span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  border: 1px solid #9aa8b2;
  color: #5b6871;
  font-size: 23px;
  line-height: 1;
}
.basemap-card:hover .basemap-thumbnail {
  border-color: #79add0;
}
.basemap-card:hover .basemap-thumbnail img {
  transform: scale(1.04);
}
.basemap-card.active .basemap-thumbnail {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(11,95,138,.18), 0 1px 5px rgba(0,0,0,.28);
}
.basemap-selected {
  position: absolute;
  top: 4px;
  right: 4px;
  display: none;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 21px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.basemap-card.active .basemap-selected { display: block; }
.basemap-name {
  display: block;
  min-height: 29px;
  padding: 5px 2px 0;
  font-size: 11.5px;
  line-height: 1.15;
}
.basemap-card.active .basemap-name {
  color: var(--blue-dark);
  font-weight: 700;
}

.panel-titlebar {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--panel-line);
  background: var(--panel-head);
}
.panel-titlebar h1 {
  margin: 0;
  flex: 1 1 auto;
  color: #405160;
  font-size: 15px;
  line-height: 1;
  font-weight: 700;
  text-align: center;
}
.window-close {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #3e4b55;
  font-size: 20px;
  font-weight: 700;
  line-height: 22px;
}
.window-close:hover { background: #d2dce3; }
.panel-subtitle {
  padding: 4px 8px;
  min-height: 20px;
  border-bottom: 1px solid var(--panel-line);
  color: var(--muted);
  font-size: 11px;
}
.panel-subtitle.ok { color: var(--ok); }
.panel-subtitle.err { color: var(--danger); }
.panel-tools {
  padding: 7px 8px;
  border-bottom: 1px solid var(--panel-line);
  background: #f8fafb;
}
input[type="text"], input[type="search"] {
  width: 100%;
  height: 25px;
  border: 1px solid #bfc9d0;
  border-radius: 0;
  padding: 3px 7px;
  font: inherit;
  font-size: 12px;
  background: #fff;
}
input[type="checkbox"] {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  accent-color: var(--blue);
}
.filter-row {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-top: 7px;
  color: #344450;
  font-size: 12px;
}

.layer-tree {
  height: calc(100% - 96px);
  overflow: auto;
  background: #fff;
  padding: 0;
}
.group,
.subgroup {
  border: 0;
  border-radius: 0;
  background: transparent;
}
.group > summary,
.subgroup > summary,
.inline-legend > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.group > summary::-webkit-details-marker,
.subgroup > summary::-webkit-details-marker,
.inline-legend > summary::-webkit-details-marker { display: none; }
.group > summary,
.subgroup > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--tree-line);
}
.group > summary::before,
.subgroup > summary::before {
  content: "▸";
  display: inline-block;
  width: 12px;
  color: #263947;
  font-size: 11px;
}
.group[open] > summary::before,
.subgroup[open] > summary::before { content: "▾"; }
.group > summary {
  padding: 6px 8px;
  background: #dfe7ec;
  color: #152b3c;
  font-weight: 700;
  font-size: 13px;
}
.subgroup > summary {
  padding: 5px 8px 5px 21px;
  background: #f3f6f8;
  color: #1f2c35;
  font-weight: 700;
  font-size: 12px;
}
.group-label,
.subgroup-label { flex: 1 1 auto; min-width: 0; }
.group-count { color: #4e5b64; font-weight: 400; font-size: 11px; }

.layer-list { display: flex; flex-direction: column; }
.layer-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 4px;
  padding: 5px 8px 5px 34px;
  border-bottom: 1px solid #eef2f5;
  align-items: start;
  background: #fff;
}
.layer-item:hover { background: #f8fbfd; }
.layer-item.active { background: var(--active); }
.layer-item.error { background: #fff7f7; }
.layer-check { margin-top: 1px; }
.layer-symbol {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 5px;
  vertical-align: -2px;
  border: 1px solid #79b7ec;
  background: #dff1ff;
}
.layer-symbol.grouped { background: repeating-linear-gradient(45deg,#e9f4ff 0,#e9f4ff 3px,#9ccbf0 3px,#9ccbf0 5px); }
.layer-title { color: #111; font-size: 12px; font-weight: 700; line-height: 1.18; }
.layer-meta,
.layer-note,
.layer-actions { display: none !important; }
.layer-error {
  display: none;
  margin-top: 3px;
  color: var(--danger);
  font-size: 10.5px;
  line-height: 1.25;
}
.layer-item.error .layer-error { display: block; }
.inline-legend {
  display: none;
  margin: 5px 0 2px 0;
  border-left: 3px solid #d0dce4;
  padding-left: 6px;
}
.layer-item.active .inline-legend { display: block; }
.inline-legend > summary {
  color: #33444f;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
}
.inline-legend > summary::before { content: "▸ "; }
.inline-legend[open] > summary::before { content: "▾ "; }
.inline-legend img { max-width: 100%; background: #fff; border: 1px solid #e1e7eb; }

.tabbar {
  display: flex;
  gap: 0;
  padding: 0 10px;
  background: #fff;
  border-bottom: 1px solid var(--panel-line);
}
.tab {
  min-width: 95px;
  height: 34px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  padding: 0 12px;
  color: #111;
  font-size: 14px;
}
.tab.active { border-bottom-color: #1688d4; font-weight: 700; }
.tab-content { display: none; padding: 18px 20px; }
.tab-content.active { display: block; }
.tab-content label { display: grid; grid-template-columns: 110px minmax(0,1fr); align-items: center; gap: 10px; margin-bottom: 12px; }
.form-btn {
  height: 34px;
  min-width: 100px;
  border: 0;
  background: #e9eef2;
  color: #1d2e3b;
  font-size: 13px;
  float: right;
}
.form-btn:hover { background: #d7e0e6; }
.placeholder-text { color: var(--muted); }
.panel-content { padding: 10px; line-height: 1.35; max-height: calc(100vh - 126px); overflow: auto; }
.muted-content { color: var(--muted); }

.legend-entry { margin-bottom: 10px; border-bottom: 1px solid #e7edf1; padding-bottom: 8px; }
.legend-entry:last-child { border-bottom: 0; }
.legend-title { font-size: 12px; font-weight: 700; margin-bottom: 5px; }
.legend-entry img { max-width: 100%; border: 1px solid #e1e7eb; background: #fff; }

.identify-content {
  max-height: calc(100vh - 170px);
  padding: 0;
  background: #fff;
}
.identify-message,
.identify-loading {
  padding: 14px;
  color: var(--muted);
  line-height: 1.4;
}
.identify-loading { color: var(--blue-dark); }
.identify-layer {
  border-bottom: 1px solid var(--panel-line);
  padding: 0 10px 10px;
}
.identify-layer:last-child { border-bottom: 0; }
.identify-layer h2 {
  margin: 0 -10px 8px;
  padding: 7px 10px;
  background: #eef3f6;
  color: #203746;
  font-size: 13px;
}
.identify-feature {
  margin-bottom: 6px;
  border: 1px solid #d8e0e5;
}
.identify-feature > summary {
  padding: 6px 8px;
  background: #f8fafb;
  color: #263844;
  font-weight: 700;
}
.identify-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.identify-table th,
.identify-table td {
  border-top: 1px solid #e4eaee;
  padding: 5px 7px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.identify-table th {
  width: 38%;
  background: #fbfcfd;
  color: #41515d;
  font-weight: 700;
}
.identify-empty { padding: 8px; color: var(--muted); }
.identify-errors {
  margin: 8px 10px 10px;
  padding: 8px;
  border-left: 3px solid #d07b00;
  background: #fff8ec;
  color: #784900;
  line-height: 1.35;
}
.identify-footer {
  padding: 6px 10px;
  border-top: 1px solid var(--panel-line);
  background: #f5f7f9;
  color: var(--muted);
}


.north-arrow {
  position: absolute;
  z-index: 500;
  top: 18px;
  right: 18px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,.90);
  box-shadow: 0 1px 9px rgba(0,0,0,.15);
  color: #a3adb5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.scale-box,
.mouse-box,
.date-box {
  position: absolute;
  z-index: 500;
  height: 22px;
  display: flex;
  align-items: center;
  padding: 2px 8px;
  background: rgba(255,255,255,.92);
  border: 1px solid #c7d0d7;
  box-shadow: 0 1px 5px rgba(0,0,0,.15);
  color: #111;
  font-size: 12px;
}
.scale-box { left: 8px; bottom: 8px; min-width: 170px; }
.mouse-box { right: 8px; bottom: 8px; min-width: 220px; justify-content: flex-end; }
.date-box { left: 50%; transform: translateX(-50%); bottom: 8px; min-width: 165px; justify-content: center; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0,0,0,.68);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.modal-overlay.hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.credits-modal {
  width: 520px;
  max-width: calc(100vw - 24px);
  height: 610px;
  max-height: calc(100vh - 24px);
  background: #fff;
  border: 3px solid #003f87;
  box-shadow: 0 14px 50px rgba(0,0,0,.38);
  display: flex;
  flex-direction: column;
}
.credits-titlebar {
  height: 28px;
  background: #00459d;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-weight: 700;
  font-size: 13px;
}
.credits-titlebar button {
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 23px;
  font-weight: 700;
  line-height: 22px;
}
.credits-body {
  flex: 1 1 auto;
  text-align: center;
  padding: 38px 42px;
  font-size: 14px;
}
.credits-logo { width: 105px; height: 105px; object-fit: contain; margin: 0 auto 22px; }
.credits-body h2 { margin: 0; font-size: 26px; line-height: 1.1; }
.credits-version { margin-top: 2px; font-size: 15px; }
.credits-body h3 { margin: 26px 0 28px; font-size: 15px; }
.credits-body p { margin: 20px 0; }
.credits-ok {
  margin-top: 44px;
  width: 110px;
  height: 36px;
  border: 0;
  background: #e9eef2;
  color: #444;
  border-radius: 4px;
  font-size: 14px;
}
.credits-ok:hover { background: #dce5eb; }

@media (max-width: 820px) {
  .territory-search { min-width: 180px; }
  .layer-window,
  .search-window,
  .basemap-window,
  .print-window,
  .mini-window,
  .legend-window,
  .identify-window {
    top: 88px;
    left: 50px;
    width: calc(100vw - 62px);
    max-width: calc(100vw - 62px);
  }
  .print-window { right: auto; }
  .layer-window { height: calc(100vh - 112px); }
  .basemap-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .print-form { grid-template-columns: 1fr; }
  .print-field-wide { grid-column: 1; }
  .date-box { display: none; }
}


/* Search results, measurement and readable in-app help. */
.search-results{margin-top:10px;font-size:12px;max-height:38vh;overflow:auto}.search-result{display:block;width:100%;padding:9px;margin:5px 0;text-align:left;border:1px solid #b8c4cc;background:#fff;color:#16384b;cursor:pointer}.search-result:hover{background:#edf5f8}.search-warning{color:#9c341a}#helpPanel{width:min(540px,calc(100vw - 80px));max-height:calc(100vh - 110px);overflow:auto}#helpPanel h2{font-size:14px;margin:12px 0 4px}#helpPanel p{line-height:1.5}#measurePanel{width:min(390px,calc(100vw - 80px))}.measure-actions{display:flex;gap:5px;flex-wrap:wrap}.measure-actions button{padding:7px;border:1px solid #b8c4cc;background:#edf5f8;cursor:pointer}.measure-actions [aria-pressed="true"]{background:#0b5f8a;color:#fff}#measureResult{display:block;font-weight:bold;padding:8px;background:#edf5f8}


/* One scroll region: its height follows the actual header and filters. */
#layersPanel.visible{display:flex;flex-direction:column;height:calc(100dvh - 94px)}
#layersPanel>.panel-titlebar,#layersPanel>.panel-subtitle,#layersPanel>.panel-tools{flex:0 0 auto}
#layersPanel #layerTree{flex:1 1 auto;min-height:0;height:auto;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch;scrollbar-gutter:stable;padding-bottom:12px}
@media(max-width:700px){#layersPanel.visible{height:calc(100dvh - 112px)}}


/* Mobile landscape: use the real iOS/Android visual viewport and keep the map usable. */
html, body, #app {
  min-height: var(--app-viewport-height, 100%);
}
#app {
  height: var(--app-viewport-height, 100%);
}

@supports (height: 100dvh) {
  html, body, #app {
    min-height: var(--app-viewport-height, 100dvh);
    height: var(--app-viewport-height, 100dvh);
  }
}

@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  html, body, #app {
    width: 100vw !important;
    min-height: var(--app-viewport-height, 100dvh) !important;
    height: var(--app-viewport-height, 100dvh) !important;
    overflow: hidden !important;
  }

  #map {
    inset: 0 !important;
    width: 100vw !important;
    height: var(--app-viewport-height, 100dvh) !important;
  }

  .top-toolbar {
    top: max(3px, env(safe-area-inset-top, 0px)) !important;
    left: max(4px, env(safe-area-inset-left, 0px)) !important;
    right: max(4px, env(safe-area-inset-right, 0px)) !important;
    width: auto !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 1px !important;
    overflow: hidden !important;
  }

  .top-tool {
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    flex-basis: 34px !important;
    font-size: 18px !important;
  }

  .emblem-btn img {
    width: 27px !important;
    height: 27px !important;
  }

  .login-btn {
    width: 48px !important;
    min-width: 48px !important;
    height: 34px !important;
    flex-basis: 48px !important;
  }
  .login-btn::before { line-height: 34px !important; }

  .left-dock {
    top: calc(max(3px, env(safe-area-inset-top, 0px)) + 42px) !important;
    left: max(4px, env(safe-area-inset-left, 0px)) !important;
    width: 38px !important;
    max-height: calc(var(--app-viewport-height, 100dvh) - 48px - env(safe-area-inset-bottom, 0px)) !important;
    overflow-y: auto !important;
  }

  .dock-btn {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    line-height: 36px !important;
    flex-basis: 36px !important;
    font-size: 18px !important;
  }

  #activeProjectIndicator.project-indicator {
    top: calc(max(3px, env(safe-area-inset-top, 0px)) + 42px) !important;
    left: calc(max(4px, env(safe-area-inset-left, 0px)) + 42px) !important;
    right: max(46px, calc(env(safe-area-inset-right, 0px) + 4px)) !important;
    width: auto !important;
    height: 26px !important;
    min-height: 26px !important;
  }

  .north-arrow {
    top: calc(max(3px, env(safe-area-inset-top, 0px)) + 42px) !important;
    right: max(4px, env(safe-area-inset-right, 0px)) !important;
    width: 36px !important;
    height: 36px !important;
    font-size: 20px !important;
  }

  .layer-window,
  .search-window,
  .basemap-window,
  .print-window,
  .mini-window,
  .legend-window,
  .identify-window {
    top: calc(max(3px, env(safe-area-inset-top, 0px)) + 42px) !important;
    bottom: max(4px, env(safe-area-inset-bottom, 0px)) !important;
    left: calc(max(4px, env(safe-area-inset-left, 0px)) + 42px) !important;
    right: max(4px, env(safe-area-inset-right, 0px)) !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
  }

  .layer-window {
    max-width: 430px !important;
    right: auto !important;
    width: min(430px, calc(100vw - 52px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))) !important;
  }

  /* Project tools such as Photos/Terrain become side drawers in landscape,
     leaving at least half of the map visible. */
  .terrain-panel {
    top: calc(max(3px, env(safe-area-inset-top, 0px)) + 42px) !important;
    right: max(4px, env(safe-area-inset-right, 0px)) !important;
    bottom: max(4px, env(safe-area-inset-bottom, 0px)) !important;
    left: auto !important;
    width: min(430px, 48vw) !important;
    max-width: min(430px, 48vw) !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
  }

  .terrain-panel .photo-body,
  .terrain-panel > div:not(header) {
    max-height: calc(var(--app-viewport-height, 100dvh) - 88px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .tracking-bar {
    left: calc(max(4px, env(safe-area-inset-left, 0px)) + 42px) !important;
    right: max(4px, env(safe-area-inset-right, 0px)) !important;
    bottom: max(4px, env(safe-area-inset-bottom, 0px)) !important;
    max-height: 108px !important;
  }

  .scale-box {
    left: max(4px, env(safe-area-inset-left, 0px)) !important;
    bottom: max(4px, env(safe-area-inset-bottom, 0px)) !important;
  }

  .date-box, .mouse-box { display: none !important; }
}
