:root {
  --ink: #1c1915;
  --muted: #5e574e;
  --paper: #f3efe7;
  --sheet: #fffdf9;
  --line: #e5dfd4;
  --accent: #9a3412;
  --accent-hover: #7c2a0e;
  --accent-soft: #f8ebe3;
  --pine: #166534;
  --pine-soft: #e8f6ee;
  --danger: #9f1239;
  --danger-soft: #fde8ee;
  --warn: #92400e;
  --header: #17191c;
  --shadow: 0 18px 40px rgba(40, 32, 22, 0.08);
  --sans: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --serif: "Fraunces", Palatino, "Palatino Linotype", serif;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html { touch-action: manipulation; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; }
button, a, label, summary { cursor: pointer; }
button { border: 0; background: none; }
a { color: inherit; text-decoration: none; }
:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}
::selection { background: #f3d2c3; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 80;
  background: white;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
}
.skip:focus { top: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header);
  color: #f7f3ec;
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 148px;
}
.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #2a241d;
  color: #f4efe6;
  flex: none;
}
.logo-mark svg { width: 22px; height: 22px; }
.brand-name {
  display: block;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  font-weight: 560;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.brand-sub {
  display: block;
  margin-top: 2px;
  color: #c8bfb2;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.search { flex: 1 1 240px; min-width: 180px; }
.search input,
.field input,
.field textarea,
.price-input,
.select,
.cat-filter,
.toolbar input[type="search"] {
  width: 100%;
  background: #fffdf9;
  border: 1px solid transparent;
  border-radius: 12px;
  min-height: 44px;
  padding: 0 14px;
}
.topbar .search input {
  background: #2a2723;
  color: #f7f3ec;
  border-color: #3a342c;
}
.topbar .search input::placeholder { color: #b3aa9e; }
.search input:hover,
.field input:hover,
.field textarea:hover,
.price-input:hover,
.select:hover { border-color: #d9d0c3; }
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: none;
}
.topbar :focus-visible { box-shadow: inset 0 0 0 2px #fff; }
.account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.account-link, .account-quiet {
  color: #d9d0c4;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 2px;
  background: none;
}
.account-link:hover, .account-quiet:hover { color: white; }
.account-mail {
  color: #b7aea3;
  font-size: 13px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cart-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f7f3ec;
  background: var(--accent);
  border-radius: 14px;
  min-height: 44px;
  padding: 6px 14px 6px 12px;
  transition: background 180ms ease;
}
.cart-btn:hover { background: var(--accent-hover); }
.cart-btn svg { width: 20px; height: 20px; flex: none; }
.cart-btn strong { display: block; font-size: 14px; font-weight: 700; }
.cart-btn small { display: block; color: #ffd7c4; font-size: 12px; }

.sync-line {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 20px 0;
  color: var(--muted);
  font-size: 13px;
}
.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 20px 48px;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.side {
  position: sticky;
  top: 92px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.side-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.side-head h2 { margin: 0; font-size: 16px; }
.side-head span, .meta { color: var(--muted); font-size: 13px; }
.cat-filter { margin-bottom: 8px; background: var(--paper); }
.cat-tree {
  max-height: calc(100vh - 250px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 2px 2px 0;
}
.cat-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  border-radius: 10px;
  margin-left: calc(var(--depth, 0) * 12px);
}
.cat-item:hover { background: var(--paper); }
.cat-item:has([aria-current="true"]) { background: var(--accent-soft); }
.cat-caret {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
}
button.cat-caret:hover { background: rgba(28, 25, 21, 0.06); }
.cat-caret svg { width: 14px; height: 14px; }
.cat-caret[aria-expanded="true"] svg { transform: rotate(90deg); }
.cat-btn {
  width: 100%;
  min-width: 0;
  text-align: left;
  border-radius: 10px;
  min-height: 40px;
  padding: 6px 8px 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  background: transparent;
}
.cat-btn:hover { background: transparent; }
.cat-btn span { min-width: 0; }
.cat-item:has([aria-current="true"]) .cat-btn {
  color: var(--accent);
  font-weight: 700;
}
.cat-btn small {
  color: var(--muted);
  font-weight: 600;
  flex: none;
}
.cat-item:has([aria-current="true"]) small { color: var(--accent); }

.sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin: 4px 2px 12px;
  flex-wrap: wrap;
}
.sheet-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 600;
}
.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent, #9a3412);
}
.cat-open {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin: 0;
  padding: 0 2px;
  background: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.user-price {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-currency {
  width: 11.5rem;
  min-width: 11.5rem;
}
.cat-markup { padding: 4px 0 8px; }
.cat-markup .cat-filter { width: min(320px, 100%); margin-bottom: 8px; }
.cat-markup-list { display: grid; gap: 6px; max-height: 420px; overflow: auto; }
.cat-markup-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 140px;
  gap: 8px;
  align-items: center;
}
.tree-caret {
  width: 22px;
  height: 22px;
  padding: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
}
.banner {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-weight: 600;
}
.banner a { color: var(--accent); }
.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.group {
  padding: 14px 18px 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: #fffaf6;
  border-top: 1px solid var(--line);
}
.group:first-child { border-top: 0; }
.row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 132px 220px;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.row.out { opacity: 0.62; }
.thumb, .ph {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: var(--paper);
  object-fit: cover;
}
.ph {
  display: grid;
  place-items: center;
  color: #b5ab9e;
}
.ph svg { width: 26px; height: 26px; }
.row h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; line-height: 1.3; }
.row p { margin: 0; color: var(--muted); font-size: 13px; }
.stock { font-size: 13px; font-weight: 700; color: var(--pine); }
.stock.bad { color: var(--danger); }
.price {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 16px;
  white-space: nowrap;
}
.price em { font-style: normal; color: var(--muted); font-weight: 600; font-size: 14px; }
.buy {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.qty {
  width: 64px;
  min-height: 42px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.btn {
  min-height: 42px;
  padding: 0 14px;
  flex: none;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  white-space: nowrap;
  transition: background 180ms ease;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: #e7e1d8; color: #8a8176; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--paper); }
.btn.full { width: 100%; }
.in-cart {
  display: inline-flex;
  align-items: center;
  flex: none;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.pager { display: flex; justify-content: center; padding: 16px 0 0; }
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}
.empty h2 { margin: 0 0 6px; color: var(--ink); font-size: 22px; font-family: var(--serif); font-weight: 560; }

.foot {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px 28px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 25, 28, 0.46);
  z-index: 40;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  width: min(440px, 100%);
  background: var(--sheet);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.16);
}
.drawer[hidden], .backdrop[hidden] { display: none !important; }
.drawer-head, .cart-foot {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.drawer-head { border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-family: var(--serif); font-weight: 560; font-size: 28px; }
.cart-lines { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px 18px 18px; -webkit-overflow-scrolling: touch; }
.cart-line {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.cart-line > .thumb,
.cart-line > .ph { width: 52px; height: 52px; }
.cart-body, .cart-sum { min-width: 0; }
.cart-sum { text-align: right; }
.cart-sum strong { white-space: nowrap; }
.cart-line h3 { margin: 0 0 4px; font-size: 14px; overflow-wrap: break-word; }
.cart-line p { margin: 0; color: var(--muted); font-size: 13px; }
.stepper { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.stepper button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--paper);
  font-weight: 800;
}
.stepper button:hover { background: var(--accent-soft); }
.remove {
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cart-foot {
  border-top: 1px solid var(--line);
  align-items: stretch;
  flex-direction: column;
  flex: none;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.total-row, .sum-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}
.total-row { font-size: 18px; font-weight: 800; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; font-weight: 650; font-size: 13px; }
.field textarea { min-height: 84px; padding: 10px 14px; resize: vertical; }
.form-error { color: var(--danger); white-space: pre-line; min-height: 1.2em; margin: 0 0 8px; font-size: 14px; }
.success { padding: 8px 0 20px; }
.success h3 { font-family: var(--serif); font-size: 32px; margin: 0 0 8px; font-weight: 560; }

.toasts {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--header);
  color: white;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  max-width: 320px;
}

.admin { background: var(--paper); }
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
}
.login-screen > * { min-width: 0; }
.login-hero {
  background: var(--header);
  color: #f6f1e8;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}
.login-hero h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(48px, 6vw, 84px);
  letter-spacing: -0.04em;
  line-height: 0.95;
  margin: 24px 0 12px;
}
.login-hero p { max-width: 420px; color: #d5cbbf; font-size: 18px; }
.login-panel {
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.login-card { width: min(380px, 100%); }
.login-card h2 { font-family: var(--serif); font-size: 36px; font-weight: 560; margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 14px; }
.back-link { display: inline-block; margin-top: 14px; color: var(--muted); font-weight: 650; }
.provider {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
}
.provider:hover { background: var(--paper); }
.provider svg { width: 18px; height: 18px; flex: none; }
.provider:disabled { opacity: 0.55; cursor: not-allowed; }
#google-slot { margin-top: 10px; min-height: 44px; max-width: 100%; }
#google-slot:empty { display: none; }

.admin-bar {
  background: var(--header);
  color: #f6f1e8;
}
.admin-bar-inner, .admin-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 20px;
}
.admin-bar-inner { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.admin-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quiet { color: #d9d0c4; font-weight: 650; padding: 8px; }
.quiet:hover { color: white; }
.admin-wrap { padding-top: 22px; padding-bottom: 48px; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}
.stat b {
  display: block;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat span { color: var(--muted); font-size: 13px; }
.panel {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 10px; font-family: var(--serif); font-weight: 560; font-size: 22px; }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--line);
  font-weight: 750;
}
.tab.active { background: var(--ink); color: white; border-color: var(--ink); }
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  margin-left: 6px;
}
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}
.toolbar .grow { flex: 1 1 220px; }
.markup {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.markup label, .toolbar label { font-size: 13px; font-weight: 700; display: flex; flex-direction: column; gap: 6px; }
.markup input[type="number"] { width: 120px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 220px); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
#users-panel table { min-width: 920px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  position: sticky;
  top: 0;
  background: #fffaf4;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  z-index: 1;
}
.product-cell { display: flex; gap: 10px; align-items: center; min-width: 220px; }
.product-cell img, .product-cell .ph { width: 46px; height: 46px; border-radius: 10px; flex: none; }
.product-cell strong { display: block; }
.product-cell span { color: var(--muted); font-size: 12px; }
.price-input { width: 120px; min-height: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.margin.pos { color: var(--pine); font-weight: 800; }
.margin.neg { color: var(--danger); font-weight: 800; }
.num { font-variant-numeric: tabular-nums; }
.pager-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
.order {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--sheet);
}
.order.new { border-left-color: var(--accent); }
.order-head, .order-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.order h3 { margin: 0; font-size: 18px; }
.order-items { width: 100%; min-width: 0; margin: 12px 0; }
.order-items td { font-size: 14px; }
.subtabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.subtab {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  font-weight: 700;
}
.subtab.active { background: var(--ink); color: white; border-color: var(--ink); }
.subtab .count { margin-left: 6px; opacity: 0.72; }
.order-note { margin: 0 0 12px; }
.table-wrap.loose { max-height: none; }
.report-note { margin: 8px 0 0; }
.loss { background: #fff5f5; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .cat-tree { max-height: 240px; }
  .row {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    grid-template-areas:
      "img info price"
      "buy buy buy";
  }
  .row > .thumb, .row > .ph { grid-area: img; }
  .info { grid-area: info; }
  .price { grid-area: price; align-self: center; }
  .buy { grid-area: buy; justify-content: flex-end; }
  .login-screen { grid-template-columns: 1fr; }
  .login-hero { min-height: auto; padding: 28px 22px 22px; }
  .login-hero h1 { font-size: 56px; }
}
@media (max-width: 640px) {
  .sheet-head h1 { font-size: 28px; }
  .buy { flex-wrap: wrap; justify-content: flex-end; }
  .user-price { flex-wrap: wrap; }
  .cart-btn small { display: none; }
  .row {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    grid-template-areas:
      "img info info"
      "price price price"
      "buy buy buy";
  }
  .price { justify-self: end; }
  .drawer { width: 100%; }
  .cart-line {
    grid-template-columns: 48px minmax(0, 1fr);
  }
  .cart-line > .thumb,
  .cart-line > .ph {
    width: 48px;
    height: 48px;
    grid-row: 1 / span 2;
    grid-column: 1;
  }
  .cart-body { grid-column: 2; grid-row: 1; }
  .cart-sum { grid-column: 2; grid-row: 2; justify-self: start; text-align: left; }
  .login-hero h1 { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
