:root {
  --blue: #0a5fb4;
  --blue-d: #084a8f;
  --blue-l: #e8f1fb;
  --orange: #e8590c;
  --orange-l: #fff0e6;
  --green: #12a150;
  --green-l: #e6f6ed;
  --red: #d92d20;
  --ink: #16202e;
  --ink2: #5b6778;
  --ink3: #8d97a6;
  --line: #e6ebf2;
  --bg: #f3f6fa;
  --card: #fff;
  --r: 16px;
  --shadow: 0 1px 2px rgba(16, 40, 80, .05), 0 6px 20px rgba(16, 40, 80, .06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
body.lock { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 120px; }

/* hero */
.hero {
  background: linear-gradient(135deg, #0a5fb4 0%, #1a7fd6 60%, #3a9be8 100%);
  color: #fff; padding: calc(28px + env(safe-area-inset-top)) 0 56px; position: relative; overflow: hidden;
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .08);
}
.hero::before { width: 220px; height: 220px; right: -60px; top: -80px; }
.hero::after { width: 140px; height: 140px; right: 60px; bottom: -70px; }
.hero-in { max-width: 640px; margin: 0 auto; padding: 0 16px; position: relative; z-index: 1; }
.eyebrow { font-size: 12px; letter-spacing: .18em; opacity: .75; font-weight: 600; }
.hero h1 { font-size: 26px; font-weight: 800; letter-spacing: .02em; margin: 4px 0 6px; }
.hero p { opacity: .88; font-size: 14px; }
.stats { display: flex; gap: 10px; margin-top: 18px; }
.stat { background: rgba(255, 255, 255, .16); backdrop-filter: blur(4px); border-radius: 12px; padding: 8px 14px; min-width: 92px; }
.stat b { display: block; font-size: 20px; line-height: 1.2; }
.stat span { font-size: 12px; opacity: .85; }

/* segmented tabs */
.seg {
  display: flex; background: var(--card); border-radius: 14px; padding: 4px; box-shadow: var(--shadow);
  margin-top: -28px; position: relative; z-index: 2;
}
.seg button {
  flex: 1; border: 0; background: none; padding: 10px 0; border-radius: 10px; font-weight: 600; color: var(--ink2);
  transition: background .15s, color .15s;
}
.seg button.on { background: var(--blue); color: #fff; }

.tools { margin: 14px 0 6px; display: flex; flex-direction: column; gap: 10px; }
.search {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px; outline: none;
}
.search:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-l); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--ink2);
}
.chip.on { background: var(--blue-l); border-color: var(--blue); color: var(--blue); font-weight: 600; }
.chips .gap { flex: 1; }

