/* ═══════════════════════════════════════════════════════════
   StationeryCo Catalog — Improved Responsive CSS
   ═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --amb: #BA7517;
  --amb-lt: #FAEEDA;
  --amb-dk: #633806;
  --grn: #0F6E56;
  --grn-lt: #E1F5EE;
  --bg: #ffffff;
  --bg2: #f5f4f1;
  --bg3: #eeedea;
  --text: #1a1a18;
  --text2: #5f5e5a;
  --text3: #888780;
  --border: rgba(0,0,0,0.12);
  --border2: rgba(0,0,0,0.22);
  --danger: #A32D2D;
  --danger-bg: #FCEBEB;
  --radius: 8px;
  --radius-lg: 12px;
  /* Sidebar width token — easy to change */
  --sb-w: 218px;
}

[data-theme="dark"] {
  --amb-lt: #3a2a10;
  --amb-dk: #F2C47A;
  --grn-lt: #0d2a22;
  --bg:    #121212;
  --bg2:   #1a1a1a;
  --bg3:   #242424;
  --text:  #e8e7e4;
  --text2: #a8a7a2;
  --text3: #6d6c67;
  --border:  rgba(255,255,255,0.10);
  --border2: rgba(255,255,255,0.20);
  --danger-bg: #3a1515;
}

/* ── Theme toggle ───────────────────────────────────────── */
.theme-toggle {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text2);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }

