/* ==========================================================================
   Pharmaline portal — design system
   Tokens → base → layout → components → utilities.
   Brand colours (--brand, --accent) are overridden from Site settings in base.html.
   Page-specific styles belong in static/<app>/<app>.css, not here.
   ========================================================================== */

:root {
  --brand: #0b5e8e;
  --brand-600: color-mix(in srgb, var(--brand) 88%, black);
  --brand-700: color-mix(in srgb, var(--brand) 75%, black);
  --brand-50: color-mix(in srgb, var(--brand) 7%, white);
  --brand-100: color-mix(in srgb, var(--brand) 14%, white);
  --accent: #12a37f;
  --accent-50: color-mix(in srgb, var(--accent) 9%, white);

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #dde3ea;
  --border-strong: #c5ced9;
  --text: #17202b;
  --text-2: #3d4a5a;
  --muted: #677487;
  --faint: #95a1b2;

  --success: #13804f;
  --success-bg: #e6f5ed;
  --warning: #9a5b00;
  --warning-bg: #fdf3e1;
  --danger: #c0352b;
  --danger-bg: #fbeceb;
  --info: #1f6fb2;
  --info-bg: #e8f1fa;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --container: 1240px;
  --header-h: 64px;
  --sidebar-w: 248px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; color: var(--text); font-weight: 650; }