/* cards */
.card {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; margin-top: 12px;
}
.card.click { cursor: pointer; transition: transform .1s; }
.card.click:active { transform: scale(.99); }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink3); font-size: 13px; }
.sub { color: var(--ink2); font-size: 13px; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title { font-size: 17px; font-weight: 700; }

.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 6px; vertical-align: 1px; }
.tag.card-y { background: var(--blue-l); color: var(--blue); }
.tag.card-n { background: var(--orange-l); color: var(--orange); }
.tag.st-open { background: var(--blue-l); color: var(--blue); }
.tag.st-done { background: var(--green-l); color: var(--green); }
.tag.st-off { background: #eef0f3; color: var(--ink3); }

.bar { height: 8px; background: #eaeff5; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #2f9bf0, #0a5fb4); transition: width .3s; }
.bar.full i { background: linear-gradient(90deg, #35c47c, #12a150); }
.need { font-weight: 700; color: var(--orange); }
.need.ok { color: var(--green); }

/* product group */
.rows { margin-top: 10px; border-top: 1px dashed var(--line); }
.prow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.prow:last-child { border-bottom: 0; padding-bottom: 0; }
.more { text-align: center; padding-top: 8px; color: var(--blue); font-size: 13px; cursor: pointer; }
.pill { font-size: 12px; color: var(--ink2); background: #f1f4f8; border-radius: 6px; padding: 1px 7px; white-space: nowrap; }

/* order card item list */
.mini-items { margin: 10px 0 12px; display: flex; flex-direction: column; gap: 4px; }
.mini-items div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.mini-items .n { min-width: 0; }
.note { background: #fafbfd; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; color: var(--ink2); white-space: pre-wrap; word-break: break-word; margin-top: 10px; }

/* buttons */
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px; font-weight: 600; color: var(--ink);
  transition: opacity .15s, transform .08s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { color: var(--red); border-color: #f4c7c3; background: #fff; }
.btn.sm { padding: 4px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; padding: 12px; font-size: 16px; border-radius: 12px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--blue); }
.link { background: none; border: 0; color: var(--ink3); font-size: 13px; padding: 2px 4px; }
.link.red { color: var(--red); }
.link.blue { color: var(--blue); }

.fab {
  position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--orange); color: #fff; border: 0; border-radius: 999px; padding: 14px 22px; font-weight: 700; font-size: 16px;
  box-shadow: 0 8px 24px rgba(232, 89, 12, .4);
}
.fab:active { transform: scale(.96); }

/* stepper */
.stepper { align-self: flex-start; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.stepper button { width: 34px; height: 34px; border: 0; background: #f4f7fb; font-size: 18px; line-height: 1; color: var(--blue); }
.stepper button:active { background: var(--blue-l); }
.stepper input {
  width: 42px !important; height: 34px; border: 0 !important; padding: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  text-align: center; font-weight: 700; outline: none; -moz-appearance: textfield; background: #fff;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* order detail */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(12px + env(safe-area-inset-top)) 0 4px; max-width: 640px; margin: 0 auto; }
.topbar .back { border: 0; background: none; font-weight: 600; color: var(--blue); padding: 6px 4px; font-size: 15px; }
.banner { border-radius: 12px; padding: 10px 14px; margin-top: 12px; font-weight: 600; }
.banner.done { background: var(--green-l); color: var(--green); }
.banner.off { background: #eef0f3; color: var(--ink2); }

.item-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item-h h3 { font-size: 16px; }
.nums { display: flex; gap: 6px; margin: 10px 0 8px; flex-wrap: wrap; }
.num { background: #f4f7fb; border-radius: 8px; padding: 3px 10px; font-size: 12px; color: var(--ink2); }
.num b { color: var(--ink); font-size: 14px; margin-left: 2px; }
.num.hi { background: var(--orange-l); color: var(--orange); }
.num.hi b { color: var(--orange); }
.num.ok { background: var(--green-l); color: var(--green); }
.num.ok b { color: var(--green); }
.chain { list-style: none; margin: 10px 0 0; padding: 0; }
.chain li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.chain .no { width: 20px; height: 20px; border-radius: 50%; background: var(--blue-l); color: var(--blue); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.chain .no.o { background: var(--orange-l); color: var(--orange); }
.chain .nick { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chain .q { font-weight: 700; }
.chain .t { color: var(--ink3); font-size: 12px; }
.chain .me { font-size: 11px; background: var(--blue); color: #fff; border-radius: 4px; padding: 0 5px; margin-left: 4px; }
.pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 10px 12px; background: var(--blue-l); border-radius: 12px; }
.pick span { font-size: 14px; color: var(--blue-d); font-weight: 600; }
.pick.own { background: var(--orange-l); }
.pick.own span { color: var(--orange); }
.item-actions { display: flex; gap: 4px; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.dock-in { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.dock input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; outline: none; background: #fff; }
.dock input:focus, .field input:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-l); }
.dock .btn { padding: 10px 20px; border-radius: 12px; white-space: nowrap; }

.panel { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.section-t { margin: 20px 0 0; font-weight: 700; color: var(--ink2); font-size: 14px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field > label, .lab { font-size: 13px; font-weight: 600; color: var(--ink2); }
.field input, .field textarea, .field select {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; outline: none; width: 100%;
}
.field textarea { resize: vertical; min-height: 72px; }
.radio { display: flex; gap: 10px; }
.radio label { flex: 1; cursor: pointer; position: relative; }
.radio input { position: absolute; opacity: 0; pointer-events: none; width: 0 !important; height: 0; margin: 0; padding: 0 !important; border: 0 !important; }
.radio span {
  display: block; text-align: center; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 6px; font-weight: 600; color: var(--ink2); background: #fff;
}
.radio span small { display: block; font-weight: 400; font-size: 12px; color: var(--ink3); }
.radio input:checked + span { border-color: var(--blue); background: var(--blue-l); color: var(--blue); }
.form-item { border: 1px solid var(--line); background: #fafbfd; border-radius: 14px; padding: 12px; margin-top: 12px; }
.form-item .two { display: flex; gap: 12px; margin-top: 10px; }
.form-item .two > div { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.form-item input.nm, .form-item input.nt { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; background: #fff; margin-top: 8px; }
.form-item input.nm { margin-top: 0; font-weight: 600; }
.form-item input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-l); }
.err { color: var(--red); font-size: 14px; margin-top: 12px; }

/* modal sheet */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 20, 40, .5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  background: #fff; width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; max-height: 90vh; display: flex; flex-direction: column;
  animation: up .2s ease-out;
}
.sheet-h { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 6px; font-size: 17px; }
.sheet-h .x { border: 0; background: #f1f4f8; width: 30px; height: 30px; border-radius: 50%; color: var(--ink2); }
.sheet-b { padding: 4px 18px 8px; overflow-y: auto; }
.sheet-f { padding: 8px 18px calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.sheet-err { color: var(--red); padding: 0 18px; font-size: 14px; }
@media (min-width: 700px) { .modal-bg { align-items: center; } .sheet { border-radius: 20px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: fixed; left: 50%; top: 18%; transform: translate(-50%, -8px); background: rgba(22, 32, 46, .92); color: #fff; padding: 10px 18px;
  border-radius: 12px; z-index: 99; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { text-align: center; color: var(--ink3); padding: 48px 0; }
.empty b { display: block; font-size: 40px; margin-bottom: 8px; }
.empty .btn { margin-top: 14px; }
.skeleton { height: 110px; border-radius: var(--r); margin-top: 12px; background: linear-gradient(90deg, #e9eef5 25%, #f4f7fb 50%, #e9eef5 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
