/* ============================================================
   SnapOrder - Unified Design System & Component Library
   Designed for Mobile, Tablet, Desktop, and Kitchen KDS displays
   ============================================================ */

/* ------------------------------------------------------------
   1. Design Tokens & CSS Custom Properties
   ------------------------------------------------------------ */
:root {
  /* Brand - Refined warm terracotta / saffron */
  --primary: #d9531e;
  --primary-hover: #bf4313;
  --primary-active: #a6370e;
  --primary-light: #fff3ed;
  --primary-tint: #ffedd5;
  --primary-border: #fdba74;
  --primary-text: #ffffff;

  /* Surfaces & Neutrals (Light Theme - Warm Charcoal / Sand) */
  --bg-body: #f7f6f2;
  --bg-card: #ffffff;
  --bg-surface: #ffffff;
  --bg-subtle: #eeece6;
  --bg-elevated: #ffffff;
  --border-color: #e2ded5;
  --border-light: #edeae2;
  --border-focus: #d9531e;

  /* Typography & Text */
  --text-main: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #78716c;
  --text-light: #a8a29e;
  --text-inverse: #ffffff;

  /* Status Tokens (Soft tinted backgrounds + high contrast readable labels) */
  --status-placed: #1d4ed8;
  --status-placed-bg: #eff6ff;
  --status-placed-border: #bfdbfe;

  --status-accepted: #4338ca;
  --status-accepted-bg: #eef2ff;
  --status-accepted-border: #c7d2fe;

  --status-cooking: #b45309;
  --status-cooking-bg: #fffbeb;
  --status-cooking-border: #fde68a;

  --status-cooked: #15803d;
  --status-cooked-bg: #f0fdf4;
  --status-cooked-border: #bbf7d0;

  --status-paid: #0f766e;
  --status-paid-bg: #f0fdfa;
  --status-paid-border: #99f6e4;

  --status-cancelled: #b91c1c;
  --status-cancelled-bg: #fef2f2;
  --status-cancelled-border: #fecaca;

  /* Spacing Scale (4px / 8px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius Scale */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Transitions */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --transition-fast: 150ms var(--ease-standard);
  --transition-normal: 240ms var(--ease-standard);

  /* Layout Dimensions */
  --header-height: 60px;
  --sidebar-width: 240px;
  --sidebar-collapsed: 72px;

  /* Z-Index Hierarchy */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-drawer: 500;
  --z-modal: 1000;
  --z-toast: 2000;
}

/* ------------------------------------------------------------
   2. Dark Theme (Kitchen KDS & Manual Dark Mode)
   Soft, eye-friendly palette (~#14171d) - no harsh neon contrast
   ------------------------------------------------------------ */
[data-theme="dark"],
.kitchen-theme {
  --bg-body: #13161c;
  --bg-card: #1b2029;
  --bg-surface: #1b2029;
  --bg-subtle: #232a35;
  --bg-elevated: #28303e;
  --border-color: #2b3341;
  --border-light: #212733;
  --border-focus: #f97316;

  --text-main: #f3f4f6;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --text-light: #6b7280;
  --text-inverse: #111827;

  --primary: #ea580c;
  --primary-hover: #f97316;
  --primary-light: rgba(234, 88, 12, 0.15);
  --primary-tint: rgba(234, 88, 12, 0.25);
  --primary-border: rgba(234, 88, 12, 0.4);

  /* Tinted Status Badges for Dark Mode */
  --status-placed: #60a5fa;
  --status-placed-bg: rgba(37, 99, 235, 0.2);
  --status-placed-border: rgba(96, 165, 250, 0.35);

  --status-accepted: #818cf8;
  --status-accepted-bg: rgba(79, 70, 229, 0.2);
  --status-accepted-border: rgba(129, 140, 248, 0.35);

  --status-cooking: #fbbf24;
  --status-cooking-bg: rgba(217, 119, 6, 0.2);
  --status-cooking-border: rgba(251, 191, 36, 0.35);

  --status-cooked: #4ade80;
  --status-cooked-bg: rgba(22, 163, 74, 0.2);
  --status-cooked-border: rgba(74, 222, 128, 0.35);

  --status-paid: #2dd4bf;
  --status-paid-bg: rgba(13, 148, 136, 0.2);
  --status-paid-border: rgba(45, 212, 191, 0.35);

  --status-cancelled: #f87171;
  --status-cancelled-bg: rgba(225, 29, 72, 0.2);
  --status-cancelled-border: rgba(248, 113, 113, 0.35);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 30px -5px rgba(0, 0, 0, 0.7);
}

