Auto — Book Service Appointment
A self-contained service-booking flow for an auto repair shop or dealership. Customers pick a vehicle from their garage, multi-select services like oil change, brakes, alignment or a check-engine diagnostic, choose a date and an available bay time slot, and decide between drop-off, waiting in the lounge or a loaner. A live estimate panel breaks down parts, labor hours, options, shop fee and tax, then confirms into a work order with a success receipt.
MCP
Code
:root {
--garage: #141518;
--garage-2: #1f2127;
--steel: #5b6470;
--steel-l: #8a929d;
--orange: #ff6a13;
--orange-d: #e2540a;
--orange-50: #fff0e6;
--ink: #16181c;
--ink-2: #3b4049;
--muted: #737a85;
--bg: #f3f4f6;
--surface: #ffffff;
--line: rgba(20, 21, 24, 0.1);
--line-2: rgba(20, 21, 24, 0.18);
--ok: #2f9e6f;
--warn: #e0962a;
--danger: #d4493e;
--inprogress: #2b7fff;
--r-sm: 8px;
--r-md: 14px;
--r-lg: 18px;
--sh-1: 0 1px 2px rgba(20, 21, 24, 0.06), 0 1px 1px rgba(20, 21, 24, 0.04);
--sh-2: 0 10px 30px rgba(20, 21, 24, 0.12);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
margin: 0;
font-family: "Inter", system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--ink);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
}
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; letter-spacing: .01em; }
button { font: inherit; cursor: pointer; }
.shell { max-width: 1120px; margin: 0 auto; padding: 22px 20px 60px; }
/* Topbar */
.topbar {
display: flex; align-items: center; justify-content: space-between; gap: 14px;
background: var(--garage);
color: #fff;
border-radius: var(--r-lg);
padding: 14px 18px;
box-shadow: var(--sh-2);
background-image: linear-gradient(180deg, var(--garage-2), var(--garage));
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
width: 42px; height: 42px; display: grid; place-items: center;
border-radius: 12px; color: #fff;
background: linear-gradient(160deg, var(--orange), var(--orange-d));
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), 0 4px 14px rgba(255, 106, 19, .4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-weight: 800; letter-spacing: -.01em; }
.brand-text span { font-size: 12px; color: var(--steel-l); }
.topbar-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--steel-l); }
.open-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(47, 158, 111, .22); }
/* Layout */
.layout {
display: grid;
grid-template-columns: minmax(0, 1fr) 360px;
gap: 20px;
margin-top: 20px;
align-items: start;
}
.form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* Steps */
.steps { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.step {
font-size: 12px; font-weight: 600; color: var(--muted);
background: var(--surface); border: 1px solid var(--line);
padding: 7px 12px; border-radius: 999px;
}
.step.is-active { color: #fff; background: var(--garage); border-color: var(--garage); }
/* Blocks */
.block {
border: 1px solid var(--line); background: var(--surface);
border-radius: var(--r-md); padding: 16px 16px 18px; margin: 0;
box-shadow: var(--sh-1);
}
.block legend {
font-weight: 700; font-size: 14px; padding: 0; margin-bottom: 12px;
display: flex; align-items: baseline; gap: 8px;
}
.hint, .block legend .hint { font-weight: 500; font-size: 11px; color: var(--muted); text-transform: none; }
/* Vehicle */
.vehicle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vehicle {
display: flex; align-items: center; gap: 11px; text-align: left;
background: var(--surface); border: 1.5px solid var(--line);
border-radius: var(--r-md); padding: 10px; position: relative;
transition: border-color .15s, box-shadow .15s, transform .05s;
}
.vehicle:hover { border-color: var(--line-2); }
.vehicle:active { transform: translateY(1px); }
.vehicle[aria-checked="true"] { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-50); }
.veh-photo {
width: 58px; height: 44px; border-radius: 8px; flex: none;
background: linear-gradient(135deg, var(--steel), var(--garage-2));
position: relative; overflow: hidden;
}
.veh-photo::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 80% at 80% 0%, rgba(255,255,255,.25), transparent 60%); }
.veh-a { background: linear-gradient(135deg, #3a5a6b, #1f2127); }
.veh-b { background: linear-gradient(135deg, #6b4030, #1f2127); }
.veh-info { display: flex; flex-direction: column; min-width: 0; }
.veh-info strong { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.veh-info small { font-size: 11px; color: var(--muted); }
.veh-info small b { color: var(--ink-2); font-weight: 600; }
.veh-check {
width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2);
margin-left: auto; flex: none; transition: .15s;
}
.vehicle[aria-checked="true"] .veh-check { border-color: var(--orange); background: var(--orange); box-shadow: inset 0 0 0 3px #fff; }
.vehicle.add { border-style: dashed; color: var(--muted); }
.vehicle.add[aria-checked="true"] { color: var(--ink); }
.veh-plus {
width: 58px; height: 44px; border-radius: 8px; flex: none; display: grid; place-items: center;
font-size: 24px; font-weight: 400; color: var(--steel); background: var(--bg); border: 1px dashed var(--line-2);
}
/* Services */
.service-list { display: flex; flex-direction: column; gap: 9px; }
.svc {
display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 12px 13px;
background: var(--surface); text-align: left; width: 100%;
transition: border-color .15s, box-shadow .15s, background .15s;
}
.svc:hover { border-color: var(--line-2); }
.svc[aria-pressed="true"] { border-color: var(--orange); background: var(--orange-50); }
.svc-box {
width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line-2);
display: grid; place-items: center; color: #fff; flex: none; transition: .15s;
}
.svc[aria-pressed="true"] .svc-box { background: var(--orange); border-color: var(--orange); }
.svc-box svg { opacity: 0; transition: opacity .12s; }
.svc[aria-pressed="true"] .svc-box svg { opacity: 1; }
.svc-main { min-width: 0; }
.svc-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.svc-code {
font-size: 10px; font-weight: 700; color: var(--inprogress);
background: rgba(43, 127, 255, .1); padding: 1px 6px; border-radius: 5px;
font-variant-numeric: tabular-nums;
}
.svc-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.svc-price { text-align: right; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.svc-price small { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); }
/* Dates */
.date-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.date {
flex: none; min-width: 64px; text-align: center; padding: 9px 4px;
border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface);
transition: .15s; line-height: 1.2;
}
.date:hover { border-color: var(--line-2); }
.date[aria-checked="true"] { border-color: var(--garage); background: var(--garage); color: #fff; }
.date .d-dow { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.date[aria-checked="true"] .d-dow { color: var(--steel-l); }
.date .d-num { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.date .d-mon { font-size: 10px; color: var(--muted); }
.date[aria-checked="true"] .d-mon { color: var(--steel-l); }
.date[disabled] { opacity: .4; cursor: not-allowed; }
.slot-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 16px 0 9px; }
.slot-head > span:first-child { font-weight: 700; font-size: 13px; }
.slot-bay { font-size: 11px; color: var(--muted); }
.slot-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot {
padding: 9px 4px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
background: var(--surface); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
transition: .15s; position: relative; color: var(--ink-2);
}
.slot:hover:not([disabled]) { border-color: var(--line-2); }
.slot[aria-checked="true"] { border-color: var(--orange); background: var(--orange); color: #fff; box-shadow: 0 4px 12px rgba(255,106,19,.34); }
.slot[disabled] { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.slot .slot-bay-no { display: block; font-size: 9.5px; font-weight: 600; opacity: .75; margin-top: 1px; }
/* Options */
.option-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.option {
display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 12px; background: var(--surface);
transition: .15s; position: relative;
}
.option:hover { border-color: var(--line-2); }
.option[aria-checked="true"] { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-50); }
.opt-ico { font-size: 20px; line-height: 1; }
.opt-txt strong { font-size: 13px; font-weight: 700; display: block; }
.opt-txt small { font-size: 11px; color: var(--muted); }
.opt-tag {
position: absolute; top: 10px; right: 10px; font-size: 10.5px; font-weight: 700;
color: var(--ok); background: rgba(47,158,111,.1); padding: 2px 7px; border-radius: 999px;
}
/* Summary */
.summary { position: sticky; top: 16px; }
.sum-card {
background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
padding: 18px; box-shadow: var(--sh-2);
}
.sum-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.sum-head h2 { font-size: 17px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.sum-vin { font-size: 11px; color: var(--muted); }
.sum-vin b { color: var(--ink-2); }
.sum-lines { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sum-lines .empty {
font-size: 13px; color: var(--muted); text-align: center; padding: 18px 8px;
border: 1px dashed var(--line-2); border-radius: var(--r-md); background: var(--bg);
}
.sl-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; align-items: baseline; }
.sl-item .sl-name { font-weight: 600; }
.sl-item .sl-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.sl-item .sl-sub { grid-column: 1 / -1; font-size: 11px; color: var(--muted); margin-top: -2px; }
.sum-totals { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.t-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--ink-2); }
.t-row small { color: var(--muted); font-weight: 500; font-size: 11px; }
.t-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.t-row.total { margin-top: 4px; padding-top: 11px; border-top: 1px dashed var(--line-2); font-size: 15px; color: var(--ink); }
.t-row.total b { font-size: 19px; font-weight: 800; }
.sum-when {
display: flex; align-items: center; gap: 9px; margin: 14px 0;
background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md);
padding: 11px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.sum-when.set { background: var(--orange-50); border-color: rgba(255,106,19,.3); color: var(--ink); }
.when-ico { font-size: 16px; }
.confirm {
width: 100%; border: none; border-radius: var(--r-md); padding: 14px;
font-size: 15px; font-weight: 800; color: #fff;
background: linear-gradient(160deg, var(--orange), var(--orange-d));
box-shadow: 0 8px 20px rgba(255,106,19,.36); transition: transform .06s, filter .15s, box-shadow .15s;
}
.confirm:hover:not([disabled]) { filter: brightness(1.04); }
.confirm:active:not([disabled]) { transform: translateY(1px); }
.confirm[disabled] { background: var(--steel); box-shadow: none; cursor: not-allowed; opacity: .6; }
.sum-note { font-size: 11px; color: var(--muted); text-align: center; margin: 10px 0 0; }
/* Overlay */
.overlay {
position: fixed; inset: 0; background: rgba(20,21,24,.62); backdrop-filter: blur(3px);
display: grid; place-items: center; padding: 20px; z-index: 50;
animation: fade .2s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.ok-card {
background: var(--surface); border-radius: var(--r-lg); padding: 28px 24px 22px;
max-width: 380px; width: 100%; text-align: center; box-shadow: var(--sh-2);
animation: pop .28s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { transform: translateY(12px) scale(.96); opacity: 0; } }
.ok-badge {
width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 14px; color: #fff;
display: grid; place-items: center; background: linear-gradient(160deg, var(--ok), #248a5e);
box-shadow: 0 8px 22px rgba(47,158,111,.4);
}
.ok-card h2 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.ok-card p { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }
.ok-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 20px; text-align: left; }
.ok-grid div { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); padding: 9px 11px; }
.ok-grid dt { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.ok-grid dd { margin: 2px 0 0; font-size: 13.5px; font-weight: 700; }
.ok-btn {
width: 100%; border: none; border-radius: var(--r-md); padding: 13px; color: #fff;
font-weight: 700; font-size: 14px; background: var(--garage);
}
.ok-btn:hover { background: var(--garage-2); }
/* Toast */
.toast {
position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px);
background: var(--garage); color: #fff; padding: 11px 18px; border-radius: 999px;
font-size: 13px; font-weight: 600; box-shadow: var(--sh-2);
opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
max-width: calc(100vw - 40px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
/* Responsive */
@media (max-width: 880px) {
.layout { grid-template-columns: 1fr; }
.summary { position: static; }
}
@media (max-width: 520px) {
.shell { padding: 16px 14px 48px; }
.topbar-meta { display: none; }
.vehicle-grid { grid-template-columns: 1fr; }
.option-row { grid-template-columns: 1fr; }
.option { flex-direction: row; align-items: center; }
.option .opt-tag { position: static; margin-left: auto; }
.slot-grid { grid-template-columns: repeat(3, 1fr); }
.ok-grid { grid-template-columns: 1fr; }
.svc { grid-template-columns: auto 1fr; }
.svc-price { grid-column: 2; text-align: left; margin-top: 4px; }
}(function () {
"use strict";
var CHECK =
'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>';
// ---- Data ----------------------------------------------------------------
var VEHICLES = [
{ name: "2021 Subaru Outback", vin: "JF2SJ…D8421", plate: "7KJ·4821" },
{ name: "2018 Ford F-150", vin: "1FTEW…B7710", plate: "RTX·9007" }
];
var SERVICES = [
{ id: "oil", name: "Oil & filter change", code: "LOF-05", parts: 34.0, hours: 0.5, meta: "Full synthetic 0W-20 · 5 qt" },
{ id: "tires", name: "Tire rotation & balance", code: "TR-12", parts: 0.0, hours: 0.6, meta: "4-wheel rotation, road-force balance" },
{ id: "brakes", name: "Front brake service", code: "BRK-21", parts: 168.0, hours: 1.4, meta: "Pads + rotor resurface, inspection" },
{ id: "diag", name: "Check-engine diagnostic", code: "P0301", parts: 0.0, hours: 1.0, meta: "Scan, road test & report" },
{ id: "align", name: "4-wheel alignment", code: "ALN-04", parts: 0.0, hours: 1.0, meta: "Camber / caster / toe set to spec" },
{ id: "battery", name: "Battery test & replace", code: "BAT-09", parts: 189.0, hours: 0.4, meta: "Load test, terminals, AGM 750 CCA" }
];
var LABOR_RATE = 145; // $/hr
var SHOP_FEE = 12.5;
var TAX_RATE = 0.0825;
// ---- State ---------------------------------------------------------------
var state = {
vehicle: 0,
services: {},
date: null,
slot: null,
option: "dropoff",
optionPrice: 0
};
// ---- Helpers -------------------------------------------------------------
function $(s, c) { return (c || document).querySelector(s); }
var fmt = function (n) {
return "$" + n.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
};
var toastEl = $("#toast");
var toastTimer;
function toast(msg) {
toastEl.textContent = msg;
toastEl.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(function () { toastEl.classList.remove("show"); }, 2200);
}
// ---- Build services ------------------------------------------------------
var serviceList = $("#serviceList");
SERVICES.forEach(function (s) {
var labor = s.hours * LABOR_RATE;
var total = s.parts + labor;
var btn = document.createElement("button");
btn.type = "button";
btn.className = "svc";
btn.setAttribute("aria-pressed", "false");
btn.dataset.id = s.id;
btn.innerHTML =
'<span class="svc-box">' + CHECK + "</span>" +
'<span class="svc-main"><span class="svc-name">' + s.name +
' <span class="svc-code mono">' + s.code + "</span></span>" +
'<span class="svc-meta">' + s.meta + "</span></span>" +
'<span class="svc-price mono">' + fmt(total) + "<small>est.</small></span>";
btn.addEventListener("click", function () {
var on = btn.getAttribute("aria-pressed") === "true";
btn.setAttribute("aria-pressed", on ? "false" : "true");
if (on) delete state.services[s.id];
else state.services[s.id] = s;
render();
});
serviceList.appendChild(btn);
});
// ---- Build dates ---------------------------------------------------------
var dateRow = $("#dateRow");
var DOW = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
var MON = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var dates = [];
var base = new Date(2026, 5, 18); // fixed reference for stable demo
for (var i = 0; i < 7; i++) {
var d = new Date(base.getFullYear(), base.getMonth(), base.getDate() + i);
var closed = d.getDay() === 0; // Sunday closed
dates.push({ date: d, closed: closed });
var b = document.createElement("button");
b.type = "button";
b.className = "date";
b.setAttribute("role", "radio");
b.setAttribute("aria-checked", "false");
if (closed) b.disabled = true;
b.dataset.idx = i;
b.innerHTML =
'<div class="d-dow">' + (i === 0 ? "Today" : DOW[d.getDay()]) + "</div>" +
'<div class="d-num">' + d.getDate() + "</div>" +
'<div class="d-mon">' + MON[d.getMonth()] + (closed ? " · closed" : "") + "</div>";
if (!closed) {
b.addEventListener("click", function () { pickDate(parseInt(this.dataset.idx, 10)); });
}
dateRow.appendChild(b);
}
// ---- Slots ---------------------------------------------------------------
var SLOTS = [
{ t: "8:00", bay: 1, open: true }, { t: "9:30", bay: 2, open: true },
{ t: "10:30", bay: 1, open: false }, { t: "11:30", bay: 3, open: true },
{ t: "1:00", bay: 2, open: true }, { t: "2:30", bay: 1, open: true },
{ t: "3:30", bay: 3, open: false }, { t: "4:30", bay: 2, open: true }
];
var slotGrid = $("#slotGrid");
function pickDate(idx) {
state.date = idx;
state.slot = null;
Array.prototype.forEach.call(dateRow.children, function (el) {
el.setAttribute("aria-checked", el.dataset.idx === String(idx) ? "true" : "false");
});
renderSlots(idx);
render();
}
function renderSlots(idx) {
slotGrid.innerHTML = "";
SLOTS.forEach(function (s, si) {
// make availability vary slightly by day so it feels live
var open = s.open && !((idx + si) % 7 === 0);
var b = document.createElement("button");
b.type = "button";
b.className = "slot";
b.setAttribute("role", "radio");
b.setAttribute("aria-checked", "false");
if (!open) b.disabled = true;
b.dataset.slot = si;
b.innerHTML = s.t + (si < 4 ? " AM" : " PM") +
'<span class="slot-bay-no">Bay ' + s.bay + "</span>";
if (open) {
b.addEventListener("click", function () { pickSlot(parseInt(this.dataset.slot, 10)); });
}
slotGrid.appendChild(b);
});
}
function pickSlot(si) {
state.slot = si;
Array.prototype.forEach.call(slotGrid.children, function (el) {
el.setAttribute("aria-checked", el.dataset.slot === String(si) ? "true" : "false");
});
var s = SLOTS[si];
toast("Slot held — " + s.t + (si < 4 ? " AM" : " PM") + " · Bay " + s.bay);
render();
}
// ---- Vehicle select ------------------------------------------------------
var vehicleGrid = $("#vehicleGrid");
Array.prototype.forEach.call(vehicleGrid.querySelectorAll(".vehicle"), function (el) {
el.addEventListener("click", function () {
var v = el.dataset.vehicle;
Array.prototype.forEach.call(vehicleGrid.children, function (c) {
c.setAttribute("aria-checked", "false");
});
el.setAttribute("aria-checked", "true");
if (v === "add") {
toast("Add-vehicle form would open here.");
return;
}
state.vehicle = parseInt(v, 10);
$("#sumVin").textContent = VEHICLES[state.vehicle].vin;
render();
});
});
// ---- Options -------------------------------------------------------------
var optionRow = $("#optionRow");
Array.prototype.forEach.call(optionRow.querySelectorAll(".option"), function (el) {
el.addEventListener("click", function () {
Array.prototype.forEach.call(optionRow.children, function (c) {
c.setAttribute("aria-checked", "false");
});
el.setAttribute("aria-checked", "true");
state.option = el.dataset.opt;
state.optionPrice = parseFloat(el.dataset.price) || 0;
render();
});
});
// ---- Render summary ------------------------------------------------------
var sumLines = $("#sumLines");
function render() {
var ids = Object.keys(state.services);
var parts = 0, hours = 0;
sumLines.innerHTML = "";
if (!ids.length) {
sumLines.innerHTML = '<li class="empty">Select a service to see your estimate.</li>';
} else {
ids.forEach(function (id) {
var s = state.services[id];
parts += s.parts;
hours += s.hours;
var line = s.parts + s.hours * LABOR_RATE;
var li = document.createElement("li");
li.className = "sl-item";
li.innerHTML =
'<span class="sl-name">' + s.name + "</span>" +
'<span class="sl-price mono">' + fmt(line) + "</span>" +
'<span class="sl-sub">' + s.code + " · " + s.hours.toFixed(1) +
" hr labor" + (s.parts ? " · " + fmt(s.parts) + " parts" : " · no parts") + "</span>";
sumLines.appendChild(li);
});
}
var labor = hours * LABOR_RATE;
var opt = state.optionPrice;
var subtotal = parts + labor + opt;
var fee = ids.length ? SHOP_FEE : 0;
var tax = (subtotal + fee) * TAX_RATE;
var total = ids.length ? subtotal + fee + tax : 0;
$("#tParts").textContent = fmt(parts);
$("#tLabor").textContent = fmt(labor);
$("#tHours").textContent = hours.toFixed(1) + " hr @ " + fmt(LABOR_RATE) + "/hr";
$("#tOpt").textContent = fmt(opt);
$("#tTax").textContent = fmt(ids.length ? fee + tax : 0);
$("#tTotal").textContent = fmt(total);
// when
var whenBox = $("#sumWhen");
var whenText = $("#whenText");
var when = whenString();
if (when) {
whenBox.classList.add("set");
whenText.textContent = when;
} else {
whenBox.classList.remove("set");
whenText.textContent = "Choose a date and time slot";
}
var ready = ids.length && state.date !== null && state.slot !== null;
$("#confirmBtn").disabled = !ready;
}
function whenString() {
if (state.date === null || state.slot === null) return "";
var d = dates[state.date].date;
var s = SLOTS[state.slot];
var label = DOW[d.getDay()] + " " + MON[d.getMonth()] + " " + d.getDate();
return label + " · " + s.t + (state.slot < 4 ? " AM" : " PM") + " · Bay " + s.bay;
}
// ---- Confirm -------------------------------------------------------------
var overlay = $("#overlay");
$("#confirmBtn").addEventListener("click", function () {
if (this.disabled) return;
var wo = "RO-" + (50000 + Math.floor(Math.random() * 49999));
$("#okWO").textContent = wo;
$("#okWhen").textContent = whenString();
$("#okVeh").textContent = VEHICLES[state.vehicle].name;
$("#okTotal").textContent = $("#tTotal").textContent;
overlay.hidden = false;
$("#okClose").focus();
});
$("#okClose").addEventListener("click", function () { overlay.hidden = true; toast("Work order saved to your account."); });
overlay.addEventListener("click", function (e) { if (e.target === overlay) overlay.hidden = true; });
document.addEventListener("keydown", function (e) { if (e.key === "Escape" && !overlay.hidden) overlay.hidden = true; });
// ---- Init ----------------------------------------------------------------
pickDate(0);
render();
})();<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Apex Motorworks — Book Service Appointment</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="shell">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 13l2-5a2 2 0 0 1 1.9-1.4h10.2A2 2 0 0 1 19 8l2 5" />
<path d="M3 13h18v4a1 1 0 0 1-1 1h-1a2 2 0 0 1-4 0H9a2 2 0 0 1-4 0H4a1 1 0 0 1-1-1z" />
<circle cx="7" cy="17" r="1.4" /><circle cx="17" cy="17" r="1.4" />
</svg>
</div>
<div class="brand-text">
<strong>Apex Motorworks</strong>
<span>Service & Repair · Bay City</span>
</div>
</div>
<div class="topbar-meta">
<span class="open-dot" aria-hidden="true"></span>
<span>Open · Next slot today 2:30 PM</span>
</div>
</header>
<main class="layout">
<section class="form" aria-label="Book a service appointment">
<ol class="steps" aria-hidden="true">
<li class="step is-active">1 · Vehicle & service</li>
<li class="step">2 · Date & time</li>
<li class="step">3 · Confirm</li>
</ol>
<!-- Vehicle -->
<fieldset class="block">
<legend>Select your vehicle</legend>
<div class="vehicle-grid" id="vehicleGrid" role="radiogroup" aria-label="Vehicle">
<button class="vehicle" role="radio" aria-checked="true" data-vehicle="0">
<span class="veh-photo veh-a" aria-hidden="true"></span>
<span class="veh-info">
<strong>2021 Subaru Outback</strong>
<small>Plate <b class="mono">7KJ·4821</b> · 38,402 mi</small>
</span>
<span class="veh-check" aria-hidden="true"></span>
</button>
<button class="vehicle" role="radio" aria-checked="false" data-vehicle="1">
<span class="veh-photo veh-b" aria-hidden="true"></span>
<span class="veh-info">
<strong>2018 Ford F-150</strong>
<small>Plate <b class="mono">RTX·9007</b> · 91,755 mi</small>
</span>
<span class="veh-check" aria-hidden="true"></span>
</button>
<button class="vehicle add" role="radio" aria-checked="false" data-vehicle="add">
<span class="veh-plus" aria-hidden="true">+</span>
<span class="veh-info"><strong>Add vehicle</strong><small>Enter VIN or plate</small></span>
</button>
</div>
</fieldset>
<!-- Services -->
<fieldset class="block">
<legend>Service needed <span class="hint">select one or more</span></legend>
<div class="service-list" id="serviceList"></div>
</fieldset>
<!-- Schedule -->
<fieldset class="block">
<legend>Pick a date</legend>
<div class="date-row" id="dateRow" role="radiogroup" aria-label="Appointment date"></div>
<div class="slot-head">
<span>Available time slots</span>
<span class="slot-bay">Bay assignment is automatic</span>
</div>
<div class="slot-grid" id="slotGrid" role="radiogroup" aria-label="Time slot"></div>
</fieldset>
<!-- Drop-off option -->
<fieldset class="block">
<legend>While we work</legend>
<div class="option-row" id="optionRow" role="radiogroup" aria-label="Drop-off option">
<button class="option" role="radio" aria-checked="true" data-opt="dropoff" data-price="0">
<span class="opt-ico" aria-hidden="true">🔑</span>
<span class="opt-txt"><strong>Drop off</strong><small>Leave it with us</small></span>
<span class="opt-tag">Free</span>
</button>
<button class="option" role="radio" aria-checked="false" data-opt="wait" data-price="0">
<span class="opt-ico" aria-hidden="true">☕</span>
<span class="opt-txt"><strong>Wait in lounge</strong><small>Wi-Fi & coffee</small></span>
<span class="opt-tag">Free</span>
</button>
<button class="option" role="radio" aria-checked="false" data-opt="loaner" data-price="35">
<span class="opt-ico" aria-hidden="true">🚗</span>
<span class="opt-txt"><strong>Loaner car</strong><small>Subject to availability</small></span>
<span class="opt-tag">+$35</span>
</button>
</div>
</fieldset>
</section>
<!-- Summary -->
<aside class="summary" aria-label="Estimate and confirmation">
<div class="sum-card">
<div class="sum-head">
<h2>Estimate</h2>
<span class="sum-vin">VIN <b class="mono" id="sumVin">JF2SJ…D8421</b></span>
</div>
<ul class="sum-lines" id="sumLines">
<li class="empty">Select a service to see your estimate.</li>
</ul>
<div class="sum-totals">
<div class="t-row"><span>Parts</span><b class="mono" id="tParts">$0.00</b></div>
<div class="t-row"><span>Labor <small id="tHours">0.0 hr</small></span><b class="mono" id="tLabor">$0.00</b></div>
<div class="t-row"><span>Options</span><b class="mono" id="tOpt">$0.00</b></div>
<div class="t-row"><span>Shop fee & tax</span><b class="mono" id="tTax">$0.00</b></div>
<div class="t-row total"><span>Estimated total</span><b class="mono" id="tTotal">$0.00</b></div>
</div>
<div class="sum-when" id="sumWhen">
<span class="when-ico" aria-hidden="true">📅</span>
<span id="whenText">Choose a date and time slot</span>
</div>
<button class="confirm" id="confirmBtn" disabled>Confirm appointment</button>
<p class="sum-note">Estimate only. Final price confirmed after technician inspection.</p>
</div>
</aside>
</main>
</div>
<!-- Success overlay -->
<div class="overlay" id="overlay" role="dialog" aria-modal="true" aria-labelledby="okTitle" hidden>
<div class="ok-card">
<div class="ok-badge" aria-hidden="true">
<svg viewBox="0 0 24 24" width="30" height="30" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>
</div>
<h2 id="okTitle">Appointment booked</h2>
<p id="okSub">We’ll text you when your vehicle is in the bay.</p>
<dl class="ok-grid">
<div><dt>Work order</dt><dd class="mono" id="okWO">RO-58213</dd></div>
<div><dt>When</dt><dd id="okWhen">—</dd></div>
<div><dt>Vehicle</dt><dd id="okVeh">—</dd></div>
<div><dt>Estimate</dt><dd class="mono" id="okTotal">—</dd></div>
</dl>
<button class="ok-btn" id="okClose">Done</button>
</div>
</div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<script src="script.js"></script>
</body>
</html>Book Service Appointment
An industrial, status-forward booking page for a fictional auto shop, Apex Motorworks. The layout pairs a stepped form with a sticky estimate summary. Customers start by selecting a vehicle card (with plate, odometer and VIN), then toggle one or more services — each row shows its service code such as LOF-05 or diagnostic P0301, labor time and an estimated price.
The right-hand panel reacts in real time: selecting services rebuilds the line items and recomputes parts, labor (charged per hour), the chosen lounge/loaner option, shop fee and tax. A horizontally scrollable date strip skips the Sunday closure, and the time-slot grid shows automatic bay assignments with some slots already taken. Picking a slot holds it with a toast, and the Confirm button only unlocks once a vehicle, service, date and slot are all set.
Confirming opens a success dialog with a generated work-order number, the scheduled time and bay, the vehicle and the final estimate. Everything is vanilla JS — no frameworks — with keyboard-usable controls, ARIA radio/pressed states, tabular figures for money and odometer, and a responsive layout that collapses to a mobile-first single column down to ~360px.
Illustrative UI only — fictional shop/dealership, not a real service system.