/* Utopia POS — web terminal. Tokens first; dark mode, palettes and the
   appearance options (end of file) redefine them. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --surface-3: #e3e6eb;
  --border: #d5d9e0;
  --text: #161b22;
  --text-2: #4b5563;
  --text-3: #636b78;
  /* Utopia blue (from the logo, darkened slightly so white text on it reads well) */
  --accent: #2f5e9e;
  --accent-hover: #264d83;
  --accent-soft: #e4ecf7;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --ok: #1b5e20;
  --ok-soft: #e2f0e1;
  --focus: #3a6fb8;
  --chart-1: #2f5e9e;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 18%);
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  --header-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  --zoom: 1;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1217;
    --surface: #171b21;
    --surface-2: #1e232b;
    --surface-3: #272d36;
    --border: #303742;
    --text: #e7eaee;
    --text-2: #aeb6c1;
    --text-3: #828c99;
    --accent: #7aa2e2;
    --accent-hover: #96b7ea;
    --accent-soft: #1d2a3e;
    --on-accent: #0b1526;
    --danger: #ff8a80;
    --danger-soft: #3a1d1b;
    --warn: #f5c060;
    --warn-soft: #3a2f17;
    --ok: #7ccf83;
    --ok-soft: #1f3322;
    --focus: #96b7ea;
    --chart-1: #6a92d4;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-lg: 0 12px 40px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1217;
  --surface: #171b21;
  --surface-2: #1e232b;
  --surface-3: #272d36;
  --border: #303742;
  --text: #e7eaee;
  --text-2: #aeb6c1;
  --text-3: #828c99;
  --accent: #7aa2e2;
  --accent-hover: #96b7ea;
  --accent-soft: #1d2a3e;
  --on-accent: #0b1526;
  --danger: #ff8a80;
  --danger-soft: #3a1d1b;
  --warn: #f5c060;
  --warn-soft: #3a2f17;
  --ok: #7ccf83;
  --ok-soft: #1f3322;
  --focus: #96b7ea;
  --chart-1: #6a92d4;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 60%);
  color-scheme: dark;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  /* text size option: everything scales together (percent heights still fill the screen) */
  zoom: var(--zoom);
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: 13px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#app {
  height: 100%;
}

