:root {
  --bar-bg: #000;
  --bar-text: #f5f6f7;
  --bar-muted: #9ba3ad;
  --bar-border: #1f2329;
  --bar-input-bg: #14181d;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f3f4f6;
  --border: #e5e7eb;
  --text: #111418;
  --muted: #5b6470;
  --accent: #10a0ff;
  --accent-ink: #ffffff;
  --good: #16a34a;
  --bad: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bar-bg);
  color: var(--bar-text);
  border-bottom: 1px solid var(--bar-border);
  padding: max(env(safe-area-inset-top), 12px) 16px 10px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.brand img {
  display: block;
  height: 64px;
  width: auto;
}
.brand-tag {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--bar-muted);
  padding: 3px 8px;
  border: 1px solid var(--bar-border);
  border-radius: 999px;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  position: relative;
}
.bar-row:first-child { margin-top: 0; }
.version {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--bar-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  pointer-events: none;
}
h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.status {
  font-size: 13px;
  color: var(--bar-muted);
  min-height: 1em;
}
.updated {
  font-size: 12px;
  color: var(--bar-muted) !important;
}
.status.busy { color: var(--accent); }
.status.err { color: #ff8a8a; }
.btn {
  appearance: none;
  border: 1px solid var(--bar-border);
  background: var(--bar-input-bg);
  color: var(--bar-text);
  padding: 10px 16px;
  min-height: 44px;
  border-radius: var(--radius);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { background: #0d1014; }
.btn:disabled { opacity: 0.6; cursor: default; }
.controls .search,
.controls .select {
  flex: 1 1 160px;
  min-width: 140px;
  padding: 12px 14px;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--bar-border);
  background: var(--bar-input-bg);
  color: var(--bar-text);
  font: inherit;
  font-size: 16px;
}
.controls .search { flex: 2 1 240px; }
.controls .search::placeholder { color: var(--bar-muted); }
.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--bar-muted);
  font-size: 14px;
  user-select: none;
  -webkit-user-select: none;
}
.chk input { transform: translateY(1px); }
.meta {
  font-size: 12px;
  margin-top: 6px;
  justify-content: space-between;
  color: var(--bar-muted);
}
.quick-access {
  gap: 8px;
}
.quick-tile {
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  min-height: 48px;
  border: 1px solid var(--bar-border);
  background: var(--bar-input-bg);
  color: var(--bar-text);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.quick-tile:active { background: #1f252d; }
.quick-tile.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.quick-tile svg { flex: 0 0 auto; }
.quick-tile span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta .muted { color: var(--bar-muted); }
.muted { color: var(--muted); }

:root {
  --basket-w: 360px;
}
main {
  padding: 12px 16px 32px;
  max-width: 1400px;
  margin: 0 auto;
}
.basket-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 19;
}
.basket-backdrop.open { opacity: 1; }

.thumb {
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  opacity: 0;
  transition: opacity 0.18s ease;
}
.lightbox[hidden] { display: none !important; }
.lightbox:not([hidden]) { display: flex; }
.lightbox.open { opacity: 1; }
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}
.lightbox-close {
  appearance: none;
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right, 16px));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:active { background: rgba(255, 255, 255, 0.22); }
.basket {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(var(--basket-w), 100vw);
  background: #fff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.18);
}
.basket.open { transform: translateX(0); }
.basket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(env(safe-area-inset-top), 20px) 16px 14px;
  border-bottom: 1px solid var(--border);
  background: #000;
  color: #fff;
}
.basket-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.basket-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.basket-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.basket-clear {
  appearance: none;
  background: transparent;
  border: 1px solid #2a2f37;
  color: #c0c6cf;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.basket-clear:hover { color: #fff; border-color: #555; }
.basket-clear:disabled { opacity: 0.4; cursor: default; }
.basket-close {
  appearance: none;
  background: transparent;
  border: none;
  color: #fff;
  font: inherit;
  font-size: 28px;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.basket-close:hover { background: rgba(255,255,255,0.1); }
.basket-row {
  margin-top: 8px;
}
.basket-row .basket-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.basket-toggle {
  position: relative;
}
.basket-toggle-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.basket-toggle-count.zero {
  background: transparent;
  color: var(--bar-muted);
  border: 1px solid var(--bar-border);
}
.basket-items {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.basket-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.basket-item img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: var(--panel-2);
  border-radius: 6px;
}
.basket-item-info > div:first-child + div { font-size: 12px; }
.basket-item .basket-item-controls .qty-btn { width: 36px; height: 36px; font-size: 18px; }
.basket-item-info {
  min-width: 0;
}
.basket-item-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.basket-item-variant {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.basket-item-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.qty-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.qty-btn:active { background: var(--panel-2); }
.qty-num {
  min-width: 28px;
  text-align: center;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.basket-item-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.basket-item-price {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.basket-item-remove {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}
.basket-item-remove:hover { color: var(--bad); border-color: var(--bad); }
.basket-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.basket-empty .kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
}
.basket-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: #fafafa;
}
.basket-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.basket-total-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.basket-total {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.basket-print {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  min-height: 52px;
  border: 1px solid #000;
  background: #000;
  color: #fff;
  border-radius: var(--radius);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.basket-print:hover { background: #1a1a1a; }
.basket-print:active { background: #2a2a2a; }
.basket-print:disabled { opacity: 0.4; cursor: default; background: #555; border-color: #555; }
.basket-print svg { flex: 0 0 auto; }

@media print {
  body * { visibility: hidden; }
  #basket, #basket * { visibility: visible; }
  #basket {
    position: static !important;
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
    width: auto !important;
    color: #000 !important;
  }
  .basket-header {
    background: #fff !important;
    color: #000 !important;
    border-bottom: 2px solid #000 !important;
  }
  .basket-header .basket-count { background: #000 !important; color: #fff !important; }
  .basket-header-actions, .qty-btn, .basket-item-remove, .basket-print { display: none !important; }
  .basket-item-controls .qty-num { font-size: 14px; }
  .basket-footer { background: #fff !important; border-top: 2px solid #000 !important; }
  .basket-backdrop { display: none !important; }
}
.basket.empty .basket-items { display: none; }
.basket:not(.empty) #basket-empty { display: none; }
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.card:active { transform: scale(.985); border-color: var(--accent); }
.card:hover { box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08); }
.thumb {
  aspect-ratio: 1 / 1;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.thumb.empty { color: var(--muted); font-size: 12px; }
.card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}
.price { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.stock-line {
  font-size: 11px;
  font-weight: 700;
  color: #15803d;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stock-line.unknown { color: var(--muted); font-weight: 600; }
.stock-line.low { color: #b91c1c; }
.stock-line::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.variants {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.variant {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  line-height: 1.3;
  min-height: 44px;
}
.variant-name {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.variant-price {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
  font-size: 14px;
}
.variant-add {
  appearance: none;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid #15803d;
  background: #16a34a;
  color: #ffffff;
  border-radius: 8px;
  font: inherit;
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.variant-add:hover { background: #15803d; }
.variant-add:active { background: #166534; }
.variant-add.added {
  background: #dc2626;
  border-color: #b91c1c;
  color: #ffffff;
}
.variant-add.added:hover { background: #b91c1c; }
.variant-add.added:active { background: #991b1b; }
.tag {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 4px;
}
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  margin-right: 4px;
  vertical-align: middle;
}
#empty,
.list .empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}
.hidden { display: none; }

@media (max-width: 520px) {
  .list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  h1 { font-size: 18px; }
  .card-title { font-size: 13px; -webkit-line-clamp: 2; }
}
