*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f7;
  --surface: #fff;
  --text: #1d1d1f;
  --text2: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --border: #d2d2d7;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Utilities ─── */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.center { align-items: center; }
.between { justify-content: space-between; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text2 { color: var(--text2); }
.bold { font-weight: 600; }
.small { font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ─── Header ─── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 18px; font-weight: 700; }
.header .subtitle { font-size: 13px; color: var(--text2); }

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border: none; border-radius: 8px;
  font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-green { background: var(--green); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 17px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Inputs ─── */
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
label { font-size: 13px; font-weight: 600; color: var(--text2); display: block; margin-bottom: 4px; }
textarea { resize: vertical; min-height: 60px; }

/* ─── Grid for menu ─── */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.menu-item {
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow);
}
.menu-item:hover { border-color: var(--accent); }
.menu-item.selected { border-color: var(--accent); background: #e8f2ff; }
.menu-item .name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.menu-item .price { color: var(--accent); font-weight: 700; font-size: 15px; }

/* ─── Category tabs ─── */
.cat-tabs {
  display: flex; gap: 8px;
  overflow-x: auto; padding: 4px 0;
  -webkit-overflow-scrolling: touch;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  background: var(--surface);
  border: 1.5px solid var(--border);
  transition: all .15s;
}
.cat-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── Order list ─── */
.order-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  border-left: 4px solid var(--border);
}
.order-card.pending { border-left-color: var(--orange); }
.order-card.preparing { border-left-color: var(--accent); }
.order-card.ready { border-left-color: var(--green); }

/* ─── Cart sidebar ─── */
.cart {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.cart-items { flex: 1; overflow-y: auto; }
.cart-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.cart-item:last-child { border-bottom: none; }
.qty-ctrl {
  display: inline-flex; align-items: center; gap: 4px;
}
.qty-btn {
  width: 28px; height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:active { background: #f0f0f0; }

/* ─── Badge ─── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase;
}
.badge-pending { background: #fff3cd; color: #856404; }
.badge-preparing { background: #cfe2ff; color: #084298; }
.badge-ready { background: #d1e7dd; color: #0f5132; }
.badge-completed { background: #e8e8ed; color: #6e6e73; }
.badge-cancelled { background: #f8d7da; color: #842029; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }

/* ─── PIN Screen ─── */
.pin-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.pin-box { text-align: center; }
.pin-box h1 { font-size: 24px; margin-bottom: 8px; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 24px 0; }
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all .15s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3,72px); gap: 10px; justify-content: center; }
.pin-key {
  width: 72px; height: 56px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 22px; font-weight: 600;
  cursor: pointer;
  transition: all .1s;
}
.pin-key:active { background: #e8e8ed; }
.pin-key.wide { grid-column: span 2; width: auto; font-size: 14px; }

/* ─── POS layout ─── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  height: calc(100vh - 65px);
  padding: 16px;
}
@media (max-width: 768px) {
  .pos-layout { grid-template-columns: 1fr; height: auto; }
}

/* ─── KDS ─── */
.kds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px;
}

/* ─── Customer order page ─── */
.order-hero {
  text-align: center;
  padding: 32px 16px 16px;
}
.order-hero h1 { font-size: 22px; }
.order-hero p { color: var(--text2); font-size: 14px; }

.floating-cart {
  position: fixed; bottom: 16px; left: 16px; right: 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,113,227,.35);
  z-index: 50;
  max-width: 500px;
  margin: 0 auto;
}
.floating-cart:active { transform: scale(.98); }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: #1d1d1f; color: #fff;
  padding: 12px 24px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  z-index: 2000;
  animation: toastIn .3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Admin table ─── */
.data-table {
  width: 100%; border-collapse: collapse;
}
.data-table th, .data-table td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
}
.data-table th { font-size: 12px; text-transform: uppercase; color: var(--text2); font-weight: 700; }
.data-table tr:hover td { background: #fafafa; }

/* ─── Stat cards ─── */
.stat { text-align: center; padding: 20px; }
.stat .value { font-size: 28px; font-weight: 800; color: var(--accent); }
.stat .label { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* Print */
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
}
