/* =============================================================
   BAUCOM360 — Styles
   3 colors only. Manrope + JetBrains Mono. Mobile-first.
   ============================================================= */

:root {
  --red: #D72E48;
  --red-dark: #B82740;
  --red-tint: #FBEDF0;
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --line: #E8E5DC;
  --line-strong: #D8D4C8;
  --text: #323232;
  --text-2: #6B6960;
  --text-3: #9A968B;
  --green: #2D8A4E;
  --green-tint: #E8F5EE;

  --r: 10px;
  --r-sm: 6px;
  --r-lg: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.4 'Manrope', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior: none;
}
/* `hidden` attribute hides elements until JS shows them. */
[hidden] { display: none; }

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }
input, select, textarea { font: inherit; color: var(--text); }
input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-tint);
}
textarea { min-height: 70px; resize: vertical; }

.boot-wordmark {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.02em;
  color: var(--red);
}
.boot-wordmark span {
  color: var(--text-3);
  font-weight: 600;
  font-size: 0.55em;
  letter-spacing: 0.05em;
  margin-left: 5px;
  vertical-align: 6px;
}

.topbar-mark {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: var(--red);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.topbar-mark span {
  color: var(--text-3);
  font-weight: 600;
  font-size: 0.6em;
  letter-spacing: 0.04em;
  margin-left: 2px;
  vertical-align: 3px;
}

.mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }

/* ----------- Buttons ----------- */
.btn {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--line-strong); background: var(--bg); }
.btn.full { width: 100%; }

