/* Horse Cargo — app styles */
:root {
  /* Horse Cargo brand (from logo) */
  --brand: #800c1f;
  --brand-2: #640919;
  --brand-3: #a3223a;
  --brand-soft: #f8e8eb;
  --brand-ink: #4a0612;
  --amber-soft: #fdf3dc;
  --bg: #f7f4f5;
  --card: #ffffff;
  --ink: #16202b;
  --ink-2: #4a5868;
  --ink-3: #7b8896;
  --line: #e2e7ee;
  --line-2: #eef1f5;
  --green: #1d8a55;
  --green-soft: #e3f5ec;
  --red: #c8352e;
  --red-soft: #fbe7e6;
  --blue: #2463b8;
  --blue-soft: #e5eefb;
  --violet: #6a48b8;
  --violet-soft: #efeafb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 50, .06), 0 2px 8px rgba(16, 32, 50, .05);
  --sidebar: 244px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--brand-3); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
.mono { font-family: var(--mono); letter-spacing: -.01em; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───── shell ───── */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: #f5e6e9; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding-top: var(--safe-top); }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.brand b { display: block; font-size: 15px; letter-spacing: .02em; }
.brand span { font-size: 11px; color: #e8c3ca; }
.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: #f3dde1; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.15); color: #fff; box-shadow: inset 3px 0 0 #fff; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.nav .nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #d9a3ad; padding: 8px 10px 4px; }
.side-foot { padding: 12px 14px calc(12px + var(--safe-bottom)); border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot .role { color: #e8c3ca; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(247,244,245,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: calc(10px + var(--safe-top)) 24px 10px; display: flex; align-items: center; gap: 12px; }
.topbar .title { font-weight: 650; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .mobile-brand { display: none; }
.content { padding: 20px 24px 40px; max-width: 1280px; width: 100%; margin: 0 auto; }
.bottom-nav { display: none; }

.lang-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: #fff; }
.lang-toggle button { border: 0; background: transparent; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.lang-toggle button.on { background: var(--brand); color: #fff; }

/* ───── components ───── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.card-h h2, .card-h h3 { flex: 1; }
.card-b { padding: 16px; }
.card-b.tight { padding: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 9px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 38px; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: #f7f9fb; border-color: #cfd7e1; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--brand-3); border-color: var(--brand-3); color: #fff; }
.btn.accent:hover { filter: brightness(.96); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0c9c6; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--ink-2); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--line-2); }
.icon-btn svg { width: 20px; height: 20px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.s-pending_deposit { background: var(--amber-soft); color: #8a5a00; }
.s-booked { background: var(--blue-soft); color: var(--blue); }
.s-received { background: #e6f1f7; color: #1f6f95; }
.s-loaded { background: var(--violet-soft); color: var(--violet); }
.s-in_transit { background: #e9e8fb; color: #4b43b8; }
.s-arrived { background: #e3f3f3; color: #16777a; }
.s-clearing { background: #fbeee2; color: #a2561a; }
.s-ready { background: var(--green-soft); color: var(--green); }
.s-released { background: #e8ebef; color: #3f4b58; }
.s-cancelled { background: var(--red-soft); color: var(--red); }
.s-received_dubai { background: var(--blue-soft); color: var(--blue); }
.s-packed { background: var(--violet-soft); color: var(--violet); }
.s-dispatched { background: #e9e8fb; color: #4b43b8; }
.s-in_customs { background: #fbeee2; color: #a2561a; }
.s-delivered { background: var(--green-soft); color: var(--green); }
.s-open { background: var(--blue-soft); color: var(--blue); }
.s-departed { background: #e9e8fb; color: #4b43b8; }
.s-completed { background: #e8ebef; color: #3f4b58; }
.mode { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.mode svg { width: 14px; height: 14px; }

.kpi { padding: 14px 16px; }
.kpi .k { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi.alert .v { color: var(--red); }

.pipeline { display: grid; grid-template-columns: repeat(8, minmax(0,1fr)); gap: 8px; }
.pipe { display: block; padding: 12px; border-radius: 10px; background: #fff; border: 1px solid var(--line); color: var(--ink); position: relative; }
.pipe:hover { border-color: var(--brand-3); }
.pipe .n { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pipe .l { font-size: 11.5px; color: var(--ink-2); font-weight: 600; margin-top: 2px; }
.pipe .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: 10px 0 0 10px; }

/* table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f8fafc; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tfoot td { font-weight: 700; border-top: 1px solid var(--line); background: #fafbfc; }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-3); }
.empty svg { width: 36px; height: 36px; opacity: .45; margin-bottom: 6px; }

/* mobile list cards */
.list-cards { display: none; }
.lc { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line-2); color: var(--ink); }
.lc:last-child { border-bottom: 0; }
.lc .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.lc .sub { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }

/* forms */
.form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid #d3dbe4; background: #fff; border-radius: 9px; padding: 9px 11px; min-height: 40px; outline: none; transition: border-color .12s, box-shadow .12s; }
textarea.input { min-height: 72px; resize: vertical; }
.input:focus { border-color: var(--brand-3); box-shadow: 0 0 0 3px rgba(128,12,31,.14); }
.input.sm { min-height: 32px; padding: 5px 8px; border-radius: 7px; }
.input[readonly] { background: #f6f8fa; }
.req::after { content: " *"; color: var(--red); }
.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow); }
.seg button svg { width: 15px; height: 15px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); }
.search .input { padding-left: 34px; }

.callout { border-radius: 10px; padding: 10px 12px; font-size: 13px; display: flex; gap: 9px; align-items: flex-start; }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout.warn { background: var(--amber-soft); color: #7a4f00; }
.callout.danger { background: var(--red-soft); color: #8f231e; }
.callout.info { background: var(--blue-soft); color: #1b4f93; }
.callout.ok { background: var(--green-soft); color: #145f3b; }

/* key-value */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 7px 12px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.money { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); }
.money > div { padding: 12px 16px; border-right: 1px solid var(--line-2); }
.money > div:last-child { border-right: 0; }
.money .k { font-size: 11.5px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.money .v { font-size: 18px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.money .v.due { color: var(--red); }
.money .v.ok { color: var(--green); }

/* stepper */
.stepper { display: flex; gap: 0; overflow-x: auto; padding: 14px 16px; }
.step { flex: 1; min-width: 78px; text-align: center; position: relative; font-size: 11px; color: var(--ink-3); font-weight: 600; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--line); margin: 0 auto 6px; display: grid; place-items: center; position: relative; z-index: 1; color: #fff; }
.step .dot svg { width: 13px; height: 13px; }
.step::before { content: ""; position: absolute; top: 11px; left: -50%; right: 50%; height: 2px; background: var(--line); }
.step:first-child::before { display: none; }
.step.done { color: var(--ink-2); }
.step.done .dot { background: var(--green); }
.step.done::before, .step.cur::before { background: var(--green); }
.step.cur { color: var(--brand); }
.step.cur .dot { background: var(--brand); box-shadow: 0 0 0 4px rgba(128,12,31,.15); }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 4px 0 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: -6px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--brand-3); }
.timeline li:first-child::after { background: var(--brand); border-color: var(--brand); }
.timeline .tt { font-weight: 650; }
.timeline .tn { color: var(--ink-2); font-size: 13px; }
.timeline .tm { color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 8px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 11px 12px; font-weight: 600; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

.progress { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--brand-3); border-radius: 99px; }
.progress.over > div { background: var(--red); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(12, 22, 34, .5); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .16s ease; }
.modal.wide { max-width: 860px; }
.modal-h { padding: 16px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
.modal-h h2 { flex: 1; }
.modal-b { padding: 18px; overflow-y: auto; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* toast */
#toast-root { position: fixed; z-index: 200; right: 16px; bottom: calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-weight: 500; display: flex; gap: 9px; align-items: flex-start; animation: pop .18s ease; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.ok { background: #145f3b; }
.toast.err { background: #8f231e; }

/* login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(1200px 600px at 10% 0%, #a3223a 0%, var(--brand) 55%, #4a0612 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art h1 { font-size: 34px; line-height: 1.15; max-width: 440px; }
.auth-art p { color: #f0d3d9; max-width: 420px; }
.auth-art .lanes { display: flex; gap: 10px; flex-wrap: wrap; }
.auth-art .lanes span { border: 1px solid rgba(255,255,255,.2); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; color: #f7e4e8; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box .brand { color: var(--brand); padding: 0 0 24px; }
.auth-box .brand span { color: var(--ink-3); }

/* doc / print */
.doc-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.doc { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 36px 40px; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); font-size: 13px; }
.doc .dh { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--brand); padding-bottom: 14px; margin-bottom: 18px; }
.doc .dh .co b { font-size: 18px; color: var(--brand); display: block; }
.doc .dh .co div { color: #555; font-size: 12px; }
.doc .dh .dt { text-align: right; }
.doc .dh .dt h1 { font-size: 22px; letter-spacing: .06em; color: var(--brand); }
.doc table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.doc th { background: #f1f4f8; text-align: left; padding: 7px 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid #ccd; }
.doc td { padding: 7px 8px; border-bottom: 1px solid #e5e8ee; }
.doc .num { text-align: right; }
.doc .tot td { font-weight: 700; border-top: 2px solid #333; }
.doc .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.doc .parties h4 { font-size: 11px; text-transform: uppercase; color: #777; letter-spacing: .05em; margin-bottom: 4px; }
.doc .foot { margin-top: 26px; font-size: 11.5px; color: #555; border-top: 1px solid #ddd; padding-top: 10px; }
.doc .sig { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; }
.doc .sig div { border-top: 1px solid #333; padding-top: 5px; font-size: 12px; }
.doc .stamp { display: inline-block; border: 2px solid; border-radius: 6px; padding: 3px 10px; font-weight: 800; letter-spacing: .08em; transform: rotate(-4deg); }
.labels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 820px; margin: 0 auto; }
.label { background: #fff; color: #000; border: 2px solid #000; border-radius: 6px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 10px; page-break-inside: avoid; break-inside: avoid; }
.label .l1 { font-size: 20px; font-weight: 900; letter-spacing: .06em; }
.label .l2 { font-family: var(--mono); font-size: 17px; font-weight: 700; }
.label .l3 { font-size: 16px; font-weight: 800; }
.label .l4 { font-size: 15px; font-weight: 700; }
.label .qr svg, .label .qr img { width: 92px; height: 92px; display: block; }
.qr-box svg { display: block; width: 100%; height: auto; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; }
  .sidebar, .topbar, .bottom-nav, .doc-toolbar, #toast-root, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .labels { gap: 6mm; }
}

/* A4 documents and packing operations */
.doc h2 { color: var(--brand); font-size: 14px; margin: 18px 0 8px; }
.doc h3 { font-size: 12px; margin: 0 0 6px; color: var(--brand); }
.doc table { table-layout: fixed; }
.doc td, .doc th, .doc p, .doc .co, .doc .parties { overflow-wrap: anywhere; }
.doc-note { color: #555; font-size: 11px; }
.payment-info { border: 1px solid #d9c5ca; border-radius: 4px; padding: 12px; margin-top: 22px; }
.payment-info h2 { margin: 0 0 12px; }
.payment-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.payment-grid p { margin: 6px 0; font-size: 11px; }
.packing-summary { border-top: 2px solid var(--brand); padding-top: 12px; margin-top: 18px; }
.pl-list-card { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.pl-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.pl-item p { overflow-wrap: anywhere; margin: 4px 0; }
.pl-item-actions { display: flex; align-items: end; gap: 6px; flex-wrap: wrap; }
.pl-item-actions label { display: grid; gap: 4px; font-size: 11px; width: 105px; }
.pl-item-form { display: grid; gap: 12px; max-width: 600px; padding: 16px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
.pl-item-form label { display: grid; gap: 5px; }
.pl-item-form select { max-width: 100%; }
@media (max-width: 700px) {
  .pl-item { grid-template-columns: minmax(0,1fr); }
  .pl-box .card-h { flex-wrap: wrap; gap: 8px; }
  .pl-item-form { padding: 12px; }
  .doc .dh { flex-wrap: wrap; gap: 12px; }
  .doc .dh .dt { text-align: left; }
  .payment-grid { grid-template-columns: minmax(0,1fr); }
}
@media print {
  .doc { width: 100%; font-size: 10pt; }
  .doc .dh { flex-wrap: nowrap; }
  .doc .dh .dt { text-align: right; }
  .doc .parties { grid-template-columns: 1fr 1fr; }
  .doc-top { flex-direction: row; }
  .doc thead { display: table-header-group; }
  .doc tfoot { display: table-row-group; }
  .doc tr { break-inside: avoid; }
  .doc h2 { break-after: avoid; }
  .doc .payment-info, .doc .sig, .doc .packing-summary { break-inside: avoid; }
  .payment-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .doc th { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* scanner */
#scanner { width: 100%; max-width: 480px; margin: 0 auto; border-radius: 12px; overflow: hidden; background: #000; min-height: 260px; }

/* ───── responsive ───── */
@media (max-width: 1100px) {
  .pipeline { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: calc(8px + var(--safe-top)) 14px 8px; background: var(--brand); color: #fff; border-bottom: 0; }
  .topbar .icon-btn { color: #fff; }
  .topbar .icon-btn:hover { background: rgba(255,255,255,.1); }
  .topbar .mobile-brand { display: block; width: 28px; height: 28px; border-radius: 7px; }
  .topbar .lang-toggle { border-color: rgba(255,255,255,.25); background: transparent; }
  .topbar .lang-toggle button { color: #f3dde1; }
  .topbar .lang-toggle button.on { background: #fff; color: var(--brand); }
  .content { padding: 14px 14px calc(88px + var(--safe-bottom)); }
.bottom-nav { display: grid; grid-template-columns: repeat(var(--bottom-items, 5), minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); padding: 4px 4px calc(4px + var(--safe-bottom)); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: 10.5px; font-weight: 600; color: var(--ink-3); border-radius: 8px; }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav a.scan { color: #fff; }
  .bottom-nav a.scan span.ic { background: var(--brand); color: #fff; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 4px 14px rgba(128,12,31,.4); }
  .bottom-nav a.scan span.tx { color: var(--ink-2); }
  .grid.c2, .grid.c3 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .money { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .money > div:nth-child(2) { border-right: 0; }
  .money > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-2); }
  .kv { grid-template-columns: 110px 1fr; }
  .hide-m { display: none !important; }
  .list-cards { display: block; }
  .table-wrap.cards-m { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .doc { padding: 18px; }
  .doc .parties { grid-template-columns: 1fr; }
  .labels { grid-template-columns: 1fr; }
  h1 { font-size: 19px; }
  .modal-bg { place-items: end center; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; }
  .modal-f { padding-bottom: calc(12px + var(--safe-bottom)); }
}
@media (max-width: 420px) {
  .grid.c4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .v { font-size: 19px; }
  .pipeline { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* brand logo placements */
.side-logo { display: flex; justify-content: center; padding: 20px 18px 14px; }
.side-logo img { height: 96px; width: auto; }
.side-branches { text-align: center; font-size: 10.5px; color: #e8c3ca; letter-spacing: .04em; padding: 0 12px 10px; }
.logo-tile { background: var(--brand); border-radius: 10px; display: inline-grid; place-items: center; }
.auth-logo { height: 170px; width: auto; }
.doc .dh .logo-tile { width: 64px; height: 64px; flex: none; }
.doc .dh .logo-tile img { width: 50px; height: auto; }
.topbar .mobile-brand { height: 26px; width: auto; border-radius: 0; }

/* ───────── animated login ───────── */
.login { position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden; color: #fff;
  background: radial-gradient(900px 520px at 50% 34%, #a3223a 0%, var(--brand) 52%, #4a0612 100%); }
.login-scene { position: absolute; inset: 0; pointer-events: none; }
.login-lang { position: absolute; z-index: 3; top: calc(16px + var(--safe-top)); right: 16px; }
.login-lang .lang-toggle { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.28); }
.login-lang .lang-toggle button { color: #f3dde1; }
.login-lang .lang-toggle button.on { background: #fff; color: var(--brand); }
.login-center { position: relative; z-index: 2; min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(88px + var(--safe-top)) 16px calc(120px + var(--safe-bottom)); gap: 14px; }

.login-logo { position: relative; width: 196px; animation: hcLogoIn 1.1s cubic-bezier(.2,.8,.2,1) both, hcFloat 6s ease-in-out 1.2s infinite; }
.login-logo img { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 24px rgba(0,0,0,.25)); }
.login-logo::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  -webkit-mask: url(../img/logo-white.png) center / contain no-repeat; mask: url(../img/logo-white.png) center / contain no-repeat;
  background: linear-gradient(105deg, transparent 38%, rgba(255,240,200,.95) 50%, transparent 62%) -140% 0 / 250% 100% no-repeat;
  animation: hcShine 5.5s ease-in-out 1.4s infinite; }
.login-tagline { margin: 0; font-size: 15px; color: #f0d3d9; text-align: center; max-width: 340px; animation: hcRise .8s ease-out .45s both; }
.login-card { width: 100%; max-width: 380px; background: #fff; color: var(--ink); border-radius: 18px; padding: 24px 22px 18px;
  box-shadow: 0 24px 60px rgba(40,0,10,.35), 0 2px 6px rgba(40,0,10,.15); animation: hcRise .8s cubic-bezier(.2,.8,.2,1) .6s both; }
.login-card h1 { font-size: 20px; margin-bottom: 16px; }
.login-lanes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; animation: hcRise .8s ease-out .8s both; }
.login-lanes span { border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.06); border-radius: 999px; padding: 4px 11px; font-size: 12px; color: #f7e4e8; }

.login .routes { position: absolute; top: calc(8px + var(--safe-top)); left: 50%; transform: translateX(-50%); width: min(1200px, 100%); height: auto; overflow: visible; }
.login .routes text { fill: rgba(255,255,255,.7); font: 600 13px var(--font); letter-spacing: .12em; }
.login .route-draw { stroke-dasharray: 100; stroke-dashoffset: 100; animation: hcDraw 9s linear infinite; }

.cloud { position: absolute; height: 40px; border-radius: 40px; background: rgba(255,255,255,.07); filter: blur(2px); }
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 50%; height: 150%; left: 15%; top: -60%; }
.cloud::after { width: 35%; height: 120%; right: 15%; top: -40%; }
.cloud.c1 { width: 160px; top: 22%; animation: hcDrift 70s linear infinite; }
.cloud.c2 { width: 110px; top: 44%; animation: hcDrift 95s linear -40s infinite; opacity: .7; }
.cloud.c3 { width: 200px; top: 62%; animation: hcDrift 120s linear -80s infinite; opacity: .5; }

.sea { position: absolute; left: 0; right: 0; bottom: 0; height: 110px; }
.wave { position: absolute; bottom: 0; left: 0; width: 200%; height: 60px; animation: hcWave 16s linear infinite; }
.wave path { fill: rgba(255,255,255,.08); }
.wave.w2 { height: 48px; animation-duration: 11s; animation-direction: reverse; }
.wave.w2 path { fill: rgba(0,0,0,.12); }
.ship { position: absolute; bottom: 34px; left: 0; animation: hcSail 48s linear infinite; }
.ship svg { display: block; opacity: .85; animation: hcBob 3.2s ease-in-out infinite; transform-origin: 50% 80%; }

@keyframes hcLogoIn { from { opacity: 0; transform: translateY(24px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes hcFloat { 0%,100% { translate: 0 0; } 50% { translate: 0 -7px; } }
@keyframes hcShine { 0%, 55% { background-position: -140% 0; } 85%, 100% { background-position: 240% 0; } }
@keyframes hcRise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes hcDraw { 0% { stroke-dashoffset: 100; opacity: 1; } 90% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes hcDrift { from { transform: translateX(-260px); } to { transform: translateX(calc(100vw + 260px)); } }
@keyframes hcWave { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes hcSail { from { transform: translateX(-160px); } to { transform: translateX(calc(100vw + 40px)); } }
@keyframes hcBob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-4px) rotate(1deg); } }

@media (max-width: 860px) {
  .login-logo { width: 150px; }
  .login-center { padding-top: calc(96px + var(--safe-top)); gap: 12px; }
  .login .routes text { font-size: 22px; }
  .sea { height: 86px; }
  .ship { bottom: 26px; }
  .ship svg { width: 96px; height: 42px; }
}
@media (max-height: 700px) { .login-center { justify-content: flex-start; } .sea { opacity: .5; } }
@media (prefers-reduced-motion: reduce) {
  .login *, .login *::before, .login *::after { animation: none !important; }
  .login .plane { display: none; }
  .login .route-draw { stroke-dashoffset: 0; }
}


/* ───────── shipment wizard (v2) ───────── */
.wiz { display: flex; flex-direction: column; gap: 12px; }
.wiz-steps { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.wiz-steps::-webkit-scrollbar { display: none; }
.wiz-step { display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; background: #fff;
  border: 1px solid var(--line); white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--ink-3); cursor: default; }
.wiz-step .n { width: 19px; height: 19px; border-radius: 50%; background: var(--line-2); color: var(--ink-2);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.wiz-step.done { color: var(--brand); border-color: var(--brand-soft); cursor: pointer; }
.wiz-step.done .n { background: var(--brand-soft); color: var(--brand); }
.wiz-step.on { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow); }
.wiz-step.on .n { background: rgba(255,255,255,.22); color: #fff; }
.wiz-bar { height: 4px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.wiz-bar > div { height: 100%; background: var(--brand); border-radius: 4px; transition: width .25s ease; }
.wiz-foot { display: flex; align-items: center; gap: 10px; position: sticky; bottom: 0; padding: 10px 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent); }
.wiz-foot .btn { min-height: 46px; min-width: 110px; justify-content: center; }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: #fff; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.pick:hover { border-color: var(--brand-3); }
.pick.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--shadow); }
.pick .pi svg { width: 22px; height: 22px; color: var(--brand); }
.pick b { font-size: 15px; }

.calc { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.calc > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; font-size: 13.5px; border-bottom: 1px solid var(--line-2); }
.calc > div:last-child { border-bottom: 0; }
.calc > div span { color: var(--ink-2); }
.calc .tot { background: var(--brand-soft); font-size: 16px; font-weight: 800; color: var(--brand); }

.cust-hits { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.cust-hits .hit { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; }
.cust-hits .hit:hover { border-color: var(--brand); background: var(--brand-soft); }

.steps { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.steps .stp { flex: 1; min-width: 92px; font-size: 11px; font-weight: 650; color: var(--ink-3); }
.steps .stp span { display: block; height: 5px; border-radius: 3px; background: var(--line-2); margin-bottom: 5px; }
.steps .stp.done span { background: var(--brand-3); }
.steps .stp.done { color: var(--ink-2); }
.steps .stp.on span { background: var(--brand); }
.steps .stp.on { color: var(--brand); }
@media (max-width: 860px) {
  .wiz-step .l { display: none; }
  .wiz-step.on .l { display: inline; }
}


/* ───────── documents: QR verification block ───────── */
.doc-top { display: flex; gap: 16px; align-items: flex-start; }
.doc-top > *:first-child { flex: 1; min-width: 0; }
.qr-box.verify { width: 150px; flex: 0 0 150px; text-align: center; padding: 8px; background: #fff;
  border: 1px solid #ddd; border-radius: 8px; }
.qr-box.verify svg { width: 120px; height: 120px; display: block; margin: 0 auto 6px; }
.qr-box.verify .vq { font-size: 10.5px; color: #444; line-height: 1.25; }
.qr-box.verify .vs { font-size: 10.5px; font-weight: 700; margin-top: 3px; }
@media (max-width: 700px) { .doc-top { flex-direction: column; } .qr-box.verify { align-self: flex-start; } }
@media print { .qr-box.verify { border-color: #999; } }


/* ───────── one-click status buttons ───────── */
.status-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sbtn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; min-height: 42px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 13px; font-weight: 650;
  cursor: pointer; white-space: nowrap; }
.sbtn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.sbtn svg { width: 15px; height: 15px; }
.sbtn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.sbtn.on:disabled { opacity: 1; cursor: default; }
.sbtn:disabled { opacity: .55; cursor: not-allowed; }
.sbtn.last { margin-left: auto; border-color: var(--green); color: var(--green); }
.sbtn.last:hover:not(:disabled) { background: var(--green-soft); border-color: var(--green); color: var(--green); }

/* ───────── responsive polish (v3) ───────── */
html, body { max-width: 100%; overflow-x: hidden; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.page-head { flex-wrap: wrap; gap: 10px; }
.page-head .row { flex-wrap: wrap; }
@media (max-width: 860px) {
  .page-head h1 { font-size: 20px; }
  .page-head .row .btn { flex: 1 1 auto; justify-content: center; }
  .card-h { flex-wrap: wrap; gap: 8px; }
  .card-h .row { width: 100%; }
  .card-h .row .btn { flex: 1 1 auto; justify-content: center; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .money { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .sbtn { flex: 1 1 calc(50% - 8px); justify-content: center; }
  .sbtn.last { flex: 1 1 100%; margin-left: 0; }
  .modal { max-height: 88vh; }
  .modal-b { max-height: calc(88vh - 130px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .form .field, .form .field.full { grid-column: 1 / -1; }
  .input, .btn { font-size: 16px; }          /* stops iOS zooming the page on focus */
  .btn { min-height: 44px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  .wiz-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 520px) {
  .grid.c4, .money { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 20px; }
  .t th, .t td { padding: 9px 8px; }
}
@media print {
  .status-btns, .doc-toolbar, .bottom-nav, .side { display: none !important; }
}

/* ── v4 · storage, packing and special access ───────────────────────── */
.pk-unpacked         { background: var(--red-soft);   color: var(--red); }
.pk-partially_packed { background: var(--blue-soft);  color: var(--blue); }
.pk-fully_packed     { background: var(--green-soft); color: var(--green); }
.pkbar { display: block; height: 4px; border-radius: 999px; background: var(--line-2); margin-top: 5px; overflow: hidden; max-width: 130px; }
.pkbar span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .2s ease; }
.void-row td { opacity: .55; }
.struck { text-decoration: line-through; }
.pill { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; line-height: 17px; text-align: center; }
.chip.on .pill { background: #fff; color: var(--brand); }
.pack-t td { vertical-align: middle; }
.pack-t .qty { width: 78px; text-align: right; padding: 6px 8px; }
.pack-t .all-btn { display: block; margin: 3px 0 0 auto; font-size: 11px; }
button.link { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; cursor: pointer; }
.lbl { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; font-size: 13px; }
.note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.note.info { background: var(--blue-soft); color: var(--blue); }

@media (max-width: 720px) {
  /* on a phone the packing sheet reads as a stack of items, not a wide table */
  .pack-t thead { display: none; }
  .pack-t, .pack-t tbody, .pack-t tr, .pack-t td { display: block; width: 100%; }
  .pack-t tr { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
  .pack-t td { border: 0; padding: 2px 0; text-align: left !important; }
  .pack-t td[data-l]::before { content: attr(data-l); }
  .pack-t td:nth-child(2), .pack-t td:nth-child(3), .pack-t td:nth-child(4) { display: inline-block; width: auto; margin-right: 14px; font-size: 12.5px; color: var(--ink-3); }
  .pack-t .qty { width: 100%; text-align: left; margin-top: 6px; font-size: 16px; }
  .pack-t .all-btn { margin: 4px 0 0; }
  .pkbar { max-width: none; }
}
/* Keep print rules after mobile rules: A4 must retain document columns. */
@media print {
  .content { padding: 0; }
  html, body, .shell, .main, .content, #page { background: #fff !important; min-height: 0; }
  .doc { padding: 0; font-size: 9pt; line-height: 1.35; }
  .doc .parties { grid-template-columns: 1fr 1fr; }
  .doc-top { flex-direction: row; }
  .doc .dh { flex-wrap: nowrap; }
  .doc .dh .dt { text-align: right; }
  .payment-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .doc td, .doc th { padding: 5px 6px; }
  .doc .foot { margin-top: 14px; }
  .doc .sig { margin-top: 26px; }
  .doc .payment-info { margin-top: 14px; }
}

/* ───────── v6 · staff mail, leads, sourcing, scan, registers ───────── */
.nav a { position: relative; }
.nav-badge { margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px; background: #fff; color: var(--brand);
  font-size: 11px; font-weight: 800; display: inline-grid; place-items: center; line-height: 1; }
.nav-badge.hidden { display: none; }
.top-act { position: relative; }
.top-act .nav-badge { position: absolute; top: -2px; right: -4px; background: var(--brand); color: #fff; margin: 0; border: 2px solid #fff; }
.bottom-nav a { position: relative; }
.bottom-nav .nav-badge { position: absolute; top: 2px; right: calc(50% - 22px); background: var(--red); color: #fff; margin: 0; height: 17px; min-width: 17px; font-size: 10px; }
.bottom-nav a.scan .nav-badge { top: -16px; right: calc(50% - 26px); }
.pre { white-space: pre-wrap; }
.due-flag { color: var(--red); font-weight: 700; }
.wrap-actions { flex-wrap: wrap; gap: 8px; }
.danger-text { color: var(--red); }
.reg-tools { flex-wrap: wrap; gap: 10px; }
.reg-tools .chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; scrollbar-width: none; }
.reg-tools .chips::-webkit-scrollbar { display: none; }
.lc.click, tr.click { cursor: pointer; }
.steps-line { display: flex; gap: 4px; margin: 0 0 14px; overflow-x: auto; scrollbar-width: none; }
.steps-line span { flex: 1 0 auto; text-align: center; font-size: 11.5px; font-weight: 600; padding: 6px 10px; border-radius: 999px; background: var(--line-2); color: var(--ink-3); white-space: nowrap; }
.steps-line span.on { background: var(--brand-soft); color: var(--brand); }

/* staff mail */
.mail-folders { margin-bottom: 4px; }
.mail-folders .chip { display: inline-flex; align-items: center; gap: 6px; }
.mail-folders .chip svg { width: 15px; height: 15px; }
.mail-folders .cnt { font-weight: 800; }
.mail-list { display: flex; flex-direction: column; }
.mail-row { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); color: var(--ink); min-width: 0; }
.mail-row:hover { background: #fbfafb; }
.mail-row:last-child { border-bottom: 0; }
.mail-row .av, .mail-msg .av { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; flex: none; }
.mr-main { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.mr-top { display: flex; justify-content: space-between; gap: 10px; }
.mr-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.mr-time { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.mr-subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.mr-snip { color: var(--ink-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row.unread .mr-who, .mail-row.unread .mr-subj { color: var(--ink); font-weight: 750; }
.mail-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; }
.mail-thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.mail-msg { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.mail-msg.mine { border-left: 3px solid var(--brand); }
.mail-msg header { display: flex; gap: 10px; align-items: flex-start; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 12px 0 6px; line-height: 1.55; }
.mail-msg .receipts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rr { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-3); }
.rr svg { width: 12px; height: 12px; }
.rr.ok { background: var(--green-soft); color: var(--green); }
.msg-acts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.rcpt { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 5px 8px; background: #fff; min-height: 42px; }
.rcpt:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.rcpt-chips { display: contents; }
.rchip { display: inline-flex; align-items: center; gap: 4px; background: var(--brand-soft); color: var(--brand-ink); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12.5px; font-weight: 600; }
.rchip button { border: 0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; color: var(--brand); padding: 0 4px; min-width: 24px; min-height: 24px; }
.rcpt-in { border: 0; outline: 0; flex: 1; min-width: 120px; font: inherit; padding: 4px 2px; background: transparent; }
.rcpt-list { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 4px; background: #fff; box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; }
.rcpt-opt { display: flex; flex-direction: column; align-items: flex-start; width: 100%; border: 0; background: #fff; padding: 8px 10px; cursor: pointer; text-align: left; font: inherit; }
.rcpt-opt:hover, .rcpt-opt:focus { background: var(--line-2); }

/* scan result */
.scan-wrap { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.scan-result { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.scan-result .sr-brand { background: var(--brand); color: #fff; font-weight: 800; letter-spacing: .12em; padding: 10px 16px; font-size: 13px; }
.scan-result .sr-head { display: flex; gap: 10px; align-items: center; padding: 14px 16px; font-size: 17px; }
.scan-result .sr-head svg { width: 26px; height: 26px; flex: none; }
.scan-result.ok .sr-head { background: var(--green-soft); color: var(--green); }
.scan-result.no .sr-head { background: var(--red-soft); color: var(--red); }
.scan-result.warn .sr-head { background: var(--amber-soft); color: #8a5a00; }
.scan-result .sr-rows { padding: 4px 16px 8px; }
.scan-result .vrow { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.scan-result .vrow:last-child { border-bottom: 0; }
.scan-result .vrow span { color: var(--ink-2); }
.scan-result .vrow b { text-align: right; overflow-wrap: anywhere; }
.scan-result .sr-acts { padding: 12px 16px 16px; gap: 8px; flex-wrap: wrap; }
.vtag { padding: 2px 9px; border-radius: 999px; font-size: 12.5px; }
.vtag.ok { background: var(--green-soft); color: var(--green); }
.vtag.no { background: var(--red-soft); color: var(--red); }

/* role permissions */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.perm-group { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px 10px; margin: 0; }
.perm-group legend { font-weight: 700; padding: 0 4px; }
.perm-row { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; cursor: pointer; }
.perm-row input { margin-top: 3px; width: 17px; height: 17px; flex: none; }

@media (max-width: 860px) {
  .top-act .nav-badge { border-color: var(--brand); background: #fff; color: var(--brand); }
  .mail-row { padding: 12px; }
  .mail-msg { padding: 12px; }
  .mail-head .wrap-actions .btn { flex: 1 1 auto; }
  .scan-result .sr-acts .btn { flex: 1 1 100%; justify-content: center; min-height: 46px; }
  .wrap-actions { width: 100%; }
  .wrap-actions .btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
  .staff-filters .search, .staff-filters select { max-width: none !important; flex: 1 1 100%; }
}
/* history lists (shipment timeline, lead & sourcing history) */
ol.tl { list-style: none; margin: 0; padding: 4px 0 0; }
ol.tl li { position: relative; padding: 0 0 14px 22px; }
ol.tl li::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: -6px; width: 2px; background: var(--line); }
ol.tl li:last-child::before { display: none; }
ol.tl li::after { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--brand-3); }
ol.tl li:first-child::after { background: var(--brand); border-color: var(--brand); }

/* Work-area navigation: six top-level entries, one open group. */
.menu-group-toggle { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 44px; padding: 10px; margin-bottom: 2px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.menu-group-toggle > span:first-of-type { flex: 1; min-width: 0; }
.menu-group-toggle svg { width: 18px; height: 18px; flex: none; }
.menu-chevron { font-size: 23px; line-height: 18px; transition: transform .15s; }
.menu-group-toggle[aria-expanded="true"] .menu-chevron { transform: rotate(90deg); }
.menu-group-links[hidden] { display: none !important; }
.menu-group-toggle:focus-visible, .grouped-menu a:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.sidebar .menu-group-toggle { color: #f3dde1; }
.sidebar .menu-group-toggle:hover, .sidebar .menu-group-toggle[aria-expanded="true"] { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .menu-group-toggle.active-group { color: #fff; }
.sidebar .menu-group-links { margin: 0 0 8px 9px; padding-left: 9px; border-left: 1px solid rgba(255,255,255,.18); }
.sidebar .menu-group-links a { padding: 8px 9px; font-size: 13px; }
.menu-section-label { padding: 10px 9px 4px; color: var(--ink-3); font-size: 11px; font-weight: 600; }
.sidebar .menu-section-label { color: #e8c3ca; }
.side-logo { padding-top: 16px; padding-bottom: 8px; }
.side-logo img { height: 72px; }
.top-tool { display: inline-flex; align-items: center; gap: 6px; position: relative; min-height: 38px; padding: 7px 9px; border-radius: 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; flex: none; }
.top-tool svg { width: 19px; height: 19px; flex: none; }
.top-tool:hover, .top-tool.active { background: var(--brand-soft); color: var(--brand); }
.top-tool .nav-badge { margin-left: 0; }
.workspace-menu, .workspace-tools { margin-bottom: 14px; }
.workspace-menu { padding: 6px; }
.workspace-menu > a, .workspace-menu .menu-group-links a { display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 10px; border-radius: 8px; }
.workspace-menu a svg { width: 19px; height: 19px; flex: none; }
.workspace-menu .menu-group-links { padding-left: 15px; }
.workspace-menu a:hover, .workspace-menu .menu-group-toggle:hover { background: var(--bg); }
.workspace-tools svg { width: 20px; height: 20px; flex: none; }
.dashboard-actions .btn { justify-content: flex-start; white-space: normal; text-align: left; }
.dashboard-actions .btn svg { flex: none; }
@media (max-width: 860px) {
  .top-tool { color: #fff; min-width: 36px; min-height: 40px; justify-content: center; padding: 6px; }
  .top-tool:hover, .top-tool.active { background: rgba(255,255,255,.1); color: #fff; }
  .top-tool .tool-label, .top-scan { display: none; }
  .topbar { gap: 7px; }
  .top-tool .nav-badge { position: absolute; top: 0; right: -2px; }
  .bottom-nav a { min-height: 48px; }
  .menu-group-toggle { min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) { .menu-chevron { transition: none; } }

/* An available update stays outside the changing page shell. */
.app-update { position:fixed; z-index:1000; bottom:calc(20px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%); width:min(540px,calc(100% - 24px)); display:flex; align-items:center; gap:12px; padding:12px 16px; border-radius:12px; background:var(--brand); color:#fff; box-shadow:0 4px 24px #0003; }
.app-update span { flex:1; font-size:14px; }
.app-update .btn { flex-shrink:0; background:#fff; color:var(--brand); }
@media (max-width:767px) { .app-update { bottom:calc(78px + env(safe-area-inset-bottom)); } }