/* ------------------------------------------------------------
   3. Reset & Base Typography
   ------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Inter, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

/* Tabular figures for numbers, currency, and times */
.tabular,
.price,
.time,
.timer,
.count,
.stat-val {
  font-variant-numeric: tabular-nums;
}

/* Crucial Fix: Form controls inherit typography (No Monospace!) */
input,
textarea,
select,
button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h1 { font-size: clamp(1.5rem, 2.5vw, 2.25rem); }
h2 { font-size: clamp(1.25rem, 2vw, 1.75rem); }
h3 { font-size: clamp(1.1rem, 1.5vw, 1.35rem); }
h4 { font-size: 1.1rem; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

p {
  color: var(--text-secondary);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------
   Responsive Visibility Utilities
   ------------------------------------------------------------ */
.hidden {
  display: none !important;
}

@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .hide-desktop {
    display: none !important;
  }
}

/* ------------------------------------------------------------
   Header & App Shell Standards
   ------------------------------------------------------------ */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  position: sticky;
  top: 0;
  z-index: 40;
  gap: var(--space-3);
  backdrop-filter: blur(8px);
}

/* ------------------------------------------------------------
   4. SVG Icons Helper
   ------------------------------------------------------------ */
.icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  stroke-width: 1.75;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.18em;
  flex-shrink: 0;
}

.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

/* ------------------------------------------------------------
   5. Buttons (Min 44px Touch Target)
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  min-width: 44px;
  padding: 0.55rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background-color: transparent;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 1px 3px rgba(217, 83, 30, 0.25);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(217, 83, 30, 0.3);
}
.btn-primary:active {
  background-color: var(--primary-active);
}

.btn-secondary {
  background-color: var(--bg-subtle);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-muted);
}

.btn-ghost {
  background-color: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.btn-danger {
  background-color: var(--status-cancelled-bg);
  border-color: var(--status-cancelled-border);
  color: var(--status-cancelled);
}
.btn-danger:hover {
  background-color: var(--status-cancelled);
  color: #ffffff;
}

.btn-success {
  background-color: var(--status-cooked-bg);
  border-color: var(--status-cooked-border);
  color: var(--status-cooked);
}
.btn-success:hover {
  background-color: var(--status-cooked);
  color: #ffffff;
}

.btn-sm {
  min-height: 36px;
  min-width: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  min-height: 50px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
}

.btn-icon-sm {
  padding: 0;
  min-height: 36px;
  min-width: 36px;
  width: 36px;
  height: 36px;
}

/* ------------------------------------------------------------
   6. Badges & Status Indicators
   ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-placed {
  background-color: var(--status-placed-bg);
  color: var(--status-placed);
  border-color: var(--status-placed-border);
}

.badge-accepted {
  background-color: var(--status-accepted-bg);
  color: var(--status-accepted);
  border-color: var(--status-accepted-border);
}

.badge-cooking {
  background-color: var(--status-cooking-bg);
  color: var(--status-cooking);
  border-color: var(--status-cooking-border);
}

.badge-cooked {
  background-color: var(--status-cooked-bg);
  color: var(--status-cooked);
  border-color: var(--status-cooked-border);
}

.badge-paid {
  background-color: var(--status-paid-bg);
  color: var(--status-paid);
  border-color: var(--status-paid-border);
}

.badge-cancelled {
  background-color: var(--status-cancelled-bg);
  color: var(--status-cancelled);
  border-color: var(--status-cancelled-border);
}

.badge-neutral {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.badge-warning {
  background-color: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

/* Veg / Non-Veg FSSAI Mark */
.fssai-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 3px;
  border: 1.5px solid;
  flex-shrink: 0;
}
.fssai-mark.veg {
  border-color: #16a34a;
}
.fssai-mark.veg::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #16a34a;
}
.fssai-mark.non-veg {
  border-color: #b91c1c;
}
.fssai-mark.non-veg::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4.5px solid transparent;
  border-right: 4.5px solid transparent;
  border-bottom: 8px solid #b91c1c;
}

/* ------------------------------------------------------------
   7. Form Controls & Custom Switch
   ------------------------------------------------------------ */
