:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #65736b;
  --line: #d8ded9;
  --paper: #f7f8f4;
  --surface: #ffffff;
  --primary: #0f6b4f;
  --primary-strong: #094935;
  --accent: #b62735;
  --warn: #9b5b00;
  --shadow: 0 18px 46px rgba(17, 36, 28, 0.12);
  --font-ui: "Noto Sans Myanmar", "Noto Sans JP", "Hiragino Sans", "Yu Gothic",
    "Myanmar Sangam MN", "Myanmar MN", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.device-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 28px;
  padding: 4px 18px;
  color: #ffffff;
  background: #101310;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.device-bar span:nth-child(2) {
  text-align: center;
}

.device-bar span:last-child {
  text-align: right;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.28;
}

.tabs {
  display: flex;
  gap: 8px;
  max-width: 74vw;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.tab,
.button {
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
}

.tab {
  flex: 0 0 auto;
  min-width: max-content;
  color: var(--ink);
  background: #edf2ee;
  white-space: normal;
}

.tab.active,
.button.primary {
  color: #ffffff;
  background: var(--primary);
}

.button.secondary {
  color: var(--ink);
  background: #eef1ed;
  border-color: var(--line);
}

.button.danger {
  color: #ffffff;
  background: var(--accent);
}

.app-shell {
  width: 100%;
  margin: 0 auto;
  padding: 14px 18px 18px;
}

.message {
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 8px;
  background: #fff7df;
  border: 1px solid #e3c777;
  color: #604007;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.55;
}

.message.success {
  background: #e7f4ed;
  border-color: #9ecdb5;
  color: #164d38;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.purchase-toolbar {
  grid-template-columns: repeat(2, minmax(150px, 1fr)) minmax(220px, 1.2fr) repeat(2, minmax(180px, 1fr));
}

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

.summary-strip div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.summary-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.1;
}

.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  gap: 16px;
  align-items: start;
}

.menu-pane,
.ticket-pane {
  min-width: 0;
}

.menu-toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(280px, 1fr);
  gap: 14px;
  align-items: end;
  margin-bottom: 12px;
}

.menu-toolbar h2,
.ticket-header h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.35;
}

.search-box {
  min-width: 0;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.category-tile {
  min-height: 62px;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  color: #ffffff;
  background: var(--tile-color, var(--primary));
  box-shadow: 0 8px 18px rgba(17, 36, 28, 0.12);
  font-family: var(--font-ui);
  text-align: left;
  cursor: pointer;
}

.category-tile.active {
  outline: 3px solid rgba(15, 107, 79, 0.24);
  outline-offset: 2px;
}

.category-tile span,
.category-tile strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-tile span {
  max-height: 2.9em;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
}

.category-tile strong {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.25;
  opacity: 0.9;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.menu-item {
  position: relative;
  display: grid;
  grid-template-rows: 76px auto auto auto;
  min-height: 156px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(17, 36, 28, 0.09);
  font-family: var(--font-ui);
  text-align: left;
  touch-action: manipulation;
  cursor: pointer;
}

.menu-item > span {
  pointer-events: none;
}

.menu-item:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(17, 36, 28, 0.12);
}

.menu-photo {
  position: relative;
  display: block;
  width: 100%;
  height: 76px;
  max-height: 76px;
  contain: paint;
  overflow: hidden;
  background: linear-gradient(135deg, #e7f4ed, #fff7df);
}

.menu-photo img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.menu-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--primary-strong);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.menu-name,
.menu-meta,
.menu-price,
.menu-stock {
  display: block;
  padding: 0 10px;
}

.menu-name {
  min-height: 2.8em;
  margin-top: 8px;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.4;
}

.menu-meta {
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-price {
  align-self: end;
  padding-bottom: 10px;
  color: var(--primary-strong);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.15;
}

.menu-stock {
  align-self: end;
  margin: 0 10px 9px;
  border-radius: 6px;
  padding: 5px 6px;
  color: #8b1f2d;
  background: #fde2e1;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.menu-item.out-of-stock {
  opacity: 0.86;
}

.menu-item.out-of-stock .menu-price {
  padding-bottom: 2px;
}

.ticket-pane {
  position: sticky;
  top: 104px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 122px);
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ticket-header {
  display: grid;
  gap: 10px;
}

.ticket-number {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.15;
}

.ticket-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.ticket-tab {
  min-height: 40px;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 6px 2px;
  color: var(--muted);
  background: transparent;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
}

.ticket-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.checkout-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.checkout-panel,
.cart-panel {
  display: grid;
  gap: 16px;
}

.cart-panel h2,
.receipt h2 {
  margin: 0;
}

.input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.35;
}

textarea.input {
  min-height: 110px;
  resize: vertical;
}

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

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(150px, 1fr)) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.card.purchase {
  grid-template-columns: 140px minmax(180px, 1fr) repeat(4, minmax(115px, 0.8fr)) auto;
}

.product-card {
  grid-template-columns: 74px minmax(220px, 1.3fr) repeat(3, minmax(145px, 0.8fr)) minmax(150px, 0.7fr) auto;
}

.sale-card {
  grid-template-columns: 190px minmax(210px, 1fr) repeat(4, minmax(125px, 0.7fr)) auto;
}

.name {
  margin: 0 0 6px;
  font-size: 23px;
  font-weight: 850;
}

