:root {
  --bg: #FBF3E7;
  --bg-alt: #F5E9D6;
  --panel-bg: rgba(255,255,255,0.78);
  --panel-bg-solid: #FFFDF9;
  --text: #2B2118;
  --muted: #8A7A66;
  --border: #E4D3B8;
  --accent: #ff9a5b;
  --accent-2: #ffd27f;
  --accent-deep: #8b3e2f;
  --business: #2F6F6B;
  --danger: #C0392B;
  --success: #4C7A4A;
  --space: 8px;
  --radius: 10px;
  --shadow-soft: 0 8px 30px rgba(139, 62, 47, 0.10), 0 2px 8px rgba(139, 62, 47, 0.06);
  --shadow-panel: 0 16px 48px rgba(43, 33, 24, 0.16), 0 4px 12px rgba(43, 33, 24, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif {
  font-family: "Merriweather", Georgia, serif;
  font-weight: 700;
  color: var(--accent-deep);
  margin: 0;
}

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

svg.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---------- Header ---------- */

.app-header {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(228, 211, 184, 0.8);
  border-radius: 999px;
  padding: 10px 12px 10px 20px;
  box-shadow: var(--shadow-soft);
  max-width: calc(100% - 32px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Merriweather", serif;
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
}

.brand .mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
}

.brand .kec { color: var(--accent-deep); }
.brand .ins { color: var(--text); font-weight: 400; }

.app-nav {
  display: flex;
  gap: 4px;
  font-size: 14px;
  font-weight: 500;
}

.app-nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text);
}

.app-nav a.active, .app-nav a:hover {
  background: rgba(255, 154, 91, 0.16);
  color: var(--accent-deep);
  text-decoration: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(228, 211, 184, 0.35);
  border-radius: 999px;
  padding: 4px 6px;
}

.lang-switch button {
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

.lang-switch button.active {
  background: var(--accent-deep);
  color: #fff;
}

.lang-switch button.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: rgba(228, 211, 184, 0.35);
}

.icon-btn:hover { background: rgba(228, 211, 184, 0.6); }

/* ---------- Map view ---------- */

.map-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

#map { position: absolute; inset: 0; }

.maplibregl-ctrl-attrib { font-size: 11px !important; }

/* ---------- Layers toggle + panel ---------- */

.layers-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 41;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(228, 211, 184, 0.8);
  border-radius: 999px;
  padding: 10px 18px 10px 16px;
  box-shadow: var(--shadow-soft);
  font-weight: 600;
  font-size: 14px;
}

.layers-toggle.is-hidden { display: none; }

.layers-panel {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 42;
  width: 320px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(228, 211, 184, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  display: none;
  flex-direction: column;
}

.layers-panel.is-open { display: flex; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px 18px;
}

.panel-header h2 {
  font-family: "Inter", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.text-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
}

.text-btn:hover { background: rgba(228,211,184,0.4); color: var(--accent-deep); }

.panel-body { padding: 4px 16px 18px; }

.search-box {
  position: relative;
  margin-bottom: 10px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 154, 91, 0.18);
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-results {
  margin-top: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(43,33,24,0.08);
  display: none;
}

.search-results.is-open { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-alt); }

.search-result-item .sri-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: rgba(255, 154, 91, 0.16);
  color: var(--accent-deep);
  display: flex; align-items: center; justify-content: center;
}

.search-result-item .sri-text { flex: 1; min-width: 0; }
.search-result-item .sri-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.search-result-item .sri-pop { font-size: 12px; color: var(--muted); }

.upload-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.upload-btn:hover { border-color: var(--accent); color: var(--accent-deep); }

.pill-group {
  display: flex;
  background: rgba(228, 211, 184, 0.3);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 10px;
}

.pill-group button {
  flex: 1;
  padding: 7px 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.pill-group button.active {
  background: #fff;
  color: var(--accent-deep);
  box-shadow: 0 2px 6px rgba(43,33,24,0.10);
}

.layer-group {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.layer-group:first-of-type { border-top: none; padding-top: 4px; }

.layer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.layer-row .dot {
  width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}

.layer-row label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.layer-sub {
  margin: 8px 0 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.layer-sub .sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.layer-source {
  margin: 8px 0 0 20px;
  font-size: 11.5px;
  color: var(--muted);
}

.layer-source a { color: var(--muted); text-decoration: underline; }

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent-deep);
  width: 15px; height: 15px;
}

/* ---------- Legend ---------- */

.legend {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 39;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(228,211,184,0.8);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
  font-size: 12px;
}

.legend-title { font-weight: 700; margin-bottom: 6px; color: var(--text); }
.legend-bar {
  width: 180px; height: 10px; border-radius: 6px;
  background: linear-gradient(90deg, #fff5e6, #ffd27f, #ff9a5b, #8b3e2f);
  margin-bottom: 4px;
}
.legend-labels { display: flex; justify-content: space-between; color: var(--muted); }

/* ---------- Sidepanel ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(43, 33, 24, 0.28);
  z-index: 43;
  display: none;
}

.scrim.is-open { display: block; }

.sidepanel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 420px;
  background: var(--panel-bg-solid);
  z-index: 44;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(.22,.9,.1,1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-panel);
}

.sidepanel.is-open {
  transform: translateX(0);
}

/* overlay mode: floats over map with margin + rounded corners + scrim (default) */
body.layout-overlay .sidepanel {
  top: 16px;
  right: 16px;
  height: calc(100vh - 32px);
  border-radius: var(--radius);
  border: 1px solid rgba(228,211,184,0.8);
}

/* docked mode: pushes map, full-height flush column, no scrim */
body.layout-docked .sidepanel {
  border-left: 1px solid var(--border);
}

body.layout-docked .scrim { display: none !important; }

body.layout-docked .map-shell {
  width: calc(100% - 420px);
}

.sp-header {
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--border);
}

.sp-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sp-title { font-size: 22px; }
.sp-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

.sp-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  background: rgba(228,211,184,0.35);
  flex-shrink: 0;
}
.sp-close:hover { background: rgba(228,211,184,0.6); color: var(--text); }

