:root {
  /* Subtle Dark Theme (Zinc Palette) */
  --bg: #18181b;
  /* Zinc 900 */
  --surface: #27272a;
  /* Zinc 800 */
  --surface-hover: #3f3f46;
  /* Zinc 700 */
  --border: #3f3f46;

  --primary: #f59e0b;
  /* Amber 500 (Subtle Gold) */
  --primary-hover: #d97706;

  --text-main: #f4f4f5;
  /* Zinc 100 */
  --text-muted: #a1a1aa;
  /* Zinc 400 */

  --success: #10b981;
  /* Emerald 500 */
  --danger: #ef4444;
  /* Red 500 */

  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Utilities */
.container-padding {
  padding: 20px;
  padding-bottom: 120px;
  /* Space for mobile cart */
}

.hidden {
  display: none !important;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary);
  color: #000;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--surface-hover);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background-color: var(--danger);
  color: #fff;
}

.btn-block {
  width: 100%;
  display: flex;
}

.btn-micro {
  padding: 4px 10px;
  background: var(--surface-hover);
  border-radius: 6px;
  border: none;
  color: var(--text-main);
  font-size: 1.1rem;
  cursor: pointer;
}

.actions-group {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: wrap;
}

.actions-group .btn {
  padding: 8px 12px !important;
  font-size: 0.85rem !important;
}

/* Header */
header {
  background-color: rgba(24, 24, 27, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 15px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

/* Login */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  background: var(--surface);
  padding: 40px;
  border-radius: 20px;
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary);
}

/* Fix for Radio Buttons inheriting width: 100% */
.form-group input[type="radio"] {
  width: auto;
  margin-right: 5px;
  display: inline-block;
}

/* Fix for Side-by-Side Inputs (Price & Category) */
.form-group-row {
  display: flex;
  gap: 15px;
}

.form-group-row .form-group {
  flex: 1;
  min-width: 0;
}

/* Fix for Select Dropdown */
.form-select {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23a1a1aa%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 30px;
}

.form-select:focus {
  border-color: var(--primary);
}


/* Tables View Header */
#tables-view h2 {
  margin-bottom: 30px;
  color: var(--text-main);
}

/* Dashboard Action Buttons - Subtle Style */
#manage-menu-btn {
  background-color: rgba(99, 102, 241, 0.1);
  /* Indigo */
  color: #818cf8;
  border: 1px solid #6366f1;
}

#manage-menu-btn:hover {
  background-color: rgba(99, 102, 241, 0.2);
}

#manage-tables-btn {
  background-color: rgba(59, 130, 246, 0.1);
  /* Blue */
  color: #60a5fa;
  border: 1px solid #3b82f6;
}

#manage-tables-btn:hover {
  background-color: rgba(59, 130, 246, 0.2);
}

#manage-waiters-btn {
  background-color: rgba(20, 184, 166, 0.1);
  /* Teal */
  color: #2dd4bf;
  border: 1px solid #14b8a6;
}

#manage-waiters-btn:hover {
  background-color: rgba(20, 184, 166, 0.2);
}

#history-btn {
  background-color: rgba(249, 115, 22, 0.1);
  /* Orange */
  color: #fb923c;
  border: 1px solid #f97316;
}

#history-btn:hover {
  background-color: rgba(249, 115, 22, 0.2);
}

#kds-btn {
  background-color: rgba(244, 63, 94, 0.1);
  /* Rose */
  color: #fb7185;
  border: 1px solid #f43f5e;
}

#kds-btn:hover {
  background-color: rgba(244, 63, 94, 0.2);
}

#analytics-btn {
  background-color: rgba(139, 92, 246, 0.1);
  /* Violet */
  color: #a78bfa;
  border: 1px solid #8b5cf6;
}

#analytics-btn:hover {
  background-color: rgba(139, 92, 246, 0.2);
}

#reports-btn {
  background-color: rgba(16, 185, 129, 0.1);
  /* Emerald */
  color: #34d399;
  border: 1px solid #10b981;
}

#reports-btn:hover {
  background-color: rgba(16, 185, 129, 0.2);
}


/* Table Grid */
.table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 15px;
}

