/* Sales Portal — stylesheet */
:root {
  --brand: #e71b23;
  --brand-dk: #b8121a;
  --brand-tint: #fdecec;
  --navy: #161c2c;
  --navy-2: #232b40;
  --ink: #1b2130;
  --ink-2: #5b6270;
  --ink-3: #8a90a0;
  --line: #e4e6ea;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ok: #1f8a4c;
  --ok-tint: #e7f5ec;
  --warn: #b86e00;
  --warn-tint: #fff3df;
  --bad: #c62828;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --side: 248px;
  --shadow: 0 1px 2px rgba(22, 28, 44, .06), 0 4px 14px rgba(22, 28, 44, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dk); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: .88em; }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
.r { text-align: right; }
.hide { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--navy); color: #cfd4e0;
  display: flex; flex-direction: column; z-index: 40; transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand-mark.lg { width: 48px; height: 48px; font-size: 24px; border-radius: 12px; }
.brand-name { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.sidebar nav { flex: 1; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
  color: #cfd4e0; text-decoration: none; font-weight: 500; position: relative;
}
.sidebar nav a:hover { background: var(--navy-2); color: #fff; }
.sidebar nav a.active { background: var(--navy-2); color: #fff; }
.sidebar nav a.active::before {
  content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.sidebar nav a svg { opacity: .8; }
.sidebar nav a .badge { margin-left: auto; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--navy-2); }
.side-user .who { min-width: 0; flex: 1; }
.side-user strong { display: block; color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user small { color: #9aa2b5; font-size: 12px; }
.logout { color: #9aa2b5; padding: 6px; border-radius: 6px; }
.logout:hover { color: #fff; background: var(--navy-2); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-dk);
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.side-user .avatar { background: var(--brand); color: #fff; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; font-style: normal;
}

.has-nav .main { margin-left: var(--side); }
.main { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: rgba(244, 245, 247, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; font-weight: 700; flex: 1; }
.menu-btn { display: none; }
.top-cart { position: relative; color: var(--ink); padding: 8px; border-radius: 8px; }
.top-cart:hover { background: #e9ebef; }
.top-cart .badge { position: absolute; top: -2px; right: -4px; }
.page { padding: 24px 28px 48px; max-width: 1280px; }
.scrim { display: none; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dk); }
.btn.primary:disabled { background: #e9a4a7; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: #c8ccd4; background: #fafbfc; }
.btn.danger { color: var(--bad); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 48px; font-size: 16px; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font: inherit; font-size: 18px;
}
.icon-btn:hover { background: #f4f5f7; }
.icon-btn.danger { color: var(--bad); }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.end { justify-content: flex-end; margin-top: 18px; }
.grow { flex: 1; }

input[type=text], input[type=number], input[type=search], input[type=password], input:not([type]) {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font: inherit; color: var(--ink); background: #fff;
}
input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(231, 27, 35, .12); }
input.invalid { border-color: var(--bad); background: #fff6f6; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }

/* ---------- flash / toast / notes ---------- */
.flashes { padding: 0 28px; max-width: 1280px; }
.flashes:empty { display: none; }
.flashes .flash { margin-top: 16px; }
.flash { padding: 11px 14px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: 14px; border: 1px solid; transition: opacity .4s; }
.flash.sm { font-size: 13px; padding: 8px 10px; }
.flash-error { background: #fdf0f0; border-color: #f3c9ca; color: #8c1d1d; }
.flash-success { background: var(--ok-tint); border-color: #bfe3cc; color: #145c33; }
.flash-info { background: #eef3fb; border-color: #cfdcf2; color: #1d3b6b; }
.flash.fade { opacity: 0; pointer-events: none; }
.note { background: #fff; border: 1px dashed #c8ccd4; border-radius: var(--r); padding: 12px 16px; margin-bottom: 18px; }
.empty { color: var(--ink-2); padding: 24px 0; text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; padding: 12px 18px;
  border-radius: 10px; background: var(--navy); color: #fff; font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.toast.err { background: var(--bad); }
.loading { padding: 24px 0; color: var(--ink-2); display: flex; align-items: center; gap: 10px; }
.loading::before {
  content: ''; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(22, 28, 44, .45); z-index: 80; display: grid; place-items: center; padding: 16px; }
.modal-box {
  position: relative; background: #fff; border-radius: var(--r-lg); width: 100%; max-width: 460px; max-height: 88vh;
  overflow-y: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); transform: translateY(8px); transition: transform .18s ease;
}
.modal.show .modal-box { transform: none; }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 4px 8px; }
.modal-body h3 { font-size: 19px; margin-bottom: 4px; padding-right: 24px; }
.modal-body .sub { font-size: 14px; margin: 18px 0 10px; }
.modal-body p { margin: 6px 0; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(180deg, var(--navy) 0 38%, var(--bg) 38%); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: var(--r-lg); padding: 32px; box-shadow: 0 20px 60px rgba(22,28,44,.18); }
.auth-head { margin-bottom: 22px; }
.auth-head h2 { font-size: 26px; margin: 16px 0 6px; }
.auth-head p { color: var(--ink-2); margin: 0; }
.role-switch { display: grid; grid-template-columns: 1fr 1fr; background: #f0f1f4; border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.role-switch label { position: relative; }
.role-switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.role-switch span { display: block; text-align: center; padding: 9px 8px; border-radius: 7px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.role-switch input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.role-switch input:focus-visible + span { outline: 2px solid var(--brand); }
.pw { position: relative; }
.pw input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 6px; height: 28px; border: 0; background: #f0f1f4; border-radius: 5px; font: inherit; font-size: 12px; font-weight: 600; padding: 0 10px; cursor: pointer; }
.muted-link { display: block; text-align: center; margin-top: 16px; color: var(--ink-2); font-size: 13px; }

/* ---------- dashboard ---------- */
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.hello-sub { margin: 0; color: var(--ink-2); }
.hello h2 { font-size: 28px; font-weight: 800; }
.target-band {
  display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 28px; background: var(--navy); color: #fff;
  border-radius: var(--r-lg); padding: 26px 28px; margin-bottom: 18px;
}
.target-band .lbl { color: #9aa2b5; font-size: 13px; font-weight: 500; }
.target-main .big { font-size: 64px; font-weight: 800; line-height: 1; margin: 10px 0 16px; font-variant-numeric: tabular-nums; }
.target-main .big small { font-size: 28px; color: #9aa2b5; margin-left: 2px; }
.meter { height: 8px; background: var(--navy-2); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.target-cells { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--navy-2); border-radius: var(--r); overflow: hidden; align-self: stretch; }
.target-cells .cell { background: var(--navy); padding: 6px 18px; display: flex; flex-direction: column; justify-content: center; }
.target-cells strong { font-size: 26px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.target-cells small { color: #7d869b; font-size: 12px; }
.target-cells .ok strong { color: #6fdc9b; }
.target-cells .warn strong { color: #ffb74d; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.stat .lbl, .cust-strip .lbl { display: block; color: var(--ink-2); font-size: 13px; }
.stat strong { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; margin-bottom: 18px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 18px; }
.grid-2 .panel { margin-bottom: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-head h3 { font-size: 16px; }
.link { font-weight: 600; font-size: 14px; text-decoration: none; }
.chart-box { position: relative; height: 340px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.compact td { padding: 8px 10px; }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.sm { padding: 1px 8px; font-size: 11px; }
.st-pending { background: var(--warn-tint); color: var(--warn); }
.st-invoiced { background: var(--ok-tint); color: var(--ok); }
.st-cancel { background: #f1f2f4; color: #6b7280; text-decoration: line-through; }

/* ---------- toolbar / tabs ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; }
.search svg { position: absolute; left: 12px; top: 10px; color: var(--ink-3); width: 20px; }
.search input { padding-left: 40px; height: 42px; }
.count { color: var(--ink-2); font-size: 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; user-select: none; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 18px; padding-bottom: 2px; }
.tab {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  text-decoration: none; font: inherit; font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer;
}
.tab small { color: var(--ink-3); font-weight: 500; }
.tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab.active small { color: #b8bdc9; }
.result-meta { color: var(--ink-2); font-size: 13px; margin: 0 0 10px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 24px; color: var(--ink-2); font-size: 14px; }

/* ---------- customers ---------- */
.cust-list { display: grid; gap: 8px; }
.cust {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 16px; font: inherit; color: inherit; cursor: pointer;
}
.cust:hover { border-color: #c8ccd4; }
.cust.is-selected { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.cust-main { flex: 1; min-width: 0; }
.cust-main strong { display: block; }
.cust-main small { color: var(--ink-2); }
.brands { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; font-style: normal; }
.chip.on { background: var(--ok-tint); color: var(--ok); }
.chip.off { background: #f1f2f4; color: var(--ink-3); text-decoration: line-through; }
.chev { color: var(--ink-3); }
.aging { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.age { border-radius: var(--r-sm); padding: 10px 12px; border: 1px solid var(--line); border-left-width: 4px; }
.age span { display: block; font-size: 12px; color: var(--ink-2); }
.age strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.age.ok { border-left-color: var(--ok); }
.age.mid { border-left-color: #d4a017; }
.age.warn { border-left-color: #e0701c; }
.age.bad { border-left-color: var(--bad); }
.aging-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.aging-total strong { font-size: 20px; }

/* ---------- products ---------- */
.cust-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--r); padding: 12px 16px; margin-bottom: 16px;
}
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.pcard {
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; transition: border-color .15s;
}
.pcard:hover { border-color: var(--brand); }
.pimg { aspect-ratio: 4 / 3; background: #f6f7f9; display: grid; place-items: center; overflow: hidden; }
.pimg img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.noimg { color: var(--ink-3); font-size: 13px; font-style: normal; }
.pinfo { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid #f0f1f4; }
.pcode { font-size: 15px; font-weight: 700; word-break: break-word; }
.pprice { font-size: 17px; font-weight: 700; color: var(--brand-dk); font-variant-numeric: tabular-nums; }
.qty-dlg { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.qty-dlg img { width: 84px; height: 84px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #f6f7f9; }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; }
.stepper input { text-align: center; font-size: 18px; font-weight: 700; height: 44px; }
.stepper .icon-btn { width: 44px; height: 44px; }

/* ---------- cart ---------- */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.cart-items { display: grid; gap: 10px; }
.citem {
  display: grid; grid-template-columns: 64px 1fr auto; grid-template-areas: 'img head rm' 'fields fields fields';
  gap: 10px 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px;
}
.cimg { grid-area: img; width: 64px; height: 64px; border-radius: 8px; background: #f6f7f9; overflow: hidden; }
.cimg img { width: 100%; height: 100%; object-fit: contain; }
.chead { grid-area: head; display: flex; flex-direction: column; min-width: 0; }
.cremove { grid-area: rm; }
.cfields { grid-area: fields; display: grid; grid-template-columns: 100px 1fr 1fr 1fr; gap: 10px; }
.mini > span { display: block; font-size: 12px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.mini input { height: 38px; font-variant-numeric: tabular-nums; }
.mini.ro output { display: flex; align-items: center; height: 38px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini.ro .disc { display: block; margin-top: -6px; color: var(--ok); font-size: 12px; }
.mini.wide { grid-column: 1 / -1; }
.summary { position: sticky; top: 80px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.summary h3 { font-size: 17px; margin-bottom: 14px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; font-size: 14px; }
.sum-row strong { font-variant-numeric: tabular-nums; }
.sum-row em { font-style: normal; color: var(--ink-2); font-size: 12px; }
.sum-row.foc input { width: 130px; text-align: right; }
.sum-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; font-size: 17px; }
.sum-row.total strong { font-size: 22px; font-weight: 800; }
.sum-row.term { align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 4px; }
.term-btn {
  text-align: right; border: 1px solid var(--line); background: #fafbfc; border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; color: inherit;
}
.term-btn:hover { border-color: var(--brand); }
.term-btn strong, .term-btn small { display: block; }
.term-btn small { color: var(--ok); font-size: 12px; }
.sum-hint { font-size: 12px; color: var(--ink-3); margin: 4px 0 14px; }
.summary .btn + .btn { margin-top: 8px; }
.radio-list { display: grid; gap: 6px; margin-top: 14px; max-height: 50vh; overflow-y: auto; }
.radio-row { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.radio-row:has(input:checked) { border-color: var(--brand); background: #fff8f8; }
.radio-row input { accent-color: var(--brand); width: 18px; height: 18px; }
.radio-row span { flex: 1; font-weight: 500; }
.empty-state { text-align: center; padding: 70px 20px; }
.empty-state svg { width: 56px; height: 56px; color: var(--ink-3); }
.empty-state h2 { margin: 14px 0 6px; }
.empty-state p { color: var(--ink-2); margin: 0 0 18px; }

/* ---------- orders ---------- */
.order-list { display: grid; gap: 14px; }
.order { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.order-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; flex-wrap: wrap; }
.order-head h3 { font-size: 17px; }
.order-head p { margin: 3px 0 0; font-size: 14px; }
.order-right { display: flex; align-items: center; gap: 12px; }
.order-total { font-size: 19px; font-variant-numeric: tabular-nums; }
.order-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.order-foot:empty { display: none; }
.inv-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.inv-list li { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .cart-layout { grid-template-columns: 1fr; }
  .summary { position: static; }
  .target-band { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .has-nav .main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
  .menu-btn { display: inline-grid; }
  .page { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .flashes { padding: 0 16px; }
  .pgrid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .target-cells { grid-template-columns: 1fr; }
  .target-cells .cell { padding: 12px 16px; }
  .target-main .big { font-size: 52px; }
  .cfields { grid-template-columns: 1fr 1fr; }
  .pgrid { gap: 10px; }
  .pinfo { padding: 10px; }
  .pprice { font-size: 15px; }
  .hello h2 { font-size: 22px; }
  .chart-box { height: 300px; }
  .aging { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- print (single order) ---------- */
@media print {
  .sidebar, .topbar, .toolbar, .tabs, .flashes, .no-print, .toast, .modal { display: none !important; }
  .has-nav .main { margin: 0; }
  body { background: #fff; }
  body.printing-one .order:not(.print-me) { display: none !important; }
  .order { border: 0; padding: 0; }
  .pill { border: 1px solid #999; }
}

/* debug page */
.dbg { background: #f6f7f9; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 12px; line-height: 1.45; margin: 0 0 10px; white-space: pre-wrap; word-break: break-word; }
details summary { cursor: pointer; font-size: 13px; margin-bottom: 6px; }

/* company logo */
.brand { margin: 14px 14px 10px; padding: 12px 14px; background: #fff; border-radius: var(--r); justify-content: center; text-decoration: none; }
.brand-logo { display: block; width: 100%; max-width: 190px; height: auto; }
.auth-logo { display: block; width: 100%; max-width: 240px; height: auto; margin: 0 auto 4px; }
.auth-head { text-align: center; }
.hello { align-items: center; }
.hello-logo { width: 150px; height: auto; flex: none; padding-right: 20px; border-right: 1px solid var(--line); }
.hello-text { flex: 1; min-width: 0; }
@media (max-width: 640px) {
  .hello-logo { width: 110px; padding-right: 14px; }
}
/* on desktop the sidebar already shows the logo; show it in the dashboard header on mobile/tablet */
@media (min-width: 901px) { .hello-logo { display: none; } }
@media (max-width: 900px) {
  .hello-logo { width: 150px; border: 0; padding: 0; margin-right: calc(100% - 150px); }
}
@media (max-width: 640px) {
  .hello .btn { width: 100%; }
}
/* menu button only when the sidebar is hidden */
.topbar .menu-btn { display: none; }
@media (max-width: 900px) { .topbar .menu-btn { display: inline-grid; } }

/* developer credit + version */
.credit { margin: 0; font-size: 12px; line-height: 1.5; }
.credit span { display: block; }
.side-credit { padding: 10px 16px 14px; color: #7d869b; border-top: 1px solid var(--navy-2); }
.side-credit strong { color: #cfd4e0; font-weight: 600; }
.auth-wrap { grid-template-rows: 1fr auto; }
.auth-wrap .auth-card { align-self: center; }
.auth-credit { text-align: center; color: var(--ink-3); padding-top: 20px; }
.auth-credit strong { color: var(--ink-2); font-weight: 600; }
.auth-credit span { display: inline; margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--line); }
@media print { .credit { display: none; } }

/* ---------- compact product cards ---------- */
.pgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pcard { border-radius: 8px; }
.pimg { aspect-ratio: auto; height: 110px; }
.pimg img { padding: 6px; }
.pimg.is-empty { background: #f6f7f9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23c3c7cf'%3E%3Cpath d='M21 19V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2zM8.5 13.5l2.5 3 3.5-4.5 4.5 6H5z'/%3E%3C/svg%3E") center / 34px no-repeat; }
.pinfo { padding: 8px 10px 10px; gap: 0; }
.pcode { font-size: 13px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.pprice { font-size: 14px; margin-top: 2px; }
.pinfo small { font-size: 11px; }
@media (max-width: 900px) { .pgrid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; } }
@media (max-width: 640px) {
  .pgrid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .pimg { height: 80px; }
  .pinfo { padding: 6px 7px 8px; }
  .pcode { font-size: 12px; }
  .pprice { font-size: 12px; }
}
