:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #212c46;
  --text: #3b4663;
  --muted: #697797;
  --line: #e5e9f0;
  --soft: #f8fbff;
  --blue: #006cfd;
  --blue-soft: #e8f1ff;
  --green: #0f9d58;
  --green-soft: #e3f6ec;
  --amber: #b86e00;
  --amber-soft: #fff4e0;
  --red: #d93025;
  --red-soft: #fdeceb;
  --violet: #5b4bd6;
  --violet-soft: #eeecfd;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(33, 44, 70, 0.06), 0 2px 8px rgba(33, 44, 70, 0.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff; }
.top__inner { display: flex; align-items: center; gap: 10px; max-width: 1100px; margin: 0 auto; padding: 10px 14px; }
.brand { font-weight: 700; color: #fff; white-space: nowrap; }
.brand span { color: #7fb2ff; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #c9d3ea; padding: 7px 10px; border-radius: 8px; white-space: nowrap; font-size: 14px; }
.nav a.is-active { background: rgba(255, 255, 255, 0.12); color: #fff; }
.nav a:hover { text-decoration: none; color: #fff; }
.nav .badge { background: #ff8a00; color: #fff; border-radius: 10px; padding: 0 6px; font-size: 12px; margin-left: 4px; }
.top .icon-btn { background: none; border: 0; color: #c9d3ea; cursor: pointer; padding: 6px; font-size: 13px; }

.page { max-width: 1100px; margin: 0 auto; padding: 14px 12px 90px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 2px 12px; flex-wrap: wrap; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card > h2 { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid { display: grid; gap: 12px; }

/* forms */
.input, .select, .textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; min-height: 40px; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid rgba(0, 108, 253, 0.25); border-color: var(--blue); }
.textarea { min-height: 90px; resize: vertical; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 9px 14px; cursor: pointer; font-weight: 500; min-height: 40px; color: var(--ink); text-decoration: none; }
.btn:hover { text-decoration: none; border-color: #c6cfdf; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn--primary:hover { background: #005ee0; }
.btn--green { background: var(--green); border-color: var(--green); color: #fff; }
.btn--danger { color: var(--red); }
.btn--big { width: 100%; min-height: 52px; font-size: 16px; font-weight: 600; }
.btn--sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* chips / status */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 12px; white-space: nowrap; cursor: pointer; font-size: 14px; }
.chip b { font-weight: 600; margin-left: 4px; color: var(--muted); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.is-active b { color: #c9d3ea; }
.chip--hot b { color: #ff8a00; }

.status { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 2px 9px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.s-new { background: #eef1f6; color: #4a5675; }
.s-claimed { background: var(--amber-soft); color: var(--amber); }
.s-paid { background: var(--blue-soft); color: var(--blue); }
.s-sent { background: var(--violet-soft); color: var(--violet); }
.s-problem { background: var(--red-soft); color: var(--red); }
.s-shipped { background: var(--green-soft); color: var(--green); }
.s-cancelled { background: #eef1f6; color: #8a94ab; text-decoration: line-through; }

/* order list */
.search { display: flex; gap: 8px; margin-bottom: 10px; }
.olist { display: grid; gap: 8px; }
.orow { display: block; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; color: inherit; border-left: 4px solid transparent; }
.orow:hover { text-decoration: none; box-shadow: 0 2px 10px rgba(33, 44, 70, 0.12); }
.orow--hot { border-left-color: #ff8a00; }
.orow--paid { border-left-color: var(--blue); }
.orow--problem { border-left-color: var(--red); }
.orow__top { display: flex; align-items: center; gap: 8px; }
.orow__num { font-weight: 700; color: var(--ink); }
.orow__total { margin-left: auto; font-weight: 700; color: var(--ink); }
.orow__meta { margin-top: 4px; font-size: 13.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.orow__note { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--amber); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.pager { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }

/* order detail */
.back { display: inline-block; margin: 2px 2px 8px; font-size: 14px; }
.ohead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ohead h1 { font-size: 22px; }
.ohead .total { margin-left: auto; font-size: 22px; font-weight: 700; color: var(--ink); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }
.items { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.items td, .items th { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.items th { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.items tfoot td { border: 0; padding: 4px; }
.alert { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.alert--warn { background: var(--amber-soft); color: #7a4a00; }
.alert--err { background: var(--red-soft); color: #9b1c14; }
.alert--ok { background: var(--green-soft); color: #0b6b3c; }
.alert--info { background: var(--blue-soft); color: #0047a8; }
.pay-amounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.pay-amount { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.pay-amount.is-chosen { border-color: var(--amber); background: var(--amber-soft); }
.pay-amount b { display: block; color: var(--ink); font-size: 16px; }
.pay-amount span { font-size: 12.5px; color: var(--muted); }
.copy { border: 0; background: none; color: var(--blue); cursor: pointer; font-size: 13px; padding: 0 0 0 6px; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
.timeline li:last-child { border: 0; }
.timeline time { color: var(--muted); }
.actionbar { position: sticky; bottom: 0; z-index: 10; background: linear-gradient(rgba(244, 246, 250, 0), var(--bg) 30%); padding: 14px 0 calc(10px + env(safe-area-inset-bottom)); margin-top: 6px; }
.rates { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 8px; }
.rates td { padding: 5px 4px; border-bottom: 1px solid var(--line); }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(20, 27, 45, 0.45); }
.modal__panel { background: #fff; width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
.modal__panel h2 { font-size: 18px; margin-bottom: 12px; }
@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal__panel { border-radius: 16px; }
}

/* stats */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.kpi span { font-size: 12.5px; color: var(--muted); display: block; }
.kpi b { font-size: 21px; color: var(--ink); display: block; margin-top: 2px; }
.kpi small { color: var(--muted); font-size: 12px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 10px; fill: var(--muted); }
.chart .val { fill: var(--ink); font-weight: 600; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 90px 1fr 44px; align-items: center; gap: 8px; font-size: 13.5px; }
.bar i { display: block; height: 10px; border-radius: 6px; background: var(--blue); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.table td.num, .table th.num { text-align: right; }
.low { color: var(--red); font-weight: 600; }

/* login */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login .card { padding: 22px; }
.login h1 { margin-bottom: 14px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: 0.25s; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 80; pointer-events: none; max-width: 92vw; font-size: 14px; }
.toast.is-on { opacity: 1; transform: translateX(-50%); }
.toast.is-err { background: var(--red); }

.d-only { display: none; }
@media (min-width: 760px) {
  .d-only { display: inline-flex; }
  .m-only { display: none; }
  .page { padding: 20px 20px 60px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .detail { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; align-items: start; }
  .actionbar { position: static; background: none; padding: 0; }
}
