:root {
  --brand: #6E9935;
  --brand-dark: #527526;
  --brand-darker: #3d5c1a;
  --brand-light: #9DC240;
  --brand-muted: #EEF4E6;
  --green-900: #3d5a1c;
  --ink: #0f172a;
  --muted: #56606f;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 4px 20px rgba(0,0,0,0.06);
  --shadow-raised: 0 2px 8px rgba(0,0,0,0.08), 0 8px 32px rgba(0,0,0,0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: 'Inter', system-ui, -apple-system, sans-serif; color: var(--ink); -webkit-font-smoothing: antialiased; }
body {
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(157,194,64,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(110,153,53,0.08) 0%, transparent 55%),
    radial-gradient(ellipse 100% 80% at 50% 50%, #f8faf5 0%, #f0f4f0 100%);
}

/* ── Header — matches platform (fortify green gradient), compact ── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 18px;
  background: linear-gradient(120deg, #4a6f22 0%, #6E9935 62%, #7aab3a 100%);
  box-shadow: 0 2px 12px rgba(82,117,38,0.30);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand img { width: 28px; height: 28px; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(0,0,0,.15)); }
.wordmark { font-size: 18px; letter-spacing: -0.3px; color: #fff; white-space: nowrap; }
.wordmark b { font-weight: 700; }
.wordmark .lite { font-weight: 300; color: rgba(255,255,255,.6); }
.appname {
  margin-left: 4px; padding: 4px 10px; border-radius: 8px;
  background: rgba(255,255,255,.94); color: var(--brand-dark);
  font-size: 12.5px; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.10); white-space: nowrap;
}
.regionpill {
  padding: 4px 10px; border-radius: 8px; background: rgba(0,0,0,.12);
  color: rgba(255,255,255,.85); font-size: 12px; font-weight: 500; white-space: nowrap;
}
#aboutBtn {
  flex: none; background: rgba(255,255,255,.10); color: #fff;
  border: 1px solid rgba(255,255,255,.28); border-radius: 9px;
  padding: 6px 14px; font-size: 12.5px; font-weight: 500; font-family: inherit; cursor: pointer;
  transition: background .15s;
}
#aboutBtn:hover { background: rgba(255,255,255,.22); }

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

/* ── Card surfaces — platform card style ── */
#panel {
  position: absolute; top: 70px; left: 14px; z-index: 10; width: 248px;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 14px; box-shadow: var(--shadow-card); border: 1px solid rgba(255,255,255,0.7);
  padding: 12px 14px; max-height: calc(100% - 96px); overflow-y: auto;
}
#panel h2 { margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 600; }
.grp { margin: 12px 0 4px; font-size: 11px; font-weight: 700; color: var(--brand-dark); text-transform: uppercase; letter-spacing: .6px; }
.layerBtn {
  display: block; width: 100%; text-align: left; margin: 3px 0; padding: 7.5px 10px;
  border: 1px solid #e5e9df; border-radius: 9px; background: #fff;
  font-size: 13px; font-family: inherit; cursor: pointer; color: var(--ink);
  transition: border-color .12s, background .12s;
}
.layerBtn:hover { border-color: var(--brand-light); }
.layerBtn.active { background: var(--brand-muted); border-color: var(--brand); font-weight: 600; color: var(--green-900); }

#legend {
  position: absolute; right: 14px; bottom: 26px; z-index: 10;
  background: rgba(255,255,255,0.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 14px; box-shadow: var(--shadow-card); border: 1px solid rgba(255,255,255,0.7);
  padding: 10px 14px; font-size: 12px; min-width: 176px;
}
#legend h3 { margin: 0 0 6px; font-size: 12.5px; color: var(--ink); }
.lrow { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.swatch { width: 16px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.14); flex: none; }
#legend .src { margin-top: 6px; color: var(--muted); font-size: 10.5px; }

.maplibregl-popup-content { font-family: inherit; font-size: 12.5px; border-radius: 12px; padding: 12px 14px; max-height: 320px; overflow-y: auto; box-shadow: var(--shadow-raised); }
.maplibregl-popup-content h3 { margin: 0 0 2px; font-size: 14px; color: var(--brand-dark); }
.maplibregl-popup-content .cty { color: var(--muted); margin: 0 0 8px; }
.maplibregl-popup-content table { border-collapse: collapse; width: 100%; }
.maplibregl-popup-content td { padding: 2.5px 0; }
.maplibregl-popup-content td:last-child { text-align: right; font-weight: 600; padding-left: 14px; }
.maplibregl-popup-content tr.cur td { color: var(--brand-dark); }
.maplibregl-popup-content a { color: var(--brand); }

/* ── About dialog ── */
dialog#aboutDlg {
  max-width: 640px; width: calc(100vw - 48px); border: none; border-radius: 16px;
  padding: 24px 28px; box-shadow: 0 8px 40px rgba(10,20,4,.4);
  max-height: 82vh; overflow-y: auto; font-family: 'Inter', system-ui, sans-serif; color: var(--ink);
}
dialog#aboutDlg::backdrop { background: rgba(20,28,10,.55); }
.dlgHead { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.dlgHead img { width: 30px; height: 30px; }
dialog h2 { margin: 0; color: var(--brand-dark); font-size: 20px; }
dialog h3 { color: var(--brand-dark); font-size: 15px; margin: 18px 0 6px; }
dialog p, dialog li { font-size: 13.5px; line-height: 1.6; color: #26303e; }
dialog ul { padding-left: 20px; margin: 6px 0; }
dialog a { color: var(--brand); }
.srcTable { border-collapse: collapse; width: 100%; font-size: 12.5px; margin: 6px 0 2px; }
.srcTable th { text-align: left; background: var(--brand-muted); color: var(--green-900); padding: 6px 8px; border-bottom: 2px solid var(--brand-light); }
.srcTable td { padding: 6px 8px; border-bottom: 1px solid #edf0e6; vertical-align: top; line-height: 1.45; }
.srcTable tr:nth-child(even) td { background: #fafbf6; }
dialog .attr { color: var(--muted); font-size: 11.5px; }
dialog form { margin-top: 14px; }
dialog form button {
  background: var(--brand-dark); color: #fff; border: none; border-radius: 10px;
  padding: 9px 20px; font-size: 13px; font-family: inherit; font-weight: 500; cursor: pointer;
}
dialog form button:hover { background: var(--brand); }

@media (max-width: 720px) {
  .regionpill, .appname { display: none; }
  #panel { width: 200px; top: 78px; }
}
