:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #121212;
  --muted: #686868;
  --line: #e6e2dc;
  --red: #ef2d18;
  --red-dark: #c91e10;
  --green: #12923f;
  --green-soft: #e7f8ed;
  --amber: #f8b51d;
  --shadow: 0 14px 32px rgba(18, 18, 18, 0.11);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 68px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #f3f2ef;
  color: var(--ink);
}

.title {
  margin: 0;
  text-align: center;
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
}

.order-btn,
.primary-btn,
.pay-btn,
.confirm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 13px;
  background: var(--red);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(239, 45, 24, 0.22);
}

.order-btn:disabled,
.primary-btn:disabled,
.pay-btn:disabled {
  opacity: 0.42;
  box-shadow: none;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #9ee4b6;
  color: var(--green);
  background: var(--green-soft);
  font-size: 13px;
  font-weight: 800;
}

.content {
  padding: 12px 14px 228px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.tab {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 56px;
  padding: 5px 2px;
  border-radius: 14px;
  background: #f4f3f1;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.tab-icon {
  font-size: 21px;
  line-height: 1;
}

.tab.active {
  background: var(--red);
  color: #fff;
}

.ticket-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.ticket-strip::-webkit-scrollbar {
  display: none;
}

.ticket-btn,
.add-ticket {
  flex: 0 0 64px;
  min-height: 54px;
  border-radius: 14px;
  background: #f3f2ef;
  color: var(--ink);
  font-size: 20px;
  font-weight: 950;
}

.ticket-btn.active {
  background: #111;
  color: #fff;
}

.ticket-btn[data-ticket="delivery"] { background: #e9f7ee; color: var(--green); }
.ticket-btn[data-ticket="delivery"].active { background: #087331; color: #fff; }

.ticket-btn.has-items::after {
  content: attr(data-count);
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  margin-left: 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 14px;
}

.add-ticket {
  position: sticky;
  right: 0;
  background: var(--green);
  color: #fff;
  box-shadow: -10px 0 18px rgba(255, 255, 255, 0.86);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.food-card {
  position: relative;
  overflow: hidden;
  min-height: 190px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(18, 18, 18, 0.08);
}

.food-card:active {
  transform: scale(0.985);
}

.food-card.has-image {
  min-height: 168px;
}

.food-art {
  display: grid;
  place-items: center;
  height: 128px;
  background: var(--art-bg, #f5eadf);
  background-image:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.8) 0 16%, transparent 17%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.04));
}

.food-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.food-card.has-image .food-art {
  height: 168px;
}

.food-card.has-image .food-info {
  position: relative;
  min-height: 42px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid rgba(230, 226, 220, 0.9);
  box-shadow: 0 -10px 22px rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
}

.food-emoji {
  font-size: 68px;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.16));
}

.food-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.94);
}

.food-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 900;
}

.food-price {
  flex: 0 0 auto;
  font-size: 17px;
  line-height: 1;
  font-weight: 950;
}

.qty-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 26px;
  font-weight: 950;
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.16);
}