.form-group {
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-control,
.form-select {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  font-size: 0.875rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

/* Accessible iOS-Style Toggle Switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}

.switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  transition: background-color var(--transition-fast);
  flex-shrink: 0;
}

.switch-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

.switch input:checked + .switch-slider {
  background-color: var(--primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   8. Cards & Layout Containers
   ------------------------------------------------------------ */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
}

/* ------------------------------------------------------------
   9. Quantity Stepper
   ------------------------------------------------------------ */
.stepper {
  display: inline-flex;
  align-items: center;
  background-color: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 40px;
}

.stepper button {
  background: none;
  border: none;
  color: var(--primary);
  width: 36px;
  height: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

.stepper button:hover {
  background-color: rgba(217, 83, 30, 0.15);
}

.stepper button:active {
  background-color: rgba(217, 83, 30, 0.25);
}

.stepper .count {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 28px;
  text-align: center;
  user-select: none;
}

/* ------------------------------------------------------------
   10. Segmented Controls & Category Tabs
   ------------------------------------------------------------ */
.segmented-control {
  display: inline-flex;
  background-color: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 2px;
}

.segmented-btn {
  background: none;
  border: none;
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.segmented-btn:hover {
  color: var(--text-main);
}

.segmented-btn.active {
  background-color: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Sticky horizontal category chips */
.category-chips-nav {
  position: sticky;
  top: var(--header-height);
  z-index: 30;
  background-color: var(--bg-body);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-4);
}

.category-chips-scroll {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--space-4);
}
.category-chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
}

.chip-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(217, 83, 30, 0.25);
}

/* ------------------------------------------------------------
   11. Toast System (Bottom-Center - Never Overlaps Headers!)
   ------------------------------------------------------------ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
  width: 90%;
  max-width: 440px;
}

.toast {
  pointer-events: auto;
  background-color: #1c1917;
  color: #ffffff;
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.875rem;
  font-weight: 500;
  animation: toastSlideUp 0.24s var(--ease-standard) forwards;
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
}

.toast.toast-success {
  background-color: #14532d;
  border-color: #166534;
}

.toast.toast-error {
  background-color: #7f1d1d;
  border-color: #991b1b;
}

.toast.toast-info {
  background-color: #1e293b;
  border-color: #334155;
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ------------------------------------------------------------
   12. Order Tracking Stepper (Strictly contained, no overflow)
   ------------------------------------------------------------ */
.tracker-container {
  padding: var(--space-4) 0;
  width: 100%;
  overflow: hidden;
}

.tracker-steps {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  width: 100%;
}

.tracker-track-bg {
  position: absolute;
  top: 14px;
  left: 24px;
  right: 24px;
  height: 3px;
  background-color: var(--border-color);
  z-index: 1;
}

.tracker-track-fill {
  position: absolute;
  top: 14px;
  left: 24px;
  height: 3px;
  background-color: var(--primary);
  z-index: 2;
  transition: width 0.4s var(--ease-standard);
}

.step-node {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 72px;
  text-align: center;
}

.step-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.step-node.completed .step-circle {
  border-color: #15803d;
  background-color: #15803d;
  color: #ffffff;
}

.step-node.active .step-circle {
  border-color: var(--primary);
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.step-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

.step-node.active .step-label {
  color: var(--primary);
  font-weight: 700;
}
.step-node.completed .step-label {
  color: var(--text-main);
}

/* ------------------------------------------------------------
   13. Modals & Drawers
   ------------------------------------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background-color: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(0.96);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.modal-backdrop.open .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Bottom Sheet (Drawer for Mobile, Drawer panel on Tablet/Desktop) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: var(--z-drawer);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.drawer-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 88vh;
  background-color: var(--bg-card);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
  z-index: calc(var(--z-drawer) + 1);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s var(--ease-standard);
  overflow: hidden;
}

.drawer-panel.open {
  transform: translateY(0);
}

/* Tablet & Desktop Drawer Variant (Slides in from Right) */
@media (min-width: 1024px) {
  .drawer-panel.desktop-drawer-right {
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 440px;
    max-height: 100vh;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
  }

  .drawer-panel.desktop-drawer-right.open {
    transform: translateX(0);
  }
}

.drawer-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.drawer-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------
   14. Highlight & Animation Utilities
   ------------------------------------------------------------ */
@keyframes highlightFlash {
  0% {
    background-color: rgba(217, 83, 30, 0.25);
    box-shadow: 0 0 0 2px var(--primary);
  }
  100% {
    background-color: var(--bg-card);
    box-shadow: var(--shadow-sm);
  }
}

.item-flash {
  animation: highlightFlash 1.4s var(--ease-standard);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-5);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-state .empty-icon {
  margin-bottom: var(--space-3);
  color: var(--text-light);
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-1);
  color: var(--text-main);
}

