/* The mockups' plain style: Sarabun, navy, light surfaces, 8px corners, taps of 44px or more. No yellow. */
:root {
  --navy:#0B2545; --text:#1B2A41; --muted:#5B6B82; --line:#D9DEE7; --soft:#F5F7FA; --white:#fff;
  --ok:#1E7B4F; --bad:#B3261E; --neutral:#3D5A80;
  --ok-soft:#E6F2EC; --bad-soft:#FBEAE9; --neutral-soft:#E8EEF5;
  --gutter:16px; --r:8px;
}
* { box-sizing:border-box }
html, body { overflow-x:hidden }
body { margin:0; background:var(--soft); color:var(--text); font-family:"Sarabun",Tahoma,sans-serif; font-size:17px; line-height:1.6; font-variant-numeric:tabular-nums }
button, input, select, textarea { font:inherit; color:inherit }
button { cursor:pointer; background:none; border:0 }
a { color:inherit }
h1, h2, h3 { color:var(--navy); margin:0; line-height:1.35 }
h1 { font-size:22px; font-weight:700 }
h2 { font-size:18px; font-weight:700 }
h3 { font-size:17px }
p { margin:0 }
[hidden] { display:none !important }
:focus-visible { outline:2px solid var(--navy); outline-offset:2px }
.wrap { width:100%; max-width:560px; margin-inline:auto; padding-inline:var(--gutter) }
.muted { color:var(--muted); font-size:15px }
.small { font-size:14px }
.mono { font-variant-numeric:tabular-nums; letter-spacing:.02em }
.code { color:var(--muted); font-size:13px; font-weight:400; overflow-wrap:anywhere }

