:root { --blue: #0A84E0; --yellow: #FFC400; --navy: #0B2742; --bg: #F3F6FA; --line: #E1E7EF; --text: #14202E; --muted: #627286; --red: #D92D20; --green: #12805C; }
* { box-sizing: border-box; }
[hidden], input[type=hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.5 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif; }
a { color: inherit; text-decoration: none; }
h1, h3 { margin: 0; line-height: 1.3; } h1 { font-size: 21px; font-weight: 800; } h3 { font-size: 15.5px; font-weight: 700; margin-bottom: 12px; }
button, input, select, textarea { font: inherit; color: inherit; } button { cursor: pointer; }
.muted { color: var(--muted); font-weight: 400; } .r { text-align: right; } .err, .bad-text { color: var(--red); font-weight: 600; min-height: 1.2em; }
.loading { padding: 48px; text-align: center; color: var(--muted); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 1px; }
.logo { font-weight: 800; font-size: 26px; letter-spacing: -.5px; line-height: 1; } .logo span:first-child { color: var(--blue); } .logo span:nth-child(2) { color: var(--yellow); }
.logo small { display: block; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: #9FB3C8; font-weight: 600; margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 16px; font-weight: 700; white-space: nowrap; }
.btn:hover { filter: brightness(.96); } .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; } .btn.danger { color: var(--red); border-color: #F3C3BF; }
.btn.sm { padding: 5px 11px; font-size: 13px; } .btn.block { display: flex; width: 100%; padding: 12px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--navy); }
.login .panel { width: min(380px, 100%); text-align: center; } .login label { text-align: left; } .login .logo { font-size: 38px; }

.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--navy); color: #C9D6E4; padding: 20px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { padding: 0 10px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; font-weight: 600; }
.side nav a:hover { background: rgba(255,255,255,.08); } .side nav a.on { background: var(--blue); color: #fff; }
.side nav i { font-style: normal; width: 20px; text-align: center; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 10px; font-size: 13px; } .side-foot a { color: var(--yellow); font-weight: 600; }
.side-foot .btn { background: transparent; color: #C9D6E4; border-color: rgba(255,255,255,.25); }
.content { padding: 22px 26px 60px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; } .top-actions { display: flex; gap: 8px; }

.panel { background: #fff; border-radius: 14px; padding: 18px 20px; box-shadow: 0 1px 2px rgba(11,39,66,.06), 0 4px 14px rgba(11,39,66,.05); margin-bottom: 16px; display: block; }
.panel.erp { background: #F7FAFD; border: 1.5px dashed #B9CBDD; box-shadow: none; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: 14px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(11,39,66,.06); display: flex; flex-direction: column; border-top: 4px solid var(--blue); }
.stat:nth-child(even) { border-top-color: var(--yellow); } .stat span { color: var(--muted); font-weight: 600; font-size: 13px; } .stat b { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; } .stat small { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } .zone:hover { outline: 2px solid var(--blue); }
.codes { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 0; align-items: center; color: var(--muted); } .codes span { background: var(--bg); border-radius: 6px; padding: 1px 7px; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text); }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label > input:not([type=checkbox]):not([type=color]), label > select, textarea, .toolbar input, .row input, .row select { display: block; width: 100%; margin-top: 4px; padding: 8px 11px; border: 1.5px solid var(--line); border-radius: 9px; background: #fff; font-weight: 400; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }
textarea { resize: vertical; font-family: inherit; margin-bottom: 10px; }
input[type=color] { display: block; width: 100%; height: 38px; margin-top: 4px; border: 1.5px solid var(--line); border-radius: 9px; padding: 2px; background: #fff; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; } .check input { width: 16px; height: 16px; accent-color: var(--blue); flex: none; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .f3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.savebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; } .toolbar form { display: flex; gap: 8px; flex: 1; min-width: 240px; } .toolbar input { margin: 0; }
.seg { display: inline-flex; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: 7px; padding: 6px 13px; font-weight: 600; color: var(--muted); } .seg button.on { background: var(--blue); color: #fff; }
.seg.big { margin-bottom: 16px; } .seg.big button { padding: 9px 22px; font-size: 15px; }
.rows { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.row { display: flex; gap: 8px; width: 100%; align-items: center; } .row input, .row select { margin: 0; } .row input[type=color] { height: 37px; padding: 2px; min-width: 44px; } .row input[type=hidden] { display: none; }
.imgcell { display: flex; gap: 6px; min-width: 0; align-items: center; } .imgcell input { flex: 1; }
.x { border: 0; background: none; font-size: 21px; line-height: 1; color: var(--muted); flex: none; padding: 2px 6px; } .x:hover { color: var(--red); }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.thumb { width: 92px; height: 92px; border: 1.5px solid var(--line); border-radius: 10px; position: relative; overflow: hidden; background: #fff; margin: 0; }
.thumb img { width: 100%; height: 100%; object-fit: contain; } .thumb .x { position: absolute; top: 2px; right: 2px; background: rgba(255,255,255,.92); border-radius: 50%; }
.thumb.add { display: grid; place-items: center; font-size: 30px; color: var(--muted); border-style: dashed; cursor: pointer; font-weight: 400; }

.scroll { overflow-x: auto; } table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: top; } th { border: 0; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; } td small { color: var(--muted); }
table.click tbody tr { cursor: pointer; } table.click tbody tr:hover { background: #F4F9FE; } tr.grand td { font-weight: 800; font-size: 16px; }
.pager { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; } .pager button { border: 1.5px solid var(--line); background: #fff; border-radius: 7px; min-width: 34px; padding: 4px; } .pager .on { background: var(--blue); border-color: var(--blue); color: #fff; }
.pill { display: inline-block; background: #E9EEF4; color: #41536A; border-radius: 99px; padding: 1px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok, .st-delivered { background: #E3F4EC; color: #0B5C41; } .pill.warn, .st-pending { background: #FFF3C4; color: #7A5B00; } .pill.bad, .st-cancelled { background: #FDE7E5; color: #A1221A; }
.st-confirmed, .st-packing, .st-shipping { background: #E1F0FD; color: #075A9C; }
dl { margin: 0; } .kv div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-top: 1px solid var(--line); } .kv div:first-child { border: 0; } dt { color: var(--muted); flex: none; } dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.addr { padding: 10px 0; border-top: 1px solid var(--line); } .addr:first-of-type { border: 0; padding-top: 0; } .addr small { display: block; color: var(--muted); }
.note { background: #FFF8DC; border-radius: 9px; padding: 9px 13px; margin: 12px 0 0; }
ul.plain { margin: 0 0 12px; padding-left: 18px; } ul.plain li { margin-bottom: 6px; }
pre { background: var(--navy); color: #D5E4F3; padding: 14px; border-radius: 10px; overflow: auto; font-size: 12.5px; } code { background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
summary { cursor: pointer; font-weight: 700; }
.toast { position: fixed; bottom: 22px; left: 50%; translate: -50% 0; background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 999px; z-index: 60; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--red); } .toast[hidden] { display: none; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; } .side { position: static; height: auto; padding: 12px; gap: 10px; } .side nav { flex-direction: row; overflow-x: auto; } .side nav a { white-space: nowrap; }
  .side-foot { flex-direction: row; align-items: center; margin: 0; } .content { padding: 16px; }
  .cols, .cards { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row { flex-wrap: wrap; } .row > * { flex-basis: 40% !important; }
}