.sb-theme {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sb-theme-lbl { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Base ───────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */
.sb {
  width: var(--sb-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 200ms ease;
}

.sb-top {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-mark { display: flex; align-items: center; gap: 10px; }
.sb-icon {
  width: 28px; height: 28px;
  background: var(--amb);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-icon svg { width: 14px; height: 14px; stroke: #fff; fill: none; stroke-width: 1.8; }
.sb-name { font-size: 13px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.sb-sub { font-size: 11px; color: var(--text3); margin-top: 3px; margin-left: 38px; }

.nav-grp { padding: 5px 0; }
.nav-grp + .nav-grp { border-top: 1px solid var(--border); }
.nav-lbl {
  font-size: 10px; color: var(--text3);
  padding: 7px 14px 2px;
  letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 14px;
  font-size: 12.5px; color: var(--text2);
  cursor: pointer;
  border-left: 2.5px solid transparent;
  text-decoration: none;
  user-select: none;
  transition: background 100ms, color 100ms;
  min-height: 36px;
}
.nav-item:hover { background: var(--bg2); color: var(--text); }
.nav-item.active {
  color: var(--amb);
  border-left-color: var(--amb);
  background: var(--amb-lt);
  font-weight: 600;
}
.nav-item svg { width: 13px; height: 13px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.6; }
.nav-badge {
  margin-left: auto; font-size: 10px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 100px; padding: 1px 6px; color: var(--text3);
  flex-shrink: 0;
}
.nav-item.active .nav-badge { background: var(--amb-lt); border-color: var(--amb); color: var(--amb-dk); }

/* ── Sidebar user area ──────────────────────────────────── */
.sb-user { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.sb-user-avatar {
  width: 28px; height: 28px;
  background: var(--amb); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: 10px; color: var(--text3); text-transform: capitalize; margin-top: 1px; }
.sb-signout {
  background: none; border: none; cursor: pointer;
  color: var(--text3); padding: 5px; border-radius: var(--radius);
  display: flex; align-items: center; flex-shrink: 0;
  transition: color 120ms, background 120ms;
}
.sb-signout:hover { color: var(--danger); background: var(--danger-bg); }

/* ── Hamburger (mobile only) ────────────────────────────── */
.mob-hamburger {
  display: none;
  align-items: center; justify-content: center;
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius);
  width: 36px; height: 36px;
  flex-shrink: 0;
  user-select: none;
  transition: background 120ms;
}
.mob-hamburger:active { background: var(--bg3); }

/* ── Overlay ────────────────────────────────────────────── */
.mob-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.38);
  z-index: 190;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.mob-overlay.open { display: block; }

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════════════════ */
.mn { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-shrink: 0;
  min-height: 52px;
}
.topbar-title { font-size: 14px; font-weight: 600; white-space: nowrap; }
.topbar-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── Content ────────────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 16px 20px; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
  font-size: 12px; padding: 5px 13px; height: 32px;
  cursor: pointer; border-radius: var(--radius);
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 500; white-space: nowrap;
  font-family: inherit;
  border: none;
  transition: background 120ms, color 120ms, border-color 120ms, opacity 120ms;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--amb); color: #fff; }
.btn-primary:not(:disabled):hover { background: #9d6011; }
.btn-secondary { background: var(--bg); border: 1px solid var(--border2); color: var(--text2); }
.btn-secondary:not(:disabled):hover { background: var(--bg2); color: var(--text); }
.btn-danger {
  background: transparent; border: 1px solid var(--border);
  color: var(--danger); font-size: 11px; height: 24px;
  padding: 0 8px; cursor: pointer; border-radius: var(--radius); font-family: inherit;
  display: inline-flex; align-items: center; transition: background 120ms;
}
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { height: 27px; padding: 3px 10px; font-size: 11px; }

/* ═══════════════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════════════ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.stat {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
}
.stat-n { font-size: 24px; font-weight: 700; line-height: 1; color: var(--text); }
.stat-l { font-size: 10px; color: var(--text3); margin-top: 5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════
   QUICK-ADD BAR
   ═══════════════════════════════════════════════════════════ */
.qa-bar {
  display: flex; gap: 7px; align-items: center;
  padding: 8px 10px; margin-bottom: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.qa-hint { font-size: 11px; color: var(--text3); white-space: nowrap; font-weight: 600; }
.qa-bar input { flex: 1; min-width: 0; }

/* ═══════════════════════════════════════════════════════════
   FILTER ROW
   ═══════════════════════════════════════════════════════════ */
.filter-row {
  display: flex; gap: 7px; margin-bottom: 10px; flex-wrap: wrap; align-items: center;
}
.filter-row input { flex: 2 1 220px; min-width: 160px; }
.filter-row select { flex: 1 1 140px; min-width: 120px; }
#sort-bar { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════════════════════ */
input[type=text], input[type=number], input[type=email],
input[type=password], input[type=search], select, textarea {
  font-size: 13px; padding: 6px 9px; height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--bg2); color: var(--text);
  font-family: inherit; width: 100%;
  transition: border-color 120ms, box-shadow 120ms;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--amb);
  box-shadow: 0 0 0 3px rgba(186,117,23,.14);
}
textarea { height: auto; min-height: 56px; resize: vertical; }
select { cursor: pointer; }
input::placeholder { color: var(--text3); }

/* ═══════════════════════════════════════════════════════════
   TABLE
   ═══════════════════════════════════════════════════════════ */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  background: var(--bg2); font-weight: 600; font-size: 10px;
  color: var(--text3); text-align: left; padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg2); }
tr.expanded td { background: var(--bg2); }
.sku-mono { font-family: 'Courier New', monospace; font-size: 10px; color: var(--text3); }
.cat-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 100px;
  background: var(--amb-lt); color: var(--amb-dk); font-weight: 600; display: inline-block;
  white-space: nowrap;
}
.enc-price { font-family: 'Courier New', monospace; font-size: 11px; color: var(--text2); }
.chev {
  font-size: 9px; display: inline-block;
  transition: transform .15s ease; color: var(--text3);
}
.chev.open { transform: rotate(90deg); }

/* ── Expand row ─────────────────────────────────────────── */
.expand-row td { padding: 14px 14px 14px 38px; background: var(--bg2); }
.expand-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.expand-sec h4 {
  font-size: 10px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 9px;
}
.spec-line {
  display: flex; justify-content: space-between; font-size: 11px;
  padding: 4px 0; border-bottom: 1px solid var(--border);
}
.spec-line:last-child { border-bottom: none; }
.spec-k { color: var(--text2); }
.spec-v { font-weight: 500; }

/* ── Pack sizes mini table ──────────────────────────────── */
.ps-mini { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.ps-mini th {
  font-size: 10px; color: var(--text3); text-align: left; padding: 3px 6px;
  border-bottom: 1px solid var(--border); background: none;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
}
.ps-mini td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.ps-mini tr:last-child td { border-bottom: none; }

/* ═══════════════════════════════════════════════════════════
   FORM CARD (add.html)
   ═══════════════════════════════════════════════════════════ */
.form-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  max-width: 760px;
}
.form-section {
  font-size: 11px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: .07em;
  margin: 18px 0 11px; padding: 0 0 6px 10px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--amb);
}
.form-section:first-child { margin-top: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 11px; }
.row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 9px; margin-bottom: 11px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11px; font-weight: 600; color: var(--text2); }
.field label .opt { font-weight: 400; color: var(--text3); }

/* ── Spec tags ──────────────────────────────────────────── */
.spec-tags { min-height: 28px; margin-bottom: 8px; }
.spec-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--amb-lt); border: 1px solid var(--amb);
  border-radius: 100px; padding: 3px 10px;
  font-size: 11px; color: var(--amb-dk); margin: 2px;
}
.spec-tag .remove { cursor: pointer; opacity: .6; }
.spec-tag .remove:hover { opacity: 1; }

