/* Otayo Kiakia Delivery Register
   Look: a dispatch waybill in the brand colours, navy #070329 on white, one wide typeface. */

:root {
  --ink: #070329;
  --ink-2: #1D1850;
  --tint: #ECEBF4;       /* light navy wash for highlights */
  --on-ink-muted: #B9B6D3; /* secondary text on navy */
  --ground: #F4F4F8;
  --paper: #FFFFFF;
  --line: #D3D2E0;
  --muted: #5B5875;
  --focus: #1B4FB8;

  --ok: #0E7A45;      --ok-bg: #DDF3E6;
  --wait: #7A4F00;    --wait-bg: #FFEFC0;
  --move: #1B4FB8;    --move-bg: #E1EAFB;
  --stop: #4B5566;    --stop-bg: #E4E8ED;
  --bad: #B3261E;     --bad-bg: #FBE3E1;

  --r-sm: 6px;
  --r: 10px;
  --sidebar: 248px;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
  font-variant-numeric: tabular-nums;
}
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2 { font-stretch: 112%; line-height: 1.15; margin: 0; }
h1 { font-size: 1.25rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 750; }
small { font-size: .82em; }
code { font-size: .9em; word-break: break-all; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: min(86vw, 300px);
  background: var(--ink); color: #fff;
  display: flex; flex-direction: column;
  transform: translateX(-102%);
  transition: transform .22s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.sidebar.open { transform: none; box-shadow: 8px 0 30px rgba(7, 3, 41, .35); }
.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(7, 3, 41, .6); }
.brand { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 14px 20px; border-bottom: 3px solid #fff; }
.brand-mark { display: inline-flex; flex-direction: column; text-decoration: none; color: inherit; margin: 0; }
.brand-mark span { font-size: 1.7rem; font-weight: 800; font-stretch: 125%; letter-spacing: -.01em; line-height: 1; }
.brand-mark small { font-size: .8rem; opacity: .8; margin-top: 4px; }
.brand-mark.on-light span { color: #fff; background: var(--ink); padding: 4px 10px 2px; align-self: flex-start; }
.brand-mark.on-light small { color: var(--muted); opacity: 1; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar nav a {
  display: block; padding: 13px 20px; color: #DCDAEC; text-decoration: none; font-weight: 600;
  border-left: 5px solid transparent;
}
.sidebar nav a:hover { background: var(--ink-2); color: #fff; }
.sidebar nav a.active { color: #fff; background: var(--ink-2); border-left-color: #fff; }
.sidebar-user { padding: 14px 20px 18px; border-top: 1px solid var(--ink-2); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sidebar-user a { color: #fff; text-decoration: none; font-weight: 600; display: flex; flex-direction: column; }
.sidebar-user small { color: var(--on-ink-muted); font-weight: 400; }
.link-btn { background: none; border: 0; color: #fff; text-decoration: underline; text-underline-offset: 3px; font: inherit; font-weight: 600; cursor: pointer; padding: 8px 0; }

.icon-btn { background: none; border: 0; color: inherit; width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-sm); cursor: pointer; }
.sidebar-close { color: #fff; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-new { padding: 9px 14px; font-size: .92rem; }
.content { padding: 16px 12px 48px; max-width: 1180px; margin: 0 auto; }

@media (min-width: 1024px) {
  .sidebar { width: var(--sidebar); transform: none; transition: none; }
  .sidebar-close, .hamburger, .overlay { display: none !important; }
  .main { margin-left: var(--sidebar); }
  .topbar { padding: 14px 28px; }
  .topbar h1 { font-size: 1.5rem; }
  .content { padding: 24px 28px 64px; }
}

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px;
  font: inherit; font-weight: 700; line-height: 1.1; text-decoration: none; white-space: nowrap;
  border: 2px solid var(--ink); border-radius: var(--r-sm); cursor: pointer;
  background: var(--paper); color: var(--ink);
}
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-lg { min-height: 54px; font-size: 1.08rem; padding: 14px 28px; font-stretch: 112%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

label { display: block; font-weight: 650; font-size: .92rem; }
.opt { font-weight: 400; color: var(--muted); font-size: .85em; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  display: block; width: 100%; margin-top: 6px;
  min-height: 48px; padding: 11px 12px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--r-sm);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--tint); }
[aria-invalid="true"] { border-color: var(--bad) !important; background: #FFF8F7 !important; }
.field-error { color: var(--bad); font-size: .88rem; font-weight: 600; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: .86rem; margin: 6px 0 0; }
.field.check label, .check label { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-top: 22px; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }
.field-submit { display: flex; align-items: flex-end; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 800; font-stretch: 112%; margin-bottom: 10px; }
.stack > * + * { margin-top: 14px; }
.grid-2, .grid-3 { display: grid; gap: 14px; }
@media (min-width: 700px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-3 .form-actions, .grid-2 .form-actions { grid-column: 1 / -1; }
}
.naira-input { position: relative; }
.naira-input span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--muted); margin-top: 3px; }
.naira-input input:not([type=checkbox]) { padding-left: 34px; font-weight: 650; }

/* ---------- Flash, panels, empty ---------- */
.flash { padding: 12px 14px; border-radius: var(--r-sm); margin-bottom: 12px; font-weight: 600; border-left: 5px solid; }
.flash-ok { background: var(--ok-bg); border-color: var(--ok); color: #0A4F2D; }
.flash-error { background: var(--bad-bg); border-color: var(--bad); color: #7C1A14; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 16px; }
.panel.narrow { max-width: 520px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head .count { font-size: 1.6rem; font-stretch: 125%; }
.empty { text-align: center; padding: 28px 12px; }
.empty p { color: var(--muted); margin: 0 0 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.segmented { display: flex; overflow-x: auto; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--r-sm); max-width: 100%; }
.segmented a { padding: 9px 14px; text-decoration: none; font-weight: 650; white-space: nowrap; font-size: .92rem; }
.segmented a + a { border-left: 1px solid var(--line); }
.segmented a.on { background: var(--ink); color: #fff; }
.actions, .form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.form-actions { justify-content: flex-end; }
form.inline { display: inline; }
.more { text-align: center; margin: 12px 0 0; }
.chip { display: inline-flex; gap: 8px; align-items: center; background: var(--tint); padding: 6px 10px; border-radius: 99px; font-weight: 600; margin: 0; align-self: end; }
.chip a { text-decoration: none; font-size: 1.2rem; line-height: 1; }

/* ---------- Status badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.st-delivered, .st-paid { background: var(--ok-bg); color: var(--ok); }
.st-pending, .st-assigned, .st-partially-paid { background: var(--wait-bg); color: var(--wait); }
.st-picked-up, .st-in-transit { background: var(--move-bg); color: var(--move); }
.st-cancelled { background: var(--stop-bg); color: var(--stop); }
.st-failed, .st-unpaid { background: var(--bad-bg); color: var(--bad); }
.st-remitted { background: var(--ok-bg); color: var(--ok); }
.st-not-remitted { background: var(--wait-bg); color: var(--wait); }

/* ---------- Dashboard ---------- */
.stat-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat {
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; text-decoration: none; min-height: 96px;
}
.stat b { font-size: 2rem; font-stretch: 125%; font-weight: 800; line-height: 1; }
.stat span { color: var(--muted); font-weight: 600; font-size: .88rem; }
.stat:hover { border-color: var(--ink); }
.stat-lead { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat-lead span { color: var(--on-ink-muted); }
.stat-lead b { color: #fff; }
@media (min-width: 760px) { .stat-strip { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }

.money-board {
  display: grid; grid-template-columns: 1fr; gap: 0;
  background: var(--paper); border: 2px solid var(--ink); border-radius: var(--r);
  margin-bottom: 16px; overflow: hidden;
}
.money-board > div { padding: 12px 16px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.money-board > div + div { border-top: 1px solid var(--line); }
.money-board span { color: var(--muted); font-weight: 600; font-size: .9rem; }
.money-board b { font-size: 1.25rem; font-weight: 800; font-stretch: 112%; }
.money-board .plus { display: none; }
.money-board .money-total { background: var(--ink); color: #fff; }
.money-board .money-total span { color: var(--on-ink-muted); }
.money-board .money-total b { font-size: 1.5rem; font-stretch: 125%; }
.money-board .money-owed.has-owed b { color: var(--bad); }
@media (min-width: 900px) {
  .money-board { grid-template-columns: 1fr auto 1fr auto 1.25fr 1fr; align-items: stretch; }
  .money-board > div { flex-direction: column; justify-content: center; align-items: flex-start; }
  .money-board > div + div { border-top: 0; border-left: 1px solid var(--line); }
  .money-board .plus { display: flex; align-items: center; font-size: 1.6rem; font-weight: 800; color: var(--muted); padding: 0 6px; border-left: 0 !important; }
  .money-board .plus + div { border-left: 0; }
}

/* ---------- Tables (become cards on phones) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table td small { display: block; color: var(--muted); }
.table .num { text-align: right; white-space: nowrap; font-weight: 650; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: #F6F8FA; }
.row-dim td { opacity: .55; }
.ref { font-weight: 800; font-stretch: 112%; text-decoration: none; white-space: nowrap; }
.cell-route span { display: block; }
.cell-route .to::before { content: "↓ "; color: var(--muted); font-weight: 700; }
.cell-action { white-space: nowrap; text-align: right; }

@media (max-width: 759px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; }
  .panel .table-cards tr { border-color: var(--line); }
  .table-cards td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; font-weight: 600; text-align: left; flex-shrink: 0; }
  .table-cards td.cell-ref { text-align: left; font-size: 1.05rem; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
  .table-cards td.cell-ref::before { content: none; }
  .table-cards td.num { font-size: 1rem; }
  .table-cards td small { display: inline; margin-left: 6px; }
  .table-cards td .pod-tag { display: inline; }
  .table-cards td.cell-ref { display: flex; justify-content: space-between; align-items: baseline; }
  .table-cards td .svc { display: inline-block; margin: 0; padding: 2px 8px; border-radius: 99px; background: var(--tint); }
  .table-cards td.cell-action { justify-content: flex-end; gap: 8px; }
  .table-cards td.cell-action::before { content: none; }
  .table-cards .cell-route { flex-direction: row; }
  .table-cards .cell-route span { display: block; }
  .panel:has(> .table-wrap) { background: transparent; border: 0; padding: 0; }
  .panel:has(> .table-wrap) .panel-head { padding: 0 2px; }
}

/* ---------- Filters ---------- */
.filters { margin-bottom: 12px; }
.search-row { display: flex; gap: 8px; }
.search-row input { margin-top: 0; }
.search-row select { margin-top: 0; width: auto; }
.filters details { margin-top: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); }
.filters summary, .edit-box > summary, .user-row > summary { padding: 12px 14px; font-weight: 700; cursor: pointer; min-height: 44px; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 14px 12px; }
.filter-actions { display: flex; gap: 10px; padding: 0 14px 14px; }
@media (min-width: 900px) { .filter-grid { grid-template-columns: repeat(6, 1fr); } }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 2px 12px; color: var(--muted); }
.result-bar p { margin: 0; }
.result-bar b { color: var(--ink); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }
.edit-box { padding: 0; }
.edit-box > form, .edit-box > .flash { margin: 0 14px 14px; }
.edit-box > form.grid-2, .edit-box > form.grid-3 { padding: 0; }

/* ---------- Pay on delivery & quick-fill chips ---------- */
@media (min-width: 700px) { .grid-2 .span-2 { grid-column: 1 / -1; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip-btn {
  font: inherit; font-size: .85rem; font-weight: 650; color: var(--ink);
  min-height: 34px; padding: 5px 12px; border-radius: 99px; cursor: pointer;
  background: var(--paper); border: 1.5px solid var(--line);
}
.chip-btn:hover { border-color: var(--ink); }
.chip-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.switch-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-weight: 400; padding: 4px 0; }
.switch-row input { width: 24px; height: 24px; margin-top: 1px; flex-shrink: 0; accent-color: var(--ink); }
.switch-row b { display: block; font-weight: 700; font-size: 1rem; }
.switch-row small { display: block; color: var(--muted); font-size: .86rem; margin-top: 2px; }
.pod-fields { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.pod-strip {
  display: grid; gap: 0; margin-bottom: 16px; border-radius: var(--r); overflow: hidden;
  border: 2px dashed var(--ink); background: var(--paper);
}
.pod-strip > * { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 16px; text-decoration: none; }
.pod-strip > * + * { border-top: 1px solid var(--line); }
.pod-strip span { color: var(--muted); font-weight: 600; font-size: .9rem; }
.pod-strip b { font-size: 1.2rem; font-weight: 800; font-stretch: 112%; }
.pod-strip .has-owed b { color: var(--wait); }
@media (min-width: 760px) {
  .pod-strip { grid-auto-flow: column; grid-auto-columns: 1fr; }
  .pod-strip > * { flex-direction: column; align-items: flex-start; }
  .pod-strip > * + * { border-top: 0; border-left: 1px solid var(--line); }
}
.pod-tag { display: block; font-size: .78rem !important; font-weight: 700; color: var(--wait) !important; }
.pod-tag.is-done { color: var(--ok) !important; }
.table td.owed { color: var(--wait); }
.wb-pod { background: var(--tint); }

/* ---------- Service type ---------- */
.service-pick { margin: 0; }
.service-pick legend { font-size: 1.05rem; margin-bottom: 12px; }
.service-pick[aria-invalid="true"] .pick span { border-color: var(--bad); }
.pick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { position: relative; margin: 0; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick span {
  display: inline-flex; align-items: center; min-height: 46px; padding: 8px 18px;
  border: 2px solid var(--line); border-radius: 99px; background: var(--paper);
  font-weight: 700; cursor: pointer;
}
.pick span:hover { border-color: var(--ink); }
.pick input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.pick input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.svc { display: block; margin-top: 3px; font-weight: 700; font-size: .78rem !important; color: var(--ink-2) !important; }
.svc-none { color: var(--muted) !important; font-weight: 500; }
.badge-service { background: #fff; color: var(--ink); }
.add-row { display: flex; gap: 8px; margin-top: 14px; }
.add-row input { margin-top: 0; }
.inline-delete { padding: 0 14px 14px; }

/* ---------- Delivery form ---------- */
.delivery-form { max-width: 860px; }
.form-section { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.form-section h2 { margin-bottom: 12px; }
.slip {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  background: var(--ink); border-color: var(--ink); color: #fff;
}
.slip span { display: block; font-size: .85rem; font-weight: 600; }
.slip b { display: block; }
.ref-big { font-size: 1.7rem; font-weight: 800; font-stretch: 125%; letter-spacing: -.01em; line-height: 1.05; }
@media (min-width: 700px) { .ref-big { font-size: 2.3rem; } }
.slip-when b { font-weight: 700; font-size: 1.05rem; margin-top: 4px; }

/* The route: pickup and delivery joined by a line, like on a waybill */
.route { padding-left: 38px; position: relative; }
.route::before { content: ""; position: absolute; left: 19px; top: 28px; bottom: 44%; border-left: 3px dashed var(--ink); }
.route-leg { position: relative; }
.route-leg + .route-leg { margin-top: 20px; }
.route-leg::before {
  content: ""; position: absolute; left: -26px; top: 3px; width: 17px; height: 17px;
  border-radius: 50%; border: 4px solid var(--ink); background: var(--paper);
}
.route-leg + .route-leg::before { background: var(--ink); border-radius: 3px; }

.money-calc { display: grid; gap: 14px; }
.total-out { background: var(--ink); color: #fff; border-radius: var(--r-sm); padding: 14px 16px; }
.total-out span { font-weight: 600; font-size: .92rem; color: var(--on-ink-muted); }
.total-out output { display: block; font-size: 2rem; font-weight: 800; font-stretch: 125%; color: #fff; line-height: 1.1; margin-top: 2px; }
.total-out .hint { color: var(--on-ink-muted); }
@media (min-width: 760px) { .money-calc { grid-template-columns: 1fr 1fr 1.1fr; align-items: start; } }

.form-actions .btn-lg { width: 100%; }
@media (min-width: 700px) { .form-actions .btn-lg { width: auto; } }
@media (max-width: 699px) {
  .delivery-form .form-actions { position: sticky; bottom: 0; z-index: 10; background: var(--ground); padding: 10px 0 max(10px, env(safe-area-inset-bottom)); margin: 0 -2px; }
}

/* Autocomplete */
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% - 2px); z-index: 25;
  background: var(--paper); border: 2px solid var(--ink); border-top-width: 1px; border-radius: 0 0 var(--r-sm) var(--r-sm);
  margin: 0; padding: 4px 0; list-style: none; max-height: 320px; overflow-y: auto;
  box-shadow: 0 12px 24px rgba(7, 3, 41, .18);
}
.ac-list li { padding: 11px 12px; cursor: pointer; min-height: 48px; }
.ac-list li b { display: block; font-weight: 700; }
.ac-list li small { color: var(--muted); }
.ac-list li[aria-selected="true"], .ac-list li:hover { background: var(--tint); }
.ac-list li.ac-new { border-top: 1px solid var(--line); color: var(--muted); }
.ac-list li.ac-new b { color: var(--ink); }
.ac-list li.ac-note { cursor: default; color: var(--muted); font-size: .9rem; min-height: 0; }
.ac-tag { display: inline-block; margin-top: 6px; font-size: .82rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.ac-tag.is-new { background: var(--wait-bg); color: var(--wait); }
.ac-tag.is-found { background: var(--ok-bg); color: var(--ok); }

/* ---------- Delivery details (waybill) ---------- */
.waybill { background: var(--paper); border: 2px solid var(--ink); border-radius: var(--r); overflow: hidden; margin-bottom: 16px; }
.waybill-head { background: var(--ink); color: #fff; padding: 16px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: flex-end; }
.waybill-head p { margin: 6px 0 0; font-weight: 600; font-size: .92rem; }
.waybill-badges .badge { font-size: .9rem; padding: 5px 12px; background: var(--paper); }
.waybill .actions { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.wb-block, .wb-route { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.wb-block:last-child { border-bottom: 0; }
.waybill h2 { font-size: .85rem; color: var(--muted); font-stretch: 100%; font-weight: 700; margin-bottom: 4px; }
.waybill p { margin: 2px 0; }
.wb-main { font-size: 1.15rem; font-weight: 750; }
.wb-route { display: grid; gap: 16px; padding-left: 50px; position: relative; }
.wb-route::before { content: ""; position: absolute; left: 25px; top: 24px; bottom: 50%; border-left: 3px dashed var(--ink); }
.wb-leg { position: relative; }
.wb-leg::before { content: ""; position: absolute; left: -32px; top: 2px; width: 17px; height: 17px; border-radius: 50%; border: 4px solid var(--ink); background: var(--paper); }
.wb-leg + .wb-leg::before { background: var(--ink); border-radius: 3px; }
@media (min-width: 760px) {
  .waybill { display: grid; grid-template-columns: 1fr 1fr; }
  .waybill-head, .waybill .actions, .wb-route { grid-column: 1 / -1; }
  .wb-block:nth-of-type(odd) { border-right: 1px solid var(--line); }
  .wb-route { grid-template-columns: 1fr 1fr; padding-left: 16px; }
  .wb-route::before { left: 24px; right: 50%; top: 24px; bottom: auto; border-left: 0; border-top: 3px dashed var(--ink); display: none; }
  .wb-leg { padding-left: 30px; }
  .wb-leg::before { left: 0; }
}
.sum { margin: 6px 0 0; }
.sum div { display: flex; justify-content: space-between; padding: 5px 0; }
.sum dt { color: var(--muted); }
.sum dd { margin: 0; font-weight: 700; }
.sum .sum-total { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 8px; }
.sum .sum-total dt { color: var(--ink); font-weight: 750; }
.sum .sum-total dd { font-size: 1.2rem; font-weight: 800; }
.sum .sum-owed dd, .sum .sum-owed dt { color: var(--bad); font-weight: 750; }

/* ---------- Customer, reports, import ---------- */
.profile { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; align-items: center; }
.profile p { margin: 2px 0; }
.mini-stats { display: flex; gap: 20px; margin: 0; }
.mini-stats dt { color: var(--muted); font-size: .82rem; font-weight: 600; }
.mini-stats dd { margin: 0; font-size: 1.3rem; font-weight: 800; font-stretch: 112%; }
.range-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.range-form label { font-size: .82rem; }
.range-form input { min-height: 44px; padding: 8px; }
.report-title { font-size: 1.2rem; font-weight: 800; font-stretch: 112%; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 12px; }
.report-grid { display: grid; gap: 16px; margin-top: 16px; }
@media (min-width: 900px) { .report-grid { grid-template-columns: 1.3fr 1fr; } }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { position: relative; margin-bottom: 8px; }
.bars li a { display: flex; justify-content: space-between; padding: 8px 10px; text-decoration: none; position: relative; z-index: 1; font-weight: 600; }
.bars li i { position: absolute; inset: 0 auto 0 0; width: var(--w); min-width: 4px; border-radius: var(--r-sm); }
.import-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.import-summary div { border-radius: var(--r-sm); padding: 12px; }
.import-summary b { display: block; font-size: 1.8rem; font-stretch: 125%; line-height: 1; }
.import-summary span { font-size: .85rem; font-weight: 600; }
.map-grid { display: grid; gap: 10px; margin-bottom: 10px; }
.map-grid label span { display: block; font-weight: 700; }
@media (min-width: 760px) { .map-grid { grid-template-columns: repeat(3, 1fr); } }
.preview-table td, .preview-table th { font-size: .88rem; white-space: nowrap; }
.preview-table td small { max-width: 280px; white-space: normal; }
.row-error td { background: #FFF8F7; }
.io-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .io-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.export-list { list-style: none; margin: 12px 0 0; padding: 0; }
.export-list li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.export-list li span { flex: 1; font-weight: 700; }
.user-list .user-row { border-top: 1px solid var(--line); }
.user-row summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; }
.user-row summary span:last-child { color: var(--muted); font-weight: 500; font-size: .9rem; }
.user-row form, .user-row .hint { padding: 0 14px 14px; }
.kv div { padding: 8px 0; border-top: 1px solid var(--line); }
.kv dt { color: var(--muted); font-size: .85rem; font-weight: 600; }
.kv dd { margin: 2px 0 0; }
.secret { filter: blur(5px); cursor: pointer; }
.secret.shown { filter: none; }
.code-box { background: var(--ink); color: #fff; padding: 14px; border-radius: var(--r-sm); overflow-x: auto; font-size: .85rem; }

/* ---------- Login / install ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: var(--ink); }
.auth-card { background: var(--paper); width: 100%; max-width: 420px; border-radius: var(--r); padding: 28px 22px; border-top: 8px solid var(--ink); }
.auth-card.wide { max-width: 560px; }
.auth-card h1 { font-size: 1.6rem; margin: 20px 0 16px; }

/* ---------- Print: the delivery page becomes a clean waybill ---------- */
.print-only { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 12pt; }
  .sidebar, .overlay, .topbar, .no-print, .flash, .actions { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0; max-width: none; }
  .print-only { display: block; font-weight: 700; }
  .waybill, .panel, .money-board { border: 1.5pt solid #000; break-inside: avoid; }
  .waybill-head { background: #fff; color: #000; border-bottom: 3pt solid #000; }
  .badge { border: 1pt solid #000; background: #fff !important; color: #000 !important; }
  .money-board .money-total, .stat-lead, .slip { background: #fff !important; color: #000 !important; }
  .money-board .money-total span, .stat-lead span { color: #000; }
  .stat-lead b { color: #000; }
  a { text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
