:root {
  --bg: #F3EDFF;
  --card: #FFFFFF;
  --ink: #241C38;
  --muted: #6E6487;
  --line: #E4DAF7;
  --primary: #C2ABEE;
  --deep: #7A5CC0;
  --deep-bg: #EEE6FD;
  --good: #1F7F52;
  --good-bg: #DCF3E6;
  --bad: #B8304B;
  --bad-bg: #FCE3E8;
  --warn: #7A5A00;
  --warn-bg: #FFF1BF;
  --radius: 16px;
  --tabs-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
a { color: var(--deep); }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1em; margin: 4px 0 0; font-weight: 600; }
.small-text { font-size: 14px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border: 2px solid var(--deep); background: #fff; color: var(--deep); border-radius: 999px; padding: 8px 18px; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--deep); color: #fff; }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

/* form fields: 16px stops iOS from zooming in */
input, select, textarea { font: inherit; font-size: 16px; color: inherit; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 46px; background: #fff; width: 100%; min-width: 0; }
textarea { min-height: 70px; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236E6487' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--primary); outline-offset: 0; border-color: var(--deep); }
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; font-weight: 700; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--deep); }
.check { display: flex; gap: 10px; align-items: center; color: var(--ink); font-size: 16px; font-weight: 600; margin: 14px 0; }

/* login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; color: var(--deep); }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(243, 237, 255, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1.5px solid var(--line); }
.brand { font-weight: 800; font-size: 19px; color: var(--deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .row { flex-wrap: nowrap; gap: 4px; }
.lang-btn { min-width: 52px; }
.sync-info { padding: 8px 16px 0; font-size: 13px; color: var(--muted); max-width: 760px; margin: 0 auto; }
main { padding: 12px 16px; max-width: 760px; margin: 0 auto; }

/* bottom tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-top: 1.5px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; box-shadow: 0 -4px 16px rgba(36, 28, 56, .06); }
.tabs button { height: var(--tabs-h); border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font: inherit; font-weight: 700; font-size: 12px; color: var(--muted); cursor: pointer; }
.tabs svg { width: 24px; height: 24px; }
.tabs button.active { color: var(--deep); }
.tabs button.active svg { background: var(--deep-bg); border-radius: 999px; padding: 2px 12px; width: 48px; box-sizing: content-box; }

/* cards + chips + tags */
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(36, 28, 56, .04); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 10px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.card .chips { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 16px; font: inherit; font-size: 15px; font-weight: 700; color: var(--muted); cursor: pointer; }
.chip.on { background: var(--deep); border-color: var(--deep); color: #fff; }
.tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 700; background: var(--line); color: var(--ink); white-space: nowrap; }
.tag.shopify { background: #E2F1D8; color: #34622A; }
.tag.xhs { background: #FFE0E6; color: #B42343; }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }

/* orders */
.orders-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.orders-count { font-size: 15px; }
.orders-count b { font-size: 22px; }
.search { margin-bottom: 10px; }
.filters { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.filters select { font-size: 14px; padding: 8px 24px 8px 9px; min-height: 42px; background-position: right 9px center; }
.order { border-left: 6px solid var(--primary); }
.order.state-unpaid { border-left-color: var(--bad); }
.order.state-shipped, .order.state-delivered { border-left-color: var(--good); }
.order.state-cancelled { border-left-color: #B9B2C8; opacity: .75; }
.order-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.order-title { font-weight: 800; font-size: 19px; line-height: 1.25; word-break: break-word; }
.order-pay { display: flex; align-items: center; gap: 8px; flex: none; }
.order-total { font-weight: 800; font-size: 19px; color: var(--deep); white-space: nowrap; }
.order-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.order-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.items { margin: 14px 0 4px; display: grid; gap: 8px; }
.item { position: relative; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line); cursor: pointer; transition: transform .08s; }
.item:active { transform: scale(.98); }
.item:has(.item-pick:focus-visible) { outline: 3px solid var(--deep); outline-offset: 1px; }
.item-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.item-status { flex: none; max-width: 42%; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 2px; text-align: right; font-size: 12px; font-weight: 700; color: var(--muted); line-height: 1.25; }
.st-line b { color: var(--ink); }
.item-pick { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; border: 0; padding: 0; -webkit-appearance: none; appearance: none; font-size: 16px; }
.item-name { font-weight: 700; font-size: 16px; }
.qty { display: inline-block; min-width: 30px; text-align: center; background: var(--deep-bg); color: var(--deep); border-radius: 8px; padding: 1px 6px; margin-right: 4px; font-size: 14px; }
.stage-todo { background-color: #fff; }
.stage-fridge { background-color: #D7EAFF; border-color: #98C4F2; }
.stage-packed { background-color: var(--good-bg); border-color: #95D3B1; }
.dates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.date-l { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.date-v { font-size: 15px; font-weight: 700; }
.date-v.none { color: #B9B2C8; }
.tracking, .notes { font-size: 14px; margin-top: 10px; }
.notes { background: var(--bg); border-radius: 10px; padding: 8px 10px; white-space: pre-wrap; }
.order-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 14px; }
.order-actions .btn { min-width: 90px; }
.order-actions select { font-size: 15px; }

/* production */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(5, 1fr); } }
.tile { border-radius: var(--radius); padding: 14px; border: 2px solid var(--line); }
.tile .n { font-size: 32px; font-weight: 800; line-height: 1.1; }
.tile .l { font-size: 14px; font-weight: 700; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num b { font-size: 17px; }
.table-wrap { overflow-x: auto; margin: 0 -6px; }
tr.total td { font-weight: 800; border-top: 2px solid var(--ink); border-bottom: 0; }
.price { color: var(--deep); }

/* recipe editor */
.recipe-row { display: grid; grid-template-columns: minmax(0, 1fr) 52px 60px 70px 28px; gap: 6px; align-items: center; margin-bottom: 8px; }
.recipe-row input, .recipe-row select { padding: 8px; min-height: 44px; }
.recipe-row select { padding-right: 22px; background-position: right 6px center; }
.recipe-head { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.x { border: 0; background: none; color: var(--bad); font-size: 26px; line-height: 1; cursor: pointer; padding: 0; min-height: 44px; }

/* bottom sheet */
.sheet { position: fixed; inset: 0; background: rgba(36, 28, 56, .5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { background: #fff; width: 100%; max-width: 640px; max-height: 94vh; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain; border-radius: 22px 22px 0 0; padding: 22px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-body::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: -10px auto 14px; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-body { border-radius: 22px; } }
.sheet-actions { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: #fff; padding: 12px 0 calc(4px + env(safe-area-inset-bottom)); display: flex; gap: 8px; justify-content: space-between; margin-top: 18px; border-top: 1px solid var(--line); }
.sheet-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; padding: 12px 14px; background: var(--deep-bg); border-radius: 12px; font-weight: 700; }
.sheet-total b { font-size: 20px; color: var(--deep); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 600; z-index: 30; max-width: calc(100% - 32px); text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }
.warnbox { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.grid2 > * { min-width: 0; }
input[type=date] { display: block; min-width: 0; -webkit-appearance: none; appearance: none; }

/* deadlines + customisation */
.due { margin-top: 10px; padding: 8px 12px; border-radius: 10px; font-size: 14px; background: var(--deep-bg); color: var(--deep); }
.due-soon { background: var(--warn-bg); color: var(--warn); }
.due-late { background: var(--bad-bg); color: var(--bad); }
.due-done { background: #F1EEF6; color: var(--muted); }
.due-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.due-items { display: grid; gap: 3px; margin-top: 3px; font-size: 14px; color: var(--muted); }
.due-custom { margin: 2px 0 2px 2px; padding: 4px 8px; border-radius: 8px; background: #FFF0F3; color: #B42343; font-weight: 700; font-size: 13px; }
.due-row:last-child { border-bottom: 0; }
.due-when { flex: none; font-size: 14px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: var(--deep-bg); color: var(--deep); }
.due-when.due-soon { background: var(--warn-bg); color: var(--warn); }
.due-when.due-late { background: var(--bad-bg); color: var(--bad); }
.custom-line { font-size: 14px; font-weight: 600; color: #B42343; background: #FFF0F3; border-radius: 8px; padding: 4px 8px; }
.cust-box { margin-top: 8px; padding: 10px; border-radius: 12px; background: #FFF6F8; display: grid; gap: 6px; }
.cust-row { display: grid; grid-template-columns: 1fr 80px; gap: 8px; align-items: center; font-weight: 600; }
.cust-row input { min-height: 40px; padding: 6px 10px; }
.tag.method { background: #E3ECFF; color: #2F55A8; }
.need-box { background: var(--deep-bg); border-radius: 14px; padding: 12px 14px; margin: 4px 0 10px; }
.need-title { font-weight: 800; color: var(--deep); margin-bottom: 8px; }
.need-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.need-item { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 8px 10px; font-weight: 700; }
.need-n { flex: none; min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--deep); color: #fff; font-size: 20px; font-weight: 800; }
.need-custom { display: block; font-size: 12px; color: #B42343; font-weight: 700; }
.due-when.due-none { background: #F1EEF6; color: var(--muted); }
.settings-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; color: var(--muted); margin-top: 12px; }
.setting-input { width: 70px; min-height: 38px; padding: 6px 8px; }

/* split stages */
.stage-mixed { background-color: #F6F2FF; border-color: var(--primary); }
.split-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.split-box { display: grid; gap: 6px; padding: 10px; border-radius: 12px; background: #FAF8FF; border: 1.5px solid var(--line); }
.split-row { display: grid; grid-template-columns: 1fr 44px 36px 44px; align-items: center; gap: 6px; border-radius: 10px; padding: 4px 4px 4px 12px; font-weight: 700; border: 1.5px solid var(--line); }
.step { width: 44px; height: 40px; border-radius: 10px; border: 2px solid var(--deep); background: #fff; color: var(--deep); font-size: 22px; font-weight: 800; line-height: 1; cursor: pointer; }
.step:disabled { opacity: .3; }
.step-n { text-align: center; font-size: 18px; }