.empty-state p {
  font-size: 0.875rem;
  max-width: 320px;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-color) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ------------------------------------------------------------
   15. Kitchen Display System (KDS) Specialized Styles
   ------------------------------------------------------------ */
.kds-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-body);
}

.kds-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  flex-shrink: 0;
}

.kds-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  padding: var(--space-4);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.kds-column {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Top subtle 3px accent line per column instead of thick neon borders */
.kds-column.col-accepted { border-top: 3px solid #818cf8; }
.kds-column.col-cooking { border-top: 3px solid #fbbf24; }
.kds-column.col-cooked { border-top: 3px solid #4ade80; }

.kds-col-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
  flex-shrink: 0;
}

.kds-col-title {
  font-size: 0.9375rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.kds-col-count {
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
}

.kds-col-cards {
  padding: var(--space-3);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Kitchen Ticket Card */
.kds-ticket {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.kds-ticket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-2);
  border-bottom: 1px dashed var(--border-color);
}

.kds-table-badge {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.elapsed-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
}

.elapsed-chip.urgent {
  background-color: var(--status-cancelled-bg);
  color: var(--status-cancelled);
  border: 1px solid var(--status-cancelled-border);
}

.elapsed-chip.warning {
  background-color: var(--status-cooking-bg);
  color: var(--status-cooking);
  border: 1px solid var(--status-cooking-border);
}

.kds-items-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kds-item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 0.9375rem;
  color: var(--text-main);
}

.kds-item-qty {
  font-weight: 800;
  min-width: 28px;
  color: var(--primary);
}

.kds-item-name {
  font-weight: 600;
  flex: 1;
}

.kds-note-box {
  background-color: var(--bg-subtle);
  border-left: 3px solid var(--primary);
  padding: var(--space-2) var(--space-3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Tablet / Mobile Tabs for Kitchen Display */
.kds-mobile-tabs {
  display: none;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-2) var(--space-4);
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .kds-mobile-tabs {
    display: flex;
    justify-content: space-around;
  }
  .kds-board {
    display: block;
    padding: var(--space-3);
  }
  .kds-column {
    display: none;
    height: 100%;
  }
  .kds-column.active-tab-col {
    display: flex;
  }
}

/* ------------------------------------------------------------
   16. Manager Dashboard Layout
   Responsive sidebar: >=1100px: 240px; 768-1099px: 72px rail; <768px: bottom nav
   ------------------------------------------------------------ */
.manager-shell {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-body);
}

.manager-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: var(--z-sticky);
  flex-shrink: 0;
  transition: width var(--transition-normal);
}

.sidebar-brand {
  height: var(--header-height);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-color);
  font-weight: 800;
  font-size: 1.15rem;
}

.sidebar-nav {
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
  overflow-y: auto;
}

/* Fixed-height nav items so badges or state changes never cause height shift */
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}

.nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
}

.nav-item-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: #ffffff;
}

.manager-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.manager-header {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 20;
}

.manager-main {
  padding: var(--space-6);
  flex: 1;
}

/* Tablet Rail Navigation (768px - 1099px) */
@media (min-width: 768px) and (max-width: 1099px) {
  .manager-sidebar {
    width: var(--sidebar-collapsed);
  }
  .sidebar-brand span,
  .nav-item .nav-text,
  .nav-badge {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 0;
  }
  .nav-item-content {
    justify-content: center;
  }
}

