:root {
  --bg: #fbf6ee;
  --surface: #ffffff;
  --surface-2: #f4e9d8;
  --border: #e6d6ba;
  --text: #2b1c12;
  --text-dim: #7a6650;
  --text-faint: #a4907a;

  --dinein: #c1531c;
  --dinein-dim: #f0d9c6;
  --parcel: #1f7a63;
  --parcel-dim: #d3ebe2;

  --danger: #d64545;

  --font-display: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

/* ---------- Topbar / tabs ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 16px 0;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--dinein);
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--dinein);
  border-bottom-color: var(--dinein);
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Order type switch ---------- */
.order-type-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.type-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
}

.type-btn[data-type="dine-in"].active {
  background: var(--dinein-dim);
  border-color: var(--dinein);
  color: var(--dinein);
}

.type-btn[data-type="parcel"].active {
  background: var(--parcel-dim);
  border-color: var(--parcel);
  color: var(--parcel);
}

/* ---------- Table picker ---------- */
.picker-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.table-picker { margin-bottom: 16px; }
.table-picker.hidden { display: none; }

.table-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-chip {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-dim);
}

.table-chip.occupied {
  background: var(--dinein-dim);
  border-color: var(--dinein);
  color: var(--dinein);
}

.table-chip.selected {
  background: var(--dinein);
  border-color: var(--dinein);
  color: #fff;
}

.table-empty-note {
  font-size: 13px;
  color: var(--text-faint);
  font-style: italic;
}

/* ---------- Order layout ---------- */
.order-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}

@media (max-width: 720px) {
  .order-layout { grid-template-columns: 1fr; }
}

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

.menu-item-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item-btn:active { transform: scale(0.97); }

.mi-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.mi-price {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--dinein);
  font-weight: 600;
}

.menu-empty, .table-manage-empty, .menu-manage-empty, .history-empty {
  color: var(--text-faint);
  font-size: 13.5px;
  font-style: italic;
  padding: 10px 0;
}

/* ---------- Cart ---------- */
.cart-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: start;
  position: sticky;
  top: 110px;
}

.cart-head {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.cart-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.cart-empty {
  font-size: 13px;
  color: var(--text-faint);
  font-style: italic;
  padding: 6px 0;
}

.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.cr-name {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
}

.cr-qty-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cr-qty-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  color: var(--text);
}

.cr-qty {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  min-width: 16px;
  text-align: center;
}

.cr-amt {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  min-width: 56px;
  text-align: right;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.cart-total {
  font-family: var(--font-mono);
  color: var(--dinein);
}

.bill-btn {
  background: var(--dinein);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.bill-btn:disabled {
  background: var(--border);
  color: var(--text-faint);
  cursor: not-allowed;
}

/* ---------- Panel cards (Tables / Menu / History) ---------- */
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.panel-card h2 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0 0 4px;
}

.panel-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 14px;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1;
  min-width: 120px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
}

.inline-form input:focus { outline: none; border-color: var(--dinein); }

.add-btn {
  background: var(--dinein);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
}

.table-manage-list, .menu-manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
}

.manage-row-name {
  font-weight: 600;
  font-size: 13.5px;
}

.manage-row-sub {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
}

.manage-row-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.manage-row-status.free { background: var(--parcel-dim); color: var(--parcel); }
.manage-row-status.occupied { background: var(--dinein-dim); color: var(--dinein); }

.row-del {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
}

.row-del:hover { color: var(--danger); }

/* ---------- History ---------- */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  cursor: pointer;
}

.hist-left { display: flex; flex-direction: column; gap: 2px; }

.hist-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  width: fit-content;
}

.hist-tag.dine-in { background: var(--dinein-dim); color: var(--dinein); }
.hist-tag.parcel { background: var(--parcel-dim); color: var(--parcel); }

.hist-time { font-size: 11.5px; color: var(--text-faint); }

.hist-amt {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
}

/* ---------- Print / receipt (80mm thermal) ---------- */
.print-area { display: none; }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 80mm;
  }
}

.receipt {
  width: 80mm;
  padding: 4mm;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #000;
}

.receipt h2 {
  text-align: center;
  font-size: 14px;
  margin: 0 0 4px;
}

.r-meta {
  text-align: center;
  font-size: 10px;
  margin-bottom: 6px;
}

.r-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
}

.r-table thead td {
  font-weight: 700;
  border-bottom: 1px dashed #000;
  padding-bottom: 3px;
}

.r-table td { padding: 2px 0; }
.r-table td:nth-child(2) { text-align: center; }
.r-table td:nth-child(3) { text-align: right; }

.r-total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
  margin-top: 4px;
}

.r-thanks {
  text-align: center;
  font-size: 10px;
  margin-top: 10px;
}