/* ── Pricing table ──────────────────────────────────────── */
.pricing-tbl { width: 100%; border-collapse: collapse; }
.pricing-tbl th {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text2);
  padding: 3px 6px 7px; text-align: left;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.pricing-tbl td { padding: 3px 4px; vertical-align: top; }
.pricing-tbl input[type="text"],
.pricing-tbl input[type="number"] { width: 100%; }
.pricing-tbl .enc-hint { font-size: 10px; color: var(--text2); margin-top: 2px; min-height: 13px; }
.pr-disc-row { display: flex; align-items: center; gap: 2px; margin-top: 3px; }
.pr-disc-row input { width: 50px !important; height: 22px !important; font-size: 10px !important; padding: 0 4px !important; flex-shrink: 0; }
.pr-disc-lbl { font-size: 10px; color: var(--text3); }
.pr-disc-hint { font-size: 10px; color: var(--grn); font-weight: 600; margin-left: 2px; }
.pr-unit-hint { font-size: 10px; color: var(--amb-dk); font-weight: 600; margin-top: 3px; }
.pr-unit-chips { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 3px; }
.pr-chip {
  font-size: 9px; padding: 2px 7px; border: 1px solid var(--border);
  border-radius: 100px; cursor: pointer; user-select: none;
  white-space: nowrap; color: var(--text2);
  transition: background 100ms, color 100ms, border-color 100ms;
}
.pr-chip:hover { background: var(--amb-lt); border-color: var(--amb); color: var(--amb-dk); }

/* ═══════════════════════════════════════════════════════════
   EMPTY / LOADING
   ═══════════════════════════════════════════════════════════ */
.empty { text-align: center; padding: 40px 20px; color: var(--text3); font-size: 13px; }
.loading { text-align: center; padding: 28px; color: var(--text3); font-size: 12px; }

/* ═══════════════════════════════════════════════════════════
   MANAGE PAGE CARDS
   ═══════════════════════════════════════════════════════════ */
.manage-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  margin-bottom: 14px; max-width: 660px;
}
.manage-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 11px; }
.manage-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--border); gap: 8px; font-size: 12.5px;
}
.manage-row:last-of-type { border-bottom: none; }
.add-row { display: flex; gap: 7px; margin-top: 11px; }

/* Category pills for attribute management */
.cat-pill {
  display: inline-block; font-size: 10px; padding: 3px 9px; border-radius: 100px;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text2);
  margin: 2px; cursor: pointer; user-select: none;
  transition: background 100ms, color 100ms, border-color 100ms;
}
.cat-pill.linked { background: var(--grn-lt); border-color: var(--grn); color: var(--grn); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════
   PAGE TABS
   ═══════════════════════════════════════════════════════════ */
.page-tabs {
  display: flex; gap: 3px;
  border-bottom: 1px solid var(--border); margin-bottom: 16px;
  overflow-x: auto; flex-wrap: nowrap;
  scrollbar-width: none;
}
.page-tabs::-webkit-scrollbar { display: none; }
.page-tab {
  padding: 9px 15px; font-size: 12.5px; cursor: pointer; user-select: none;
  border: 1px solid transparent; border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text2); background: transparent; margin-bottom: -1px;
  white-space: nowrap; transition: color 100ms;
  flex-shrink: 0;
}
.page-tab:hover { color: var(--text); }
.page-tab.active {
  background: var(--bg); border-color: var(--border); border-bottom-color: var(--bg);
  color: var(--text); font-weight: 600;
}
.page-tab .tab-count {
  display: inline-block; background: var(--bg2); color: var(--text2);
  padding: 1px 6px; border-radius: 100px; font-size: 10px; margin-left: 5px;
}
.page-tab.active .tab-count { background: var(--amb-lt); color: var(--amb-dk); }

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg2); padding: 16px;
}
.login-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px 28px;
  width: 100%; max-width: 360px;
}
.login-logo {
  width: 38px; height: 38px; background: var(--amb);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.login-logo svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 1.8; }
.login-heading { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-sub { font-size: 12px; color: var(--text3); text-align: center; margin-bottom: 22px; }
.login-err {
  font-size: 12px; color: var(--danger); background: var(--danger-bg);
  border: 1px solid var(--danger); border-radius: var(--radius);
  padding: 8px 10px; margin-bottom: 10px; display: none;
}
.login-err.show { display: block; }
.login-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 11px; }
.login-field label { font-size: 11px; font-weight: 600; color: var(--text2); }
.login-switch { font-size: 12px; color: var(--text3); text-align: center; margin-top: 14px; }
.login-switch a { color: var(--amb); cursor: pointer; text-decoration: underline; }
.btn-google {
  width: 100%; height: 40px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text);
  margin-bottom: 10px; transition: background .15s, border-color .15s;
  font-family: inherit;
}
.btn-google:hover { background: var(--bg2); border-color: var(--border2); }
.btn-google:disabled { opacity: .6; cursor: default; }
.login-divider {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 14px; color: var(--text3); font-size: 11px;
}
.login-divider::before, .login-divider::after { content:''; flex:1; height:1px; background:var(--border); }

