:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #17202b;
  --muted: #667085;
  --line: #e3e6eb;
  --brand: #e2571b;
  --brand-ink: #ffffff;
  --ok: #157f3b;
  --ok-bg: #e5f5ea;
  --warn: #9a5b00;
  --warn-bg: #fff3dc;
  --bad: #b42318;
  --bad-bg: #fde8e7;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #1a2028;
    --text: #e8ecf1;
    --muted: #98a2b3;
    --line: #2c3440;
    --brand: #f07a3f;
    --ok: #5cd08a;
    --ok-bg: #173323;
    --warn: #f2b955;
    --warn-bg: #3a2c12;
    --bad: #ff8a80;
    --bad-bg: #3d1a1a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
h4 { font-size: 13px; margin: 16px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); margin-right: auto; }
.brand strong { display: block; color: var(--text); }
.brand small { color: var(--muted); }
.branch-picker { flex: 0 1 auto; flex-direction: row; align-items: center; gap: 8px; }
.branch-picker span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.branch-picker select { width: auto; max-width: 300px; }

.tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 12px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--brand); font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }
.banner { max-width: 1180px; margin: 16px auto 0; padding: 10px 14px; border-radius: var(--radius); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.sticky { position: sticky; top: 16px; }
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sticky { position: static; }
  main, .topbar, .tabs { padding-left: 16px; padding-right: 16px; }
  .branch-picker { order: 3; width: 100%; }
  .branch-picker select { flex: 1; max-width: none; }
}

fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; margin-bottom: 8px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; min-width: 0; }
.row { display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.row label { min-width: 140px; }
.row .grow { flex: 2; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
.check input { width: auto; }

button, .button {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); width: 100%; margin-top: 16px; }
.actions button.primary { width: auto; margin: 0; }
button:disabled { opacity: .55; cursor: not-allowed; }
.ghost { background: transparent; }
.danger { color: var(--bad); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.quote { display: grid; grid-template-columns: auto 1fr; row-gap: 6px; margin: 0; }
.quote dt { color: var(--muted); }
.quote dd { margin: 0; padding-left: 16px; text-align: right; }
.quote .total { font-weight: 700; font-size: 17px; color: var(--text); border-top: 1px solid var(--line); padding-top: 8px; }
.quote.compact { font-size: 13.5px; }
.quote.compact .total { font-size: 15px; }

.methods { display: grid; gap: 8px; }
.method { flex-direction: row; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); cursor: pointer; }
.method:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--surface)); }
.method input { width: auto; margin-top: 4px; }
.method small { display: block; color: var(--muted); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.muted { background: var(--line); color: var(--muted); }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }

.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.head-row h2 { margin: 0; }
.awb { font: 700 22px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; margin: 0; }
.awb.small { font-size: 14px; text-align: center; margin: 4px 0 12px; }
.paid-banner { background: var(--ok-bg); color: var(--ok); padding: 10px 14px; border-radius: 8px; font-weight: 600; margin: 12px 0; }

.pay { text-align: center; padding: 16px 0 4px; }
.va { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.va span { font: 700 clamp(22px, 5vw, 30px) ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
.qr { width: min(260px, 100%); margin: 8px auto; background: #fff; padding: 8px; border-radius: 8px; }
.qr svg { display: block; width: 100%; height: auto; }
.qr-raw { word-break: break-all; }
.pay details { text-align: left; max-width: 460px; margin: 12px auto 0; color: var(--muted); font-size: 13.5px; }

.label .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.label .cols div { display: flex; flex-direction: column; font-size: 13.5px; }
.label .cols small { color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.barcode svg { width: 100%; height: 56px; fill: var(--text); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 4px 0 4px 12px; border-left: 2px solid var(--line); }
.timeline time { display: block; color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.num { text-align: right; white-space: nowrap; }
.filters { display: flex; gap: 8px; }
.filters select { width: auto; }
.bar-cell { width: 18%; min-width: 80px; }
.bar { display: block; height: 8px; border-radius: 4px; background: var(--brand); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat small { color: var(--muted); display: block; }
.stat strong { font-size: 20px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-weight: 600; box-shadow: 0 6px 24px rgb(0 0 0 / .2); max-width: calc(100vw - 32px); }
.toast.ok { background: var(--ok); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }

@media print {
  body { background: #fff; color: #000; }
  .topbar, .tabs, .banner, .toast, .grid-2 > .card:first-child { display: none; }
  main { padding: 0; }
  .grid-2 { display: block; }
  .label { border: 2px solid #000; max-width: 420px; }
}
