/* gebiedsviewer/css/style.css */

:root {
  --pzh-red: #E3001B;
  --esri-blue: #007ac2;
  --border: #e0e0e0;
  --sidebar-width: 360px;
  --text: #333;
}

* { box-sizing: border-box; }

body {
  margin: 0; padding: 0;
  font-family: 'Avenir Next', 'Segoe UI', Roboto, sans-serif;
  background: #fff;
  height: 100vh;
  display: flex;
  overflow: hidden;
  color: var(--text);
}

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-width);
  background: white;
  border-right: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 2px 0 5px rgba(0,0,0,0.05);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-logo { height: 44px; width: auto; }

.app-title {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  line-height: 1.3;
  cursor: pointer;
}
.app-title:hover {
  color: #007ac2;
}

.app-subtitle {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

.export-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: #f0f7ff;
  border: 1px solid #b3d4f0;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--esri-blue);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.15s;
  white-space: nowrap;
}
.export-btn i { font-size: 13px; }
.export-btn:hover { background: #daeeff; }

/* ── TABS ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 9px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #777;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  flex: 1;
  text-align: center;
  transition: color 0.15s;
}
.tab:hover { color: var(--text); background: #fafafa; }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--pzh-red);
  background: white;
}

/* ── SIDEBAR CONTENT ── */
.sidebar-content { display: none; flex: 1; overflow-y: auto; }
.sidebar-content.active { display: flex; flex-direction: column; }

/* ── SEARCH BAR ── */
.search-bar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fafafa;
  position: relative;
}
.search-bar i { color: #aaa; font-size: 12px; flex-shrink: 0; }
.search-bar input {
  flex: 1;
  border: none;
  background: none;
  font-size: 12px;
  outline: none;
  color: var(--text);
}
#search-clear {
  display: none;
  cursor: pointer;
  color: #aaa;
  font-size: 11px;
}
#search-clear:hover { color: #555; }

/* ── ACTIVE LAYERS PANEL ── */
#active-layers-panel {
  display: none;
  border-bottom: 2px solid var(--border);
  background: #f8fafd;
}
.active-panel-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--esri-blue);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 8px 12px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#active-layers-list { display: flex; flex-direction: column; gap: 0; }

