:root {
  --bg: #f3efe6;
  --ink: #1c241c;
  --muted: #3e433c;
  --line: #b7ad9c;
  --card: #fffdf8;
  --green: #0f6e56;
  --green-soft: #e5f3ed;
  --amber: #9a5b16;
  --amber-soft: #f8ecd9;
  --blue: #1d4e89;
  --red: #9d3b32;
  --red-soft: #f8e6e2;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at -10% -20%, #e4f2eb 0%, transparent 55%),
    radial-gradient(700px 380px at 110% -10%, #f8ead6 0%, transparent 50%),
    var(--bg);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-weight: 600;
  line-height: 1.45;
}

button, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green); }

.wrap {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
}
.wrap.wide { width: min(880px, 100%); }

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; font-weight: 800; }
h2 { font-size: 18px; margin: 0 0 8px; font-weight: 800; }
p { margin: 0; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.brand-copy { flex: 1; min-width: 0; }
.brand-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand-sub { margin: 2px 0 0; color: var(--muted); font-size: 15px; font-weight: 700; }
.lang-btn {
  border: 2px solid var(--green);
  background: #fff;
  color: var(--green);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
  font-weight: 800;
  flex: none;
}
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.brand-mark.sm { width: 36px; height: 36px; border-radius: 10px; font-size: 12px; }
.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 800;
  font-size: 15px;
  line-height: 1.25;
}

.route {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
}
.route b { display: block; font-size: 16px; }
.route span { color: var(--muted); font-size: 12px; }
.route-mid { flex: 1; text-align: center; }
.route-mid i {
  display: block;
  height: 4px;
  margin-bottom: 4px;
  background: linear-gradient(90deg, var(--green), #d7a15a);
  position: relative;
}
.route-mid i::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -4px;
  border: 5px solid transparent;
  border-left-color: #d7a15a;
}
.route-mid em { font-style: normal; font-size: 12px; color: var(--muted); }

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-top: 12px;
}
.card-soft { background: transparent; }

