.trh-tdw-app {
	--tdw-ink: #1a1a1a;
	--tdw-muted: #5a5a5a;
	--tdw-border: #dcdcdc;
	--tdw-bg-soft: #f7f6f3;
	/* The Rabbit Hole's own brand purple (#661E9A), not an arbitrary plugin
	   color -- used everywhere this app needs an accent (links, active tab,
	   focus rings, the entity picker) so it reads as part of the same site
	   rather than a mismatched red. */
	--tdw-accent: #661E9A;
	--tdw-accent-soft: #f1e7f8;
	--tdw-good: #1f6b3a;
	max-width: 1120px;
	margin: 0 auto;
	padding: 1.5rem 1rem 3rem;
	color: var(--tdw-ink);
	font-size: 16px;
	line-height: 1.5;
}

.trh-tdw-app * { box-sizing: border-box; }

.trh-tdw-hero h1 {
	font-size: 2rem;
	margin: 0 0 0.5rem;
}

.trh-tdw-hero-sub {
	max-width: 68ch;
	color: var(--tdw-muted);
	margin: 0 0 1.5rem;
}

.trh-tdw-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	margin: 0 0 2rem;
}

.trh-tdw-stat {
	background: var(--tdw-bg-soft);
	border: 1px solid var(--tdw-border);
	border-radius: 8px;
	padding: 0.75rem 1rem;
	min-width: 180px;
	flex: 1 1 180px;
}

.trh-tdw-stat dt {
	font-size: 0.8rem;
	color: var(--tdw-muted);
	margin: 0 0 0.25rem;
}

.trh-tdw-stat dd {
	font-size: 1.5rem;
	font-weight: 700;
	margin: 0;
}

.trh-tdw-stat--clickable {
	cursor: pointer;
	transition: background 0.12s, border-color 0.12s;
}

.trh-tdw-stat--clickable:hover {
	background: var(--tdw-accent-soft);
	border-color: var(--tdw-accent);
}

.trh-tdw-stat--clickable:focus-visible {
	outline: 2px solid var(--tdw-accent);
	outline-offset: 2px;
}

.trh-tdw-hero-hint {
	color: var(--tdw-muted);
	font-size: 0.85rem;
	margin: -1rem 0 1.5rem;
}

/* Inline "cell link" buttons: a vendor or agency name inside a data table
 * that drills deeper when clicked. Styled to read as a link, not a button,
 * so it doesn't look out of place inside a dense table row. */
.trh-tdw-cell-link {
	background: none;
	border: none;
	padding: 0;
	margin: 0;
	font: inherit;
	color: inherit;
	text-decoration: underline;
	text-decoration-color: var(--tdw-border);
	text-underline-offset: 2px;
	cursor: pointer;
	text-align: left;
}

.trh-tdw-cell-link:hover,
.trh-tdw-cell-link:focus-visible {
	color: var(--tdw-accent);
	text-decoration-color: var(--tdw-accent);
}

.trh-tdw-plain {
	background: var(--tdw-bg-soft);
	border: 1px solid var(--tdw-border);
	border-radius: 12px;
	padding: 1.5rem 1.5rem 1.75rem;
	margin: 0 0 2rem;
}

.trh-tdw-plain h2 {
	font-size: 1.4rem;
	margin: 0 0 0.6rem;
}

.trh-tdw-entity-picker {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 1rem;
}

.trh-tdw-entity-picker label {
	font-weight: 600;
	font-size: 0.9rem;
}

.trh-tdw-entity-picker select {
	min-width: 220px;
}

/* The hero copy of the picker is the main call-to-action on the page --
   deliberately bigger and more visually distinct than the plain-language
   section's own (identical, same #trh-tdw-budget-entity element) picker, so
   a first-time visitor's eye lands there before anything else. */
.trh-tdw-entity-picker--hero {
	background: var(--tdw-accent-soft);
	border: 1px solid var(--tdw-accent);
	border-radius: 8px;
	padding: 1rem 1.1rem;
	margin: 1.1rem 0 1.4rem;
	align-items: center;
}

