:root {
  --red: #a83224;
  --red-dark: #7f241b;
  --orange: #d56b2a;
  --cream: #fff8ed;
  --paper: #fffdf8;
  --ink: #2d2926;
  --muted: #706862;
  --line: #eadfd2;
  --jade: #1fa855;
  --blue: #315b7c;
  --gold: #d69c00;
  --rose: #fff0ed;
  --shadow: 0 18px 45px rgba(72, 45, 25, 0.14);
  --radius: 8px;
  --max: 1440px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 248, 237, 0.88), rgba(255, 253, 248, 1) 360px),
    var(--paper);
  font-family: Inter, "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(168, 50, 36, 0.24);
  outline-offset: 2px;
}

img {
  display: block;
  width: 100%;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid rgba(168, 50, 36, 0.12);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(168, 50, 36, 0.16);
  background: #fff;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.15;
}

.brand small,
.topbar-center span,
.summary-tile span,
.section-kicker,
label span,
.ticket-type,
.order-meta,
.empty-state span {
  color: var(--muted);
}

.brand strong {
  font-size: 1rem;
}

.brand small {
  font-size: 0.75rem;
}

.topbar-center {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.topbar-center strong {
  color: var(--red);
  font-size: 1.08rem;
}

.topbar-actions {
  display: inline-flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--red);
  background: #fff;
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
}

.lang-button {
  min-width: 58px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(168, 50, 36, 0.28);
  border-radius: var(--radius);
  color: var(--red);
  background: #fff8ed;
  font-weight: 900;
  cursor: pointer;
}

.settlement-button {
  min-width: 72px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(31, 168, 85, 0.32);
  border-radius: var(--radius);
  color: #fff;
  background: var(--jade);
  font-weight: 900;
  cursor: pointer;
}

.app-shell {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-tile {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 26px rgba(72, 45, 25, 0.08);
}

.summary-tile strong {
  color: var(--red);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  line-height: 1;
}

.summary-tile.revenue strong {
  color: var(--jade);
}

.order-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 18px;
  align-items: start;
}

.menu-pane,
.ticket-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 26px rgba(72, 45, 25, 0.08);
}

.menu-pane {
  min-width: 0;
  padding: clamp(16px, 2vw, 22px);
}

