:root {
  --bg: #efe8d8;
  --bg-2: #f7f2e8;
  --ink: #1c241c;
  --muted: #5b6458;
  --line: #d7cdb8;
  --panel: #fffdf7;
  --green: #1f3a2e;
  --green-2: #2d5644;
  --gold: #e2b93b;
  --cash: #2f6b3a;
  --card: #1d4f8a;
  --danger: #a33b2c;
  --ok: #1f7a45;
  --shadow: 0 10px 30px rgba(28, 36, 28, 0.12);
  --radius: 18px;
  --touch: 64px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #fff7e4, var(--bg));
  color: var(--ink);
  overflow: hidden;
}

button, input, select { font: inherit; }
button { cursor: pointer; border: 0; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: 64px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--green);
  color: #fff;
}
.brand { font-weight: 800; letter-spacing: 0.04em; font-size: 1.15rem; }
.brand small { display: block; font-weight: 500; opacity: 0.75; letter-spacing: 0; font-size: 0.72rem; }
.spacer { flex: 1; }
.pill {
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.9rem;
}
.topbar a, .ghost {
  color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,0.12);
  padding: 8px 12px;
  border-radius: 10px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  min-height: 0;
}

.catalog {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  padding: 12px;
  gap: 12px;
}

.cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.cat {
  background: var(--panel);
  border: 2px solid var(--line);
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}
.cat.active { background: var(--green); color: #fff; border-color: var(--green); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  overflow: auto;
  padding-bottom: 12px;
}
.product {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 96px;
  max-height: 140px;
  aspect-ratio: 4 / 3;
  padding: 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 2px solid transparent;
  border-left: 8px solid var(--tile, var(--gold));
}
.product:active { transform: scale(0.98); }
.product .name { font-size: 1.25rem; font-weight: 800; }
.product .price { font-size: 1.1rem; color: var(--green); font-weight: 700; }

.cart {
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: 0;
}
.cart h2 { margin: 0; padding: 16px; font-size: 1.1rem; }
.lines { overflow: auto; padding: 0 12px 12px; }
.line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}
.line .title { font-weight: 700; }
.line .meta { color: var(--muted); font-size: 0.85rem; }
.qty {
  display: flex;
  align-items: center;
  gap: 6px;
}
.qty button {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--bg);
  font-size: 1.3rem;
  font-weight: 800;
}
.qty .n { min-width: 24px; text-align: center; font-weight: 800; }
.remove {
  background: transparent;
  color: var(--danger);
  font-weight: 700;
  padding: 4px 0;
}

.total {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.6rem;
  font-weight: 800;
  border-top: 1px solid var(--line);
}
.pay {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}
.pay button {
  min-height: var(--touch);
  border-radius: 16px;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.btn-cash { background: var(--cash); }
.btn-card { background: var(--card); }
.btn-clear {
  grid-column: 1 / -1;
  background: var(--bg);
  color: var(--ink);
  min-height: 44px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 20, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}
.overlay.show { display: flex; }
.modal {
  background: var(--panel);
  width: min(560px, 100%);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.modal h2 { margin: 0 0 8px; font-size: 1.8rem; }
.modal p { color: var(--muted); font-size: 1.1rem; }
.modal .amount { font-size: 2.4rem; font-weight: 800; margin: 12px 0 20px; }
.modal .actions { display: grid; gap: 10px; }
.modal .actions button, .big {
  min-height: var(--touch);
  border-radius: 16px;
  font-weight: 800;
  font-size: 1.1rem;
}
.ok { background: var(--ok); color: #fff; }
.warn { background: var(--gold); }
.bad { background: var(--danger); color: #fff; }
.secondary { background: var(--bg); }
.spinner {
  width: 48px; height: 48px; margin: 12px auto;
  border: 5px solid #eadfbf;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Register picker */
.picker {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.picker button {
  min-height: 72px;
  background: var(--bg-2);
  border-radius: 16px;
  text-align: left;
  padding: 12px 16px;
  border: 2px solid var(--line);
}
.picker button strong { display: block; font-size: 1.15rem; }
.picker button span { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.picker button span { color: var(--muted); font-size: 0.9rem; }
.admin h2, .admin h3 { margin: 0 0 12px; }
.admin h3 { margin-top: 18px; }
.meta { color: var(--muted); padding: 12px; }

/* Admin */
.admin-body { overflow: auto; }
.admin {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat .k { color: var(--muted); }
.stat .v { font-size: 1.6rem; font-weight: 800; }
.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
form.row, .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input, select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  min-height: 44px;
}
.admin .ok, .admin .secondary, .admin .bad { padding: 10px 14px; border-radius: 10px; min-height: 44px; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .layout { grid-template-columns: 1fr; }
  .cart { border-left: 0; border-top: 1px solid var(--line); min-height: 42vh; }
  .product { aspect-ratio: auto; max-height: none; }
}

.bo-app { min-height: 100dvh; display: grid; grid-template-rows: 64px 1fr; }
.bo-layout { display: grid; grid-template-columns: 220px 1fr; min-height: 0; }
.bo-nav {
  background: var(--green);
  color: #fff;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bo-nav a {
  color: #fff;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  opacity: 0.85;
}
.bo-nav a.active, .bo-nav a:hover { background: rgba(255,255,255,0.14); opacity: 1; }
.admin-body { overflow: auto; }
@media (max-width: 900px) {
  .bo-layout { grid-template-columns: 1fr; }
  .bo-nav { flex-direction: row; overflow-x: auto; }
}