.table-card {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.2s;
  position: relative;
  /* Fix inconsistent size */
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.table-card:hover {
  transform: translateY(-2px);
  border-color: var(--text-muted);
}

.table-card .table-number {
  font-size: 1.8rem;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  /* Changed font */
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 5px;
}

.table-card .table-status {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.table-card.vacant .table-status {
  color: var(--success);
}

.table-card.vacant {
  border-bottom: 3px solid var(--success);
}

.waiter-tag {
  font-size: 0.8rem;
  font-weight: normal;
  color: var(--primary);
  display: inline-block;
  margin-left: 10px;
  background: var(--background);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--primary);
}

.table-card.occupied .table-status {
  color: var(--danger);
}

.table-card.occupied {
  border-bottom: 3px solid var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

.table-card.ready .table-status {
  color: var(--primary);
  /* Amber/Gold */
  animation: pulse 2s infinite;
}

.table-card.ready {
  border-bottom: 3px solid var(--primary);
  background: rgba(245, 158, 11, 0.1);
}

@keyframes pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }

  100% {
    opacity: 1;
  }
}


/* Layout */
.order-interface {
  display: flex;
  flex-direction: column;
  display: flex;
  flex-direction: column;
  min-height: 80vh;
}

/* Back Button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 0;
  margin-bottom: 20px;
  transition: all 0.2s ease;
}

.back-btn svg {
  transition: transform 0.2s ease;
}

.back-btn:hover {
  color: var(--primary);
}

.back-btn:hover svg {
  transform: translateX(-4px);
}

/* Dietary Toggle (Segmented Control) */
.dietary-toggle-container {
  display: flex;
  justify-content: center;
  padding-bottom: 10px;
}

.dietary-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  display: flex;
  padding: 4px;
  gap: 2px;
}