.cart-bar {
  position: fixed;
  right: max(14px, calc((100vw - 720px) / 2 + 14px));
  bottom: calc(74px + var(--safe-bottom));
  left: max(14px, calc((100vw - 720px) / 2 + 14px));
  z-index: 30;
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 10px;
  max-width: 692px;
  margin: 0 auto;
  padding: 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.cart-total {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 6px;
  min-height: 62px;
  border-radius: 14px;
  color: var(--ink);
  background: #f8f6f1;
  font-weight: 950;
}

.cart-total .tiny {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.cart-total .big {
  display: block;
  font-size: 21px;
}

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

.review-row {
  display: grid;
  grid-template-columns: 118px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 136px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.thumb {
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--art-bg, #f5eadf);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb .food-emoji {
  font-size: 58px;
}

.row-name {
  font-size: 20px;
  font-weight: 950;
}

.row-sum {
  color: var(--muted);
  font-size: 18px;
  font-weight: 950;
  white-space: nowrap;
}

.stepper {
  display: grid;
  grid-template-columns: 44px 48px 44px;
  align-items: center;
  justify-items: center;
  gap: 5px;
}

.stepper button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #f1f0ed;
  color: var(--red);
  font-size: 30px;
  font-weight: 900;
}

.stepper strong {
  font-size: 26px;
}

.review-footer {
  position: sticky;
  bottom: calc(72px + var(--safe-bottom));
  display: grid;
  gap: 10px;
  padding: 12px 0 calc(12px + var(--safe-bottom));
  background: linear-gradient(transparent, #fff 14px, #fff);
}

.total-line {
  display: flex;
  align-items: end;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 900;
}

.total-line strong {
  font-size: 38px;
  line-height: 1;
}

.pay-btn {
  width: 100%;
  min-height: 72px;
  font-size: 30px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 18px 12px calc(18px + var(--safe-bottom));
  background: rgba(0, 0, 0, 0.58);
}

.payment-modal {
  width: min(100%, 560px);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 24px;
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
}

.modal-title {
  margin: 0;
  text-align: center;
  font-size: 24px;
  font-weight: 950;
}

.large-total {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  margin: 6px 0 14px;
}

.large-total strong {
  font-size: clamp(66px, 20vw, 104px);
  line-height: 0.95;
  font-weight: 950;
}

.cash-panel,
.change-panel {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.cash-panel label,
.change-panel span {
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
}

.cash-value,
.change-value {
  text-align: right;
  font-size: 52px;
  line-height: 1;
  font-weight: 950;
}

.change-panel {
  background: var(--green-soft);
  border-color: #ccefd7;
}

.change-value {
  color: var(--green);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.key {
  min-height: 68px;
  border-radius: 12px;
  background: #f5f4f1;
  color: var(--ink);
  font-size: 34px;
  font-weight: 950;
  border: 1px solid var(--line);
}

.confirm-btn {
  width: 100%;
  min-height: 70px;
  margin-top: 12px;
  background: var(--green);
  font-size: 27px;
  box-shadow: 0 8px 18px rgba(18, 146, 63, 0.24);
}

.exact-pay-btn { width: 100%; min-height: 56px; margin-top: 8px; border-radius: 13px; background: var(--red); color: #fff; font-size: 19px; font-weight: 950; }

.pin-panel {
  display: grid;
  gap: 12px;
  width: min(100%, 420px);
  border-radius: 24px;
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
}

.pin-title {
  margin: 0;
  text-align: center;
  font-size: 27px;
  font-weight: 950;
}

.pin-display {
  display: grid;
  place-items: center;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #faf9f6;
  font-size: 36px;
  font-weight: 950;
  letter-spacing: 8px;
}

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

.secondary-btn {
  min-height: 58px;
  border-radius: 14px;
  background: #f3f2ef;
  color: var(--ink);
  font-size: 21px;
  font-weight: 950;
}

.dashboard {
  display: grid;
  gap: 14px;
}

.products-page {
  display: grid;
  gap: 18px;
}

.product-intro {
  border-top: 4px solid var(--green);
}

.product-intro p,
.section-heading p {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 750;
}

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

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 950;
}

.section-heading p {
  margin: 4px 0 0;
}

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

.product-editor {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.product-image-edit {
  align-self: start;
}

.product-image {
  width: 104px;
  height: 104px;
  overflow: hidden;
  border: 1px solid rgba(18, 18, 18, 0.08);
  border-radius: 8px;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image .food-emoji {
  font-size: 48px;
}

.product-editor-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
}

.product-editor-fields .field:nth-child(3),
.product-editor-fields .replace-photo {
  grid-column: 1 / -1;
}

.small-upload {
  min-height: 52px;
  font-size: 17px;
}

.save-product {
  grid-column: 1 / -1;
  min-height: 52px;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-size: 18px;
  font-weight: 950;
}

.delete-product { grid-column: 1 / -1; min-height: 44px; border-radius: 10px; background: #fff1ef; color: var(--red-dark); font-size: 16px; font-weight: 900; }
.category-manager { display: grid; gap: 10px; }
.category-add { display: grid; grid-template-columns: 1fr 88px; gap: 8px; }
.category-add input { min-width: 0; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; font-size: 16px; font-weight: 800; }
.category-add button { border-radius: 10px; background: var(--green); color: #fff; font-weight: 900; }
.category-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.category-chips span { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #faf9f6; font-weight: 800; }
.category-chips button { width: 24px; height: 24px; border-radius: 7px; background: #fff1ef; color: var(--red); font-size: 18px; font-weight: 950; }

.refresh-data {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  border: 1px solid #9edbb3;
  border-radius: 8px;
  background: var(--green-soft);
  color: #087331;
  font-size: 19px;
  font-weight: 950;
}

.refresh-data:disabled { opacity: 0.62; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  display: grid;
  gap: 4px;
  padding: 14px 8px;
  border-radius: 8px;
  background: #fbf2ef;
  text-align: center;
}

.stat:nth-child(2) {
  background: #edf8f1;
}

.stat:nth-child(3) {
  background: #fff5d8;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.stat strong {
  font-size: 24px;
  font-weight: 950;
}

.panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 950;
}

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

.bill-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

.bill-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.bill-name {
  font-size: 20px;
  font-weight: 950;
}

.bill-time {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.bill-total {
  color: var(--red);
  text-align: right;
  font-size: 24px;
  font-weight: 950;
  white-space: nowrap;
}

.bill-items {
  display: grid;
  gap: 6px;
}

.bill-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
}

.menu-editor {
  display: grid;
  gap: 10px;
}

.menu-edit-row {
  display: grid;
  grid-template-columns: 44px 1fr 82px 78px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

.menu-edit-row input {
  min-width: 0;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
  font-weight: 900;
}

.menu-edit-row button {
  height: 46px;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  font-weight: 950;
}

.mini-thumb {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--art-bg, #f5eadf);
  font-size: 23px;
}

.mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chart {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  align-items: end;
  gap: 6px;
  height: 150px;
  padding-top: 10px;
  border-bottom: 1px solid var(--line);
}

.bar {
  min-height: 12px;
  border-radius: 5px 5px 0 0;
  background: #45b564;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
}

.field input,
.field select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font-size: 19px;
  font-weight: 850;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 72px;
  border: 2px dashed #cfc9c1;
  border-radius: 14px;
  background: #faf9f6;
  color: var(--ink);
  font-size: 22px;
  font-weight: 950;
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.save-menu {
  min-height: 58px;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  font-size: 23px;
  font-weight: 950;
}

.bottom-nav {
  position: fixed;
  right: max(0px, calc((100vw - 720px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 720px) / 2));
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 720px;
  margin: 0 auto;
  padding: 5px 6px calc(5px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav-btn {
  display: grid;
  place-items: center;
  gap: 1px;
  min-height: 54px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.nav-btn.active {
  color: var(--red);
  background: #fff1ef;
}

.nav-icon {
  font-size: 25px;
  line-height: 1;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  text-align: center;
  font-size: 22px;
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(98px + var(--safe-bottom));
  z-index: 70;
  transform: translateX(-50%);
  width: min(calc(100vw - 28px), 500px);
  padding: 14px 16px;
  border-radius: 16px;
  background: #111;
  color: #fff;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

@media (min-width: 760px) {
  body {
    padding: 20px 0;
  }

  .app {
    min-height: calc(100vh - 40px);
    border-radius: 24px;
    overflow: hidden;
  }

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

@media (max-width: 380px) {
  .order-btn {
    min-width: 58px;
    padding: 0 10px;
    font-size: 0;
  }

  .order-btn .btn-icon {
    font-size: 22px;
  }

  .food-card {
    min-height: 174px;
  }

  .food-art {
    height: 116px;
  }

  .review-row {
    grid-template-columns: 96px 1fr;
    min-height: 112px;
  }

  .thumb {
    width: 96px;
    height: 96px;
  }

  .product-editor {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .product-image {
    width: 82px;
    height: 82px;
  }

  .product-editor-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .product-editor-fields .field:nth-child(3),
  .product-editor-fields .replace-photo {
    grid-column: auto;
  }

  .review-row .stepper {
    grid-column: 2;
  }
}
