:root {
  --ink: #1b1714;
  --muted: #6d645c;
  --paper: #f4efe8;
  --card: #fffdfb;
  --line: #e4dcd2;
  --accent: #c2410c;
  --accent-dark: #9a3412;
  --good: #1f6b45;
  --shadow: 0 16px 40px rgba(40, 24, 10, 0.12);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 20px;
  background: var(--ink);
  color: #f7f1ea;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.brand strong { display: block; font-size: 1.05rem; letter-spacing: 0.01em; }
.brand small { color: #d8c8b8; }
.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  font-weight: 700;
}
.search input {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: #2a241f;
  color: #fff;
}
.search input::placeholder { color: #b5a89c; }
.cart-btn, .add, .primary, .ghost, .page-btn, .cat {
  border: 0;
  border-radius: 999px;
}
.cart-btn {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.cart-btn span {
  min-width: 1.4rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  text-align: center;
}

main { width: min(1180px, calc(100% - 32px)); margin: 24px auto 48px; }
.toolbar-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 14px 0;
  color: var(--muted);
}
.toolbar-meta select {
  margin-left: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 10px;
}
.cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.cat {
  flex: none;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--line);
}
.cat[aria-selected="true"] {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.card-open {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  text-align: left;
  background: transparent;
  border: 0;
}
.card-open img, .ph {
  aspect-ratio: 1;
  object-fit: cover;
  background: #efe8df;
}
.ph { display: grid; place-items: center; color: var(--muted); font-size: 2rem; }
.card h2 {
  margin: 0;
  padding: 0 12px;
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.3;
  min-height: 2.6em;
}
.price {
  margin: 0;
  padding: 0 12px 4px;
  color: var(--accent-dark);
  font-size: 1.15rem;
  font-weight: 750;
}
.add, .primary {
  margin: 8px 12px 12px;
  padding: 10px 12px;
  background: var(--ink);
  color: white;
  font-weight: 700;
}
.primary { margin: 0; }
.add:hover, .primary:hover, .cart-btn:hover { filter: brightness(1.08); }
.ghost {
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--line);
}
.empty {
  grid-column: 1 / -1;
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.pager { display: flex; justify-content: center; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.page-btn {
  min-width: 40px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
}
.page-btn[aria-current="page"] { background: var(--ink); color: white; }

dialog {
  width: min(720px, calc(100% - 24px));
  border: 0;
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(20, 14, 10, 0.48); }
#cart-dialog { width: min(460px, calc(100% - 24px)); }
.dialog-head, .product-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  font-size: 1.4rem;
  line-height: 1;
}
.product-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
.product-layout img, .product-layout .ph { width: 100%; border-radius: 12px; aspect-ratio: 1; object-fit: cover; }
.qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}
.qty button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
}
.cart-line {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.cart-line img, .cart-line .ph { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.cart-total { display: flex; justify-content: space-between; font-size: 1.15rem; font-weight: 750; margin: 14px 0; }
.checkout { display: grid; gap: 8px; }
.checkout input, .checkout textarea, .checkout select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: white;
}
.checkout textarea { min-height: 72px; resize: vertical; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.actions .primary { display: inline-block; margin: 0; text-align: center; text-decoration: none; }
.ok { color: var(--good); }
.remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  text-decoration: underline;
}

footer { padding: 8px 20px 28px; text-align: center; color: var(--muted); }
footer a { color: var(--accent-dark); }
.admin { width: min(640px, calc(100% - 32px)); margin: 28px auto 48px; display: grid; gap: 16px; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: grid;
  gap: 12px;
}
.panel h1, .panel h2 { margin: 0; }
.panel p { margin: 0; }
.panel label { font-weight: 700; }
[hidden] { display: none !important; }
#admin-app { display: grid; gap: 16px; }
.panel input {
  width: min(100%, 16rem);
  margin-top: 6px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: white;
}
.hint, .status { color: var(--muted); }
.warn { color: var(--accent-dark); }
button:disabled { opacity: 0.55; cursor: wait; }
.top .cart-btn { text-decoration: none; }

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .top { grid-template-columns: 1fr auto; }
  .search { grid-column: 1 / -1; order: 3; }
  .product-layout { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  main { width: min(100% - 16px, 1180px); }
  .card h2 { font-size: 0.9rem; }
}