h1 { font-size: 1.65rem; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
h4 { font-size: .95rem; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
code, kbd { font-family: var(--mono); font-size: .88em; background: var(--surface-3); padding: .1em .35em; border-radius: 4px; }
small { font-size: .85em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon { display: inline-block; vertical-align: -0.2em; flex-shrink: 0; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[x-cloak] { display: none !important; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.page { padding: 24px 0 48px; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--muted); margin: 4px 0 0; }
.breadcrumbs { font-size: .85rem; color: var(--muted); margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs span.sep { color: var(--faint); }

.stack > * + * { margin-top: var(--gap, 16px); }
.stack-sm { --gap: 8px; }
.stack-lg { --gap: 28px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, 10px); }
.split { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: var(--gap, 16px); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(var(--min, 220px), 1fr)); }
.with-sidebar { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.with-aside { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.sticky { position: sticky; top: calc(var(--header-h) + 16px); }
@media (max-width: 960px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .with-sidebar, .with-aside { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.4rem; }
}

/* ---------- Storefront header ---------- */
.notice-bar { background: var(--brand-700); color: #fff; font-size: .88rem; text-align: center; padding: 8px 16px; }
.notice-bar a { color: #fff; text-decoration: underline; }
.impersonation-bar { background: #fff4d6; border-bottom: 1px solid #f0d58c; color: #6b4a00; font-size: .9rem; padding: 8px 0; }
.impersonation-bar .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.site-header .bar { display: flex; align-items: center; gap: 20px; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand img { max-height: 40px; width: auto; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }
.header-search { flex: 1; max-width: 620px; display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px 0 14px; }
.header-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); background: #fff; }
.header-search input, .header-search input[type=search] { flex: 1; border: 0; background: transparent; padding: 10px 6px; font: inherit; min-width: 0; min-height: 0; outline: none; box-shadow: none; }
.header-search .btn-icon { border-radius: 999px; }
.header-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.lang-switch { margin: 0; }
.header-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; font-size: .92rem; position: relative; white-space: nowrap; }
.header-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.cart-count { position: absolute; top: 0; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; }
.category-nav { border-top: 1px solid var(--border); background: var(--surface); }
.category-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.category-nav ul::-webkit-scrollbar { display: none; }
.category-nav a { display: block; padding: 10px 12px; color: var(--text-2); font-size: .9rem; font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; }
.category-nav a:hover, .category-nav a.is-active { color: var(--brand); border-bottom-color: var(--brand); text-decoration: none; }
.mobile-only { display: none; }
@media (max-width: 860px) {
  .site-header .bar { flex-wrap: wrap; gap: 10px; padding: 10px 0; }
  .header-search { order: 3; flex-basis: 100%; max-width: none; }
  .header-link .label { display: none; }
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none !important; }
}

/* Dropdown (Alpine) */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font: inherit; font-size: .92rem; background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.dropdown-menu .divider { height: 1px; background: var(--border); margin: 6px 0; }
/* Real buttons inside dropdown forms keep their button look (not the menu-item style). */
.dropdown-menu .btn { display: inline-flex; width: auto; background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-border); justify-content: center; }
.dropdown-menu .btn-primary:hover { background: var(--brand-600); color: #fff; }
.dropdown-menu .btn-danger:hover { color: #fff; filter: brightness(.95); }
.dropdown-menu.align-left { right: auto; left: 0; }
.send-to { border: 1px solid var(--border); border-radius: var(--radius-sm, 8px); padding: 10px 12px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.send-to legend { font-size: .78rem; font-weight: 600; color: var(--muted); padding: 0 4px; }
.send-to .checkbox { display: flex; gap: 8px; align-items: flex-start; font-size: .88rem; }
.send-to .checkbox .sub { display: block; font-size: .75rem; color: var(--muted); }
.send-to input[type=text] { width: 100%; }
.dropdown-menu .menu-label { padding: 6px 10px 2px; font-size: .75rem; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); color: var(--muted); font-size: .9rem; padding: 32px 0; margin-top: 40px; }
.site-footer a { color: var(--text-2); }
.site-footer .cols { display: flex; flex-wrap: wrap; gap: 32px; justify-content: space-between; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li + li { margin-top: 6px; }

/* ---------- App shell (staff, rep, supplier) ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.app-sidebar { background: #101b29; color: #c9d3df; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.app-sidebar .brand { color: #fff; padding: 18px 18px 14px; }
.app-sidebar .brand:hover { color: #fff; }
.app-sidebar nav { padding: 6px 10px 20px; flex: 1; }
.app-sidebar .nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: #7d8ba0; padding: 16px 10px 6px; }
.app-sidebar a.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: #c9d3df; font-size: .92rem; }
.app-sidebar a.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.app-sidebar a.nav-link.is-active { background: var(--brand); color: #fff; }
.app-sidebar a.nav-link .nav-count { margin-left: auto; background: var(--warning, #b7791f); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 1px 8px; line-height: 1.5; }
.app-sidebar .sidebar-footer { padding: 12px 14px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; }
.app-sidebar .sidebar-footer a, .app-sidebar .sidebar-footer .btn-link { color: #c9d3df; font-size: inherit; }
.app-sidebar .sidebar-footer a:hover, .app-sidebar .sidebar-footer .btn-link:hover { color: #fff; }
.sidebar-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-user .avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .78rem; text-transform: uppercase; flex-shrink: 0; }
.sidebar-user .who { min-width: 0; line-height: 1.3; }
.sidebar-user .name { color: #fff; font-weight: 600; }
.sidebar-user .email { color: #7d8ba0; font-size: .76rem; }
.sidebar-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 10px; padding-left: 42px; }
.sidebar-links form { margin: 0; }
.sidebar-backdrop { display: none; }
.app-main { min-width: 0; display: flex; flex-direction: column; }
.app-topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 30; }
.app-topbar .topbar-search { flex: 1; max-width: 420px; position: relative; margin: 0; }
.app-topbar .topbar-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.app-topbar .topbar-search input { padding-left: 36px; min-height: 38px; background: var(--surface-2); border-color: var(--border); }
.app-topbar .topbar-search input:focus { background: var(--surface); border-color: var(--brand); }
.app-content { padding: 24px; flex: 1; }
.app-content.narrow { max-width: 1100px; }
.btn.sidebar-toggle { display: none; }
@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .app-sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 35, .45); }
  .btn.sidebar-toggle { display: inline-flex; }
  .app-content { padding: 16px; }
  .app-topbar { padding: 0 16px; }
}

/* Rep layout: bottom tab bar on phones */
.rep-tabs { display: none; }
@media (max-width: 960px) {
  .rep-shell .app-content { padding-bottom: 84px; }
  .rep-tabs { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 45; padding-bottom: env(safe-area-inset-bottom); }
  .rep-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: .72rem; color: var(--muted); }
  .rep-tabs a.is-active { color: var(--brand); }
  .rep-tabs a:hover { text-decoration: none; }
}

/* Auth layout */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 32px 16px; background: linear-gradient(160deg, var(--brand-50), var(--bg) 55%); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 720px; }
.auth-card .brand { justify-content: center; margin-bottom: 20px; font-size: 1.2rem; }

/* ---------- Buttons ---------- */
.btn { --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; min-height: 40px;
  border-radius: var(--radius-sm); border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { text-decoration: none; color: var(--btn-fg); background: color-mix(in srgb, var(--btn-bg) 92%, black); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { --btn-bg: var(--brand); --btn-fg: #fff; --btn-border: var(--brand); }
.btn-primary:hover { background: var(--brand-600); }
.btn-accent { --btn-bg: var(--accent); --btn-fg: #fff; --btn-border: var(--accent); }
.btn-secondary { --btn-bg: var(--brand-50); --btn-fg: var(--brand-700); --btn-border: var(--brand-100); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: var(--danger); }
.btn-danger-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn-lg { padding: 12px 22px; min-height: 48px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; min-height: 36px; min-width: 36px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
label, .label { display: block; font-weight: 600; font-size: .88rem; color: var(--text-2); margin-bottom: 5px; }
.required-mark { color: var(--danger); margin-left: 2px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url],
input[type=search], input[type=date], input[type=datetime-local], input[type=time], input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; min-height: 40px; font: inherit; font-size: .95rem; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
input[type=file] { padding: 7px; }
textarea { min-height: 90px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23677487' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
select[multiple] { background-image: none; padding-right: 12px; min-height: 120px; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--brand); vertical-align: -3px; margin: 0 6px 0 0; }
.checkbox { display: flex; align-items: flex-start; gap: 4px; font-weight: 500; color: var(--text); }
.form-field { margin-bottom: 16px; }
.form-field .help { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.form-field.has-error input, .form-field.has-error select, .form-field.has-error textarea { border-color: var(--danger); }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--danger); font-size: .84rem; }
.errorlist.nonfield { background: var(--danger-bg); padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } .form-grid .span-2 { grid-column: auto; } }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.input-group { display: flex; }
.input-group > input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* Quantity stepper */
.qty { display: inline-flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.qty button { width: 34px; border: 0; background: var(--surface-2); color: var(--text-2); cursor: pointer; font-size: 1.1rem; }
.qty button:hover { background: var(--surface-3); }
.qty input { width: 64px; min-height: 36px; border: 0; border-radius: 0; text-align: center; padding: 6px 4px; box-shadow: none !important; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-flush .card-body { padding: 0; }
.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* Stat tiles */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .stat-delta { font-size: .85rem; margin-top: 2px; }
.stat .stat-delta.up { color: var(--success); }
.stat .stat-delta.down { color: var(--danger); }

/* Progress */
.progress { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; } /* relative: absolutely positioned labels (.sr-only) stay inside the scroller */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; background: var(--surface); }
.table th { text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table-compact td, .table-compact th { padding: 7px 10px; }
.table tfoot td { font-weight: 600; background: var(--surface-2); }
.card > .table-wrap .table, .card > .table { border-radius: 0 0 var(--radius) var(--radius); }
.sortable a { color: inherit; }

/* Definition list */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: .93rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* Totals box */
.totals { width: 100%; font-size: .95rem; }
.totals td { padding: 5px 0; }
.totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals tr.grand td { font-size: 1.15rem; font-weight: 700; border-top: 1px solid var(--border); padding-top: 10px; }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; line-height: 1.6; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: #bfe3cf; }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: #f1d9a8; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: #f2c4c0; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: #c6dcf0; }
.badge-neutral { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.badge-brand { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.badge-deal { background: #fff1e6; color: #b4480a; border-color: #f7cfae; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; font-size: .93rem; }
.alert-success { background: var(--success-bg); color: #0d5c39; border-color: #bfe3cf; }
.alert-warning { background: var(--warning-bg); color: #6f4200; border-color: #f1d9a8; }
.alert-error, .alert-danger { background: var(--danger-bg); color: #8f241c; border-color: #f2c4c0; }
.alert-info { background: var(--info-bg); color: #164f80; border-color: #c6dcf0; }
.messages { margin: 16px 0 0; }

/* ---------- Product cards ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.product-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s; }
.product-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.product-card .thumb { height: 160px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; position: relative; }
.product-card .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.product-card .thumb .badges { position: absolute; top: 8px; left: 8px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.product-card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card .sku { font-size: .76rem; color: var(--muted); font-family: var(--mono); }
.product-card .name { font-weight: 600; color: var(--text); line-height: 1.3; }
.product-card .name:hover { color: var(--brand); }
.product-card .foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.placeholder-img { color: var(--faint); }
.product-list .row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.product-list .row img { width: 64px; height: 64px; object-fit: contain; background: var(--surface-2); border-radius: var(--radius-sm); }

/* Prices */
.price { font-weight: 700; font-size: 1.1rem; color: var(--text); font-variant-numeric: tabular-nums; }
.price-lg { font-size: 1.6rem; }
.price-old { color: var(--faint); text-decoration: line-through; font-size: .88rem; margin-left: 6px; font-weight: 500; }
.price-unit { color: var(--muted); font-size: .82rem; font-weight: 500; }
.price-hidden { color: var(--muted); font-size: .88rem; }
.breaks { font-size: .82rem; color: var(--text-2); }
.breaks table td { padding: 2px 10px 2px 0; }

/* ---------- Tabs, pagination, empty states ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: .92rem; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .is-active { color: var(--brand); border-bottom-color: var(--brand); }
.pagination { display: flex; gap: 4px; justify-content: center; align-items: center; margin: 24px 0 0; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 36px; height: 36px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .9rem; }
.pagination a:hover { border-color: var(--brand); text-decoration: none; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .icon { color: var(--faint); margin-bottom: 8px; }
.empty h3 { color: var(--text-2); }

/* Filters sidebar */
.filters { font-size: .92rem; }
.filters h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.filters ul { list-style: none; margin: 0; padding: 0; }
.filters li a { display: block; padding: 5px 8px; border-radius: var(--radius-sm); color: var(--text-2); }
.filters li a:hover { background: var(--surface-3); text-decoration: none; }
.filters li a.is-active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar select, .toolbar input { width: auto; min-height: 36px; padding-top: 6px; padding-bottom: 6px; }

/* Hero / banners */
.hero { border-radius: var(--radius-lg); overflow: hidden; position: relative; background: linear-gradient(120deg, var(--brand-700), var(--brand)); color: #fff; min-height: 220px; display: flex; align-items: center; }
.hero img.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .35; }
.hero .hero-body { position: relative; padding: 36px; max-width: 640px; }
.hero h1, .hero h2 { color: #fff; font-size: 2rem; }
.hero p { font-size: 1.05rem; opacity: .92; }
.tile { border-radius: var(--radius); padding: 20px; background: var(--brand-50); border: 1px solid var(--brand-100); }

/* Modal (Alpine) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 35, .5); z-index: 80; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Barcode scanner */
.scanner-video { width: 100%; border-radius: var(--radius); background: #000; aspect-ratio: 4 / 3; object-fit: cover; }
.scanner-hint { color: var(--muted); font-size: .88rem; margin-top: 8px; text-align: center; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: #17202b; color: #fff; padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .92rem; max-width: 360px; }
@media (max-width: 640px) { .toasts { left: 16px; right: 16px; bottom: 90px; } }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 16px 12px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }
.timeline .when { font-size: .8rem; color: var(--muted); }

/* Signature pad */
.signature-pad { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fff; width: 100%; height: 180px; touch-action: none; }

/* ---------- Utilities ---------- */
.text-muted { color: var(--muted) !important; }
.text-faint { color: var(--faint); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: .87rem; }
.text-xs { font-size: .78rem; }
.text-lg { font-size: 1.1rem; }
.font-mono { font-family: var(--mono); }
.fw-600 { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-0 { margin: 0 !important; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; } .mt-5 { margin-top: 40px; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.p-0 { padding: 0 !important; }
.w-full { width: 100%; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .flex-wrap { flex-wrap: wrap; } .flex-1 { flex: 1; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@media (max-width: 640px) { .hide-sm { display: none !important; } }

/* Print */
@media print {
  .site-header, .site-footer, .app-sidebar, .app-topbar, .rep-tabs, .notice-bar, .impersonation-bar, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .app-shell { display: block; }
  .card { box-shadow: none; }
}

/* Invisible CAPTCHA: Google allows hiding the badge when the reCAPTCHA notice is shown on the form. */
.grecaptcha-badge { visibility: hidden; }

/* Cart quantity boxes (catalog): the box shows what's in the cart and updates it on change. */
.cart-qty { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.cart-qty .cart-qty-state { display: none; align-items: center; gap: 3px; font-size: .78rem; font-weight: 600; color: var(--success); }
.cart-qty.in-cart .cart-qty-state { display: inline-flex; }
.cart-qty.in-cart .qty { border-color: var(--success); box-shadow: 0 0 0 2px var(--success-bg); }
.cart-qty.htmx-request .qty { opacity: .7; }

/* Product thumbnails anywhere: the frame has a fixed size and the picture is fitted inside it, never cropped
   (percentage heights inside grid frames are not reliable, so the image is positioned against the frame). */
.pr-thumb, .pd-thumbs a, .o-thumb, .ra-thumb { position: relative; }
.pr-thumb img, .pd-thumbs a img, .o-thumb img, .ra-thumb img {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: contain; }
.price-request { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text-2); }
.price-request.price-lg { font-size: 1.35rem; }
.shipment-summary { display: flex; gap: 8px; align-items: center; font-size: .86rem; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 10px; }
.line-pallets { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: .8rem; color: var(--text-2); margin-top: 4px; }
.pack-info { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: .74rem; color: var(--text-2); }
.pack-info span { background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; line-height: 1.6; white-space: nowrap; }

/* Header search suggestions */
.header-search { position: relative; }
.search-suggest { display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; }
.search-suggest.is-open { display: block; }
.suggest-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; max-height: min(70vh, 560px); overflow-y: auto; }
.suggest-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; padding: 8px 10px 4px; }
.suggest-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text); }
.suggest-item:hover, .suggest-item.is-active, .suggest-chip:hover, .suggest-chip.is-active, .suggest-all:hover, .suggest-all.is-active { background: var(--brand-50); text-decoration: none; color: var(--text); }
.suggest-thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--surface-2); position: relative; display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.suggest-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.suggest-text { min-width: 0; display: flex; flex-direction: column; }
.suggest-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-meta { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-price { font-weight: 700; font-size: .9rem; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.suggest-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 8px; }
.suggest-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .84rem; color: var(--text-2); }
.suggest-all { display: flex; align-items: center; gap: 6px; padding: 10px; border-top: 1px solid var(--border); margin-top: 4px; font-weight: 600; font-size: .88rem; color: var(--brand); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.suggest-empty { padding: 14px 10px; color: var(--muted); font-size: .9rem; }
@media (max-width: 860px) { .search-suggest { left: -4px; right: -4px; } .suggest-item { grid-template-columns: 40px minmax(0, 1fr) auto; } }

/* "Continue with Google" (Google sign-in branding: white button, coloured G) */
.btn.btn-google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; gap: 10px; }
.btn.btn-google:hover { background: #f8f9fa; border-color: #c6c9ce; text-decoration: none; }

/* Top-bar search suggestions (staff) */
.topbar-suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; min-width: 320px; max-height: 70vh; overflow-y: auto; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); padding: 6px 0; }
.topbar-suggest .ts-group { padding: 8px 14px 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.topbar-suggest .ts-item { display: flex; gap: 10px; align-items: baseline; padding: 7px 14px; color: var(--text); text-decoration: none; }
.topbar-suggest .ts-item:hover, .topbar-suggest .ts-item.is-active { background: var(--surface-2); }
.topbar-suggest .ts-label { font-weight: 600; white-space: nowrap; }
.topbar-suggest .ts-sub { color: var(--text-2, var(--faint)); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Back office: sticky section pills (static/js/section_pills.js) */
.section-pills { position: sticky; top: 56px; z-index: 20; display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; margin: 0 0 12px; background: var(--bg, var(--surface)); scrollbar-width: none; }
.section-pills::-webkit-scrollbar { display: none; }
.section-pills a { flex: none; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .82rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.section-pills a:hover { border-color: var(--brand); color: var(--brand); }
.section-pills a.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
[id^="section-"], .card[id], fieldset[id] { scroll-margin-top: 120px; }
@media (max-width: 640px) { .topbar-storefront span { display: none; } }
.topbar-qb-errors { background: var(--danger-bg, #fde8e7); color: var(--danger, #b42318); border-color: transparent; font-weight: 600; }
.topbar-qb-errors:hover { filter: brightness(.97); color: var(--danger, #b42318); }
@media (max-width: 640px) { .topbar-qb-errors span { display: none; } }

/* Phones: wide data tables stacked as cards (static/js/app.js adds .auto-stack and the data-label of each cell). */
@media (max-width: 640px) {
  table.auto-stack, table.auto-stack > tbody, table.auto-stack > tfoot, table.auto-stack > tbody > tr, table.auto-stack > tfoot > tr { display: block; width: 100%; }
  table.auto-stack > thead { display: none; }
  table.auto-stack > tbody > tr, table.auto-stack > tfoot > tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  table.auto-stack > tbody > tr > td, table.auto-stack > tfoot > tr > td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; padding: 3px 0 !important; border: 0 !important; text-align: right; white-space: normal; min-width: 0; }
  table.auto-stack > tbody > tr > td::before, table.auto-stack > tfoot > tr > td::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; color: var(--text-muted, #677487); font-size: .75rem; font-weight: 600; text-align: left; }
  table.auto-stack > tbody > tr > td:first-child { display: block; text-align: left; font-weight: 600; padding-bottom: 6px !important; }
  table.auto-stack > tbody > tr > td:first-child::before { display: none; }
  table.auto-stack > tbody > tr > td:empty, table.auto-stack > tbody > tr > td:not([data-label]):not(:first-child):not(.auto-stack-wide):empty { display: none; }
  table.auto-stack td.auto-stack-wide { display: block; text-align: left; }
  table.auto-stack td.auto-stack-wide::before { display: none; }
  table.auto-stack td, table.auto-stack td * { white-space: normal !important; overflow-wrap: anywhere; }
  table.auto-stack td > * { max-width: 100%; }
  table.auto-stack > tbody > tr > td.auto-stack-block { display: block; text-align: left; }
  table.auto-stack > tbody > tr > td.auto-stack-block::before { display: block; max-width: none; margin-bottom: 2px; }
  table.auto-stack td.auto-stack-block input[type=text], table.auto-stack td.auto-stack-block input[type=number] { max-width: 100%; }
  table.auto-stack td.actions, table.auto-stack td.num:not([data-label]) { justify-content: flex-end; }
  table.auto-stack td input[type=text], table.auto-stack td input[type=number] { max-width: 60%; }
  .table-wrap:has(> table.auto-stack) { overflow-x: visible; }
}