/* The hidden attribute must win over component display rules. */
[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------ boot */

.boot {
  height: 100%;
  display: grid;
  place-items: center;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.spinner.sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s, transform 0.06s;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover {
  background: var(--surface-2);
}

.btn.danger {
  color: var(--danger);
}

.btn.lg {
  min-height: 52px;
  font-size: 17px;
  padding: 0 20px;
}

.btn.block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  flex: none;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn.sm {
  width: 32px;
  height: 32px;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input.invalid {
  border-color: var(--danger);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap .input {
  padding-right: 48px;
}

.input-wrap .icon-btn {
  position: absolute;
  right: 4px;
}

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

.alert.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}

.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  min-height: 44px;
  white-space: nowrap;
  padding: 0 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------ login */

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px var(--gutter);
  overflow-y: auto;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
  display: grid;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  flex: none;
}

.brand-mark .icon {
  width: 26px;
  height: 26px;
}

img.brand-mark {
  background: none;
  display: block;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p {
  margin: 2px 0 0;
  color: var(--text-2);
  font-size: 14px;
}

.login-foot {
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

/* -------------------------------------------------------- shop pick */

.shop-list {
  display: grid;
  gap: 8px;
}

.shop-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.shop-option:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.shop-option strong {
  display: block;
}

/* ------------------------------------------------------------- shell */

.shell {
  height: 100%;
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 0 var(--gutter);
  padding-top: env(safe-area-inset-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.topbar .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.topbar .brand-mark .icon {
  width: 18px;
  height: 18px;
}

.topbar-title {
  min-width: 0;
  display: grid;
  line-height: 1.2;
}

.topbar-title strong {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title span {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .spacer {
  flex: 1;
}

.menu {
  position: relative;
}

.menu-panel {
  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: 30;
  display: grid;
}

.menu-panel .who {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.menu-panel button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.menu-panel button:hover {
  background: var(--surface-2);
}

/* --------------------------------------------------------------- POS */

.pos {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
}

.catalog {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  border-right: 1px solid var(--border);
}

.search-bar {
  padding: 12px var(--gutter) 8px;
  display: flex;
  gap: 8px;
}

.search-box {
  flex: 1;
  position: relative;
}

.search-box > .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-box .input {
  min-height: 48px;
  padding-left: 42px;
  padding-right: 44px;
  font-size: 16px;
}

.search-box .icon-btn {
  position: absolute;
  right: 4px;
  top: 4px;
}

.catalog-meta {
  padding: 0 var(--gutter) 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  min-height: 26px;
}

.catalog-meta .spacer {
  flex: 1;
}

.catalog-meta > span {
  white-space: nowrap;
}

/* phones: the swipe tip matters more than the catalog age */
@media (max-width: 520px) {
  .catalog-meta .meta-updated {
    display: none;
  }
}

.results {
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--gutter) 16px;
  overscroll-behavior: contain;
}

.product {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}

.product.active {
  border-color: var(--accent);
}

@media (hover: hover) {
  .product:hover {
    border-color: var(--accent);
  }
}

.product.active {
  background: var(--accent-soft);
}

.product.unavailable {
  opacity: 0.55;
}

.product-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-codes {
  grid-column: 1;
  font-size: 13px;
  color: var(--text-2);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-fits {
  grid-column: 1;
  font-size: 13px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-price {
  grid-column: 2;
  grid-row: 1;
  text-align: right;
  font-weight: 700;
}

.product-stock {
  grid-column: 2;
  grid-row: 2 / span 2;
  justify-self: end;
  align-self: start;
}

mark {
  background: var(--warn-soft);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.empty {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  padding: 48px 16px;
  color: var(--text-2);
}

.empty .icon {
  width: 40px;
  height: 40px;
  color: var(--text-3);
  stroke-width: 1.5;
}

.empty strong {
  color: var(--text);
}

/* ------------------------------------------------------------- cart */

.cart {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--surface);
}

.cart-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 12px var(--gutter);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}

.cart-head h2 {
  margin: 0;
  font-size: 16px;
  flex: 1;
}

.cart-lines {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  padding: 12px var(--gutter);
  border-bottom: 1px solid var(--border);
}

.line.flash {
  animation: flash 0.6s ease-out;
}

@keyframes flash {
  from {
    background: var(--accent-soft);
  }
  to {
    background: transparent;
  }
}

.line-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-sub {
  font-size: 13px;
  color: var(--text-2);
}

.line-total {
  text-align: right;
  font-weight: 700;
}

.line-controls {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stepper button {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--text);
}

.stepper button:hover {
  background: var(--surface-3);
}

.stepper input {
  width: 64px;
  height: 36px;
  border: none;
  text-align: center;
  background: var(--surface);
  font-weight: 600;
}

.stepper input:focus {
  outline: none;
  background: var(--accent-soft);
}

.price-input {
  width: 120px;
  height: 36px;
  min-height: 36px;
  text-align: right;
}

.line-warn {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--warn);
}

.line-controls .spacer {
  flex: 1;
}

.cart-extra {
  padding: 8px var(--gutter);
  border-top: 1px solid var(--border);
}

.cart-extra summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: 14px;
  padding: 6px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-extra summary::-webkit-details-marker {
  display: none;
}

.cart-extra .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px 0 4px;
}

.cart-extra .grid .wide {
  grid-column: 1 / -1;
}

.cart-extra .input {
  min-height: 40px;
}

.totals {
  padding: 12px var(--gutter) calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 4px;
}

.totals .row {
  display: flex;
  justify-content: space-between;
  color: var(--text-2);
  font-size: 14px;
}

.totals .row.grand {
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  margin: 4px 0 10px;
}

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

.kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid currentColor;
  opacity: 0.7;
}

/* Mobile: products full screen, cart as a sheet. */
.cart-bar {
  display: none;
}

.cart-close {
  display: none;
}

@media (max-width: 899px) {
  .pos {
    grid-template-columns: minmax(0, 1fr);
  }

  .catalog {
    border-right: none;
    grid-template-rows: auto auto 1fr auto;
  }

  .cart {
    position: fixed;
    inset: 0;
    z-index: 20;
    transform: translateY(100%);
    transition: transform 0.22s ease;
    visibility: hidden;
    padding-top: env(safe-area-inset-top);
  }

  .cart.open {
    transform: none;
    visibility: visible;
  }

  .cart-close {
    display: inline-grid;
  }

  .cart-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 var(--gutter) calc(12px + env(safe-area-inset-bottom));
    padding: 0 8px 0 16px;
    min-height: 56px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
  }

  .cart-bar:disabled {
    background: var(--surface-3);
    color: var(--text-3);
    box-shadow: none;
    cursor: default;
  }

  .cart-bar .count {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgb(255 255 255 / 22%);
    display: grid;
    place-items: center;
    font-size: 14px;
  }

  .cart-bar .grow {
    flex: 1;
    text-align: left;
  }

  .hide-mobile {
    display: none !important;
  }

  .totals .actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar-title span {
    display: none;
  }

  .segmented .icon {
    display: none;
  }


  .cart-extra .grid {
    grid-template-columns: 1fr;
  }
}

/* ----------------------------------------------------------- dialogs */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(10 15 12 / 45%);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade 0.15s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.dialog {
  width: 100%;
  max-width: 460px;
  max-height: calc(100% - 16px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: grid;
  animation: rise 0.18s ease-out;
}

.dialog.wide {
  max-width: 640px;
}

@keyframes rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 8px 8px 20px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
  flex: 1;
}

.dialog-body {
  padding: 8px 20px 16px;
  display: grid;
  gap: 16px;
}

.dialog-foot {
  padding: 12px 20px 20px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.dialog-foot .btn {
  flex: 1;
}

@media (max-width: 520px) {
  .overlay {
    padding: 0;
    align-items: end;
  }

  .dialog {
    max-width: none;
    border-radius: 16px 16px 0 0;
    max-height: 100%;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

.due {
  text-align: center;
  padding: 8px 0 4px;
}

.due span {
  display: block;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.due strong {
  font-size: 34px;
  line-height: 1.2;
}

.tender .input {
  min-height: 56px;
  font-size: 24px;
  font-weight: 700;
  text-align: right;
}

.quick-cash {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.quick-cash .btn {
  padding: 0 8px;
}

.change {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-weight: 600;
}

.change strong {
  font-size: 22px;
}

.change.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.change.short {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ----------------------------------------------------------- receipt */

.receipt {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
}

.receipt .center {
  text-align: center;
}

.receipt h3 {
  margin: 0;
  font-size: 15px;
}

.receipt hr {
  border: none;
  border-top: 1px dashed var(--text-3);
  margin: 10px 0;
}

.receipt .r {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.receipt .r > :last-child {
  text-align: right;
  white-space: nowrap;
}

.receipt .item-name {
  overflow-wrap: anywhere;
}

.receipt .big {
  font-size: 16px;
  font-weight: 700;
}

.receipt .stamp {
  margin-top: 6px;
  text-align: center;
  font-weight: 700;
  color: var(--warn);
}

.done-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 600;
}

.done-banner.offline {
  background: var(--warn-soft);
  color: var(--warn);
}

.done-banner .icon {
  width: 28px;
  height: 28px;
}

/* ---------------------------------------------------------- history */

.history-list {
  display: grid;
  gap: 6px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-item .no {
  font-family: var(--mono);
  font-weight: 600;
}

.history-item .amt {
  text-align: right;
  font-weight: 700;
}

.history-item .meta {
  font-size: 13px;
  color: var(--text-2);
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 4px 0 -4px;
}

/* ------------------------------------------------------------ scanner */

.scanner video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* ------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(440px, calc(100% - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  pointer-events: auto;
  animation: rise 0.18s ease-out;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast .grow {
  flex: 1;
}

.toast button {
  border: none;
  background: transparent;
  color: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
  text-decoration: underline;
}

/* -------------------------------------------------------------- print */

#print-root {
  display: none;
}

@media print {
  @page {
    margin: 4mm;
  }

  body {
    background: #fff;
    color: #000;
    overflow: visible;
  }

  body > *:not(#print-root) {
    display: none !important;
  }

  #print-root {
    display: block;
    width: 72mm;
  }

  #print-root .receipt {
    background: #fff;
    color: #000;
    padding: 0;
    font-size: 11px;
  }

  #print-root .receipt .stamp {
    color: #000;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----------------------------------------------------------- extras */

.icon.sm {
  width: 16px;
  height: 16px;
}

.grow {
  flex: 1;
  min-width: 0;
}

.shop-option .grow {
  display: grid;
}

.status-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

button.pill {
  border: none;
  cursor: pointer;
}

.line-warn {
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-item .actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.history-item .btn {
  min-height: 32px;
  padding: 0 10px;
}

@media (max-width: 520px) {
  .quick-cash {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ============================================================ stock */

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-left: 8px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.stock-screen {
  min-height: 0;
  display: grid;
}

.stock-view {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.stock-head {
  display: grid;
  gap: 10px;
  padding: 12px var(--gutter) 8px;
}

.stock-toolbar {
  display: flex;
  gap: 8px;
}

.stock-toolbar .search-box {
  flex: 1;
  min-width: 0;
}

.location-pick {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 260px;
  min-width: 0;
}

.location-pick > .icon {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  pointer-events: none;
}

.location-pick select {
  min-height: 48px;
  padding-left: 40px;
  font-weight: 600;
}

select.input {
  appearance: auto;
  cursor: pointer;
}

.stock-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.tile {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.tile span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.tile strong {
  font-size: 20px;
  line-height: 1.2;
}

.tile.ok strong {
  color: var(--ok);
}

.tile.warn strong {
  color: var(--warn);
}

.tile.danger strong {
  color: var(--danger);
}

.stock-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stock-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stock-filter .catalog-meta {
  flex: 1;
  padding: 0;
  min-width: 140px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.chip-count {
  font-size: 12px;
  color: var(--text-3);
}

.stock-list {
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--gutter) 24px;
  overscroll-behavior: contain;
}

.stock-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 120px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .stock-row:hover {
    border-color: var(--accent);
  }
}

.stock-main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.stock-qty {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
}

.stock-qty strong {
  font-size: 20px;
}

.stock-state {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.neg {
  color: var(--danger);
}

.qty-in {
  color: var(--ok);
}

.qty-out {
  color: var(--text);
}

.mono {
  font-family: var(--mono);
}

.center {
  text-align: center;
}

/* product sheet */

.product-facts {
  display: grid;
  gap: 4px;
  margin-top: -8px;
}

.facts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.card .section-label {
  margin: 0 0 2px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.kv span {
  color: var(--text-2);
}

.kv.total {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 2px;
}

.move-list {
  display: grid;
  gap: 4px;
}

.move {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.move-main {
  display: grid;
  min-width: 0;
}

.move-type {
  justify-self: start;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text-2);
}

.move-type.return,
.move-type.grn {
  background: var(--ok-soft);
  color: var(--ok);
}

.move-type.sale {
  background: var(--accent-soft);
  color: var(--text);
}

.move-type.adjustment {
  background: var(--warn-soft);
  color: var(--warn);
}

/* document editor */

.dialog.doc-editor {
  max-width: 820px;
}

.doc-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.doc-fields.transfer {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.doc-fields .wide,
.form-grid .wide {
  grid-column: 1 / -1;
}

.doc-fields .swap {
  margin-bottom: 2px;
}

.finder {
  position: relative;
}

.finder .search-box .input {
  min-height: 48px;
}

.matches {
  display: grid;
  gap: 2px;
  margin-top: 4px;
}

.matches:empty {
  display: none;
}

.match {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
}

.match.active,
.match:hover {
  border-color: var(--accent);
}

.doc-lines {
  display: grid;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.doc-lines .empty {
  padding: 28px 16px;
}

.doc-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.doc-line:last-child {
  border-bottom: none;
}

.doc-line.flash {
  animation: flash 0.6s ease-out;
}

.doc-line-main {
  display: grid;
  min-width: 0;
}

.doc-line-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-totals {
  display: grid;
  margin-right: auto;
  align-self: center;
  font-size: 14px;
  color: var(--text-2);
}

.doc-totals strong {
  color: var(--text);
  font-size: 17px;
}

.dialog.doc-editor .dialog-foot .btn,
.dialog.wide .dialog-foot .btn {
  flex: 0 0 auto;
}

.doc-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text-2);
}

.doc-badge.grn {
  background: var(--ok-soft);
  color: var(--ok);
}

.doc-badge.adjustment {
  background: var(--warn-soft);
  color: var(--warn);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.btn.primary.danger-fill {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

@media (max-width: 899px) {
  .tab {
    padding: 0 10px;
  }
}

@media (max-width: 700px) {
  .stock-toolbar {
    flex-direction: column;
  }

  .location-pick {
    flex-basis: auto;
  }

  .stock-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
  }

  .stock-main {
    grid-row: 1 / span 2;
  }

  .stock-qty {
    grid-column: 2;
    grid-row: 1;
  }

  .stock-state {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .stock-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stock-actions .btn {
    padding: 0 10px;
  }

  .tile.value {
    grid-column: 1 / -1;
  }

  .doc-line .stepper {
    justify-self: start;
  }

  .dialog.doc-editor .dialog-foot {
    flex-wrap: wrap;
  }

  .dialog.doc-editor .dialog-foot .doc-totals {
    flex-basis: 100%;
  }

  .dialog.doc-editor .dialog-foot .btn {
    flex: 1 1 0;
  }

  .doc-fields,
  .doc-fields.transfer,
  .facts-grid,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .doc-fields .swap {
    justify-self: center;
    transform: rotate(90deg);
  }

  .doc-line {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .doc-line-main {
    grid-column: 1 / -1;
  }

  .move {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .move-type {
    grid-column: 1 / -1;
  }

  .stock-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .tabs {
    margin-left: 0;
  }

  .topbar-title {
    display: none;
  }

  .tab .icon {
    display: none;
  }
}

/* dropdown + "New" button in the product form */
.select-add {
  display: flex;
  gap: 8px;
}

.select-add select {
  flex: 1;
  min-width: 0;
}

.btn.add-new {
  flex: none;
  min-height: 44px;
  padding: 0 12px;
  gap: 4px;
  color: var(--accent);
  border-color: var(--accent);
}

.btn.add-new:disabled {
  color: var(--text-3);
  border-color: var(--border);
}

/* ---------------------------------------------------------- printing */

.receipt .b {
  font-weight: 700;
}

.receipt .right {
  text-align: right;
}

.receipt .feed {
  height: 1em;
}

.receipt .r > :first-child {
  overflow-wrap: anywhere;
}

/* off-screen copy used to measure a ticket at the paper width */
.print-probe {
  position: absolute;
  left: -10000px;
  top: 0;
  visibility: hidden;
}

.print-probe .receipt,
#print-root .receipt {
  background: #fff;
  color: #000;
  padding: 0;
  font-size: 11px;
}

.method-list {
  display: grid;
  gap: 8px;
}

.method {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.method.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.method input,
.check input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: none;
}

.method span,
.check span {
  display: grid;
  gap: 2px;
}

.method:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.direct-only {
  display: grid;
  gap: 12px;
}

textarea.input {
  min-height: 64px;
  padding: 10px 12px;
  resize: vertical;
}

.input.static {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
}

/* --------------------------------------------------------- combo box */

.combo {
  position: relative;
}

.combo .combo-input {
  padding-right: 40px;
}

.combo-toggle {
  position: absolute;
  right: 2px;
  top: 2px;
  bottom: 2px;
  width: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.combo-toggle:disabled {
  cursor: not-allowed;
}

.combo-caret {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: translateY(-2px) rotate(45deg);
}

.combo-list {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

.combo-option {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.combo-option[aria-selected="true"] {
  font-weight: 700;
}

.combo-option.active {
  background: var(--accent-soft);
}

.combo-none {
  color: var(--text-2);
}

.combo-add {
  color: var(--accent);
  font-weight: 700;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

/* ------------------------------------------------------------- photos */

.photo-field {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.photo-preview {
  width: 112px;
  height: 112px;
  flex: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-3);
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.opening {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 8px;
}

/* list thumbnails: the row keeps its layout, the picture sits in a left gutter */
.product.has-thumb,
.stock-row.has-thumb {
  position: relative;
  padding-left: 76px;
}

/* sell list: swipe a row right to add it; the green strip shows underneath */
.product-item {
  position: relative;
  margin-bottom: 6px;
  border-radius: var(--radius);
  --swipe: 0;
}

.product-item > .product {
  position: relative;
  margin-bottom: 0;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.product-item > .product.settling {
  transition: transform 0.18s ease-out, border-color 0.12s, background-color 0.12s;
}

.product-item.swiping > .product {
  cursor: grabbing;
  box-shadow: var(--shadow, 0 2px 8px rgb(0 0 0 / 0.12));
}

.swipe-hint {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  gap: 8px;
  padding-left: 18px;
  border-radius: var(--radius);
  background: var(--ok-soft, var(--accent-soft));
  color: var(--ok);
  font-weight: 700;
  opacity: calc(0.35 + var(--swipe) * 0.65);
}

.product-item.swiping > .swipe-hint {
  display: flex;
}

.product-item.armed > .swipe-hint {
  background: var(--ok);
  color: var(--surface);
}

.swipe-tip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--text-3);
  white-space: nowrap;
}

/* cart lines: the photo opens the product preview */
.line-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.line-text {
  min-width: 0;
}

.line-thumb {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  cursor: zoom-in;
}

.line-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.line-thumb:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.photo-dialog .photo-full {
  display: block;
  width: 100%;
  max-height: min(calc(60vh / var(--zoom)), 520px);
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.photo-none {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 28px 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 13px;
}

.photo-none .icon {
  width: 32px;
  height: 32px;
}

.photo-facts {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.photo-facts-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.photo-facts-side {
  display: grid;
  gap: 6px;
  justify-items: end;
  flex-shrink: 0;
}

.photo-price {
  font-size: 18px;
}

.thumb {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-2);
}

.product-photo {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.confirm-body {
  display: grid;
  gap: 10px;
}

.confirm-body p {
  margin: 0;
  color: var(--text-2);
}

.history-item.has-thumb {
  position: relative;
  padding-left: 76px;
}

.deleted-item .no {
  font-family: var(--font);
}

.deleted-item {
  align-items: center;
}

/* ===================================== stock screen: compact header ===
   Location + search share one row; summary lives in the filter chips; the
   actions stay on one (scrollable) row, so the list gets most of the height. */

.stock-head {
  gap: 8px;
  padding: 10px var(--gutter) 8px;
  border-bottom: 1px solid var(--border);
}

.stock-toolbar {
  flex-direction: row;
  align-items: stretch;
}

.location-pick select,
.stock-toolbar .search-box .input {
  min-height: 44px;
}

.stock-toolbar .search-box .icon-btn {
  top: 2px;
}

.stock-actions {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 6px;
}

.stock-actions::-webkit-scrollbar,
.stock-filter .chips::-webkit-scrollbar {
  display: none;
}

.stock-actions .btn {
  flex: none;
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
  gap: 6px;
}

.stock-actions .btn .icon {
  width: 18px;
  height: 18px;
}

.label-short {
  display: none;
}

.stock-filter {
  flex-wrap: nowrap;
  gap: 10px;
}

.stock-filter .chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
  max-width: 100%;
}

.chip {
  flex: none;
  min-height: 32px;
  padding: 0 11px;
}

.chip-count.warn {
  color: var(--warn);
  font-weight: 800;
}

.chip-count.danger {
  color: var(--danger);
  font-weight: 800;
}

.stock-filter .catalog-meta {
  gap: 10px;
  white-space: nowrap;
}

.stock-value strong {
  color: var(--text);
}

.stock-list {
  padding-top: 8px;
}

.stock-row {
  padding: 8px 12px;
  margin-bottom: 4px;
  gap: 2px 12px;
}

.stock-row .product-fits {
  font-size: 12px;
}

.stock-qty strong {
  font-size: 18px;
}

@media (max-width: 700px) {
  .stock-toolbar {
    flex-direction: row;
  }

  .location-pick {
    flex: 0 0 38%;
  }

  .location-pick select {
    padding-left: 34px;
    padding-right: 4px;
    font-size: 14px;
  }

  .location-pick > .icon {
    left: 10px;
    width: 18px;
    height: 18px;
  }

  .stock-actions {
    display: flex;
  }

  .label-long {
    display: none;
  }

  .label-short {
    display: inline;
  }

  .stock-filter .updated {
    display: none;
  }

  .stock-filter {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .stock-filter .catalog-meta {
    flex: 1 1 auto;
    min-height: 0;
  }
}

@media (max-width: 700px) {
  /* every action visible: equal columns, icon over a short label */
  .stock-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 4px;
    overflow: visible;
  }

  .stock-actions .btn {
    flex-direction: column;
    gap: 2px;
    min-height: 52px;
    padding: 4px 2px;
    font-size: 11.5px;
    line-height: 1.1;
    border-radius: 10px;
  }

  .stock-actions .btn .icon {
    width: 20px;
    height: 20px;
  }

  .chip {
    padding: 0 9px;
    font-size: 13px;
    gap: 4px;
  }

  .stock-filter {
    column-gap: 6px;
  }
}

@media (max-width: 700px) {
  .stock-filter .catalog-meta {
    min-width: 0;
  }
}

/* ----------------------------------------------------- receipt designer
   A tall dialog: fixed title and buttons; the options and the preview scroll
   separately (side by side on wide screens, one at a time on phones). */

.dialog.designer {
  max-width: 1120px;
  height: min(900px, calc(100dvh / var(--zoom) - 32px));
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.dialog.designer .dialog-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.dialog.designer .dialog-body {
  min-height: 0;
  padding: 0;
  gap: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.designer-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
}

.designer-controls {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px 20px 24px;
}

.designer-controls section {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.designer-controls h3 {
  margin: 0;
  font-size: 15px;
}

.designer-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.logo-preview {
  width: 160px;
  height: 90px;
  background: #fff;
}

.logo-preview img {
  object-fit: contain;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.range-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.designer-preview {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface-2);
  border-left: 1px solid var(--border);
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.preview-bar .segmented button {
  min-height: 34px;
  padding: 0 12px;
}

.designer-pane-switch {
  display: none;
  margin: 10px 16px 0;
}

.designer-status {
  margin: 0 20px 12px;
}

.dialog.designer .dialog-foot {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  align-items: center;
}

/* the paper: real width, white like a till roll, with a torn bottom edge */
.paper {
  background: #fff;
  color: #000;
  padding: 14px 10px 18px;
  box-shadow: var(--shadow-lg);
  border-radius: 2px;
  max-width: 100%;
  overflow: hidden;
}

.paper-58 {
  width: 58mm;
}

.paper-80 {
  width: 80mm;
}

.paper .receipt {
  background: #fff;
  color: #000;
  padding: 0;
  font-size: 11px;
}

.paper .receipt hr {
  border-top-color: #000;
}

.paper.as-printed .ticket-logo img {
  image-rendering: pixelated;
}

.ticket-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.ticket-logo.left {
  justify-content: flex-start;
}

.ticket-logo.right {
  justify-content: flex-end;
}

.ticket-logo img {
  height: auto;
  max-width: 100%;
}

.print-probe .ticket-logo img,
#print-root .ticket-logo img {
  filter: grayscale(1);
}

.dialog.designer .dialog-foot .spacer {
  flex: 1;
}

.dialog.designer .dialog-foot .btn {
  flex: 0 0 auto;
}

/* side by side down to portrait tablets; one pane at a time on phones */
@media (max-width: 719px) {
  .designer-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .designer-pane-switch {
    display: grid;
  }

  .designer-grid[data-pane="design"] .designer-preview,
  .designer-grid[data-pane="preview"] .designer-controls {
    display: none;
  }

  .designer-preview {
    border-left: none;
  }

  .designer-controls {
    padding: 12px 16px 20px;
  }
}

@media (max-width: 520px) {
  .dialog.designer {
    height: calc(100dvh / var(--zoom));
    max-height: calc(100dvh / var(--zoom));
    border-radius: 0;
  }

  .dialog.designer .dialog-foot {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    gap: 6px;
  }

  .dialog.designer .dialog-foot .btn {
    padding: 0 12px;
  }

  .dialog.designer .dialog-foot .label-long {
    display: none;
  }

  .dialog.designer .dialog-foot .label-short {
    display: inline;
  }

  .designer-controls section {
    padding: 12px;
  }

  .logo-preview {
    width: 120px;
    height: 72px;
  }
}

/* ======================================================= AI assistant */

.assistant-screen {
  min-height: 0;
  display: grid;
}

.assistant {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
}

.ai-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--gutter);
  border-bottom: 1px solid var(--border);
}

.ai-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ai-title > div {
  display: grid;
  min-width: 0;
}

.ai-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.ai-mark.big {
  width: 56px;
  height: 56px;
  border-radius: 16px;
}

.ai-mark.big .icon {
  width: 28px;
  height: 28px;
}

.ai-messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px var(--gutter);
}

.ai-empty {
  margin: auto;
  max-width: 560px;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 24px 0;
}

.ai-empty p {
  margin: 0;
}

.ai-examples {
  display: grid;
  gap: 8px;
  width: 100%;
}

.ai-examples .chip {
  height: auto;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius);
  white-space: normal;
  text-align: left;
  font-weight: 500;
  justify-content: flex-start;
}

.ai-bubble {
  max-width: min(640px, 88%);
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.ai-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--on-accent);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.ai-bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  display: grid;
  gap: 10px;
  width: min(640px, 88%);
}

.ai-bubble.assistant.error {
  border-color: var(--danger);
  color: var(--danger);
}

.ai-bubble.assistant.saved {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.ai-bubble.typing {
  width: auto;
  display: flex;
  gap: 5px;
  padding: 14px 16px;
}

.ai-bubble.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  animation: ai-dot 1s infinite ease-in-out;
}

.ai-bubble.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-bubble.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ai-dot {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.ai-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.ai-card-title {
  font-weight: 700;
  font-size: 16px;
}

.ai-card dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 14px;
  margin: 0;
  font-size: 14px;
}

.ai-card dt {
  color: var(--text-2);
}

.ai-card dd {
  margin: 0;
  font-weight: 600;
}

.badge-new {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
  background: var(--warn-soft);
  color: var(--warn);
}

.ai-existing {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ok);
}

.ai-notes {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-2);
}

.ai-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-saved {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.ai-saved-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
}

.ai-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ai-input {
  flex: 1;
  resize: none;
  min-height: 46px;
  max-height: 160px;
  padding: 11px 14px;
  line-height: 1.4;
}

.ai-send {
  width: 46px;
  min-height: 46px;
  padding: 0;
  flex: none;
}

@media (max-width: 700px) {
  .ai-head .muted.small {
    display: none;
  }

  .ai-bubble,
  .ai-bubble.assistant {
    max-width: 94%;
    width: auto;
  }

  .ai-bubble.assistant {
    width: 94%;
  }
}

/* the reply text: paragraphs and lists from the assistant's light formatting */
.ai-text p {
  margin: 0;
}

.ai-text p + p,
.ai-text p + ul,
.ai-text p + ol,
.ai-text ul + p,
.ai-text ol + p {
  margin-top: 6px;
}

.ai-text ul,
.ai-text ol {
  margin: 4px 0 0;
  padding-left: 20px;
}

.ai-text li + li {
  margin-top: 2px;
}

.ai-text code {
  font-family: var(--mono);
  font-size: 0.92em;
}

.ai-examples-label {
  justify-self: start;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* answer cards: figures, tables and invoices from the shop's data */
.ai-result {
  overflow-wrap: break-word;
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  min-width: 0;
}

.ai-result-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.ai-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}

.ai-stat {
  display: grid;
  gap: 1px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.ai-stat span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.ai-stat strong {
  font-size: 16px;
  white-space: nowrap;
}

.ai-stat small {
  font-size: 12px;
  color: var(--text-2);
}

.ai-table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

.ai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ai-table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-2);
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ai-table td {
  padding: 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  /* break at spaces only, so columns size to whole words */
  overflow-wrap: break-word;
}

.ai-table tr:last-child td {
  border-bottom: 0;
}

.ai-table .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ai-table .ai-open {
  width: 1%;
  text-align: right;
}

.ai-invoice dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 2px 12px;
  margin: 0;
  font-size: 14px;
}

.ai-invoice dt {
  color: var(--text-2);
}

.ai-invoice dd {
  margin: 0;
}

.ai-lines {
  display: grid;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.ai-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 14px;
}

.ai-line strong {
  flex: none;
  white-space: nowrap;
}

.ai-line + .ai-line {
  border-top: 1px dashed var(--border);
}

.ai-invoice .ai-totals dd {
  font-weight: 700;
  text-align: right;
}

@media (max-width: 700px) {
  /* table rows become stacked label / value pairs on phones */
  .ai-table thead {
    display: none;
  }

  .ai-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 10px;
    padding: 6px 2px;
    border-bottom: 1px solid var(--border);
  }

  .ai-table tr:last-child {
    border-bottom: 0;
  }

  .ai-table td {
    padding: 0;
    border: 0;
  }

  .ai-table td:first-child {
    grid-column: 1 / -1;
    font-weight: 600;
  }

  .ai-table td:not(:first-child):not(.ai-open)::before {
    content: attr(data-label) ": ";
    color: var(--text-3);
    font-size: 12px;
  }

  .ai-table .num {
    text-align: left;
  }
}

/* messages keep their full height; the list scrolls instead of squeezing them */
.ai-messages > * {
  flex-shrink: 0;
}


/* ------------------------------------------------------------ Utopia brand */

.brand-logo {
  display: flex;
  justify-content: center;
}

.brand-logo img {
  width: min(220px, 70%);
  height: auto;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
  margin-bottom: 4px;
}

.login-brand p {
  margin: 0;
  color: var(--text-2);
  font-size: 15px;
}

.boot {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 28px;
}

.boot-logo {
  width: min(260px, 64vw);
  height: auto;
  animation: boot-in 0.5s ease-out;
}

@keyframes boot-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* light / dark logo versions follow the theme (hiding must beat any display rule) */
.logo-dark {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light {
    display: none !important;
  }

  :root:not([data-theme="light"]) .logo-dark {
    display: block !important;
  }
}

:root[data-theme="dark"] .logo-light {
  display: none !important;
}

:root[data-theme="dark"] .logo-dark {
  display: block !important;
}

/* the mark sits on the bar itself (no tile behind it) */
.topbar img.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 0;
  object-fit: contain;
}

/* ================================================================ users
   Admin screen: people (cards) and the activity log, plus the user editor. */

.users-screen {
  min-height: 0;
  display: grid;
}

.users-view {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.users-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--gutter) 8px;
  flex-wrap: wrap;
}

.users-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  margin-right: auto;
}

.users-tabs {
  flex: 0 1 340px;
}

.users-tabs button {
  min-height: 40px;
}

.users-pane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.users-pane[hidden] {
  display: none;
}

.users-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--gutter) 10px;
}

.users-toolbar .search-box {
  flex: 1;
  min-width: 0;
}

.users-list,
.activity-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 var(--gutter) 24px;
}

.users-summary {
  padding: 0 2px 8px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 15px;
  background: var(--surface-3);
  color: var(--text-2);
  flex: none;
}

.avatar.admin {
  background: var(--accent);
  color: var(--on-accent);
}

.avatar.manager {
  background: var(--accent-soft);
  color: var(--accent);
}

.avatar.lg {
  width: 56px;
  height: 56px;
  font-size: 19px;
}

.avatar-wrap {
  position: relative;
  display: inline-grid;
}

.online-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--surface);
}

.user-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "avatar main tags"
    "avatar main seen";
  align-items: center;
  gap: 2px 12px;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .user-row:hover {
    border-color: var(--accent);
  }
}

.user-row.disabled {
  opacity: 0.6;
}

.user-row .avatar-wrap {
  grid-area: avatar;
}

.user-main {
  grid-area: main;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-name .you {
  font-weight: 400;
  color: var(--text-3);
}

.user-sub {
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-tags {
  grid-area: tags;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.user-seen {
  grid-area: seen;
  text-align: right;
  white-space: nowrap;
}

.pill.role.admin {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---- the editor */

.dialog.user-editor {
  max-width: 720px;
}

.user-hero {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-hero strong {
  font-size: 18px;
}

.user-hero .user-tags {
  justify-content: flex-start;
  margin-top: 6px;
}

.user-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.user-stats .tile strong {
  font-size: 17px;
}

.user-stats .tile .small-strong {
  font-size: 15px;
}

.user-stats .tile span.muted {
  font-weight: 400;
}

.form-grid.one {
  grid-template-columns: minmax(0, 1fr);
}

.password-line {
  display: flex;
  gap: 8px;
}

.password-line .input-wrap {
  flex: 1;
  min-width: 0;
}

.role-pick button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.perm-note .alert.info {
  background: var(--accent-soft);
  color: var(--text);
}

.perm-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.btn.sm {
  min-height: 34px;
  padding: 0 10px;
  font-size: 14px;
}

.perm-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.perm-group {
  margin: 0;
  padding: 6px 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}

.perm-group legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.switch-row:last-child {
  border-bottom: 0;
}

.switch-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.switch-text strong {
  font-weight: 600;
  font-size: 15px;
}

.changed-tag {
  justify-self: start;
  margin-top: 2px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--warn-soft);
  color: var(--warn);
}

/* a native checkbox drawn as a switch */
input.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.15s;
}

input.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
  transition: transform 0.15s;
}

input.switch:checked {
  background: var(--accent);
  border-color: var(--accent);
}

input.switch:checked::after {
  transform: translateX(18px);
}

input.switch:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

input.switch:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.user-actions .btn {
  flex: 1 1 auto;
}

.user-recent {
  display: grid;
  gap: 2px;
}

.recent-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.recent-row > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.recent-row .muted {
  white-space: nowrap;
}

.recent-row.failed > span:first-child {
  color: var(--danger);
}

.user-recent .btn {
  justify-self: start;
  margin-top: 4px;
}

/* ---- the activity log */

.activity-filters {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 8px;
  padding: 0 var(--gutter) 10px;
}

.activity-selects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.activity-filters .chips {
  grid-column: 1 / -1;
}

.activity-day {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 10px 2px 6px;
  background: var(--bg);
}

.activity-item {
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.activity-item.open {
  border-color: var(--accent);
}

.activity-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.activity-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
}

.activity-icon.g-sale {
  background: var(--ok-soft);
  color: var(--ok);
}

.activity-icon.g-stock,
.activity-icon.g-product,
.activity-icon.g-ai {
  background: var(--accent-soft);
  color: var(--accent);
}

.activity-icon.g-user,
.activity-icon.g-settings,
.activity-icon.g-device {
  background: var(--warn-soft);
  color: var(--warn);
}

.activity-item.failed .activity-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.activity-item.failed .activity-summary {
  color: var(--danger);
}

.activity-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.activity-summary {
  font-weight: 600;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.activity-sub {
  font-size: 13px;
  color: var(--text-2);
}

.activity-time {
  font-size: 13px;
  color: var(--text-2);
  align-self: start;
  padding-top: 2px;
}

.activity-details {
  display: grid;
  gap: 4px;
  padding: 0 12px 12px 58px;
  font-size: 14px;
}

.activity-notes {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--text-2);
}

.load-more {
  margin-top: 8px;
}

.activity-end {
  padding: 12px 0;
}

@media (max-width: 700px) {
  .users-head h2 {
    font-size: 18px;
  }

  .users-tabs {
    order: 3;
    flex: 1 1 100%;
  }

  .perm-groups {
    grid-template-columns: minmax(0, 1fr);
  }

  .activity-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .activity-details {
    padding-left: 12px;
  }

  .user-row {
    grid-template-areas:
      "avatar main seen"
      "avatar tags tags";
  }

  .user-tags {
    justify-content: flex-start;
  }

  .user-editor .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ============================================================== reports
   One filter row scopes everything below it; cards in a responsive grid;
   charts: one series, --chart-1, hairline grid, 4px rounded column tops. */

.reports-screen {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.reports-view {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px var(--gutter) 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-content: start;
}

.reports-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.reports-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto 0 0;
  font-size: 20px;
}

.report-sections {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}

.report-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.report-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.report-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.presets {
  flex: 1 1 auto;
  min-width: 0;
}

.shop-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.shop-filter select {
  min-width: 170px;
}

.stock-now {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-2);
}

.custom-range {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.custom-range .field {
  flex: 0 1 180px;
}

.report-body {
  display: grid;
  gap: 12px;
  transition: opacity 0.15s;
}

.report-body.refetching {
  opacity: 0.55;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.kpi {
  display: grid;
  gap: 2px;
  align-content: start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

/* standalone figures: proportional digits, same sans as everything */
.kpi-cur {
  margin-right: 4px;
  font-size: 0.6em;
  font-weight: 600;
  color: var(--text-2);
}

.kpi.hero {
  grid-column: span 2;
}

.kpi-num {
  white-space: nowrap;
}

.kpi-value {
  font-size: 21px;
  font-weight: 650;
  line-height: 1.25;
  font-variant-numeric: proportional-nums;
}

.kpi.hero .kpi-value {
  font-size: 30px;
}

.kpi-extra {
  font-size: 13px;
  color: var(--text-2);
}

.delta {
  font-weight: 700;
}

.delta.good {
  color: var(--ok);
}

.delta.bad {
  color: var(--danger);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.report-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* wide cards: charts over time and the long tables */
.report-card.wide {
  grid-column: 1 / -1;
}

.report-card-head h3 {
  margin: 0;
  font-size: 16px;
}

.card-note {
  margin: -4px 0 0;
}

.card-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.see-all {
  justify-self: start;
}

.small-empty {
  padding: 24px 8px;
  font-size: 14px;
}

/* ---- charts */

.chart-wrap {
  min-width: 0;
}

.chart {
  position: relative;
  width: 100%;
}

.chart-svg {
  display: block;
  overflow: visible;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-base {
  stroke: var(--text-3);
  stroke-width: 1;
}

.chart-tick {
  fill: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-bar {
  fill: var(--chart-1);
}

.chart-hit {
  fill: transparent;
  cursor: default;
  outline: none;
}

.chart-hit.on {
  fill: var(--text);
  fill-opacity: 0.05;
}

.chart-hit:focus-visible {
  stroke: var(--focus);
  stroke-width: 2;
}

.chart-tip {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 1px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  pointer-events: none;
}

.chart-tip strong {
  font-size: 15px;
  color: var(--text);
}

.chart-tip[hidden] {
  display: none;
}

/* ---- bar list */

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: end;
}

.bar-label {
  display: grid;
  min-width: 0;
}

.bar-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-sub {
  font-size: 12px;
  color: var(--text-3);
}

.bar-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: var(--chart-1);
}

/* ---- tables */

.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tr.clickable {
  cursor: pointer;
}

@media (hover: hover) {
  .data-table tr.clickable:hover td {
    background: var(--surface-2);
  }
}

.data-table tr.voided td {
  color: var(--text-3);
}

.cell-main {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.report-tools,
.sales-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.report-tools .search-box,
.sales-tools .search-box {
  flex: 1 1 240px;
}

.sales-tools select {
  flex: 0 1 190px;
}

.sales-summary {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.sales-summary .spacer {
  flex: 1;
}

@media (max-width: 760px) {
  .report-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi.hero {
    grid-column: 1 / -1;
  }

  .kpi-value {
    font-size: 18px;
  }

  .kpi.hero .kpi-value {
    font-size: 26px;
  }

  .reports-head h2 {
    font-size: 18px;
  }

  .shop-filter {
    margin-left: 0;
    flex: 1 1 100%;
  }

  .shop-filter select {
    flex: 1;
    min-width: 0;
  }

  .presets {
    flex-basis: 100%;
  }

  .sales-tools select {
    flex: 1 1 140px;
  }

  .presets {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .presets .chip {
    flex: none;
  }

  .report-tab span {
    display: none;
  }

  .report-tab[aria-selected="true"] span {
    display: inline;
  }

  /* tables become stacked rows on phones: label / value pairs */
  .data-table thead {
    display: none;
  }

  .data-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border);
  }

  .data-table tr:last-child {
    border-bottom: 0;
  }

  .data-table td {
    padding: 0;
    border: 0;
  }

  .data-table td:first-child {
    grid-column: 1 / -1;
  }

  .data-table td.num::before {
    content: attr(data-label) " ";
    color: var(--text-3);
    font-size: 12px;
  }

  .data-table td:not(.num):not(:first-child) {
    color: var(--text-2);
    font-size: 13px;
  }
}

/* phones with four or more screens: icons, and the open screen's name */
@media (max-width: 560px) {
  .tabs:has(.tab:nth-child(4)) .tab {
    padding: 0 10px;
  }

  .tabs:has(.tab:nth-child(4)) .tab .icon {
    display: inline-block;
  }

  .tabs:has(.tab:nth-child(4)) .tab span {
    display: none;
  }
}

.tabs {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

/* ============================================================ locations */

.locations-screen {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.locations-view {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding-bottom: 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

.loc-meter {
  display: grid;
  gap: 6px;
  padding: 0 var(--gutter) 12px;
}

.loc-meter-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-2);
}

.loc-meter-text strong {
  color: var(--text);
}

.loc-meter-track {
  height: 8px;
  max-width: 360px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.loc-meter-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.loc-meter-track.full .loc-meter-fill {
  background: var(--warn);
}

.loc-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 var(--gutter) 10px;
}

.loc-toolbar .search-box {
  flex: 1 1 220px;
  min-width: 0;
}

.loc-list {
  padding: 0 var(--gutter);
}

.loc-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .loc-row:hover {
    border-color: var(--accent);
  }
}

.loc-row.archived {
  opacity: 0.65;
}

.loc-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
}

.loc-icon.t-shop {
  background: var(--accent-soft);
  color: var(--accent);
}

.loc-icon.t-damaged {
  background: var(--warn-soft);
  color: var(--warn);
}

.loc-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.loc-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-code {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}

.loc-address,
.loc-facts {
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-facts {
  color: var(--text-3);
}

.loc-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.dialog.loc-editor {
  max-width: 640px;
}

.type-pick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.type-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.type-option span {
  display: grid;
  gap: 2px;
}

.type-option small {
  font-size: 12px;
  color: var(--text-2);
}

.type-option[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.type-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 700px) {
  .loc-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .loc-tags {
    grid-column: 2;
    justify-content: flex-start;
  }

  .type-pick {
    grid-template-columns: minmax(0, 1fr);
  }

  .loc-editor .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* =========================================================== appearance
   Per-user choices (js/appearance.js sets data-* on <html>): colour palette,
   density, text size, contrast and the sell-screen layout. Palettes are
   checked for WCAG AA (white or dark text on the accent, accent on surfaces)
   and their chart colour with the dataviz palette validator, light and dark.
   Generated by tools/gen-theme-css.mjs — edit the palettes there. */

/* teal */
:root[data-accent="teal"] {
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #ddf2ef;
  --on-accent: #ffffff;
  --focus: #14918a;
  --chart-1: #0d9488;
}

@media (prefers-color-scheme: dark) {
  :root[data-accent="teal"]:not([data-theme="light"]) {
    --accent: #4fc1b6;
    --accent-hover: #6fd0c7;
    --accent-soft: #142f2c;
    --on-accent: #03201c;
    --focus: #6fd0c7;
    --chart-1: #14a395;
  }
}

:root[data-accent="teal"][data-theme="dark"] {
  --accent: #4fc1b6;
  --accent-hover: #6fd0c7;
  --accent-soft: #142f2c;
  --on-accent: #03201c;
  --focus: #6fd0c7;
  --chart-1: #14a395;
}

/* violet */
:root[data-accent="violet"] {
  --accent: #6d28d9;
  --accent-hover: #5b21b6;
  --accent-soft: #efe9fc;
  --on-accent: #ffffff;
  --focus: #7c3aed;
  --chart-1: #6d28d9;
}

@media (prefers-color-scheme: dark) {
  :root[data-accent="violet"]:not([data-theme="light"]) {
    --accent: #a78bfa;
    --accent-hover: #bba5fb;
    --accent-soft: #261f3d;
    --on-accent: #170c33;
    --focus: #bba5fb;
    --chart-1: #9b7fe6;
  }
}

:root[data-accent="violet"][data-theme="dark"] {
  --accent: #a78bfa;
  --accent-hover: #bba5fb;
  --accent-soft: #261f3d;
  --on-accent: #170c33;
  --focus: #bba5fb;
  --chart-1: #9b7fe6;
}

/* sunset */
:root[data-accent="sunset"] {
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #fdece2;
  --on-accent: #ffffff;
  --focus: #ea580c;
  --chart-1: #c2410c;
}

@media (prefers-color-scheme: dark) {
  :root[data-accent="sunset"]:not([data-theme="light"]) {
    --accent: #fb923c;
    --accent-hover: #fdba74;
    --accent-soft: #36231a;
    --on-accent: #2a1206;
    --focus: #fdba74;
    --chart-1: #d9702f;
  }
}

:root[data-accent="sunset"][data-theme="dark"] {
  --accent: #fb923c;
  --accent-hover: #fdba74;
  --accent-soft: #36231a;
  --on-accent: #2a1206;
  --focus: #fdba74;
  --chart-1: #d9702f;
}

/* graphite */
:root[data-accent="graphite"] {
  --accent: #334155;
  --accent-hover: #1e293b;
  --accent-soft: #e7ebf0;
  --on-accent: #ffffff;
  --focus: #64748b;
  --chart-1: #3d6aa8;
}

@media (prefers-color-scheme: dark) {
  :root[data-accent="graphite"]:not([data-theme="light"]) {
    --accent: #cbd5e1;
    --accent-hover: #e2e8f0;
    --accent-soft: #252b35;
    --on-accent: #0f172a;
    --focus: #e2e8f0;
    --chart-1: #6a92d4;
  }
}

:root[data-accent="graphite"][data-theme="dark"] {
  --accent: #cbd5e1;
  --accent-hover: #e2e8f0;
  --accent-soft: #252b35;
  --on-accent: #0f172a;
  --focus: #e2e8f0;
  --chart-1: #6a92d4;
}

/* high contrast: stronger lines and secondary text */
:root[data-contrast="high"] {
  --border: #9aa3b0;
  --text-2: #374151;
  --text-3: #4b5563;
}

@media (prefers-color-scheme: dark) {
  :root[data-contrast="high"]:not([data-theme="light"]) {
    --border: #5a6474;
    --text-2: #cdd3db;
    --text-3: #b4bcc7;
  }
}

:root[data-contrast="high"][data-theme="dark"] {
  --border: #5a6474;
  --text-2: #cdd3db;
  --text-3: #b4bcc7;
}
:root[data-contrast="high"] :focus-visible {
  outline-width: 3px;
}

:root[data-contrast="high"] .pill,
:root[data-contrast="high"] .chip,
:root[data-contrast="high"] .tab[aria-selected="true"] {
  box-shadow: inset 0 0 0 1px var(--border);
}

/* ---- text size: everything scales together (see body) */
:root[data-text="small"] {
  --zoom: 0.92;
}

:root[data-text="large"] {
  --zoom: 1.12;
}

:root[data-text="xlarge"] {
  --zoom: 1.25;
}

/* ---- density: compact fits more on screen, touch has bigger targets */
:root[data-density="compact"] {
  --gutter: 12px;
  --header-h: 50px;
}

:root[data-density="compact"] body {
  font-size: 14px;
}

:root[data-density="compact"] .btn {
  min-height: 34px;
  padding: 0 12px;
}

:root[data-density="compact"] .btn.lg {
  min-height: 44px;
}

:root[data-density="compact"] .input {
  min-height: 38px;
}

:root[data-density="compact"] .icon-btn {
  width: 34px;
  height: 34px;
}

:root[data-density="compact"] .chip {
  min-height: 28px;
}

:root[data-density="compact"] .tab {
  min-height: 32px;
}

:root[data-density="compact"] .segmented button {
  min-height: 36px;
}

:root[data-density="compact"] .product {
  padding: 7px 12px;
  margin-bottom: 4px;
  gap: 2px 12px;
}

:root[data-density="compact"] .product-item {
  margin-bottom: 4px;
}

:root[data-density="compact"] .product.has-thumb {
  padding-left: 62px;
}

:root[data-density="compact"] .thumb {
  left: 10px;
  width: 42px;
  height: 42px;
}

:root[data-density="compact"] .line {
  padding: 8px var(--gutter);
}

:root[data-density="compact"] .stock-row,
:root[data-density="compact"] .user-row,
:root[data-density="compact"] .loc-row {
  padding-top: 7px;
  padding-bottom: 7px;
  margin-bottom: 4px;
}

:root[data-density="touch"] {
  --gutter: 18px;
  --header-h: 64px;
}

:root[data-density="touch"] body {
  font-size: 16px;
}

:root[data-density="touch"] .btn {
  min-height: 48px;
  padding: 0 18px;
}

:root[data-density="touch"] .btn.lg {
  min-height: 60px;
}

:root[data-density="touch"] .btn.sm {
  min-height: 42px;
}

:root[data-density="touch"] .input {
  min-height: 50px;
}

:root[data-density="touch"] .icon-btn {
  width: 48px;
  height: 48px;
}

:root[data-density="touch"] .chip {
  min-height: 42px;
  padding: 0 16px;
}

:root[data-density="touch"] .tab {
  min-height: 46px;
  padding: 0 18px;
}

:root[data-density="touch"] .segmented button {
  min-height: 50px;
}

:root[data-density="touch"] .product {
  padding: 16px 16px;
  margin-bottom: 8px;
}

:root[data-density="touch"] .product-item {
  margin-bottom: 8px;
}

:root[data-density="touch"] .product.has-thumb {
  padding-left: 88px;
}

:root[data-density="touch"] .thumb {
  width: 60px;
  height: 60px;
}

:root[data-density="touch"] .line {
  padding: 14px var(--gutter);
}

:root[data-density="touch"] .stepper button {
  width: 48px;
  height: 48px;
}

:root[data-density="touch"] .stock-row,
:root[data-density="touch"] .user-row,
:root[data-density="touch"] .loc-row {
  padding-top: 14px;
  padding-bottom: 14px;
}

:root[data-density="touch"] .switch-row {
  padding: 12px 0;
}

/* ---- sell screen: photo grid instead of the list */
.thumb-ph {
  display: none;
}

:root[data-products="grid"] .results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
  align-content: start;
}

:root[data-products="grid"] .product-item {
  margin: 0;
}

:root[data-products="grid"] .results > .product,
:root[data-products="grid"] .product-item > .product {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding: 0 0 10px;
  overflow: hidden;
}

:root[data-products="grid"] .product > :not(.thumb):not(.thumb-ph) {
  padding: 0 12px;
}

:root[data-products="grid"] .product .thumb,
:root[data-products="grid"] .product .thumb-ph {
  position: static;
  transform: none;
  order: 0;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  margin-bottom: 6px;
  border-radius: 0;
  object-fit: cover;
}

:root[data-products="grid"] .product .thumb-ph {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

:root[data-products="grid"] .product-name {
  order: 1;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.9em;
}

:root[data-products="grid"] .product-codes {
  order: 2;
  font-size: 12px;
}

:root[data-products="grid"] .product-price {
  order: 3;
  margin-top: auto;
  text-align: left;
  font-size: 16px;
}

:root[data-products="grid"] .product-stock {
  order: 4;
  justify-self: auto;
  align-self: flex-start;
}

:root[data-products="grid"] .product-fits {
  display: none;
}

:root[data-products="grid"] .product.has-thumb,
:root[data-products="grid"][data-density] .product.has-thumb {
  padding-left: 0;
}

/* ---- sell screen on wide screens: the sale on the left */
@media (min-width: 900px) {
  :root[data-cart="left"] .pos {
    grid-template-columns: 400px minmax(0, 1fr);
  }

  :root[data-cart="left"] .pos > .cart {
    order: -1;
    border-right: 1px solid var(--border);
  }

  :root[data-cart="left"] .catalog {
    border-right: 0;
  }
}

/* ---- the Appearance panel */
.dialog.appearance-dialog {
  max-width: 760px;
}

.appearance {
  display: grid;
  gap: 18px;
}

.look-section {
  display: grid;
  gap: 8px;
}

.look-section h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}

.look-grid {
  display: grid;
  gap: 8px;
}

.look-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.look-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.look-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}

@media (hover: hover) {
  .look-option:hover {
    border-color: var(--accent);
  }
}

.look-option[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.look-check {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
}

.look-check .icon {
  width: 13px;
  height: 13px;
  stroke-width: 3;
}

.look-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.look-text small {
  font-size: 12px;
  color: var(--text-2);
}

/* theme: a small sample tile */
.look-swatch-mode {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.look-swatch-mode.m-light {
  background: #ffffff;
  color: #161b22;
}

.look-swatch-mode.m-dark {
  background: #171b21;
  color: #e7eaee;
}

.look-swatch-mode.m-system {
  background: linear-gradient(135deg, #ffffff 50%, #171b21 50%);
  color: var(--accent);
}

/* colour: a dot of each palette */
.look-colours {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.look-dot {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 35%);
}

/* sell screen: a miniature of the layout */
.look-option:has(.mini-screen) {
  flex-direction: column;
  align-items: stretch;
}

.mini-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34%;
  gap: 4px;
  height: 70px;
  padding: 5px;
  border-radius: 8px;
  background: var(--surface-2);
}

.mini-screen.cart-left {
  grid-template-columns: 34% minmax(0, 1fr);
}

.mini-screen.cart-left .mini-cart {
  order: -1;
}

.mini-list {
  display: grid;
  gap: 3px;
  align-content: start;
}

.mini-list:has(.mini-card) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-row {
  height: 11px;
  border-radius: 3px;
  background: var(--surface);
  border-left: 8px solid var(--surface-3);
}

.mini-card {
  height: 27px;
  border-radius: 3px;
  background: linear-gradient(var(--surface-3) 0 55%, var(--surface) 55%);
}

.mini-cart {
  display: grid;
  grid-template-rows: 9px 9px 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 4px;
  background: var(--surface);
}

.mini-cart span {
  border-radius: 2px;
  background: var(--surface-2);
}

.mini-cart .mini-pay {
  align-self: end;
  height: 10px;
  background: var(--accent);
}

/* spacing: three bars, tighter or looser */
.look-density {
  display: grid;
  flex: none;
  width: 34px;
  align-content: center;
}

.look-density span {
  height: 4px;
  border-radius: 2px;
  background: var(--text-3);
}

.look-density.d-compact {
  gap: 2px;
}

.look-density.d-comfortable {
  gap: 5px;
}

.look-density.d-touch {
  gap: 8px;
}

.look-density.d-touch span {
  height: 6px;
}

/* text size */
.look-sizes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.look-sizes .look-option {
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  min-height: 74px;
}

.look-aa {
  font-weight: 700;
  line-height: 1;
}

.look-aa.s-small {
  font-size: 16px;
}

.look-aa.s-normal {
  font-size: 20px;
}

.look-aa.s-large {
  font-size: 25px;
}

.look-aa.s-xlarge {
  font-size: 30px;
}

.look-sizes small {
  font-size: 12px;
  color: var(--text-2);
}

.look-contrast {
  padding: 4px 0 0;
  border: 0;
}

/* the sale has its own screen on phones: its side only matters on wide screens */
@media (max-width: 899px) {
  .look-wide-only {
    display: none;
  }
}

@media (max-width: 700px) {
  .look-grid.three {
    grid-template-columns: minmax(0, 1fr);
  }

  .look-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .look-grid.two .look-text small {
    display: none;
  }

  .look-sizes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* ============================================================== returns */

.history-return {
  justify-self: start;
  margin-bottom: 4px;
}

.return-lines {
  display: grid;
  gap: 8px;
}

.return-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.return-line.chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.return-line.done {
  opacity: 0.6;
}

.return-line-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.return-line-qty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.return-line-qty .stepper input {
  width: 52px;
  text-align: center;
  border: 0;
  background: transparent;
}

.return-line-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.link-btn {
  display: block;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.moved-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
}

.moved-banner > .icon {
  flex: none;
  margin-top: 2px;
  color: var(--accent);
}

@media (max-width: 600px) {
  .return-line {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* the return screen fits narrow phones: its column never grows past the dialog */
.return-dialog .dialog-body {
  grid-template-columns: minmax(0, 1fr);
}

.return-dialog .segmented button {
  min-width: 0;
  padding: 0 4px;
}

@media (max-width: 600px) {
  .return-dialog .segmented .icon {
    display: none;
  }

  .return-line-foot strong {
    white-space: nowrap;
  }
}

/* a long dialog title never makes the dialog wider than the screen */
.dialog {
  grid-template-columns: minmax(0, 1fr);
}

.dialog-head h2 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
