/* BH Distribution - shared design system */
:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e3e8ef;
  --border-strong: #c9d2de;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #8795a8;

  --navy: #0b1220;
  --navy-2: #121d33;
  --navy-3: #1b2a47;
  --accent: #14b8a6;
  --accent-strong: #0d9488;
  --accent-soft: #ccfbf1;
  --accent-2: #38bdf8;

  --green: #16a34a; --green-soft: #dcfce7; --green-text: #166534;
  --amber: #f59e0b; --amber-soft: #fef3c7; --amber-text: #92400e;
  --red: #dc2626;   --red-soft: #fee2e2;   --red-text: #991b1b;
  --blue: #2563eb;  --blue-soft: #dbeafe;  --blue-text: #1e40af;
  --violet: #7c3aed; --violet-soft: #ede9fe; --violet-text: #5b21b6;
  --gray-soft: #e9edf3; --gray-text: #475569;

  --radius: 14px; --radius-sm: 9px; --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 6px 24px -8px rgba(15, 23, 42, .18), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.45; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15.5px; } h4 { font-size: 13.5px; }
p { margin: 0; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.strong { font-weight: 600; } .right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; } .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.hide { display: none !important; }

/* ---- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 560; font-size: 14px; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s, box-shadow .15s, transform .05s; box-shadow: var(--shadow-sm); text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); border-color: #b8c3d1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: #0b7f73; }
.btn.dark { background: var(--navy-2); border-color: var(--navy-2); color: #fff; } .btn.dark:hover { background: var(--navy-3); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; } .btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; } .btn.ghost:hover { background: var(--surface-3); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); box-shadow: none; } .btn.soft:hover { background: #b9f3e8; }
.btn.sm { height: 31px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.icon { width: 38px; padding: 0; } .btn.icon.sm { width: 31px; } .btn.icon.xs { width: 26px; }
.btn svg { width: 17px; height: 17px; flex: none; } .btn.sm svg { width: 15px; height: 15px; } .btn.xs svg { width: 13px; height: 13px; }

/* ---- form controls */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20, 184, 166, .18); }
.input:disabled, .select:disabled { background: var(--surface-3); color: var(--text-3); }
.input.sm, .select.sm { height: 31px; padding: 0 8px; font-size: 13px; border-radius: 7px; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.4; }
.select { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 14px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent-strong); margin: 0; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 999px; background: var(--border-strong); transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch.on { background: var(--accent-strong); } .switch.on::after { transform: translateX(18px); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; } .form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid .span-2 { grid-column: span 1; } }

/* search box */
.search { position: relative; }
.search .input { padding-left: 36px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }

/* ---- surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card.pad { padding: 18px; } .card.pad-sm { padding: 12px 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-body { padding: 16px 18px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ---- badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-soft); color: var(--gray-text); }
.badge.green { background: var(--green-soft); color: var(--green-text); }
.badge.amber { background: var(--amber-soft); color: var(--amber-text); }
.badge.red { background: var(--red-soft); color: var(--red-text); }
.badge.blue { background: var(--blue-soft); color: var(--blue-text); }
.badge.violet { background: var(--violet-soft); color: var(--violet-text); }
.badge.teal { background: var(--accent-soft); color: #0f766e; }
.badge.dark { background: var(--navy-2); color: #fff; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.lg { height: 26px; padding: 0 10px; font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 560; font-size: 13.5px; color: var(--text-2); white-space: nowrap; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: #aab6c6; color: var(--text); }
.chip.on { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.chip .count { font-size: 11.5px; opacity: .7; }

/* ---- stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat .k { font-size: 12.5px; color: var(--text-2); font-weight: 560; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .s { font-size: 12px; color: var(--text-3); }
.stat.accent::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.stat.warn::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--amber); }
.stat.danger::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.stat.info::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.stat.click { cursor: pointer; transition: box-shadow .15s, transform .15s; } .stat.click:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

/* ---- tables */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-weight: 600; font-size: 12px; color: var(--text-2); letter-spacing: .02em; text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f8fafc; }
.table tr.click { cursor: pointer; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .title { font-weight: 600; color: var(--text); }
.table .sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.table.compact td { padding: 6px 10px; } .table.compact th { padding: 8px 10px; }
.table td .input.sm { width: 84px; }

/* ---- bars (dashboard) */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bar .lbl { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s var(--ease); }
.bar .val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 48px; text-align: right; }

