/* Dispatch-desk look: cool paper neutrals, kraft-carton accent, monospace for IDs and numbers.
   System fonts only: Google Fonts and CDNs are blocked in China. */
:root {
  --bg: #f2f3f0; --surface: #fff; --surface-2: #eceee9; --sunk: #e4e7e1;
  --ink: #1d2320; --muted: #5d6661; --line: #d8dbd4;
  --accent: #9a6327; --accent-ink: #fff; --accent-soft: #f3e6d6;
  --ok: #2f7a4b; --ok-soft: #dff0e4; --warn: #9a6200; --warn-soft: #fbecc9;
  --bad: #b3372c; --bad-soft: #f7dcd8; --info: #2f5f9a; --info-soft: #dce7f5;
  --side: #1f2724; --side-ink: #d9dfdb; --side-muted: #8d9892; --side-active: #2d3833;
  --shadow: 0 1px 2px rgba(20,30,25,.06), 0 6px 20px rgba(20,30,25,.07);
  --f-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #131715; --surface: #1b201e; --surface-2: #232927; --sunk: #2a312e;
  --ink: #e6eae7; --muted: #99a39d; --line: #323a36;
  --accent: #d79a55; --accent-ink: #1a1410; --accent-soft: #3a2c1c;
  --ok: #6fc28f; --ok-soft: #1e3427; --warn: #e3b04d; --warn-soft: #3a2f16;
  --bad: #ef7f73; --bad-soft: #42221f; --info: #82aee6; --info-soft: #1d2b3d;
  --side: #0e1110; --side-active: #222a26;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
} }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--f-body); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 700; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 750; letter-spacing: .01em; }
.brand i { width: 26px; height: 20px; border-radius: 3px; background: var(--accent); position: relative; flex: none; }
.brand i::before, .brand i::after { content: ""; position: absolute; background: rgba(255,255,255,.85); }
.brand i::before { left: 0; right: 0; top: 6px; height: 2px; } .brand i::after { top: 0; bottom: 0; left: 12px; width: 2px; }
.brand small { display: block; font-weight: 500; color: var(--side-muted); font-size: 11px; }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--side-ink); font-weight: 550; }
.nav a:hover { background: var(--side-active); }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav a.later { color: var(--side-muted); font-weight: 500; }
.nav .badge { font-family: var(--f-mono); font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--bad); color: #fff; }
.nav .sep { margin: 14px 10px 4px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--side-muted); }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; color: var(--side-muted); display: flex; flex-direction: column; gap: 6px; }
.side .me b { color: var(--side-ink); }
.side .me button { all: unset; cursor: pointer; color: var(--side-ink); text-decoration: underline; width: fit-content; }
.main { min-width: 0; padding: 24px clamp(16px, 3vw, 36px) 64px; display: flex; flex-direction: column; gap: 20px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 12px; align-items: center; }
  .brand { padding: 4px 8px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; width: 100%; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .nav .sep, .nav a.later { display: none; }
  .side .me { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; }
}

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.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.07); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 10px; min-width: 0; width: 100%; }
select.field { padding-right: 6px; }
textarea.field { min-height: 72px; resize: vertical; }
.field:disabled { background: var(--surface-2); color: var(--muted); }
label.lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); min-width: 0; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.form .wide { grid-column: 1 / -1; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* cards & tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; min-width: 0; }
.card > h2 { margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
.tile .v { font-family: var(--f-mono); font-size: 28px; font-weight: 600; line-height: 1.1; }
.tile .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tile.red { border-color: var(--bad); background: var(--bad-soft); } .tile.red .v { color: var(--bad); }
.tile.amber .v { color: var(--warn); }
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 9px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--ink); }
th.num, td.num { text-align: right; }
td { padding: 8px 11px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
tr.is-red td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
td.ref { font-family: var(--f-mono); font-weight: 600; }
td.wrap { white-space: normal; min-width: 180px; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.more { padding: 10px; text-align: center; border-top: 1px solid var(--line); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-created { color: var(--muted); }
.st-at_factory { background: var(--accent-soft); color: var(--accent); }
.st-with_forwarder, .st-in_transit { background: var(--info-soft); color: var(--info); }
.st-arrived, .st-receiving { background: var(--warn-soft); color: var(--warn); }
.st-closed { background: var(--ok-soft); color: var(--ok); }
.st-cancelled { color: var(--muted); text-decoration: line-through; }
.flag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 5px; }
.flag.red { background: var(--bad); color: #fff; }
.flag.amber { background: var(--warn-soft); color: var(--warn); }
.days { font-family: var(--f-mono); font-weight: 600; }
.days.red { color: var(--bad); } .days.amber { color: var(--warn); } .days.ok { color: var(--ok); }
.late { color: var(--bad); font-weight: 600; }
.meter { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; vertical-align: middle; }
.meter i { display: block; height: 100%; background: var(--ok); }
.meter.amber i { background: var(--warn); } .meter.red i { background: var(--bad); }

/* alert list */
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.alerts li a { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px dashed var(--line); text-decoration: none; }
.alerts li:last-child a { border-bottom: 0; }
.alerts li a:hover .ref { color: var(--accent); text-decoration: underline; }
.alerts .ref { font-family: var(--f-mono); font-weight: 600; }

/* shipment detail */
.timeline { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 0; overflow-x: auto; }
.step { position: relative; padding: 0 10px 0 0; display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.step .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); position: relative; z-index: 1; }
.step::before { content: ""; position: absolute; top: 6px; left: 14px; right: 0; height: 2px; background: var(--line); }
.step:last-child::before { display: none; }
.step.done .dot { background: var(--ok); border-color: var(--ok); }
.step.done::before { background: var(--ok); }
.step.now .dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step .name { font-size: 12px; font-weight: 700; }
.step input { font-family: var(--f-mono); font-size: 12px; padding: 4px 6px; width: 100%; max-width: 140px; }
.step .gap { font-size: 11px; color: var(--muted); font-family: var(--f-mono); }
.step .gap.red { color: var(--bad); font-weight: 700; }
.lines input { width: 100%; min-width: 70px; border: 1px solid var(--line); background: var(--bg); padding: 5px 6px; border-radius: 6px; }
.lines input:hover, .lines input:focus { border-color: var(--line); background: var(--bg); }
.lines input.sku { min-width: 140px; font-family: var(--f-mono); }
.lines input.n { text-align: right; font-family: var(--f-mono); width: 90px; }
.lines tfoot td { font-weight: 700; font-family: var(--f-mono); background: var(--surface-2); }
.x { border: 0; background: transparent; color: var(--muted); font-size: 17px; padding: 2px 6px; }
.x:hover { color: var(--bad); }
.log { list-style: none; margin: 0; padding: 0; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.log li { display: grid; grid-template-columns: 120px 1fr; gap: 10px; }
.log time { color: var(--muted); font-family: var(--f-mono); font-size: 11.5px; }
.banner { border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.banner.red { background: var(--bad); color: #fff; }
.banner.amber { background: var(--warn-soft); color: var(--ink); border: 1px solid var(--line); }
.banner.info { background: var(--info-soft); color: var(--ink); }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 18px; overflow-x: auto; }
.bars .b { flex: 1 0 22px; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 30px; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .b.hi i { background: var(--bad); }
.bars .b span { font-size: 10px; color: var(--muted); font-family: var(--f-mono); white-space: nowrap; }
.bars .b em { font-style: normal; font-size: 10.5px; font-family: var(--f-mono); color: var(--ink); }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(10,14,12,.5); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.dialog { background: var(--bg); border-radius: 14px; width: min(760px, 100%); padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dialog .spread h2 { font-size: 18px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-weight: 600; z-index: 60; box-shadow: var(--shadow); }
.toast.err { background: var(--bad); color: #fff; }
.err { color: var(--bad); font-size: 13px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 26px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login .brand { color: var(--ink); padding: 0 0 6px; font-size: 17px; }
.login .brand small { color: var(--muted); }

.later-page { max-width: 640px; }
.later-page ul { padding-left: 18px; line-height: 1.7; }
@media (prefers-reduced-motion: no-preference) { .dialog { animation: pop .14s ease-out; } @keyframes pop { from { transform: translateY(8px); opacity: .5; } } }

/* products & pictures */
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); display: inline-block; vertical-align: middle; flex: none; }
.thumb.sm { width: 34px; height: 34px; border-radius: 6px; }
.thumb.lg { width: 200px; height: 200px; border-radius: 10px; }
.thumb.none { background: repeating-linear-gradient(45deg, var(--surface-2) 0 6px, var(--sunk) 6px 12px); }
.warnText { color: var(--warn); font-weight: 600; }
.pgroup { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.pgroup > header { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; }
.pgroup > header:hover { background: var(--surface-2); }
.pgroup .chev { border: 0; background: none; font-size: 14px; color: var(--muted); width: 18px; padding: 0; }
.pgroup .strip { display: flex; gap: 4px; }
.pgroup .gname { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pgroup .gname b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmodal { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.pimg { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pimg label.btn { cursor: pointer; }
.skucell { display: flex; gap: 8px; align-items: center; }
.skucell .skuname { max-width: 260px; white-space: normal; line-height: 1.3; margin-top: 2px; }
@media (max-width: 560px) { .pgroup .strip { display: none; } .thumb.lg { width: 140px; height: 140px; } }
.mchips { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.mchip { display: inline-block; font-family: var(--f-mono); font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--ok); color: var(--ok); }
.mchip.live { background: var(--ok); color: #fff; }
.selbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; background: var(--ink); color: var(--bg); border-radius: 10px; position: sticky; top: 8px; z-index: 5; }
.selbar .field { color: var(--ink); }
.pgroup .gsel, tr input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
select.pstat { width: auto; padding: 3px 6px; font-size: 12.5px; font-weight: 650; border-radius: 99px; }
.ppick { display: flex; flex-direction: column; gap: 6px; }
.mpick { position: relative; }
.mpick summary { list-style: none; cursor: pointer; font-weight: 400; color: var(--ink); }
.mpick summary::-webkit-details-marker { display: none; }
.mpick summary::after { content: " ▾"; color: var(--muted); }
.mpick-list { position: absolute; z-index: 10; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); margin-top: 4px; min-width: 240px; font-weight: 500; color: var(--ink); }
.lwh { display: grid; grid-template-columns: repeat(4, minmax(90px, 1fr)); gap: 10px; }
@media (max-width: 560px) { .lwh { grid-template-columns: repeat(2, 1fr); } }
.grid td { padding: 6px 6px; }
.grid input[type=date] { width: 132px; font-size: 12.5px; padding: 5px 6px; }
.grid .field.edited { border-color: var(--accent); background: var(--accent-soft); }
tr.grouprow td { background: var(--surface-2); font-weight: 700; font-size: 12.5px; padding: 6px 11px; }
.locin { display: inline-flex; align-items: center; gap: 4px; }
td input.field.n, .locin input { width: 84px; text-align: right; font-family: var(--f-mono); padding: 4px 6px; }
input.field.edited { border-color: var(--ok); }
.tbar { position: relative; width: 140px; height: 8px; border-radius: 4px; background: var(--sunk); display: inline-block; vertical-align: middle; margin-right: 6px; }
.tbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--ok); }
.tbar i.amber { background: var(--warn); } .tbar i.red { background: var(--bad); }
.tbar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
button.tile { cursor: pointer; text-align: left; font: inherit; color: inherit; }
.selbar .btn:not(.primary) { color: var(--ink); }
td.ref .small { white-space: normal; max-width: 260px; line-height: 1.3; }
.tstable td { padding: 7px 8px; } .tstable th { padding: 8px; white-space: normal; min-width: 54px; }
tr.grp-port td { background: var(--ink); color: var(--bg); font-weight: 750; font-size: 13.5px; padding: 8px 11px; }
tr.grp-port td .muted { color: var(--side-muted); }
tr.grp-fac td { background: var(--accent-soft); font-weight: 700; padding: 6px 11px; }
tr.grp-par td { background: var(--surface-2); font-weight: 650; font-size: 12.5px; padding: 5px 11px 5px 24px; }
.portpill { background: rgba(255,255,255,.12); border-radius: 99px; padding: 3px 10px; font-size: 12.5px; }
.portpill.under { background: var(--warn); color: #fff; }
