:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1c2430;
  --muted: #667085;
  --primary: #2453d6;
  --primary-hover: #1b41ad;
  --primary-soft: #eaf0ff;
  --danger: #c4321f;
  --danger-soft: #fdecea;
  --ok: #157f3c;
  --ok-soft: #e6f6ec;
  --warn: #9a6200;
  --warn-soft: #fff4dc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.loading, .empty { padding: 2rem; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: #111a2e; color: #cdd5e3; display: flex; flex-direction: column;
  padding: 1.25rem .9rem; position: sticky; top: 0; height: 100vh;
}
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; padding: 0 .6rem 1.25rem; overflow-wrap: anywhere; }
.brand small { display: block; font-weight: 400; font-size: .75rem; color: #8a96ad; margin-top: .2rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { color: #cdd5e3; padding: .6rem .7rem; border-radius: 8px; }
.sidebar nav a:hover { background: #1c2742; text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.me { border-top: 1px solid #24304a; padding: 1rem .6rem 0; font-size: .85rem; }
.me strong { color: #fff; display: block; }
.me .links { display: flex; gap: .75rem; margin-top: .5rem; }
.me a, .me button { color: #9fb3dd; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
main { padding: 1.75rem 2rem 3rem; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 1.25rem; }
.stack > * + * { margin-top: 1.25rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.kpi .label { color: var(--muted); font-size: .85rem; }
.kpi .value { font-size: 1.6rem; font-weight: 700; margin: .25rem 0; }
.kpi .sub { color: var(--muted); font-size: .8rem; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem .95rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: #f1c4bd; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.link-btn.danger { color: var(--danger); }
.icon-btn { background: none; border: 0; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); padding: .2rem .4rem; }

input, select, textarea {
  font: inherit; color: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid var(--border);
  border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[readonly] { background: #f5f6f8; }
textarea { resize: vertical; min-height: 64px; }
label { display: block; font-size: .85rem; font-weight: 500; color: #344054; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.form-grid { display: grid; gap: .85rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.checkbox input { width: auto; margin: 0; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: .6rem .8rem; border-radius: 8px; margin: .75rem 0 0; font-size: .9rem; }
.hint { color: var(--muted); font-size: .8rem; margin-top: .25rem; font-weight: 400; }

.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; }
.toolbar .checkbox { margin-left: .25rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { border: 0; box-shadow: none; border-radius: 0; margin: 0 -1.25rem -1.1rem; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table td.right, .table th.right { text-align: right; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f8f9fb; }
.table tr.inactive td { color: var(--muted); }
.table .actions { display: flex; gap: .75rem; justify-content: flex-end; white-space: nowrap; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok, .badge.paid { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.unpaid { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.void { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: #eef0f3; color: var(--muted); }
.pos { color: var(--ok); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }

/* ---------- Product photos ---------- */
.thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: contain; flex: none;
  background: #fff; border: 1px solid var(--border); display: inline-grid; place-items: center;
  color: #a0a8b6; font-size: .7rem; font-weight: 600; vertical-align: middle;
}
.thumb.lg { width: 56px; height: 56px; }
.photo-edit { display: flex; gap: 1rem; align-items: center; }
.photo-edit .preview { width: 160px; height: 120px; border-radius: 10px; object-fit: contain; background: #eef0f3; border: 1px solid var(--border); flex: none; display: grid; place-items: center; color: #a0a8b6; font-size: .85rem; }
.photo-edit .btns { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.photo-view { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 8px; }
.cell-product { display: flex; align-items: center; gap: .7rem; }
button.thumb-btn { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 8px; }

/* ---------- Sell ---------- */
.sell { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 1.25rem; align-items: start; }
.product-list { margin-top: .85rem; display: flex; flex-direction: column; max-height: 70vh; overflow-y: auto; }
.product-row { display: flex; align-items: center; gap: .75rem; padding: .7rem .25rem; border-bottom: 1px solid var(--border); }
.product-row:last-child { border-bottom: 0; }
.product-row .info { flex: 1; min-width: 0; }
.product-row .info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-row .price { font-weight: 600; white-space: nowrap; }
.cart { position: sticky; top: 1rem; }
.cart-line { display: grid; grid-template-columns: 1fr 70px auto auto; gap: .5rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.cart-line .name { min-width: 0; }
.cart-line .name strong { display: block; font-size: .92rem; }
.cart-line input { padding: .35rem .4rem; text-align: center; }
.cart-empty { color: var(--muted); padding: 1rem 0; text-align: center; }
.cart fieldset { border: 0; padding: 0; margin: 1rem 0 0; display: grid; gap: .7rem; }
.cart legend { font-weight: 600; font-size: .9rem; margin-bottom: .5rem; padding: 0; }
.totals { margin: 1rem 0; display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; }
.totals .grand { font-size: 1.2rem; font-weight: 700; color: var(--text); }

/* ---------- Invoice document ---------- */
.invoice-doc { max-width: 820px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.5rem; }
.invoice-doc header { display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; margin-bottom: 2rem; }
.invoice-doc .company { font-size: 1.35rem; font-weight: 700; }
.invoice-doc .addr { white-space: pre-line; color: var(--muted); font-size: .9rem; margin-top: .3rem; }
.invoice-doc .title { text-align: right; }
.invoice-doc .title h1 { font-size: 1.8rem; letter-spacing: .08em; color: var(--primary); }
.invoice-doc .meta { display: grid; grid-template-columns: auto auto; gap: .2rem 1rem; justify-content: end; margin-top: .5rem; font-size: .9rem; }
.invoice-doc .meta dt { color: var(--muted); }
.invoice-doc .meta dd { margin: 0; }
.invoice-doc .bill-to { margin-bottom: 1.5rem; }
.invoice-doc .bill-to h3 { font-size: .78rem; text-transform: uppercase; color: var(--muted); margin: 0 0 .3rem; letter-spacing: .05em; }
.invoice-doc .table th { background: #f3f5f8; }
.invoice-doc .sum { display: grid; grid-template-columns: auto auto; gap: .4rem 2.5rem; justify-content: end; margin-top: 1.25rem; }
.invoice-doc .sum dt { color: var(--muted); text-align: right; }
.invoice-doc .sum dd { margin: 0; text-align: right; }
.invoice-doc .sum .grand { font-size: 1.25rem; font-weight: 700; color: var(--text); border-top: 2px solid var(--text); padding-top: .4rem; }
.invoice-doc .notes { margin-top: 2rem; white-space: pre-line; font-size: .9rem; }
.invoice-doc .footer { margin-top: 2.5rem; text-align: center; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.void-stamp { color: var(--danger); border: 3px solid var(--danger); display: inline-block; padding: .2rem .8rem; font-weight: 800; letter-spacing: .15em; transform: rotate(-6deg); margin-top: .5rem; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: 100%; max-width: 380px; }
.login h1 { margin-bottom: .25rem; }
.login p { margin: 0 0 1.25rem; }

/* ---------- Modal & toasts ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 1rem; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 480px; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal > header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal > header h2 { margin: 0; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal > .form-error { margin: 0 1.25rem 1rem; }
.modal > footer { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); }

#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: #111a2e; color: #fff; padding: .75rem 1rem; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 360px; }
.toast.error { background: var(--danger); }

/* ---------- Wholesale: shared bits ---------- */
.center { text-align: center !important; }
.section { margin-top: 1.25rem; }
.kpi.accent { border-color: #c9d6fb; background: linear-gradient(180deg, #f4f7ff, #fff); }
.kpi .value small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.nav-badge { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; background: #e5484d; color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.3rem; margin-left: .25rem; }
.pack-tag { display: inline-block; padding: .1rem .5rem; border-radius: 6px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; vertical-align: middle; }
.pack-tag.ratio { background: #e7efff; color: #1e46b8; }
.pack-tag.mix { background: #fff0e0; color: #a35200; }
.bar { display: inline-block; width: 70px; height: 8px; background: #edf0f4; border-radius: 99px; overflow: hidden; vertical-align: middle; margin-right: .35rem; }
.bar span { display: block; height: 100%; background: var(--ok); }
.table .total-row td, tfoot .total-row td { font-weight: 700; background: #f6f8fb; }
.table td.zero { color: var(--danger); font-weight: 600; }
.addr { white-space: pre-line; }
.input-group { display: flex; gap: .35rem; margin-top: .3rem; }
.input-group input { flex: 1; margin: 0; }
.input-group select { width: 64px; margin: 0; }

/* Tabs and chips */
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .75rem; }
.tab { border: 1px solid var(--border); background: var(--surface); padding: .5rem .9rem; border-radius: 999px; font: inherit; font-weight: 500; cursor: pointer; color: var(--text); }
.tab.active { background: #111a2e; color: #fff; border-color: #111a2e; }
.tab-count { display: inline-block; margin-left: .3rem; font-size: .75rem; opacity: .75; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .75rem; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: .3rem .75rem; border-radius: 999px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--text); }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* Shop bar (which shop the order is for) */
.shop-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; background: #fffbea; border: 1px solid #f3e2a4; border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 1rem; }
.shop-bar select { width: auto; min-width: 220px; font-weight: 600; }
.shop-card { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding-bottom: .9rem; border-bottom: 1px solid var(--border); margin-bottom: .5rem; }

/* Catalog grid */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.pcard.soldout { opacity: .6; }
/* Product photos show front + back side by side, so show the whole picture. */
.pimg { position: relative; aspect-ratio: 4 / 3; background: #fff; border-bottom: 1px solid var(--border); }
.pimg img { width: 100%; height: 100%; object-fit: contain; display: block; padding: .25rem; }
.pimg-btn { padding: 0; border: 0; background: none; width: 100%; height: 100%; cursor: zoom-in; display: block; }
.pimg-ph { height: 100%; display: grid; place-content: center; text-align: center; color: #9aa3b2; font-weight: 700; font-size: 1.2rem; letter-spacing: .05em; text-transform: uppercase; }
.pimg-ph small { font-size: .72rem; font-weight: 500; letter-spacing: 0; text-transform: none; margin-top: .25rem; }
.pimg .pack-tag { position: absolute; top: .6rem; left: .6rem; }
.soldout-tag { position: absolute; top: .6rem; right: .6rem; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 6px; }
.pbody { padding: .8rem .9rem 1rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.pbody h3 { margin: 0; font-size: 1rem; line-height: 1.25; }
.pmeta { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.pcode { font-size: .85rem; color: #344054; }
.pprice { font-size: 1.15rem; font-weight: 700; }
.pprice small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.ratio-row { display: flex; gap: .3rem; flex-wrap: wrap; font-size: .78rem; align-items: center; }
.ratio-row span { background: #f2f4f7; border-radius: 6px; padding: .1rem .4rem; }
.ratio-row span b { margin-right: .2rem; }
.ratio-row span.muted { background: none; }
.stock-line { font-size: .85rem; font-weight: 600; color: var(--ok); }
.stock-line.neg { color: var(--danger); }
.buy { display: flex; gap: .5rem; margin-top: auto; }
.buy .btn { flex: 1; }
.stepper { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.stepper button { border: 0; background: #f5f6f8; width: 2rem; font-size: 1.1rem; cursor: pointer; color: var(--text); }
.stepper button:hover { background: #e9ecf1; }
.stepper input { width: 3rem; border: 0; border-radius: 0; text-align: center; padding: .4rem .2rem; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper.sm button { width: 1.6rem; }
.stepper.sm input { width: 2.6rem; padding: .25rem .1rem; }
.mix-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .3rem; }
.mix-grid label { font-size: .72rem; text-align: center; font-weight: 600; }
.mix-grid label small { font-weight: 400; color: var(--muted); }
.mix-grid label.none { opacity: .45; }
.mix-grid input { padding: .3rem .1rem; text-align: center; margin-top: .15rem; }

/* Cart */
.cart-table td { padding: .5rem .5rem; }
.cart-table .cell-product { min-width: 190px; }
input.rate { width: 80px; text-align: right; padding: .3rem .4rem; }
input.rate.changed { border-color: #e8a33d; background: #fff8ec; }
/* Cart: lines get the full width, order details below in two columns. */
.sell.cart-layout { grid-template-columns: minmax(0, 1fr); }
.cart-layout .cart { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1.5rem; align-items: start; }
.cart-layout .cart > h2, .cart-layout .cart > .totals, .cart-layout .cart > .form-error, .cart-layout .cart > button[type=submit] { grid-column: 1 / -1; }
.cart-layout .cart fieldset { margin: 0; }
.cart-layout .cart .totals { max-width: 420px; margin-left: auto; width: 100%; }
@media (max-width: 820px) { .cart-layout .cart { grid-template-columns: minmax(0, 1fr); } }
.rate-box { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.off-box { display: inline-flex; align-items: center; gap: .2rem; font-size: .75rem; color: var(--muted); white-space: nowrap; }
input.off { width: 48px; padding: .2rem .3rem; text-align: right; font-size: .8rem; }
.disc-chips { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .35rem; }
.disc-chips .chip { padding: .2rem .6rem; font-size: .8rem; }
.cart-foot { padding-top: .75rem; }
.cart-empty { padding: 2rem 0; text-align: center; color: var(--muted); }

/* Warehouse */
.inv-table th, .inv-table td { padding: .55rem .6rem; }
.size-inputs { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.size-inputs label { text-align: center; }
.size-now { display: flex; gap: .4rem; flex-wrap: wrap; }
.size-now span { background: #f2f4f7; border-radius: 6px; padding: .2rem .55rem; font-size: .88rem; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.preview-table { max-height: 300px; overflow: auto; }

/* Order document (wholesale order / invoice) */
.order-doc { max-width: 980px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem 2.25rem; font-size: .88rem; position: relative; }
.od-brand { text-align: center; font-size: 1.6rem; font-weight: 800; letter-spacing: .25em; margin-bottom: 1rem; }
.od-top { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid #222; padding-bottom: .5rem; }
.od-top span { padding: 0 .9rem; border-right: 1px solid #bbb; }
.od-top span:first-child { padding-left: 0; }
.od-top span:last-child { border-right: 0; }
.od-grid { display: grid; border-bottom: 1px solid #222; }
.od-grid.four { grid-template-columns: repeat(4, 1fr); }
.od-grid.five { grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr; }
.od-grid.three { grid-template-columns: 1.2fr 1.2fr .8fr; }
.od-grid > div { padding: .75rem .75rem .75rem 0; border-right: 1px solid #bbb; min-height: 60px; }
.od-grid > div + div { padding-left: .75rem; }
.od-grid > div:last-child { border-right: 0; }
.od-grid h4 { margin: 0 0 .35rem; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.od-grid p { margin: 0 0 .15rem; }
.od-grid .big { font-size: 1rem; margin-bottom: .5rem; }
.od-lines { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.od-lines th { font-size: .7rem; text-transform: uppercase; text-align: left; padding: .4rem .45rem; border-bottom: 1px solid #222; }
.od-lines td { padding: .45rem; border: 1px solid #d0d4da; vertical-align: middle; }
.od-lines td.apack { background: #f3f4f6; font-weight: 600; }
.od-lines .od-img { width: 58px; padding: 2px; }
.od-lines .od-img { width: 96px; }
.od-lines .od-img img { width: 92px; height: 50px; object-fit: contain; display: block; }
.od-lines .price { color: #c0392b; font-weight: 600; }
.od-foot { display: flex; justify-content: space-between; gap: 2rem; margin-top: 1.25rem; flex-wrap: wrap; }
.od-sign { border: 1px solid #bbb; padding: .75rem 1rem; width: 320px; font-size: .75rem; }
.od-sign .sign-line { margin-top: 2.5rem; border-top: 1px solid #222; padding-top: .2rem; }
.od-sum { display: grid; grid-template-columns: auto auto; gap: .35rem 2rem; margin: 0; align-content: start; border: 1px solid #bbb; padding: .75rem 1rem; }
.od-sum dt { color: var(--muted); }
.od-sum dd { margin: 0; text-align: right; font-weight: 600; }
.od-sum .grand { font-size: 1.1rem; color: var(--text); font-weight: 800; }
.order-doc .footer { margin-top: 1.5rem; text-align: center; color: var(--muted); }
.order-doc .void-stamp { position: absolute; top: 5rem; right: 2rem; }

/* ---------- Factory vs Sales interfaces ---------- */
.nav-section { margin: 1rem .7rem .3rem; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #6f7c96; }
body.ui-factory .brand small { color: #f5b942; letter-spacing: .15em; font-weight: 700; }

body.ui-sales { --primary: #0f766e; --primary-hover: #0b5c56; --primary-soft: #e3f4f2; }
.sales-shell { min-height: 100vh; display: flex; flex-direction: column; }
.sales-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.5rem; background: #0b3b38; color: #d4ece9; }
.sales-top .brand { padding: 0; color: #fff; font-size: 1.05rem; }
.sales-top .brand small { color: #7fd8cd; letter-spacing: .15em; font-weight: 700; }
.sales-tabs { display: flex; gap: .25rem; flex: 1; }
.sales-tabs a { color: #cfe7e4; padding: .5rem .8rem; border-radius: 8px; display: flex; align-items: center; gap: .4rem; position: relative; }
.sales-tabs a:hover { background: #12514c; text-decoration: none; color: #fff; }
.sales-tabs a.active { background: #fff; color: #0b3b38; font-weight: 600; }
.sales-tabs .ico { font-size: 1rem; }
.sales-me { display: flex; gap: .9rem; align-items: center; font-size: .88rem; }
.sales-me a, .sales-me .link-btn { color: #bfe6e1; }
.sales-shell main { flex: 1; max-width: 1300px; width: 100%; margin: 0 auto; }

/* ---------- Brand tagline ("BY US INDUSTRIES") ---------- */
.brand .brand-tag { display: block; font-size: .62rem; font-weight: 600; letter-spacing: .14em; color: #aab6cc; margin-top: .1rem; }
.sales-top .brand .brand-tag { color: #9fd9d1; }
.login-tag { font-size: .72rem; font-weight: 700; letter-spacing: .2em; color: var(--muted); margin: .15rem 0 .6rem; }
.od-brand .brand-tag { font-size: .7rem; font-weight: 700; letter-spacing: .3em; color: #555; margin-top: .2rem; }
.od-brand-left { text-align: left; }

/* ---------- Warehouses, packing list, install ---------- */
.wh-select { width: auto; font-weight: 600; }
h1 .wh-select { font-size: 1.1rem; padding: .3rem .6rem; margin-left: .25rem; vertical-align: middle; }
.shop-bar .ship-from { margin-left: .5rem; }
.btn.whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn.whatsapp:hover { background: #1eb457; }
.packing-doc .pk-title { text-align: center; letter-spacing: .2em; margin: -.5rem 0 1rem; font-size: 1.1rem; }
.tick-box { display: inline-block; width: 18px; height: 18px; border: 2px solid #444; border-radius: 3px; }
.install-card { display: flex; gap: 1rem; align-items: center; justify-content: space-between; background: #f0faf8; border-color: #b7e0da; }
.install-link { background: #12514c; padding: .25rem .6rem; border-radius: 6px; color: #fff !important; }
ol.steps { margin: 0; padding-left: 1.2rem; line-height: 1.9; }
@media (max-width: 820px) {
  .install-card { flex-direction: column; align-items: stretch; }
  .sales-me .install-link { font-size: .78rem; }
  .shop-bar .ship-from { margin-left: 0; }
}

/* ---------- Notifications ---------- */
.notif-list { padding: 0; overflow: hidden; }
.notif { display: flex; gap: .8rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); color: var(--text); }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: #f8f9fb; text-decoration: none; }
.notif.unread { background: #fff7e6; }
.notif-ico { width: 2rem; height: 2rem; border-radius: 50%; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; flex: none; font-weight: 700; }
.notif-body { display: flex; flex-direction: column; gap: .2rem; }

/* ---------- Ledger ---------- */
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.ledger-head { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }
.ledger-balance { text-align: right; border-radius: 12px; padding: .9rem 1.2rem; min-width: 220px; }
.ledger-balance span { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.ledger-balance b { display: block; font-size: 2rem; }
.ledger-balance small { color: var(--muted); }
.ledger-balance.due { background: var(--danger-soft); color: var(--danger); }
.ledger-balance.clear { background: var(--ok-soft); color: var(--ok); }
.ledger-table tr.payment td { background: #f6fbf8; }
tr.voided td { text-decoration: line-through; color: var(--muted) !important; background: #fafafa !important; }
tr.voided td .neg { text-decoration: none; }
.voided { text-decoration: line-through; color: var(--muted); }
.value.neg, .value .neg { color: var(--danger); }
.value.pos, .value .pos { color: var(--ok); }
.print-only { display: none; }
.pay-now { border: 1px dashed #b7d9d4 !important; border-radius: 10px; padding: .75rem !important; background: #f6fbfa; }
.od-payments { margin-top: 1rem; font-size: .85rem; border-top: 1px dashed #bbb; padding-top: .6rem; }
.od-payments h4 { margin: 0 0 .3rem; font-size: .72rem; text-transform: uppercase; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .sell { grid-template-columns: minmax(0, 1fr); }
  .cart { position: static; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { min-width: 0; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .product-row { flex-wrap: wrap; }
  .product-row .info { flex: 1 1 calc(100% - 72px); }
  .product-row .badge { margin-left: 68px; margin-right: auto; }
  .cart-line { grid-template-columns: minmax(0, 1fr) 60px auto auto; }
  .sidebar { position: static; height: auto; padding: .75rem 1rem; }
  .brand { padding: 0 0 .5rem; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; }
  .me { display: flex; justify-content: space-between; align-items: center; padding: .6rem 0 0; margin-top: .5rem; }
  .me .links { margin: 0; }
  main { padding: 1rem; }
  .invoice-doc { padding: 1.25rem; }
  .invoice-doc .title { text-align: left; }
  .invoice-doc .meta { justify-content: start; }
  .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .pbody { padding: .6rem; }
  .buy { flex-direction: column; }
  .stepper { align-self: flex-start; }
  .mix-grid { grid-template-columns: repeat(3, 1fr); }
  .shop-bar select { min-width: 0; flex: 1; }
  .order-doc { padding: 1rem; overflow-x: auto; }
  .od-grid.four, .od-grid.five, .od-grid.three { grid-template-columns: 1fr 1fr; }
  .od-grid > div { border-right: 0; padding-left: 0 !important; }
}
@media (max-width: 820px) {
  /* Sales app on a phone: tabs move to the bottom like a shopping app. */
  .sales-top { padding: .55rem 1rem; gap: .5rem; justify-content: space-between; }
  .sales-tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #0b3b38; justify-content: space-around; padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom)); gap: 0; }
  .sales-tabs a { flex-direction: column; gap: .1rem; font-size: .7rem; padding: .35rem .4rem; flex: 1; text-align: center; }
  .sales-tabs .ico { font-size: 1.15rem; }
  .sales-tabs .nav-badge { position: absolute; top: 0; right: 18%; margin: 0; }
  .sales-shell main { padding-bottom: 5.5rem; }
  .kpis-3 { grid-template-columns: 1fr; }
  .ledger-balance { text-align: left; width: 100%; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
  .shop-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Print (invoices) ---------- */
@media print {
  body { background: #fff; }
  .no-print, .sidebar, #toasts { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
  .invoice-doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .invoice-doc .title { text-align: right; }
  .invoice-doc .meta { justify-content: end; }
  .order-doc { border: 0; box-shadow: none; padding: 0; max-width: none; font-size: 10pt; }
  .od-grid.four { grid-template-columns: repeat(4, 1fr); }
  .od-grid.five { grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr; }
  .od-grid.three { grid-template-columns: 1.2fr 1.2fr .8fr; }
  .od-lines tr { break-inside: avoid; }
  .sales-top, .sales-tabs { display: none !important; }
  .print-only { display: block; }
  .ledger-doc .card { border: 0; box-shadow: none; padding: 0; }
  .ledger-doc .kpis { grid-template-columns: repeat(3, 1fr); }
  .badge { border: 1px solid currentColor; }
}
