:root {
	--bg: #ffffff;
	--fg: #1f2933;
	--muted: #5f6b76;
	--line: #d9dee3;
	--accent: #2e7d5b;
	--accent-soft: #e6f2ec;
	--warn-bg: #fff4d6;
	--warn-fg: #6b4e00;
	--danger-bg: #7a1111;
	--panel-w: 320px;
	--details-w: 380px;
	--topbar-h: 48px;
	font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans Arabic", Tahoma, sans-serif;
	color: var(--fg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { display: flex; flex-direction: column; overflow: hidden; }
button, input, select { font: inherit; }
:focus-visible { outline: 3px solid #1d5fbf; outline-offset: 2px; }

.topbar {
	height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 8px;
	padding-inline: 8px; background: var(--accent); color: #fff;
}
.topbar .title { font-size: 1.05rem; margin: 0; flex: 1; font-weight: 600; }
.icon-btn {
	background: transparent; border: 0; color: inherit; cursor: pointer; border-radius: 6px;
	min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.icon-btn.small { min-width: 28px; min-height: 28px; font-size: 1rem; color: var(--muted); }
.icon-btn:hover { background: rgba(0, 0, 0, 0.08); }
.text-btn { background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.5); color: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.link-btn { background: none; border: 0; padding: 0; color: #1d5fbf; text-decoration: underline; cursor: pointer; text-align: start; }

.tier-banner { background: var(--danger-bg); color: #fff; padding: 6px 12px; font-weight: 600; font-size: 0.9rem; }

.layout { flex: 1; position: relative; display: flex; min-height: 0; }
.map { flex: 1; min-width: 0; }

.panel {
	width: var(--panel-w); flex: none; overflow-y: auto; border-inline-end: 1px solid var(--line);
	padding: 12px; background: var(--bg); z-index: 2;
}
.panel.collapsed { display: none; }
.panel h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 8px 0; }

.layer { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.layer.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.layer-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px; }
.layer-head .check { flex: 1; }
.layer-controls { padding: 0 10px 10px; border-top: 1px solid var(--line); }
.check, .radio { display: flex; align-items: center; gap: 8px; cursor: pointer; min-height: 32px; }
.check input, .radio input { width: 18px; height: 18px; accent-color: var(--accent); }
.basemaps { display: grid; gap: 2px; }
.field { display: grid; gap: 4px; margin-top: 8px; }
.field select, .filter input { width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.filter { border: 0; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.filter label { display: grid; gap: 2px; }

.legend { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; font-size: 0.85rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.swatch { width: 16px; height: 16px; border-radius: 3px; flex: none; border: 1px solid rgba(0, 0, 0, 0.25); }
.swatch.round { border-radius: 50%; }

.details {
	width: var(--details-w); flex: none; overflow: hidden; display: flex; flex-direction: column;
	border-inline-start: 1px solid var(--line); background: var(--bg); z-index: 2;
}
.details[hidden] { display: none; }
.details-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.details-head h2 { flex: 1; margin: 0; font-size: 1.05rem; }
.details-body { overflow-y: auto; padding: 12px; }
.details-body h3 { font-size: 0.9rem; margin: 14px 0 6px; }
.lead { font-size: 1rem; font-weight: 600; margin: 0 0 4px; }
.precision { background: var(--warn-bg); color: var(--warn-fg); padding: 4px 8px; border-radius: 6px; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.group { border-top: 1px solid var(--line); padding: 6px 0; }
.group > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.indicator { margin: 8px 0 12px; }
.indicator h4 { margin: 0 0 4px; font-size: 0.88rem; }
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; }
.bars li { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; font-size: 0.82rem; }
.bar-track { height: 10px; background: #eef1f4; border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; }
.bar-value { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.status-line { color: var(--muted); margin: 4px 0 0; }

.props { margin: 0; display: grid; gap: 4px; }
.props .row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; font-size: 0.85rem; border-bottom: 1px dotted var(--line); padding: 3px 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; overflow-wrap: anywhere; }
.identity { background: #fdecec; border-radius: 6px; padding: 6px; }
.caveats { padding-inline-start: 18px; font-size: 0.85rem; }
.place-list { padding-inline-start: 18px; }
.place-list li { margin: 4px 0; }

.filters { margin-top: 8px; }
.filters > summary { cursor: pointer; font-weight: 600; font-size: 0.88rem; padding: 4px 0; }
.filters input[type=search] { width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 6px; }
.insight-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.insight-card h4 { margin: 0 0 4px; font-size: 0.92rem; display: flex; align-items: center; gap: 6px; }
.traits { padding-inline-start: 18px; margin: 4px 0; font-size: 0.84rem; }
.findings { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 10px; }
.or-row { display: grid; grid-template-columns: 120px 1fr; gap: 8px; align-items: center; margin-top: 2px; }
.or-track { position: relative; height: 12px; background: #eef1f4; border-radius: 6px; display: block; }
.or-one { position: absolute; inset-block: -2px; inset-inline-start: 50%; width: 2px; background: #888; }
.or-ci { position: absolute; inset-block: 4px; height: 4px; background: #1d5fbf; border-radius: 2px; }
.or-dot { position: absolute; top: 1px; width: 10px; height: 10px; margin-inline-start: -5px; border-radius: 50%; background: #0b3d91; }
.text-btn[hidden] { display: none; }

.legend li.with-count { display: grid; grid-template-columns: 16px minmax(0, 1fr) 48px 28px; gap: 6px; align-items: center; }
.legend-bar { height: 8px; background: #eef1f4; border-radius: 4px; overflow: hidden; display: block; }
.legend-bar > span { display: block; height: 100%; }
.legend-count { font-variant-numeric: tabular-nums; text-align: end; color: var(--muted); }
.cluster-donut { pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35)); }
.cluster-donut svg { display: block; }

.about { border-top: 1px solid var(--line); margin-top: 8px; }
.about p { margin: 4px 0 8px; line-height: 1.45; }
.noscript { padding: 16px; max-width: 60ch; }

.status {
	position: absolute; inset-block-end: 12px; inset-inline-start: 50%; transform: translateX(-50%);
	background: rgba(31, 41, 51, 0.88); color: #fff; padding: 4px 12px; border-radius: 12px; font-size: 0.85rem; z-index: 5;
}
.status:empty { display: none; }

@media (max-width: 720px) {
	:root { --panel-w: 100%; --details-w: 100%; }
	.layout { flex-direction: column; }
	.panel, .details {
		position: absolute; inset-inline: 0; inset-block-end: 0; max-height: 60%;
		border: 0; border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
	}
	.details { z-index: 3; }
}