.sp-tabs {
  display: flex;
  gap: 2px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.sp-tab {
  padding: 12px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.sp-tab.active {
  color: var(--accent-deep);
  border-bottom-color: var(--accent-deep);
}

.sp-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px 24px;
}

.sp-pane { display: none; }
.sp-pane.active { display: block; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.kpi-card.primary {
  background: linear-gradient(160deg, rgba(255,210,127,0.35), rgba(255,154,91,0.18));
  border-color: rgba(255,154,91,0.4);
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.kpi-value {
  font-family: "Merriweather", serif;
  font-weight: 700;
  font-size: 26px;
  color: var(--accent-deep);
  line-height: 1.1;
}

.kpi-card:not(.primary) .kpi-value {
  font-size: 19px;
  color: var(--text);
}

.kpi-unit {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 3px;
}

.sp-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* charts tab */
.bar-chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.bar-chart-label {
  width: 108px;
  font-size: 12.5px;
  color: var(--text);
  flex-shrink: 0;
  font-weight: 600;
}

.bar-chart-track {
  flex: 1;
  height: 22px;
  background: var(--bg-alt);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-chart-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--accent-2);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
}

.bar-chart-fill.selected { background: var(--accent-deep); }

.bar-chart-fill span {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

/* POIs tab */
.poi-list { display: flex; flex-direction: column; gap: 10px; }

.poi-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.poi-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: rgba(47, 111, 107, 0.14);
  color: var(--business);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.poi-name { font-weight: 600; font-size: 13.5px; color: var(--text); }

.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(47, 111, 107, 0.14);
  color: var(--business);
  margin-top: 3px;
}

.poi-distance {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  flex-shrink: 0;
}

/* Data & sources tab */
.source-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg);
}

.source-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-card p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.provenance-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  background: var(--bg-alt);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 14px;
}

/* Export tab */
.export-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.export-btn:hover { border-color: var(--accent); color: var(--accent-deep); }

.export-btn.primary {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #fff;
}

.export-btn.primary:hover { color: #fff; opacity: 0.92; }

.export-btn svg { color: inherit; }

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: #2B2118;
  color: #FBF3E7;
  padding: 13px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.28);
  z-index: 60;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.toast.is-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast svg { color: var(--success); }

/* Hotspot tooltip */
.maplibregl-popup-content {
  background: var(--panel-bg-solid) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-panel) !important;
  padding: 10px 14px !important;
  font-family: "Inter", sans-serif !important;
  border: 1px solid var(--border);
}

.maplibregl-popup-tip { border-top-color: var(--panel-bg-solid) !important; }

.hs-tip-name { font-weight: 700; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.hs-tip-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.hs-tip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--business);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
}

/* ---------- Landing page ---------- */

.landing { background: var(--bg); }

.landing-header {
  position: sticky;
  top: 16px;
  margin: 0 auto 0;
  width: fit-content;
}

.landing-hero {
  padding: 150px 24px 64px;
  text-align: center;
  max-width: 880px;
  margin: 0 auto;
}

.landing-hero .eyebrow {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 18px;
}

.landing-hero h1 {
  font-size: 52px;
  line-height: 1.12;
  margin-bottom: 20px;
}

.landing-hero h1 .hl { color: var(--accent); }

.landing-hero p.lead {
  font-size: 18px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 640px;
  margin: 0 auto 36px;
}

.landing-cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 26px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14.5px;
}

.btn-primary {
  background: var(--accent-deep);
  color: #fff;
}
.btn-primary:hover { opacity: 0.92; text-decoration: none; }

.btn-secondary {
  background: rgba(139, 62, 47, 0.08);
  color: var(--accent-deep);
  border: 1px solid rgba(139, 62, 47, 0.2);
}
.btn-secondary:hover { text-decoration: none; background: rgba(139, 62, 47, 0.14); }

.entry-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  max-width: 1040px;
  margin: 56px auto 0;
  padding: 0 24px;
}

.entry-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  text-align: left;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.entry-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
}

.entry-card .ec-icon {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: rgba(255, 154, 91, 0.16);
  color: var(--accent-deep);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}

.entry-card.business .ec-icon {
  background: rgba(47, 111, 107, 0.14);
  color: var(--business);
}

.entry-card h3 {
  font-family: "Inter", sans-serif;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.entry-card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.landing-section {
  max-width: 760px;
  margin: 0 auto;
  padding: 88px 24px;
}

.landing-section.alt {
  max-width: none;
  background: var(--bg-alt);
}

.landing-section.alt > .inner {
  max-width: 760px;
  margin: 0 auto;
}

.landing-section h2 {
  font-size: 30px;
  margin-bottom: 20px;
  text-align: center;
}

.landing-section p {
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 16px;
}

.badge-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--accent-deep);
}

.landing-footer {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 56px 24px 28px;
}

.footer-grid {
  max-width: 1040px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 32px;
}

.footer-brand p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.6;
  max-width: 260px;
}

.footer-col h4 {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
  margin: 0 0 14px;
}

.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 10px; }
.footer-col a { font-size: 13.5px; color: var(--muted); }
.footer-col a:hover { color: var(--accent-deep); }

.footer-bottom {
  max-width: 1040px;
  margin: 40px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
}
