:root {
  --bg: #f6f1e9;
  --bg-2: #efe7db;
  --card: #fffdf9;
  --ink: #1d1a16;
  --ink-2: #5d564c;
  --ink-3: #998f82;
  --line: rgba(60, 45, 25, .10);
  --accent: #e2591b;
  --accent-2: #ff8a3d;
  --accent-soft: #fde3d2;
  --gold: #c9921e;
  --ok: #2f8f5b;
  --ok-soft: #dcf1e4;
  --warn: #c7811a;
  --warn-soft: #fbeccf;
  --bad: #c8382f;
  --bad-soft: #fadcd9;
  --blue: #2f6fd6;
  --blue-soft: #dce8fb;
  --shadow: 0 1px 2px rgba(50, 35, 15, .05), 0 6px 20px rgba(50, 35, 15, .06);
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --bg-2: #1d1a17;
    --card: #221f1b;
    --ink: #f4eee6;
    --ink-2: #b8ae9f;
    --ink-3: #7d7366;
    --line: rgba(255, 240, 220, .08);
    --accent: #ff7a35;
    --accent-2: #ffa35f;
    --accent-soft: #3a2316;
    --ok: #52c784; --ok-soft: #173325;
    --warn: #f0ae45; --warn-soft: #382a12;
    --bad: #ff6b60; --bad-soft: #3c1a17;
    --blue: #6aa2ff; --blue-soft: #172741;
    --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.4; }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

#app { padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 110px); max-width: 720px; margin: 0 auto; }

