:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f8faf7;
  --ink: #22251f;
  --muted: #707667;
  --line: #e0ddd3;
  --terracotta: #b95337;
  --terracotta-dark: #963e28;
  --teal: #17756f;
  --teal-soft: #dff2ef;
  --amber: #ad7819;
  --amber-soft: #fff0ca;
  --danger: #b43d3d;
  --danger-soft: #ffe2df;
  --nav: #20261f;
  --shadow: 0 14px 36px rgba(31, 35, 28, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  display: grid;
  grid-template-columns: 188px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--nav);
  color: #f5f8f2;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--terracotta);
  font-weight: 900;
}

.brand small { display: block; color: #c9d1c2; margin-top: 2px; }
.nav-list { display: grid; gap: 6px; }

.nav-item {
  border: 0;
  color: #e4ebde;
  background: transparent;
  padding: 10px 9px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav-item svg {
  width: 31px;
  height: 31px;
  padding: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}

.nav-item.active, .nav-item:hover { background: #35402f; }
.users-pin { margin-top: auto; width: 100%; }

.workspace { padding: 22px; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.eyebrow {
  color: var(--terracotta);
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
  font-size: 0.74rem;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 2vw, 2.1rem); }
h2 { font-size: 1rem; }

.topbar-actions { display: flex; align-items: center; gap: 9px; }

.search, .compact-search {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0 11px;
  border-radius: 8px;
}

.search span, .compact-search span { color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.search input, .compact-search input { border: 0; outline: 0; min-width: min(32vw, 300px); background: transparent; }

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 900;
}

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

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

.metrics article { padding: 15px; }
.metrics span { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }
.metrics strong { font-size: 1.2rem; }

.view { display: none; }
.view.active { display: block; }

.content-grid, .order-layout, .checkout-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 15px;
  align-items: start;
}

.panel { padding: 17px; }

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

.panel-header.tight { margin-top: 18px; }
.panel-header p { color: var(--muted); margin-top: 5px; font-size: 0.9rem; }

.form-stack { display: grid; gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.form-grid.compact { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 0.88rem; }

textarea, input, select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
  outline-color: rgba(185, 83, 55, 0.35);
  min-width: 0;
}

textarea { min-height: 72px; resize: vertical; }

.primary, .secondary, .success, .danger {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 15px;
  font-weight: 900;
}

.small { min-height: 38px; }
.primary { color: white; background: var(--terracotta); }
.primary:hover { background: var(--terracotta-dark); }
.secondary { color: var(--ink); background: var(--surface-2); border-color: var(--line); }
.success { color: white; background: var(--teal); }
.danger { color: white; background: var(--danger); }

.action-stack { display: grid; gap: 10px; }
.action-stack.horizontal { grid-template-columns: 1fr 1fr; }

.tables-grid, .product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 12px;
}

.side-products {
  grid-template-columns: 1fr;
  max-height: 260px;
  overflow: auto;
  padding-right: 3px;
  margin-bottom: 12px;
}

.side-products .product-card {
  min-height: 82px;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.side-products .product-card span {
  grid-column: 1 / -1;
}

.order-search {
  margin-bottom: 10px;
}

.table-form {
  grid-template-columns: minmax(180px, 1.2fr) 120px minmax(180px, 1fr) minmax(220px, 1fr);
  align-items: end;
}

.table-card, .product-card, .data-row, .ticket {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 13px;
  text-align: left;
}

.table-card, .product-card { min-height: 116px; display: grid; align-content: space-between; gap: 10px; }
.table-card.active { outline: 3px solid rgba(185, 83, 55, 0.24); border-color: var(--terracotta); }

.table-meta, .row-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eef0eb;
  color: #485044;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.teal { background: var(--teal-soft); color: var(--teal); }
.status-pill.amber { background: var(--amber-soft); color: var(--amber); }
.status-pill.danger { background: var(--danger-soft); color: var(--danger); }

.category-tabs, .payment-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
}

.category-tabs button, .payment-methods button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--muted);
  font-weight: 800;
}

.category-tabs button.active, .payment-methods button.active {
  background: #293027;
  color: white;
  border-color: #293027;
}

.cart-lines, .table-list { display: grid; gap: 10px; }
.cart-lines { max-height: 310px; overflow: auto; padding-right: 3px; }

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

.qty-controls { display: flex; align-items: center; gap: 7px; }
.qty-controls button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 6px;
  font-weight: 900;
}

.notes { margin: 14px 0; }
.totals { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; margin-bottom: 14px; }
.totals div, .receipt-total { display: flex; justify-content: space-between; gap: 12px; }
.totals span { color: var(--muted); }
.totals .grand { font-size: 1.18rem; }

.kitchen-columns { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 14px; }
.kitchen-column { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-height: 300px; }
.kitchen-column h3 { margin: 0 0 10px; font-size: 0.9rem; }
.ticket { width: 100%; margin-bottom: 10px; background: white; }
.ticket span { display: block; color: var(--muted); margin-top: 5px; font-size: 0.84rem; }

.receipt { background: #fffdf7; border: 1px dashed #c9c2b1; border-radius: 8px; padding: 18px; }
.receipt-head { display: grid; gap: 4px; text-align: center; padding-bottom: 12px; border-bottom: 1px dashed #d8cfbd; margin-bottom: 12px; }
.receipt-line { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 7px 0; color: var(--muted); }
.receipt-total { border-top: 1px dashed #d8cfbd; margin-top: 12px; padding-top: 12px; font-size: 1.1rem; }
.receipt-note { margin-top: 14px; border-radius: 8px; background: var(--amber-soft); color: var(--amber); padding: 10px; text-align: center; font-weight: 900; }

.subsection { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 2px; }

.data-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.data-row strong, .data-row span { display: block; }
.data-row span { color: var(--muted); font-size: 0.86rem; margin-top: 3px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.row-actions button { min-height: 34px; padding: 0 10px; border-radius: 7px; }

.empty {
  border: 1px dashed #cfcabe;
  background: #fbfaf6;
  color: var(--muted);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #232822;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 180ms ease;
  max-width: min(420px, calc(100vw - 40px));
}

.toast.show { opacity: 1; transform: translateY(0); }

@media print {
  body * { visibility: hidden; }
  #receipt, #receipt * { visibility: visible; }
  #receipt { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; border: 0; }
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 76px 1fr; }
  .brand span:last-child, .nav-item b { display: none; }
  .content-grid, .order-layout, .checkout-layout { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 5; flex-direction: row; align-items: center; justify-content: space-between; padding: 10px; overflow-x: auto; }
  .nav-list { display: flex; }
  .users-pin { margin-top: 0; width: auto; }
  .workspace { padding: 14px; }
  .topbar, .topbar-actions, .panel-header { align-items: stretch; flex-direction: column; }
  .search input, .compact-search input { min-width: 0; width: 100%; }
  .metrics, .kitchen-columns, .form-grid, .form-grid.compact, .action-stack.horizontal { grid-template-columns: 1fr; }
}
