.tpi-fe {
	max-width: 960px;
	margin: 0 auto;
	font-size: 15px;
	line-height: 1.5;
}

.tpi-fe-notice {
	background: #f6f7f7;
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 1.5em;
	text-align: center;
}

.tpi-fe-flash {
	padding: 0.75em 1em;
	border-radius: 4px;
	margin-bottom: 1em;
}
.tpi-fe-flash-ok { background: #eafaf0; border: 1px solid #34a853; }
.tpi-fe-flash-error { background: #fdeaea; border: 1px solid #d93025; }

.tpi-fe-tabs {
	display: flex;
	gap: 0.5em;
	border-bottom: 2px solid #ddd;
	margin-bottom: 1.5em;
	flex-wrap: wrap;
}
.tpi-fe-tab {
	padding: 0.6em 1em;
	text-decoration: none;
	color: #333;
	border-bottom: 3px solid transparent;
	margin-bottom: -2px;
}
.tpi-fe-tab.is-active {
	border-bottom-color: #2271b1;
	font-weight: 600;
	color: #2271b1;
}

.tpi-fe-table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 1.5em;
}
.tpi-fe-table th,
.tpi-fe-table td {
	padding: 0.5em 0.6em;
	border-bottom: 1px solid #e5e5e5;
	text-align: left;
	vertical-align: middle;
}

.tpi-fe-grid th, .tpi-fe-grid td { text-align: center; }
.tpi-fe-grid td:first-child { text-align: left; }
.tpi-fe-cell.is-ticked { background: #eafaf0; color: #1e7e34; font-weight: bold; }

.tpi-fe-status {
	padding: 0.15em 0.6em;
	border-radius: 12px;
	font-size: 0.85em;
	background: #eee;
}
.tpi-fe-status-scheduled { background: #e8f0fe; color: #1a56b0; }
.tpi-fe-status-completed { background: #eafaf0; color: #1e7e34; }
.tpi-fe-status-cancelled,
.tpi-fe-status-no_show { background: #fdeaea; color: #a01313; }

.tpi-fe-form {
	display: flex;
	flex-direction: column;
	gap: 0.9em;
	max-width: 480px;
	margin-bottom: 2em;
}
.tpi-fe-form label {
	display: flex;
	flex-direction: column;
	gap: 0.3em;
	font-weight: 600;
}
.tpi-fe-form input,
.tpi-fe-form select,
.tpi-fe-form textarea {
	font-weight: normal;
	padding: 0.5em;
	border: 1px solid #ccc;
	border-radius: 4px;
	font-size: 1em;
}
.tpi-fe-form .tpi-fe-check-row {
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
}

.tpi-button,
button.tpi-button {
	display: inline-block;
	background: #2271b1;
	color: #fff;
	border: none;
	padding: 0.6em 1.4em;
	border-radius: 4px;
	cursor: pointer;
	font-size: 1em;
	text-decoration: none;
	width: fit-content;
}
.tpi-button:hover { background: #135e96; color: #fff; }

.tpi-link-button {
	background: none;
	border: none;
	color: #a01313;
	text-decoration: underline;
	cursor: pointer;
	padding: 0;
	font: inherit;
}

.tpi-fe-vehicle {
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 1em 1.2em;
	margin-bottom: 1.5em;
}

.tpi-fe-alerts { margin: 0.5em 0; padding-left: 1.2em; }
.tpi-fe-alert-expired,
.tpi-fe-alert-missing { color: #a01313; }
.tpi-fe-alert-due { color: #8a5a00; }
.tpi-fe-ok { color: #1e7e34; }

.tpi-fe-hint {
	color: #666;
	font-size: 0.9em;
}

/* Accounts tab: quick stat cards */
.tpi-fe-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	margin: 12px 0 20px;
}
.tpi-fe-stat {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 12px 18px;
	min-width: 160px;
}
.tpi-fe-stat-value {
	display: block;
	font-size: 22px;
	font-weight: 700;
}
.tpi-fe-stat-label {
	display: block;
	font-size: 12px;
	color: #666;
}

/* Learners tab: search box */
.tpi-fe-search {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 10px 0 16px;
	flex-wrap: wrap;
}
.tpi-fe-search input[type="search"] {
	padding: 8px 10px;
	border: 1px solid #ccc;
	border-radius: 4px;
	min-width: 240px;
}

/* Junction diagram editor (front-end) — mirrors the admin toolbar so the
   shared tpi-diagram-editor.js script has consistent hooks to attach to. */
.tpi-diagram-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 18px;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 10px 14px;
	margin: 12px 0;
}
.tpi-diagram-toolbar-group {
	display: flex;
	align-items: center;
	gap: 6px;
}
.tpi-diagram-toolbar-group label {
	font-size: 12px;
	color: #666;
}
.tpi-diagram-tools,
.tpi-diagram-colors {
	gap: 4px;
}
.tpi-tool-btn,
.tpi-color-btn {
	width: 34px;
	height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid #ccc;
	border-radius: 4px;
	background: #f6f7f7;
	cursor: pointer;
	font-size: 17px;
	line-height: 1;
	padding: 0;
	color: #1f2328 !important;
	text-shadow: none !important;
	-webkit-text-fill-color: #1f2328 !important;
	opacity: 1 !important;
}
.tpi-tool-btn.is-active {
	border-color: #1a56b0;
	background: #e8f0fe;
	box-shadow: 0 0 0 1px #1a56b0;
	color: #1a56b0 !important;
	-webkit-text-fill-color: #1a56b0 !important;
}
.tpi-color-btn {
	border-radius: 50%;
}
.tpi-color-btn.is-active {
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a56b0;
}
#tpi-diagram-title {
	min-width: 200px;
	padding: 6px 8px;
}
.tpi-diagram-actions {
	margin-left: auto;
}
.tpi-diagram-canvas-wrap {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 8px;
	max-width: 900px;
}
#tpi-diagram-canvas {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 3 / 2;
	background: #e8efe1;
	border-radius: 4px;
	touch-action: none;
	cursor: crosshair;
}

/* Printable progress report */
/* -------------------------------------------------------------------
 * Small screens
 *
 * This is a tablet tool before it is a desktop one — an instructor uses
 * it in a car, between lessons, one-handed. Until now the stylesheet had
 * no breakpoints at all, so everything below was laid out for a monitor
 * that is not there.
 * ---------------------------------------------------------------- */

/*
 * Wide tables cannot reflow usefully, so let them scroll sideways inside
 * their own box rather than stretching the page and knocking the whole
 * layout out of alignment.
 */
.tpi-fe-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin-bottom: 1.5em;
}

.tpi-fe-table-wrap .tpi-fe-table {
	margin-bottom: 0;
}

@media ( max-width: 782px ) {
	.tpi-fe {
		padding: 0 12px;
	}

	/* Tabs become a scrolling strip instead of stacking into a wall of
	   links that pushes the content off-screen. */
	.tpi-fe-tabs {
		flex-wrap: nowrap;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	.tpi-fe-tabs::-webkit-scrollbar {
		display: none;
	}

	.tpi-fe-tab {
		white-space: nowrap;
		flex: 0 0 auto;
	}

	/* Stats go two-up rather than one long column. */
	.tpi-fe-stats {
		display: grid;
		grid-template-columns: repeat( 2, 1fr );
		gap: 8px;
	}

	.tpi-fe-stat {
		min-width: 0;
	}

	/* A search field with a 240px floor overflows a narrow phone. */
	.tpi-fe-search input[type="search"] {
		min-width: 0;
		flex: 1 1 100%;
	}

	.tpi-diagram-toolbar {
		gap: 10px;
		padding: 10px;
	}

	/* The toolbar's auto margin pushes actions off the edge once things
	   wrap, so drop it and let them sit on their own row. */
	.tpi-diagram-actions {
		margin-left: 0;
		width: 100%;
		display: flex;
		gap: 6px;
		flex-wrap: wrap;
	}

	#tpi-diagram-title {
		min-width: 0;
		flex: 1 1 100%;
	}

	/*
	 * Touch targets. 44px is the size a finger actually needs; the
	 * desktop padding gives roughly 30, which is why precise taps in a
	 * moving car are miserable.
	 */
	.tpi-button,
	.tpi-tool-btn,
	.tpi-fe-tab {
		min-height: 44px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	.tpi-fe-table th,
	.tpi-fe-table td {
		padding: 10px 8px;
	}
}

@media ( max-width: 480px ) {
	.tpi-fe-stats {
		grid-template-columns: 1fr;
	}

	/* Toolbar buttons go full-width and stack, which is easier to hit
	   than a row of narrow ones. */
	.tpi-diagram-actions .tpi-button {
		flex: 1 1 auto;
	}
}

@media print {
	body * {
		visibility: hidden;
	}
	.tpi-print-report,
	.tpi-print-report * {
		visibility: visible;
	}
	.tpi-print-report {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
	}
	.tpi-no-print {
		display: none !important;
	}
}
.tpi-print-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	border-bottom: 2px solid #111;
	padding-bottom: 10px;
	margin-bottom: 10px;
}
.tpi-print-header h2 {
	margin: 0 0 2px;
}
.tpi-print-header-right {
	text-align: right;
}
.tpi-print-table {
	width: 100%;
	border-collapse: collapse;
	margin: 14px 0;
	font-size: 12px;
}
.tpi-print-table th,
.tpi-print-table td {
	border: 1px solid #999;
	padding: 4px 6px;
	text-align: center;
}
.tpi-print-table th:first-child,
.tpi-print-table td:first-child {
	text-align: left;
	min-width: 160px;
}
.tpi-print-category td {
	background: #eee;
	font-weight: 700;
	text-align: left;
}
.tpi-print-cell {
	white-space: nowrap;
}
.tpi-print-date {
	font-size: 10px;
	color: #444;
}
.tpi-print-footnote {
	font-size: 11px;
	color: #555;
	margin-top: 14px;
}

/* Dashboard visual upgrade: coloured stat cards, bar charts, pills */
.tpi-fe-stat {
	position: relative;
	overflow: hidden;
	padding-left: 22px;
	box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.tpi-fe-stat::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 6px;
	background: #9ca3af;
}
.tpi-fe-stat--blue::before   { background: #1a56b0; }
.tpi-fe-stat--green::before  { background: #16a34a; }
.tpi-fe-stat--amber::before  { background: #f59e0b; }
.tpi-fe-stat--red::before    { background: #dc2626; }
.tpi-fe-stat--purple::before { background: #7c3aed; }

.tpi-fe-stat-icon {
	font-size: 20px;
	line-height: 1;
	display: block;
	margin-bottom: 4px;
}

/* Horizontal bar rows, e.g. bottleneck skills or lesson status split */
.tpi-bar-row {
	display: grid;
	grid-template-columns: 170px 1fr 70px;
	align-items: center;
	gap: 10px;
	margin: 8px 0;
}
.tpi-bar-row-label {
	font-size: 13px;
	color: #1f2328;
}
.tpi-bar-track {
	background: #eef0f2;
	border-radius: 999px;
	height: 12px;
	overflow: hidden;
}
.tpi-bar-fill {
	height: 100%;
	border-radius: 999px 0 0 999px;
	background: #1a56b0;
}
.tpi-bar-fill--amber { background: #f59e0b; }
.tpi-bar-fill--red   { background: #dc2626; }
.tpi-bar-fill--green { background: #16a34a; }
.tpi-bar-row-value {
	font-size: 12px;
	color: #555;
	text-align: right;
}

/* Segmented single-row bar (lesson status split) */
.tpi-segmented-bar {
	display: flex;
	height: 22px;
	border-radius: 6px;
	overflow: hidden;
	background: #eef0f2;
	margin: 10px 0 6px;
}
.tpi-segmented-bar span {
	height: 100%;
}
.tpi-segmented-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	font-size: 12px;
	color: #444;
	margin-bottom: 18px;
}
.tpi-segmented-legend .tpi-dot {
	display: inline-block;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	margin-right: 5px;
	vertical-align: middle;
}

/* Status pills */
.tpi-pill {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
}
.tpi-pill--green  { background: #dcfce7; color: #166534; }
.tpi-pill--red    { background: #fee2e2; color: #991b1b; }
.tpi-pill--amber  { background: #fef3c7; color: #92400e; }
.tpi-pill--gray   { background: #f1f2f4; color: #444; }

/* Editor toolbar buttons -------------------------------------------- */

.tpi-button-quiet {
	background: #6b7280;
}

.tpi-button-danger {
	background: #b91c1c;
}

/*
 * A disabled button has to look disabled. These act on a selection, and
 * before this they stayed fully lit with nothing selected — which reads
 * as a broken page rather than as "pick something first".
 */
.tpi-button:disabled,
.tpi-button[disabled] {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}
