:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #66737f;
  --line: #d7e0e6;
  --paper: #ffffff;
  --bg: #edf1f3;
  --brand: #175f7a;
  --brand-strong: #10475d;
  --accent: #d08a24;
  --danger: #b42318;
  --soft: #f6f8f9;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: #123f56;
  color: white;
}

.topbar h1 { margin: 0; font-size: 20px; }
.topbar p { margin: 3px 0 0; color: #d4eeee; font-size: 13px; }
.topbar p.status-online { color: #d8f5df; }
.topbar p.status-offline { color: #ffd9d4; font-weight: 700; }
.topbar p.status-pending { color: #ffe3a3; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.top-actions input { width: min(240px, 42vw); }

button, input, select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
}

button { cursor: pointer; background: #f8fbfc; }
button.primary {
  width: 100%;
  border-color: var(--brand);
  background: var(--brand);
  color: white;
  font-weight: 700;
}
button.primary:hover { background: var(--brand-strong); }
button.muted { color: var(--muted); }

.tabs {
  display: flex;
  gap: 1px;
  background: #d5dee4;
  padding: 0 12px;
}

.tab {
  border: 0;
  border-radius: 0;
  padding: 13px 18px;
  background: #e7eef2;
}

.tab.active {
  background: var(--paper);
  color: var(--brand-strong);
  font-weight: 700;
}

main { padding: 12px; }
.view { display: none; }
.view.active { display: block; }

.pos-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 12px;
  min-height: calc(100vh - 112px);
}

.panel, .pos-main, .cart-panel, .category-strip {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel { padding: 14px; }

.category-strip {
  padding: 10px;
  overflow: auto;
}

#categoryList { display: flex; gap: 8px; flex-wrap: wrap; }
.category {
  min-height: 44px;
  margin-bottom: 8px;
  text-align: left;
  border-color: #cdd8df;
  background: #f9fbfc;
  color: #25313a;
  font-weight: 700;
}
.category.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.pos-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
}

.pos-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
}

.pos-toolbar h2 { flex: 1; margin: 0; text-align: center; font-size: 18px; }
.pos-toolbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.pos-toolbar input { width: min(380px, 46vw); }

.home-btn {
  min-width: 78px;
  border-color: transparent;
  background: #ffefef;
  color: #d42b2b;
  font-weight: 700;
}

.table-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-content: start;
  gap: 26px;
  flex: 1;
  padding: 22px 16px 40px;
  overflow: auto;
  background: #e5e5e5;
}

.table-card {
  display: grid;
  grid-template-rows: 1fr 40px;
  min-height: 162px;
  overflow: hidden;
  border: 1px solid #c8c8c8;
  border-radius: 10px;
  background: white;
  padding: 0;
}

.table-card.active,
.table-card.occupied {
  border-color: #f2d225;
  background: #ffef33;
}

.table-card strong {
  display: grid;
  place-items: center;
  font-size: 16px;
}

.table-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  border-top: 1px solid #d0d0d0;
  font-weight: 700;
}

.table-meta span {
  text-align: center;
}

.order-menu {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.order-menu.hidden,
.table-board.hidden {
  display: none;
}

.menu-head {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px 0;
  color: var(--muted);
}

.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-content: start;
  gap: 8px;
  padding: 10px;
  overflow: auto;
}

.product {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
  border-color: #cbd6dd;
  background: #fbfcfd;
  box-shadow: 0 1px 0 rgba(15, 43, 57, 0.04);
}

.product strong { font-size: 15px; line-height: 1.25; }
.product small { color: var(--muted); }
.product .price {
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
}
.stock-pill {
  align-self: flex-start;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eaf2f4;
  color: #30424d;
  font-size: 12px;
}

.cart-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.cart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
}
.cart-head h2 { margin: 0; font-size: 18px; }
.cart-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.table-tools {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fffdf8;
}

.table-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 8px;
  margin-bottom: 8px;
}

.table-entry button {
  border-color: #d69a43;
  background: #fff2dd;
  color: #714514;
  font-weight: 700;
}

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

.table-ticket {
  min-height: 54px;
  padding: 8px;
  text-align: left;
  border-color: #cfdbe2;
  background: #f8fbfc;
}

.table-ticket.active {
  border-color: var(--brand);
  background: #e9f4f8;
}

.table-ticket strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-ticket small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.lines {
  flex: 1;
  overflow: auto;
  padding: 4px 12px;
}
.lines.empty {
  color: var(--muted);
  padding: 36px 0;
  text-align: center;
}

.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px 78px 34px;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.line strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}
.line input { width: 100%; }
.line button { color: var(--danger); padding: 8px; }

.cart-footer {
  padding: 12px;
  border-top: 1px solid var(--line);
  background: white;
}

.cart-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.cart-actions button {
  min-height: 38px;
  padding: 7px 6px;
  background: #e6e6e6;
  color: #6c747b;
  font-weight: 700;
}

.cart-actions button.active {
  border-color: var(--brand);
  background: #e7f3f8;
  color: var(--brand-strong);
}

.order-meta {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

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

.print-actions button {
  min-height: 42px;
  padding: 8px;
  background: #edf5f8;
  color: #17465d;
  font-weight: 700;
}

.totals {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 14px;
  font-size: 18px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.field input, .field select { color: var(--ink); }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2, h3 { margin: 0; font-size: 18px; }
.panel-head input { min-width: 220px; }

.purchase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.purchase-line {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 86px 92px 126px 150px 92px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.pack-preview {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.remove-line, .negative { color: var(--danger); }
.negative { font-weight: 700; }
.inline-tools, .import-box { display: flex; gap: 8px; flex-wrap: wrap; }
.import-box { margin-bottom: 12px; }

.table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}
table { width: 100%; border-collapse: collapse; background: white; }
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
th { background: #f2f6f8; }
.hint { color: var(--muted); }

.queue-card, .approval-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  background: #fbfdfe;
}
.approval-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.approval-card ul { margin: 8px 0; padding-left: 18px; }
.approval-actions { display: flex; gap: 8px; }
.approval-actions button { min-width: 100px; }
.approval-actions .reject { color: var(--danger); }
.row-actions {
  display: flex;
  gap: 6px;
}
.row-actions button {
  padding: 7px 9px;
}
.danger-action {
  color: var(--danger);
  border-color: #f1b6ad;
}
.status-pill {
  display: inline-block;
  min-width: 52px;
  border-radius: 999px;
  padding: 3px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}
.status-pill.paid {
  background: #def7e8;
  color: #176b3a;
}
.status-pill.void {
  background: #ffe1dc;
  color: var(--danger);
}
.void-row td {
  color: #7b6b69;
  background: #fff8f7;
}

@media (max-width: 900px) {
  .pos-shell, .purchase-grid, .purchase-line { grid-template-columns: 1fr; }
  .pos-shell { min-height: 0; }
  .category-strip { overflow-x: auto; }
  #categoryList { display: flex; gap: 8px; }
  .category { min-width: 120px; white-space: nowrap; }
  .topbar, .panel-head, .top-actions, .inline-tools, .pos-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .pos-toolbar input { width: 100%; }
  .tabs { overflow-x: auto; padding: 0; }
  .tab { flex: 1; min-width: 120px; }
  main { padding: 8px; }
}
