.todo-sdr-map-app {
	--todo-sdr-accent: #0f5f8f;
	--todo-sdr-accent-dark: #0a4568;
	--todo-sdr-border: #d9e1e7;
	--todo-sdr-bg: #ffffff;
	--todo-sdr-soft: #f4f7f9;
	--todo-sdr-text: #17212b;
	--todo-sdr-muted: #5c6b78;
	--todo-sdr-online: #16834a;
	--todo-sdr-offline: #b33a3a;
	--todo-sdr-unknown: #9a6b05;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 1.25rem 0;
	container-type: inline-size;
	container-name: todo-sdr-map;
	color: var(--todo-sdr-text);
	font: inherit;
}

.todo-sdr-map-app *,
.todo-sdr-map-app *::before,
.todo-sdr-map-app *::after {
	box-sizing: border-box;
}

.todo-sdr-map-toolbar {
	display: grid;
	grid-template-columns: minmax(180px, 1.6fr) repeat(3, minmax(0, 1fr)) max-content;
	gap: 0.55rem;
	align-items: center;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	padding: 0.7rem;
	border: 1px solid var(--todo-sdr-border);
	border-radius: 12px 12px 0 0;
	background: var(--todo-sdr-soft);
}

.todo-sdr-map-field {
	display: block;
	min-width: 0;
	margin: 0;
}

.todo-sdr-map-field,
.todo-sdr-map-field input,
.todo-sdr-map-field select {
	width: 100%;
	max-width: 100%;
}

.todo-sdr-map-field input,
.todo-sdr-map-field select,
.todo-sdr-map-reset {
	min-width: 0;
	max-width: 100%;
	min-height: 42px;
	margin: 0;
	padding: 0.55rem 0.7rem;
	border: 1px solid #b9c5ce;
	border-radius: 7px;
	background: #fff;
	color: var(--todo-sdr-text);
	font: inherit;
	font-size: 0.93rem;
	line-height: 1.2;
}

.todo-sdr-map-field input:focus,
.todo-sdr-map-field select:focus,
.todo-sdr-map-reset:focus,
.todo-sdr-connect-button:focus,
.todo-sdr-copy-button:focus {
	outline: 3px solid rgba(15, 95, 143, 0.25);
	outline-offset: 1px;
	border-color: var(--todo-sdr-accent);
}

.todo-sdr-map-reset {
	cursor: pointer;
	min-width: 76px;
	white-space: nowrap;
	font-weight: 700;
	color: var(--todo-sdr-accent-dark);
}

.todo-sdr-map-reset:hover {
	background: #e9f2f7;
}

.todo-sdr-map-summary {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.55rem 1rem;
	min-height: 44px;
	padding: 0.55rem 0.85rem;
	border-right: 1px solid var(--todo-sdr-border);
	border-left: 1px solid var(--todo-sdr-border);
	background: var(--todo-sdr-bg);
	font-size: 0.9rem;
}

.todo-sdr-map-summary-pills {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.todo-sdr-summary-pill {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.18rem 0.5rem;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 700;
	background: #eef2f4;
}

.todo-sdr-summary-pill::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: currentColor;
}

.todo-sdr-summary-pill--online { color: var(--todo-sdr-online); }
.todo-sdr-summary-pill--offline { color: var(--todo-sdr-offline); }
.todo-sdr-summary-pill--unknown { color: var(--todo-sdr-unknown); }

.todo-sdr-map-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	height: var(--todo-sdr-map-height, 620px);
	min-height: 360px;
	border: 1px solid var(--todo-sdr-border);
	border-radius: 0 0 12px 12px;
	overflow: hidden;
	background: var(--todo-sdr-bg);
}

.todo-sdr-map-canvas {
	width: 100%;
	height: 100%;
	min-height: 360px;
	background: #dce8ee;
	z-index: 1;
}

.todo-sdr-popup-actions {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.45rem;
	margin-top: 0.8rem;
}

.todo-sdr-popup-actions--spyserver {
	grid-template-columns: minmax(0, 1fr);
}

.todo-sdr-connect-button,
.todo-sdr-copy-button {
	display: flex;
	justify-content: center;
	align-items: center;
	width: 100%;
	min-width: 0;
	min-height: 44px;
	margin: 0;
	padding: 0.65rem 0.75rem;
	border: 1px solid var(--todo-sdr-accent);
	border-radius: 7px;
	font: inherit;
	font-size: 0.82rem;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
}

.todo-sdr-connect-button {
	background: var(--todo-sdr-accent);
	color: #fff !important;
	text-decoration: none !important;
}

.todo-sdr-copy-button {
	cursor: pointer;
	background: #fff;
	color: var(--todo-sdr-accent-dark);
}

.todo-sdr-connect-button:hover {
	background: var(--todo-sdr-accent-dark);
	color: #fff !important;
}

.todo-sdr-copy-button:hover:not(:disabled) {
	background: #e9f2f7;
}

.todo-sdr-copy-button:disabled {
	cursor: wait;
	opacity: 0.72;
}

.todo-sdr-status {
	display: inline-flex;
	align-items: center;
	gap: 0.28rem;
	white-space: nowrap;
	font-size: 0.72rem;
	font-weight: 700;
	color: var(--todo-sdr-unknown);
}

.todo-sdr-status::before {
	content: "";
	flex: 0 0 auto;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
}

.todo-sdr-status--online { color: var(--todo-sdr-online); }
.todo-sdr-status--offline { color: var(--todo-sdr-offline); }
.todo-sdr-status--unknown { color: var(--todo-sdr-unknown); }

/* Leaflet markers */
.todo-sdr-marker-shell {
	background: transparent;
	border: 0;
}

