:root {
  --ink: #1c1c1e;
  --muted: #6e6e73;
  --hair: rgba(60, 60, 67, 0.14);
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-edge: rgba(255, 255, 255, 0.7);
  --blur: saturate(180%) blur(22px);
  --brand: #2e7d5b;
  --brand-ink: #ffffff;
  --brand-soft: rgba(46, 125, 91, 0.12);
  --changed: #fff1c7;
  --changed-ink: #8a5a00;
  --added: #e3ebff;
  --added-ink: #2443a3;
  --bad: #d70015;
  --bad-soft: rgba(255, 59, 48, 0.12);
  --ok: #248a3d;
  --ok-soft: rgba(52, 199, 89, 0.15);
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html { background: #eef3ef; }
body { margin: 0; min-height: 100vh; -webkit-text-size-adjust: 100%; line-height: 1.35; }
/* Soft colour field behind the glass */
body::before {
  content: ""; position: fixed; inset: -20vmax; z-index: -1;
  background:
    radial-gradient(38vmax 38vmax at 12% 18%, rgba(129, 199, 132, 0.55), transparent 70%),
    radial-gradient(34vmax 34vmax at 88% 12%, rgba(255, 204, 128, 0.55), transparent 70%),
    radial-gradient(40vmax 40vmax at 70% 85%, rgba(128, 203, 196, 0.55), transparent 70%),
    radial-gradient(30vmax 30vmax at 15% 90%, rgba(206, 147, 216, 0.35), transparent 70%),
    #eef3ef;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: 0 8px 30px rgba(31, 38, 35, 0.08);
}

/* ---------- Shell ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 8px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--hair);
}
.top .titles { flex: 1; min-width: 0; }
.top h1 { font-size: 17px; margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; background: var(--brand-soft); color: var(--brand); border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.back { flex: none; background: none; border: 0; color: var(--brand); font-size: 28px; line-height: 1; padding: 0 4px 2px 0; }
main { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(env(safe-area-inset-bottom) + 100px); }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; padding-bottom: env(safe-area-inset-bottom);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-top: 1px solid var(--hair);
}
.tabs button { flex: 1; border: 0; background: none; padding: 8px 4px 10px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.tabs .ico { font-size: 22px; line-height: 1; }
.tabs button.on { color: var(--brand); font-weight: 600; }
.tabs .dot { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--bad); color: #fff; border-radius: 9px; font-size: 11px; min-width: 18px; padding: 0 5px; line-height: 18px; font-weight: 600; }

/* ---------- Cards & forms ---------- */
.card { border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card > h2 { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; min-width: 0; }
label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label.f input, label.f textarea, label.f select { display: block; width: 100%; margin-top: 6px; }
input, textarea, select { border: 1px solid var(--hair); border-radius: 12px; padding: 11px 13px; background: rgba(255, 255, 255, 0.75); font-size: 16px; min-width: 0; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 70px; }
.btn { border: 0; border-radius: 14px; padding: 14px 16px; font-weight: 600; font-size: 16px; background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 18px rgba(46, 125, 91, .25); }
.btn.block { width: 100%; }
.btn.danger { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 4px 0 10px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- Login ---------- */
.login { max-width: 400px; margin: 9vh auto 0; padding: 0 16px; }
.login .card { padding: 26px 22px; border-radius: 26px; }
.logo { width: 60px; height: 60px; border-radius: 18px; background: linear-gradient(145deg, #4caf7d, #2e7d5b); color: #fff; display: grid; place-items: center; font-size: 30px; margin: 0 auto 14px; box-shadow: 0 10px 24px rgba(46, 125, 91, .35); }
.login h1 { font-size: 24px; margin: 0 0 4px; text-align: center; letter-spacing: -.01em; }
.login p { margin: 0 0 22px; text-align: center; }
.linkbtn { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--brand); font-size: 15px; padding: 8px; }

/* ---------- Catalog ---------- */
.search { position: sticky; top: 62px; z-index: 4; padding: 2px 0 10px; }
.search input { width: 100%; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 1px solid var(--glass-edge); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-radius: 999px; padding: 7px 14px; font-size: 14px; white-space: nowrap; }
.chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.list { padding: 4px 14px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--hair); }
.item:last-child { border-bottom: 0; }
.item .name { font-size: 15px; overflow-wrap: anywhere; }
.item .code { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item .ctl { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.stepper { display: flex; align-items: center; border-radius: 12px; overflow: hidden; background: rgba(255,255,255,.75); border: 1px solid var(--hair); flex: none; }
.stepper button { width: 38px; height: 38px; border: 0; background: transparent; color: var(--brand); font-size: 22px; line-height: 1; }
.stepper input { width: 52px; border: 0; border-radius: 0; text-align: center; padding: 8px 2px; background: transparent; }
.uom { padding: 8px 6px; font-size: 14px; max-width: 84px; }
.uomtag { font-size: 13px; color: var(--muted); min-width: 30px; text-align: right; }
.cartbar { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 64px); z-index: 4; padding: 0 14px; max-width: 760px; margin: 0 auto; }
.cartbar .btn { width: 100%; display: flex; justify-content: space-between; gap: 12px; }

/* ---------- Orders ---------- */
.order { display: block; width: 100%; text-align: left; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.order .no { font-weight: 600; font-size: 16px; }
.order .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; flex: none; }
.badge.SUBMITTED, .badge.REVIEWING, .badge.PREPARING { background: rgba(120,120,128,.14); color: #48484a; }
.badge.CONFIRMED, .badge.AWAITING_STOCK, .badge.PARTIAL { background: var(--changed); color: var(--changed-ink); }
.badge.DELIVERING { background: var(--added); color: var(--added-ink); }
.badge.RECEIVED { background: var(--ok-soft); color: var(--ok); }
.badge.REJECTED, .badge.CANCELLED { background: var(--bad-soft); color: var(--bad); }
.flag { display: inline-block; font-size: 11px; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; font-weight: 600; white-space: nowrap; }
.flag.changed { background: var(--changed); color: var(--changed-ink); }
.flag.added { background: var(--added); color: var(--added-ink); }
.flag.removed { background: var(--bad-soft); color: var(--bad); }

.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 14px; }
.steps span { height: 4px; border-radius: 2px; background: var(--hair); }
.steps span.on { background: var(--brand); }
.stepnames { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.stepnames span { text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepnames span:first-child { text-align: left; }
.stepnames span:last-child { text-align: right; }

/* Order lines as stacked rows: no columns to collide on narrow screens */
.line { padding: 12px 0; border-bottom: 1px solid var(--hair); }
.line:last-child { border-bottom: 0; }
.line .name { font-size: 15px; overflow-wrap: anywhere; }
.line .sub { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.line.added { background: linear-gradient(90deg, var(--added), rgba(227,235,255,0) 85%); margin: 0 -16px; padding-left: 16px; padding-right: 16px; box-shadow: inset 3px 0 0 var(--added-ink); }
.qtys { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.q { font-size: 12px; border-radius: 8px; padding: 3px 8px; background: rgba(120,120,128,.1); color: #3a3a3c; white-space: nowrap; }
.q b { font-weight: 700; }
.q.changed { background: var(--changed); color: var(--changed-ink); }
.q.removed, .q.bad { background: var(--bad-soft); color: var(--bad); }
.q.ok { background: var(--ok-soft); color: var(--ok); }
.q.info { background: var(--added); color: var(--added-ink); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.ship { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.ship .head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.ship .head b { flex: 1; min-width: 0; }

/* ---------- Receiving ---------- */
.recv { border-bottom: 1px solid var(--hair); padding: 12px 0; }
.recv:last-child { border-bottom: 0; }
.recv .nums { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.recv .nums label { font-size: 12px; color: var(--muted); }
.recv .nums input { width: 100%; margin-top: 4px; }
.recv .note { width: 100%; margin-top: 8px; font-size: 14px; padding: 9px 12px; }
.recv.short .nums input { border-color: rgba(255, 59, 48, .45); }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 140px); transform: translateX(-50%);
  background: rgba(28, 28, 30, .86); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: 90vw; text-align: center;
}
#toast.on { opacity: 1; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgba(255,255,255,.9); --glass-strong: rgba(255,255,255,.96); }
}
