:root {
  --blue: #172BD2; --blue-dark: #0F1E9A; --mist: #8EB1C8; --mist-soft: #EEF3F7;
  --bg: #F2F4F7; --card: #FFFFFF; --text: #1A1D29; --muted: #4A5163; --line: #E3E8EE; --input: #C9D3DD;
  --ok-bg: #E7F5EC; --ok: #1E5E36; --warn-bg: #FFF4E5; --warn: #7A4A00; --err-bg: #FDECEA; --err: #B42318;
  --radius: 12px; --nav-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Noto Sans Thai', system-ui, sans-serif; font-size: 15px; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.top { position: sticky; top: 0; z-index: 5; background: var(--blue); color: #fff; padding: calc(16px + env(safe-area-inset-top)) 18px 14px; display: flex; align-items: flex-end; gap: 12px; }
.top-text { flex: 1; min-width: 0; }
.top-sub { font-size: 13px; color: #D6E2EC; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top h1 { margin: 2px 0 0; font-size: 21px; font-weight: 700; }
.top-action a, .top-action button { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--mist); color: #fff; background: transparent; text-decoration: none; font-size: 13px; cursor: pointer; }
.back { color: #D6E2EC; text-decoration: none; font-size: 13px; }
.main { flex: 1; padding: 14px 14px calc(var(--nav-h) + 90px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 16px; }
.card h3 { margin: 0; font-size: 14px; color: var(--muted); font-weight: 500; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.right { text-align: right; }
.b { font-weight: 700; }
.blue { color: var(--blue); }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; min-width: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--input); border-radius: 8px; background: #fff; font-size: 15px; }
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 16px; border-radius: 12px; border: none; background: var(--blue); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.alt { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
.btn.ghost { background: #fff; color: var(--muted); border: 1px solid var(--input); font-weight: 500; }
.btn.danger { background: #fff; color: var(--err); border: 1px solid #F1B7B0; }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.dashed { min-height: 44px; border-radius: 8px; border: 1px dashed var(--mist); background: #F5F8FB; color: var(--blue); cursor: pointer; width: 100%; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--mist); background: #fff; color: var(--blue); cursor: pointer; font-size: 14px; }
.chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: #E3E8EE; border-radius: 12px; padding: 4px; }
.seg button { min-height: 40px; border: none; background: transparent; border-radius: 9px; color: var(--muted); cursor: pointer; font-size: 14px; }
.seg button.on { background: #fff; color: var(--blue); font-weight: 700; }
.pill { display: inline-block; flex-shrink: 0; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #EEF1F4; color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.blue { background: #E8EBFC; color: var(--blue); }
.note { border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.6; }
.note.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #F0C27A; }
.note.err { background: var(--err-bg); color: var(--err); border: 1px solid #F1B7B0; }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.info { background: var(--mist-soft); color: #1A3550; }
.note ul { margin: 6px 0 0; padding-left: 20px; }
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.li:last-child { border-bottom: none; }
.li .t { font-weight: 500; }
.datebox { width: 46px; height: 46px; border-radius: 10px; background: var(--mist-soft); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; flex-shrink: 0; }
.datebox b { font-size: 16px; color: var(--blue); }
.datebox span { font-size: 11px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: #fff; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-size: 19px; }
.qty { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qty button { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--mist); background: #fff; color: var(--blue); font-size: 20px; cursor: pointer; }
.qty button.plus { background: var(--blue); color: #fff; border-color: var(--blue); }
.qty input { width: 56px; text-align: center; font-weight: 700; padding: 8px 4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 4px; border-bottom: 1px solid #EEF1F4; vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; white-space: nowrap; }
.est { color: var(--warn); font-size: 12px; }
.fab { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); width: min(532px, calc(100% - 28px)); }
.sticky-actions { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); width: min(532px, calc(100% - 28px)); display: flex; gap: 10px; }
.sticky-actions .btn { flex: 1; box-shadow: 0 2px 8px rgba(23,43,210,.18); }
.nav { position: fixed; z-index: 7; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; display: flex; background: #fff; border-top: 1px solid #DDE3EA; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--muted); text-decoration: none; border-top: 3px solid transparent; }
.nav a svg { width: 22px; height: 22px; }
.nav a.on { color: var(--blue); font-weight: 700; border-top-color: var(--blue); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(var(--nav-h) + 80px); transform: translateX(-50%) translateY(20px); background: #1A1D29; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 40px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--err); }
.modal { position: fixed; inset: 0; z-index: 15; background: rgba(10, 15, 40, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 88vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; padding: 14px 16px; gap: 10px; border-bottom: 1px solid var(--line); background: #fff; border-radius: 16px 16px 0 0; }
.sheet-head h2 { margin: 0; font-size: 17px; flex: 1; }
.sheet-body { overflow-y: auto; padding: 12px 14px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.x { width: 40px; height: 40px; border-radius: 50%; border: none; background: #EEF1F4; font-size: 20px; cursor: pointer; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--blue); }
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; gap: 14px; }
.brand { color: var(--blue); font-size: 26px; font-weight: 700; margin: 0; }
details.card summary { cursor: pointer; font-weight: 700; list-style: none; }
details.card summary::after { content: '▾'; float: right; color: var(--muted); }
details[open].card summary::after { content: '▴'; }
@media (min-width: 600px) { .main { padding-left: 0; padding-right: 0; } }
