:root {
  /* JR Promotions brand: black, logo blue and logo grey */
  --brand: #16191d;
  --brand-2: #0b78ad;
  --accent: #1ba3dd;
  --brand-grey: #b8babd;
  --brand-tint: #e5f4fb;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #1c2630;
  --muted: #5f6f7d;
  --border: #dde3e8;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --danger: #c0392b;
  --info: #1f6fb2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  font-size: 15px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand-2); }
.brand-logo { display: block; height: auto; }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.shell > div { min-width: 0; }
.sidebar {
  background: #fff; color: var(--text); padding: 16px 12px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--border);
}
.logo { padding: 4px 8px 6px; }
.logo .brand-logo { width: 196px; }
.logo small { display: block; color: var(--muted); font-size: 0.75rem; margin: 6px 0 0 2px; letter-spacing: 0.02em; }
.nav-group { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: #8a9097; padding: 12px 10px 4px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px;
  color: #2b3036; text-decoration: none; border-left: 3px solid transparent;
}
.nav a:hover { background: #f2f4f6; }
.nav a.active { background: var(--brand-tint); color: #075e88; font-weight: 600; border-left-color: var(--accent); }
.nav .count { background: var(--accent); color: #fff; border-radius: 999px; font-size: 0.72rem; padding: 1px 7px; font-weight: 700; }
.sidebar .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 0.85rem; }
.sidebar .me button { margin-top: 8px; }

.main { padding: 24px 28px 64px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.topbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35); }
  .topbar {
    display: flex; align-items: center; gap: 12px; background: #fff; color: var(--text); padding: 8px 12px;
    position: sticky; top: 0; z-index: 20; border-bottom: 3px solid var(--accent);
  }
  .topbar .brand-logo { width: 150px; }
  .topbar button { background: transparent; border: 0; color: var(--text); font-size: 1.4rem; padding: 0 4px; }
  .topbar .scan-top { background: var(--accent); color: #fff; font-size: 0.95rem; padding: 6px 10px; border-radius: 8px; margin-left: auto; }
  .main { padding: 16px 14px 64px; }
}

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 0.8rem; }
.kpi .value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.alert .value { color: var(--danger); }
.kpi a { color: inherit; text-decoration: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
th.num, td.num { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #eef7fc; }
tr.low td { background: #fff6ea; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: #e8edf1; color: #3b4a57; white-space: nowrap; }
.badge.pending, .badge.planned, .badge.picking { background: #fff1d6; color: var(--warn); }
.badge.approved, .badge.dispatched { background: #e2efff; color: var(--info); }
.badge.delivered, .badge.received, .badge.active, .badge.receipt, .badge.return { background: #dff5e7; color: var(--ok); }
.badge.rejected, .badge.cancelled, .badge.damage { background: #fde6e3; color: var(--danger); }
.badge.dispatch, .badge.transfer { background: #e2efff; color: var(--info); }
.badge.usage { background: #efe6fb; color: #6b3fa0; }
.badge.adjustment { background: #fff1d6; color: var(--warn); }
.badge.completed { background: #e8edf1; color: #3b4a57; }

/* ---------- forms ---------- */
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; color: #33414d; }
input, select, textarea {
  width: 100%; font: inherit; padding: 9px 10px; border: 1px solid #c9d2d9; border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(22, 105, 122, 0.35); border-color: var(--brand-2); }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 3px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters input[type='search'] { flex: 1; min-width: 200px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.check input, .filters .check input { width: auto; min-width: 0; }

button, .btn {
  font: inherit; font-weight: 600; border-radius: 8px; padding: 9px 14px; border: 1px solid transparent; cursor: pointer;
  background: var(--brand-2); color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
button:hover, .btn:hover { filter: brightness(1.07); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary, .btn.secondary { background: #fff; color: var(--brand); border-color: #c9d2d9; }
button.ghost { background: #fff; color: var(--text); border-color: var(--border); }
button.danger { background: var(--danger); }
button.ok { background: var(--ok); }
button.small, .btn.small { padding: 5px 10px; font-size: 0.85rem; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { background: #fff; color: var(--muted); border-color: var(--border); font-weight: 500; padding: 6px 12px; }
.tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.lines { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr 120px 40px; gap: 8px; align-items: start; }
.line.with-bin { grid-template-columns: 1fr 110px 100px 40px; }
.line button { padding: 9px 0; }
@media (max-width: 560px) {
  .line, .line.with-bin { grid-template-columns: 1fr 90px 36px; }
  .line.with-bin .bin { display: none; }
}

/* ---------- detail ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 0.85rem; }
.dl dd { margin: 0; }
.steps { display: flex; gap: 0; margin: 4px 0 16px; flex-wrap: wrap; }
.steps span { padding: 6px 12px; font-size: 0.8rem; border: 1px solid var(--border); background: #fff; color: var(--muted); }
.steps span:first-child { border-radius: 999px 0 0 999px; }
.steps span:last-child { border-radius: 0 999px 999px 0; }
.steps span.done { background: var(--brand-tint); color: #075e88; border-color: #b6dff2; font-weight: 600; }
.steps span.current { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 30, 40, 0.45); display: grid; place-items: start center; z-index: 50; overflow-y: auto; padding: 5vh 12px; }
.modal { background: #fff; border-radius: 12px; width: min(760px, 100%); min-width: 0; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal header button { background: transparent; color: var(--muted); font-size: 1.4rem; padding: 0 6px; }
.modal .body { padding: 18px; overflow-x: hidden; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #1c2630; color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #f4f6f8 0%, #f4f6f8 45%, var(--brand-tint) 100%); }
.login .card { border-top: 4px solid var(--accent); }
.login .card { width: min(420px, 100%); padding: 28px; }
.login .logo { padding: 0 0 18px; }
.login .logo .brand-logo { width: 100%; max-width: 300px; }
.login .logo small { color: var(--muted); }
.demo { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.demo .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.error-text { color: var(--danger); font-size: 0.9rem; margin-top: 10px; }

/* ---------- chart ---------- */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; align-items: center; font-size: 0.88rem; }
.bar-track { background: #edf1f4; border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { background: var(--brand-2); height: 100%; border-radius: 6px; }
.flow svg { width: 100%; height: 160px; display: block; }
.legend { display: flex; gap: 14px; font-size: 0.8rem; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.list { display: grid; gap: 10px; }
.list-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: #fff; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { border-color: var(--brand-2); }

/* ---------- movement / handover badges ---------- */
.badge.laundry { background: #e6f3fb; color: #1f6fb2; }
.badge.laundered { background: #dff5e7; color: var(--ok); }
.badge.write_off { background: #fde6e3; color: var(--danger); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.blind-note { background: #eef4ff; color: #2b4f86; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; }
.decide-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.decide-bar select { width: auto; }

.modal.wide { width: min(980px, 100%); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.alert-box { border: 1px solid #f0c27a; background: #fffaf0; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }

/* ---------- scanning ---------- */
.scan-btn { width: 100%; margin: 8px 0 10px; background: var(--accent); color: #fff; }
.scan-video { width: 100%; max-height: 55vh; border-radius: 10px; background: #000; display: block; object-fit: cover; }
.scan-status { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 0.9rem; }
.scan-status.ok { background: #dff5e7; color: var(--ok); font-weight: 600; }
.scan-status.error { background: #fde6e3; color: var(--danger); font-weight: 600; }
.scan-manual { display: flex; gap: 8px; margin-top: 10px; }
.qr { background: #fff; image-rendering: pixelated; }
.qr-box { text-align: center; }
.product-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.qr-codes { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* ---------- packs & scanning out ---------- */
.pack-rows { display: grid; gap: 6px; }
.pack-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 90px minmax(0, 1.4fr) auto; gap: 6px; }
.pack-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.label-counts { display: flex; gap: 8px; flex-wrap: wrap; }
.label-count { display: grid; gap: 2px; font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.label-count input { width: 76px; }
.scan-out { border: 2px solid var(--accent); border-radius: var(--radius); padding: 12px; margin: 12px 0; background: var(--brand-tint); }
.scan-out .table-wrap { background: #fff; border-radius: 8px; margin: 0; padding: 0; }
.scan-out-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.scan-out-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.scan-total { margin-top: 8px; font-weight: 700; color: var(--warn); }
.scan-total.ok { color: var(--ok); }
.scan-override { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed #9cc9df; }
@media (max-width: 560px) {
  .pack-row { grid-template-columns: minmax(0, 1fr) 80px auto; }
  .pack-row > :nth-child(3) { grid-column: 1 / 3; grid-row: 2; }
}

/* ---------- signatures & handovers ---------- */
.sig-wrap { margin-top: 12px; }
.sigpad { width: 100%; height: 160px; border: 2px dashed #b9c4cc; border-radius: 10px; background: #fff; touch-action: none; display: block; cursor: crosshair; }
.sig-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.processing { background: var(--brand-tint); color: #075e88; border-radius: 8px; padding: 8px 12px; font-weight: 600; margin-bottom: 12px; }
.uniform-check { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; padding: 10px 12px; border: 1px solid #f0c27a; background: #fffaf0; border-radius: 8px; margin-bottom: 12px; }
tr.uniform-row td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.handovers { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.handover { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: grid; gap: 6px; background: #fff; }
.handover-who { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.handover-who .arrow, .session-row .arrow { font-size: 1.4rem; color: var(--muted); }
.label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.signature { max-width: 100%; height: 70px; object-fit: contain; object-position: left; border-bottom: 1px solid var(--border); }
button.big, .btn.big { padding: 13px 20px; font-size: 1.05rem; }

/* ---------- geotags ---------- */
.geo-status { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 0.88rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.geo-status.ok { background: #dff5e7; color: var(--ok); }
.geo-status.warn { background: #fff1d6; color: var(--warn); }
.geo-link { white-space: nowrap; }
.thumb .geo-link { font-size: 0.78rem; }

/* ---------- counter ---------- */
.session { border-left: 4px solid var(--accent); }
.session-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.person { display: flex; gap: 12px; align-items: center; }
.person.staff { flex-direction: column; align-items: flex-start; gap: 0; }
.avatar { width: 54px; height: 54px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; }
.big-name { font-size: 1.3rem; }
.counter-start { max-width: 620px; }
.counter-start .or { text-align: center; color: var(--muted); margin: 16px 0 10px; font-size: 0.85rem; }

/* ---------- attachments ---------- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.thumb { margin: 0; position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.thumb img, .thumb .pdf { width: 100%; height: 120px; object-fit: cover; display: block; background: var(--surface-2); }
.thumb .pdf { display: grid; place-items: center; font-weight: 700; color: var(--danger); }
.thumb figcaption { padding: 6px 8px; font-size: 0.8rem; }
.thumb-del { position: absolute; top: 4px; right: 4px; padding: 0 8px; background: rgba(0, 0, 0, 0.55); border-radius: 6px; }
.upload-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upload-row input { flex: 1; min-width: 200px; }
.file-picker { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- reminders ---------- */
.reminder { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: inherit; background: #fff; }
.reminder:hover { border-color: var(--brand-2); }
.reminder .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--muted); }
.reminder.high .dot { background: var(--danger); }
.reminder.medium .dot { background: #e0962b; }
.reminder.low .dot { background: #7aa7c7; }

/* ---------- lines / matrix / kits ---------- */
.batch-row { margin-top: 6px; }
.batch-fields { display: grid; grid-template-columns: 1fr 160px; gap: 8px; }
table.matrix th, table.matrix td { text-align: center; }
table.matrix tbody th { background: var(--surface-2); width: 70px; }
table.matrix td.low { background: #fff1d6; }
table.matrix td.current { outline: 2px solid var(--brand-2); outline-offset: -2px; }
td.clickable { cursor: pointer; }
td.clickable:hover { background: #f0f6f7; }
.kit-items { margin: 0; padding-left: 18px; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--brand-2); }

/* ---------- campaign colours ---------- */
.swatch { display: inline-block; border-radius: 4px; vertical-align: -2px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); flex: none; }
.camp-tag { display: inline-flex; gap: 6px; align-items: center; }
.shelf-tag { display: inline-block; margin-top: 3px; font-size: 0.75rem; font-weight: 600; padding: 1px 8px 1px 6px; border-radius: 999px; border-left: 6px solid var(--c); background: #f2f4f6; }
.with-stripe { border-left: 5px solid var(--c, transparent); padding-left: 8px; margin-left: -8px; min-width: 220px; }
.colour-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.colour-choice { background: #fff; color: var(--text); border: 1px solid var(--border); font-weight: 500; padding: 5px 10px; }
.colour-choice .swatch { width: 16px; height: 16px; }
.colour-choice.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); font-weight: 700; }
.shelf-hint { display: flex; gap: 8px; align-items: center; font-weight: 600; min-height: 4px; }
.qr-label.banded { border-left: 10px solid var(--c); }
.label-band { margin-top: 3px; font-weight: 700; font-size: 0.72rem; text-transform: uppercase; }
.shelf-sign { border: 3px solid var(--c); border-radius: 14px; overflow: hidden; margin: 0 0 16px; break-inside: avoid; background: #fff; }
.shelf-sign-band { background: var(--c); color: #fff; font-size: 2.6rem; font-weight: 800; letter-spacing: 0.06em; padding: 14px 22px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.shelf-sign-body { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 22px; font-size: 1.1rem; }
.shelf-sign-name { font-size: 1.8rem; font-weight: 800; }

/* ---------- setups ---------- */
.agenda-day { margin-bottom: 18px; }
.agenda-day h3 { margin: 6px 0 8px; }
.agenda-day.overdue h3 { color: var(--danger); }
.agenda-item { border-left: 6px solid var(--c); }
.agenda-time { width: 92px; flex: none; font-weight: 700; font-size: 1.05rem; }
.agenda-kind { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
.agenda-kind.setup { color: var(--ok); }
.agenda-kind.strike { color: #b25e00; }
.agenda-kind.return { color: var(--info); }
.setup-head { border-top: 6px solid var(--c); }
.stage-list { display: grid; gap: 0; }
.stage { display: flex; gap: 12px; align-items: flex-start; padding: 0 0 14px 2px; position: relative; color: var(--muted); }
.stage:not(:last-child)::before { content: ''; position: absolute; left: 8px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.stage-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #c9d2d9; background: #fff; margin-top: 3px; flex: none; z-index: 1; }
.stage.done { color: var(--text); }
.stage.done .stage-dot { background: var(--ok); border-color: var(--ok); }
.stage.current { color: var(--text); }
.stage.current .stage-dot { background: var(--accent); border-color: #e0962b; }

/* ---------- messages ---------- */
.wa-link { display: inline-flex; align-items: center; gap: 4px; background: #25d366; color: #fff !important; text-decoration: none; font-weight: 700; font-size: 0.78rem; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.wa-link::before { content: '✆'; }
.wa-link:hover { background: #1ebe5b; }
.chat-head h2 { margin-bottom: 2px; }
.chat-head { margin-bottom: 10px; }
.chat-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.chat-empty { padding: 8px; }
.bubble { max-width: min(560px, 85%); background: #fff; border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; padding: 7px 11px; align-self: flex-start; }
.bubble.mine { align-self: flex-end; background: var(--brand-tint); border-color: #b7dcee; border-radius: 12px 12px 4px 12px; }
.bubble-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 2px; }
.bubble-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-send { display: flex; gap: 8px; margin-top: 8px; align-items: flex-end; }
.chat-send textarea { flex: 1; min-height: 44px; resize: vertical; }
.messages-layout { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.inbox-card { padding: 8px; }
.inbox { display: grid; gap: 4px; max-height: 70vh; overflow-y: auto; }
.inbox-item { display: block; min-width: 0; overflow: hidden; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; border: 1px solid transparent; }
.inbox-item:hover { background: var(--surface-2); }
.inbox-item.active { background: var(--brand-tint); border-color: #b7dcee; }
.inbox-item.unread .inbox-last { font-weight: 700; color: var(--text); }
.inbox-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.inbox-top strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-top .count { background: var(--accent); color: #fff; border-radius: 999px; font-size: 0.72rem; padding: 1px 7px; font-weight: 700; }
.inbox-last { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-top { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.thread-back { display: none; }
.thread-empty { min-height: 200px; display: grid; place-items: center; }
.notice-banner { display: block; background: #fff8e1; border: 1px solid #f3d27a; border-left: 6px solid #e0a800; border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px; color: var(--text); text-decoration: none; }
.banner { border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px; font-weight: 600; }
.banner.warn { background: #fff4e0; border: 1px solid #f0c27b; color: #8a5300; }
.banner.ok { background: #e3f6ea; border: 1px solid #a8dcb9; color: var(--ok); }
@media (max-width: 800px) {
  .messages-layout { grid-template-columns: 1fr; }
  .messages-layout.has-thread .inbox-card { display: none; }
  .messages-layout:not(.has-thread) .thread-card { display: none; }
  .thread-back { display: inline-flex; }
  .chat-list { max-height: 55vh; }
}

/* ---------- handover condition & BA form ---------- */
.condition { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.condition-opts { display: flex; gap: 14px; flex-wrap: wrap; }
.ba-form { max-width: 900px; margin: 0 auto; font-size: 0.9rem; }
.ba-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.ba-top .brand-logo { width: 220px; }
.ba-title { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.03em; }
.ba-band { background: var(--brand); color: #fff; font-weight: 800; letter-spacing: 0.06em; padding: 5px 10px; margin: 16px 0 8px; border-left: 6px solid var(--accent); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.ba-form table { width: 100%; border-collapse: collapse; }
.ba-form th, .ba-form td { border: 1px solid #c9d2d9; padding: 6px 8px; text-align: left; vertical-align: top; }
.ba-form th { background: #f2f5f7; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.ba-details th { width: 16%; }
.ba-details td { width: 34%; }
.ba-stock td.num { text-align: right; white-space: nowrap; }
.ba-stock tr.owed td { background: #fff4e0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.ba-office tbody th { width: 24%; }
.ba-sign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.ba-sign { border: 1px solid #c9d2d9; padding: 8px 10px; }
.ba-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.ba-sig { display: block; width: 100%; height: 90px; object-fit: contain; border-bottom: 1px solid #999; margin: 4px 0 8px; background: #fff; }
.ba-sig.empty { color: var(--muted); font-size: 0.8rem; padding-top: 60px; height: 30px; }
.ba-ticks { display: flex; gap: 16px; margin-top: 4px; }
.ba-tick { color: var(--muted); }
.ba-tick.on { color: var(--text); font-weight: 700; }
@media (max-width: 640px) {
  .ba-sign-grid { grid-template-columns: 1fr; }
  .ba-details th, .ba-details td { display: block; width: auto; border-bottom: 0; }
  .ba-details tr { display: block; border-bottom: 1px solid #c9d2d9; }
}

/* ---------- labels & badges ---------- */
.print-only { display: none; }
.label-sheet, .badge-sheet { display: grid; gap: 8px; }
.label-sheet:empty { display: none; }
.label-sheet { grid-template-columns: repeat(3, 1fr); }
.qr-label { display: flex; gap: 8px; align-items: center; border: 1px dashed #c9d2d9; border-radius: 6px; padding: 6px; break-inside: avoid; font-size: 0.8rem; }
.label-name { font-weight: 700; line-height: 1.2; font-size: 0.85rem; }
.label-text { min-width: 0; display: grid; gap: 1px; }
.label-pack { font-weight: 800; text-transform: uppercase; font-size: 0.78rem; background: var(--brand); color: #fff; padding: 1px 5px; border-radius: 3px; justify-self: start; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.label-exp { font-weight: 800; font-size: 0.9rem; }
.qr-label .qr { flex: none; }
.badge-sheet { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); margin-top: 16px; }
.id-badge { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; break-inside: avoid; }
.id-head { background: var(--brand); color: #fff; padding: 8px 12px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.id-head { border-bottom: 4px solid var(--accent); }
.id-head .brand-logo { height: 26px; width: auto; background: #fff; border-radius: 6px; padding: 3px 6px; }
.id-body { display: flex; gap: 12px; padding: 12px; align-items: center; }
.id-name { font-size: 1.2rem; font-weight: 700; }
.my-badge { max-width: 380px; margin: 0 auto; text-align: center; padding: 0 0 20px; overflow: hidden; }
.my-badge .id-head { justify-content: center; margin-bottom: 18px; }
.my-badge .qr { width: min(240px, 70vw); height: auto; }
.slip-head { display: flex; justify-content: space-between; gap: 12px; }
.sign-lines { justify-content: space-between; margin-top: 30px; }

@media print {
  .sidebar, .topbar, .page-head .actions, .no-print, #toasts, .scan-btn { display: none !important; }
  .print-only { display: block; }
  .sign-lines.print-only { display: flex; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body:has(.print-area:not(:empty)) .main > div > :not(.print-area) { display: none !important; }
  .qr-label { border-color: #ddd; }
}
