:root {
  --blue-950: #0a1f5c;
  --blue-800: #123a9c;
  --blue-700: #1746c0;
  --blue-600: #1d5ce6;
  --blue-200: #c7d8fb;
  --blue-100: #e3ecfd;
  --blue-50: #f2f6ff;
  --ink: #12203f;
  --muted: #55627f;
  --line: #d5def2;
  --green: #0d7a55;
  --green-bg: #e2f5ec;
  --red: #b42318;
  --red-bg: #fdecea;
  --amber: #8a4b00;
  --amber-bg: #fff3d6;
  --radius: 16px;
  font-size: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--blue-50);
  color: var(--ink);
  font-family: "Noto Sans Thai", "Sarabun", "Thonburi", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}
h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
small, .small { font-size: 0.82rem; }
.muted { color: var(--muted); }

/* ---------- ส่วนหัว ---------- */
.demo-banner {
  position: sticky; top: 0; z-index: 20;
  background: var(--amber-bg); color: var(--amber);
  border-bottom: 2px solid #f0c36b;
  padding: 8px 16px; text-align: center; font-size: 0.85rem; line-height: 1.35;
}
.demo-banner strong { display: block; font-size: 1rem; }

.topbar {
  background: var(--blue-800); color: #fff;
  padding: 14px 16px 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
}
.brand { font-size: 1.5rem; font-weight: 800; letter-spacing: 0.2px; }
.tagline { opacity: 0.9; }
.clock-note {
  flex-basis: 100%; background: #ffffff22; border-radius: 10px; padding: 4px 10px;
  font-size: 0.85rem;
}

