:root {
	--bg: #f1eee8;
	--panel: #fffdf9;
	--ink: #1c1b19;
	--muted: #6d675f;
	--line: #d8d0c4;
	--accent: #b08a45;
	--accent-dark: #806229;
	--evergreen: #1f3b35;
	--black: #171716;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: "Aptos", "Helvetica Neue", Helvetica, Arial, sans-serif;
	color: var(--ink);
	background: linear-gradient(135deg, #f8f5ef 0%, var(--bg) 52%, #e8e1d6 100%);
}

.page-shell {
	min-height: 100vh;
	padding: 24px 16px 40px;
}

.site-nav {
	max-width: 1180px;
	margin: 0 auto 24px;
	padding: 12px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 18px;
	background: var(--black);
	border: 1px solid #3b3429;
	border-radius: 12px;
	box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.nav-brand,
.nav-links a,
.nav-group summary {
	color: #f7f0e4;
	text-decoration: none;
	font-weight: 700;
}

.nav-brand {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.nav-brand img {
	width: 22px;
	height: 22px;
	object-fit: contain;
}

.nav-brand-copy {
	display: grid;
	gap: 2px;
}

.nav-brand-copy strong {
	color: #d9b873;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 0.9rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	line-height: 1.1;
}

.nav-brand-copy small {
	color: #f7f0e4;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 0.78rem;
	letter-spacing: 0.04em;
}

.nav-links {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 6px;
	flex-wrap: wrap;
}

.nav-links > a,
.nav-group summary {
	padding: 8px 10px;
	border-radius: 7px;
	cursor: pointer;
	list-style: none;
}

.nav-links > a:hover,
.nav-group summary:hover {
	background: #302c25;
}

.nav-group {
	position: relative;
}

.nav-group summary::-webkit-details-marker {
	display: none;
}

.nav-group summary::after {
	content: ' ▾';
	font-size: 0.75rem;
}

.nav-group-links {
	position: absolute;
	right: 0;
	top: calc(100% + 6px);
	min-width: 210px;
	display: grid;
	gap: 2px;
	padding: 6px;
	background: var(--black);
	border: 1px solid #3b3429;
	border-radius: 8px;
	box-shadow: 0 12px 24px rgba(15, 23, 42, 0.2);
	z-index: 5;
}

.nav-group-links a {
	padding: 8px 10px;
	font-size: 0.9rem;
}

.nav-group-links a:hover {
	background: #302c25;
}

.container {
	max-width: 1180px;
	margin: 0 auto;
}

.page-header h1 {
	margin: 0;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 2rem;
	font-weight: 600;
	letter-spacing: 0.01em;
}

.page-header p {
	margin: 8px 0 0;
	color: var(--muted);
}

.inline-link {
	color: var(--accent-dark);
	text-decoration: none;
	font-weight: 600;
}

.inline-link:hover {
	text-decoration: underline;
}

.table-panel,
.error-panel {
	margin-top: 20px;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 16px;
	box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.terminal-panel {
	margin-top: 20px;
	background: #020617;
	border: 1px solid #1e293b;
	border-radius: 12px;
	padding: 16px;
	box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);
}

.terminal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 10px;
}

.terminal-head h2 {
	margin: 0;
	font-size: 1rem;
	color: #f8fafc;
}

.terminal-badge {
	display: inline-block;
	padding: 4px 8px;
	border-radius: 999px;
	background: var(--accent-dark);
	color: #fff8eb;
	font-size: 0.8rem;
	font-weight: 700;
}

.terminal-body {
	margin: 0;
	padding: 12px;
	background: #0f172a;
	color: #e2e8f0;
	border-radius: 8px;
	font-family: "Cascadia Code", "Consolas", monospace;
	font-size: 0.9rem;
	line-height: 1.5;
	white-space: pre-wrap;
	word-break: break-word;
}

.info-panel {
	margin-top: 20px;
	background: #f5f0e7;
	border: 1px solid #d8c9ae;
	border-radius: 12px;
	padding: 16px;
	box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.info-panel h2 {
	margin-top: 0;
	color: var(--evergreen);
}

.filter-bar {
	display: flex;
	align-items: end;
	gap: 10px;
	flex-wrap: wrap;
}

.filter-bar label {
	font-size: 0.9rem;
	color: var(--muted);
}

.filter-bar input {
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 8px 10px;
	min-width: 180px;
	font: inherit;
}

.filter-bar select {
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 8px 10px;
	min-width: 150px;
	font: inherit;
	background: #ffffff;
}

.preset-buttons {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	width: 100%;
}

.preset-label {
	font-size: 0.88rem;
	color: var(--muted);
}

.preset-button {
	border: 1px solid #94a3b8;
	background: #f8fafc;
	color: #0f172a;
	border-radius: 8px;
	padding: 6px 10px;
	font: inherit;
	font-size: 0.88rem;
	font-weight: 600;
	cursor: pointer;
}

.preset-button:hover {
	background: #eef2ff;
	border-color: #64748b;
}

.state-pill-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	gap: 8px;
	width: min(680px, 100%);
}

.state-pill {
	position: relative;
	display: block;
}

.state-pill input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.state-pill span {
	display: block;
	text-align: center;
	padding: 8px 12px;
	border: 1px solid #cbd5e1;
	border-radius: 999px;
	background: #faf7f1;
	color: #0f172a;
	font-size: 0.9rem;
	line-height: 1.1;
	cursor: pointer;
	user-select: none;
	transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.state-pill span:hover {
	border-color: #94a3b8;
	background: #f1f5f9;
}

.state-pill input[type="checkbox"]:checked + span {
	background: var(--evergreen);
	border-color: var(--evergreen);
	color: #ffffff;
	box-shadow: 0 0 0 2px rgba(176, 138, 69, 0.24);
}

.filter-bar button {
	border: 1px solid var(--accent-dark);
	background: var(--evergreen);
	color: #ffffff;
	border-radius: 8px;
	padding: 8px 14px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.sync-button {
	border: 1px solid var(--accent-dark);
	background: var(--evergreen);
	color: #ffffff;
	border-radius: 8px;
	padding: 9px 14px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.sync-button:hover {
	background: var(--accent-dark);
}

.danger-button {
	border: 1px solid #991b1b;
	background: #dc2626;
	color: #ffffff;
	border-radius: 8px;
	padding: 9px 14px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

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

.filter-bar button:hover {
	background: var(--accent-dark);
}

.error-panel h2 {
	margin-top: 0;
	color: #b91c1c;
}

.table-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
}

.table-head h2 {
	margin: 0;
}

.badge {
	display: inline-block;
	background: #eee3ce;
	color: #725526;
	border-radius: 999px;
	padding: 4px 10px;
	font-size: 0.85rem;
	font-weight: 600;
}

.table-wrap {
	overflow-x: auto;
}

@media (max-width: 760px) {
	.page-shell {
		padding: 12px 10px 28px;
	}

	.site-nav {
		align-items: stretch;
		flex-direction: column;
		gap: 8px;
		margin-bottom: 16px;
	}

	.nav-links {
		justify-content: stretch;
		gap: 4px;
	}

	.nav-links > a,
	.nav-group {
		flex: 1 1 46%;
	}

	.nav-links > a,
	.nav-group summary {
		text-align: center;
	}

	.nav-group-links {
		position: static;
		margin-top: 4px;
		min-width: 0;
	}

	.page-header h1 {
		font-size: 1.55rem;
	}

	.table-panel,
	.error-panel,
	.info-panel {
		padding: 12px;
		border-radius: 9px;
	}

	.filter-bar {
		align-items: stretch;
		flex-direction: column;
	}

	.filter-bar input,
	.filter-bar select,
	.filter-bar button {
		width: 100%;
		min-width: 0;
	}

	.state-pill-grid {
		width: 100%;
	}

	.table-head {
		align-items: flex-start;
		flex-direction: column;
		gap: 8px;
	}

}

table {
	width: 100%;
	border-collapse: collapse;
}

.table-wrap table th:nth-child(2),
.table-wrap table td:nth-child(2) {
	width: 72px;
	white-space: nowrap;
}

.table-wrap table th:nth-child(4),
.table-wrap table td:nth-child(4) {
	width: 72px;
	white-space: nowrap;
}

th,
td {
	padding: 10px 12px;
	text-align: left;
	border-bottom: 1px solid var(--line);
}

th {
	font-size: 0.86rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--muted);
}

tbody tr:hover {
	background: #f8fafc;
}

.empty {
	text-align: center;
	color: var(--muted);
}

.empty-inline {
	color: var(--muted);
	font-size: 0.9rem;
}

.customer-cell {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.customer-name {
	font-weight: 600;
}

.customer-phone {
	font-size: 0.84rem;
	color: var(--muted);
}

.invoice-cell {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.invoice-preview {
	font-size: 0.9rem;
	line-height: 1.3;
	color: var(--ink);
}

.invoice-summary-box {
	padding: 8px 10px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #f8fafc;
	margin: 0;
}

.compact-invoice-item {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-bottom: 4px;
}

.invoice-total-line {
	font-size: 0.85rem;
	color: var(--muted);
}

.invoice-status-pill {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 700;
	border: 1px solid transparent;
	text-transform: capitalize;
}

.invoice-status-paid {
	background: #dcfce7;
	border-color: #bbf7d0;
	color: #166534;
}

.invoice-status-open {
	background: #fef3c7;
	border-color: #fde68a;
	color: #92400e;
}

.invoice-status-cancelled {
	background: #dbeafe;
	border-color: #bfdbfe;
	color: #1d4ed8;
	text-decoration: line-through;
}

.legs-table {
	width: 100%;
	border-collapse: collapse;
}

.legs-table th,
.legs-table td {
	padding: 8px 10px;
	border-bottom: 1px solid var(--line);
	text-align: left;
}

.leg-confirmation {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border-radius: 999px;
	font-weight: 700;
}

.leg-confirmation.success {
	background: #dcfce7;
	color: #166534;
}

.leg-confirmation.failure {
	background: #fee2e2;
	color: #991b1b;
}

.leg-confirmation.neutral {
	background: #f3f4f6;
	color: #6b7280;
}

.leg-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 280px;
}

.leg-card {
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 8px 9px;
	background: #f8fafc;
}

.leg-card-row {
	display: grid;
	grid-template-columns: auto 56px minmax(0, 1fr) auto auto;
	align-items: center;
	gap: 6px;
	width: 100%;
}

.leg-number {
	font-weight: 700;
	color: var(--accent);
	margin-right: 2px;
	flex-shrink: 0;
}

.leg-card-row .leg-pill-muted:nth-of-type(1) {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.leg-card-row .leg-pill-muted:nth-of-type(2) {
	justify-self: end;
	white-space: nowrap;
}

.leg-card-row .leg-icon {
	justify-self: end;
	flex-shrink: 0;
	margin-left: 2px;
}

.leg-pill {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 0.74rem;
	font-weight: 700;
	border: 1px solid transparent;
}

.leg-pill-confirmed {
	background: #dcfce7;
	border-color: #bbf7d0;
	color: #166534;
}

.leg-pill-pending {
	background: #fef3c7;
	border-color: #fde68a;
	color: #92400e;
}

.leg-pill-muted {
	background: #ffffff;
	border-color: var(--line);
	color: var(--muted);
}

.leg-pill-date {
	background: #eef2ff;
	border-color: #c7d2fe;
	color: #4338ca;
	font-variant-numeric: tabular-nums;
	width: 56px;
	justify-content: center;
	flex-shrink: 0;
}

.leg-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border-radius: 999px;
	font-weight: 700;
	font-size: 0.9rem;
}

.leg-icon-success {
	background: #dcfce7;
	color: #166534;
}

.leg-icon-failure {
	background: #fee2e2;
	color: #991b1b;
}

.leg-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-bottom: 4px;
}

.leg-note {
	font-size: 0.78rem;
	color: var(--muted);
}

.calendar-nav-link {
	display: inline-flex;
	align-items: center;
	padding: 8px 10px;
	border-radius: 8px;
	background: #f8fafc;
	border: 1px solid var(--line);
	color: var(--ink);
	text-decoration: none;
	font-size: 0.9rem;
	font-weight: 600;
}

.calendar-nav-link:hover {
	background: #eef2ff;
}

.legend-pill,
.status-pill {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 0.82rem;
	font-weight: 700;
	border: 1px solid transparent;
	text-transform: capitalize;
}

.status-available {
	background: #dcfce7;
	border-color: #bbf7d0;
	color: #166534;
}

.status-on-job {
	background: #dbeafe;
	border-color: #bfdbfe;
	color: #1d4ed8;
}

.status-day-off {
	background: #fef3c7;
	border-color: #fde68a;
	color: #92400e;
}

.status-unavailable {
	background: #fee2e2;
	border-color: #fecaca;
	color: #991b1b;
}

.status-inspection {
	background: #ede9fe;
	border-color: #ddd6fe;
	color: #6d28d9;
}

.status-garage {
	background: #e2e8f0;
	border-color: #cbd5e1;
	color: #334155;
}

.calendar-tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 12px;
}

.calendar-tab {
	display: inline-block;
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: #f8fafc;
	color: var(--ink);
	text-decoration: none;
	font-weight: 600;
}

.calendar-tab:hover {
	background: #eef2ff;
}

.calendar-scroll-shell {
	overflow-x: auto;
	padding-bottom: 8px;
}

.calendar-grid {
	border-collapse: collapse;
	min-width: 720px;
}

.calendar-grid th,
.calendar-grid td {
	white-space: nowrap;
	min-width: 86px;
	vertical-align: top;
	padding: 8px 6px;
}

.calendar-grid td {
	text-align: center;
}

.calendar-grid th + th,
.calendar-grid td + td {
	border-left: 1px solid rgba(15, 23, 42, 0.08);
}

.calendar-resource-head {
	position: sticky;
	left: 0;
	background: var(--panel);
	z-index: 1;
}

.calendar-date-head {
	font-size: 0.78rem;
	line-height: 1.2;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	min-width: 74px;
}

.calendar-date-head-narrow {
	min-width: 62px;
}

.calendar-date-year,
.calendar-date-month,
.calendar-date-day {
	display: block;
}

.calendar-date-month {
	font-size: 0.82rem;
	font-weight: 700;
	color: var(--muted);
}

.calendar-date-day {
	font-size: 0.98rem;
	font-weight: 700;
	color: var(--ink);
}

.calendar-empty {
	color: var(--muted);
}

.calendar-cell-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 28px;
	padding: 2px 6px;
	margin: 0 2px;
	border-radius: 999px;
	background: #f8fafc;
	border: 1px solid var(--line);
	color: var(--ink);
	text-decoration: none;
	font-size: 0.75rem;
	font-weight: 700;
}

.calendar-cell-link:hover {
	background: #eef2ff;
}

.calendar-cycle-pill {
	text-decoration: none;
}

.calendar-cell-updating {
	opacity: 0.7;
	transition: opacity 120ms ease-in-out;
}
.calendar-order-links {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-top: 4px;
	font-size: 12px;
}

.calendar-leg-lines {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-top: 4px;
	font-size: 12px;
}

.calendar-leg-pill {
	display: inline-flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 1px;
	min-width: 94px;
	text-decoration: none;
}

.calendar-leg-pill-row {
	line-height: 1.15;
}

.calendar-leg-pill-row:first-child {
	font-size: 11px;
	font-weight: 700;
}

.calendar-leg-pill-row:last-child {
	font-size: 10px;
	color: #14532d;
	font-weight: 600;
}

.pill-order-status {
	font-weight: 700;
}

.pill-order-status-c {
	color: #14532d;
}

.pill-order-status-r {
	color: #991b1b;
}

.status-off_road {
	background: #fee2e2;
	border-color: #fecaca;
	color: #991b1b;
}

.status-scheduled_maintenance {
	background: #fef3c7;
	border-color: #fde68a;
	color: #92400e;
}

.quote-form {
	display: grid;
	gap: 16px;
}

.quote-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 10px;
}

.quote-grid label {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 0.9rem;
	color: var(--muted);
}

.quote-grid input,
.quote-grid select {
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 8px 10px;
	font: inherit;
	background: #ffffff;
	color: var(--ink);
}

.section-title {
	margin: 0;
	font-size: 1rem;
}

.leg-card {
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 12px;
	background: #fbfdff;
	margin-bottom: 10px;
}

.row-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

@media (max-width: 640px) {
	.page-header h1 {
		font-size: 1.6rem;
	}

	th,
	td {
		padding: 9px;
		font-size: 0.92rem;
	}
}