.todo-sdr-marker {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: 3px solid #fff;
	border-radius: 50% 50% 50% 0;
	background: var(--todo-sdr-unknown);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
	transform: rotate(-45deg);
}

.todo-sdr-marker::after {
	content: "";
	position: absolute;
	inset: 3px;
	border: 1px solid rgba(255, 255, 255, 0.55);
	border-radius: 50%;
}

.todo-sdr-marker-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #fff;
	transform: rotate(45deg);
}

.todo-sdr-marker--online { background: var(--todo-sdr-online); }
.todo-sdr-marker--offline { background: var(--todo-sdr-offline); }
.todo-sdr-marker--unknown { background: var(--todo-sdr-unknown); }

.todo-sdr-cluster {
	display: flex;
	align-items: center;
	justify-content: center;
	border: 4px solid rgba(255, 255, 255, 0.85);
	border-radius: 50%;
	background: rgba(15, 95, 143, 0.92);
	box-shadow: 0 2px 9px rgba(0, 0, 0, 0.35);
	color: #fff;
	font-size: 0.78rem;
	font-weight: 800;
}

.todo-sdr-cluster--medium { background: rgba(10, 78, 119, 0.94); }
.todo-sdr-cluster--large { background: rgba(5, 56, 87, 0.96); }
.todo-sdr-cluster span { line-height: 1; }

/* Popup */
.todo-sdr-map-app .leaflet-popup-content-wrapper {
	border-radius: 10px;
}

.todo-sdr-map-app .leaflet-popup-content {
	margin: 0;
	width: auto !important;
	font: inherit;
}

.todo-sdr-popup {
	padding: 1rem;
	min-width: 235px;
	max-width: 340px;
}

.todo-sdr-popup-title {
	margin: 0 0 0.35rem;
	font-size: 1rem;
	line-height: 1.3;
}

.todo-sdr-popup-location {
	margin: 0.45rem 0;
	color: var(--todo-sdr-muted);
	font-size: 0.85rem;
}

.todo-sdr-popup-meta {
	display: grid;
	gap: 0.3rem;
	margin: 0.7rem 0;
	font-size: 0.8rem;
}

.todo-sdr-popup-meta-row {
	display: grid;
	grid-template-columns: minmax(70px, auto) 1fr;
	gap: 0.55rem;
}

.todo-sdr-popup-meta dt {
	font-weight: 700;
}

.todo-sdr-popup-meta dd {
	min-width: 0;
	margin: 0;
	overflow-wrap: anywhere;
	color: var(--todo-sdr-muted);
}

.todo-sdr-external-client-note,
.todo-sdr-http-note {
	margin: 0.5rem 0 0;
	color: var(--todo-sdr-muted);
	font-size: 0.72rem;
	line-height: 1.35;
}

.todo-sdr-map-app--error .todo-sdr-map-summary {
	color: var(--todo-sdr-offline);
	font-weight: 700;
}

.todo-sdr-map-data-credit {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 0.25rem 0.8rem;
	margin: 0.5rem 0.15rem 0;
	color: var(--todo-sdr-muted);
	font-size: 0.72rem;
	line-height: 1.4;
	text-align: right;
}

.todo-sdr-map-data-credit a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/*
 * WordPress themes often place the shortcode in a narrow content column while
 * the browser window remains wide. Container queries use the map's real width,
 * so the controls never extend beyond the map border.
 */
@container todo-sdr-map (max-width: 760px) {
	.todo-sdr-map-toolbar {
		grid-template-columns: repeat(6, minmax(0, 1fr));
		grid-template-areas:
			"search search search search search reset"
			"type type status status source source";
		gap: 0.5rem;
		padding: 0.65rem;
	}

	.todo-sdr-map-field--search { grid-area: search; }
	.todo-sdr-map-field--type { grid-area: type; }
	.todo-sdr-map-field--status { grid-area: status; }
	.todo-sdr-map-field--source { grid-area: source; }

	.todo-sdr-map-reset {
		grid-area: reset;
		width: 100%;
		min-width: 0;
	}
}

@container todo-sdr-map (max-width: 520px) {
	.todo-sdr-map-toolbar {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-template-areas:
			"search search"
			"type status"
			"source reset";
		border-radius: 10px 10px 0 0;
	}

	.todo-sdr-map-summary {
		align-items: flex-start;
		flex-direction: column;
	}
}

@container todo-sdr-map (max-width: 360px) {
	.todo-sdr-map-toolbar {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"search"
			"type"
			"status"
			"source"
			"reset";
	}
}

/* Viewport fallback for browsers without container-query support. */
@media (max-width: 760px) {
	.todo-sdr-map-toolbar {
		grid-template-columns: repeat(6, minmax(0, 1fr));
		grid-template-areas:
			"search search search search search reset"
			"type type status status source source";
		gap: 0.5rem;
		padding: 0.65rem;
	}

	.todo-sdr-map-field--search { grid-area: search; }
	.todo-sdr-map-field--type { grid-area: type; }
	.todo-sdr-map-field--status { grid-area: status; }
	.todo-sdr-map-field--source { grid-area: source; }

	.todo-sdr-map-reset {
		grid-area: reset;
		width: 100%;
		min-width: 0;
	}

	.todo-sdr-map-canvas {
		min-height: 360px;
	}
}

@media (max-width: 520px) {
	.todo-sdr-map-toolbar {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-template-areas:
			"search search"
			"type status"
			"source reset";
		border-radius: 10px 10px 0 0;
	}

	.todo-sdr-map-summary {
		align-items: flex-start;
		flex-direction: column;
	}
}

@media (max-width: 360px) {
	.todo-sdr-map-toolbar {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"search"
			"type"
			"status"
			"source"
			"reset";
	}
}