/* chrome */
.top { display:flex; gap:12px; justify-content:space-between; align-items:center; min-height:52px; padding-block:6px; background:var(--navy); color:var(--white); max-width:none; position:sticky; top:0; z-index:5 }
.brand { display:flex; align-items:baseline; gap:10px; white-space:nowrap; flex:none }
.brand b { font-size:20px; letter-spacing:.08em }
.brand span { font-size:15px; opacity:.85 }
.who { font-size:14px; opacity:.9; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
.sections { display:flex; background:var(--white); border-bottom:1px solid var(--line); max-width:none; padding-inline:0 }
.sections a { flex:1; display:flex; align-items:center; justify-content:center; min-height:44px; text-decoration:none; color:var(--muted); border-bottom:3px solid transparent; font-size:15px }
.sections a[aria-current] { color:var(--navy); font-weight:700; border-bottom-color:var(--navy) }
.page { display:grid; gap:16px; padding-block:16px 48px }
.page.has-bar { padding-bottom:180px }
.page > * { min-width:0 }
.title { display:flex; align-items:center; gap:4px; min-height:44px }
.title h1 { flex:1; min-width:0; overflow-wrap:anywhere }
.title .back { min-width:44px; min-height:44px; display:grid; place-items:center; text-decoration:none; font-size:26px; color:var(--navy); margin-left:-12px }
.loading-page { display:grid; place-items:center; min-height:40vh }
.spinner { width:28px; height:28px; border:3px solid var(--line); border-top-color:var(--navy); border-radius:50%; animation:spin .8s linear infinite }
@keyframes spin { to { transform:rotate(360deg) } }

/* blocks */
.card { background:var(--white); border:1px solid var(--line); border-radius:var(--r); padding:14px 16px; display:grid; gap:8px }
.row { display:flex; justify-content:space-between; align-items:baseline; gap:8px 12px; flex-wrap:wrap }
.row.mid { align-items:center }
section { display:grid; gap:10px }
.list { display:grid; gap:8px }
.pill { display:inline-block; padding:2px 10px; border-radius:999px; font-size:13px; white-space:nowrap; font-weight:600; background:var(--neutral-soft); color:var(--neutral) }
.pill.warn { background:var(--bad-soft); color:var(--bad) }
.pill.ok { background:var(--ok-soft); color:var(--ok) }
.item { display:grid; gap:2px; padding:10px 14px; min-height:52px; background:var(--white); border:1px solid var(--line); border-radius:var(--r); text-decoration:none }
.item .row b { color:var(--navy) }
.item .meta, .meta { font-size:15px; color:var(--muted) }
.item-link { text-decoration:none; display:grid; gap:2px; min-height:44px }
.navrow, .hist { display:flex; justify-content:space-between; align-items:center; gap:10px; min-height:52px; padding:10px 14px; background:var(--white); border:1px solid var(--line); border-radius:var(--r); text-decoration:none; color:var(--navy); font-weight:600 }
.hist { font-weight:400; color:var(--text); font-size:15px }
.warnbox { background:var(--bad-soft); color:var(--bad); border-radius:var(--r); padding:10px 12px; display:grid; gap:8px; font-size:15px; text-decoration:none }
.note, .lock { background:var(--neutral-soft); color:var(--navy); border-radius:var(--r); padding:10px 12px; font-size:15px; display:grid; gap:8px }
.err { background:var(--bad-soft); color:var(--bad); padding:10px 12px; border-radius:var(--r) }
.kv { display:grid; grid-template-columns:auto 1fr; gap:6px 14px; margin:0; align-items:center }
.kv dt { color:var(--muted); font-size:15px }
.kv dd { margin:0; display:flex; justify-content:space-between; align-items:center; gap:8px; flex-wrap:wrap; min-width:0; overflow-wrap:anywhere }
.who-card { display:flex; gap:12px; align-items:center }
.avatar { width:56px; height:56px; flex:none; border-radius:50%; background:var(--neutral-soft); color:var(--navy); display:grid; place-items:center; font-size:22px; font-weight:700; object-fit:cover; overflow:hidden }
.avatar.big { width:88px; height:88px; font-size:34px }
.codebig { font-size:30px; font-weight:700; letter-spacing:.2em; color:var(--navy); text-align:center }
.center { text-align:center; display:grid; gap:12px; justify-items:center; padding-block:24px }
.center .button, .center .card { width:100%; max-width:360px }
.center .card { text-align:left }
.vbrand { font-size:28px; font-weight:700; letter-spacing:.1em; color:var(--navy) }
.period { border-left:3px solid var(--line); padding-left:12px; display:grid; gap:2px }
.period.now { border-left-color:var(--navy) }
.answered { color:var(--ok); font-size:15px }
.stats { display:grid; grid-template-columns:repeat(2,1fr); gap:8px }
.stats div { padding:12px 14px; background:var(--white); border:1px solid var(--line); border-radius:var(--r); display:grid }
.stats b { font-size:28px; color:var(--navy) }
.stats span { color:var(--muted); font-size:14px; line-height:1.4 }
/* Stage 5: review signals, each a link that filters the page */
.stats a.sig { padding:12px 14px; background:var(--white); border:1px solid var(--line); border-radius:var(--r); display:grid; text-decoration:none; min-height:44px }
.stats a.sig.hot b { color:var(--bad) }
.hist .linkbtn { white-space:nowrap; flex:none }
.stats a.sig.on { border:2px solid var(--navy); background:var(--neutral-soft) }
.sum { display:grid; grid-template-columns:repeat(3,1fr); border:1px solid var(--line); border-radius:var(--r); background:var(--white); overflow:hidden }
.sum div { padding:12px; border-right:1px solid var(--line); display:grid }
.sum div:last-child { border-right:0 }
.sum b { font-size:26px; color:var(--navy) }
.sum span { font-size:14px; color:var(--muted) }
details summary { min-height:44px; display:flex; align-items:center; justify-content:space-between; cursor:pointer; color:var(--navy); font-weight:700; list-style:none }
details summary::-webkit-details-marker { display:none }
details summary::after { content:'\25BE' }
details[open] summary::after { content:'\25B4' }
.sticky-foot { position:sticky; bottom:0; background:var(--soft); padding-block:8px; display:grid; gap:8px; border-top:1px solid var(--line) }

/* buttons: the tap answers at once; a spinner only after 150 ms */
.button { display:flex; justify-content:center; align-items:center; gap:12px; width:100%; min-height:52px; padding:10px 18px; border-radius:var(--r); background:var(--navy); color:var(--white); border:1px solid var(--navy); font-size:17px; font-weight:600; text-decoration:none; text-align:center; cursor:pointer }
.button-outline { background:var(--white); color:var(--navy) }
.button-bad { background:var(--white); color:var(--bad); border-color:var(--bad) }
.button-danger { background:var(--bad); color:var(--white); border-color:var(--bad) }
.button.tiny { min-height:44px; padding:6px 14px; font-size:15px; width:auto }
.button[disabled], .button.busy { opacity:.5; pointer-events:none }
.button.loading::after { content:''; width:16px; height:16px; border:2px solid currentColor; border-right-color:transparent; border-radius:50%; animation:spin .8s linear infinite }
.linkbtn { min-height:44px; display:inline-flex; align-items:center; color:var(--navy); text-decoration:underline; text-underline-offset:3px; font-size:16px }
.button:active, .item:active, .navrow:active, .hist:active, .linkbtn:active, .title .back:active, .sections a:active, .qty button:active { transform:scale(.97); filter:brightness(.9) }
.ctl { display:flex; gap:8px; flex-wrap:wrap }
.ctl > * { flex:1 1 140px }
.self-start { justify-self:start }

/* forms */
select, textarea, input[type=text], input[type=date], input[type=number], input[type=search] { border:1px solid var(--line); border-radius:var(--r); background:var(--white); padding:10px 12px; min-height:48px; width:100% }
.field { display:grid; gap:6px }
.field > label, .field > span, legend { font-size:15px; color:var(--muted) }
fieldset { border:0; padding:0; margin:0; display:grid; gap:8px; min-width:0 }
.radio { display:flex; align-items:center; gap:10px; min-height:44px; padding:6px 12px; border:1px solid var(--line); border-radius:var(--r); background:var(--white) }
.radio input { width:20px; height:20px; accent-color:var(--navy); flex:none }
.filters { display:grid; grid-template-columns:1fr 1fr; gap:8px }
.option-values { display:grid; grid-template-columns:1fr 1fr; gap:8px }
.option-values input { position:absolute; opacity:0; width:1px; height:1px }
.option-values label { display:flex; align-items:center; min-height:48px; padding:10px 14px; border:1px solid var(--line); border-radius:var(--r); background:var(--white); cursor:pointer; line-height:1.3 }
.option-values input:checked + label { border:2px solid var(--navy); background:var(--neutral-soft); color:var(--navy); font-weight:600 }
.option-values input:focus-visible + label { outline:2px solid var(--navy); outline-offset:2px }
.tabs { display:flex; border-bottom:1px solid var(--line); overflow-x:auto; scrollbar-width:none }
.tabs a { flex:1 1 auto; display:flex; align-items:center; justify-content:center; text-align:center; padding:8px 4px; min-height:44px; text-decoration:none; color:var(--muted); border-bottom:3px solid transparent; font-size:14px; line-height:1.3 }
.tabs a[aria-current] { color:var(--navy); font-weight:700; border-bottom-color:var(--navy) }

/* goods-in grid */
.block { background:var(--white); border:1px solid var(--line); border-radius:var(--r); padding:14px; display:grid; gap:10px }
.block h3 small { font-weight:400; color:var(--muted) }
.grid-scroll { overflow-x:auto }
.grid { border-collapse:separate; border-spacing:3px; width:100% }
.grid th, .grid td { padding:4px 0; text-align:center; min-width:30px; font-size:15px }
.grid th:first-child, .grid td:first-child { text-align:left; color:var(--muted); font-weight:400; white-space:nowrap }
.grid thead th { color:var(--navy); font-weight:600; background:var(--soft); border-radius:6px; font-size:13px }
.grid input { min-width:44px; min-height:52px; padding:0; text-align:center; font-size:19px; font-weight:600; border-color:#9AA6B8 }
.grid td.diff input, .grid td.diff.ro { border:2px solid var(--bad); color:var(--bad); background:var(--bad-soft) }
.grid td.ro { border:1px solid var(--line); border-radius:6px; font-weight:600; min-height:44px }
.flag { display:flex; justify-content:space-between; align-items:center; gap:8px; flex-wrap:wrap; background:var(--soft); border-radius:var(--r); padding:8px 10px; font-size:15px }
.flag.need { background:var(--bad-soft); color:var(--bad) }
.bar { position:fixed; left:0; right:0; bottom:0; background:var(--white); border-top:1px solid var(--line); padding:10px var(--gutter) calc(10px + env(safe-area-inset-bottom)); z-index:5 }
.bar .in { max-width:528px; margin:auto; display:grid; gap:6px }
.bar .hint { font-size:14px; color:var(--bad); min-height:1em }
.qrow { display:flex; align-items:center; gap:14px; flex-wrap:wrap }
.qty { display:flex; align-items:center; border:1px solid var(--line); border-radius:var(--r); overflow:hidden }
.qty button { width:52px; min-height:52px; font-size:22px; color:var(--navy); background:var(--soft) }
.qty input { width:72px; border:0; border-radius:0; text-align:center; font-size:20px; font-weight:600 }
.grid tr.old td { color:var(--muted) }
button.hist { width:100%; text-align:left; font:inherit }
.picks { display:grid; gap:6px; max-height:44vh; overflow-y:auto }
.err ul { margin:6px 0 0; padding-left:20px; font-size:15px }
pre.sample { background:var(--soft); border-radius:var(--r); padding:8px 10px; font-size:14px; margin:0; overflow-x:auto }
.conclude { display:grid; grid-template-columns:1fr auto; gap:8px }
.conclude select { min-height:44px; padding:6px 10px }

/* sheets and toast */
dialog { border:1px solid var(--line); border-radius:12px 12px 0 0; padding:0; width:min(520px,100%); max-width:100%; max-height:92vh; margin:auto auto 0; background:var(--white); color:var(--text) }
dialog::backdrop { background:rgba(11,37,69,.45) }
dialog form { padding:20px var(--gutter) 24px; display:grid; gap:14px }
@media (min-width:600px) { dialog { margin:auto; border-radius:12px } }
#toast { position:fixed; left:50%; bottom:200px; transform:translateX(-50%); opacity:0; pointer-events:none; background:var(--navy); color:var(--white); border-radius:var(--r); padding:10px 16px; font-size:15px; width:max-content; max-width:calc(100% - 32px); z-index:20; transition:opacity 150ms }
#toast.show { opacity:1 }
.center-text { text-align:center }

/* goods out and corrections (Stage 3) */
input.qin { width:88px; min-height:48px; text-align:center; font-size:19px; font-weight:600 }
.radio.cand { align-items:flex-start; padding-block:10px; line-height:1.45 }
.radio.cand input { margin-top:3px }
a.warnbox { font-weight:600 }

/* sign out in the header, outside LINE only */
.linkish { background:none; border:0; padding:0; font:inherit; color:inherit; text-decoration:underline; cursor:pointer }


/* home: the to-do list (Stage 7) */
.homelink { color:inherit; text-decoration:none; font-weight:600; min-height:44px; display:inline-flex; align-items:center }
.hello { font-size:22px; font-weight:700; margin:4px 0 0 }
.tasks { display:grid; gap:10px }
.task { display:flex; align-items:center; gap:12px; padding:12px 14px; min-height:68px; background:var(--white); border:1px solid var(--line); border-radius:var(--r); text-decoration:none; color:inherit }
.task:active { transform:scale(.99) }
.task-n { flex:none; width:44px; height:44px; border-radius:12px; display:grid; place-items:center; font-weight:700; background:var(--neutral-soft); color:var(--navy) }
.task.warn .task-n { background:var(--bad-soft); color:var(--bad) }
.task-t { display:grid; min-width:0 }
.task-t b { color:var(--navy) }
.task-t span { font-size:15px; color:var(--muted); overflow-wrap:anywhere }
.task-go { margin-left:auto; color:var(--muted); font-size:22px }
.done { color:var(--muted) }

/* trial (env TRIAL = "1"): a banner on every page and a dark green header, so nobody mistakes the pilot for go-live */
.trial { position:sticky; top:0; z-index:6; text-align:center; font-size:14px; font-weight:600; padding:4px 12px; background:#E3F1EA; color:#0F5132; border-bottom:1px solid #B7DCC7 }
.is-trial .top { background:#0F5132; top:29px }