.pane-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.section-kicker {
  margin: 0 0 6px;
  color: var(--orange);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

h2 {
  font-size: 1.05rem;
}

.search-wrap {
  min-height: 48px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.search-wrap span {
  color: var(--red);
  font-size: 1.25rem;
  font-weight: 900;
}

.search-wrap input,
.customer-grid input,
.full-field textarea {
  width: 100%;
  border: 0;
  color: var(--ink);
  background: transparent;
}

.search-wrap input {
  min-width: 0;
  min-height: 44px;
}

.order-mode,
.category-tabs,
.payment-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.order-mode {
  margin-bottom: 14px;
}

.mode-btn,
.category-btn,
.pay-btn {
  min-height: 42px;
  flex: 0 0 auto;
  border: 1px solid #d9c5ad;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}

.mode-btn {
  min-width: 88px;
  padding: 9px 16px;
}

.category-tabs {
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.category-btn {
  min-width: max-content;
  padding: 9px 14px;
}

.mode-btn.active,
.category-btn.active,
.pay-btn.active {
  border-color: var(--red);
  color: #fff;
  background: var(--red);
}

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

.dish-card {
  min-height: 210px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 26px rgba(72, 45, 25, 0.08);
}

.dish-body {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 9px;
  padding: 12px;
}

.dish-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.dish-title h3 {
  font-size: 1rem;
}

.dish-title span {
  color: var(--red);
  font-weight: 900;
  white-space: nowrap;
}

.dish-bm {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.size-row,
.method-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.size-btn,
.method-btn {
  min-width: 44px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff8ed;
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

.method-row {
  padding-top: 2px;
}

.method-btn {
  color: #5f4c3f;
  background: #fff;
}

.size-btn.active,
.method-btn.active {
  border-color: rgba(168, 50, 36, 0.34);
  color: var(--red);
  background: var(--rose);
}

.dish-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: start;
}

.dish-tags span,
.order-badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  color: #5a5048;
  background: #fff2df;
  font-size: 0.76rem;
  font-weight: 800;
}

.add-btn {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  color: #fff;
  background: var(--red);
  font-weight: 900;
  cursor: pointer;
}

.ticket-panel {
  position: sticky;
  top: 92px;
  padding: 16px;
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.ticket-header h2 {
  margin-top: 2px;
  color: var(--red);
  font-size: 1.8rem;
}

.ticket-type {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff8ed;
  font-weight: 900;
}

.customer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  font-size: 0.78rem;
  font-weight: 900;
}

.customer-grid label,
.full-field {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.full-field {
  margin-top: 10px;
}

textarea {
  resize: vertical;
}

.cart-list {
  display: grid;
  gap: 10px;
  min-height: 96px;
  max-height: 38svh;
  margin: 14px 0;
  overflow: auto;
  padding-right: 2px;
}

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.cart-row h3 {
  font-size: 0.95rem;
}

.cart-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.qty-tools {
  display: grid;
  grid-template-columns: 34px 34px 34px;
  align-items: center;
  gap: 4px;
}

.qty-tools button,
.remove-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff8ed;
  color: var(--red);
  font-weight: 900;
  cursor: pointer;
}

.qty-tools span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
}

.remove-btn {
  width: 100%;
  margin-top: 6px;
  color: var(--muted);
}

.empty-state {
  min-height: 96px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px dashed #d9c5ad;
  border-radius: var(--radius);
  background: #fff8ed;
  text-align: center;
}

.ticket-summary {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.ticket-summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.ticket-summary span {
  color: var(--muted);
}

.ticket-summary strong {
  color: var(--ink);
}

.total-row {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 1.25rem;
}

.total-row strong {
  color: var(--red);
}

.payment-row {
  padding: 2px 0 10px;
}

.pay-btn {
  min-width: 94px;
  padding: 9px 12px;
}

.cash-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(31, 168, 85, 0.24);
  border-radius: var(--radius);
  background: #f6fff9;
}

.cash-panel[hidden] {
  display: none;
}

.cash-field {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.cash-field input {
  width: 100%;
  min-height: 38px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 1.3rem;
  font-weight: 900;
}

.cash-change-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff;
}

.cash-change-row span {
  color: var(--muted);
  font-weight: 900;
}

.cash-change-row strong {
  color: var(--jade);
  font-size: 1.25rem;
}

.cash-change-row strong.short {
  color: var(--red);
}

.ewallet-qr-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(49, 91, 124, 0.24);
  border-radius: var(--radius);
  background: #f8fbff;
}

.ewallet-qr-panel[hidden] {
  display: none;
}

.ewallet-qr-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.ewallet-qr-copy strong {
  color: var(--blue);
}

.ewallet-qr-copy span {
  color: var(--red);
  font-weight: 900;
}

.ewallet-qr-frame {
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.ewallet-qr-frame img {
  width: min(100%, 300px);
  max-height: 360px;
  object-fit: contain;
}

.ewallet-qr-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.qr-upload-btn {
  min-height: 40px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(49, 91, 124, 0.36);
  border-radius: 6px;
  color: var(--blue);
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}

.qr-upload-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.confirm-paid-btn {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  font-weight: 900;
  cursor: pointer;
}

.confirm-paid-btn.paid {
  background: var(--jade);
}

.payment-status {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.86rem;
  font-weight: 900;
}

.payment-status.paid {
  color: var(--jade);
}

.submit-order {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  color: #fff;
  background: var(--jade);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(31, 168, 85, 0.18);
}

.submit-order:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.settlement-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(45, 41, 38, 0.34);
}

.settlement-modal[hidden] {
  display: none;
}

.settlement-dialog {
  width: min(720px, 100%);
  max-height: min(780px, calc(100svh - 40px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.settlement-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.settlement-heading h2 {
  color: var(--red);
  font-size: 1.55rem;
}

.settlement-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.settlement-grid article {
  display: grid;
  gap: 4px;
  min-height: 82px;
  align-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff8ed;
}

.settlement-grid span,
.settlement-item span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.settlement-grid strong {
  color: var(--red);
  font-size: 1.25rem;
}

.settlement-grid .settlement-total {
  border-color: rgba(31, 168, 85, 0.28);
  background: #f6fff9;
}

.settlement-grid .settlement-total strong {
  color: var(--jade);
}

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

.settlement-history-section {
  margin-top: 14px;
}

.settlement-section h3 {
  font-size: 1rem;
}

.settlement-list {
  display: grid;
  gap: 8px;
}

.settlement-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.settlement-item div {
  display: grid;
  gap: 2px;
}

.settlement-item b {
  color: var(--red);
  white-space: nowrap;
}

.settlement-history-item {
  background: #fffdf8;
}

.settlement-history-item b {
  color: var(--jade);
}

.settlement-order-item.voided {
  opacity: 0.62;
  background: #f7f2ed;
}

.settlement-order-item.voided strong,
.settlement-order-item.voided b {
  text-decoration: line-through;
}

.settlement-order-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settlement-order-side button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid rgba(168, 50, 36, 0.28);
  border-radius: 6px;
  color: var(--red);
  background: #fff8ed;
  font-weight: 900;
  cursor: pointer;
}

.settlement-order-side button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.settlement-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.settlement-actions button {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--red);
  background: #fff8ed;
  font-weight: 900;
  cursor: pointer;
}

.settlement-actions button:first-child {
  color: #fff;
  border-color: transparent;
  background: var(--jade);
}

.settlement-actions #printSettlementBtn {
  color: #fff;
  border-color: transparent;
  background: var(--blue);
}

@media (max-width: 1180px) {
  .menu-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar-center {
    display: none;
  }

  .summary-strip,
  .order-workspace {
    grid-template-columns: 1fr;
  }

  .ticket-panel {
    position: static;
  }

  .cart-list {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, var(--max));
    padding-top: 14px;
  }

  .topbar {
    gap: 10px;
    padding: 10px;
  }

  .brand small {
    display: none;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .pane-heading,
  .menu-grid {
    grid-template-columns: 1fr;
  }

  .dish-card {
    min-height: auto;
  }

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

  .ticket-header h2 {
    font-size: 1.45rem;
  }

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

  .settlement-actions {
    flex-direction: column;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .menu-pane,
  .summary-strip {
    display: none;
  }

  .app-shell,
  .order-workspace {
    width: 100%;
    display: block;
    padding: 0;
  }

  .ticket-panel {
    position: static;
    box-shadow: none;
    border: 0;
  }

  body.printing-settlement .topbar,
  body.printing-settlement .app-shell {
    display: none;
  }

  body.printing-settlement .settlement-modal {
    position: static;
    display: block;
    padding: 0;
    background: #fff;
  }

  body.printing-settlement .settlement-dialog {
    width: 100%;
    max-height: none;
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  body.printing-settlement .settlement-actions,
  body.printing-settlement .settlement-heading .icon-button {
    display: none;
  }
}
