/* PackSure — โต๊ะแพ็คของ: พื้นเทาอมฟ้าเย็น หมึกน้ำเงินโคบอลต์ ตัวเลขโมโน */
:root {
  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --fg: #151922;
  --muted: #5c6475;
  --line: #dde1e8;
  --accent: #ff5a00;
  --accent-soft: #fff2e8;
  --accent-ink: #ffffff;
  --navy: #092648;
  --ok: #0f7a57;
  --ok-soft: #e1f4ec;
  --warn: #a86400;
  --warn-soft: #fbf0dc;
  --bad: #c42b2b;
  --bad-soft: #fbe6e6;
  --rec: #e3262b;
  --shadow: 0 1px 2px rgb(20 24 34 / .06), 0 4px 16px rgb(20 24 34 / .05);
  --font: 'IBM Plex Sans Thai', 'Leelawadee UI', Tahoma, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117; --surface: #171b23; --surface-2: #1d222c; --fg: #e8eaf0; --muted: #9aa2b2; --line: #2a303c;
    --accent: #ff7524; --accent-soft: #361706; --accent-ink: #ffffff;
    --navy: #1e3a60;
    --ok: #45c79a; --ok-soft: #12291f; --warn: #e5a944; --warn-soft: #2d2412; --bad: #ff7272; --bad-soft: #321718;
    --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1117; --surface: #171b23; --surface-2: #1d222c; --fg: #e8eaf0; --muted: #9aa2b2; --line: #2a303c;
  --accent: #ff7524; --accent-soft: #361706; --accent-ink: #ffffff;
  --navy: #1e3a60;
  --ok: #45c79a; --ok-soft: #12291f; --warn: #e5a944; --warn-soft: #2d2412; --bad: #ff7272; --bad-soft: #321718;
  --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; font-weight: 600; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--accent); }
.mono, code { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.label-caps { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
[hidden] { display: none !important; }

/* controls */
button, .btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: .4em; padding: .55em 1em; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-lg { font-size: 1.05rem; padding: .8em 1.4em; }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .55em .7em; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: .3em; font-size: .88rem; color: var(--muted); }
label.field > span { font-weight: 500; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.card > h2, .card-head { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: .35em; padding: .15em .6em; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.s-pending { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill.s-packing { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pill.s-packed { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pill.s-shipped, .pill.s-in_transit, .pill.s-out_for_delivery { color: var(--accent); background: transparent; border-color: var(--accent); }
.pill.s-delivered { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill.s-returned, .pill.s-cancelled { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.stock-low { color: var(--bad); font-weight: 600; }

/* toast */
#toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 100; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: .92rem; animation: tin .18s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes tin { from { transform: translateY(6px); opacity: 0; } }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgb(10 12 18 / .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; box-shadow: var(--shadow); }
.modal h2 { margin-bottom: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
