/* CALON — tema JarKe (Outfit + DM Sans, black primary, white cards) — responsive */

:root {
  --bg-primary:    #F4F7FA;
  --bg-secondary:  #FFFFFF;
  --bg-card:       #FFFFFF;
  --surface-soft:  rgba(0,0,0,0.04);
  --surface-card:  rgba(0,0,0,0.06);
  --border-color:  rgba(0,0,0,0.12);
  --border-input:  #d1d5db;
  --text-primary:  #111111;
  --text-hover:    #333333;
  --text-secondary:#374151;
  --text-muted:    #6B7280;

  --header-yellow: #B45309;
  --header-red:    #B91C1C;
  --header-green:  #15803D;
  --header-gray:   #4B5563;
  --header-pink:   #BE185D;
  --header-cyan:   #0E7490;
  --header-purple: #7E22CE;
  --header-orange: #C2410C;

  --accent-cyan:   #0E7490;
  --accent-blue:   #1A3A6B;
  --accent-ok:     #28a745;

  --font-display:  "Outfit", sans-serif;
  --font-body:     "DM Sans", "Segoe UI", sans-serif;
  --radius-input:  8px;
  --radius-card:   12px;
  --shadow-float:  0 2px 8px rgba(0,0,0,.12);
  --gap:           .8rem;
  --header-h:      58px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
* { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.2) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.35); }

html, body { min-height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; }

/* ============ APP CONTAINER ============ */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ============ HEADER ============ */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: .55rem 1.2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  position: relative;
  z-index: 1100;
}

.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; border-radius: 10px; background: var(--surface-card);
  cursor: pointer; user-select: none;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text-primary) !important;
  margin: 0;
  line-height: 1.5rem;
}
.brand-subtitle {
  display: block;
  font-size: .76rem;
  font-weight: 300;
  letter-spacing: .02em;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  position: relative;
}

/* Theme Toggle — hidden */
.theme-toggle { display: none; }

.header-notice {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px;
  background: rgba(180,83,9,.08); border: 1px solid rgba(180,83,9,.2); border-radius: var(--radius-input);
}
.notice-icon { color: #f59e0b; font-size: 13px; }
.notice-text { font-size: 11px; color: var(--text-secondary); }
.notice-link { color: var(--accent-cyan); text-decoration: none; font-weight: 600; }
.notice-link:hover { text-decoration: underline; }

.file-btn,
.load-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 .9rem;
  background: var(--text-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-input);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .05em;
  white-space: nowrap;
  transition: background .2s;
}
.file-btn:hover, .load-all-btn:hover { background: var(--text-hover); }
.load-all-btn:disabled {
  background: var(--bg-primary);
  color: var(--text-muted);
  border: 1px solid var(--border-input);
  cursor: not-allowed;
}

.file-status { color: var(--text-muted); font-size: 11px; }

.dem-status {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  white-space: nowrap;
  background: rgba(180,83,9,.1);
  color: #b45309;
  border: 1px solid rgba(180,83,9,.2);
}
.dem-status.loaded { background: rgba(21,128,61,.1); color: #15803d; border-color: rgba(21,128,61,.2); }

/* File pool popover (loader.php) */
.file-pool-list {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 420px;
  max-width: calc(100vw - 32px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  z-index: 1200;
  padding: 8px;
  font-size: 12px;
}
.file-pool-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px; padding: 0 2px;
  font-family: var(--font-display); font-size: .7rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
}
.file-pool-head #poolCount { color: var(--text-muted); font-weight: 500; letter-spacing: .04em; text-transform: none; }
.file-pool-items { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }

/* ============ MAIN LAYOUT (desktop) ============ */
.main-content {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(600px, 54%) minmax(0, 1fr);
  gap: var(--gap);
  padding: var(--gap) 1.2rem;
  overflow: hidden;
}

.left-panel-stack {
  display: grid;
  grid-template-rows: minmax(0, 1.1fr) minmax(220px, 1fr);
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
}

.left-top-row {
  display: grid;
  grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
  gap: var(--gap);
  min-height: 0;
}

.panel-col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
}

.panel-col1 { overflow-y: auto; overflow-x: hidden; padding-right: 2px; }
.panel-col1 > *, .download-col > * { flex-shrink: 0; }
.panel-col2 { overflow: hidden; }
.panel-col2 > .chart-card { flex: 1; min-height: 0; }
.panel-col2 .chart-wrapper { flex: 1; min-height: 0; }