/* ═══════════════════════════════════════════════════════════
   SEARCH SCOPE PILLS
   ═══════════════════════════════════════════════════════════ */
.scope-pill {
  font-size: 11px; padding: 3px 10px; border: 1px solid var(--border);
  border-radius: 100px; cursor: pointer; user-select: none;
  color: var(--text3); background: var(--bg);
  transition: background .1s, color .1s, border-color .1s;
  white-space: nowrap;
}
.scope-pill.active {
  background: var(--amb-lt); border-color: var(--amb); color: var(--amb-dk); font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   SORT PILLS — fixed: var(--amb) not undefined var(--primary)
   ═══════════════════════════════════════════════════════════ */
.sort-pill {
  font-size: 11px; padding: 0 10px; height: 26px;
  border: 1px solid var(--border); border-radius: 13px;
  background: var(--bg); color: var(--text2);
  cursor: pointer; white-space: nowrap; font-family: inherit;
  transition: background .12s, color .12s, border-color .12s;
}
.sort-pill.active {
  background: var(--amb); color: #fff; border-color: var(--amb);
}
.sort-pill:hover:not(.active) { background: var(--bg2); border-color: var(--border2); }

#mob-view-toggles { display: none; }

/* ═══════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: #1f1f1d; color: #f0efe9;
  padding: 9px 16px; border-radius: var(--radius);
  font-size: 12px; opacity: 0;
  transition: opacity .18s, transform .18s;
  transform: translateY(6px);
  pointer-events: none; z-index: 999;
  max-width: calc(100vw - 40px);
}
.toast.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* ═══════════════════════════════════════════════════════════
   BULK EDIT BAR — wrap fix for all screen sizes
   ═══════════════════════════════════════════════════════════ */
#bulk-bar {
  flex-wrap: wrap !important;
  gap: 6px 10px !important;
  align-items: center !important;
  row-gap: 6px !important;
}
#bulk-bar select {
  min-width: 160px !important;
  max-width: 220px !important;
  flex-shrink: 1 !important;
  height: 28px !important;
  font-size: 12px !important;
}
#bulk-bar > div {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-shrink: 1 !important;
  flex-wrap: wrap !important;
  min-width: 0 !important;
}
#bulk-prices { flex-wrap: wrap !important; gap: 6px !important; }
#bulk-prices input { width: 72px !important; min-width: 60px !important; }
/* Keep Done button pinned to the right */
#bulk-bar > button.btn-primary { margin-left: auto; flex-shrink: 0; }

/* ── Utility ─────────────────────────────────────────────── */
.text-muted { color: var(--text3); }
.text-sm { font-size: 11px; }
.mt-4 { margin-top: 4px; }
.mb-10 { margin-bottom: 10px; }

/* ═══════════════════════════════════════════════════════════
   PRODUCT IMAGES
   ═══════════════════════════════════════════════════════════ */
.img-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.img-thumb-wrap {
  position: relative; width: 72px; height: 72px; flex-shrink: 0;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: var(--bg2);
}
.img-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-remove-btn {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  background: rgba(0,0,0,.55); color: #fff;
  border: none; border-radius: 50%; cursor: pointer;
  font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.img-remove-btn:hover { background: rgba(163,45,45,.85); }
.img-order-btn {
  position: absolute; bottom: 2px;
  width: 18px; height: 18px;
  background: rgba(0,0,0,.45); color: #fff;
  border: none; border-radius: 3px; cursor: pointer;
  font-size: 10px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.img-order-btn:hover { background: rgba(0,0,0,.7); }
.img-add-box {
  width: 72px; height: 72px; flex-shrink: 0;
  border: 1.5px dashed var(--border2); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text3); font-size: 10px; gap: 3px;
  background: var(--bg2); transition: border-color .15s, color .15s;
}
.img-add-box:hover { border-color: var(--amb); color: var(--amb); }
.img-add-box span { font-size: 20px; line-height: 1; }
.img-add-menu {
  position: absolute; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.14);
  z-index: 300; padding: 4px 0; min-width: 160px;
}
.img-add-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; font-size: 12px; color: var(--text);
  background: none; border: none; cursor: pointer; text-align: left;
}
.img-add-menu button:hover { background: var(--bg2); }
.img-progress {
  height: 3px; background: var(--amb); border-radius: 2px;
  margin-top: 6px; transition: width 200ms; display: none;
}
.img-tier-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.img-tier-row:last-child { border-bottom: none; }
.img-tier-label { min-width: 100px; color: var(--text2); font-weight: 500; }
.img-tier-status { color: var(--text3); font-size: 11px; flex: 1; }
.img-tier-thumbs { display: flex; gap: 4px; }
.img-tier-thumb { width: 28px; height: 28px; border-radius: 3px; object-fit: cover; border: 1px solid var(--border); }