.trh-tdw-entity-picker--hero label {
	font-size: 1.05rem;
	color: var(--tdw-ink);
}

.trh-tdw-entity-picker--hero select {
	min-width: 260px;
	font-size: 1rem;
	padding: 0.5rem 0.6rem;
	border: 1px solid var(--tdw-accent);
	border-radius: 6px;
	background: #fff;
}

.trh-tdw-entity-picker--hero select:focus {
	outline: 2px solid var(--tdw-accent);
	outline-offset: 1px;
}

/* Global cross-government search: same accent-bordered treatment as the
   hero entity picker (see above) so it reads as an equally prominent, but
   distinct, way into the data -- one is "pick a government," this is
   "search everything at once, regardless of government." */
.trh-tdw-search-section {
	background: var(--tdw-bg-soft);
	border: 1px solid var(--tdw-accent);
	border-radius: 8px;
	padding: 1.1rem 1.1rem 1.3rem;
	margin: 0 0 1.6rem;
}

.trh-tdw-search-section .trh-tdw-panel-intro { margin-bottom: 0.9rem; }

.trh-tdw-search-controls { margin-bottom: 0.6rem; }

.trh-tdw-search--global {
	width: 100%;
	font-size: 1.05rem;
	padding: 0.65rem 0.85rem;
	border: 1px solid var(--tdw-accent);
}

.trh-tdw-search--global:focus {
	outline: 2px solid var(--tdw-accent);
	outline-offset: 1px;
}

.trh-tdw-search-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.9rem;
}

.trh-tdw-filter--text,
.trh-tdw-filter--num {
	padding: 0.45rem 0.6rem;
	border: 1px solid var(--tdw-border);
	border-radius: 6px;
	font-size: 0.88rem;
	background: #fff;
	width: 130px;
}

.trh-tdw-search-clear {
	padding: 0.45rem 0.8rem;
	border: 1px solid var(--tdw-border);
	background: #fff;
	border-radius: 6px;
	cursor: pointer;
	font-size: 0.85rem;
	color: var(--tdw-muted);
}

.trh-tdw-search-clear:hover { color: var(--tdw-ink); border-color: var(--tdw-ink); }

.trh-tdw-plain .trh-tdw-panel-intro {
	max-width: none;
	font-size: 1rem;
}

.trh-tdw-plain-block {
	margin-top: 1.75rem;
}

.trh-tdw-plain-block h3 {
	font-size: 1.1rem;
	margin: 0 0 0.25rem;
}

.trh-tdw-plain-note {
	color: var(--tdw-muted);
	font-size: 0.9rem;
	margin: 0 0 0.85rem;
	max-width: 68ch;
}

.trh-tdw-bars {
	display: grid;
	gap: 0.55rem;
}

.trh-tdw-bar-row {
	display: grid;
	grid-template-columns: minmax(120px, 220px) 1fr auto;
	align-items: center;
	gap: 0.75rem;
}

.trh-tdw-bar-row--clickable {
	grid-template-columns: minmax(120px, 220px) 1fr auto auto;
	cursor: pointer;
	padding: 0.35rem 0.5rem;
	margin: -0.35rem -0.5rem;
	border-radius: 6px;
	border: 1px solid transparent;
}

.trh-tdw-bar-row--clickable:hover {
	background: var(--tdw-accent-soft);
	border-color: var(--tdw-border);
}

.trh-tdw-bar-row--clickable:focus-visible {
	outline: 2px solid var(--tdw-accent);
	outline-offset: 2px;
}

.trh-tdw-bar-chevron {
	color: var(--tdw-muted);
	font-size: 1.1rem;
	line-height: 1;
	padding-left: 0.15rem;
}

.trh-tdw-bar-row--clickable:hover .trh-tdw-bar-chevron {
	color: var(--tdw-accent);
}

.trh-tdw-bar-label {
	font-size: 0.9rem;
	font-weight: 600;
	overflow-wrap: anywhere;
}