.meta,
.label {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.value {
  margin-top: 5px;
  font-size: 20px;
  font-weight: 800;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 16px;
  font-weight: 800;
  background: #e4f3eb;
  color: var(--primary-strong);
}

.status.inactive {
  background: #f0e9e6;
  color: #744033;
}

.stock-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin-bottom: 8px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 850;
  background: #e7f4ed;
  color: #164d38;
}

.stock-status.low-stock {
  background: #fff0ce;
  color: var(--warn);
}

.stock-status.out-of-stock {
  background: #fde2e1;
  color: var(--accent);
}

.panel {
  padding: 20px;
}

.product-list-thumb,
.product-image-preview,
.product-detail-photo {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #e7f4ed, #fff7df);
}

.product-list-thumb {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  color: var(--primary-strong);
  font-size: 22px;
  font-weight: 800;
}

.product-list-thumb img,
.product-image-preview img,
.product-detail-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-upload-field {
  align-items: start;
}

.product-image-preview {
  display: grid;
  place-items: center;
  width: min(280px, 100%);
  aspect-ratio: 4 / 3;
  color: var(--primary-strong);
  font-size: 32px;
  font-weight: 800;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
}

.wide {
  grid-column: 1 / -1;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  color: var(--ink);
  font-size: 20px;
}

.toggle-row input {
  width: 26px;
  height: 26px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

.stock-panel {
  display: grid;
  gap: 18px;
}

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

.pick-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--ink);
  background: #fbfcfa;
  font: inherit;
  font-size: 18px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.pick-item span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.selected-product {
  padding: 16px;
  border: 1px solid #9ecdb5;
  border-radius: 8px;
  background: #e7f4ed;
}

.line-entry,
.stock-totals {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.stock-totals {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.button.tiny {
  min-height: 48px;
  padding: 0 12px;
  font-size: 15px;
  background: #eef1ed;
  border-color: var(--line);
}

.qty-controls {
  display: inline-grid;
  grid-template-columns: 48px minmax(40px, auto) 48px;
  gap: 8px;
  align-items: center;
}

.cart-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.cart-totals .detail-box .value {
  font-size: 26px;
  line-height: 1.1;
}

.cart-totals label {
  color: var(--ink);
}

.cart-totals label .input {
  margin-top: 2px;
  font-size: 22px;
  font-weight: 850;
}

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

.receipt h2,
.receipt > p,
.thanks {
  text-align: center;
}

.refund-line {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 0.4fr);
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.product-detail-hero {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}

.product-detail-photo {
  display: grid;
  place-items: center;
  width: 180px;
  aspect-ratio: 4 / 3;
  color: var(--primary-strong);
  font-size: 42px;
  font-weight: 800;
}

.product-detail-hero h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.3;
}

.detail-note {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  border: 1px solid #9ecdb5;
  border-radius: 8px;
  padding: 14px 16px;
  color: #164d38;
  background: #e7f4ed;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.55;
}

.detail-note strong {
  color: var(--primary-strong);
  font-size: 16px;
}

.detail-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 15px;
  line-height: 1.45;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: none;
}

.totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 20px;
  font-weight: 750;
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .tabs,
  .actions {
    width: 100%;
  }

  .tabs {
    max-width: 100%;
  }

  .tab,
  .actions .button {
    flex: 1;
  }

  .toolbar,
  .purchase-toolbar,
  .summary-strip,
  .checkout-grid,
  .pos-layout,
  .menu-toolbar,
  .cart-totals,
  .card,
  .sale-card,
  .card.purchase,
  .form-grid,
  .line-entry,
  .stock-totals,
  .detail-grid,
  .refund-line,
  .totals {
    grid-template-columns: 1fr;
  }

  .product-card {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .product-card > .button,
  .product-card > div:not(.product-list-thumb):not(:first-child) {
    grid-column: 1 / -1;
  }

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

  .ticket-pane {
    position: static;
    max-height: none;
  }

  .app-shell {
    padding: 16px;
  }

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

@media (min-width: 901px) and (max-width: 1180px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 16px;
  }

  .tabs {
    max-width: 100%;
  }

  h1 {
    font-size: 28px;
  }

  .pos-layout {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 36vw);
    gap: 12px;
  }

  .category-grid {
    grid-template-columns: repeat(4, minmax(110px, 1fr));
  }

  .menu-grid {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 8px;
  }

  .menu-item {
    grid-template-rows: 68px auto auto auto;
    min-height: 148px;
  }

  .menu-photo {
    height: 68px;
    max-height: 68px;
  }

  .ticket-pane {
    top: 156px;
  }

  .cart-totals {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .device-bar {
    grid-template-columns: 1fr auto;
  }

  .device-bar span:last-child {
    display: none;
  }

  h1 {
    font-size: 26px;
  }

  .tab {
    min-height: 54px;
    font-size: 15px;
  }

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

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

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

  .menu-item {
    grid-template-rows: 72px auto auto auto;
  }

  .menu-photo {
    height: 72px;
    max-height: 72px;
  }

  table {
    min-width: 620px;
  }

  .actions {
    flex-direction: column;
  }
}

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

  .topbar,
  .message,
  .no-print {
    display: none !important;
  }

  .app-shell {
    width: 80mm;
    padding: 0;
  }

  .panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .receipt table {
    min-width: 0;
  }

  .receipt th,
  .receipt td {
    padding: 6px 2px;
    font-size: 11px;
  }

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