/* [STOCK_WEB_v1] stock.ashira-group.com */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1c2330;
  --muted: #667085;
  --line: #e3e6eb;
  --brand: #1f5fbf;
  --brand-ink: #ffffff;
  --ok: #17803d;
  --warn: #b35c00;
  --bad: #c0262d;
  --chip: #eef2f7;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Sarabun", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
small, .muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---- layout */
header.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
header.top .brand { font-weight: 700; color: var(--ink); }
header.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
header.top nav a { white-space: nowrap; padding: 6px 10px; border-radius: 8px; color: var(--ink); }
header.top nav a.on { background: var(--chip); font-weight: 600; }
header.top nav a:hover { text-decoration: none; background: var(--chip); }
header.top .who { font-size: 13px; color: var(--muted); }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }

/* ---- tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
th { background: #fafbfc; font-weight: 600; font-size: 13px; color: var(--muted); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f3f7fd; }
tr.group td { background: #fafbfc; font-weight: 600; }
tfoot td { font-weight: 700; background: #fafbfc; }

/* ---- forms */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  padding: 7px 9px; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d0f5; border-color: var(--brand); }
input[type="checkbox"] { width: auto; }
.field { min-width: 140px; flex: 1; }
.field.s { flex: 0 0 110px; min-width: 90px; }
.check { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--ink); }
button, .btn {
  font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid #cfd4dc; background: #fff; color: var(--ink);
}
button:hover, .btn:hover { background: var(--chip); text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: #f0c2c4; }
button.small { padding: 3px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---- chips */
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--chip); white-space: nowrap; }
.chip.draft { background: #eef0f3; color: #475467; }
.chip.invoiced { background: #e8f0fd; color: #1f5fbf; }
.chip.shipped { background: #fff3e0; color: #b35c00; }
.chip.delivered { background: #e6f6ec; color: #17803d; }
.chip.cancelled { background: #fdecec; color: #c0262d; text-decoration: line-through; }
.chip.ok { background: #e6f6ec; color: #17803d; }
.chip.warn, .chip.return_pending { background: #fff3e0; color: #b35c00; }
.chip.returned { background: #eef0f3; color: #475467; }
.chip.confirmed { background: #e8f0fd; color: #1f5fbf; }
.chip.billed { background: #e6f6ec; color: #17803d; }
.chip.stock { background: #e8f0fd; color: #1f5fbf; }
.chip.nonstock { background: #f3eefc; color: #6941c6; }

/* ---- messages, dialog */
.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.msg.err { background: #fdecec; color: var(--bad); }
.msg.ok { background: #e6f6ec; color: var(--ok); }
.msg.info { background: #e8f0fd; color: #1f4f99; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); }
dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100% - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
dialog .dhead { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
dialog .dbody { padding: 16px; }
dialog .dfoot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---- requisition lines editor */
.line { display: grid; grid-template-columns: 110px 1fr 90px 36px; gap: 8px; align-items: end; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.line .pick { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.line .free { display: grid; grid-template-columns: 1.6fr 1fr 110px; gap: 8px; }
@media (max-width: 760px) {
  .line { grid-template-columns: 1fr 90px 36px; }
  .line .kind { grid-column: 1 / -1; }
  .line .pick, .line .free { grid-template-columns: 1fr; grid-column: 1 / -1; }
  header.top nav { order: 3; flex: 0 0 100%; overflow-x: auto; flex-wrap: nowrap; }
}
.loading { color: var(--muted); padding: 24px 0; }