/* ── Image lightbox ─────────────────────────────────────── */
.img-modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.82); z-index: 500;
  align-items: center; justify-content: center;
}
.img-modal.open { display: flex; }
.img-modal-inner {
  position: relative; max-width: 92vw; max-height: 90vh;
  display: flex; align-items: center; justify-content: center;
}
.img-modal-inner img {
  max-width: 92vw; max-height: 88vh;
  border-radius: var(--radius); object-fit: contain;
}
.img-modal-close {
  position: absolute; top: -12px; right: -12px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; font-size: 18px; color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  line-height: 1; transition: color 120ms;
}
.img-modal-close:hover { color: var(--danger); }
.img-modal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.2);
  color: #fff; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; z-index: 2;
}
.img-modal-nav:hover { background: rgba(0,0,0,.82); }
.img-modal-prev { left: -52px; }
.img-modal-next { right: -52px; }
.img-modal-counter {
  position: absolute; bottom: -28px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: rgba(255,255,255,.7); white-space: nowrap;
}

/* ── Expand row gallery ─────────────────────────────────── */
.exp-gallery { margin-bottom: 10px; }
.exp-gallery-main {
  width: 100%; max-height: 220px; object-fit: contain;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; display: block;
  transition: opacity .15s;
}
.exp-gallery-strip { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.exp-gallery-thumb {
  width: 38px; height: 38px; border-radius: 4px; object-fit: cover;
  border: 2px solid transparent; cursor: pointer; transition: border-color .1s;
}
.exp-gallery-thumb.active { border-color: var(--amb); }
.exp-tier-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.exp-tier-tab {
  font-size: 11px; padding: 3px 9px; border: 1px solid var(--border);
  border-radius: 100px; cursor: pointer; color: var(--text2); background: var(--bg);
  transition: background .1s, color .1s;
}
.exp-tier-tab.active { background: var(--amb-lt); border-color: var(--amb); color: var(--amb-dk); font-weight: 600; }

/* ── Related products ───────────────────────────────────── */
.rel-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 100px; padding: 3px 10px;
  font-size: 11px; color: var(--text2); text-decoration: none;
  transition: border-color 100ms, color 100ms, background 100ms;
}
.rel-chip:hover { border-color: var(--amb); color: var(--amb-dk); background: var(--amb-lt); }
.rel-chip .unlink-btn {
  cursor: pointer; opacity: .5; font-size: 13px; line-height: 1;
  background: none; border: none; color: inherit; padding: 0;
}
.rel-chip .unlink-btn:hover { opacity: 1; color: var(--danger); }
.rel-search-wrap { position: relative; }
.rel-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.12);
  max-height: 180px; overflow-y: auto;
}
.rel-result-item {
  padding: 8px 10px; font-size: 12px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.rel-result-item:last-child { border-bottom: none; }
.rel-result-item:hover { background: var(--bg2); }

/* ═══════════════════════════════════════════════════════════
   TABLET  601 – 1024px
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 601px) and (max-width: 1024px) {
  :root { --sb-w: 180px; }

  .sb-top { padding: 11px 12px 10px; display: block; }
  .sb-mark { display: flex; align-items: center; gap: 8px; }
  .sb-icon { width: 24px; height: 24px; border-radius: 6px; }
  .sb-icon svg { width: 11px; height: 11px; }
  .sb-name { font-size: 12px; white-space: nowrap; }
  .sb-sub { font-size: 10px; margin-left: 32px; margin-top: 2px; }
  .nav-item { font-size: 12px; padding: 6px 12px; min-height: 38px; }
  .nav-item svg { width: 12px; height: 12px; }
  .nav-lbl { font-size: 9.5px; padding: 8px 12px 3px; }
  .mob-hamburger { display: none; }

  .topbar { padding: 9px 16px; min-height: 48px; }
  .topbar-sub { font-size: 10px; }
  .topbar > div:last-child { flex-wrap: wrap; gap: 5px; }
  .topbar > div:last-child .btn { font-size: 11.5px; padding: 0 10px; height: 30px; }

  .content { padding: 13px 16px; }
  .form-card { padding: 16px; max-width: 100%; }

  .stat-row { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .stat { padding: 10px 12px; }
  .stat-n { font-size: 20px; }

  .row-4 { grid-template-columns: 1fr 1fr; }
  .form-section { margin: 14px 0 9px; }

  td, th { font-size: 12px; padding: 8px 9px; }
  .col-supplier { display: none !important; }

  .filter-row { flex-wrap: wrap; gap: 6px; }
  .filter-row input { flex: 1 1 100%; min-width: 0; }
  .filter-row select { flex: 1 1 140px; }
  #sort-bar { flex: 1 1 100%; }

  .page-tabs { padding-bottom: 1px; }
  .page-tab { padding: 8px 12px; font-size: 12px; }

  #search-scope-row { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  #search-scope-row::-webkit-scrollbar { display: none; }

  /* Scale up inputs for touch */
  input[type="text"], input[type="number"], input[type="email"],
  input[type="password"], select { min-height: 38px; font-size: 13px; }

  .qa-table { min-width: 650px; }
  .qa-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE  ≤ 600px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* ── Layout ── */
  .app { flex-direction: column; overflow: visible; height: auto; min-height: 100dvh; }
  .mn { margin-left: 0; padding-top: 52px; height: auto; overflow: visible; flex: none; }
  .content { overflow-y: visible; height: auto; flex: none; padding: 11px 13px; }

  /* ── Sidebar → fixed top navbar ── */
  .sb {
    position: fixed; top: 0; left: 0; right: 0; width: 100%;
    min-width: unset; height: 52px;
    flex-direction: column; align-items: stretch;
    padding: 0; border-right: none; border-bottom: 1px solid var(--border);
    overflow: hidden; z-index: 200;
  }

  /* Menu open — drop-down panel */
  .sb.mob-open {
    height: auto;
    overflow: visible; padding-bottom: 6px;
    box-shadow: 0 16px 40px rgba(0,0,0,.22);
    animation: menuSlide 160ms ease both;
  }
  @keyframes menuSlide {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* sb-top becomes a flex row on mobile to hold logo + hamburger */
  .sb-top {
    display: flex; flex-direction: row; align-items: center; justify-content: space-between;
    padding: 0 14px; min-height: 52px; gap: 8px; flex-shrink: 0; border-bottom: none;
  }
  .sb.mob-open .sb-top { border-bottom: 1px solid var(--border); }
  .sb-sub { display: none; }
  .sb-name { font-size: 14px; white-space: nowrap; }
  .sb-mark { flex: 1; min-width: 0; }

  /* Nav groups: hidden until menu opens */
  .nav-grp { display: none; }
  .sb-user  { display: none; }
  .sb-theme { display: none; }
  .sb.mob-open .nav-grp { display: block; }
  .sb.mob-open .sb-user  { display: flex; }
  .sb.mob-open .sb-theme { display: flex; }

  /* Touch-friendly nav items */
  .nav-item { min-height: 46px; padding: 0 16px; font-size: 13.5px; gap: 10px; border-left-width: 3px; }
  .nav-item svg { width: 15px; height: 15px; }
  .nav-lbl { padding: 8px 16px 3px; font-size: 10.5px; }
  .nav-badge { font-size: 11px; padding: 2px 7px; }
  .nav-grp { padding: 3px 0; }

  .sb-user { padding: 11px 16px; gap: 10px; }
  .sb-user-avatar { width: 32px; height: 32px; font-size: 12px; }
  .sb-user-name { font-size: 13px; }
  .sb-signout { padding: 8px; min-width: 36px; min-height: 36px; }

  /* Hamburger */
  .mob-hamburger { display: flex; }

  /* ── Topbar: allow wrapping so buttons never cut ── */
  .topbar {
    position: sticky; top: 52px; z-index: 100;
    flex-wrap: wrap; align-items: center;
    gap: 5px; padding: 7px 13px; min-height: 48px;
    border-bottom: 1px solid var(--border);
  }
  .topbar > div:first-child { flex: 1 1 auto; min-width: 0; }
  .topbar > div:last-child {
    display: flex !important; flex-wrap: wrap !important;
    align-items: center !important; gap: 5px !important; flex-shrink: 0;
  }
  .topbar-title { font-size: 14px; white-space: nowrap; }
  .topbar-sub { display: none; }
  .topbar > div:last-child .btn { font-size: 11.5px; padding: 0 10px; min-height: 36px; }

  /* ── Hide desktop-only topbar controls ── */
  #show-cost-label, #show-supplier-label, #export-btn { display: none !important; }

  /* ── Inputs: comfortable touch size ── */
  input[type="text"], input[type="number"], input[type="email"],
  input[type="password"], select { min-height: 42px; font-size: 14px; }
  textarea { font-size: 14px; }

  /* ── Form grids → single column ── */
  .row-2, .row-4 { grid-template-columns: 1fr; gap: 9px; }
  .form-card { padding: 14px 13px; }
  .form-section { margin: 16px 0 9px; }

  /* ── Buttons ── */
  .btn { min-height: 40px; font-size: 13px; padding: 0 13px; }
  .btn-sm { min-height: 32px; font-size: 11.5px; }
  .btn-danger { min-height: 32px; }

  /* ── Stat row: 2×2 ── */
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 7px; margin-bottom: 12px; }
  .stat { padding: 10px 12px; }
  .stat-n { font-size: 20px; }
  .stat-l { font-size: 10px; }

  /* ── Quick-add bar: horizontal scroll, fixed widths beat inline styles ── */
  .qa-bar { flex-wrap: nowrap; overflow-x: auto; padding: 7px 10px; gap: 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .qa-bar::-webkit-scrollbar { display: none; }
  .qa-hint { display: none; }
  .qa-bar input { min-height: 40px; flex-shrink: 0; }
  #qa-input  { flex: 0 0 160px !important; width: 160px !important; }
  #qa-mrp, #qa-wh, #qa-retail, #qa-cost { width: 82px !important; min-width: 82px !important; }
  .qa-bar .btn { min-height: 40px; flex-shrink: 0; }

  /* ── Filter row ── */
  .filter-row { flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
  .filter-row #search { width: 100%; flex: 1 1 100%; min-height: 44px; font-size: 14px; }
  .filter-row select { flex: 1 1 calc(50% - 4px); min-height: 42px; min-width: 0; }
  #sort-bar { display: flex; align-items: center; gap: 4px; width: 100%; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  #sort-bar::-webkit-scrollbar { display: none; }
  #sort-bar .sort-pill { flex-shrink: 0; height: 30px; font-size: 12px; padding: 0 11px; }
  /* Ensure selects never clip their text */
  select { text-overflow: ellipsis; }

  /* ── Scope pills ── */
  #search-scope-row { overflow-x: auto; flex-wrap: nowrap; gap: 5px; margin: 5px 0 2px; padding-bottom: 2px; scrollbar-width: none; }
  #search-scope-row::-webkit-scrollbar { display: none; }
  #search-scope-row .scope-pill { flex-shrink: 0; }

  /* ── Mobile view toggles ── */
  #mob-view-toggles { display: flex; gap: 6px; margin: 5px 0 2px; flex-wrap: wrap; }

  /* ── Bulk bar ── */
  #bulk-bar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  #bulk-bar .btn { font-size: 11.5px; min-height: 34px; padding: 0 10px; }

  /* ── Product table → card layout (NOT qa-table-wrap) ── */
  .tbl-wrap:not(.qa-table-wrap) { overflow-x: visible !important; border-radius: var(--radius-lg); }
  .tbl-wrap:not(.qa-table-wrap) table { display: block !important; min-width: unset !important; width: 100% !important; }
  .tbl-wrap:not(.qa-table-wrap) thead { display: none !important; }
  .tbl-wrap:not(.qa-table-wrap) tbody { display: block !important; }

  /* Product rows → 3-row grid cards */
  tbody tr:has(td[data-col="chev"]) {
    display: grid !important;
    grid-template-columns: 22px 1fr auto;
    grid-template-rows: auto auto auto;
    column-gap: 9px; row-gap: 3px;
    align-items: center;
    padding: 11px 13px;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
  }
  tbody tr:has(td[data-col="chev"]) td { display: block; padding: 0 !important; border: none !important; }

  td[data-col="chev"]   { grid-column: 1; grid-row: 1 / span 10; display: flex !important; align-items: center; }
  td[data-col="name"]   { grid-column: 2; grid-row: 1; font-size: 13px; }
  td[data-col="cat"]    { grid-column: 3; grid-row: 1; text-align: right; max-width: 96px; overflow: hidden; }
  td[data-col="cat"] .cat-badge { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; max-width: 86px; font-size: 10px; }
  td.col-sku            { grid-column: 2; grid-row: 2; font-size: 10.5px; color: var(--text3); }
  td[data-col="wh"]     { grid-column: 3; grid-row: 2; text-align: right; font-size: 10.5px; color: var(--text3); display: block !important; }
  td[data-col="mrp"]    { grid-column: 2; grid-row: 3; font-size: 11.5px; color: var(--text3); display: block !important; }
  td[data-col="retail"] { grid-column: 3; grid-row: 3; text-align: right; font-size: 13px; font-weight: 700; display: block !important; }
  td[data-col="cost"]   { grid-column: 2; grid-row: 4; font-size: 11px; color: var(--danger); display: block !important; }
  td[data-col="supplier"] { grid-column: 3; grid-row: 4; font-size: 11px; color: var(--text3); text-align: right; display: block !important; }
  td[data-col="action"], tbody tr:has(td[data-col="chev"]) td:not([data-col]):not(.col-sku) { display: none !important; }

  td, th { font-size: 12px; }

  /* ── Expand row ── */
  .expand-row { display: block !important; }
  .expand-row > td { display: block !important; padding: 12px 13px !important; border: none !important; width: 100%; box-sizing: border-box; }
  .expand-grid { grid-template-columns: 1fr; gap: 10px; }
  .expand-row .exp-actions { flex-wrap: wrap; gap: 6px; }
  .expand-row .exp-actions .btn { flex: 1 1 auto; min-width: 110px; justify-content: center; }

  /* ── Page tabs: must scroll horizontally ── */
  .page-tabs { overflow-x: auto !important; flex-wrap: nowrap !important; -webkit-overflow-scrolling: touch; padding-bottom: 0; }
  .page-tab { white-space: nowrap; min-height: 40px; font-size: 12.5px; padding: 0 14px; display: flex; align-items: center; flex-shrink: 0; }

  /* ── Toast: bottom center ── */
  .toast { bottom: 16px; left: 50%; right: auto; transform: translateX(-50%) translateY(6px); }
  .toast.show { transform: translateX(-50%) translateY(0); }

  /* ── Manage cards ── */
  .manage-card { max-width: 100%; padding: 14px 13px; }

  /* ── Users table → clean mobile cards ── */
  #users-list table { display: block !important; width: 100% !important; min-width: unset !important; }
  #users-list thead { display: none !important; }
  #users-list tbody { display: block !important; }
  #users-list tbody tr {
    display: flex !important;
    flex-direction: column;
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    gap: 0;
  }
  #users-list tbody td { display: block; padding: 0 !important; border: none !important; }
  /* Row 1: avatar + name + status badge */
  td[data-col="avatar"] {
    display: none !important;
  }
  td[data-col="name"] {
    font-size: 14px; font-weight: 700;
    margin-bottom: 2px;
    display: flex !important; align-items: center; gap: 8px;
  }
  td[data-col="email"] {
    font-size: 12px; color: var(--text3);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-bottom: 10px;
  }
  td[data-col="status"] {
    display: flex !important; align-items: center; gap: 8px;
    margin-bottom: 6px;
  }
  td[data-col="role"] {
    display: flex !important; align-items: center; gap: 8px;
  }
  td[data-col="joined"] { display: none !important; }
  td[data-col="status"]::before { content: 'Status:'; font-size: 11px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; min-width: 52px; }
  td[data-col="role"]::before   { content: 'Role:';   font-size: 11px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; min-width: 52px; }
  td[data-col="status"] button  { min-height: 34px !important; font-size: 12px !important; padding: 0 12px !important; }
  td[data-col="role"] select    { min-height: 34px !important; font-size: 12px !important; height: 34px !important; flex: 1; max-width: 160px; }

  /* ── History ── */
  #history-list > div { flex-wrap: wrap; gap: 6px; }
  #history-list > div > div:last-child { flex-basis: 100%; }

  /* ── Pricing table (add.html): horizontal scroll ── */
  #pricing-tbl { font-size: 10.5px; min-width: 520px; }
  #pricing-tbl th { font-size: 8.5px; padding: 2px 3px 5px; white-space: nowrap; }
  #pricing-tbl td { padding: 2px 2px; }
  #pricing-tbl input[type="text"],
  #pricing-tbl input[type="number"] { height: 30px !important; min-height: 30px !important; font-size: 10.5px !important; }
  #pricing-tbl select { height: 30px !important; min-height: 30px !important; font-size: 10.5px !important; }

  /* ── Quick-add import table: handled entirely in quick-add.html inline styles ── */
  .qa-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ── Import modal: full-screen ── */
  .import-modal-box { width: 100vw !important; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }

  /* ── Lightbox nav arrows: inside on mobile ── */
  .img-modal-prev { left: 6px; }
  .img-modal-next { right: 6px; }

  /* ── Print/labels hint ── */
  .no-print-hint {
    display: block; background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; font-size: 13px;
    text-align: center; color: var(--text2);
  }

  .mob-hide-kbd { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   EXTRA-SMALL  ≤ 400px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .content { padding: 9px 10px; }
  .form-card { padding: 12px 10px; border-radius: var(--radius); }
  .topbar { padding: 6px 10px; }
  .topbar-title { font-size: 13px; }
  .topbar > div:last-child .btn { font-size: 10.5px; padding: 0 8px; min-height: 32px; }
  .btn { padding: 0 11px; }
  .sb-top { padding: 0 11px; }
  .nav-item { padding: 0 14px; min-height: 48px; }
  .nav-lbl  { padding: 9px 14px 3px; }
  .sb-user  { padding: 10px 14px; }
  .stat-n { font-size: 18px; }
  .stat { padding: 8px 10px; }
  .filter-row select { flex: 1 1 100%; }
  .exp-actions .btn { flex: 1 1 100%; }
}