/* Mobile Bottom Navigation (<768px) */
@media (max-width: 767px) {
  .manager-shell {
    flex-direction: column;
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  .manager-header {
    height: 52px;
    padding: 0 var(--space-3);
  }
  .manager-header #page-title {
    font-size: 1rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 155px !important;
  }
  .manager-header #header-clock {
    display: none !important;
  }
  .manager-sidebar {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(58px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-right: none;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-card);
    z-index: var(--z-sticky);
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.06);
    flex-direction: row;
  }
  .sidebar-brand {
    display: none !important;
  }
  .sidebar-nav {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    gap: 0 !important;
  }
  .nav-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
    min-height: 0 !important;
    padding: 4px 2px !important;
    font-size: 0.6875rem !important;
    border-radius: 0 !important;
    border: none !important;
    border-top: 2px solid transparent !important;
    position: relative !important;
    gap: 2px !important;
    text-align: center !important;
  }
  .nav-item.active {
    border-top-color: var(--primary) !important;
    background-color: var(--bg-subtle) !important;
    color: var(--primary) !important;
  }
  .nav-item-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 2px !important;
  }
  .nav-item-content .icon {
    width: 19px !important;
    height: 19px !important;
  }
  .nav-text {
    font-size: 0.6875rem !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
  }
  .nav-badge {
    position: absolute !important;
    top: 4px !important;
    right: calc(50% - 17px) !important;
    padding: 1px 4px !important;
    font-size: 0.6rem !important;
    min-width: 15px !important;
    height: 15px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    border-radius: var(--radius-full) !important;
  }
  .manager-main {
    padding: var(--space-3);
  }
}

/* ------------------------------------------------------------
   17. Manager HTML/CSS Sales Bar Chart (Proportional, Beautiful)
   ------------------------------------------------------------ */
.sales-chart-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.chart-bars-wrap {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  height: 200px;
  padding-top: var(--space-6);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.chart-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 56px; /* Crucial: Prevents a single bar from stretching to 100% width! */
  min-width: 36px;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.chart-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--primary), #ea580c);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  transition: height 0.4s var(--ease-standard);
  position: relative;
  min-height: 4px;
}

.chart-bar-group:hover .chart-bar-fill {
  background: linear-gradient(180deg, #f97316, var(--primary));
}

.chart-bar-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-2);
  white-space: nowrap;
}

.chart-bar-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

/* ------------------------------------------------------------
   18. Table Management Grid & Tiles
   ------------------------------------------------------------ */
.tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-3);
}

.table-tile {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px; /* Equal height across all tables, including Table 10 */
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

.table-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--text-muted);
}

.table-tile.has-waiter {
  border-color: #ef4444;
  background-color: #fff1f2;
}
[data-theme="dark"] .table-tile.has-waiter {
  background-color: rgba(239, 68, 68, 0.15);
}

.table-tile.active-dining {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.table-tile.awaiting-payment {
  border-color: #0d9488;
  background-color: #f0fdfa;
}
[data-theme="dark"] .table-tile.awaiting-payment {
  background-color: rgba(13, 148, 136, 0.15);
}

.table-tile-num {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.table-tile-status {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.2;
}

.table-tile-total {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--primary);
}

/* ------------------------------------------------------------
   19. Customer Mobile-First App Shell & Food Cards
   ------------------------------------------------------------ */
.customer-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--bg-card);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 35px rgba(0, 0, 0, 0.08);
}

@media (min-width: 1024px) {
  .customer-shell.desktop-wide {
    max-width: 1200px;
    box-shadow: none;
    background-color: transparent;
  }
}

.food-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.food-card:hover {
  box-shadow: var(--shadow-md);
}

.food-card.unavailable {
  opacity: 0.55;
  filter: grayscale(40%);
}

.food-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background-color: var(--bg-subtle);
  overflow: hidden;
}

.food-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s var(--ease-standard);
}

.food-card:hover .food-card-img {
  transform: scale(1.03);
}

.food-card-badges {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  display: flex;
  gap: var(--space-1);
}

.watch-video-btn {
  position: absolute;
  bottom: var(--space-2);
  right: var(--space-2);
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: background-color var(--transition-fast);
}

.watch-video-btn:hover {
  background-color: rgba(0, 0, 0, 0.88);
}

.food-card-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.food-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.food-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.food-card-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.food-ingredients-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: 2px;
}

.ingredient-chip {
  font-size: 0.6875rem;
  padding: 0.15rem 0.5rem;
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}

.food-card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
}

.food-price {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text-main);
}

/* Sticky Bottom Cart Bar on Mobile */
.sticky-cart-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 35;
}

/* ------------------------------------------------------------
   20. Hub / Landing Grid (Responsive 4-Cards, No Orphan Row)
   ------------------------------------------------------------ */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: var(--space-5);
  margin-top: var(--space-6);
  width: 100%;
  align-items: stretch;
}

.hub-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-4);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  text-decoration: none;
  color: inherit;
}

.hub-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary);
}

.hub-card-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  background-color: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hub-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.hub-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
