/* Truck Hunter dashboard. Everything is scoped to .th-app so it doesn't fight your theme. */

.th-app {
	--th-ink: #16181d;
	--th-muted: #4b5160;
	--th-line: #cfd3dc;
	--th-card: #ffffff;
	--th-soft: #f3f4f7;
	--th-focus: #1849c9;
	--th-pass: #0b6b2c;
	--th-fail: #a4161a;
	--th-unknown: #5a6070;
	--th-match: #0b6b2c;
	--th-strong: #1849c9;
	--th-possible: #8a4b00;
	--th-warn-bg: #fff4e0;
	--th-warn-line: #c77800;
	color: var(--th-ink);
	font-size: 1rem;
	line-height: 1.5;
	max-width: 1200px;
	margin: 0 auto;
}

.th-app *,
.th-app *::before,
.th-app *::after {
	box-sizing: border-box;
}

.th-app ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.th-app :focus-visible {
	outline: 3px solid var(--th-focus);
	outline-offset: 2px;
}

.th-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ---- scanner status ---------------------------------------------------- */

.th-status {
	border: 2px solid var(--th-line);
	border-left-width: 8px;
	border-radius: 8px;
	background: var(--th-card);
	padding: 12px 16px;
	margin: 0 0 20px;
}
.th-status--ok { border-left-color: var(--th-pass); }
.th-status--busy { border-left-color: var(--th-strong); }
.th-status--warn { border-left-color: var(--th-warn-line); background: var(--th-warn-bg); }
.th-status__line { margin: 0; }
.th-status__line a { margin-left: 6px; }
.th-status__details { margin-top: 8px; color: var(--th-muted); }
.th-status__details li { margin: 4px 0; font-size: 0.95rem; }

.th-app summary {
	cursor: pointer;
	font-weight: 600;
	min-height: 32px;
	padding: 4px 0;
}

.th-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
}
.th-controls form { margin: 0; }
.th-app .th-hint {
	display: block;
	margin: 6px 0 0;
	color: var(--th-muted);
	font-size: 0.95rem;
}
.th-hint-inline { font-weight: 400; color: var(--th-muted); }

.th-flash {
	margin: 0 0 16px;
	padding: 12px 16px;
	border-radius: 8px;
	border: 2px solid var(--th-pass);
	background: #e9f6ee;
	font-weight: 600;
}
.th-flash--error { border-color: var(--th-fail); background: #fdecec; }

/* ---- settings ------------------------------------------------------------ */

.th-settings { max-width: 720px; }
.th-settings h2 { margin: 8px 0 12px; }
.th-fieldset {
	margin: 0 0 20px;
	padding: 12px 16px 16px;
	border: 2px solid var(--th-line);
	border-radius: 10px;
	background: var(--th-card);
}
.th-fieldset legend { padding: 0 6px; font-weight: 700; font-size: 1.05rem; }
.th-truck + .th-truck { border-top: 1px solid var(--th-line); margin-top: 12px; padding-top: 4px; }
.th-app .th-field { margin: 12px 0 0; display: grid; gap: 6px; }
.th-app .th-field > label { font-weight: 600; }
.th-app .th-field--check {
	display: grid;
	grid-template-columns: auto 1fr;
	align-items: start;
	gap: 10px;
}
.th-app .th-field--check > label { font-weight: 400; padding-top: 1px; }
.th-app .th-field--check input {
	width: 22px;
	height: 22px;
	margin: 1px 0 0;
	accent-color: var(--th-ink);
}
.th-app .th-field input[type="text"],
.th-app .th-field input[type="password"],
.th-app .th-field input[type="url"],
.th-app .th-field select,
.th-app .th-field textarea {
	width: 100%;
	max-width: 420px;
	min-height: 44px;
	padding: 8px 10px;
	border: 2px solid var(--th-line);
	border-radius: 8px;
	font: inherit;
	color: var(--th-ink);
	background: var(--th-card);
}
.th-app .th-field textarea { max-width: 100%; font-family: ui-monospace, Consolas, monospace; }
.th-app .th-field input:focus,
.th-app .th-field select:focus,
.th-app .th-field textarea:focus { border-color: var(--th-focus); }
.th-reset { margin-top: 4px; }

/* ---- tabs and filters --------------------------------------------------- */

.th-nav {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin: 0 0 12px;
}
.th-nav .th-tabs { margin: 0; }
.th-more { position: relative; }
.th-app .th-more > summary { list-style: none; cursor: pointer; }
.th-app .th-more > summary::-webkit-details-marker { display: none; }
.th-app .th-more > summary[aria-current="page"] { background: var(--th-ink); border-color: var(--th-ink); color: #ffffff; }
.th-caret { font-size: 0.8em; }
.th-more__list {
	position: absolute;
	z-index: 20;
	top: calc(100% + 6px);
	left: 0;
	min-width: 200px;
	padding: 6px 0 !important;
	background: var(--th-card);
	border: 2px solid var(--th-ink);
	border-radius: 10px;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}
.th-app .th-more__list a {
	display: block;
	min-height: 44px;
	padding: 10px 16px;
	color: var(--th-ink);
	text-decoration: none;
	font-weight: 600;
}
.th-app .th-more__list a:hover, .th-app .th-more__list a[aria-current="page"] { background: var(--th-soft); }
.th-truck-filter {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 0;
}
.th-truck-filter label { font-weight: 600; }
.th-app .th-truck-filter select {
	min-height: 44px;
	padding: 6px 10px;
	border: 2px solid var(--th-line);
	border-radius: 8px;
	font: inherit;
	color: var(--th-ink);
	background: var(--th-card);
	max-width: 70vw;
}
.th-app .th-btn--small { min-height: 44px; padding: 6px 12px; }
.th-js .th-app .th-filter-go { display: none; }   /* picking a truck switches at once */

.th-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 12px;
}
.th-app .th-tab {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-height: 44px;
	padding: 8px 16px;
	border: 2px solid var(--th-line);
	border-radius: 999px;
	background: var(--th-card);
	color: var(--th-ink);
	text-decoration: none;
	font-weight: 600;
}
.th-app .th-tab:hover { border-color: var(--th-ink); }
.th-app .th-tab[aria-current="page"] {
	background: var(--th-ink);
	border-color: var(--th-ink);
	color: #ffffff;
}
.th-tabs--small .th-tab { min-height: 40px; padding: 6px 14px; font-size: 0.95rem; }
.th-count { font-weight: 400; }

.th-legend {
	margin: 4px 0 20px;
	padding: 8px 16px;
	background: var(--th-soft);
	border-radius: 8px;
}
.th-legend li { margin: 6px 0; }
.th-legend p { margin: 8px 0 4px; }

.th-empty {
	padding: 32px 16px;
	text-align: center;
	background: var(--th-soft);
	border-radius: 8px;
	font-size: 1.05rem;
}

/* ---- cards -------------------------------------------------------------- */

.th-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
	gap: 20px;
}