.trh-tdw-bar-sub {
	display: block;
	font-weight: 400;
	color: var(--tdw-muted);
	font-size: 0.78rem;
}

.trh-tdw-bar-track {
	background: #fff;
	border: 1px solid var(--tdw-border);
	border-radius: 5px;
	height: 16px;
	overflow: hidden;
}

.trh-tdw-bar-fill {
	height: 100%;
	background: var(--tdw-accent);
	border-radius: 5px 0 0 5px;
}

.trh-tdw-bar-value {
	font-size: 0.88rem;
	font-weight: 700;
	white-space: nowrap;
	text-align: right;
	min-width: 70px;
}

.trh-tdw-bar-more {
	color: var(--tdw-muted);
	font-size: 0.82rem;
	margin: 0.4rem 0 0;
}

.trh-tdw-detail-intro {
	margin: 0 0 1.25rem;
}

.trh-tdw-detail-intro h2 {
	font-size: 1.25rem;
	margin: 0 0 0.4rem;
}

.trh-tdw-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
	border-bottom: 2px solid var(--tdw-border);
	margin-bottom: 1.25rem;
}

.trh-tdw-tab {
	background: none;
	border: none;
	padding: 0.65rem 1rem;
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--tdw-muted);
	cursor: pointer;
	border-bottom: 3px solid transparent;
	margin-bottom: -2px;
}

.trh-tdw-tab:hover { color: var(--tdw-ink); }

.trh-tdw-tab.is-active {
	color: var(--tdw-accent);
	border-bottom-color: var(--tdw-accent);
}

.trh-tdw-panel-intro {
	max-width: 72ch;
	color: var(--tdw-muted);
	margin: 0 0 1rem;
}

.trh-tdw-controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem;
	margin-bottom: 0.75rem;
}

.trh-tdw-search {
	flex: 1 1 260px;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--tdw-border);
	border-radius: 6px;
	font-size: 0.95rem;
}

.trh-tdw-filter {
	padding: 0.5rem 0.6rem;
	border: 1px solid var(--tdw-border);
	border-radius: 6px;
	font-size: 0.9rem;
	background: #fff;
}

.trh-tdw-count {
	margin-left: auto;
	color: var(--tdw-muted);
	font-size: 0.85rem;
	white-space: nowrap;
}

.trh-tdw-table-wrap {
	overflow-x: auto;
	border: 1px solid var(--tdw-border);
	border-radius: 8px;
}

.trh-tdw-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
	min-width: 640px;
}

.trh-tdw-table thead th {
	position: sticky;
	top: 0;
	background: var(--tdw-bg-soft);
	text-align: left;
	padding: 0.55rem 0.7rem;
	border-bottom: 1px solid var(--tdw-border);
	white-space: nowrap;
	cursor: pointer;
	user-select: none;
}

.trh-tdw-table thead th:hover { color: var(--tdw-accent); }

.trh-tdw-table thead th.trh-tdw-num,
.trh-tdw-table td.trh-tdw-num {
	text-align: right;
}

.trh-tdw-table tbody td {
	padding: 0.5rem 0.7rem;
	border-bottom: 1px solid #eee;
	vertical-align: top;
}

.trh-tdw-table tbody tr:hover { background: #fafafa; }

.trh-tdw-table tbody tr.is-negative td.trh-tdw-num { color: var(--tdw-accent); }

.trh-tdw-empty-row td {
	text-align: center;
	color: var(--tdw-muted);
	padding: 1.5rem 0.7rem;
}

.trh-tdw-src-link {
	font-size: 0.85rem;
	white-space: nowrap;
}

.trh-tdw-pager {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin-top: 0.9rem;
}

.trh-tdw-pager button {
	padding: 0.4rem 0.9rem;
	border: 1px solid var(--tdw-border);
	background: #fff;
	border-radius: 6px;
	cursor: pointer;
	font-size: 0.9rem;
}

.trh-tdw-pager button:disabled {
	opacity: 0.4;
	cursor: default;
}

.trh-tdw-pager span {
	color: var(--tdw-muted);
	font-size: 0.85rem;
}

.trh-tdw-footer {
	margin-top: 2.5rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--tdw-border);
}

