:root {
  --brand: #0f766e; --brand-2: #14b8a6; --brand-soft: #e6f6f4;
  --bg: #f6f8f9; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --ok: #16a34a; --warn: #d97706; --err: #dc2626; --info: #2563eb;
  --radius: 14px; --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);
  font-family: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.55; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
button, input, select, textarea { font: inherit; }
input, select, textarea { width: 100%; padding: .6em .75em; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: transparent; }
input:disabled { background: #f3f4f6; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: .4em; padding: .6em 1.1em; border: 0; border-radius: 10px; background: var(--brand); color: #fff; cursor: pointer; font-weight: 600; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: var(--err); }
.btn.sm { padding: .35em .75em; font-size: .9em; }
button.icon { border: 0; background: none; font-size: 1.2em; cursor: pointer; color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 2rem; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.stat b { display: block; font-size: 2rem; color: var(--brand); }

.form { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .95em; }
.field > span { font-weight: 600; }
.field small { color: var(--muted); font-size: .82em; }
.field.wide { grid-column: 1 / -1; }
.field.check { display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: start; align-content: start; }
.field.check input { width: 1.15em; height: 1.15em; margin: .2em 0 0; }
.field.check small { grid-column: 2; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: .65rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85em; color: var(--muted); font-weight: 600; background: #fafafa; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--brand-soft); }

.badge { display: inline-block; padding: .15em .65em; border-radius: 99px; font-size: .82em; background: #eef2f7; color: #374151; white-space: nowrap; }
.st-pending { background: #fef3c7; color: #92400e; }
.st-confirmed { background: #dbeafe; color: #1e40af; }
.st-picked_up, .st-at_hospital { background: #ede9fe; color: #5b21b6; }
.st-completed { background: #dcfce7; color: #166534; }
.st-cancelled { background: #fee2e2; color: #991b1b; }

.modal-bg { position: fixed; inset: 0; background: rgb(15 23 42 / .45); display: grid; place-items: center; padding: 1rem; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); width: min(860px, 100%); max-height: 92vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 1.25rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: .55em 1em; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs button.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 0 0 .9rem 1rem; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: .45em; width: 12px; height: 12px; border-radius: 50%; background: var(--brand-2); }
.timeline small { color: var(--muted); display: block; }

.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); padding: .75em 1.25em; border-radius: 10px; color: #fff; background: var(--ok); z-index: 99; box-shadow: var(--shadow); }
.toast.err { background: var(--err); }

.login { max-width: 380px; margin: 10vh auto; display: flex; flex-direction: column; gap: .9rem; }
.overlay { position: fixed; inset: 0; background: rgb(255 255 255 / .9); display: grid; place-items: center; font-size: 1.2rem; z-index: 100; }

@media (max-width: 640px) {
  thead { display: none; }
  tr { display: block; border-bottom: 1px solid var(--line); padding: .4rem 0; }
  td { display: flex; gap: .75rem; border: 0; padding: .25rem .75rem; }
  td::before { content: attr(data-label); color: var(--muted); min-width: 40%; font-size: .85em; }
}
