:root {
  --ink: #ffffff;
  --muted: #ffe7c7;
  --line: #8a6554;
  --paper: #4c3428;
  --soft: #5b3d30;
  --soft-2: #684638;
  --cream: #ffebcd;
  --cream-2: #ead2ad;
  --orange: #ea953c;
  --green: #648c4e;
  --danger: #d96b5f;
  --button-text: #4c3428;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.22);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(100, 140, 78, 0.16), rgba(76, 52, 40, 0) 250px),
    var(--paper);
  color: var(--ink);
  font-family: var(--font);
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 28px;
}

.topbar,
.kitchen-head,
.admin-head,
.admin-products-head,
.admin-savebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  min-height: 74px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 31px;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 235, 205, 0.22);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.plain-button,
.ghost-button,
.primary-button {
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.plain-button {
  border: 1px solid var(--line);
  background: rgba(255, 235, 205, 0.08);
  color: var(--cream);
  padding: 0 14px;
}

.plain-button:hover,
.ghost-button:hover {
  border-color: var(--cream);
}

.primary-button {
  border: 1px solid var(--orange);
  background: var(--orange);
  color: var(--button-text);
  padding: 0 18px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
}

.primary-button:hover {
  background: #f0a34e;
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--cream);
  padding: 0 14px;
}

.is-hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.kitchen-view {
  display: block;
  padding: 28px 0 0;
}

.admin-view {
  display: none;
  padding: 28px 0 0;
}

.app-shell[data-view="admin"] .kitchen-view {
  display: none;
}

.app-shell[data-view="admin"] .admin-view {
  display: block;
}

.app-shell[data-view="admin"] #openAdmin {
  display: none;
}

.app-shell[data-view="admin"] #closeAdmin {
  display: inline-flex !important;
}

.search-box,
.pin-field,
.add-product label {
  display: grid;
  gap: 7px;
}

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

.search-box span,
.pin-field span,
.add-product label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--cream);
  color: var(--button-text);
  padding: 0 13px;
}

input:focus,
select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(234, 149, 60, 0.22);
}

.category-tabs,
.admin-category-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 18px 0 16px;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar,
.admin-category-filter::-webkit-scrollbar {
  display: none;
}

.tab-button,
.admin-tab {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 235, 205, 0.07);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  padding: 0 15px;
}

.tab-button[aria-pressed="true"],
.admin-tab[aria-pressed="true"] {
  border-color: var(--cream);
  background: var(--cream);
  color: var(--button-text);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(188px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.product-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 86px;
  border: 1px solid rgba(255, 235, 205, 0.22);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
  font-size: 20px;
  font-weight: 950;
  line-height: 1.08;
  padding: 14px;
  text-align: center;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.13);
}

.product-button:hover,
.product-button:focus-visible {
  border-color: var(--orange);
  background: var(--soft-2);
  outline: none;
}

.product-button:active {
  transform: translateY(1px);
}

.empty-state {
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-weight: 800;
  text-align: center;
}

.last-print {
  position: sticky;
  bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(580px, 100%);
  margin: 22px auto 0;
  border: 1px solid rgba(255, 235, 205, 0.32);
  border-radius: 8px;
  background: rgba(91, 61, 48, 0.96);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}

.last-print span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.last-print strong {
  text-align: right;
}

.admin-head {
  margin-bottom: 20px;
}

.pin-field {
  width: min(240px, 100%);
}

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

.add-product,
.admin-products {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(91, 61, 48, 0.78);
  padding: 16px;
}

.add-product {
  display: grid;
  gap: 13px;
}

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

.product-row {
  display: grid;
  grid-template-columns: 1fr 104px 92px;
  gap: 10px;
  align-items: end;
  border: 1px solid rgba(255, 235, 205, 0.16);
  border-radius: 8px;
  background: rgba(76, 52, 40, 0.62);
  padding: 12px;
}

.product-row label {
  display: grid;
  gap: 6px;
}

.product-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.delete-button {
  min-height: 52px;
  border: 1px solid rgba(217, 107, 95, 0.68);
  border-radius: 8px;
  background: rgba(217, 107, 95, 0.12);
  color: #ffd8d3;
  cursor: pointer;
  font-weight: 900;
}

.delete-button:hover {
  background: rgba(217, 107, 95, 0.2);
}

.admin-savebar {
  position: sticky;
  bottom: 10px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(91, 61, 48, 0.74), var(--soft));
  padding-top: 14px;
}

.admin-savebar p {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

#printArea {
  display: none;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 680px);
  }

  .topbar,
  .kitchen-head,
  .admin-head,
  .admin-products-head,
  .admin-savebar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .admin-savebar {
    width: 100%;
  }

  .topbar-actions > * {
    flex: 1 1 auto;
    justify-content: center;
  }

  .search-box,
  .pin-field {
    width: 100%;
  }

  .product-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .product-button {
    min-height: 78px;
    font-size: 18px;
  }

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

  .product-row {
    grid-template-columns: 1fr;
  }

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

  .last-print strong {
    text-align: left;
  }
}

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

@media print {
  @page {
    size: 62mm 29mm;
    margin: 0;
  }

  html,
  body {
    width: 62mm;
    height: 29mm;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  body * {
    visibility: hidden !important;
  }

  #printArea,
  #printArea * {
    visibility: visible !important;
  }

  #printArea {
    position: fixed;
    inset: 0 auto auto 0;
    display: block !important;
    width: 62mm;
    height: 29mm;
    overflow: hidden;
  }

  .print-label {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 62mm;
    height: 29mm;
    padding: 3.2mm 4mm;
    background: #ffffff;
    color: #111111;
    font-family: Arial, Helvetica, sans-serif;
    text-align: center;
  }

  .print-product {
    overflow-wrap: break-word;
    font-size: 21pt;
    font-weight: 900;
    line-height: 0.95;
    text-transform: none;
  }

  .print-date {
    margin-top: 2.2mm;
    border-top: 0.45mm solid #111111;
    padding-top: 1.8mm;
    font-size: 14pt;
    font-weight: 900;
    line-height: 1;
  }

  .print-label[data-size="medium"] .print-product {
    font-size: 18pt;
  }

  .print-label[data-size="small"] .print-product {
    font-size: 15.5pt;
    line-height: 1;
  }

  .print-label[data-size="tiny"] .print-product {
    font-size: 13.5pt;
    line-height: 1;
  }
}