.dt-btn {
  background: transparent;
  border: none;
  padding: 6px 20px;
  border-radius: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.dt-btn.active {
  background: var(--text-main);
  color: var(--bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Specific Active Colors */
.dt-btn:nth-child(2).active {
  background: #10b981;
  color: #fff;
}

/* Veg Green */
.dt-btn:nth-child(3).active {
  background: #ef4444;
  color: #fff;
}

/* Non-Veg Red */

/* Filters */
.category-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0;
  margin-bottom: 10px;
  position: sticky;
  top: 62px;
  background: var(--bg);
  z-index: 40;
}

.cat-btn {
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.cat-btn:hover {
  background: var(--surface-hover);
  color: var(--text-main);
}

.cat-btn.active {
  background: var(--text-main);
  color: var(--bg);
  border-color: var(--text-main);
  font-weight: 600;
}

/* Menu Grid */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.menu-item {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Stack vertically on mobile */
  border: 1px solid var(--border);
}

.menu-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  background-color: #000;
}

.menu-details {
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.menu-details h4 {
  font-size: 1rem;
  margin-bottom: 5px;
}

.menu-details .menu-price {
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 10px;
}

/* Fixed Cart Bottom Sheet */
.order-summary {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  z-index: 100;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.order-summary h3 {
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
}

.cart-items {
  max-height: 35vh;
  overflow-y: auto;
  margin-bottom: 15px;
  padding-right: 5px;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.cart-item>div:first-child {
  flex: 1 1 100%;
}

/* Full width name on mobile */
.cart-item>div:nth-child(2) {
  flex: 0 0 auto;
}

/* Qty controls */
.cart-item>div:last-child {
  flex: 0 0 auto;
  min-width: 60px;
  text-align: right;
}

@media (min-width: 400px) {
  .cart-item {
    flex-wrap: nowrap;
  }

  .cart-item>div:first-child {
    flex: 1;
    margin-right: 10px;
  }
}

/* Veg/Non-Veg Tags */
.veg-tag,
.non-veg-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.veg-tag {
  border-color: #10b981;
}

.veg-tag::after {
  content: '';
  width: 10px;
  height: 10px;
  background: #10b981;
  border-radius: 50%;
}

.non-veg-tag {
  border-color: #ef4444;
}

.non-veg-tag::after {
  content: '';
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
}

.menu-item {
  position: relative;
}

/* Ensure relative for absolute tags */

.cart-total {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: right;
  margin-bottom: 15px;
  color: var(--primary);
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.action-buttons .btn {
  flex: 1;
  padding: 14px;
}


/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.modal-content {
  background: #fff;
  color: #000;
  padding: 25px;
  border-radius: 2px;
  width: 90%;
  max-width: 320px;
}

.bill-print-area {
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  border: 1px solid #eee;
  padding: 10px;
  margin-bottom: 15px;
}

.bill-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  border-bottom: 1px dashed #eee;
  padding-bottom: 2px;
}

.bill-total {
  text-align: right;
  font-weight: bold;
  font-size: 1.1rem;
  margin-top: 10px;
  border-top: 2px solid #000;
  padding-top: 5px;
}



/* Mobile Order Summary (Bottom Sheet) */
.order-summary {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 15px 20px 25px 20px;
  z-index: 100;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  max-height: 85vh;
  overflow-y: hidden;
}

/* Waiter Selection Container */
.waiter-selection-container {
  background: var(--bg);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Cart Toggle Header (Mobile Only) */
.cart-toggle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.cart-mini-summary {
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  gap: 15px;
}

.cart-toggle-icon {
  font-size: 1.2rem;
  transition: transform 0.3s;
  color: var(--primary);
}

/* Collapsible Wrapper */
.cart-details-collapsed {
  display: none;
  overflow-y: auto;
  padding-bottom: 20px;
}

.order-summary.expanded .cart-details-collapsed {
  display: block;
  animation: fadeIn 0.3s;
}

.order-summary.expanded .cart-toggle-icon {
  transform: rotate(180deg);
}

.order-summary.expanded {
  padding-top: 20px;
}

/* Dropdown Fix */
.form-select {
  width: 100%;
  max-width: 100%;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-main);
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.cart-items {
  max-height: 60vh;
}

/* Desktop Responsive */

@media (min-width: 768px) {
  .container {
    padding-bottom: 20px;
  }

  .menu-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .menu-item {
    flex-direction: column;
  }

  .menu-img {
    width: 100%;
    height: 160px;
  }

  .order-interface {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 30px;
  }

  .category-filter {
    position: relative;
    top: 0;
    background: transparent;
  }

  /* Desktop: Always Expand, Hide Toggle */
  .order-summary {
    position: sticky;
    top: 100px;
    bottom: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: none;
    height: fit-content;
    margin-top: 0;
    padding: 20px;
  }

  .cart-toggle-header {
    display: none;
  }

  .cart-details-collapsed {
    display: block;
  }

  .cart-items {
    max-height: 60vh;
  }


}



/* Dietary Toggle (Segmented Control) */
.dietary-toggle-container {
  display: flex;
  justify-content: center;
  padding-bottom: 10px;
}

.dietary-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  display: flex;
  padding: 4px;
  gap: 2px;
}

.dt-btn {
  background: transparent;
  border: none;
  padding: 6px 20px;
  border-radius: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.dt-btn.active {
  background: var(--text-main);
  color: var(--bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Specific Active Colors */
.dt-btn:nth-child(2).active {
  background: #10b981;
  color: #fff;
}

/* Veg Green */
.dt-btn:nth-child(3).active {
  background: #ef4444;
  color: #fff;
}

/* Non-Veg Red */

/* Custom Toast/Dialog (High Contrast & Top Position) */
.custom-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: #000;
  padding: 12px 24px;
  border-radius: 8px;
  /* Classic toast look */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 99999;
  /* Ensure on top of everything */
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.custom-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.custom-toast.error {
  background: #ef4444;
  /* Solid Red */
  color: #fff;
}

.custom-toast.success {
  background: #10b981;
  /* Solid Green */
  color: #fff;
}

/* Search Bar */
.search-container {
  padding: 0 0 15px 0;
}

.search-input {
  width: 100%;
  padding: 12px 20px;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}


/* Search Clear Icon */
.search-container {
  position: relative;
}

.search-clear {
  position: absolute;
  right: 15px;
  top: 35%;
  transform: translateY(-60%);
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.search-clear:hover {
  background: var(--surface-hover);
  color: var(--danger);
}


/* Global Loader */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


/* Search Clear Icon Fix */
/* .search-clear {
  top: 0 !important;
  bottom: 0 !important;
  margin: auto !important;
  transform: none !important;
} */

/* Dashboard Header & Clock */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

#tables-view h2 {
  margin-bottom: 0;
  /* Remove existing margin as parent handles it */
}

.live-clock {
  font-family: 'Courier New', Courier, monospace;
  /* Monospace for stability */
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 600;
  background: var(--surface);
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
}


/* Order View Header */
.table-label {
  margin: 0;
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 600;
}


/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.stat-card {
  background: var(--surface);
  padding: 15px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-title {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}


/* History View */
.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.h-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

#store-name {
  color: var(--primary);
}

.username-display {
  font-weight: 600;
  color: var(--primary);
  margin-right: 15px;
  font-size: 1rem;
  text-transform: capitalize;
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: 0.9rem;
}

.logout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 20px;
  margin-top: 40px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.app-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.app-footer a:hover {
  text-decoration: underline;
}

.h-items {
  margin-bottom: 15px;
}

.h-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 5px;
  color: var(--text-main);
}

.h-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}


/* History Controls */
.history-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.date-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-summary-box {
  font-weight: bold;
  color: var(--text-main);
  font-size: 1.1rem;
}

#period-total {
  color: var(--primary);
  margin-left: 5px;
}


/* Refined History Controls */
.filter-group {
  display: flex;
  align-items: flex-end;
  gap: 15px;
  flex-wrap: wrap;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-item label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 2px;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 2px;
  /* Align with inputs */
}

/* Enhancing inputs */
.form-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--primary);
}

.history-summary-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: var(--bg);
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.history-summary-box span:first-child {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.history-summary-box span:last-child {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

/* History Grouping Styles */
.history-date-group {
  margin-bottom: 30px;
}

.history-date-header {
  background: var(--surface);
  color: var(--primary);
  padding: 10px 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-weight: bold;
  font-size: 1.05rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  position: sticky;
  top: 70px;
  /* Adjust based on header height + tabs */
  z-index: 10;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.history-date-header span:last-child {
  font-size: 0.95rem;
  color: var(--text-main);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Nested Table & Collapsible Styles */
.history-date-header {
  cursor: pointer;
  user-select: none;
}

.history-date-header::after {
  content: '▲';
  font-size: 0.8rem;
  margin-left: 10px;
  transition: transform 0.3s;
}

.history-date-group.collapsed .history-date-header::after {
  transform: rotate(180deg);
}

.history-date-group.collapsed .date-content {
  display: none;
}

.history-table-group {
  margin-bottom: 20px;
  border-left: 2px solid var(--border);
  margin-left: 10px;
  padding-left: 15px;
}

.history-table-header {
  background: var(--surface-hover);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.history-table-header::after {
  content: '▼';
  font-size: 0.7rem;
  margin-left: 10px;
  transition: transform 0.3s;
}

.history-table-group.collapsed .history-table-header::after {
  transform: rotate(-90deg);
}

.history-table-group.collapsed .table-content {
  display: none;
}

.history-table-header .table-name {
  color: var(--primary);
}

.history-table-header .table-total {
  font-size: 0.9rem;
  color: var(--text-main);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text-main);
  background: var(--surface-hover);
  border-color: var(--border);
}


/* Fix for Date Picker Visibility in Dark Mode */
input[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  opacity: 0.8;
}

input[type='date']::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}


/* Desktop Cart Total */
.cart-total-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 2px solid var(--border);
  color: var(--primary);
}

@media (max-width: 768px) {
  .cart-total-section {
    /* display: none; */
    /* Unhiding as per user feedback */
    margin-bottom: 10px;
  }
}

/* Menu Manager Styles */
.manager-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding-bottom: 20px;
}

.manager-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.mc-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
}

.mc-price {
  color: var(--primary);
  font-weight: 600;
}

.mc-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}

.mc-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.radio-group {
  display: flex;
  gap: 20px;
  margin-top: 5px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.form-group-row {
  display: flex;
  gap: 15px;
}

.form-group-row .form-group {
  flex: 1;
}


/* Form Styles */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Modal Form Specifics */
#menu-form-modal .modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
}



/* Manager Controls */
.manager-controls {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 20px;
  align-items: center;
}

.search-container input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
}

.dietary-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.dt-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
}

