:root {
  color-scheme: light;
  --ink: #2f241f;
  --muted: #74685f;
  --line: #e7ded2;
  --paper: #fffdf9;
  --soft: #f8f5ef;
  --accent: #8d6b38;
  --accent-dark: #5f4520;
  --success: #2f6f4e;
  --danger: #8a3129;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.toolbar,
.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding: 18px 0 16px;
}

.topbar-actions,
.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.language-switch {
  border: 1px solid var(--line);
  background: #fff;
  padding: 3px;
}

.language-button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
}

.language-button.active {
  background: var(--ink);
  color: #fff;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  max-width: 720px;
  font-size: 28px;
  line-height: 1.08;
  font-weight: 650;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 650;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 18px;
}

.login-panel {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 24px;
  align-items: center;
}

.muted {
  color: var(--muted);
  line-height: 1.45;
}

.access-help {
  margin: 14px 0 0;
  border-left: 3px solid var(--line);
  padding-left: 12px;
  color: #5e5149;
  font-size: 14px;
  line-height: 1.55;
}

.request-access {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-underline-offset: 4px;
}

.login-actions,
.login-form,
.order-options {
  display: grid;
  gap: 12px;
}

.existing-access {
  display: grid;
  gap: 11px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 14px;
}

.existing-access h3 {
  margin: 0;
}

.existing-access .muted {
  margin-top: 6px;
  font-size: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d9cec0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid #b8955c;
  outline-offset: 2px;
}

.primary,
.ghost,
.cart-chip,
.segment,
.category-option,
.qty-button {
  border: 1px solid var(--ink);
  min-height: 42px;
  padding: 0 14px;
  border-radius: 0;
  font-weight: 800;
}

.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.primary:hover {
  border-color: #3b332d;
  background: #3b332d;
}

.primary:disabled {
  border-color: #d4c8bb;
  background: #e9e0d4;
  color: #8b8177;
  cursor: not-allowed;
}

.ghost,
.cart-chip,
.segment,
.category-option,
.qty-button {
  background: #fff;
  color: var(--ink);
}

.compact {
  min-height: 36px;
  padding: 0 11px;
  font-size: 13px;
}

.cart-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

#cartCount {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.catalog {
  display: grid;
  gap: 16px;
}

.toolbar {
  align-items: end;
}

.search {
  min-width: min(360px, 100%);
}

.status {
  color: var(--muted);
}

.category-tree {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 14px;
}

.category-tree h3 {
  margin: 0;
}

.category-options {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.category-option {
  display: grid;
  gap: 5px;
  min-width: 0;
  height: 74px;
  align-content: center;
  text-align: left;
}

.category-option span,
.category-option strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-option span {
  font-size: 13px;
}

.category-option strong {
  color: var(--accent-dark);
  font-size: 19px;
}

.category-option.active {
  border-color: var(--accent);
  background: #fff7e7;
  color: var(--accent-dark);
}

.admin-catalog-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: #fff7e7;
  padding: 14px;
}

.admin-catalog-notice h3,
.admin-catalog-notice p {
  margin-bottom: 0;
}

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

.insight-block {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 14px;
}

.recent-orders {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 14px;
}

.insight-heading h3 {
  margin-bottom: 10px;
}

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

.quick-product {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  width: 100%;
  border: 1px solid #d9cec0;
  background: #fffaf2;
  padding: 10px;
  color: var(--ink);
  text-align: left;
}

.quick-product span,
.quick-product strong,
.quick-product small {
  min-width: 0;
}

.quick-product span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.quick-product small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.quick-product:disabled {
  color: #8b8177;
  cursor: not-allowed;
}

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

.recent-order {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #d9cec0;
  background: #fffaf2;
  padding: 10px;
}

.recent-order strong,
.recent-order span {
  display: block;
}

.recent-order span {
  color: var(--muted);
  font-size: 12px;
}

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

.product-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 12px;
}

.product-body {
  min-width: 0;
}

.product-body h3 {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.25;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tag {
  border: 1px solid var(--line);
  padding: 4px 7px;
  background: #fffaf2;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
}

.product-action {
  display: grid;
  grid-template-columns: minmax(120px, auto) auto;
  gap: 10px;
  align-items: center;
}

.price {
  font-size: 16px;
  font-weight: 800;
}

.stock {
  color: var(--muted);
  font-size: 12px;
}

.cart-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  width: min(440px, 100%);
  padding: 18px;
  background: var(--paper);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(0, 0, 0, .14);
  transform: translateX(105%);
  transition: transform .18s ease;
}

.cart-drawer.open {
  transform: translateX(0);
}

.cart-lines {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 12px 0;
}

.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border: 1px solid var(--line);
  padding: 12px;
  background: #fffaf2;
}

.cart-line strong {
  display: block;
  margin-bottom: 5px;
}

.qty {
  display: grid;
  grid-template-columns: 34px 34px 34px;
  align-items: center;
  text-align: center;
}

.qty-button {
  min-height: 34px;
  padding: 0;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.full {
  width: 100%;
}

.result {
  min-height: 24px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.result.ok {
  color: var(--success);
}

.result.error {
  color: var(--danger);
}

.admin-orders-list {
  display: grid;
  gap: 12px;
}

.admin-order {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 14px;
}

.admin-order header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.admin-order header strong {
  font-size: 20px;
}

.admin-order dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.admin-order dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-order dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.admin-notes {
  border: 1px solid #d9cec0;
  background: #fffaf2;
  padding: 10px;
  color: var(--muted);
}

.admin-lines {
  display: grid;
  gap: 6px;
}

.admin-lines div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

@media (max-width: 860px) {
  .topbar {
    display: grid;
    justify-content: stretch;
  }

  .cart-chip {
    justify-self: start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .login-panel,
  .product-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
  }

  .category-options {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-catalog-notice {
    align-items: stretch;
    flex-direction: column;
  }

  .category-option {
    height: 66px;
  }

  .product-card,
  .product-action {
    grid-template-columns: 1fr;
  }

  .product-action {
    align-items: stretch;
  }

  .insights {
    grid-template-columns: 1fr;
  }

  .recent-order,
  .admin-order dl {
    grid-template-columns: 1fr;
  }

  .admin-order header,
  .admin-lines div {
    display: grid;
  }

  .app-shell {
    padding: 14px;
  }
}