.roles {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: var(--blue-800); padding: 0 12px 12px;
}
.roles a {
  display: flex; align-items: center; justify-content: center;
  min-height: 48px; border-radius: 12px; color: #fff; text-decoration: none; font-weight: 700;
  background: #ffffff1f; text-align: center; font-size: 0.95rem;
}
.roles a[aria-current="page"] { background: #fff; color: var(--blue-800); }
.roles a.role-test { background: #ffffff10; font-weight: 500; }
.roles a.role-test[aria-current="page"] { background: #fff; color: var(--blue-800); font-weight: 700; }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 24px; display: grid; gap: 14px; }

.foot { max-width: 640px; margin: 0 auto; padding: 8px 16px 40px; color: var(--muted); font-size: 0.8rem; text-align: center; }

/* ---------- การ์ดและข้อความ ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: grid; gap: 12px; box-shadow: 0 1px 2px #0a1f5c14;
}
.card.accent { border-color: var(--blue-600); border-width: 2px; }
.card > h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-note { color: var(--muted); font-size: 0.88rem; }

.notice { border-radius: 12px; padding: 12px 14px; font-size: 0.95rem; }
.notice.info { background: var(--blue-100); color: var(--blue-950); }
.notice.warn { background: var(--amber-bg); color: var(--amber); }
.notice.bad { background: var(--red-bg); color: var(--red); }
.notice.good { background: var(--green-bg); color: var(--green); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 700; background: var(--blue-100); color: var(--blue-800); white-space: nowrap;
}
.chip.ok { background: var(--green-bg); color: var(--green); }
.chip.wait { background: var(--amber-bg); color: var(--amber); }
.chip.off { background: #e8ebf3; color: #4a5470; }
.chip.bad { background: var(--red-bg); color: var(--red); }

/* ---------- ปุ่มและฟอร์ม ---------- */
.btn {
  appearance: none; border: 2px solid transparent; cursor: pointer;
  min-height: 58px; padding: 10px 18px; border-radius: 14px; width: 100%;
  font: inherit; font-weight: 800; font-size: 1.1rem; text-align: center;
  background: var(--blue-600); color: #fff;
}
.btn:hover { background: var(--blue-700); }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.btn:focus-visible, .choice:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .roles a:focus-visible {
  outline: 3px solid #f5a524; outline-offset: 2px;
}
.btn.secondary { background: #fff; color: var(--blue-700); border-color: var(--blue-600); }
.btn.secondary:hover { background: var(--blue-100); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-bg); }
.btn.danger.confirm { background: var(--red); color: #fff; }
.btn.small { min-height: 46px; font-size: 0.95rem; width: auto; padding: 6px 14px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: grid; gap: 10px; }
.btn-row.two { grid-template-columns: 1fr 1fr; }

label, .label { display: grid; gap: 6px; font-weight: 700; }
.label-title { font-weight: 700; }
input[type="text"], input[type="tel"], input[type="date"], input[type="time"], select, textarea {
  font: inherit; font-weight: 400; width: 100%; min-height: 54px; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
.hint { font-size: 0.85rem; color: var(--muted); font-weight: 400; }

.choices { display: grid; gap: 8px; }
.choice {
  appearance: none; cursor: pointer; font: inherit; text-align: left; width: 100%;
  min-height: 58px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 700; font-size: 1.05rem;
  display: flex; align-items: center; gap: 10px;
}
.choice::before { content: ""; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--blue-600); flex: none; }
.choice[aria-pressed="true"] { border-color: var(--blue-600); background: var(--blue-100); color: var(--blue-950); }
.choice[aria-pressed="true"]::before { background: radial-gradient(var(--blue-600) 45%, #fff 50%); }

/* ---------- เส้นทาง / สถานะ ---------- */
.route { display: grid; gap: 2px; }
.route .stop { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; }
.route .dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 6px; flex: none; }
.route .dot.from { background: var(--blue-600); }
.route .dot.to { background: var(--green); }
.route .meet { margin-left: 24px; font-weight: 400; font-size: 0.88rem; color: var(--muted); }
.route .line { margin-left: 6px; width: 2px; height: 14px; background: var(--blue-200); }

.status-big { font-size: 1.35rem; font-weight: 800; color: var(--blue-800); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.95rem; }
.steps li::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--blue-200); flex: none;
}
.steps li.done { color: var(--ink); }
.steps li.done::before { background: var(--blue-600); border-color: var(--blue-600); }
.steps li.now { color: var(--blue-800); font-weight: 800; }
.steps li.now::before { background: #fff; border: 4px solid var(--blue-600); }

.driver-card { display: grid; grid-template-columns: 76px 1fr; gap: 6px 14px; align-items: center; }
.driver-card img { width: 76px; height: 76px; border-radius: 16px; background: var(--blue-100); }
.driver-card .name { font-size: 1.15rem; font-weight: 800; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; word-break: break-word; }
.kv.wide { grid-column: 1 / -1; }

.target { background: var(--blue-100); border-radius: 12px; padding: 10px 14px; color: var(--blue-950); font-size: 0.92rem; }

/* ---------- แถวรายการ ---------- */
.rows { display: grid; gap: 10px; }
.row { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 8px; background: #fff; }
.row-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-head strong { font-size: 1rem; }
.assign { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.assign select { min-height: 48px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; color: var(--blue-800); line-height: 1.2; }
.stat span { font-size: 0.78rem; color: var(--muted); }

details summary { cursor: pointer; font-weight: 700; color: var(--blue-700); min-height: 32px; }
details ul { margin: 6px 0 0; padding-left: 20px; font-size: 0.88rem; color: var(--muted); }
.days { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.days li { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 12px; }
.inline { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.empty { color: var(--muted); text-align: center; padding: 10px; }
.big-clock { font-size: 2rem; font-weight: 800; color: var(--blue-800); font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 50;
  max-width: min(92vw, 560px); background: var(--blue-950); color: #fff; border-radius: 14px;
  padding: 12px 18px; font-weight: 700; box-shadow: 0 6px 24px #0a1f5c55; font-size: 0.95rem;
}
.toast.bad { background: var(--red); }
.toast.good { background: var(--green); }
.noscript { padding: 16px; color: var(--red); text-align: center; }

@media (min-width: 600px) {
  .btn-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .choice { transition: background 0.12s, border-color 0.12s; }
}

/* ---------- เวลาโดยประมาณ ---------- */
.eta { background: var(--blue-100); border-radius: 14px; padding: 12px 14px; display: grid; gap: 2px; }
.eta-big { font-size: 1.5rem; font-weight: 800; color: var(--blue-800); line-height: 1.3; }
.eta-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.eta-choices .choice { justify-content: center; padding: 8px 6px; min-height: 54px; }
.eta-choices .choice::before { display: none; }

/* ---------- ปุ่มโทร และรูปจุดนัดรับ ---------- */
.btn.call { background: var(--green); }
.btn.call:hover { background: #09644a; }
.call-wrap { grid-column: 1 / -1; display: grid; }
label.btn { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-row .btn.small { width: 100%; }
.spot-photo { display: block; width: 100%; max-height: 320px; object-fit: contain; background: var(--blue-50); border: 1px solid var(--line); border-radius: 12px; }
.route .spot-photo { margin: 6px 0 6px 24px; width: calc(100% - 24px); }
.photo-edit { display: grid; gap: 8px; }

/* ---------- แท็บย่อยของผู้ดูแล ---------- */
.subnav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 5px; }
.subnav a { display: flex; align-items: center; justify-content: center; min-height: 46px; border-radius: 10px; text-decoration: none; color: var(--blue-700); font-weight: 700; }
.subnav a[aria-current="page"] { background: var(--blue-600); color: #fff; }

/* ---------- หน้าเว็บจริง (live) ---------- */
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; font-size: 0.95rem; }
.check input[type="checkbox"] { width: 26px; height: 26px; flex: none; margin-top: 2px; accent-color: var(--blue-600); }
.live-head { background: var(--blue-800); color: #fff; padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.live-head .brand { font-size: 1.4rem; }
a.btn.call { flex-direction: column; gap: 2px; }