/* ---- empty / loading */
.empty { padding: 40px 20px; text-align: center; color: var(--text-3); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty svg { width: 40px; height: 40px; opacity: .5; }
.empty .t { font-weight: 600; color: var(--text-2); font-size: 15px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-strong); border-top-color: var(--accent-strong); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; gap: 10px; color: var(--text-3); }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, #f6f8fb 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- modal, drawer, toast */
.overlay { position: fixed; inset: 0; background: rgba(10, 16, 30, .45); backdrop-filter: blur(2px); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .18s var(--ease); }
.modal.wide { max-width: 860px; } .modal.xl { max-width: 1100px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.drawer-overlay { position: fixed; inset: 0; background: rgba(10, 16, 30, .35); z-index: 55; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 56; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .22s var(--ease); }
.drawer.wide { width: min(760px, 100vw); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-body { padding: 18px 20px; overflow: auto; flex: 1; }
.drawer-foot { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100vw - 24px)); }
.toast { pointer-events: auto; background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; display: flex; gap: 10px; align-items: center; animation: pop .2s var(--ease); max-width: 100%; }
.toast.ok { background: #065f46; } .toast.err { background: #991b1b; } .toast.warn { background: #92400e; }
.toast svg { width: 18px; height: 18px; flex: none; }

/* ---- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { height: 40px; padding: 0 14px; border: 0; background: none; color: var(--text-2); font-weight: 560; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.tab:hover { color: var(--text); } .tab.on { color: var(--accent-strong); border-bottom-color: var(--accent-strong); }
.tab .badge { height: 18px; padding: 0 6px; font-size: 11px; }

/* ---- misc */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert.info { background: var(--blue-soft); border-color: #bfdbfe; color: var(--blue-text); }
.alert.warn { background: var(--amber-soft); border-color: #fde68a; color: var(--amber-text); }
.alert.danger { background: var(--red-soft); border-color: #fecaca; color: var(--red-text); }
.alert.ok { background: var(--green-soft); border-color: #bbf7d0; color: var(--green-text); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.typeahead { position: relative; }
.typeahead .menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 40; max-height: 320px; overflow: auto; }
.typeahead .opt { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.typeahead .opt:last-child { border-bottom: none; }
.typeahead .opt:hover, .typeahead .opt.hl { background: var(--surface-2); }
.qty { font-variant-numeric: tabular-nums; }
.qty .u { color: var(--text-3); font-size: .85em; margin-left: 2px; }
.pill-num { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px; background: var(--surface-3); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; font-size: 13px; color: var(--text-2); }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* new version banner */
.update-banner { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-radius: 12px; background: var(--navy-2); color: #fff; box-shadow: var(--shadow-lg); font-weight: 560; font-size: 14px; max-width: calc(100vw - 32px); }
.update-banner .btn { flex-shrink: 0; }
/* "+ New product" row in the product search */
.typeahead .opt.create { color: var(--accent-strong, #0f766e); font-weight: 600; justify-content: flex-start; }
.typeahead .opt.create .faint { font-weight: 400; }
/* packing list review */
.pl-table td { vertical-align: top; }
.pl-table .input, .pl-table .select { height: 34px; }
.pl-table .num-in { width: 84px; }
.pl-table .src { max-width: 300px; }
.pl-row-check { background: var(--amber-soft); }
.pl-row-skip { opacity: .45; }
.variant-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pl-table td.book .input.sm, .pl-table td.book .select.sm { width: 100%; min-width: 0; }
.pl-table td.book .row > select, .pl-table td.book .row > div { flex: 1 1 0; min-width: 0; }

/* v1.6 */
.text-red { color: var(--red-text); }
table tfoot td { border-top: 2px solid var(--border-strong); font-weight: 600; }
