:root {
  --red: #d62828;
  --yellow: #fdc218;
  --green: #43a047;
  --blue: #1976d2;
  --ink: #202124;
  --muted: #697077;
  --line: #d8dee4;
  --panel: #f7f8fa;
  --danger: #e8312f;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--ink);
  background: #fff;
  overflow: hidden;
}

button, input {
  font: inherit;
  min-width: 0;
}

button {
  cursor: pointer;
}

.shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  background: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 10px 6px 16px;
  min-width: 0;
}

.logo {
  width: min(180px, 28vw);
  height: 48px;
  object-fit: contain;
  object-position: left center;
  display: block;
  flex: 0 1 auto;
}

.nav {
  display: flex;
  gap: 7px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.icon-btn, .nav-btn {
  min-width: 66px;
  height: 48px;
  border: 0;
  border-radius: 6px;
  background: rgba(255,255,255,.85);
  color: #111;
  font-weight: 700;
  padding: 0 10px;
  white-space: nowrap;
}

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

.pos-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 58fr) minmax(560px, 42fr);
  overflow: hidden;
}

.products-area {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) auto;
  background: #fff;
}

.product-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}

.product-pager button {
  width: 54px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-weight: 800;
}

.product-pager strong {
  min-width: 88px;
  text-align: center;
}

.products-grid {
  min-height: 0;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
  align-content: stretch;
  justify-content: stretch;
}

.product-button {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid #d4d6d9;
  border-radius: 4px;
  background: #d9d9d9;
  color: #111;
  font-size: clamp(15px, 1.08vw, 22px);
  font-weight: 800;
  text-shadow: none;
  line-height: 1.05;
  padding: 3px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
  text-align: center;
  overflow: hidden;
  word-break: normal;
}

.product-button img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  display: block;
  border-radius: 2px 2px 0 0;
}

.product-button span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(24px, 3.2vh, 34px);
  padding: 2px 4px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 4px;
  padding: 5px 6px;
  background: #f2f2f2;
  border-top: 1px solid var(--line);
  overflow: hidden;
}

.inventory-pill {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  border: 1px solid #222;
  background: #fff;
  font-size: clamp(10px, .76vw, 13px);
  font-weight: 700;
  min-width: 0;
}

.inventory-pill span {
  padding: 2px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-pill.low span {
  background: #f39c12;
  color: #fff;
}

.inventory-pill.none span {
  background: #d71920;
  color: #fff;
}

.cart {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  border-left: 3px solid #787878;
  padding: 12px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #fff;
}

.customer-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}

.customer-row input {
  width: 100%;
  height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 18px;
}

.ticket-title {
  margin: 10px 0 8px;
  font-size: clamp(26px, 1.8vw, 34px);
  line-height: 1.1;
}

.ticket-items {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  border-top: 2px solid #bbb;
}

.ticket-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid #e1e4e8;
  font-size: clamp(18px, 1.2vw, 22px);
  font-weight: 700;
  min-width: 0;
}

.ticket-item span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-item .qty {
  color: var(--muted);
}

.ticket-item .comment {
  width: 38px;
  height: 32px;
  border: 0;
  border-radius: 4px;
  background: #eef2f6;
}

.ticket-item .comment.has {
  background: #c8e6c9;
}

.total {
  border-top: 2px solid #bbb;
  padding-top: 10px;
  font-size: clamp(26px, 1.8vw, 34px);
  font-weight: 800;
  text-align: right;
}

.time-box {
  margin-top: 8px;
}

.time-title {
  font-weight: 800;
  margin-bottom: 6px;
}

.time-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}

.minutes-row {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 5px;
}

.time-btn {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-weight: 800;
}

.time-btn.selected {
  background: #111;
  color: #fff;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.action {
  min-height: 66px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  font-size: clamp(14px, .95vw, 18px);
  padding: 6px;
}

.save { background: var(--green); }
.clear { background: var(--danger); }
.pay { background: var(--blue); }
.action:disabled {
  background: #b9c0c7;
  cursor: default;
}

.page {
  height: 100%;
  overflow: auto;
  padding: 12px;
}

