/* PriceTag vendor portal. Brand tokens follow the prototype (navy + orange, Bai Jamjuree for headings,
   Noto Sans Thai for text). Tables collapse into cards below 760px. */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --ink: #0d1934;
  --muted: #5a667e;
  --line: #d9dfea;
  --soft: #eaeef6;
  --navy: #00184a;
  --blue: #0b4fe0;
  --accent: #fe9300;
  --accent-soft: #fff3e0;
  --accent-ink: #8a4a00;
  --good: #0f7a55;
  --good-soft: #e3f5ee;
  --bad: #c0322b;
  --bad-soft: #fde9e7;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --radius: 12px;
  --display: "Bai Jamjuree", "Noto Sans Thai", system-ui, sans-serif;
  --body: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--body); }
img { max-width: 100%; }
a { color: var(--blue); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); color: var(--navy); line-height: 1.3; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
[hidden] { display: none !important; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 20px 16px 64px; outline: none; }
.loading, .muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand span { font-family: var(--display); font-weight: 700; color: var(--navy); font-size: 15px; padding-left: 10px;
  border-left: 1px solid var(--line); white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 8px; color: var(--muted);
  font-weight: 600; text-decoration: none; white-space: nowrap; }
.tabs a:hover { background: var(--soft); color: var(--navy); }
.tabs a[aria-current="page"] { background: var(--navy); color: #fff; }
.tabs .sep { width: 1px; background: var(--line); margin: 6px 6px; }
.tabs .count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--navy);
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.who { display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 13px; color: var(--muted); }
.who b { color: var(--ink); font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role { padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: 12px; }
.demo-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; padding: 8px 16px;
  background: var(--navy); color: #fff; font-size: 13px; text-align: center; }
.demo-bar button { background: none; border: 1px solid rgba(255, 255, 255, .5); color: #fff; border-radius: 6px; padding: 2px 10px;
  font: inherit; cursor: pointer; }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--navy); font: inherit;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--navy); }
.btn.primary:hover { background: #ffa526; }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.dark:hover { background: #0a2a6b; }
.btn.danger { color: var(--bad); }
.btn.good { color: var(--good); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.link { border: 0; background: none; height: auto; padding: 0; color: var(--blue); text-decoration: underline; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
label { font-weight: 600; font-size: 14px; }
input[type=text], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--ink); font: inherit; }
textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 2px solid rgba(11, 79, 224, .15); outline-offset: 0; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 42px; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }
.check.consent { align-items: flex-start; min-height: 0; }
.check.consent input { flex: none; margin: 3px 0 0; }
.check.consent a { margin-left: 4px; }
.consent + .err { font-size: 12.5px; color: var(--bad); }
.consent + .err:empty { display: none; }
.field { display: grid; gap: 6px; align-content: start; }
.field .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.field .err { font-size: 12.5px; color: var(--bad); }
.req { color: var(--bad); }
.grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid .wide { grid-column: 1 / -1; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 12px; }
legend { font-family: var(--display); font-weight: 700; color: var(--navy); font-size: 15px; padding: 0; margin-bottom: 4px; }

/* Layout pieces */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 18px; }
.page-head > div { display: grid; gap: 4px; }
.page-head .spacer { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.stack { display: grid; gap: 16px; }
.cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 14px;
  background: var(--soft); color: var(--ink); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.good { background: var(--good-soft); color: var(--good); }
.notice b { font-weight: 700; }
.steps { counter-reset: step; display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; }
code { font-size: 13px; background: var(--soft); padding: 1px 6px; border-radius: 4px; }
.legal { max-width: 760px; margin: 0 auto; }
.legal p { margin: 0; }
.legal section { display: grid; gap: 6px; }
.legal ul { margin: 0; padding-left: 20px; }
.site-foot { padding: 0 16px 24px; text-align: center; font-size: 13px; }

/* Stats and chips */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font: inherit; color: inherit; cursor: pointer; }
.stat b { font-family: var(--display); font-size: 24px; color: var(--navy); line-height: 1.2; }
.stat span { font-size: 13px; color: var(--muted); }
.stat[aria-pressed="true"] { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px;
  font-weight: 600; white-space: nowrap; background: var(--soft); color: var(--muted); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; min-width: 180px; }

/* Tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.wide { min-width: 1180px; }
table.wide td:last-child .row { display: grid; grid-template-columns: repeat(2, auto); justify-content: end; }
td.shop { min-width: 130px; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: #f7f9fc; font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
td.right, th.right { text-align: right; }
td .sub { display: block; color: var(--muted); font-size: 12.5px; }
td .strike { color: var(--muted); text-decoration: line-through; font-size: 12.5px; margin-left: 4px; }
td .note { display: block; margin-top: 4px; font-size: 12.5px; color: var(--bad); }
.cell-check { width: 36px; }
.cell-check input { width: 18px; height: 18px; accent-color: var(--navy); }
.prod { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: start; min-width: 220px; }
.thumb { width: 44px; height: 44px; border-radius: 8px; background: var(--soft) center / cover no-repeat; border: 1px solid var(--line); }
.prod b { font-weight: 600; color: var(--ink); }
.empty-state { display: grid; justify-items: center; gap: 10px; padding: 40px 16px; text-align: center; color: var(--muted); }
.empty-state img { width: 84px; }
.key-input { display: grid; gap: 4px; min-width: 220px; }
.key-input input { height: 34px; font-size: 13px; }
.key-input .btn { justify-self: start; }

/* Identity documents */
.doc-help { display: grid; gap: 8px; padding: 12px 14px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.doc-help ul { margin: 0; padding-left: 20px; }
.doc-help img { max-width: 360px; border-radius: 8px; border: 1px solid var(--line); }
.docs { display: grid; gap: 10px; }
.doc-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; }
.doc-row > div:first-child { min-width: 0; flex: 1 1 240px; }
.doc-row .sub { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.doc-row input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.doc-row label.btn { position: relative; }
.doc-row label.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Shop statistics */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.kpi { display: grid; gap: 2px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.kpi b { font-family: var(--display); font-size: 24px; color: var(--navy); line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 13px; color: var(--muted); }
.chart { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 2px; height: 180px; align-items: end;
  border-bottom: 1px solid var(--line); }
.chart .day { position: relative; display: flex; align-items: flex-end; height: 100%; }
.chart .day i { display: block; width: 100%; max-width: 16px; margin: 0 auto; background: var(--blue); border-radius: 4px 4px 0 0; }
.chart .day:hover i { background: var(--navy); }
.chart .day .tip { display: none; position: absolute; bottom: calc(100% - 28px); left: 50%; transform: translateX(-50%); z-index: 2;
  padding: 4px 8px; border-radius: 6px; background: var(--navy); color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none; }
.chart .day:nth-child(-n+5) .tip { left: 0; transform: none; }
.chart .day:nth-last-child(-n+5) .tip { left: auto; right: 0; transform: none; }
.chart .day:hover .tip { display: block; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
details summary { cursor: pointer; font-size: 13px; color: var(--blue); }

/* Upload */
.drop { display: grid; justify-items: center; gap: 8px; padding: 32px 16px; border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--surface); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop b { font-family: var(--display); color: var(--navy); font-size: 17px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.issues { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: 12.5px; color: var(--bad); }
.changes { margin: 0 0 6px; padding: 0; list-style: none; display: grid; gap: 2px; font-size: 12.5px; }
.changes b { font-weight: 600; color: var(--muted); }
.row-same { color: var(--muted); font-weight: 600; white-space: nowrap; }
.row-ok { color: var(--good); font-weight: 600; white-space: nowrap; }
.row-bad { color: var(--bad); font-weight: 600; white-space: nowrap; }
.row-upd { color: var(--blue); font-weight: 600; white-space: nowrap; }

/* Login */
.login { max-width: 440px; margin: 40px auto; }
.login .card { gap: 16px; padding: 28px 24px; }
.login .mascot { width: 72px; justify-self: center; }
.login h1 { text-align: center; }
.login p.lead { text-align: center; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Dialog and toast */
.dialog { width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 24, 74, .3); color: var(--ink); }
.dialog.narrow { width: min(480px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(0, 24, 74, .45); }
.dialog form { display: grid; gap: 0; }
.dialog .d-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog .d-body { padding: 18px 20px; display: grid; gap: 20px; }
.dialog .d-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line);
  position: sticky; bottom: 0; background: var(--surface); }
.dialog .x { margin-left: auto; width: 36px; height: 36px; padding: 0; font-size: 20px; }
.history { margin: 0; padding: 0; list-style: none; font-size: 13px; display: grid; gap: 4px; }
.history li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 24, 74, .3); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

@media (max-width: 760px) {
  .topbar { gap: 8px 12px; }
  .brand span { display: none; }
  .tabs { order: 3; flex-basis: 100%; }
  .who b { max-width: 140px; }
  h1 { font-size: 21px; }
  .cards-sm thead { display: none; }
  table.cards-sm.wide { min-width: 0; }
  table.wide.cards-sm td:last-child .row { display: flex; flex-wrap: wrap; justify-content: flex-start; }
  .cards-sm .prod { min-width: 0; padding-right: 32px; }
  .cards-sm, .cards-sm tbody, .cards-sm tr, .cards-sm td { display: block; width: 100%; }
  .cards-sm tr { padding: 12px; border-bottom: 1px solid var(--line); position: relative; }
  .cards-sm td { border: 0; padding: 3px 0; }
  .cards-sm td[data-label]::before { content: attr(data-label) " · "; color: var(--muted); font-size: 12.5px; }
  .cards-sm td.cell-check { position: absolute; right: 12px; top: 12px; width: auto; }
  .cards-sm td.right { text-align: left; }
  .toolbar input[type=search], .toolbar select { max-width: none; flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