.btn-icon {
  width: 46px; height: 46px;
  border-radius: var(--r);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
  flex-shrink: 0;
}
.btn-icon.btn-primary { color: #fff; }
.btn-icon.btn-dark { background: var(--text); color: #fff; }
.btn-icon.btn-dark:hover { background: #1f1f1f; }

.link {
  color: var(--red); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.link:hover { color: var(--red-dark); }

.btn-clear {
  display: none;  /* default; .show toggles to grid */
  position: absolute; right: 56px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px;
  color: var(--text-3);
  border-radius: 50%;
  font-size: 14px;
  place-items: center;
}
.btn-clear.show { display: grid; }
.btn-clear:hover { color: var(--red); background: var(--bg); }

/* ----------- Boot ----------- */
#boot {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
}
.boot-msg { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------- Auth (login) ----------- */
#login-screen {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: var(--surface);
  align-items: center; justify-content: center;
  padding: 24px; padding-top: calc(24px + var(--safe-top));
}
#login-screen.show { display: flex; }
.auth-card { width: 100%; max-width: 380px; }
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-header .logo { display: block; margin: 0 auto; }
.wordmark {
  font-size: 28px; font-weight: 800;
  color: var(--red);
  letter-spacing: 0.02em;
  margin: 12px 0 0;
}
.motto { font-size: 12px; color: var(--text-2); font-weight: 600; margin: 2px 0 0; }
.tag {
  font-size: 11px; color: var(--text-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.16em;
  margin: 12px 0 0;
}
.auth-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-2);
}
.auth-card label input { margin-top: 6px; }
.hint-card {
  background: var(--bg);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 18px;
}
.hint-card strong {
  display: block;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.hint-card p { margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.error {
  display: none;
  color: var(--red); font-size: 13px; margin: 10px 0 0; text-align: center;
}
.error.show { display: block; }
.auth-footer {
  text-align: center; margin: 18px 0 0;
  font-size: 11px; color: var(--text-3); font-weight: 600;
  letter-spacing: 0.04em;
}
.btn-primary[id="cfg-save"], .btn-primary[id="login-btn"] { width: 100%; }

/* ----------- App shell ----------- */
#app { padding-bottom: calc(72px + var(--safe-bot)); }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  padding-top: calc(10px + var(--safe-top));
  display: flex; align-items: center; gap: 12px;
}
.topbar h1 {
  flex: 1; margin: 0;
  font-size: 15px; font-weight: 700;
  letter-spacing: -0.01em;
}
.topbar .user {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  max-width: 50%;
}
.topbar .user > span:not(.dot) {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.topbar .user button {
  font-size: 11px; color: var(--text-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.topbar .user button:hover { color: var(--red); }

#session-bar {
  display: none;
  background: var(--red); color: #fff;
  text-align: center; padding: 6px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
}
#session-bar.show { display: block; }

/* ----------- Tabs ----------- */
/* ----------- Tabs (bottom for agents, top for admin) ----------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 8px 0; padding-bottom: calc(8px + var(--safe-bot));
  display: grid; grid-template-columns: repeat(7, 1fr);
}
.tab {
  padding: 8px 2px;
  color: var(--text-3);
  font-size: 9.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.02em;
  position: relative;
  transition: color 0.12s;
  white-space: nowrap;
}
.tab.active { color: var(--red); }
.tab .badge {
  position: absolute; top: 0; right: calc(50% - 18px);
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 8px;
  min-width: 16px; text-align: center;
}

/* Admin layout: tab bar at top, horizontally scrollable */
body.is-admin .tabs {
  position: fixed; top: 0; bottom: auto;
  left: 0; right: 0;
  border-top: 0;
  border-bottom: 1px solid var(--line);
  padding: 0; padding-top: var(--safe-top);
  display: flex; overflow-x: auto;
  gap: 0;
  scrollbar-width: thin;
}
body.is-admin .tabs::-webkit-scrollbar { height: 3px; }
body.is-admin .tabs::-webkit-scrollbar-thumb { background: var(--line); }

body.is-admin .tab {
  flex-shrink: 0;
  padding: 14px 18px;
  font-size: 11px;
  border-bottom: 3px solid transparent;
  color: var(--text-2);
}
body.is-admin .tab.active {
  color: var(--red);
  border-bottom-color: var(--red);
  background: var(--bg);
}
body.is-admin .tab .badge {
  position: static;
  margin-left: 4px; display: inline-block;
}
body.is-admin .topbar {
  margin-top: 44px;   /* push topbar below the new top nav */
}
body.is-admin .view {
  padding-bottom: 24px;   /* no need for bottom-tab safe area */
}

/* ----------- Views ----------- */
.view { display: none; padding: 14px; }
.view.active { display: block; }

/* ----------- Cards ----------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.card > input, .card > textarea, .card > .row, .card > .seg, .card > select {
  margin-bottom: 10px;
}
.card > :last-child { margin-bottom: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty p { margin: 4px 0; }

/* ----------- Search bar ----------- */
.searchbar {
  display: flex; gap: 8px; margin-bottom: 12px; position: relative;
}
.searchbar input { flex: 1; padding-right: 36px; }
.chips {
  display: flex; gap: 6px; margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  transition: all 0.12s;
}
.chip.active { background: var(--red); color: #fff; border-color: var(--red); }
.chip .count { opacity: 0.7; margin-left: 4px; font-weight: 500; }

.meta {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 4px; margin-bottom: 8px;
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.meta > span:first-child { color: var(--text-2); font-weight: 700; }

/* ----------- Lists / cards ----------- */
.list { display: flex; flex-direction: column; gap: 8px; }

/* product card */
.product-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.06s;
}
.product-card:active { transform: scale(0.99); }
.product-card:hover { border-color: var(--line-strong); }
.pc-row1 {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-bottom: 4px;
}
.pc-name {
  font-weight: 600; font-size: 14px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pc-price {
  font-weight: 700; font-size: 15px; color: var(--green);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pc-row2 {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-3); gap: 8px;
}
.pc-sku { font-family: 'JetBrains Mono', monospace; color: var(--text-2); flex-shrink: 0; }
.pc-cat {
  background: var(--bg); padding: 2px 7px; border-radius: 4px;
  color: var(--text-2); font-weight: 500; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pc-margin {
  font-family: 'JetBrains Mono', monospace; font-weight: 700;
  color: var(--text-2); flex-shrink: 0;
}

.load-more {
  display: block;
  margin: 14px auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  padding: 10px 18px;
  border-radius: var(--r);
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.load-more:hover { border-color: var(--red); color: var(--red); }

/* ----------- Quote ----------- */
#client-pick-area { margin-bottom: 8px; }
.client-pick-btn {
  background: var(--bg);
  border: 1px dashed var(--line-strong);
  color: var(--text-2);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 8px;
}
.client-pick-btn:hover { border-color: var(--red); color: var(--red); }
.client-selected {
  background: var(--red-tint);
  border: 1px solid var(--red);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 13px;
  position: relative;
}
.client-selected .name { font-weight: 700; }
.client-selected .meta { color: var(--text-2); font-size: 12px; margin-top: 2px; padding: 0; text-transform: none; letter-spacing: 0; font-weight: normal; }
.client-selected .clear-btn {
  position: absolute; top: 8px; right: 10px;
  font-size: 11px; color: var(--text-3); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.client-selected .clear-btn:hover { color: var(--red); }

.quote-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
}
.qi-top {
  display: flex; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.qi-name { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; }
.qi-name .sku-line {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--text-3);
  margin-top: 2px; font-weight: 400;
}
.unit-toggle {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--red-tint);
  border: 1px solid var(--red);
  border-radius: 4px;
  padding: 1px 7px;
  font-family: 'Manrope', sans-serif;
  font-size: 10px; font-weight: 700;
  color: var(--red);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s;
}
.unit-toggle:hover { background: var(--red); color: #fff; }
.unit-static {
  display: inline-block;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  color: var(--text-2);
}
.unit-tag {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  letter-spacing: 0.04em;
}
.qi-remove {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-3); font-size: 14px;
  flex-shrink: 0;
}
.qi-remove:hover { color: var(--red); background: var(--red-tint); }

.qi-controls {
  display: grid; grid-template-columns: 90px 1fr 80px;
  gap: 6px; align-items: center;
  margin-bottom: 8px;
}
.qi-qty {
  display: flex; align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.qi-qty button {
  width: 28px;
  color: var(--text-2);
  font-size: 16px; font-weight: 600;
}
.qi-qty button:hover { background: var(--bg); color: var(--red); }
.qi-qty input {
  flex: 1; min-width: 0;
  text-align: center;
  border: 0; padding: 6px 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; font-weight: 700;
  -moz-appearance: textfield;
}
.qi-qty input::-webkit-outer-spin-button,
.qi-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qi-price, .qi-disc {
  padding: 7px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; font-weight: 700;
  text-align: right;
}
.qi-disc { text-align: center; padding: 7px 8px; font-size: 12px; }
.qi-price.below-min, .qi-disc.over-max {
  border-color: var(--red); color: var(--red); background: var(--red-tint);
}
.qi-summary {
  display: flex; justify-content: space-between;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 11px;
}
.qi-summary .label { color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.qi-summary .val { font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.qi-warning {
  margin-top: 8px;
  background: var(--red-tint); color: var(--red);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 11px; font-weight: 600;
}

/* totals */
.totals .trow {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.totals .trow > span:first-child { color: var(--text-2); font-weight: 500; }
.totals .trow > span:last-child {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}
.totals .trow-disc {
  border-top: 1px dashed var(--line);
  margin-top: 4px; padding-top: 10px;
}
.totals .trow-disc input {
  width: 80px; padding: 4px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 700;
  text-align: right;
}
.totals .profit { color: var(--text-2); font-style: italic; }
.totals .grand {
  border-top: 1px solid var(--line);
  margin-top: 8px; padding-top: 12px;
}
.totals .grand > span:first-child {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text); font-style: normal;
}
.totals .grand > span:last-child {
  font-size: 22px; font-weight: 800; color: var(--red);
}

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ----------- Clients & history ----------- */
.client-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  cursor: pointer;
}
.client-item:hover { border-color: var(--line-strong); }
.cli-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.cli-name {
  font-weight: 700; font-size: 14px;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cli-prof {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.cli-contact {
  display: flex; gap: 12px; margin-top: 4px;
  font-size: 12px; color: var(--text-2);
  flex-wrap: wrap;
}
.cli-comment { font-size: 12px; color: var(--text-2); margin-top: 4px; line-height: 1.4; }

.history-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  cursor: pointer;
}
.history-item:hover { border-color: var(--line-strong); }
.hi-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.hi-num { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-3); font-weight: 700; }
.hi-total { font-family: 'JetBrains Mono', monospace; font-weight: 800; color: var(--red); font-size: 15px; }
.hi-mid {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 4px;
}
.hi-bot { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-3); }
.hi-profit { font-family: 'JetBrains Mono', monospace; color: var(--text-2); font-weight: 700; }

/* ----------- Suggestions ----------- */
.seg { display: flex; gap: 4px; margin-bottom: 12px; }
.seg-btn {
  flex: 1; padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.seg-btn.active { background: var(--text); color: #fff; border-color: var(--text); }

.fb-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.fb-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.fb-prod {
  font-weight: 700; font-size: 13px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fb-status {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 2px 8px; border-radius: 4px;
  flex-shrink: 0;
}
.fb-status.pending { background: var(--red-tint); color: var(--red); }
.fb-status.approved { background: var(--green-tint); color: var(--green); }
.fb-status.rejected { background: var(--bg); color: var(--text-3); }
.fb-meta {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--text-2); margin-bottom: 6px;
}
.fb-meta .arr { color: var(--text-3); }
.fb-meta .new { color: var(--red); font-weight: 700; }
.fb-meta .kind {
  font-family: 'Manrope', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--bg); padding: 2px 6px; border-radius: 3px; color: var(--text-2);
}
.fb-note { font-size: 12px; color: var(--text-2); line-height: 1.4; }
.fb-by { font-size: 10px; color: var(--text-3); margin-top: 4px; font-weight: 600; }
.fb-actions { display: flex; gap: 6px; margin-top: 8px; }
.fb-actions button {
  flex: 1; padding: 7px;
  font-size: 11px; font-weight: 700;
  border-radius: var(--r-sm);
  text-transform: uppercase; letter-spacing: 0.05em;
  border: 1px solid;
}
.fb-approve { background: var(--green-tint); color: var(--green); border-color: #B5DDC5; }
.fb-reject { background: var(--red-tint); color: var(--red); border-color: #F0BAC5; }

#feedback-list { margin-top: 16px; }

/* ----------- Admin ----------- */
.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
}
.stat-num {
  font-size: 22px; font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--red);
  letter-spacing: -0.02em;
}
.stat-lbl {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3); margin-top: 2px;
}

.block { margin-bottom: 22px; }
.block h3 {
  margin: 0; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-3);
}
.block-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}

.dropzone {
  display: block;
  background: var(--surface);
  border: 2px dashed var(--line-strong);
  border-radius: var(--r);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.15s;
}
.dropzone.dragover { border-color: var(--red); background: var(--red-tint); }
.dropzone strong { display: block; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.dropzone small { font-size: 11px; color: var(--text-3); }

#upload-progress {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 12px; color: var(--text-2);
  margin-bottom: 12px;
}

.agent-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
}
.agent-info { flex: 1; min-width: 0; }
.agent-name { font-weight: 700; font-size: 14px; }
.agent-username { font-size: 11px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }
.toggle-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
}

.toggle {
  position: relative;
  width: 38px; height: 22px;
  background: var(--line-strong);
  border-radius: 22px;
  transition: background 0.18s;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle.on { background: var(--green); }
.toggle::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { left: 18px; }

.toggle-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  font-size: 13px;
}
.toggle-row > span { flex: 1; }

/* ----------- Modals ----------- */
.modal {
  display: none;  /* hidden by default; .show makes them visible */
  position: fixed; inset: 0; z-index: 100;
  background: rgba(50,50,50,0.6);
  backdrop-filter: blur(4px);
  align-items: flex-end; justify-content: center;
}
.modal.show { display: flex; }
@media (min-width: 600px) {
  .modal { align-items: center; }
}
.sheet {
  background: var(--surface);
  width: 100%; max-width: 560px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  max-height: 92dvh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-bottom: none;
  animation: slideUp 0.2s ease-out;
}
@media (min-width: 600px) {
  .sheet { border-radius: var(--r-lg); border-bottom: 1px solid var(--line); }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet > header {
  position: sticky; top: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.sheet > header h2 {
  margin: 0;
  font-size: 17px; font-weight: 700;
  letter-spacing: -0.01em; line-height: 1.3;
  flex: 1; min-width: 0;
}

.pm-title-wrap { width: 100%; }
.pm-title-name {
  font-size: 17px; font-weight: 700;
  line-height: 1.3; letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.pm-title-tools {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.g-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px 4px 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 100px;
  text-decoration: none;
  color: var(--text-2);
  font-size: 11px; font-weight: 600;
}
.g-btn:hover { border-color: var(--text-3); color: var(--text); }
.g-letter {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  background: var(--white);
  border-radius: 50%;
  font-family: 'Manrope', sans-serif;
  font-weight: 700; font-size: 11px;
  color: #4285F4;
  line-height: 1;
  border: 1px solid var(--line);
}
.sheet > header .x {
  width: 32px; height: 32px;
  background: var(--bg);
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--text-2);
  font-size: 14px;
}
.sheet-body { padding: 16px 18px; }
.sheet-body > input,
.sheet-body > textarea,
.sheet-body > .row,
.sheet-body > .toggle-row,
.sheet-body > select,
.sheet-body > button { margin-bottom: 10px; }
.sheet > footer {
  position: sticky; bottom: 0;
  background: var(--surface);
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.sheet > footer:has(.full),
.sheet > footer.single { grid-template-columns: 1fr; }

/* product detail body */
.pd-section { margin-bottom: 18px; }
.pd-section:last-child { margin-bottom: 0; }
.pd-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-3); margin-bottom: 8px;
}
.pd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pd-cell {
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.pd-cell .k {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3); margin-bottom: 4px;
}
.pd-cell .v {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 14px;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}
.pd-cell.full { grid-column: 1 / -1; }
.pd-cell .v.text { font-family: 'Manrope', sans-serif; }
.pd-cell .v.sell { color: var(--green); }
.pd-cell .v.cogs { color: var(--red); }
.pd-cell .v.muted { color: var(--text-3); font-weight: 500; font-size: 12px; }

/* ----------- Scanner ----------- */
#scanner-modal {
  display: none;  /* hidden by default; .show makes it visible */
  position: fixed; inset: 0; z-index: 200;
  background: #000;
}
#scanner-modal.show { display: block; }
#scanner-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.scan-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px;
  padding-top: calc(16px + var(--safe-top));
  color: #fff;
}
.scan-top button {
  width: 40px; height: 40px;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: 18px;
}
.scan-top span {
  font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.scan-frame {
  position: absolute; inset: 80px 0 120px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.scan-window {
  width: 80%; max-width: 320px; aspect-ratio: 16/10;
  border: 2px solid var(--red);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  position: relative;
}
.scan-line {
  position: absolute; left: 8px; right: 8px; top: 50%;
  height: 2px; background: var(--red);
  box-shadow: 0 0 12px var(--red);
  animation: scanline 1.6s ease-in-out infinite;
}
@keyframes scanline {
  0%, 100% { top: 8%; }
  50% { top: 92%; }
}
.scan-status {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 1;
  padding: 16px; margin: 16px;
  margin-bottom: calc(16px + var(--safe-bot));
  background: rgba(0,0,0,0.5);
  border-radius: var(--r);
  text-align: center;
  color: #fff;
  font-size: 13px;
}
.scan-status .mono { display: block; margin-top: 4px; color: var(--red); }

/* Rich product card shown after a successful scan */
.scan-card {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 2;
  margin: 16px;
  margin-bottom: calc(16px + var(--safe-bot));
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.scan-card-name {
  font-weight: 700; font-size: 15px; line-height: 1.3;
  color: var(--text);
  margin-bottom: 4px;
}
.scan-card-meta {
  display: flex; gap: 10px; align-items: center;
  font-size: 11px; color: var(--text-3);
  margin-bottom: 10px;
}
.scan-card-meta .mono {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-2); font-weight: 600;
}
.scan-card-prices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin-bottom: 12px;
}
.scan-card-price {
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 8px 10px;
}
.scan-card-price .k {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 2px;
}
.scan-card-price .v {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.scan-card-price .v.sell { color: var(--green); }
.scan-card-price .v.cogs { color: var(--red); }
.scan-card-price.full { grid-column: 1 / -1; }
.scan-card-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.scan-card-actions .btn { padding: 11px; font-size: 12px; }

/* ----------- Wave 3: Filter pills, info pages, pricing table, tag builder ----------- */
.filter-pills {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.pill {
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.pill.active { background: var(--red); border-color: var(--red); color: #fff; }
.pill:hover:not(.active) { border-color: var(--text-3); }

.filter-input {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  flex: 1; min-width: 120px;
}

/* Pricing table */
#pricing-table-wrap { overflow-x: auto; margin-top: 8px; }
.pricing-table {
  width: 100%; border-collapse: collapse;
  font-size: 11px; font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.pricing-table th {
  text-align: left; padding: 8px 6px;
  background: var(--bg); border-bottom: 2px solid var(--line);
  font-family: 'Manrope', sans-serif;
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-3); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.pricing-table th:hover { color: var(--red); }
.pricing-table th.sorted-asc::after  { content: ' ↑'; color: var(--red); }
.pricing-table th.sorted-desc::after { content: ' ↓'; color: var(--red); }
.pricing-table td {
  padding: 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.pricing-table tbody tr:hover { background: var(--bg); }
.pricing-table .name {
  font-family: 'Manrope', sans-serif; font-weight: 600;
  font-size: 12px; max-width: 280px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pricing-table .neg { color: var(--red); font-weight: 700; }
.pricing-table .pos { color: var(--green); }
.pricing-table .num { text-align: right; }
.pricing-table .abc-A { color: var(--green); font-weight: 700; }
.pricing-table .abc-B { color: var(--text-2); font-weight: 600; }
.pricing-table .abc-C { color: var(--text-3); }

/* Info pages */
#info-page-list {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px; border-bottom: 1px solid var(--line);
  margin: 0 -14px;
}
.info-pill {
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.info-pill.active {
  background: var(--red); border-color: var(--red); color: #fff;
}
.info-pill .ico { font-size: 14px; }
#info-page-content {
  padding: 16px 0; line-height: 1.6;
}
#info-page-content h1, #info-page-content h2, #info-page-content h3 {
  font-family: 'Manrope', sans-serif; font-weight: 700;
  letter-spacing: -0.01em;
  margin: 1.2em 0 0.4em;
}
#info-page-content h1 { font-size: 22px; }
#info-page-content h2 { font-size: 18px; }
#info-page-content h3 { font-size: 15px; }
#info-page-content p { margin: 0.5em 0; }
#info-page-content ul, #info-page-content ol {
  margin: 0.5em 0 0.5em 1.5em;
}
#info-page-content li { margin: 0.2em 0; }
#info-page-content table {
  width: 100%; border-collapse: collapse; margin: 0.8em 0;
  font-size: 13px;
}
#info-page-content th, #info-page-content td {
  border: 1px solid var(--line); padding: 6px 10px;
  text-align: left;
}
#info-page-content th { background: var(--bg); font-weight: 700; }
#info-page-content code {
  background: var(--bg); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 3px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
}
#info-page-content blockquote {
  border-left: 3px solid var(--red);
  padding-left: 12px; color: var(--text-2);
  font-style: italic; margin: 0.5em 0;
}

/* Client requests */
.req-card {
  padding: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 8px;
  cursor: pointer;
}
.req-card:hover { border-color: var(--text-3); }
.req-card .req-prod {
  font-size: 14px; font-weight: 700;
  margin-bottom: 4px;
}
.req-card .req-meta {
  font-size: 11px; color: var(--text-3);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.req-card .req-status {
  display: inline-block;
  padding: 2px 8px; border-radius: 3px;
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.req-status.open { background: #fef3c7; color: #92400e; }
.req-status.in_progress { background: #dbeafe; color: #1e40af; }
.req-status.resolved { background: #d1fae5; color: #065f46; }
.req-status.rejected { background: #fee2e2; color: #991b1b; }
.req-priority {
  display: inline-block;
  padding: 1px 6px; border-radius: 3px;
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.req-priority.high { background: var(--red); color: #fff; }
.req-priority.normal { background: var(--bg); color: var(--text-2); }
.req-priority.low { background: var(--bg); color: var(--text-3); }

.rr-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

/* Price tag builder */
.tag-builder { display: grid; gap: 10px; }
#tag-search-results {
  max-height: 240px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  display: none;
}
#tag-search-results.show { display: block; }
.tag-result-row {
  padding: 8px 10px; cursor: pointer;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
}
.tag-result-row:hover { background: var(--bg); }
.tag-result-row:last-child { border-bottom: 0; }
.tag-result-row .name { font-weight: 600; }
.tag-result-row .meta { color: var(--text-3); font-size: 10px; font-family: 'JetBrains Mono', monospace; }

#tag-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 280px; overflow-y: auto;
}
.tag-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg); border-radius: var(--r-sm);
  font-size: 12px;
}
.tag-row .name {
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag-row .qty-input {
  width: 50px; padding: 4px 6px;
  font-size: 12px; text-align: center;
}
.tag-row .x { color: var(--red); font-size: 16px; font-weight: 700; padding: 2px 6px; }
.tag-actions { display: flex; gap: 8px; }
.tag-actions .btn { flex: 1; }

#tag-selected {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 4px;
}
#tag-selected .muted { color: var(--text-3); font-size: 12px; }

.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0;
}
.checkbox-label input[type=checkbox] { width: auto; margin: 0; }

/* ----------- Toast ----------- */
#toast {
  position: fixed;
  top: calc(var(--safe-top) + 60px);
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: var(--text); color: #fff;
  border-radius: var(--r);
  padding: 10px 16px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 500;
  max-width: 90vw; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: var(--green); }
#toast.error { background: var(--red); }