.th-card {
	display: flex;
	flex-direction: column;
	background: var(--th-card);
	border: 2px solid var(--th-line);
	border-radius: 10px;
	overflow: hidden;
}
.th-card.th-is-ruled_out { opacity: 0.72; }
.th-card.th-is-ruled_out .th-title { text-decoration: line-through; }

.th-photo {
	position: relative;
	aspect-ratio: 4 / 3;
	background: var(--th-soft);
}
.th-photo img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	margin: 0;
}
.th-nophoto,
.th-photo--broken::after {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	padding: 16px;
	text-align: center;
	color: var(--th-muted);
}
.th-photo--broken img { display: none; }
.th-photo--broken::after { content: "Photo no longer available. The ad may have been taken down."; }

.th-badge {
	position: absolute;
	top: 10px;
	left: 10px;
	padding: 4px 10px;
	border-radius: 6px;
	font-weight: 700;
	font-size: 0.85rem;
	letter-spacing: 0.04em;
	color: #ffffff;
	background: var(--th-possible);
}
.th-tier-match .th-badge { background: var(--th-match); }
.th-tier-strong .th-badge { background: var(--th-strong); }

.th-body {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px 16px 16px;
	flex: 1;
}
.th-app .th-meta { margin: 0; color: var(--th-muted); font-size: 0.9rem; }
.th-app .th-title { margin: 0; font-size: 1.15rem; line-height: 1.3; }
.th-app .th-price { margin: 0; font-size: 1.15rem; font-weight: 700; }
.th-loc { font-weight: 400; color: var(--th-muted); margin-left: 6px; font-size: 1rem; }
.th-was { font-weight: 600; color: var(--th-pass); margin-left: 6px; font-size: 0.95rem; }
.th-app .th-pricecheck {
	margin: 0;
	padding: 6px 10px;
	border-radius: 6px;
	font-size: 0.95rem;
	border-left: 4px solid var(--th-unknown);
	background: var(--th-soft);
}
.th-app .th-pricecheck--good { border-left-color: var(--th-pass); background: #e9f6ee; }
.th-app .th-pricecheck--high { border-left-color: var(--th-warn-line); background: var(--th-warn-bg); }
.th-pricecheck__basis { color: var(--th-muted); }
.th-app .th-distance { margin: 0; font-weight: 600; }
.th-home form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 8px 0 0; }
.th-phone code { word-break: break-all; }
.th-app .th-legend-like { margin: 0 0 8px; font-size: 1.05rem; }
.th-phone form { margin: 8px 0 0; }
.th-phone p { margin: 0 0 8px; }

