/* All colours, type and spacing come from these tokens, so the look can be changed in one place. */
:root {
  --ink: #0f1b2d;
  --ink-2: #4a5568;
  --ink-3: #8691a3;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e3e6eb;
  --accent: #0b5cff;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0ff;
  --good: #0a7d4f;
  --good-soft: #e3f5ec;
  --warn: #a15c00;
  --warn-soft: #fdf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* layout */
.top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; min-height: 54px; }
.brand { font-weight: 700; letter-spacing: 0.02em; color: #fff; white-space: nowrap; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: #b9c3d3; padding: 16px 11px; white-space: nowrap; font-size: 14px; border-bottom: 2px solid transparent; }
.nav a.on { color: #fff; border-bottom-color: #fff; }
.top button.link { color: #b9c3d3; }
main { max-width: 1180px; margin: 0 auto; padding: 22px 16px 64px; }
main.narrow { max-width: 640px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: block; color: inherit; }
.stat b { display: block; font-size: 26px; line-height: 1.1; letter-spacing: -0.02em; }
.stat span { color: var(--ink-2); font-size: 13px; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.note.info { background: var(--accent-soft); color: #0a3ea8; }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.empty { text-align: center; color: var(--ink-2); padding: 36px 16px; }

/* controls */
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid #cfd5de; border-radius: 9px; padding: 9px 11px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; padding: 0; vertical-align: -3px; accent-color: var(--accent); }
.field { margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
button { font: inherit; cursor: pointer; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 9px; padding: 9px 16px; font-weight: 600; font-size: 15px; text-align: center; }
.btn.ghost { background: #fff; color: var(--ink); border-color: #cfd5de; font-weight: 500; }
.btn.danger { background: #fff; color: var(--bad); border-color: #e7c2be; font-weight: 500; }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.block { display: block; width: 100%; padding: 12px; }
.btn:disabled { opacity: 0.55; cursor: default; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; }
.seg { display: inline-flex; border: 1px solid #cfd5de; border-radius: 9px; overflow: hidden; background: #fff; }
.seg label { margin: 0; padding: 8px 16px; font-size: 14px; color: var(--ink); cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; scrollbar-width: none; }
.tabs a { white-space: nowrap; padding: 6px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }
.tabs a.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* status */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #eceff3; color: var(--ink-2); white-space: nowrap; }
.pill.declared { background: var(--warn-soft); color: var(--warn); }
.pill.received_cn, .pill.in_transit, .pill.arrived_bn, .pill.departed, .pill.open { background: var(--accent-soft); color: #0a3ea8; }
.pill.ready, .pill.completed, .pill.paid, .pill.arrived, .pill.yes { background: var(--good-soft); color: var(--good); }
.pill.problem, .pill.unpaid { background: var(--bad-soft); color: var(--bad); }

/* tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafbfc; }
td .sub { color: var(--ink-2); font-size: 12px; }

/* customer pieces */
.address { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.address .code { font-size: 30px; font-weight: 700; letter-spacing: 0.04em; line-height: 1.1; }
.address dl { margin: 14px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.address dt { color: #9fb0c8; }
.address dd { margin: 0; word-break: break-word; }
.address .btn { background: #fff; color: var(--ink); border-color: #fff; margin-top: 14px; }
.item { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; color: inherit; }
.item .t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.drop { border: 2px dashed #c3cad6; border-radius: var(--radius); padding: 30px 16px; text-align: center; background: #fff; cursor: pointer; display: block; margin: 0 0 12px; color: var(--ink); font-size: 15px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { display: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.thumbs img { height: 150px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 5px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-word; }
.auth { max-width: 400px; margin: 7vh auto 0; padding: 0 16px; }
.auth h1 { text-align: center; margin-bottom: 20px; }

/* dialog + toast */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); color: var(--ink); }
dialog::backdrop { background: rgba(15, 27, 45, 0.5); }
.dlg { padding: 20px; }
.dlg-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
.bulk { position: sticky; bottom: 12px; background: var(--ink); color: #fff; border-radius: var(--radius); padding: 10px 14px; margin-top: 12px; }
.bulk select { width: auto; font-size: 14px; padding: 6px 8px; }

@media (max-width: 720px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px; }
  .g2.stack { grid-template-columns: 1fr; }
  .g2.stack .span2 { grid-column: auto; }
  h1 { font-size: 21px; }
  .kv { grid-template-columns: 110px 1fr; }
}
@media print {
  .top, .noprint { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
}

/* tariff finder */
.hits { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; margin-top: 6px; }
.hits:empty { display: none; }
.hit { display: block; width: 100%; text-align: left; background: #fff; border: 0; border-bottom: 1px solid var(--line); padding: 8px 10px; font-size: 13px; color: var(--ink); }
.hit:hover { background: var(--accent-soft); }
.hit .sub { display: block; color: var(--ink-2); font-size: 12px; }

/* accounts, calculator, usage */
.auth.wide { max-width: 520px; }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cat { margin: 0; border: 1px solid #cfd5de; border-radius: 10px; padding: 10px 12px; cursor: pointer; color: var(--ink); font-size: 14px; }
.cat input { position: absolute; opacity: 0; width: 0; height: 0; }
.cat b { display: block; }
.cat span { display: block; color: var(--ink-2); font-size: 12px; line-height: 1.35; margin-top: 2px; }
.cat:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.reg:has(input[value=personal]:checked) .needs-group { display: none; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--ink); color: #fff; }
.bar { height: 8px; border-radius: 99px; background: #e6e9ee; overflow: hidden; margin: 6px 0 4px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.pickup { background: var(--good-soft); border-color: #bfe5d1; color: var(--good); text-align: center; }
.code-big { font-size: 40px; font-weight: 700; letter-spacing: 0.12em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; text-align: center; }
.months .col { height: 90px; display: flex; align-items: flex-end; background: #f1f3f6; border-radius: 6px; overflow: hidden; }
.months .col i { display: block; width: 100%; background: var(--accent); min-height: 2px; }
.months b { display: block; font-size: 14px; margin-top: 4px; }
.months span { font-size: 12px; color: var(--ink-2); }
@media (max-width: 480px) { .cats { grid-template-columns: 1fr; } }

/* ---------- added with: milestones, alerts, wallet, scanning, deliveries ---------- */
.center { text-align: center; }
.dim { color: #9fb0c8; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.sans { font-family: var(--font); }
.pl0 { padding-left: 0; } .pr0 { padding-right: 0; } .pad8 { padding: 8px; }
.mt { margin-top: 10px; }
select.auto, input.auto { width: auto; font-size: 14px; padding: 5px 8px; }
.nowrapflex { flex-wrap: nowrap; }
.link.danger { color: var(--bad); }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
ul.plain { list-style: none; margin: 8px 0 0; padding: 0; }
ul.plain li { padding: 3px 0; }
a.note { display: block; }
details > summary { cursor: pointer; }
.chip.light { background: #e6e9ee; color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 15px; color: var(--ink); cursor: pointer; }
.check input { flex: none; }
.item.check { cursor: pointer; }
.item.check .t, .item.check .small { display: block; }
.item.unread { border-left: 3px solid var(--accent); }
.stat.warn { border-color: #f0c98a; background: var(--warn-soft); }
.okcard { border-color: #bfe5d1; background: var(--good-soft); }
img.mini { height: 84px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.printonly { display: none; }

/* customer frame: alerts link on top, tabs at the bottom */
.bell { color: #b9c3d3; font-size: 14px; padding: 6px 10px; border-radius: 99px; }
.bell.has { color: #fff; background: rgba(255, 255, 255, 0.14); }
.bell b { background: #ff5a4d; color: #fff; border-radius: 99px; padding: 0 6px; font-size: 12px; margin-left: 2px; }
main.with-tabs { padding-bottom: 96px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; max-width: 128px; text-align: center; padding: 10px 4px; font-size: 13px; color: var(--ink-2); border-radius: 10px; }
.tabbar a.on { color: var(--ink); font-weight: 700; }
.tabbar a.add { background: var(--accent); color: #fff; font-weight: 600; margin: 0 4px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.tiles a { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: inherit; }
.tiles b { display: block; }
.tiles span { font-size: 12px; color: var(--ink-2); }
.balance .big { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
pre.bank { font: inherit; white-space: pre-wrap; background: #f1f3f6; border-radius: 9px; padding: 10px 12px; margin: 0 0 10px; }
.addr { padding: 8px 0; border-bottom: 1px solid var(--line); }

/* parcel journey (customer) and shipment stages (staff) */
.journey { list-style: none; margin: 0; padding: 0; }
.journey li { position: relative; padding: 0 0 14px 24px; border-left: 2px solid var(--line); margin-left: 6px; color: var(--ink-3); }
.journey li:last-child { border-left-color: transparent; padding-bottom: 0; }
.journey li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #cfd5de; box-sizing: border-box; }
.journey li.done, .journey li.now { color: var(--ink); border-left-color: var(--accent); }
.journey li.now { border-left-color: var(--line); }
.journey li.done::before { background: var(--accent); border-color: var(--accent); }
.journey li.now::before { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.journey b { font-weight: 500; display: block; }
.journey li.now b { font-weight: 700; }
.journey span { font-size: 12px; color: var(--ink-2); display: block; }
.journey .btn { margin-top: 6px; }
.stages { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; overflow-x: auto; }
.stages li { flex: 1; min-width: 104px; border-top: 4px solid #e3e6eb; padding-top: 8px; color: var(--ink-3); font-size: 13px; }
.stages li.done { border-top-color: var(--accent); color: var(--ink); }
.stages li.now { border-top-color: var(--good); color: var(--ink); }
.stages b { display: block; font-weight: 600; }
.stages span { font-size: 12px; color: var(--ink-2); }

/* scanning and proof of delivery */
#reader { margin-top: 12px; border-radius: 10px; overflow: hidden; }
#reader:empty { display: none; }
#sig { width: 100%; height: auto; border: 1px dashed #b8c0cc; border-radius: 10px; background: #fff; touch-action: none; display: block; }
.statement h1 { font-size: 20px; }

@media (max-width: 720px) { .tiles span { display: block; } }
@media print {
  .tabbar, .bulk { display: none !important; }
  main.with-tabs { padding-bottom: 0; }
  .printonly { display: block; margin-top: 10px; }
  .stop { break-inside: avoid; border-bottom: 1px solid #999; border-radius: 0; }
}

/* ---------- CRM ---------- */
.mb { margin-bottom: 14px; }
.months.m12 { grid-template-columns: repeat(12, 1fr); gap: 4px; }
.months.m12 b { font-size: 11px; font-weight: 600; }
.months.m12 span { font-size: 10px; }
.months.m12 .col, .months.m6 .col { height: 80px; }
.stat span b { color: var(--ink); }
.noteitem { border-top: 1px solid var(--line); padding: 10px 0; }
.noteitem.done { opacity: 0.6; }
li.tl { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
li.tl.click { cursor: pointer; }
li.tl:last-child { border-bottom: 0; }