/* Layer cards */
.layer-card {
  border-bottom: 1px solid #e4eef7;
  background: white;
  padding: 6px 10px;
}
.layer-card:hover { background: #f5f9ff; }
.layer-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
}
.layer-card-order {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
}
.lc-btn {
  font-size: 10px;
  color: #999;
  cursor: pointer;
  padding: 1px 3px;
  line-height: 1.2;
  transition: color 0.1s;
}
.lc-btn:hover { color: var(--esri-blue); }
.lc-disabled { color: #ddd !important; cursor: default; pointer-events: none; }
.lc-remove:hover { color: var(--pzh-red) !important; }
.layer-card-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.layer-card-name {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.layer-card-opacity {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding-left: 24px;
}
.opacity-slider {
  flex: 1;
  height: 3px;
  accent-color: var(--esri-blue);
  cursor: pointer;
}
.opacity-val {
  font-size: 10px;
  color: #888;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}
.lc-status { font-size: 10px; flex-shrink: 0; }
.lc-loading-icon { color: var(--esri-blue); }
.lc-error-icon { color: #cc4400; }
.lc-count { color: #888; font-size: 10px; }
.popup-more { font-size: 10px; color: #888; margin: 4px 0 0; font-style: italic; }

/* ── LAYER TREE ── */
#layer-tree { flex: 1; overflow-y: auto; }

.theme-group {
  border-bottom: 1px solid #f0f0f0;
}

.theme-summary {
  list-style: none;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}
.theme-summary:hover { background: #f5f5f5; }
.theme-summary::-webkit-details-marker { display: none; }

.theme-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.theme-label { flex: 1; }

.theme-badge {
  display: none;
  background: var(--esri-blue);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  align-items: center;
  justify-content: center;
}

.toggle-arrow {
  font-size: 9px;
  color: #999;
  width: 10px;
  flex-shrink: 0;
  transition: transform 0.2s;
}
details[open] > summary .toggle-arrow { transform: rotate(90deg); }

/* Service groups */
.service-group {
  border-top: 1px solid #f5f5f5;
}

.service-summary {
  list-style: none;
  padding: 7px 14px 7px 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #555;
  user-select: none;
}
.service-summary:hover { background: #f0f7ff; }
.service-summary::-webkit-details-marker { display: none; }

/* Layers */
.layers-list { padding: 2px 0 6px 0; }

.layer-item {
  padding: 0;
}
.layer-item[style*="display: none"] { display: none !important; }

.layer-row {
  display: flex;
  align-items: stretch;
}

.layer-label {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 6px 5px 44px;
  cursor: pointer;
  font-size: 12px;
  color: #444;
  line-height: 1.3;
  transition: background 0.1s;
}
.layer-label:hover { background: #f0f7ff; }

.layer-meta-link {
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #ccc;
  font-size: 11px;
  text-decoration: none;
  transition: color 0.15s;
  flex-shrink: 0;
}
.layer-meta-link:hover { color: var(--esri-blue); }
.layer-item--active .layer-meta-link { color: #a0c4e8; }
.layer-item--active .layer-meta-link:hover { color: var(--esri-blue); }

.lc-meta { color: #bbb !important; text-decoration: none; }
.lc-meta:hover { color: var(--esri-blue) !important; }

/* ── SUBLAYER TOGGLES (group layers) ── */
.sublayer-list {
  padding: 5px 10px 6px 24px;
  background: #f8fafd;
  border-top: 1px solid #eef2f8;
}
.sublayer-list-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #aaa;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sublayer-count {
  background: #e8e8e8;
  color: #888;
  border-radius: 8px;
  padding: 0 5px;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
}
.sublayer-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #555;
  padding: 2px 0;
  cursor: pointer;
  line-height: 1.3;
}
.sublayer-toggle input[type="checkbox"] {
  accent-color: var(--esri-blue);
  flex-shrink: 0;
  cursor: pointer;
}
.sublayer-geo-icon {
  font-size: 9px;
  color: #aaa;
  width: 10px;
  text-align: center;
  flex-shrink: 0;
}

.layer-checkbox {
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--esri-blue);
  cursor: pointer;
}

.layer-name { flex: 1; }

/* ── LEGEND TAB ── */
#legend-content {
  padding: 12px;
}

.legend-empty {
  color: #888;
  font-size: 12px;
  text-align: center;
  padding: 20px 10px;
  line-height: 1.6;
}

.legend-item {
  margin-bottom: 14px;
  border: 1px solid #eee;
  border-radius: 4px;
  overflow: hidden;
}

.legend-layer-name {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  background: var(--esri-blue);
}

.legend-img {
  display: block;
  max-width: 100%;
  padding: 6px;
  background: white;
}

.legend-body { padding: 6px 10px; background: white; }
.legend-loading { font-size: 11px; color: #aaa; font-style: italic; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #444;
  padding: 3px 0;
}
.legend-row img { flex-shrink: 0; }

/* ── MAP CONTAINER ── */
#map-container {
  flex: 1;
  position: relative;
  background: #e8e8e8;
  overflow: hidden;
}

#deck-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* ── TOOLBAR ── */
.top-toolbar {
  position: absolute;
  top: 12px;
  left: 52px;
  z-index: 10;
  display: flex;
  gap: 6px;
}

.tool-pill {
  background: white;
  border: 1px solid #bbb;
  border-radius: 4px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: background 0.15s;
}
.tool-pill:hover { background: #f0f8ff; color: var(--esri-blue); }

/* ── ADDRESS SEARCH ── */
#address-search-container {
  display: none;
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: 380px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.search-pill-box {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 50px;
  padding: 9px 16px;
  border: 1px solid #ddd;
}
.search-pill-icon { color: var(--esri-blue); margin-right: 10px; font-size: 14px; }
.search-pill-box input { border: none; outline: none; flex: 1; font-size: 13px; font-family: inherit; color: var(--text); }
.search-pill-close { color: #ccc; cursor: pointer; padding: 4px; font-size: 13px; }
.search-pill-close:hover { color: #888; }

#address-results {
  display: none;
  background: white;
  margin-top: 6px;
  border-radius: 10px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #eee;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
#address-results .result-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#address-results .result-item:hover { background: #f0f8ff; }
#address-results .result-item i { font-size: 11px; color: #aaa; flex-shrink: 0; }

/* ── ZOOM CONTROLS ── */
.zoom-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.zoom-btn {
  width: 30px; height: 30px;
  background: white;
  border: 1px solid #bbb;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #444;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: background 0.15s;
}
.zoom-btn:hover { background: #f0f0f0; }
.zoom-btn.active { background: var(--esri-blue); color: white; border-color: var(--esri-blue); }

/* ── POPUP ── */
.info-popup {
  position: absolute;
  z-index: 200;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  width: 320px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--esri-blue);
  color: white;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.popup-close { cursor: pointer; opacity: 0.8; }
.popup-close:hover { opacity: 1; }

.popup-body {
  overflow-y: auto;
  padding: 8px 12px;
  font-size: 12px;
  flex: 1;
}

.popup-layer { margin-bottom: 10px; }
.popup-layer-title {
  font-weight: 700;
  color: white;
  font-size: 10px;
  padding: 3px 8px;
  background: var(--esri-blue);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: -1px -1px 0;
  border-radius: 0;
}
.popup-layer:first-child .popup-layer-title { margin-top: 0; }

.attr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.attr-table tr { border-bottom: 1px solid #f0f0f0; }
.attr-table tr:last-child { border-bottom: none; }
.attr-table th {
  text-align: left;
  padding: 4px 8px 4px 0;
  color: #666;
  font-weight: 600;
  white-space: nowrap;
  width: 40%;
  vertical-align: top;
}
.attr-table td {
  padding: 4px 0;
  color: #222;
  word-break: break-word;
}

.popup-loading { color: #888; font-size: 12px; }
.popup-empty { color: #888; font-size: 12px; font-style: italic; }

/* ── SCALE BAR ── */
.scale-bar {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 10;
  background: rgba(255,255,255,0.85);
  border: 1px solid #999;
  border-top: none;
  height: 6px;
  min-width: 60px;
  font-size: 10px;
  display: flex;
  align-items: flex-end;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  transition: width 0.3s;
}
.scale-text {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-weight: 600;
  color: #222;
}
.scale-tick { position: absolute; bottom: 0; width: 1px; height: 6px; background: #999; }

/* ── COORDS ── */
.coords-widget {
  position: absolute;
  bottom: 0; right: 0;
  z-index: 10;
  background: rgba(255,255,255,0.9);
  padding: 3px 8px;
  border-top-left-radius: 5px;
  font-size: 11px;
  color: #555;
  font-family: monospace;
  border-top: 1px solid #ccc;
  border-left: 1px solid #ccc;
  pointer-events: none;
}

/* ── LOADING ── */
#loading {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 18px 28px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
}

/* ── ACTIVE LAYER HIGHLIGHT IN TREE ── */
.layer-item--active > .layer-row {
  background: #eef5ff;
  border-left: 3px solid var(--esri-blue);
}
.layer-item--active > .layer-row .layer-label { padding-left: 41px; }
.layer-item--active > .layer-row:hover { background: #daeeff; }
.layer-item--active > .layer-row .layer-label:hover { background: transparent; }

/* ── SCALE-DEPENDENT VISIBILITY ── */
.layer-item--outofscale > .layer-row .layer-name {
  color: #bbb;
  font-style: italic;
}
.layer-card--outofscale .layer-card-name {
  color: #bbb;
  font-style: italic;
}
.layer-card--outofscale .layer-card-name::after {
  content: ' (buiten schaal)';
  font-size: 10px;
  font-weight: 400;
  color: #ccc;
}
.layer-card--error .layer-card-name::after {
  content: ' ⚠';
  color: #e74c3c;
  font-style: normal;
}

/* ── ACTIVE LAYERS THEME GROUPS ── */
.active-group-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  padding: 10px 12px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.active-group-header:first-child { padding-top: 4px; }
.active-group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── CLEAR ALL BUTTON ── */
.clear-all-btn {
  background: none;
  border: none;
  font-size: 10px;
  color: #aaa;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: color 0.15s;
}
.clear-all-btn:hover { color: #c0392b; }

/* ── DRAG HANDLE ── */
.drag-handle {
  cursor: grab;
  color: #ccc;
  font-size: 12px;
  padding: 2px 4px;
  transition: color 0.15s;
}
.drag-handle:hover { color: #999; }
.drag-handle:active { cursor: grabbing; }

/* ── LAYER LOADING INDICATOR ── */
.layer-card--loading .layer-card-name::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1.5px solid #ccc;
  border-top-color: var(--esri-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 6px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── LAYER SEARCH EMPTY STATE ── */
.layer-search-empty {
  text-align: center;
  color: #bbb;
  font-size: 12px;
  padding: 24px 16px;
  line-height: 1.8;
}
.layer-search-empty i { font-size: 20px; margin-bottom: 8px; color: #ddd; }

/* ── MEASURE TOOLTIP ── */
.measure-tooltip {
  position: absolute;
  background: rgba(0,0,0,0.78);
  color: white;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 5px;
  pointer-events: none;
  z-index: 400;
  line-height: 1.5;
  white-space: nowrap;
}

/* ── MEASURE / SHARE ACTIVE STATE ── */
#btn-measure.active {
  background: #fdf0f1;
  color: #c0392b;
  border-color: #f5aaaa;
}
.scale-hint {
  font-size: 10px;
  color: #e67e22;
  padding: 3px 0 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.scale-hint::before {
  content: '\f06a';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
}

/* ── BASEMAP PANEL ── */
.basemap-panel {
  position: fixed;  /* fixed so WebGL stacking context can't clip it */
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  min-width: 140px;
  z-index: 9999;
  overflow: hidden;
}
.basemap-panel-title {
  font-size: 10px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px 5px;
  border-bottom: 1px solid #eee;
}
.basemap-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  color: #444;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.12s;
}
.basemap-option:last-child { border-bottom: none; }
.basemap-option:hover { background: #f0f8ff; color: var(--esri-blue); }
.basemap-option.active { background: var(--esri-blue); color: white; font-weight: 600; }
.basemap-option i { width: 14px; text-align: center; flex-shrink: 0; }

/* ── SHARE BUTTON ── */
#btn-share.active {
  background: #e6f4ea;
  color: #2d7a3a;
  border-color: #a8d5b0;
}

/* ── ANALYSE / MCA TAB ── */
.mca-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: #f8fafd;
}
.mca-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}
.mca-region {
  font-size: 11px;
  color: var(--esri-blue);
  font-weight: 600;
  margin-bottom: 5px;
}
.mca-desc {
  font-size: 11px;
  color: #777;
  line-height: 1.5;
}
.mca-loading {
  padding: 20px;
  text-align: center;
  color: #888;
  font-size: 12px;
}
#mca-controls { padding: 10px 12px 14px; }
.mca-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  margin-bottom: 8px;
}
.mca-slider-row {
  margin-bottom: 10px;
}
.mca-slider-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #444;
  margin-bottom: 4px;
  font-weight: 600;
}
.mca-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.mca-slider-track {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mca-slider {
  flex: 1;
  height: 4px;
  accent-color: var(--esri-blue);
  cursor: pointer;
}
.mca-slider-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--esri-blue);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}
.mca-view-toggle {
  display: flex;
  gap: 6px;
}
.mca-view-btn {
  flex: 1;
  padding: 7px 8px;
  border: 1.5px solid #dde3ec;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #777;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.mca-view-btn:hover { border-color: var(--esri-blue); color: var(--esri-blue); }
.mca-view-btn.active { background: var(--esri-blue); color: white; border-color: var(--esri-blue); }
.mca-legend { display: flex; flex-direction: column; gap: 5px; }
.mca-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #555;
}

/* ── ADD LAYER BUTTON ── */
.add-layer-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 24px);
  margin: 10px 12px 14px;
  padding: 8px 12px;
  background: white;
  border: 1.5px dashed #c0d8ef;
  border-radius: 6px;
  color: var(--esri-blue);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.add-layer-btn:hover { background: #f0f8ff; border-color: var(--esri-blue); }
.add-layer-btn i { font-size: 11px; }

/* ── TABLE PANEL ── */
.table-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 38vh;
  min-height: 200px;
  background: white;
  border-top: 2px solid var(--esri-blue);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
}
.table-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--esri-blue);
  color: white;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  gap: 10px;
}
.table-panel-header span:first-child { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-panel-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.table-count-info { font-size: 10px; font-weight: 400; color: rgba(255,255,255,0.75); }
.tp-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.tp-btn:hover:not(:disabled) { background: rgba(255,255,255,0.3); }
.tp-btn:disabled { opacity: 0.4; cursor: default; }
.table-content {
  flex: 1;
  overflow: auto;
  font-size: 11px;
}
.table-loading {
  padding: 20px;
  text-align: center;
  color: #888;
  font-style: italic;
}
.attr-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  white-space: nowrap;
}
.attr-data-table th {
  position: sticky;
  top: 0;
  background: #f5f7fa;
  border-bottom: 2px solid #dde3ec;
  padding: 5px 10px;
  text-align: left;
  font-weight: 700;
  color: #555;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  z-index: 1;
}
.attr-data-table td {
  padding: 4px 10px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attr-data-table tr:hover td { background: #f5f9ff; }
.table-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  background: #f5f7fa;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}
.table-page-info { font-size: 11px; color: #888; }

/* ── ADD LAYER MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: white;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  width: 420px;
  max-width: 95vw;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--esri-blue);
  color: white;
  font-size: 13px;
  font-weight: 700;
}
.modal-close { cursor: pointer; opacity: 0.8; font-size: 14px; }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 16px; }
.modal-tabs { display: flex; gap: 0; margin-bottom: 14px; border-bottom: 2px solid #eee; }
.modal-tab {
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.modal-tab.active { color: var(--esri-blue); border-bottom-color: var(--esri-blue); }
.modal-hint { font-size: 12px; color: #666; margin-bottom: 10px; line-height: 1.5; }
.modal-hint-ex { font-size: 10px; color: #aaa; }
.modal-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 12px;
  font-family: inherit;
  margin-bottom: 10px;
  outline: none;
}
.modal-input:focus { border-color: var(--esri-blue); }
.modal-btn-primary {
  padding: 8px 16px;
  background: var(--esri-blue);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-btn-primary:hover { background: #005f99; }
.add-layer-status { margin-top: 10px; font-size: 11px; line-height: 1.5; }
.status-error { color: #c0392b; }
.modal-layer-pick-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  margin-bottom: 4px;
  background: #f5f9ff;
  border: 1px solid #c8dff5;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  color: var(--esri-blue);
}
.modal-layer-pick-btn:hover { background: #daeeff; }
.file-drop-zone {
  border: 2px dashed #c0d8ef;
  border-radius: 8px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  color: #888;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.file-drop-zone i { font-size: 24px; color: #c0d8ef; }
.file-drop-zone:hover, .file-drop-zone.dragging {
  border-color: var(--esri-blue);
  background: #f0f8ff;
  color: var(--esri-blue);
}
.file-drop-zone.dragging i { color: var(--esri-blue); }

/* ── CATALOG TAB ── */
#catalog-results { flex: 1; overflow-y: auto; padding: 0; }
.catalog-loading { padding: 20px; text-align: center; color: #888; font-size: 12px; }
.catalog-result {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.1s;
}
.catalog-result:hover { background: #fafcff; }
.catalog-result-title {
  font-size: 12px;
  font-weight: 700;
  color: #333;
  margin-bottom: 4px;
  line-height: 1.3;
}
.catalog-result-abstract {
  font-size: 11px;
  color: #777;
  line-height: 1.4;
  margin-bottom: 6px;
}
.catalog-result-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.catalog-add-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--esri-blue);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}
.catalog-add-btn:hover { background: #005f99; }
.catalog-no-service { font-size: 10px; color: #bbb; font-style: italic; }
.catalog-meta-link {
  font-size: 11px;
  color: #aaa;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.catalog-meta-link:hover { color: var(--esri-blue); }

/* Catalog empty-state source blocks */
.cat-source-block {
  padding: 10px 14px 6px;
  border-bottom: 1px solid #eeeeee;
}
.cat-source-kea {
  border-left: 3px solid #e65100;
  background: #fffaf8;
}
.cat-source-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 4px;
}
.cat-source-desc {
  margin: 0 0 6px;
  font-size: 11px;
  color: #777;
  line-height: 1.5;
}
.kea-cat-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  background: #f0f0f0;
  color: #888;
  padding: 1px 5px;
  border-radius: 3px;
}
.kea-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
  border-top: 1px solid #f0ece9;
  cursor: pointer;
  color: #333;
}
.kea-cat-row:hover { color: #bf360c; }
.kea-cat-row .fa-plus-circle { color: #d5b8b0; font-size: 14px; }
.kea-cat-row:hover .fa-plus-circle { color: #e65100; }

/* ── MOBILE ── */
#sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 300;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  font-size: 15px;
  color: #333;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
#sidebar-toggle:hover { background: #f5f5f5; }

@media (max-width: 700px) {
  #sidebar-toggle { display: flex; }

  #sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    box-shadow: 2px 0 16px rgba(0,0,0,0.15);
  }
  #sidebar.sidebar-open {
    transform: translateX(0);
  }

  #map-container {
    width: 100vw !important;
    margin-left: 0 !important;
  }

  .top-toolbar {
    left: 60px;
  }
}

/* ── PRINT ── */
@media print {
  #sidebar { display: none !important; }
  .top-toolbar, .zoom-controls, #address-search-container { display: none !important; }
  #map-container { width: 100vw !important; height: 100vh !important; position: fixed; top: 0; left: 0; }
  .scale-bar, .coords-widget { display: flex !important; }
}