.orders-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.order-card {
  width: 150px;
  height: 140px;
  border: 2px solid #999;
  border-radius: 6px;
  background: #fff;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  white-space: pre-line;
}

.order-card.delivering { background: #9be665; }
.order-card.delivered { background: orange; }
.order-card.paid { border: 10px solid green; }

.kitchen-layout {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto auto;
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
}

.kitchen-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 19px;
  font-weight: 800;
}

.kitchen-table th {
  background: #333;
  color: #fff;
  position: sticky;
  top: 0;
}

.kitchen-table th, .kitchen-table td {
  padding: 10px;
  border: 1px solid #a8b0b8;
  text-align: center;
}

.kitchen-table tr.delivering td {
  background: #c8e6c9;
}

.kitchen-table td.alert {
  background: #d71920;
  color: #fff;
}

.kitchen-foot {
  background: #f2f2f2;
  padding: 8px;
}

.pending-foot {
  background: var(--yellow);
  padding: 8px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.inventory-editor {
  max-width: 900px;
  margin: 0 auto;
}

.inventory-row-edit {
  display: grid;
  grid-template-columns: 1fr 160px 160px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 700;
}

.inventory-row-edit input {
  height: 38px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.42);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,.3);
}

.numeric-title,
.payment-title {
  margin: 0 0 18px;
  text-align: center;
  color: #555;
  font-size: 38px;
  line-height: 1.12;
}

.numeric-display {
  width: 82%;
  height: 66px;
  display: block;
  margin: 0 auto 8px;
  border: 1px solid #d6dbe0;
  border-radius: 5px;
  padding: 0 18px;
  color: #555;
  background: #fff;
  font-size: 26px;
}

.numeric-keypad {
  width: 86%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 6px;
}

.numeric-keypad button {
  height: 82px;
  border: 1px solid #d6dbe0;
  border-radius: 5px;
  background: #f5f6f7;
  color: #424a53;
  font-size: 38px;
  font-weight: 800;
}

.numeric-keypad button:disabled {
  color: #a0a6ad;
  background: #edf0f2;
}

.numeric-actions {
  justify-content: center;
  margin-top: 28px;
}

.numeric-actions .primary {
  background: #7467e8;
  box-shadow: 0 0 0 4px #c7c0ff;
}

.numeric-actions .neutral {
  background: #77818b;
  color: #fff;
}

.payment-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 92%;
  margin: 0 auto 6px;
}

.payment-label {
  text-align: center;
  color: #4b5561;
  font-size: 28px;
  font-weight: 800;
}

.payment-amount {
  min-height: 74px;
  border: 1px solid #888;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 29px;
  font-weight: 800;
}

.total-amount {
  color: #9c1d1d;
}

.total-amount.no-send-enabled {
  color: #f08a00;
}

.paid-amount {
  color: #21751e;
}

.change-amount {
  color: #5c73ef;
}

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

.modal h2 {
  margin: 0 0 12px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-actions button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 800;
}

.primary { background: var(--green); color: #fff; }
.secondary { background: var(--blue); color: #fff; }
.danger { background: var(--danger); color: #fff; }
.neutral { background: #e6e8eb; color: #111; }

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

.form-grid input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
}

.detail-list {
  background: #c1d9e4;
  border: 3px solid #888;
  padding: 10px 20px;
  font-size: 22px;
  font-weight: 800;
}

.stats-frame {
  width: 100%;
  height: calc(100vh - 120px);
  border: 0;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

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

  .logo {
    height: 42px;
  }

  .pos-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(330px, 46vh);
  }

  .cart {
    border-left: 0;
    border-top: 3px solid #787878;
  }

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

  .inventory-strip {
    display: none;
  }

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

@media (max-height: 760px) and (min-width: 1101px) {
  .shell {
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .logo {
    height: 42px;
  }

  .nav-btn {
    height: 42px;
  }

  .products-area {
    grid-template-rows: 46px minmax(0, 1fr) auto;
  }

  .products-grid {
    gap: 6px;
  }

  .inventory-strip {
    max-height: 82px;
  }

  .customer-row input,
  .time-btn {
    height: 38px;
  }

  .action {
    min-height: 54px;
  }
}