.trh-tdw-footer h2 {
	font-size: 1.1rem;
	margin: 0 0 0.75rem;
}

.trh-tdw-sources {
	list-style: none;
	margin: 0 0 1.25rem;
	padding: 0;
	display: grid;
	gap: 0.6rem;
}

.trh-tdw-sources li {
	background: var(--tdw-bg-soft);
	border: 1px solid var(--tdw-border);
	border-radius: 8px;
	padding: 0.7rem 0.9rem;
	font-size: 0.9rem;
	color: var(--tdw-muted);
}

.trh-tdw-sources li strong { color: var(--tdw-ink); }

.trh-tdw-disclaimer {
	font-size: 0.82rem;
	color: var(--tdw-muted);
	max-width: 72ch;
}

.trh-tdw-loading-note {
	color: var(--tdw-muted);
	font-size: 0.85rem;
}

.trh-tdw-app[data-loading="0"] .trh-tdw-loading-note { display: none; }

.trh-tdw-prompt-note {
	color: var(--tdw-muted);
	font-size: 0.85rem;
	font-style: italic;
}

/* -------------------------------------------------- vendor detail modal */

.trh-tdw-modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(20, 18, 16, 0.55);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 4vh 1rem;
	z-index: 100000;
}

.trh-tdw-modal-overlay[hidden] { display: none; }

.trh-tdw-modal {
	position: relative;
	background: #fff;
	color: var(--tdw-ink);
	border-radius: 12px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
	max-width: 920px;
	width: 100%;
	max-height: 92vh;
	overflow-y: auto;
	padding: 2rem 1.75rem 1.75rem;
}

.trh-tdw-modal-close {
	position: absolute;
	top: 0.75rem;
	right: 0.9rem;
	background: none;
	border: none;
	font-size: 1.6rem;
	line-height: 1;
	color: var(--tdw-muted);
	cursor: pointer;
	padding: 0.25rem 0.4rem;
}

.trh-tdw-modal-close:hover { color: var(--tdw-accent); }

.trh-tdw-modal-title {
	font-size: 1.25rem;
	margin: 0 0.5rem 0.4rem 0;
	padding-right: 1.5rem;
}

.trh-tdw-modal-summary {
	color: var(--tdw-muted);
	font-size: 0.92rem;
	margin: 0 0 1.1rem;
}

.trh-tdw-modal-body .trh-tdw-table-wrap {
	max-height: none;
}

.trh-tdw-modal-body .trh-tdw-table { min-width: 720px; }

@media (max-width: 640px) {
	.trh-tdw-hero h1 { font-size: 1.5rem; }
	.trh-tdw-count { margin-left: 0; }
	.trh-tdw-tab { padding: 0.55rem 0.7rem; font-size: 0.85rem; }
	.trh-tdw-filter--text,
	.trh-tdw-filter--num { width: 100%; flex: 1 1 45%; }
	.trh-tdw-plain { padding: 1.1rem 1rem 1.4rem; }
	.trh-tdw-bar-row {
		grid-template-columns: 1fr;
		gap: 0.25rem;
	}
	.trh-tdw-bar-value { text-align: left; }
	.trh-tdw-bar-row--clickable {
		grid-template-columns: 1fr auto;
		grid-template-areas:
			"label chevron"
			"track track"
			"value value";
	}
	.trh-tdw-bar-row--clickable .trh-tdw-bar-label { grid-area: label; }
	.trh-tdw-bar-row--clickable .trh-tdw-bar-chevron { grid-area: chevron; }
	.trh-tdw-bar-row--clickable .trh-tdw-bar-track { grid-area: track; }
	.trh-tdw-bar-row--clickable .trh-tdw-bar-value { grid-area: value; text-align: left; }
	.trh-tdw-modal { padding: 1.75rem 1.1rem 1.25rem; max-height: 96vh; }
	.trh-tdw-modal-overlay { padding: 0 0.5rem; align-items: stretch; }
}