.th-checks { display: grid; gap: 4px; }
.th-check {
	display: grid;
	grid-template-columns: 1.4em 1fr;
	align-items: start;
	font-size: 0.95rem;
}
.th-sym { font-weight: 700; text-align: center; }
.th-check--pass .th-sym { color: var(--th-pass); }
.th-check--fail .th-sym { color: var(--th-fail); }
.th-check--unknown .th-sym { color: var(--th-unknown); }
.th-check--unknown { color: var(--th-muted); }

.th-warnings li {
	padding: 8px 10px;
	background: var(--th-warn-bg);
	border-left: 4px solid var(--th-warn-line);
	border-radius: 4px;
	margin: 4px 0;
	font-size: 0.95rem;
}
.th-info { color: var(--th-muted); font-size: 0.9rem; }

.th-app .th-gone {
	margin: 0;
	padding: 8px 10px;
	background: #fdecec;
	border-left: 4px solid var(--th-fail);
	border-radius: 4px;
	font-size: 0.95rem;
}
.th-card.th-is-gone .th-photo { filter: grayscale(1); opacity: 0.75; }

.th-also {
	padding: 8px 10px;
	background: var(--th-soft);
	border-radius: 6px;
	font-size: 0.95rem;
}
.th-app .th-also__title { margin: 0 0 4px; }
.th-also li { margin: 4px 0; }
.th-also--gone a { color: var(--th-muted); }
.th-cheaper {
	display: inline-block;
	padding: 0 6px;
	border-radius: 4px;
	background: var(--th-pass);
	color: #ffffff;
	font-size: 0.8rem;
}

/* ---- buttons ------------------------------------------------------------ */

.th-app .th-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 8px 14px;
	border: 2px solid var(--th-ink);
	border-radius: 8px;
	background: var(--th-card);
	color: var(--th-ink);
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
}
.th-app .th-btn:hover { background: var(--th-soft); }
.th-app .th-btn:disabled { opacity: 0.6; cursor: wait; }
.th-app .th-btn--primary {
	background: var(--th-ink);
	color: #ffffff;
}
.th-app .th-btn--primary:hover { background: #33373f; }

.th-actions {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
}
.th-app .th-status-btn { padding: 8px 6px; }
.th-app .th-status-btn[aria-pressed="true"] {
	background: var(--th-ink);
	color: #ffffff;
}
.th-app .th-status-btn[aria-pressed="true"]::before { content: "✓"; margin-right: 0.35em; }

.th-notes { display: grid; gap: 6px; }
.th-app .th-public-btn { justify-self: start; font-weight: 500; }
.th-app .th-public-btn[aria-pressed="true"] { background: var(--th-soft); border-style: dashed; }
.th-public-note {
	margin: 0 0 16px;
	padding: 10px 14px;
	border-radius: 8px;
	background: var(--th-soft);
	border-left: 4px solid var(--th-strong);
}
.th-public-intro { color: var(--th-muted); margin: 0 0 16px; }
.th-app .th-ruled {
	margin: 0;
	padding: 8px 10px;
	background: var(--th-soft);
	border-left: 4px solid var(--th-unknown);
	border-radius: 4px;
	font-size: 0.95rem;
}
.th-card.th-public-ruled { opacity: 0.85; }
.th-notes label { font-weight: 600; }
.th-app .th-notes textarea {
	width: 100%;
	min-height: 72px;
	padding: 8px 10px;
	border: 2px solid var(--th-line);
	border-radius: 8px;
	font: inherit;
	color: var(--th-ink);
	background: var(--th-card);
}
.th-app .th-notes textarea:focus { border-color: var(--th-focus); }
.th-notes .th-save-notes { justify-self: start; }

.th-app .th-msg { margin: 0; min-height: 1.5em; font-weight: 600; color: var(--th-pass); }
.th-app .th-msg--error { color: var(--th-fail); }

.th-pager {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin: 24px 0 8px;
}

/* ---- wp-admin setup screen ---------------------------------------------- */

.th-admin .th-app { margin: 16px 0; max-width: 900px; }
.th-admin .th-steps li { margin-bottom: 12px; max-width: 900px; }
.th-admin .th-code {
	background: #1d2327;
	color: #f0f0f1;
	padding: 12px 14px;
	border-radius: 6px;
	overflow-x: auto;
	white-space: pre;
	font-size: 13px;
	margin: 8px 0;
}
.th-admin .th-help li { margin-bottom: 8px; max-width: 900px; }

@media (max-width: 420px) {
	.th-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
	.th-app .th-btn, .th-app .th-tab { transition: background-color 0.15s, border-color 0.15s; }
}