.elevation-full-row { min-height: 0; display: flex; flex-direction: column; }
.elevation-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  transition: opacity .3s, filter .3s;
  position: relative;
}
.elevation-container .chart-card { flex: 1; min-height: 0; }

.panel-col3 { min-width: 0; min-height: 0; overflow: hidden; }
.panel-col3 .map-section { height: 100%; }

.download-col { display: flex; flex-direction: column; gap: var(--gap); }
.download-col .download-section { flex: none; }

/* Legacy layout classes (still referenced by some modules) */
.left-panel, .right-panel { display: flex; flex-direction: column; gap: var(--gap); overflow-y: auto; }
.center-section { flex: 1; display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

/* ============ CARD ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: .65rem 1rem .45rem;
  font-family: var(--font-display);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-primary);
  background: var(--bg-card);
}
.card-header::before {
  content: '';
  width: 4px; height: 14px; border-radius: 2px;
  background: var(--text-primary);
  flex-shrink: 0;
}
.card-header.yellow::before { background: var(--header-yellow); }
.card-header.red::before    { background: var(--header-red); }
.card-header.green::before  { background: var(--header-green); }
.card-header.cyan::before   { background: var(--header-cyan); }
.card-header.purple::before { background: var(--header-purple); }
.card-header.pink::before   { background: var(--header-pink); }
.card-header.gray::before   { background: var(--header-gray); }
.card-header.orange::before { background: var(--header-orange); }

.card-header .sync-btn {
  font-size: 10px; background: transparent; border: 1px solid var(--border-input);
  color: var(--text-secondary); padding: 2px 8px; border-radius: var(--radius-input);
  cursor: pointer; font-family: var(--font-display);
}

.card-collapse-icon { font-size: 10px; color: var(--text-muted); transition: transform .2s; user-select: none; line-height: 1; }
.collapsible-card.collapsed .card-collapse-icon { transform: rotate(-90deg); }
.collapsible-card.collapsed .card-body { display: none !important; }

.card-body {
  padding: .4rem 1rem .9rem;
  position: relative;
}
.card .card-body { max-height: 420px; overflow-y: auto; overflow-x: hidden; }
.panel-col1 .card .card-body { max-height: none; overflow: visible; }
.card .card-body > * { position: relative; z-index: 0; }

/* scroll fade indicators (scroll_indicators.js) */
.card .card-body::after,
.card .card-body::before {
  content: ''; position: absolute; left: 0; right: 8px; pointer-events: none; z-index: 1; transition: opacity .3s;
}
.card .card-body::after  { bottom: 0; height: 24px; background: linear-gradient(to bottom, transparent, #fff); opacity: 0; }
.card .card-body::before { top: 0; height: 16px; background: linear-gradient(to top, transparent, #fff); opacity: 0; }
.card .card-body.scrolled::before { opacity: .7; }

/* ============ FORM ============ */
.form-grid { display: flex; gap: 8px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: .25rem; min-width: 110px; flex: 1; }

.field label {
  font-family: var(--font-display);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.field label span { text-transform: none; letter-spacing: 0; font-weight: 400; }

.field input,
.field select {
  height: 34px;
  padding: 0 .7rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .85rem;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}
.field input::placeholder { color: var(--text-muted); }
.field select { cursor: pointer; }
.field select option { background: #fff; color: var(--text-primary); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 1rem;
  border: none;
  border-radius: var(--radius-input);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .05em;
  transition: background .2s, border-color .2s, color .2s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary, .btn-success, .btn-cyan, .btn-orange { background: var(--text-primary); color: #fff; }
.btn-primary:hover, .btn-success:hover, .btn-cyan:hover, .btn-orange:hover { background: var(--text-hover); }
.btn-danger { background: #B91C1C; color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-ghost {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-input);
  padding: 0 .75rem;
}
.btn-ghost:hover { border-color: var(--text-primary); color: var(--text-primary); }

/* Downloads: outline style ala btn-kml JarKe */
.download-buttons .btn-cyan,
.download-section .btn-orange {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-input);
}
.download-buttons .btn-cyan:hover,
.download-section .btn-orange:hover { background: var(--text-primary); color: #fff; border-color: var(--text-primary); }

.btn-calculate-warning {
  background: var(--text-primary) !important;
  border: 2px solid #f59e0b !important;
  animation: pulse-warning 2s infinite;
}
.btn-calculate-warning::before { content: '⚠️'; margin-right: 4px; }
@keyframes pulse-warning {
  0%,100% { border-color: #f59e0b; box-shadow: 0 0 0 0 rgba(245,158,11,.4); }
  50%      { border-color: #fbbf24; box-shadow: 0 0 0 4px rgba(245,158,11,0); }
}

/* ============ MAP ============ */
.map-section {
  position: relative;
  height: 100%;
  min-height: 400px;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}
#map { position: absolute; inset: 0; }
.leaflet-container { background: #E8EEF2; font-family: var(--font-body); }

/* Floating map tool buttons */
.map-tool-btn {
  position: absolute;
  width: 34px;
  height: 34px;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-input);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  font-size: 16px;
  box-shadow: var(--shadow-float);
  transition: background .2s, border-color .2s;
}
.map-tool-btn:hover { border-color: var(--text-primary); }
.map-tool-btn.active { background: var(--text-primary); color: #fff; border-color: var(--text-primary); }

/* Map UI Toggle (Hide/Show) */
.map-ui-toggle-wrap {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 1002;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-input);
  padding: 0 10px;
  box-shadow: var(--shadow-float);
}
.map-ui-toggle-label {
  font-family: var(--font-display); font-size: .68rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); user-select: none;
}

/* Right-click context menu */
.map-ctx-menu {
  position: fixed; z-index: 9999; background: #fff;
  border: 1px solid var(--border-color); border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(0,0,0,.15); overflow: hidden; min-width: 210px; user-select: none;
}
.ctx-coords { padding: 9px 14px 7px; font-size: 13px; font-weight: 600; color: var(--text-primary); font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.ctx-divider { height: 1px; background: var(--border-color); margin: 2px 0; }
.ctx-item { padding: 9px 14px; font-size: 12.5px; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; gap: 8px; transition: background .12s; }
.ctx-item:hover { background: var(--surface-soft); color: var(--text-primary); }

/* Toast */
.map-toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.map-toast {
  background: var(--text-primary); color: #fff; padding: 10px 16px; border-radius: var(--radius-card);
  font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,.2); pointer-events: none;
  animation: mapToastIn .2s ease, mapToastOut .3s ease 2.7s forwards;
  max-width: 320px; display: flex; align-items: center; gap: 8px; border-left: 3px solid #6b7280;
}
.map-toast.success { border-left-color: #22c55e; }
.map-toast.error   { border-left-color: #ef4444; }
.map-toast.warning { border-left-color: #f59e0b; }
@keyframes mapToastIn  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes mapToastOut { from { opacity:1; } to { opacity:0; transform:translateY(-4px); } }

/* Hidden map UI (clean capture) */
#mapWrapper.map-ui-hidden .map-legends,
#mapWrapper.map-ui-hidden .neighbour-filter-compact,
#mapWrapper.map-ui-hidden .map-tool-btn,
#mapWrapper.map-ui-hidden .leaflet-control-zoom,
#mapWrapper.map-ui-hidden .leaflet-control-layers,
#mapWrapper.map-ui-hidden .leaflet-control-scale,
#mapWrapper.map-ui-hidden .leaflet-top .leaflet-control {
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

/* Map Legends */
.map-legends {
  position: absolute;
  bottom: 50px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1000;
}
.legend-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-input);
  padding: 7px 10px;
  font-size: .72rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-float);
}
.legend-title {
  font-family: var(--font-display);
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
}
.legend-item { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.legend-color { width: 16px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend-line  { width: 16px; height: 2px; flex-shrink: 0; }

/* Ruler / angle info panel */
.tool-info-panel {
  position: absolute;
  top: 84px;
  right: 54px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 10px 12px;
  z-index: 1000;
  min-width: 170px;
  font-size: .8rem;
  box-shadow: var(--shadow-float);
}
.tool-title { font-family: var(--font-display); font-weight: 600; margin-bottom: 6px; color: var(--text-primary) !important; }
.tool-buttons { display: flex; gap: 6px; margin-top: 8px; }
.tool-buttons button { flex: 1; height: 28px; padding: 0 8px; font-size: .72rem; }

/* ============ CHART ============ */
.chart-card { display: flex; flex-direction: column; }
.chart-card h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: .65rem 1rem .4rem;
  font-family: var(--font-display);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.35;
}
.chart-card h3::before { font-size: 13px; }
.chart-card h3.range-chart::before     { content: '📊'; }
.chart-card h3.elevation-chart::before { content: '📈'; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0 1rem .3rem; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; color: var(--text-primary); }
.chart-legend-color { width: 16px; height: 9px; border-radius: 3px; }

.chart-wrapper { position: relative; padding: .3rem .8rem .7rem; }
.chart-wrapper canvas { width: 100% !important; }
.chart-wrapper.elevation-chart { flex: 1; min-height: 0; }
.chart-wrapper.elevation-chart canvas { height: 100% !important; }

.elev-deg-label {
  position: absolute; top: 6px; left: 60px;
  font-family: var(--font-display); font-size: .9rem; font-weight: 700;
  color: #dc2626; z-index: 10;
  background: rgba(255,255,255,.85); padding: 1px 8px; border-radius: 999px;
}

.elevation-container.loading { opacity: .5; pointer-events: none; filter: blur(1px); }
.chart-loading-overlay {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: #fff; padding: 15px 25px; border-radius: var(--radius-card);
  color: var(--text-primary); font-family: var(--font-display); font-size: 13px; font-weight: 600;
  display: none; z-index: 1000; box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.elevation-container.loading .chart-loading-overlay { display: block; }
.chart-loading-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,.12); border-top-color: var(--text-primary);
  border-radius: 50%; animation: spin .6s linear infinite; margin-right: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ DOWNLOAD SECTION ============ */
.download-row { display: flex; gap: 8px; }
.download-section {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: .7rem 1rem .9rem;
}
.download-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.download-toggle {
  display: flex; align-items: center; gap: 5px;
  font-size: .64rem; letter-spacing: .06em; color: var(--text-muted);
}

/* Toggle switch (dipakai Hide/Show) */
.toggle-switch { position: relative; display: inline-block; width: 32px; height: 18px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: rgba(0,0,0,.2); border-radius: 18px; transition: .25s;
}
.toggle-slider:before {
  position: absolute; content: "";
  height: 14px; width: 14px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .25s;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.toggle-switch input:checked + .toggle-slider { background: var(--text-primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(14px); }

.download-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.download-buttons .btn { font-size: .74rem; padding: 0 8px; height: 32px; }
.download-section > .btn { height: 32px; font-size: .74rem; margin-top: 6px !important; }

/* Transparency */
.transparency-control { margin: 4px 0; padding: 6px 8px; background: var(--surface-soft); border-radius: var(--radius-input); }
.transparency-control label { font-size: .66rem; color: var(--text-muted); font-family: var(--font-display); }
.transparency-slider { display: flex; align-items: center; gap: 4px; margin-top: 3px; }
.transparency-slider span { font-size: .62rem; color: var(--text-muted); }
.transparency-slider input[type="range"] { flex: 1; height: 4px; accent-color: var(--text-primary); }
.transparency-value { text-align: center; font-size: .66rem; color: var(--text-primary); margin-top: 2px; }

/* ============ PROGRESS ============ */
.progress-container { margin-top: 10px; }
.progress-info { display: flex; justify-content: space-between; font-size: .72rem; margin-bottom: 4px; color: var(--text-secondary); }
.progress-bar-bg { width: 100%; height: 6px; background: var(--surface-card); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--text-primary); border-radius: 999px; transition: width .2s; }

/* ============ STATUS ============ */
.status-chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-family: var(--font-display); font-size: .72rem; font-weight: 600; letter-spacing: .05em;
}
.status-chip.warning { background: rgba(180,83,9,.1); color: #b45309; }
.status-chip.loaded  { background: rgba(21,128,61,.1); color: #15803d; }

/* ============ FOOTER ============ */
.app-footer {
  display: flex; align-items: center; padding: 5px 1.2rem;
  background: var(--bg-secondary); border-top: 1px solid var(--border-color);
  font-size: 10px; flex-shrink: 0;
}
.footer-left { font-family: var(--font-display); font-size: .75rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.footer-marquee { flex: 1; overflow: hidden; margin-left: 20px; }
.marquee-content { display: inline-block; white-space: nowrap; animation: marquee 50s linear infinite; font-size: .75rem; color: var(--text-muted); }
.marquee-content a { color: var(--text-primary); text-decoration: none; font-weight: 600; }
@keyframes marquee { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }

/* ============ UTILITIES ============ */
.hidden { display: none !important; }
.small { font-size: .7rem; color: var(--text-muted); }

.section-title {
  font-family: var(--font-display); font-size: .68rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px;
  display: flex; align-items: center; gap: 4px;
}
.section-title.cyan   { color: var(--header-cyan); }
.section-title.orange { color: var(--header-orange); }
.section-title.purple { color: var(--header-purple); }
.section-title.green  { color: var(--header-green); }
.section-title.pink   { color: var(--header-pink); }
.section-title.gray   { color: var(--header-gray); }

.section-box { background: var(--surface-soft); border-radius: var(--radius-input); padding: 6px 8px; margin-bottom: 4px; }

#rfResultsContent { max-height: 400px; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }

/* ============ LEAFLET OVERRIDES ============ */
.leaflet-touch .leaflet-bar,
.leaflet-touch .leaflet-control-layers,
.leaflet-control-zoom,
.leaflet-control-layers {
  border: 1px solid var(--border-input) !important;
  border-radius: var(--radius-input) !important;
  box-shadow: var(--shadow-float) !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-input) !important;
  font-family: var(--font-display);
}
.leaflet-control-zoom a:last-child { border-bottom: 0 !important; }
.leaflet-control-zoom a:hover { background: var(--bg-primary) !important; }
.leaflet-control-layers-expanded { padding: 8px 12px !important; font-family: var(--font-body); font-size: .8rem; }
.leaflet-control-layers-base label { padding: 2px 0; }

.leaflet-control-scale-line {
  background: rgba(255,255,255,.9) !important;
  border-color: var(--text-secondary) !important;
  color: var(--text-secondary) !important;
  font-family: var(--font-body);
}

.leaflet-popup-content-wrapper { border-radius: var(--radius-input); box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.leaflet-popup-content { font-family: var(--font-body); font-size: 12.5px; }

.site-marker-label {
  background: rgba(17,17,17,.88) !important;
  padding: 2px 7px !important;
  border-radius: 6px !important;
  font-family: var(--font-display) !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  color: #fff !important;
  border: none !important;
  letter-spacing: .03em;
}
.az-label {
  background: transparent !important;
  border: none !important;
  font-family: var(--font-display) !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  color: #fff !important;
  text-shadow: 1px 1px 2px rgba(0,0,0,.7);
}

/* ============ NEIGHBOUR FILTER ============ */
.neighbour-filter-compact {
  position: absolute;
  top: 10px;
  left: 54px;
  width: 260px;
  max-width: calc(100% - 350px);
  min-width: 190px;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-card);
  padding: 7px 12px 8px;
  box-shadow: var(--shadow-float);
  z-index: 1000;
}
.filter-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.filter-label {
  font-family: var(--font-display); font-size: .68rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-primary);
}
.filter-value {
  font-family: var(--font-display); font-size: .82rem; font-weight: 600;
  color: var(--text-primary); background: var(--surface-card);
  padding: 1px 9px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.filter-slider-row { display: flex; align-items: center; gap: 8px; }
.filter-min, .filter-max { font-size: .66rem; color: var(--text-muted); white-space: nowrap; }

/* range sliders */
#neighbourSlider,
.population-slider,
.rf-radius-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-input);
  border-radius: 2px;
  outline: none;
  min-width: 0;
}
#neighbourSlider::-webkit-slider-thumb,
.rf-radius-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; background: var(--text-primary);
  border: 2px solid #fff; border-radius: 50%; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
#neighbourSlider::-moz-range-thumb,
.rf-radius-slider::-moz-range-thumb {
  width: 14px; height: 14px; background: var(--text-primary);
  border: 2px solid #fff; border-radius: 50%; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}

/* ============ POPULATION CALCULATOR ============ */
.population-slider-container {
  background: rgba(126,34,206,.05); border: 1px solid rgba(126,34,206,.2);
  border-radius: var(--radius-input); padding: 8px 10px;
}
.slider-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.slider-label { font-family: var(--font-display); font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); }
.slider-value { font-family: var(--font-display); font-size: .78rem; font-weight: 700; color: var(--header-purple); background: rgba(126,34,206,.12); padding: 2px 8px; border-radius: 999px; }
.slider-row { display: flex; align-items: center; gap: 6px; }
.slider-min, .slider-max { font-size: .64rem; color: var(--text-muted); min-width: 36px; text-align: center; }
.population-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
  background: var(--header-purple); border: 2px solid #fff; border-radius: 50%; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.population-slider::-moz-range-thumb {
  width: 14px; height: 14px; background: var(--header-purple);
  border: 2px solid #fff; border-radius: 50%; cursor: pointer;
}

/* Population Result Panel */
.population-result-panel {
  position: fixed; bottom: 20px; right: 20px; width: 350px; max-height: 500px;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-card);
  box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 1000; overflow: hidden;
}
.population-result-panel .panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border-color);
}
.population-result-panel .panel-header h4 {
  margin: 0; font-family: var(--font-display); font-size: .78rem !important; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-primary);
}
.population-result-panel .collapse-btn {
  background: none; border: none; color: var(--text-muted); font-size: 14px; cursor: pointer;
  padding: 4px 6px; border-radius: 6px;
}
.population-result-panel .collapse-btn:hover { background: var(--surface-card); color: var(--text-primary); }
.population-result-panel .panel-content { max-height: 440px; overflow-y: auto; padding: 10px 14px; }
.population-result-panel .result-section { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); }
.population-result-panel .result-section:last-child { border-bottom: none; margin-bottom: 0; }
.population-result-panel .result-section h5 { margin: 0 0 8px; font-family: var(--font-display); font-size: .68rem; font-weight: 700; color: var(--text-primary); text-transform: uppercase; letter-spacing: .08em; }
.population-result-panel .info-grid { display: flex; flex-direction: column; gap: 4px; }
.population-result-panel .info-row { display: flex; justify-content: space-between; align-items: center; font-size: .74rem; padding: 3px 0; }
.population-result-panel .info-row.highlight { background: var(--surface-soft); padding: 6px 8px; border-radius: var(--radius-input); margin: 4px 0; }
.population-result-panel .info-label { color: var(--text-muted); font-weight: 500; }
.population-result-panel .info-value { color: var(--text-primary); font-weight: 600; font-family: var(--font-display); }
.result-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.result-table td { padding: 3px 0; }
.result-table td:first-child { color: var(--text-muted); }
.result-table td:last-child { text-align: right; font-weight: 600; }

.population-value { font-family: var(--font-display); font-size: .82rem; font-weight: 700; padding: 4px 10px; border-radius: var(--radius-input); display: inline-block; }
.population-value.red    { background: rgba(185,28,28,.1); color: #b91c1c; border: 1px solid rgba(185,28,28,.2); }
.population-value.orange { background: rgba(194,65,12,.1); color: #c2410c; border: 1px solid rgba(194,65,12,.2); }
.population-value.green  { background: rgba(21,128,61,.1);  color: #15803d; border: 1px solid rgba(21,128,61,.2); }
.population-value.blue   { background: rgba(26,58,107,.1);  color: #1a3a6b; border: 1px solid rgba(26,58,107,.2); }
.population-pin { display: flex; align-items: center; justify-content: center; }

.popup-population { min-width: 200px; }
.popup-population h4 { margin: 0 0 8px; font-family: var(--font-display); font-size: 13px; color: var(--text-primary); }
.popup-population p  { margin: 3px 0; font-size: 11px; }
.popup-population .population-badge { padding: 2px 6px; border-radius: var(--radius-input); font-weight: 600; font-size: 11px; }
.popup-population .population-badge.red    { background: #B91C1C; color: #fff; }
.popup-population .population-badge.orange { background: #C2410C; color: #fff; }
.popup-population .population-badge.green  { background: #15803D; color: #fff; }
.popup-population .population-badge.blue   { background: #1A3A6B; color: #fff; }

.population-grid-cell { transition: opacity .3s, fill-opacity .3s; }
.population-grid-cell:hover { opacity: .8; fill-opacity: .8 !important; stroke-width: 2 !important; cursor: pointer; }
.leaflet-interactive[stroke-dasharray="5, 5"] {
  stroke: #111 !important; stroke-width: 3 !important; stroke-opacity: .6 !important; fill-opacity: .05 !important;
}

/* ============ ALAT PETA ALA JARKE (js/map_tools.js) ============ */
.leaflet-top.leaflet-right .leaflet-control { clear: both; }
.pc-base { display: inline-flex; border: 1px solid var(--border-input); border-radius: var(--radius-input); overflow: hidden;
  background: #fff; box-shadow: var(--shadow-float); }
.pc-base-btn { height: 32px; padding: 0 .85rem; border: 0; cursor: pointer; font: 600 .8rem var(--font-display);
  color: var(--text-muted); background: #fff; transition: background .2s, color .2s; }
.pc-base-btn + .pc-base-btn { border-left: 1px solid var(--border-input); }
.pc-base-btn:hover { color: var(--text-primary); }
.pc-base-btn.active { background: var(--text-primary); color: #fff; }
.leaflet-container a.pc-ruler-btn { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  background: #fff; color: var(--text-primary); border-radius: var(--radius-input); box-shadow: 0 1px 5px rgba(0,0,0,.35); cursor: pointer; }
.leaflet-container a.pc-ruler-btn:hover { background: var(--bg-primary); }
.leaflet-container a.pc-ruler-btn.pc-ruler-on { background: var(--text-primary); color: #fff; }
.pc-llpop .leaflet-popup-content-wrapper { border-radius: var(--radius-input); box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.pc-llpop .leaflet-popup-content { margin: 8px 12px; }
.pc-ll { font-weight: 600; letter-spacing: .01em; }
.pc-measuring, .pc-measuring .leaflet-interactive { cursor: crosshair !important; }
.pc-measuring .leaflet-interactive { pointer-events: none !important; }
.pc-measuring .leaflet-pcRuler-pane .leaflet-interactive { pointer-events: auto !important; }
.pc-measuring .leaflet-tooltip-pane { display: none; }
.pc-ruler-wrap { overflow: visible; }
.pc-ruler-label { position: absolute; transform: translate(-50%, -140%); white-space: nowrap; background: #fff;
  color: var(--text-primary); font: 600 13px var(--font-body); padding: 4px 9px; border-radius: var(--radius-input);
  box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.pc-ruler-final, .pc-measuring .pc-ruler-final { cursor: pointer !important; }
.pc-ruler-cp { margin-left: 8px; color: var(--accent-ok); font-size: 11px; }
.pc-pin-ctl { position: relative; }
.pc-pin-wrap { overflow: visible; }
.pc-pin { position: absolute; left: -13px; top: -33px; pointer-events: auto; cursor: pointer; }
.pc-pin span { position: absolute; left: 25px; top: 2px; font: 800 12px Arial, sans-serif; color: #111; white-space: nowrap;
  text-shadow: -1.5px -1.5px 0 #fff, 1.5px -1.5px 0 #fff, -1.5px 1.5px 0 #fff, 1.5px 1.5px 0 #fff; }
.pc-pin-panel { display: none; position: absolute; right: 44px; top: 0; width: 240px; max-width: calc(100vw - 90px);
  background: #fff; border-radius: var(--radius-input); box-shadow: 0 2px 10px rgba(0,0,0,.3); padding: 10px 12px;
  font: 500 12px var(--font-body); color: var(--text-primary); }
.pc-pin-panel.pc-open { display: block; }
.pc-pin-title { font: 600 .7rem var(--font-display); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; }
.pc-pin-in { width: 100%; box-sizing: border-box; height: 32px; padding: 0 8px; border: 1px solid var(--border-input);
  border-radius: 6px; font: inherit; }
.pc-pin-in:focus { outline: none; border-color: var(--text-primary); box-shadow: 0 0 0 3px rgba(0,0,0,.08); }
.pc-pin-nm { margin-bottom: 6px; }
.pc-pin-msg { color: var(--text-muted); font-size: 11px; margin: 4px 0 8px; }
.pc-pin-msg.pc-err { color: #d50000; }
.pc-pin-name { width: 170px; box-sizing: border-box; padding: 3px 6px; border: 1px solid #ccc; border-radius: 5px;
  font: 700 13px Arial, sans-serif; margin-bottom: 4px; }
.pc-pin-chk { display: flex; gap: 6px; align-items: center; cursor: pointer; margin-bottom: 8px; }
.leaflet-container .pc-pin-clr { color: #d50000; font-size: 11px; text-decoration: none; }
.pc-pin-act { margin-top: 6px; display: flex; gap: 14px; }
.leaflet-container .pc-pin-act a { color: var(--accent-ok); font-weight: 600; text-decoration: none; }
.leaflet-container .pc-pin-act a[data-a=del] { color: #d50000; }
.pc-pinning, .pc-pinning .leaflet-interactive { cursor: crosshair !important; }
.pc-cmp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; white-space: nowrap; }
.pc-cmp-row .pc-pin-in { width: 100px; }
.pc-cmp-wrap { overflow: visible; }
.pc-cmp-lbl { color: #ffff00; font: bold 10px sans-serif; text-shadow: 0 0 2px #000, 0 0 2px #000; white-space: nowrap; width: max-content; }
.pc-cmp-big { font-size: 13px; }
.pc-cmp-cross { transform: translate(-50%, -50%); color: #ffff00; font: bold 26px sans-serif; text-shadow: 0 0 2px #000; }
.pc-compassing { cursor: crosshair !important; }

/* ============ RESPONSIVE ============ */

/* Laptop kecil: kolom input sedikit lebih sempit */
@media (max-width: 1440px) {
  .main-content { grid-template-columns: minmax(560px, 56%) minmax(0, 1fr); padding: var(--gap); }
  .left-top-row { grid-template-columns: minmax(250px, 290px) minmax(0, 1fr); }
}

/* Tablet & HP: satu kolom, halaman scroll. Urutan: Input → Map → Download → Range → Elevation */
@media (max-width: 1100px) {
  .app-container { height: auto; min-height: 100vh; overflow: visible; }

  .app-header { position: sticky; top: 0; }

  .main-content {
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding: .7rem 16px 1rem;
  }
  .left-panel-stack, .left-top-row, .panel-col1, .download-col { display: contents; }

  .panel-col1 > .card       { order: 1; }
  .panel-col3               { order: 2; overflow: visible; }
  .download-col > .download-section { order: 3; }
  .panel-col2               { order: 4; overflow: visible; }
  .elevation-full-row       { order: 5; }

  .panel-col3 .map-section { height: 62vh; height: 62svh; min-height: 380px; }

  .panel-col2 .chart-wrapper { height: 260px; flex: none; }
  .elevation-container { flex: none; }
  .elevation-full-row .chart-wrapper.elevation-chart { height: 300px; flex: none; }

  .card .card-body { max-height: none; overflow: visible; }

  .population-result-panel { left: 16px; right: 16px; bottom: 16px; width: auto; max-height: 60vh; }
  .population-result-panel .panel-content { max-height: calc(60vh - 50px); }
}

@media (max-width: 760px) {
  :root { --gap: .7rem; }
  body { font-size: 14px; }

  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: .55rem 16px;
  }
  .brand-text h1 { font-size: 1.05rem; line-height: 1.3rem; }
  .brand-subtitle { font-size: .7rem; }

  .header-controls { justify-content: flex-start; gap: 6px; }
  .file-btn, .load-all-btn { height: 34px; padding: 0 .7rem; font-size: .76rem; }
  .file-pool-list { left: 0; right: 0; width: auto; max-width: none; }

  /* cegah iOS auto-zoom saat fokus input */
  .field input, .field select { font-size: 16px; height: 40px; }
  .btn { height: 40px; }
  .download-buttons .btn, .download-section > .btn { height: 38px; }

  .panel-col3 .map-section { height: 68vh; height: 68svh; min-height: 360px; }

  /* overlay di peta: kompak & tidak saling tumpuk */
  .neighbour-filter-compact {
    top: 52px; left: 54px; right: 56px;
    width: auto; max-width: none; min-width: 0; padding: 6px 10px 7px;
  }
  .filter-min, .filter-max { display: none; }
  .field label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .field label span { display: none; }

  .pc-base-btn { padding: 0 .6rem; font-size: .74rem; }
  .map-tool-btn { width: 36px; height: 36px; }
  .tool-info-panel { top: 170px; right: 10px; min-width: 150px; max-width: calc(100% - 20px); }

  .legend-box { padding: 5px 8px; font-size: .66rem; }
  .legend-title { font-size: .6rem; }
  .map-legends { bottom: 48px; }

  .elev-deg-label { left: 50px; font-size: .8rem; }

  .map-toast-wrap { left: 16px; right: 16px; bottom: 16px; align-items: center; }
}

@media (max-width: 420px) {
  .field { min-width: 120px; }
  .brand-subtitle { display: none; }
  .panel-col2 .chart-wrapper { height: 230px; }
  .elevation-full-row .chart-wrapper.elevation-chart { height: 260px; }
}
