:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-muted: #edf3f1;
  --ink: #14211f;
  --muted: #64716d;
  --line: #dbe4e0;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --accent: #f97316;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(20, 33, 31, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--primary); color: white; display: grid; place-items: center; font-weight: 800; }
.brand-title { font-weight: 800; white-space: nowrap; }
.brand-subtitle { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.main { width: min(1180px, 100%); margin: 0 auto; padding: 22px clamp(14px, 3vw, 28px) 96px; }
.customer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
.admin-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 22px; align-items: start; }

.panel, .card, .sidebar, .cart-panel, .modal-sheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.panel { padding: 18px; }
.sidebar { padding: 12px; position: sticky; top: 76px; }
.cart-panel { padding: 16px; position: sticky; top: 76px; }

.hero { padding: 22px; background: linear-gradient(135deg, #ecfdf5, #fff7ed); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(28px, 5vw, 48px); letter-spacing: 0; }
.hero p { margin: 0; color: var(--muted); line-height: 1.5; }
.meta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.badge.good { color: #05603a; background: #ecfdf3; border-color: #abefc6; }
.badge.warn { color: #93370d; background: #fff6ed; border-color: #fed7aa; }
.badge.danger { color: var(--danger); background: #fef3f2; border-color: #fecdca; }

.category-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 14px; }
.tab, .ghost-btn, .primary-btn, .danger-btn, .icon-btn { min-height: 38px; border-radius: 8px; border: 1px solid var(--line); padding: 0 12px; background: white; color: var(--ink); }
.tab.active, .primary-btn { background: var(--primary); border-color: var(--primary); color: white; }
.primary-btn:hover { background: var(--primary-strong); }
.ghost-btn:hover, .tab:hover { border-color: var(--primary); }
.danger-btn { background: #fff; color: var(--danger); border-color: #fecdca; }
.icon-btn { width: 38px; padding: 0; display: inline-grid; place-items: center; }

.category-section { margin: 22px 0; }
.category-section h2 { font-size: 20px; margin: 0 0 12px; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.menu-item { padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr) 82px; gap: 14px; align-items: start; }
.menu-item h3 { margin: 0 0 6px; font-size: 16px; }
.menu-item p { margin: 0 0 10px; color: var(--muted); line-height: 1.45; font-size: 14px; }
.price { font-weight: 800; color: var(--primary-strong); }
.food-thumb { width: 82px; aspect-ratio: 1; border-radius: 8px; background: linear-gradient(135deg, #d9f99d, #fed7aa); display: grid; place-items: center; color: rgba(20,33,31,.65); font-weight: 800; }

.cart-empty { color: var(--muted); padding: 20px 0; text-align: center; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-line-title { font-weight: 700; }
.cart-line-options { color: var(--muted); font-size: 13px; margin-top: 4px; }
.qty-controls { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; }
.total-row { display: flex; justify-content: space-between; gap: 10px; padding: 14px 0; font-size: 18px; font-weight: 800; }

.form-grid { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 700; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; background: white; color: var(--ink); }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.segmented button.active { background: var(--primary); color: white; border-color: var(--primary); }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20,33,31,.42); display: grid; place-items: end center; padding: 18px; }
.modal-sheet { width: min(560px, 100%); max-height: 88vh; overflow: auto; padding: 18px; }
.modal-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0 0 6px; }
.option-list { display: grid; gap: 8px; margin: 12px 0 16px; }
.option-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.option-row input { width: 18px; height: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 13px; font-weight: 800; background: var(--surface-muted); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 16px; }
.stat-value { font-size: 28px; font-weight: 900; }
.stat-label { color: var(--muted); font-size: 13px; }
.side-link { display: block; padding: 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 700; }
.side-link.active, .side-link:hover { background: var(--surface-muted); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h1, .section-title h2 { margin: 0; }
.notice { padding: 12px; background: #fff6ed; border: 1px solid #fed7aa; border-radius: 8px; color: #93370d; margin-bottom: 14px; }
.loading, .error-state { padding: 40px 18px; text-align: center; color: var(--muted); }
.error-state { color: var(--danger); }

@media (max-width: 900px) {
  .customer-layout, .admin-layout { grid-template-columns: 1fr; }
  .cart-panel, .sidebar { position: static; }
  .menu-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .brand-subtitle { white-space: normal; }
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; }
  .nav-actions { width: 100%; justify-content: stretch; }
  .nav-actions a, .nav-actions button { flex: 1; }
  .menu-item { grid-template-columns: minmax(0, 1fr); }
  .food-thumb { width: 100%; aspect-ratio: 4 / 1.7; }
}