.dt-btn.active {
  background: var(--primary);
  color: white;
}

/* Pagination */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

/* Category List */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.cat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: var(--background);
  border-radius: 8px;
  border: 1px solid var(--border);
}


/* Order Pagination */
#order-view .pagination-controls {
  justify-content: center;
  padding: 20px 0;
  width: 100%;
}

/* --- Reports View Styles --- */
.reports-controls {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.reports-controls .filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
}

.reports-controls .filter-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.reports-controls .filter-item label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.reports-controls .filter-actions {
  display: flex;
  gap: 10px;
}

.report-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 30px;
  border: 1px solid var(--border);
  min-height: 400px;
}

.report-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-muted);
  font-style: italic;
}

.report-header {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.report-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.report-card {
  background: var(--bg);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-align: center;
}

.report-card .label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.report-card .value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

.report-table th,
.report-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.report-table th {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* PDF Export Specific Overrides (Screen) */
.report-content.pdf-mode {
  max-width: 800px;
  margin: 0 auto;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* --- Print Styles --- */
@media print {

  /* Report Print Mode Class */
  body.printing-report {
    visibility: hidden !important;
    background: white !important;
    color: black !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.printing-report #reports-view,
  body.printing-report #reports-view * {
    visibility: visible !important;
    background: white !important;
    color: black !important;
  }

  body.printing-report .view-header,
  body.printing-report .reports-controls,
  body.printing-report .reports-view button,
  body.printing-report .back-btn {
    display: none !important;
  }

  body.printing-report .report-header {
    margin-bottom: 10px !important;
    padding-bottom: 10px !important;
  }

  body.printing-report .report-header h3 {
    font-size: 1.2rem !important;
    margin: 0 !important;
  }

  body.printing-report .report-header p {
    font-size: 0.8rem !important;
    margin: 2px 0 !important;
  }

  body.printing-report .report-stats-grid {
    gap: 10px !important;
    margin-bottom: 15px !important;
    grid-template-columns: repeat(3, 1fr) !important;
    /* Force 3 columns */
  }

  body.printing-report .report-card {
    padding: 10px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    color: black !important;
  }

  body.printing-report .report-card .label {
    font-size: 0.7rem !important;
  }

  body.printing-report .report-card .value {
    font-size: 1.1rem !important;
  }

  body.printing-report .report-table th,
  body.printing-report .report-table td {
    padding: 6px 8px !important;
    font-size: 0.8rem !important;
    border-color: #eee !important;
  }

  body.printing-report h4 {
    font-size: 0.9rem !important;
    margin: 10px 0 5px 0 !important;
  }

  body {
    visibility: hidden !important;
  }

  #checkout-modal,
  #checkout-modal * {
    visibility: visible !important;
  }

  #checkout-modal {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: white !important;
  }

  #checkout-modal .modal-content {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    background: white !important;
  }

  /* Hide buttons and payment selectors during print */
  #checkout-modal .btn,
  #checkout-modal label,
  #checkout-modal input[type="radio"],
  #checkout-modal .modal-content>div:not(#print-area) {
    display: none !important;
  }

  .bill-print-area {
    display: block !important;
    visibility: visible !important;
  }

  /* Thermal 58mm (Small) */
  .bill-print-area.thermal-58mm {
    width: 58mm !important;
    margin: 0 auto !important;
    padding: 2mm !important;
    font-size: 8pt !important;
    line-height: 1.1 !important;
    color: #000 !important;
    font-family: 'Courier New', Courier, monospace !important;
  }

  .thermal-58mm .bill-header h3 {
    font-size: 11pt !important;
    margin: 0 0 2mm 0;
    text-align: center;
  }

  .thermal-58mm .bill-header p {
    font-size: 7pt !important;
    margin: 0;
    text-align: center;
  }

  .thermal-58mm .bill-line {
    display: flex;
    justify-content: space-between;
    font-size: 8pt !important;
    margin-bottom: 1mm;
  }

  .thermal-58mm .bill-summary {
    font-size: 8pt !important;
    border-top: 1px dashed #000;
    margin-top: 2mm;
    padding-top: 2mm;
  }

  .thermal-58mm .bill-total {
    font-size: 10pt !important;
    font-weight: bold;
  }

  /* Thermal 80mm (Large) */
  .bill-print-area.thermal-80mm {
    width: 80mm !important;
    margin: 0 auto !important;
    padding: 4mm !important;
    font-size: 9pt !important;
    line-height: 1.2 !important;
    color: #000 !important;
    font-family: 'Courier New', Courier, monospace !important;
  }

  .thermal-80mm .bill-header h3 {
    font-size: 13pt !important;
    text-align: center;
  }

  .thermal-80mm .bill-header p {
    font-size: 8pt !important;
    text-align: center;
  }

  .thermal-80mm .bill-line {
    display: flex;
    justify-content: space-between;
  }

  .thermal-80mm .bill-total {
    font-size: 11pt !important;
    font-weight: bold;
  }

  /* Standard A4 */
  .bill-print-area.standard {
    width: 100%;
    max-width: 80mm;
    margin: 0 auto;
    padding: 10mm;
    border: none;
  }
}