/* ---------- headers ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 2px 18px; }
.top h1 { font-family: var(--font-round); font-size: 34px; letter-spacing: -.02em; margin: 0; font-weight: 800; }
.top .sub { color: var(--ink-2); font-size: 15px; margin-top: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 20px; height: 20px; fill: var(--ink); }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; padding: 6px 0; margin-bottom: 6px; background: none; border: 0; cursor: pointer; }
.back svg { width: 18px; height: 18px; fill: currentColor; }

h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 26px 6px 10px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
h2.section a { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 600; }

/* ---------- hero summary ---------- */
.hero { position: relative; overflow: hidden; border-radius: 26px; padding: 20px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #ff9b4d 0%, #e2591b 45%, #9c2f0c 100%); box-shadow: 0 10px 30px rgba(226, 89, 27, .28); }
.hero::after { content: ""; position: absolute; inset: auto -40px -60px auto; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero .label { font-size: 13px; opacity: .85; font-weight: 600; letter-spacing: .02em; }
.hero .big { font-family: var(--font-round); font-size: 40px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 2px 0 14px; }
.hero .chips { display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero .chip { background: rgba(255,255,255,.18); backdrop-filter: blur(6px); padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.group { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.group > * + * { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 52px; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--ink-3); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; flex: none; }
.row.link { cursor: pointer; }
.row.link:active { background: var(--bg-2); }
.chev { width: 8px; height: 13px; flex: none; opacity: .35; }

.thumb { width: 52px; height: 52px; border-radius: 14px; flex: none; overflow: hidden; display: grid; place-items: center;
  font-family: var(--font-round); font-weight: 800; font-size: 20px; color: #fff; background: var(--ink-3); }
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.thumb.sm { width: 40px; height: 40px; border-radius: 11px; font-size: 16px; }

/* parcel card */
.parcel { display: block; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 14px 16px; cursor: pointer; transition: transform .15s; }
.parcel:active { transform: scale(.985); }
.parcel .head { display: flex; gap: 12px; align-items: center; }
.parcel .name { font-weight: 650; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.parcel .who { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }
.parcel .last { margin-top: 12px; font-size: 14px; color: var(--ink-2); display: flex; gap: 8px; align-items: baseline; }
.parcel .last b { color: var(--ink); font-weight: 600; }
.parcel .last time { color: var(--ink-3); font-size: 12.5px; margin-left: auto; flex: none; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 12px; }
.steps i { height: 6px; border-radius: 3px; background: var(--bg-2); position: relative; overflow: hidden; }
.steps i.on { background: var(--accent); }
.steps i.now { background: linear-gradient(90deg, var(--accent) 0 50%, var(--bg-2) 50%); background-size: 200% 100%; animation: pulse 1.8s ease-in-out infinite; }
.steps.ok i.on, .steps.ok i.now { background: var(--ok); animation: none; }
.steps.bad i.on, .steps.bad i.now { background: var(--bad); animation: none; }
@keyframes pulse { 0%,100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
.steps-labels { display: grid; grid-template-columns: repeat(4, 1fr); font-size: 11px; color: var(--ink-3); margin-top: 5px; }
.steps-labels span:last-child { text-align: right; }
.steps-labels span:nth-child(2), .steps-labels span:nth-child(3) { text-align: center; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; padding: 4px 9px; border-radius: 999px; white-space: nowrap; background: var(--bg-2); color: var(--ink-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ordered { background: var(--blue-soft); color: var(--blue); }
.pill.shipped, .pill.in_transit, .pill.pending, .pill.not_found { background: var(--accent-soft); color: var(--accent); }
.pill.out_for_delivery, .pill.pickup { background: var(--warn-soft); color: var(--warn); }
.pill.delivered { background: var(--ok-soft); color: var(--ok); }
.pill.cancelled, .pill.exception, .pill.expired { background: var(--bad-soft); color: var(--bad); }
.pill.returned { background: var(--bg-2); color: var(--ink-2); }

.empty { text-align: center; padding: 34px 20px; color: var(--ink-3); }
.empty .big { font-size: 44px; margin-bottom: 6px; }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; font-size: 17px; }

.banner { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; cursor: pointer; }
.banner .ico { font-size: 26px; }
.banner b { display: block; }
.banner span { color: var(--ink-2); font-size: 14px; }

/* ---------- search & filters ---------- */
.search { display: flex; align-items: center; gap: 8px; background: var(--card); box-shadow: var(--shadow); border-radius: 14px; padding: 0 12px; height: 44px; }
.search svg { width: 18px; height: 18px; fill: var(--ink-3); flex: none; }
.search input { border: 0; outline: 0; background: none; flex: 1; height: 100%; font-size: 16px; }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 4px; scrollbar-width: none; margin: 0 -16px; padding-left: 18px; padding-right: 18px; }
.chips-row::-webkit-scrollbar { display: none; }
.fchip { flex: none; border: 0; padding: 8px 14px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.fchip.on { background: var(--ink); color: var(--bg); }
.month-head { display: flex; justify-content: space-between; margin: 22px 6px 8px; font-size: 13px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- detail ---------- */
.detail-hero { text-align: center; padding: 6px 0 8px; }
.detail-hero .thumb { width: 96px; height: 96px; border-radius: 26px; margin: 0 auto 12px; font-size: 38px; box-shadow: var(--shadow); }
.detail-hero h1 { font-size: 22px; line-height: 1.25; margin: 0 8px 4px; font-weight: 750; }
.detail-hero .merchant { color: var(--ink-2); font-weight: 600; }
.detail-hero .total { font-family: var(--font-round); font-size: 30px; font-weight: 800; margin-top: 8px; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.action { background: var(--card); box-shadow: var(--shadow); border: 0; border-radius: 16px; padding: 12px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.action svg { width: 22px; height: 22px; fill: var(--accent); }
.action.danger svg { fill: var(--bad); }

.timeline { list-style: none; margin: 4px 0 0; padding: 0 0 0 6px; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); opacity: .5; }
.timeline li::after { content: ""; position: absolute; left: 4.5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li:first-child::before { background: var(--accent); opacity: 1; box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline .t { font-weight: 600; font-size: 14.5px; }
.timeline .m { color: var(--ink-3); font-size: 12.5px; }
.tn { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13.5px; letter-spacing: .02em; }
.small-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.sbtn { border: 0; background: var(--bg-2); color: var(--ink); padding: 8px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.sbtn.accent { background: var(--accent-soft); color: var(--accent); }
.kv { display: grid; grid-template-columns: auto 1fr; }
.kv .k { color: var(--ink-2); }
.kv input[type=date], .kv input[type=text] { border: 0; background: none; text-align: right; color: var(--accent); font-weight: 600; outline: none; width: 100%; min-width: 0; }
textarea.notes { width: 100%; border: 0; background: none; resize: vertical; min-height: 70px; outline: none; padding: 14px 16px; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 0 4px 6px; }
.input, .field input, .field select, .field textarea { width: 100%; background: var(--bg-2); border: 1.5px solid transparent; border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); background: var(--card); }
.field .hint { font-size: 12.5px; color: var(--ink-3); margin: 6px 4px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: flex; justify-content: center; align-items: center; gap: 8px; width: 100%; border: 0; border-radius: 14px; padding: 15px; font-size: 16.5px; font-weight: 700; cursor: pointer; background: var(--accent); color: #fff; }
.btn:disabled { opacity: .55; }
.btn.ghost { background: var(--bg-2); color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn + .btn { margin-top: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg-2); border-radius: 12px; padding: 3px; margin-bottom: 16px; }
.seg button { border: 0; background: none; padding: 8px 4px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.settings-card { padding: 18px 16px 6px; }
.settings-card h3 { margin: 0 0 4px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.settings-card p.desc { color: var(--ink-2); font-size: 14px; margin: 0 0 14px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.err { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
details.help { background: var(--bg-2); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; color: var(--ink-2); }
details.help summary { font-weight: 600; color: var(--ink); cursor: pointer; }
details.help ol { padding-left: 20px; margin: 8px 0 2px; }
.copy { display: flex; gap: 8px; align-items: center; background: var(--bg-2); border-radius: 12px; padding: 10px 12px; font-size: 13px; word-break: break-all; }
.copy code { flex: 1; }

/* ---------- stats ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 18px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bars .b i { width: 100%; border-radius: 7px 7px 3px 3px; background: color-mix(in srgb, var(--accent) 35%, transparent); min-height: 3px; position: relative; }
.bars .b.cur i { background: var(--accent); }
.bars .b span { font-size: 10.5px; color: var(--ink-3); text-transform: capitalize; }
.bars .b em { font-style: normal; font-size: 10.5px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 16px; }
.hbar .track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--bg-2); overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .v { font-family: var(--font-round); font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.kpi .l { font-size: 13px; color: var(--ink-3); font-weight: 600; }

/* ---------- tabbar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 6px 8px calc(var(--safe-bottom) + 6px); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--ink-3); padding: 4px 0; }
.tabbar a svg { width: 25px; height: 25px; fill: currentColor; }
.tabbar a.on { color: var(--accent); }
.tab-add { justify-self: center; width: 54px; height: 54px; border-radius: 18px; border: 0; background: linear-gradient(145deg, var(--accent-2), var(--accent)); box-shadow: 0 6px 18px rgba(226, 89, 27, .4); display: grid; place-items: center; cursor: pointer; margin-top: -18px; }
.tab-add svg { width: 28px; height: 28px; fill: #fff; }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 10, 5, .4); z-index: 40; animation: fade .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto; background: var(--card); border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(var(--safe-bottom) + 20px); max-width: 720px; margin: 0 auto; animation: up .28s cubic-bezier(.2, .9, .3, 1); box-shadow: 0 -10px 40px rgba(0,0,0,.2); }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; background: var(--ink-3); opacity: .35; }
.sheet h2 { margin: 0 0 14px; font-size: 22px; font-weight: 750; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 92px); z-index: 60; background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: 14px; font-weight: 600; font-size: 14.5px; box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: fade .2s; max-width: 90vw; text-align: center; }

/* ---------- login ---------- */
.login { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; max-width: 360px; margin: 0 auto; text-align: center; }
.login .logo { width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 26px; box-shadow: 0 12px 30px rgba(226, 89, 27, .35); }
.login h1 { font-family: var(--font-round); font-size: 36px; margin: 0; }
.login p { color: var(--ink-2); margin: 4px 0 26px; }

.skeleton { background: linear-gradient(90deg, var(--card) 0%, var(--bg-2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); height: 110px; margin-bottom: 10px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (min-width: 760px) {
  #app { padding-top: 34px; }
  .list.grid2 { display: grid; grid-template-columns: 1fr 1fr; }
}
