/* TDE Global Energy Map — app chrome. Dark "data desk" panels in the site's
   Olivin palette (#17191E / #2E323C, #F5C400 accent, Noto Sans). */
.tdem-app {
	--m-bg: rgba(20, 22, 27, .94);
	--m-bg-solid: #17191E;
	--m-line: #2E323C;
	--m-line-2: #3A3F4A;
	--m-text: #C4CAD0;
	--m-muted: #8A939C;
	--m-ink: #FFFFFF;
	--m-accent: #F5C400;
	--m-radius: 4px;
	position: relative;
	width: 100%;
	height: 640px;
	min-height: 420px;
	overflow: hidden;
	background: #0F1115;
	font-family: "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 13px;
	color: var(--m-text);
	isolation: isolate;
}
.tdem-app *, .tdem-app *::before, .tdem-app *::after { box-sizing: border-box; }
.tdem-app.tdem-full { height: calc(100vh - 120px); border-top: 3px solid var(--m-accent); }
.tdem-app.tdem-embed { border-radius: 4px; border: 1px solid #2E323C; }
.tdem-map { position: absolute; inset: 0; }
.tdem-app button { font-family: inherit; }

/* ---------- Panel ---------- */
.tdem-panel {
	position: absolute; z-index: 3; top: 12px; left: 12px; bottom: 12px; width: 300px;
	display: flex; flex-direction: column; background: #15181D; border: 1px solid #262B33;
	border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
	transition: transform .25s ease;
}
.tdem-collapsed .tdem-panel { transform: translateX(calc(-100% - 12px)); }
.tdem-p-head { position: relative; padding: 16px 18px 14px; border-bottom: 1px solid #262B33; border-top: 3px solid var(--m-accent); border-radius: 6px 6px 0 0; }
.tdem-p-brand { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: #8A939C; }
.tdem-app .tdem-p-title { font-size: 18px !important; line-height: 1.25 !important; font-weight: 700 !important; color: #fff !important; margin: 3px 0 4px !important; padding: 0 !important; letter-spacing: -.01em; font-family: inherit !important; text-transform: none !important; }
.tdem-p-sub { color: #7C8590; font-size: 11.5px; line-height: 1.4; }
.tdem-p-toggle { position: absolute; right: -27px; top: 14px; width: 26px; height: 34px; border: 1px solid #262B33; border-left: 0; border-radius: 0 4px 4px 0; background: #15181D; color: #C4CAD0; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.tdem-collapsed .tdem-p-toggle svg { transform: scaleX(-1); }
.tdem-p-body { overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: #343A44 transparent; }

/* Search */
.tdem-search { position: relative; margin: 12px 14px 4px; color: #8A939C; }
.tdem-search > svg { position: absolute; left: 10px; top: 11px; pointer-events: none; }
.tdem-app .tdem-search input { width: 100%; height: 36px; padding: 0 10px 0 32px; background: #0F1115; border: 1px solid #2C323C; border-radius: 4px; color: #fff; font: inherit; font-size: 13px; outline: none; box-shadow: none; margin: 0; }
.tdem-app .tdem-search input::placeholder { color: #6B737D; }
.tdem-app .tdem-search input:focus { border-color: #5A626D; }
.tdem-search-res { display: none; position: absolute; left: 0; right: 0; top: 40px; z-index: 5; background: #15181D; border: 1px solid #2C323C; border-radius: 4px; max-height: 320px; overflow-y: auto; box-shadow: 0 12px 26px rgba(0, 0, 0, .45); }
.tdem-search-res.open { display: block; }
.tdem-search-res button { display: grid; grid-template-columns: 10px 1fr; column-gap: 9px; width: 100%; text-align: left; padding: 8px 12px; background: none; border: 0; border-top: 1px solid #22272F; color: #C4CAD0; cursor: pointer; }
.tdem-search-res button:first-child { border-top: 0; }
.tdem-search-res button:hover, .tdem-search-res button:focus { background: #1C2026; outline: none; }
.tdem-search-res i { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; grid-row: span 2; }
.tdem-search-res b { color: #fff; font-weight: 600; font-size: 13px; }
.tdem-search-res small { color: #8A939C; font-size: 11.5px; }
.tdem-search-res .none { padding: 10px 12px; color: #8A939C; }

/* Sections */
.tdem-p-sec { border-top: 1px solid #22272F; }
.tdem-p-sec:first-child { border-top: 0; }
.tdem-p-sec > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 12px 18px; cursor: pointer; user-select: none; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #9AA3AB; }
.tdem-p-sec > summary::-webkit-details-marker { display: none; }
.tdem-p-sec > summary span { flex: 1; }
.tdem-p-sec > summary:hover { color: #fff; }
.tdem-p-sec > summary .chev { transition: transform .2s; color: #6B737D; }
.tdem-p-sec[open] > summary .chev { transform: rotate(180deg); }
.tdem-p-in { padding: 0 18px 14px; }
.tdem-p-sec.dim .tdem-p-in { opacity: .4; pointer-events: none; }
.tdem-sub { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 6px; font-size: 11.5px; font-weight: 600; color: #7C8590; }
.tdem-sub:first-child { margin-top: 0; }
.tdem-quick { display: flex; gap: 10px; }
.tdem-app .tdem-quick button { background: none; border: 0; padding: 0; color: #8A939C; font-size: 11.5px; font-weight: 600; cursor: pointer; text-decoration: underline; text-decoration-color: #3A404A; text-underline-offset: 2px; }
.tdem-app .tdem-quick button:hover { color: #fff; }
.tdem-p-note { color: #7C8590; font-size: 11.5px; margin-top: 8px; line-height: 1.45; }
.tdem-p-foot { padding: 12px 18px 14px; border-top: 1px solid #22272F; font-size: 11px; color: #6B737D; line-height: 1.5; }
.tdem-p-foot a { color: #9AA3AB; text-decoration: none; }
.tdem-p-foot a:hover { color: #fff; }

/* Checkbox rows */
.tdem-layer, .tdem-check { position: relative; display: flex; align-items: center; gap: 9px; padding: 5px 0; cursor: pointer; user-select: none; font-size: 13px; color: #E6E9EC; line-height: 1.3; }
.tdem-layer input, .tdem-check input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.tdem-layer .box, .tdem-check .box { flex: none; width: 14px; height: 14px; border: 1.5px solid #4A515C; border-radius: 3px; background: transparent; transition: background .12s, border-color .12s; position: relative; }
.tdem-layer input:checked + .box, .tdem-check input:checked + .box { background: var(--m-accent); border-color: var(--m-accent); }
.tdem-layer input:checked + .box::after, .tdem-check input:checked + .box::after { content: ""; position: absolute; left: 3.5px; top: .5px; width: 4px; height: 8px; border: solid #111; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tdem-layer input:focus-visible + .box, .tdem-check input:focus-visible + .box { outline: 2px solid #5A626D; outline-offset: 2px; }
.tdem-layer input:not(:checked) ~ .nm, .tdem-check input:not(:checked) ~ span { color: #7C8590; }
.tdem-layer input:not(:checked) ~ .sym { opacity: .4; }
.tdem-layer .sym { flex: none; width: 16px; height: 12px; display: flex; }
.tdem-layer .nm { flex: 1; }
.tdem-layer .ct { color: #6B737D; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tdem-layer:hover .nm, .tdem-check:hover span { color: #fff; }
.tdem-checks { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
.tdem-check { font-size: 12.5px; }
.tdem-check .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-left: -2px; }
.tdem-check .ss { flex: none; width: 9px; height: 9px; border-radius: 50%; box-sizing: border-box; margin-left: -2px; }
.tdem-app select.tdem-cap { width: 100%; height: 32px; padding: 0 28px 0 10px; background: #0F1115 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Cpath d='M2 3.5l3 3 3-3' fill='none' stroke='%238A939C' stroke-width='1.5'/%3E%3C/svg%3E") right 10px center no-repeat; border: 1px solid #2C323C; border-radius: 4px; color: #E6E9EC; font: inherit; font-size: 12.5px; appearance: none; -webkit-appearance: none; margin: 0; box-shadow: none; }

/* Current view */
.tdem-vs { margin: 0; }
.tdem-vs > div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid #22272F; font-size: 12.5px; }
.tdem-vs dt { color: #8A939C; margin: 0; }
.tdem-vs dd { color: #fff; margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.tdem-vs-bar { display: flex; height: 6px; border-radius: 1px; overflow: hidden; margin: 12px 0 8px; background: #0F1115; }
.tdem-vs-bar span { height: 100%; }
.tdem-app table.tdem-vs-mix { width: 100%; border-collapse: collapse !important; border: 0 !important; margin: 0 !important; font-size: 12px; background: transparent !important; }
.tdem-app table.tdem-vs-mix tr, .tdem-app table.tdem-vs-mix td { background: transparent !important; border: 0 !important; padding: 3px 0 !important; color: #C4CAD0 !important; }
.tdem-app table.tdem-vs-mix td:nth-child(2), .tdem-app table.tdem-vs-mix td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; padding-left: 8px !important; }
.tdem-app table.tdem-vs-mix td:nth-child(3) { color: #7C8590 !important; width: 38px; }
.tdem-vs-mix i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 0; }

/* Voltage legend */
.tdem-volts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12px; color: #C4CAD0; }
.tdem-volts > div { display: flex; align-items: center; gap: 8px; }
.tdem-volts i { flex: none; width: 18px; height: 3px; border-radius: 1px; }
.tdem-volts i.dc { background: repeating-linear-gradient(90deg, #FFE066 0 5px, transparent 5px 8px); }

/* Segmented */
.tdem-seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #2C323C; border-radius: 4px; overflow: hidden; }
.tdem-app .tdem-seg button { background: transparent; border: 0; border-left: 1px solid #2C323C; color: #9AA3AB; padding: 7px 0; font-weight: 600; font-size: 12px; cursor: pointer; border-radius: 0; }
.tdem-app .tdem-seg button:first-child { border-left: 0; }
.tdem-app .tdem-seg button:hover { color: #fff; }
.tdem-app .tdem-seg button.on { background: #2A2F38 !important; color: #fff !important; box-shadow: inset 0 -2px 0 var(--m-accent); }

/* ---------- Detail card ---------- */
.tdem-detail {
	position: absolute; z-index: 4; top: 12px; right: 56px; width: 360px; max-height: calc(100% - 24px); overflow-y: auto;
	background: var(--m-bg); border: 1px solid var(--m-line); border-radius: var(--m-radius); box-shadow: inset 4px 0 0 var(--m-accent), 0 10px 30px rgba(0, 0, 0, .4);
	padding: 16px 18px 14px 20px; transform: translateX(calc(100% + 80px)); transition: transform .25s ease; backdrop-filter: blur(6px);
	scrollbar-width: thin; scrollbar-color: #3A3F4A transparent;
}
.tdem-detail-open .tdem-detail { transform: none; }
.tdem-d-close { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; background: transparent; color: var(--m-muted); font-size: 22px; line-height: 1; cursor: pointer; border-radius: 3px; }
.tdem-d-close:hover { color: var(--m-ink); background: rgba(255, 255, 255, .06); }
.tdem-d-kicker { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--m-muted); display: flex; align-items: center; gap: 7px; padding-right: 30px; }
.tdem-d-kicker i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.tdem-d-title { font-size: 19px !important; line-height: 1.25; color: var(--m-ink) !important; margin: 6px 0 3px !important; font-weight: 700; font-family: inherit !important; padding-right: 20px; }
.tdem-d-loc { color: var(--m-muted); font-size: 12.5px; margin-bottom: 12px; }
.tdem-d-stats { display: flex; border-top: 1px solid var(--m-line); border-bottom: 1px solid var(--m-line); margin-bottom: 10px; }
.tdem-d-stats div { flex: 1; padding: 9px 10px 8px 0; margin-right: 10px; border-right: 1px solid var(--m-line); min-width: 0; }
.tdem-d-stats div:last-child { border-right: 0; margin-right: 0; }
.tdem-d-stats b { display: block; color: var(--m-ink); font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.tdem-d-stats small { color: var(--m-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.tdem-d-stats .sg-operating { color: #4ADE80; }
.tdem-d-stats .sg-construction { color: var(--m-accent); }
.tdem-d-stats .sg-planned { color: #9EC0FF; }
.tdem-d-stats .sg-paused { color: #CDB6F2; }
.tdem-d-stats .sg-retired, .tdem-d-stats .sg-cancelled { color: #9CA3AF; }
.tdem-d-row { display: grid; grid-template-columns: 100px 1fr; gap: 8px; padding: 5px 0; font-size: 12.5px; }
.tdem-d-row span { color: var(--m-muted); }
.tdem-d-row b { color: var(--m-ink); font-weight: 500; }
.tdem-d-hint { font-size: 11px; color: var(--m-muted); margin: -2px 0 6px 108px; font-style: italic; }
.tdem-d-sum { margin: 10px 0 4px; line-height: 1.55; font-size: 13px; }
.tdem-d-sec { margin-top: 12px; }
.tdem-d-h { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--m-ink); margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.tdem-d-h::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--m-accent); }
.tdem-d-why { list-style: none; margin: 0; padding: 0; }
.tdem-d-why li { position: relative; padding: 6px 0 6px 16px; line-height: 1.5; border-top: 1px solid var(--m-line); font-size: 12.5px; }
.tdem-d-why li:first-child { border-top: 0; }
.tdem-d-why li::before { content: ""; position: absolute; left: 0; top: 14px; width: 8px; height: 2px; background: var(--m-accent); }
.tdem-app table.tdem-d-units { width: 100% !important; border-collapse: collapse !important; border: 0 !important; margin: 0 !important; font-size: 12px; background: transparent !important; table-layout: auto; }
.tdem-app table.tdem-d-units tr, .tdem-app table.tdem-d-units tbody tr:nth-child(odd), .tdem-app table.tdem-d-units tbody tr:nth-child(even) { background: transparent !important; }
.tdem-app table.tdem-d-units th, .tdem-app table.tdem-d-units td { background: transparent !important; border: 0 !important; border-bottom: 1px solid var(--m-line) !important; padding: 6px 8px !important; text-align: left; vertical-align: middle; font-family: inherit; }
.tdem-app table.tdem-d-units th { color: var(--m-muted) !important; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border-bottom: 1px solid var(--m-line-2) !important; }
.tdem-app table.tdem-d-units td { color: #E6E9EC !important; font-variant-numeric: tabular-nums; }
.tdem-app table.tdem-d-units tbody tr:hover td { background: rgba(255, 255, 255, .04) !important; }
.tdem-app table.tdem-d-units .r { text-align: right; white-space: nowrap; }
.tdem-app table.tdem-d-units th:first-child, .tdem-app table.tdem-d-units td:first-child { padding-left: 0 !important; }
.tdem-app table.tdem-d-units th:last-child, .tdem-app table.tdem-d-units td:last-child { padding-right: 0 !important; }
.tdem-app .tdem-d-units .st { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 3px; background: #2E323C; color: #C4CAD0; white-space: nowrap; }
.tdem-app .tdem-d-units .st-operating { background: rgba(34, 197, 94, .16); color: #6EE7A0; }
.tdem-app .tdem-d-units .st-construction { background: rgba(245, 196, 0, .16); color: #F5C400; }
.tdem-app .tdem-d-units .st-planned { background: rgba(96, 150, 240, .18); color: #9EC0FF; }
.tdem-app .tdem-d-units .st-paused { background: rgba(160, 120, 220, .18); color: #CDB6F2; }
.tdem-app .tdem-d-units .st-retired { background: #2E323C; color: #9CA3AF; }
.tdem-d-more { color: var(--m-muted); font-size: 11.5px; margin-top: 4px; }
.tdem-d-actions { display: flex; gap: 8px; margin-top: 14px; }
.tdem-d-btn { flex: 1; display: inline-flex; justify-content: center; align-items: center; height: 36px; border-radius: var(--m-radius); border: 1px solid var(--m-line-2); background: transparent; color: var(--m-ink) !important; font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none !important; }
.tdem-d-btn.primary { background: var(--m-accent); border-color: var(--m-accent); color: #111 !important; }
.tdem-d-btn:hover { filter: brightness(1.08); }
.tdem-d-src { margin-top: 12px; font-size: 11px; color: var(--m-muted); }
.tdem-d-load { padding: 18px 4px; color: var(--m-muted); display: flex; align-items: center; gap: 10px; }

/* Tooltip & status */
.tdem-tip { position: absolute; z-index: 6; pointer-events: none; background: rgba(15, 17, 21, .96); border: 1px solid var(--m-line-2); border-left: 3px solid var(--m-accent); border-radius: 3px; padding: 7px 10px; max-width: 280px; opacity: 0; transform: translateY(4px); transition: opacity .1s, transform .1s; }
.tdem-tip.show { opacity: 1; transform: none; }
.tdem-tip b { display: block; color: var(--m-ink); font-size: 12.5px; }
.tdem-tip span { color: var(--m-muted); font-size: 11.5px; }
.tdem-toast { position: absolute; z-index: 5; left: 50%; bottom: 26px; transform: translate(-50%, 20px); opacity: 0; background: rgba(15, 17, 21, .95); border: 1px solid var(--m-line-2); border-radius: 999px; padding: 7px 14px; color: var(--m-ink); font-size: 12px; display: flex; align-items: center; gap: 8px; transition: all .2s; pointer-events: none; white-space: nowrap; }
.tdem-toast.show { opacity: 1; transform: translate(-50%, 0); }
.spin { width: 13px; height: 13px; border: 2px solid rgba(245, 196, 0, .25); border-top-color: var(--m-accent); border-radius: 50%; animation: tdem-spin .7s linear infinite; display: inline-block; }
@keyframes tdem-spin { to { transform: rotate(360deg); } }

/* MapLibre controls in theme */
.tdem-app .maplibregl-ctrl-group { background: var(--m-bg-solid); border: 1px solid var(--m-line); border-radius: var(--m-radius); box-shadow: none; }
.tdem-app .maplibregl-ctrl-group button { width: 34px; height: 34px; }
.tdem-app .maplibregl-ctrl-group button + button { border-top: 1px solid var(--m-line); }
.tdem-app .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(.9); }
.tdem-app .maplibregl-ctrl-group button:hover { background-color: rgba(245, 196, 0, .12); }
.tdem-app .maplibregl-ctrl-attrib { background: rgba(15, 17, 21, .75); color: var(--m-muted); font-size: 10.5px; }
.tdem-app .maplibregl-ctrl-attrib a { color: var(--m-text); }
.tdem-app .maplibregl-ctrl-attrib-button { filter: invert(1); }
.tdem-app .maplibregl-ctrl-scale { background: rgba(15, 17, 21, .7); color: var(--m-text); border-color: var(--m-muted); }
.tdem-app .maplibregl-cooperative-gesture-screen { font-family: inherit; }
.tdem-mob-btn { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
	.tdem-app.tdem-full { height: calc(100vh - 70px); }
	.tdem-panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 72%; border-radius: 10px 10px 0 0; transform: translateY(100%); }
	.tdem-panel-open .tdem-panel { transform: none; }
	.tdem-p-toggle { display: none; }
	.tdem-mob-btn { display: inline-flex; align-items: center; gap: 7px; position: absolute; z-index: 3; left: 12px; top: 12px; height: 36px; padding: 0 14px; background: #15181D; color: #fff; border: 1px solid #2C323C; border-radius: 4px; font-weight: 600; font-size: 13px; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
	.tdem-panel-open .tdem-mob-btn { display: none; }
	.tdem-detail { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 64%; border-radius: 10px 10px 0 0; transform: translateY(105%); box-shadow: inset 0 3px 0 var(--m-accent), 0 -10px 30px rgba(0, 0, 0, .4); padding-left: 18px; }
	.tdem-detail-open .tdem-detail { transform: none; }
	.tdem-toast { bottom: auto; top: 60px; }
	.tdem-tip { display: none; }
}

/* Hide theme floating widgets over the full-screen map */
body.tdem-view-map .sticky-left-buttons, body.tdem-view-map .scroll-to-top, body.tdem-view-map #scroll-top { display: none !important; }

/* Guard the app chrome against theme typography/table/button defaults */
.tdem-app h2, .tdem-app h3 { text-transform: none; letter-spacing: -.01em; }
.tdem-app ul, .tdem-app li { list-style: none !important; margin-left: 0 !important; }
.tdem-app li::marker { content: none; }
.tdem-app button:not(.maplibregl-ctrl-icon) { text-transform: none; letter-spacing: normal; box-shadow: none; line-height: 1.2; min-height: 0; }
.tdem-app .tdem-d-btn.primary { background: var(--m-accent) !important; color: #111 !important; }
.tdem-app input[type=search] { box-shadow: none; }
.tdem-app p, .tdem-app li, .tdem-app .tdem-d-sum, .tdem-app .tdem-d-why li, .tdem-app .tdem-p-note { color: var(--m-text) !important; }
.tdem-app .tdem-d-sum { color: #D5DAE0 !important; }
.tdem-app .tdem-d-row b, .tdem-app .tdem-d-title, .tdem-app .tdem-p-title { color: var(--m-ink) !important; }
.tdem-app .tdem-d-loc, .tdem-app .tdem-d-src, .tdem-app .tdem-d-hint, .tdem-app .tdem-d-row span { color: var(--m-muted) !important; }

/* Detail card: same restrained treatment as the panel */
.tdem-detail { background: #15181D; border: 1px solid #262B33; border-top: 3px solid var(--m-accent); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); backdrop-filter: none; padding: 16px 18px 14px; }
.tdem-d-h { color: #9AA3AB !important; letter-spacing: .08em; }
.tdem-d-h::before { display: none; }
.tdem-d-why li::before { background: #4A515C; }
.tdem-d-kicker { color: #9AA3AB; letter-spacing: .08em; }
@media (max-width: 760px) { .tdem-detail { border-radius: 10px 10px 0 0; } .tdem-panel { border-radius: 10px 10px 0 0; } }