label { display: block; margin: 12px 0 6px; color: var(--ink); font-size: 15px; font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid #8f8676;
  background: white;
  padding: 0 12px;
  font-size: 17px;
  font-weight: 800;
}
.select-box { position: relative; width: 100%; }
.select-box > select {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.select-face, .select-menu button {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}
.select-face {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  border-radius: 12px;
  border: 2px solid #8f8676;
  background: white;
  padding: 0 12px;
}
.select-face::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: rotate(45deg) translateY(-3px);
  flex: none;
}
.select-menu {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  min-width: 100%;
  background: white;
  border: 2px solid #8f8676;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(28, 36, 28, 0.16);
}
.select-menu button {
  display: block;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid #e6e0d4;
  background: white;
  text-align: left;
}
.select-menu button:last-child { border-bottom: 0; }
.select-menu button.on { background: #1d4e89; color: white; }
textarea { min-height: 96px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b7ddd1; border-color: var(--green); }
.edit-slot { display: grid; gap: 8px; margin-top: 12px; }
.edit-form { margin-top: 8px; }
.history { display: grid; gap: 8px; margin-top: 14px; }
.history > b { font-size: 16px; }
.history-item { background: #f6f1e7; border-radius: 12px; padding: 10px 12px; }
.history-item p { margin-top: 4px; }
.history-line { font-weight: 800; }

.btn {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: white;
  font-size: 16px;
  font-weight: 800;
}
.btn.secondary { background: transparent; color: var(--ink); border: 2px solid #8f8676; }
.btn.blue, .btn.out { background: var(--blue); }
.btn.arrive { background: #9a5b16; }
.btn.done { background: #1c241c; }
.btn.danger { background: var(--red); }
.btn.slim {
  width: auto;
  min-height: 44px;
  min-width: 108px;
  margin-top: 0;
  padding: 0 14px;
  font-size: 15px;
}
.btn.in:hover:not(:disabled), .btn:hover:not(:disabled) { background: #0c5b47; }
.btn.out:hover:not(:disabled), .btn.blue:hover:not(:disabled) { background: #163e6e; }
.btn.arrive:hover:not(:disabled) { background: #7d4a10; }
.btn.done:hover:not(:disabled) { background: #000; }
.btn.secondary:hover:not(:disabled) { background: #f6f1e7; }
.btn.danger:hover:not(:disabled) { background: #7f2e27; }
.btn:disabled, .btn:disabled:hover { opacity: 0.55; cursor: default; }

.help, .muted { color: var(--muted); font-size: 14px; font-weight: 650; }
.help { margin-top: 8px; }
.num { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.scanned-no {
  margin: 0 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #e7f0e4;
  border: 2px solid var(--green);
}
.scanned-no span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.scanned-no b {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  line-height: 1.25;
  word-break: break-all;
}

.samples, .filters, .link-row, .scan-actions, .row-actions, .top-actions {
  flex-wrap: wrap;
  display: flex;
  gap: 8px;
}
.scan-actions .btn { flex: 1; margin-top: 0; }
.samples, .filters { flex-wrap: wrap; margin-top: 14px; }
.filters { gap: 10px; padding: 2px; }

.chip, .samples button, .account-fill {
  border: 0;
  background: #e7e2d8;
  color: #1c241c;
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 16px;
  font-weight: 800;
}
.chip { white-space: nowrap; }
.chip.f-pre_registered { background: #f8e0b8; color: #7a3e08; }
.chip.f-gz_received { background: #d7f0e4; color: #0b5a45; }
.chip.f-gz_shipped { background: #d6e6f8; color: #143e72; }
.chip.f-tz_received { background: #f6d7a2; color: #6d3406; }
.chip.f-picked_up { background: #e4dfd4; color: #2c312b; }
.chip.f-mismatch, .chip.f-skipped, .chip.alert { background: #f4c5be; color: #7d221b; }
.chip.f-deleted { background: #e4dfd4; color: #2c312b; }
.chip.on { color: white; box-shadow: 0 0 0 3px #cfc6b6; }
.chip.f-all.on { background: #1c241c; }
.chip.f-pre_registered.on, .chip.f-tz_received.on { background: #9a5b16; box-shadow: 0 0 0 3px #f8e0b8; }
.chip.f-gz_received.on { background: #0f6e56; box-shadow: 0 0 0 3px #b7ddd1; }
.chip.f-gz_shipped.on { background: #1d4e89; box-shadow: 0 0 0 3px #c5daf3; }
.chip.f-picked_up.on { background: #3d433c; box-shadow: 0 0 0 3px #d9d3c6; }
.chip.f-mismatch.on, .chip.f-skipped.on, .chip.alert.on { background: #9d3b32; box-shadow: 0 0 0 3px #f4c5be; }
.chip.f-deleted.on { background: #3d433c; box-shadow: 0 0 0 3px #d9d3c6; }

.account-fill {
  width: 100%;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  text-align: left;
}
.account-fill small { color: var(--muted); }

.headline { font-size: 26px; margin: 2px 0 4px; }
.headline.gz_shipped { color: var(--blue); }
.headline.tz_received { color: var(--amber); }
.headline.picked_up, .headline.gz_received { color: var(--green); }
.tracking { font-size: 20px; font-weight: 800; margin-bottom: 4px; }

.steps { list-style: none; padding: 0; margin: 14px 0 0; }
.step { display: grid; grid-template-columns: 22px 1fr; column-gap: 10px; }
.rail { display: flex; flex-direction: column; align-items: center; }
.dot {
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border-radius: 99px;
  border: 3px solid #8f8676;
  background: white;
}
.line { width: 3px; flex: 1; min-height: 16px; background: #b7ad9c; }
.step b { display: block; font-size: 16px; font-weight: 800; }
.step small { display: block; margin: 2px 0 10px; color: var(--muted); }
.step.wait b { color: #8d887e; font-weight: 600; }
.step.done .dot, .step.current .dot { background: var(--green); border-color: var(--green); }
.step.current .dot { box-shadow: 0 0 0 4px #d7efe6; }
.step.warn .dot { background: var(--amber); border-color: var(--amber); box-shadow: none; }
.step:last-child .line { visibility: hidden; }

.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin: 14px 0 0; }
.meta dt { color: var(--muted); font-size: 12px; }
.meta dd { margin: 2px 0 0; font-weight: 700; }

.note {
  background: var(--amber-soft);
  color: #6d4712;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.warn-card { background: var(--red-soft); border-color: transparent; color: var(--red); }
.warn-card input, .warn-card .select-face, .warn-card .select-menu button { color: var(--ink); }
.ok-card { background: var(--green-soft); border-color: transparent; }
.ok-card .flag { background: white; border-radius: 8px; padding: 8px 10px; }
.flag { color: var(--red); font-size: 15px; font-weight: 800; margin-top: 6px; }
.alert-line { box-shadow: inset 6px 0 0 var(--red); }
.marks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
}
.marks .mark { margin: 0; }
.mark::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: currentColor;
  flex: none;
}
.mark.warn { background: #f6d7a2; color: #6d3406; }
.mark.bad { background: #f4c5be; color: #7d221b; }
.order-card.marked { border-color: #c45c52; background: #fff8f6; }

.foot { text-align: center; margin-top: 18px; font-size: 14px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(243, 239, 230, 0.92);
  border-bottom: 2px solid var(--line);
  backdrop-filter: blur(10px);
}
#who { color: var(--ink); font-size: 15px; font-weight: 800; }
#logout-btn {
  background: #1c241c;
  color: white;
  border: 0;
  min-height: 42px;
  padding: 0 16px;
  font-size: 16px;
}
.text-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 0;
  margin-bottom: 8px;
  min-height: 42px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  background: #0f6e56;
  color: white;
  font-size: 16px;
  font-weight: 800;
}
.text-back::before {
  content: "‹";
  font-size: 28px;
  line-height: 0.7;
  font-weight: 700;
}

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action {
  text-align: left;
  min-height: 112px;
  border: 0;
  border-radius: 16px;
  padding: 16px;
  background: var(--green);
  color: white;
}
.action.tz { background: var(--blue); }
.action.manage { grid-column: 1 / -1; background: #1c241c; }
.action b { display: block; font-size: 20px; }
.action small { display: block; margin-top: 6px; font-weight: 700; opacity: 0.92; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  text-align: left;
  font-weight: 700;
}
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.bad b { color: var(--red); }

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  border: 2px solid #7dbea8;
  font-size: 13px;
  font-weight: 800;
  background: #d7f0e4;
  color: #0b5a45;
  white-space: nowrap;
}
.tag.gz_shipped { background: #d6e6f8; color: #143e72; border-color: #7eaddf; }
.tag.tz_received, .tag.pre_registered { background: #f8e0b8; color: #7a3e08; border-color: #e0b15f; }
.tag.picked_up { background: #e4dfd4; color: #2c312b; border-color: #a79f90; }
.tag.off { background: #f6d0ca; color: #8a241c; border-color: #e09a92; }
.tag.deleted { background: #e4dfd4; color: #2c312b; border-color: #a79f90; }

.pick-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pick-row {
  width: 100%;
  margin: 0;
  text-align: left;
  border: 2px solid var(--line);
  background: white;
  font-weight: 700;
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}
.pick-row:hover, .pick-row:focus { border-color: var(--green); }
.pick-row small { color: var(--muted); font-weight: 700; }
.draft-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px 12px;
}
.draft-row .pick-main { display: grid; gap: 4px; min-width: 0; flex: 1; }
.draft-row .pick-main.link { cursor: pointer; }

.order-top, .user-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.order-top b, .pick-row b, .user-head b { font-size: 18px; font-weight: 800; }
.order-card { cursor: pointer; }
.order-body { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px 12px; }
.order-main { min-width: 0; flex: 1; }
.order-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin-left: auto; }
.order-side .select-box.quick-ship { width: 196px; }
.order-side .select-box.quick-ship .select-face,
.order-side .select-box.quick-ship .select-menu button {
  min-height: 40px;
  font-size: 16px;
}
.pack-chip {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #d6e6f8;
  color: #143e72;
  font-size: 14px;
  font-weight: 800;
}
.detail { margin-top: 10px; padding-top: 10px; border-top: 2px solid var(--line); }
.user-row .row-actions { margin-top: 10px; flex-wrap: wrap; align-items: center; }
.user-row input { width: 140px; min-height: 40px; }

#reader { margin-top: 12px; overflow: hidden; border-radius: 12px; background: #111; min-height: 220px; }
#reader video { width: 100% !important; border-radius: 12px; }
#reader a, #reader img { display: none !important; }

.home-orders { margin-top: 18px; scroll-margin-top: 76px; }
.home-orders > .help { margin-top: 0; }
button.stat { width: 100%; font: inherit; cursor: pointer; }
button.stat.on { border-color: var(--green); background: var(--green-soft); }
.link-row { margin-top: 12px; display: grid; grid-template-columns: 1fr; }
.link-row .btn { margin-top: 0; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 9;
  max-width: min(420px, 92vw);
  padding: 12px 16px;
  border-radius: 999px;
  background: #1c241c;
  color: white;
  font-size: 14px;
}

@media (max-width: 420px) {
  .order-side, .draft-row .order-side { width: 100%; align-items: stretch; }
  .order-side .btn.slim { width: 100%; }
  .order-side .select-box.quick-ship { width: 100%; }
}
@media (min-width: 720px) {
  .link-row { grid-template-columns: repeat(3, 1fr); }
  .stats.five { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 900px) {
  .wrap.wide { width: min(1080px, 100%); }
  .action-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
