* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: #1d2430; }
body { display: flex; }
#sidebar { width: 340px; flex: 0 0 340px; height: 100vh; overflow-y: auto; padding: 16px 18px 24px; background: #f7f8fa; border-right: 1px solid #dfe3e8; }
#map { flex: 1; height: 100vh; }
h1 { font-size: 20px; margin: 0 0 2px; }
.sub { margin: 0 0 8px; color: #5b6573; }
.muted { color: #6b7684; font-size: 12px; }
.stat { margin: 12px 0; padding: 10px 12px; background: #fff; border: 1px solid #dfe3e8; border-radius: 8px; }
.stat #overall-rate { font-size: 28px; font-weight: 600; }
#view-bar { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; }
#view-title { font-weight: 600; }
button { cursor: pointer; padding: 6px 10px; border-radius: 6px; border: 1px solid #c8ced6; background: #fff; }
button:hover { background: #eef1f5; }
fieldset { border: 1px solid #dfe3e8; border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; background: #fff; }
legend { font-weight: 600; padding: 0 4px; }
fieldset label { display: inline-block; margin: 2px 8px 2px 0; white-space: nowrap; }
#months label, #days label { min-width: 62px; }
.btn-group button .rng { white-space: normal; text-align: center; }
#app-types small { color: #6b7684; }
input[type=number] { width: 70px; }
#legend { margin-top: 12px; padding: 10px 12px; background: #fff; border: 1px solid #dfe3e8; border-radius: 8px; }
.legend-title { font-weight: 600; margin-bottom: 6px; }
#legend-scale { display: flex; gap: 2px; }
#legend-scale div { flex: 1; text-align: center; font-size: 11px; padding: 4px 0; color: #fff; text-shadow: 0 0 2px rgba(0,0,0,.6); }
.leaflet-tooltip.rate-tip { font-size: 13px; }
.leaflet-tooltip.rate-tip b { font-size: 14px; }
#point-box { overscroll-behavior: contain; position: absolute; top: 12px; right: 12px; z-index: 1000; width: 330px; max-height: calc(100vh - 24px); overflow-y: auto; background: #fff; border: 1px solid #c8ced6; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.18); padding: 12px 14px; }
#point-box h2 { font-size: 15px; margin: 0 0 6px; display: flex; justify-content: space-between; align-items: center; }
#point-box .big { font-size: 30px; font-weight: 700; }
#point-box table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
#point-box td { padding: 3px 0; border-top: 1px solid #eef0f3; vertical-align: top; }
#point-box th { text-align: left; padding: 8px 0 2px; font-size: 12px; color: #1d2430; border-top: 1px solid #dfe3e8; }
#point-box td:first-child { color: #5b6573; width: 46%; }
#point-box select { width: 100%; margin-top: 2px; }
#point-box .row { display: flex; gap: 8px; margin-top: 8px; }
#point-box .row label { flex: 1; font-size: 12px; color: #5b6573; }
#point-box .close { border: none; background: none; font-size: 18px; cursor: pointer; }
.yes { color: #b30000; font-weight: 600; } .no { color: #1a7f37; font-weight: 600; }

/* muted basemap: desaturate + lighten the raster tiles so the choropleth stands out */
.leaflet-tile-pane { filter: grayscale(1) brightness(1.08) contrast(0.85); }

#point-box .section-title { font-weight: 600; font-size: 13px; margin: 10px 0 2px; }
#point-box .yearchart { width: 100%; height: 90px; display: block; margin: 2px 0; }

/* segmented button group (population density) */
.btn-group { display: flex; gap: 0; border: 1px solid #c8ced6; border-radius: 8px; overflow: hidden; }
.btn-group button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border: none; border-right: 1px solid #c8ced6; border-radius: 0; background: #fff; color: #1d2430; line-height: 1.2; }
.btn-group button:last-child { border-right: none; }
.btn-group button .icon { font-size: 20px; }
.btn-group button .lbl { font-weight: 600; font-size: 12px; text-transform: capitalize; }
.btn-group button .rng { font-size: 10px; color: #6b7684; }
.btn-group button:hover { background: #eef1f5; }
.btn-group button[aria-pressed=true] { background: #2b8cbe; color: #fff; }
.btn-group button[aria-pressed=true] .rng { color: #e3eef7; }

/* ML description box + examples popover */
#ml-desc-wrap { margin-top: 8px; position: relative; }
.desc-label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.desc-label #desc-count { margin-left: auto; font-weight: 400; }
#ml-description { width: 100%; margin-top: 4px; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid #c8ced6; border-radius: 6px; resize: vertical; }
button.help { width: 18px; height: 18px; padding: 0; border-radius: 50%; font-size: 12px; font-weight: 700; line-height: 16px; }
.popover { position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid #c8ced6; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 8px 10px; font-size: 12px; }
.popover-title { font-weight: 600; margin-bottom: 4px; }
.popover ul { margin: 0; padding-left: 16px; }
.popover li { margin: 3px 0; cursor: pointer; }
.popover li:hover { color: #2b8cbe; }

/* loading indicator */
#loading { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; background: #1d2430; color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
#loading[hidden] { display: none; }
.spinner { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#sidebar.pending .stat { opacity: .55; transition: opacity .2s; }

fieldset.not-used { opacity: .45; }
.ml-hint { font-size: 11px; margin-top: 4px; }
.ml-hint[hidden] { display: none; }

/* about / credits footer at the bottom of the sidebar */
#about { margin-top: 18px; padding-top: 12px; border-top: 1px solid #dfe3e8; color: #5b6573; font-size: 12px; line-height: 1.45; }
#about h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #6b7684; margin: 12px 0 4px; }
#about p { margin: 0 0 6px; }
#about ul { margin: 0; padding-left: 16px; }
#about li { margin: 2px 0; }
#about a { color: #2b6cb0; text-decoration: none; }
#about a:hover { text-decoration: underline; }
