:root {
  --pepper: #9f241c;
  --tomato: #d94a2b;
  --mustard: #f1a51d;
  --leaf: #31734b;
  --cream: #fff8ed;
  --paper: #fffdf8;
  --ink: #24130b;
  --muted: #735f51;
  --line: #ead8c1;
  --shadow: 0 18px 45px rgba(76, 38, 14, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(217, 74, 43, 0.12), rgba(49, 115, 75, 0.08)),
    var(--cream);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.shell {
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 44px);
  background: rgba(255, 248, 237, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar strong {
  color: var(--pepper);
  font-size: 1.1rem;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar a,
.button,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.button.primary,
button.primary {
  border-color: var(--pepper);
  background: var(--pepper);
  color: white;
}

.button.success,
button.success {
  border-color: var(--leaf);
  background: var(--leaf);
  color: white;
}

.home,
.page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero {
  min-height: 420px;
  display: grid;
  align-content: center;
  padding: clamp(28px, 7vw, 72px) 0;
}

.eyebrow {
  color: var(--leaf);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.82rem;
}

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

h1 {
  max-width: 760px;
  font-size: clamp(2.35rem, 7vw, 5.7rem);
  line-height: 0.96;
  margin-bottom: 18px;
}

.hero p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.55;
}

.actions,
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.quick-grid,
.grid,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.quick-card,
.card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.quick-card {
  display: grid;
  gap: 6px;
  padding: 20px;
}

.quick-card span,
.muted {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.auth-panel {
  max-width: 420px;
  margin: 42px auto;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.product-list,
.order-list,
.list {
  display: grid;
  gap: 12px;
}

.product,
.order,
.line-item,
.metric {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.metric {
  min-height: 132px;
  align-content: space-between;
}

.metric span {
  color: var(--leaf);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.metric strong {
  color: var(--pepper);
  font-size: 2rem;
}

.metric small {
  color: var(--muted);
  font-weight: 800;
}

.product-head,
.order-head,
.line-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.price {
  color: var(--pepper);
  font-weight: 900;
  white-space: nowrap;
}

.code {
  color: var(--leaf);
  font-weight: 900;
  font-size: 0.8rem;
}

.qty {
  display: grid;
  grid-template-columns: 42px 46px 42px;
  gap: 8px;
  align-items: center;
}

.qty button {
  padding: 9px 0;
}

.qty output {
  text-align: center;
  font-weight: 900;
}

.cart {
  position: sticky;
  top: 82px;
}

.total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
  font-size: 1.2rem;
  font-weight: 900;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented label {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-weight: 800;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented label:has(input:checked) {
  background: var(--mustard);
  border-color: #c78307;
}

form {
  display: grid;
  gap: 10px;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
}

textarea {
  min-height: 78px;
  resize: vertical;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button.active {
  background: var(--pepper);
  color: white;
  border-color: var(--pepper);
}

.admin-section[hidden] {
  display: none;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(241, 165, 29, 0.18);
  color: #7d4d00;
  font-weight: 900;
  font-size: 0.78rem;
}

.status.done {
  background: rgba(49, 115, 75, 0.15);
  color: var(--leaf);
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.qr-card {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 8px;
  justify-items: center;
  align-items: start;
  min-height: 292px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  text-align: center;
  break-inside: avoid;
  page-break-inside: avoid;
  overflow: hidden;
}

.qr-card strong,
.qr-card h2,
.qr-card small {
  max-width: 100%;
}

.qr-card strong {
  min-height: 20px;
  color: var(--pepper);
  font-size: 0.88rem;
  line-height: 1.2;
}

.qr-card h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.15;
}

.qr-card img {
  width: min(170px, 100%);
  aspect-ratio: 1;
  height: auto;
}

.qr-card small {
  align-self: end;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .cart {
    position: static;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .qr-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .qr-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  .topbar,
  .toolbar .actions,
  .no-print {
    display: none;
  }

  body {
    background: white;
  }

  .page {
    width: 100%;
    padding: 0;
  }

  .qr-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .qr-card {
    box-shadow: none;
    min-height: 252px;
    padding: 8px;
  }

  .qr-card img {
    width: 132px;
  }
}
