/* Fonts load via a preconnect'd <link> in each HTML <head> (parallel, non-blocking),
   not a render-blocking serial @import — see admin/login HTML heads. */

/* NOTE: :root design tokens are defined in admin-shell.css (light Logicues palette).
   Do NOT add a :root block here — it would override the light tokens and break theming.
   body.theme-* preset blocks have been removed; the admin always renders in the fixed
   light Logicues look. The #settingTheme picker still saves the customer-facing theme. */

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

/* Keyboard focus ring for interactive controls (visible only for keyboard nav). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.action-btn:focus-visible,
.table-action-btn:focus-visible,
.dismiss-alert-btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent-ocean);
  outline-offset: 2px;
  border-radius: 4px;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* Waiter Call Alert Banner Container */
#waiterAlertsContainer {
  padding: 0 40px;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.waiter-alert-banner {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border: 1px solid rgba(232, 89, 12, 0.35);
  border-radius: var(--border-radius-sm);
  padding: 14px 24px;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 16px rgba(20,18,14,.10);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.waiter-alert-text {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.waiter-alert-text span {
  font-size: 1.3rem;
  animation: bellRing 1.5s infinite alternate;
}

@keyframes bellRing {
  0% { transform: rotate(-10deg); }
  100% { transform: rotate(10deg); }
}

.dismiss-alert-btn {
  background: rgba(20,18,14,.06);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.dismiss-alert-btn:hover {
  background: var(--accent-gold);
  color: #fff;
  border-color: var(--accent-gold);
}

/* Persistent New-Order Banner (mirrors the waiter-call banner) */
#newOrderAlertsContainer {
  padding: 0 40px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.new-order-banner {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border: 1px solid rgba(232, 89, 12, 0.4);
  border-radius: var(--border-radius-sm);
  padding: 14px 24px;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 16px rgba(20,18,14,.10);
  animation: slideDown 0.3s ease;
}

.new-order-text {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.new-order-text span {
  font-size: 1.3rem;
  animation: bellRing 1.5s infinite alternate;
}

/* Ticket age badge on active order cards */
.ticket-age {
  display: inline-block;
  background: rgba(20,18,14,.05);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 50px;
  margin-top: 6px;
}

/* Overdue ticket highlight */
.order-card.ticket-overdue {
  border-color: var(--status-cancelled);
  box-shadow: 0 4px 18px rgba(225, 29, 72, 0.18);
}

.order-card.ticket-overdue .ticket-age {
  background: rgba(225, 29, 72, 0.10);
  border-color: var(--status-cancelled);
  color: var(--status-cancelled);
}

@media (max-width: 992px) {
  #newOrderAlertsContainer {
    padding: 0 20px;
  }
}

@media (max-width: 576px) {
  .new-order-banner {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
  }
}

@media (max-width: 720px) {
  #newOrderAlertsContainer {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Analytics Metrics Dashboard */
.analytics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-sm);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.metric-value {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text-primary);
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Main Section Layout */
.app-section {
  padding: 30px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

/* --- LIVE ORDERS GRID --- */
.orders-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 30px;
  align-items: start;
}

/* Grid items can't shrink below their content's min-content size by default,
   which clips wide order content. Allow the columns to shrink. */
.orders-grid > div {
  min-width: 0;
}

.column-header {
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.column-title {
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-count {
  background: rgba(20,18,14,.05);
  border: 1px solid var(--border-glass);
  color: var(--accent-gold);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 50px;
}

.orders-column {
  background: var(--bg-elevated);
  border-radius: var(--border-radius-md);
  padding: 20px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border: 1px solid var(--border-glass);
  transition: min-height 0.3s ease;
}

.empty-column-placeholder {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: center;
  padding: 40px 10px;
  border: 1px dashed var(--border-glass);
  border-radius: var(--border-radius-sm);
  background: rgba(20,18,14,.03);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
}

/* Individual Order Card */
.order-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  padding: 20px;
  border: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.order-card:hover {
  transform: translateY(-2px);
  border-color: rgba(232, 89, 12, 0.3);
  box-shadow: var(--shadow-pop);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 12px;
}

.order-id {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.order-table {
  background: rgba(232, 89, 12, 0.10);
  color: var(--accent-gold);
  border: 1px solid rgba(232, 89, 12, 0.20);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 50px;
  text-transform: uppercase;
}

.order-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.order-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.order-item-detail {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  gap: 12px;
  color: var(--text-primary);
}

/* Let the item label shrink and wrap long dish names instead of pushing the
   price out of the card. */
.order-item-detail > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-item-qty {
  font-weight: 800;
  color: var(--accent-gold);
  margin-right: 6px;
}

.order-total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-primary);
  padding-top: 12px;
  border-top: 1px dashed var(--border-glass);
}

.order-payment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(20,18,14,.04);
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  border: 1px solid var(--border-soft);
}

.payment-method-badge {
  font-weight: 700;
  color: var(--text-primary);
}

.payment-status-btn {
  border: none;
  background: none;
  font-weight: 800;
  cursor: pointer;
  text-decoration: underline;
  color: var(--accent-gold);
}

.payment-status-btn.paid {
  color: var(--accent-ocean);
  text-decoration: none;
  cursor: default;
}

.payment-status-btn.pending {
  color: var(--status-cancelled);
}

.order-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.action-btn.prepare {
  background: var(--status-preparing);
  color: #fff;
}

.action-btn.serve {
  background: var(--status-served);
  color: #fff;
}

.action-btn.complete {
  background: var(--status-completed);
  color: #fff;
}

.action-btn.cancel {
  background: transparent;
  color: var(--status-cancelled);
  border: 1px solid var(--status-cancelled);
}

.action-btn:hover {
  filter: brightness(0.92);
}

/* --- CONFIG FORMS & MENU MANAGE --- */
.settings-container {
  max-width: 600px;
  background: var(--bg-card);
  border-radius: var(--border-radius-md);
  padding: 30px;
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-card);
}

.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-elevated);
  color: var(--text-primary);
  /* 16px (not 0.95rem/15.2px) so iOS Safari does not auto-zoom the page on field focus.
     Applies to admin, login and global-admin, which all load this stylesheet. */
  font-size: 16px;
  outline: none;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--accent-gold);
  background: var(--bg-card);
}

.form-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.menu-mgmt-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 40px;
  align-items: start;
}

.menu-form-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-md);
  padding: 24px;
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-card);
}

.menu-list-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.menu-table {
  width: 100%;
  border-collapse: collapse;
}

/* On the 721px+ band the table is a real table inside an overflow-x:auto card;
   give it a min-width so the card scrolls horizontally instead of squishing the
   columns. The <=720px stacked layout overrides display to block and stays
   full-width, so this min-width must NOT be unscoped. */
@media (min-width: 721px) {
  .menu-table {
    min-width: 760px;
  }
}

.menu-table th {
  background: var(--bg-elevated);
  border-bottom: 2px solid var(--border-glass);
  text-align: left;
  padding: 16px 20px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.menu-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.9rem;
  vertical-align: middle;
  color: var(--text-primary);
}

.menu-table tr:last-child td {
  border-bottom: none;
}

.menu-table tr:hover td {
  background: rgba(20,18,14,.02);
}

/* Truncation for the Items / Description cells. Lives in a class (not inline)
   so the <=720px stacked layout can un-truncate it via the media query below;
   inline styles would otherwise win the cascade. */
.items-cell {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Switch toggles */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(20,18,14,.12);
  transition: .4s;
  border-radius: 24px;
  border: 1px solid var(--border-glass);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(20,18,14,.15);
}

input:checked + .slider {
  background-color: var(--accent-ocean);
  border-color: var(--accent-ocean);
}

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

.table-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-weight: 700;
  font-size: 0.85rem;
}

.table-action-btn.edit {
  color: var(--accent-gold);
}

.table-action-btn.delete {
  color: var(--status-cancelled);
}

/* Settings cards grid */
.settings-grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.settings-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* Responsive Styles for Mobile and Tablets */
@media (max-width: 992px) {
  #waiterAlertsContainer {
    padding: 0 20px;
  }

  .app-section {
    padding: 20px;
  }

  .analytics-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  /* Stack the 4 order columns vertically on phones/small tablets — no carousel. */
  .orders-grid {
    display: grid;
    grid-template-columns: 1fr;
    overflow-x: visible;
    scroll-snap-type: none;
    gap: 16px;
  }

  .orders-grid > div {
    flex: none;
    min-width: 0;
    scroll-snap-align: none;
  }

  .orders-column {
    min-height: auto;
  }

  .menu-mgmt-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .menu-list-card {
    overflow-x: auto;
  }
}

@media (max-width: 576px) {
  body {
    min-width: 0;
  }

  /* Compact 2x2 grid on phones (was a full-width stack of tall cards that hid the
     order board below). Smaller padding + type so all 4 stats fit in two short rows. */
  .analytics-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 18px;
  }

  .metric-card {
    padding: 12px 13px;
    gap: 3px;
  }

  .metric-title {
    font-size: 0.66rem;
    letter-spacing: 0.3px;
  }

  .metric-value {
    font-size: 1.2rem;
  }

  .metric-sub {
    font-size: 0.66rem;
  }

  .waiter-alert-banner {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
  }

  .dismiss-alert-btn {
    width: 100%;
    text-align: center;
  }

  .order-card {
    padding: 16px;
  }

  .order-actions {
    flex-direction: column;
  }

  .order-card-header,
  .order-payment-meta,
  .order-item-detail {
    gap: 10px;
  }

  .order-payment-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* --- ADMIN ADVANCED ANALYTICS & REVIEWS STYLES --- */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-top: 30px;
  align-items: stretch;
}

.analytics-grid > * {
  min-width: 0;
}

@media (max-width: 992px) {
  .analytics-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

.hourly-chart-container {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 160px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-glass);
  overflow-x: auto;
}

.chart-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.chart-bar {
  width: 24px;
  background: var(--accent-gradient);
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  transition: height 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 2px 8px rgba(232, 89, 12, 0.18);
}

.chart-bar-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.feedback-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  max-height: 300px;
}

.feedback-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feedback-card-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
}

.feedback-customer {
  color: var(--text-primary);
}

.feedback-stars {
  color: var(--accent-gold);
}

.feedback-comment {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  font-style: italic;
}

.feedback-date {
  font-size: 0.7rem;
  color: var(--text-secondary);
  align-self: flex-end;
}

/* --- ADMIN DEVELOPER FOOTER STYLES --- */
/* Bottom space so the last dashboard row clears the now-fixed footer. */
main {
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

.admin-footer {
  /* Flows at the END of the scrolling content (NOT position:fixed) so it never
     floats over / crops the order board or menu on mobile. */
  position: static;
  display: flex;
  justify-content: center;
  margin-top: 28px;
  padding: 16px 10px calc(16px + env(safe-area-inset-bottom));
  background: transparent;
}

.dev-badge {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(20,18,14,.06);
  border: 1px solid var(--border-glass);
  padding: 2px 9px;
  border-radius: 16px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.58rem;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  box-shadow: 0 1px 5px rgba(20,18,14,.06);
  opacity: 0.85;
  transition: var(--transition);
}

.dev-badge:hover {
  border-color: var(--accent-gold);
  box-shadow: 0 4px 20px rgba(232, 89, 12, 0.12);
  transform: translateY(-1px);
}

.dev-tag {
  color: var(--accent-gold);
  font-weight: 700;
}

.dev-highlight {
  color: var(--text-primary);
  font-weight: 700;
}

.dev-divider {
  width: 1px;
  height: 12px;
  background: var(--border-glass);
}

.dev-terminal-btn {
  color: var(--accent-ocean);
  text-decoration: none;
  display: flex;
  align-items: center;
  background: rgba(15,155,142,.08);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(15,155,142,.2);
  font-weight: bold;
  transition: var(--transition);
}

.dev-terminal-btn:hover {
  background: var(--accent-ocean);
  color: #fff;
}

/* --- REPORTS PERIOD DATE FILTER STYLES --- */
.filter-bar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  padding: 18px 24px;
  margin-bottom: 30px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-card);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-group label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- STATUS & PAYMENT BADGES FOR TABLE --- */
.status-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.5px;
}

.status-badge.pending {
  background: rgba(232, 133, 12, 0.12);
  color: var(--status-pending);
}

.status-badge.preparing {
  background: rgba(15, 155, 142, 0.12);
  color: var(--status-preparing);
}

.status-badge.served {
  background: rgba(47, 111, 237, 0.12);
  color: var(--status-served);
}

.status-badge.completed {
  background: rgba(22, 163, 74, 0.12);
  color: var(--status-completed);
}

.status-badge.cancelled {
  background: rgba(225, 29, 72, 0.10);
  color: var(--status-cancelled);
}

.payment-badge {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.payment-badge .method {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.payment-badge .status {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.payment-badge .status.paid {
  color: var(--status-completed);
}

.payment-badge .status.pending {
  color: var(--status-pending);
}

@media (max-width: 720px) {
  .app-section {
    padding-left: 16px;
    padding-right: 16px;
  }

  #waiterAlertsContainer,
  .app-section {
    padding-left: 16px;
    padding-right: 16px;
  }

  .menu-form-card,
  .menu-list-card,
  .settings-container,
  .filter-bar-card {
    border-radius: var(--border-radius-sm);
  }

  .filter-bar-card,
  .filter-group,
  .custom-range-inputs > div {
    align-items: stretch !important;
    flex-direction: column;
    width: 100%;
  }

  .filter-group .form-input,
  .custom-range-inputs .form-input,
  #applyCustomFilterBtn {
    width: 100% !important;
  }

  .menu-list-card {
    overflow: visible;
  }

  .menu-table,
  .menu-table thead,
  .menu-table tbody,
  .menu-table th,
  .menu-table td,
  .menu-table tr {
    display: block;
    width: 100%;
  }

  .menu-table thead {
    display: none;
  }

  .menu-table tr {
    background: var(--bg-elevated);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-sm);
    /* width:auto (NOT 100%) so the 14px side margins don't push the card 28px
       wider than the viewport — that overflow was clipping the right edge. */
    width: auto;
    margin: 14px;
    overflow: hidden;
  }

  .menu-table td {
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    text-align: right;
    white-space: normal !important;
    /* Let long values (descriptions, dish names) wrap below the label instead of
       spilling past the card edge. */
    flex-wrap: wrap;
    overflow-wrap: anywhere;
    min-width: 0;
  }

  .menu-table td:last-child {
    border-bottom: none;
  }

  .menu-table td::before {
    color: var(--text-secondary);
    content: attr(data-label);
    flex: 0 0 40%;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-align: left;
    text-transform: uppercase;
  }

  .menu-table td:empty::before {
    content: none;
  }

  /* Un-truncate the Items / Description cells in the stacked layout so their
     full content is readable. */
  .menu-table td.items-cell {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .table-action-btn {
    padding: 8px 10px;
  }

  .analytics-grid {
    gap: 16px;
  }

  .hourly-chart-container {
    overflow-x: auto;
    gap: 10px;
    justify-content: flex-start;
  }

  .chart-bar-wrapper {
    flex: 0 0 38px;
  }

  .admin-footer {
    padding: 5px 10px calc(5px + env(safe-area-inset-bottom));
  }

  .dev-badge {
    flex-direction: row;
    align-items: center;
    width: auto;
    border-radius: 16px;
  }
}

@media (max-width: 420px) {
  .analytics-row {
    gap: 10px;
  }

  .metric-title {
    font-size: 0.72rem;
  }

  .metric-value {
    font-size: 1.35rem;
    overflow-wrap: anywhere;
  }

  .orders-column {
    padding: 14px;
  }

  .order-table {
    font-size: 0.7rem;
    text-align: center;
  }
}



/* ----------------------------------------------------------------------------
   Shared card + button classes used by the Billing & Plan UI (and anywhere
   else that references them). Theme-aware via the existing CSS variables, so
   they automatically match the active tenant theme like the rest of the site.
---------------------------------------------------------------------------- */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-card);
}

.btn-primary,
.btn-secondary {
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  line-height: 1.2;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
    background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 14px rgba(232, 89, 12, 0.22);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(232, 89, 12, 0.30);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  padding: 11px 16px;
  font-weight: 600;
  font-size: 0.9rem;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card);
  border-color: var(--accent-ocean);
  transform: translateY(-2px);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Billing invoices table: give it a min-width and let its wrapper scroll
   horizontally on narrow panes instead of clipping the last column. */
.items-table {
  min-width: 380px;
}

/* ── Billing plan + add-on cards ─────────────────────────────────────────────
   Premium-styled cards that honour the active theme's accent gradient.
   The grid auto-wraps and never crops on any viewport. */

.billing-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

/* Base plan card */
.billing-plan-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  padding: 28px 20px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}

.billing-plan-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-pop);
  border-color: var(--accent-gold);
}

/* Featured / "Most Popular" card gets the accent gradient border */
.billing-plan-card--featured {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 1px var(--accent-gold), 0 8px 28px rgba(232, 89, 12, 0.14);
}

.billing-plan-card--featured::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0.05;
  pointer-events: none;
}

/* "Most Popular" badge */
.billing-badge {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 14px;
  border-radius: 0 0 10px 10px;
  white-space: nowrap;
}

.billing-plan-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 10px;
}

.billing-plan-price {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 2rem;
  font-weight: 900;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.billing-plan-interval {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  -webkit-text-fill-color: var(--text-secondary);
}

.billing-choose-btn {
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
  font-size: 0.9rem;
  min-height: 44px;
}

/* Add-on cards — slightly more compact */
.billing-addon-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  padding: 20px 16px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.billing-addon-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
  border-color: var(--accent-ocean);
}

.billing-addon-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.billing-addon-price {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent-ocean);
}

.billing-buy-btn {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.85rem;
  min-height: 44px;
}

/* Narrow mobile: single-column billing grid */
@media (max-width: 480px) {
  .billing-cards-grid {
    grid-template-columns: 1fr;
  }
}

/* ── General responsiveness & touch fixes ───────────────────────────────── */

/* Ensure all interactive controls meet the 44px touch-target minimum */
.action-btn,
.btn-primary,
.btn-secondary,
button[type="submit"],
button[type="button"] {
  min-height: 44px;
}

/* Wide data tables: horizontally scrollable within their container so they
   never blow out the page width on narrow screens. */
.menu-list-card,
#billingInvoices,
.menu-list-card > div[style*="overflow-x"] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Every section must not overflow the viewport horizontally */
.app-section {
  max-width: 100vw;
  box-sizing: border-box;
}

/* Flex children (settings cards, form rows) must not escape their row */
.settings-grid-layout > *,
.menu-mgmt-layout > *,
.header-meta > * {
  min-width: 0;
}

/* iOS zoom prevention: all inputs, selects, textareas must be >= 16px.
   The .form-input rule already sets 16px; these catch any inline-styled or
   bare elements that might fall below that threshold. */
input,
select,
textarea {
  font-size: max(16px, 1em);
}

/* Respect the OS "reduce motion" setting — disable animations/transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Tablets (iPad portrait/landscape, 721–992px): keep single-column stacked layout
   (the <=992px block already sets grid-template-columns:1fr; this block reinforces
   the reset and clears the old carousel flex properties). */
@media (min-width: 721px) and (max-width: 992px) {
  .orders-grid {
    display: grid;
    grid-template-columns: 1fr;
    overflow-x: visible;
    scroll-snap-type: none;
  }
  .orders-grid > div {
    flex: none;
    min-width: 0;
    scroll-snap-align: none;
  }
}

/* ── Premium Sections (Inventory, Reservations, Staff/Shifts) ─────────────
   All scoped under .premium-section so shared classes used by #menuSection
   and the KDS page are NOT affected.
   ─────────────────────────────────────────────────────────────────────── */

/* Section wrapper: centred, capped width, matching Billing & Plan layout */
.premium-section .premium-inner {
  max-width: 1060px;
  margin: 0 auto;
}

/* Heading + subtitle rhythm matching Billing & Plan */
.premium-section .premium-inner > h2 {
  margin: 8px 0 4px;
  font-size: 1.5rem;
}

.premium-section .premium-inner > p.premium-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Gold accent bar under the section heading */
.premium-section .premium-inner > h2::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: var(--accent-gold);
  border-radius: 2px;
  margin-top: 6px;
  opacity: 0.7;
}

/* Compact form fields — override the global 24 px gap inside premium forms */
.premium-section .form-group {
  margin-bottom: 14px;
}

/* Slightly smaller label spacing to complement tighter field gap */
.premium-section .form-group label {
  margin-bottom: 5px;
}

/* Premium tables: let them size naturally to their content on desktop.
   The global @media (min-width:721px) { .menu-table { min-width:760px } }
   makes short Reservations / Shifts tables look sparse — override here. */
@media (min-width: 721px) {
  .premium-section .menu-table {
    min-width: unset;
    width: 100%;
  }
}

/* Subtle gold-tinted top border on premium cards */
.premium-section .menu-form-card,
.premium-section .menu-list-card {
  border-top: 2px solid rgba(232, 89, 12, 0.20);
}

/* Section heading inside list-card (e.g. "Reservations", "Shifts") */
.premium-section .menu-list-card > h3,
.premium-section .menu-list-card > div > h3 {
  padding: 18px 20px 0;
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--text-primary);
}

/* Empty-state rows — make "No reservations." / "No shifts." look intentional */
.premium-empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 36px 20px;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.premium-empty-state::before {
  content: '—';
  display: block;
  font-size: 1.4rem;
  opacity: 0.4;
  margin-bottom: 8px;
}

/* Table chip list (tables in Reservations section) */
#tablesList .table-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(232, 89, 12, 0.08);
  border: 1px solid rgba(232, 89, 12, 0.25);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

#tablesList .table-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 2px;
  min-height: unset; /* chip delete × is intentionally smaller than 44px */
}

/* Staff list items */
#staffList .staff-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  gap: 8px;
  color: var(--text-primary);
}

#staffList .staff-item button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--status-cancelled);
  font-size: 0.85rem;
  min-height: 44px;
  padding: 0 8px;
}

/* Shift form row: wrap nicely on narrow viewports */
#shiftForm {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

#shiftForm .form-group {
  margin-bottom: 0;
}

/* Keep the "Add shift" / "Add" submit buttons on one line (don't let the tight
   flex row wrap the label). flex-shrink:0 stops the button from being squeezed. */
#shiftForm button[type="submit"],
#tableForm button[type="submit"] {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Premium section responsive ────────────────────────────────────── */

/* Stack the Shifts / Tables inline forms full-width on phones & small tablets.
   Bumped to ≤768 (was 576) so larger phones in landscape and small tablets also
   stack instead of overflowing the card. */
@media (max-width: 768px) {
  .premium-section .premium-inner {
    /* already 100% width; ensure it doesn't need side-scroll */
    width: 100%;
    box-sizing: border-box;
  }

  /* Shift form: stack each field full-width so controls stay tappable */
  #shiftForm {
    flex-direction: column;
    align-items: stretch;
  }

  #shiftForm .form-group {
    flex: none;
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Native <select>/date/time inputs can exceed their box on iOS Safari — pin
     them to the container width so the fields never spill past the card edge. */
  #shiftForm .form-input,
  #tableForm .form-input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  #shiftForm button[type="submit"] {
    width: 100%;
  }

  /* Table form in reservations: also full-width stacked on very narrow */
  #tableForm {
    flex-direction: column;
    align-items: stretch;
  }

  #tableForm .form-group {
    flex: none !important;
    width: 100% !important;
    margin: 0 0 10px !important;
  }

  #tableForm button[type="submit"] {
    width: 100%;
  }

  /* Premium tables' delete column: hide the empty label line in stacked view */
  .premium-section .menu-table td:last-child:empty::before,
  .premium-section .menu-table td[data-label=""]:empty {
    display: none;
  }

  /* Empty-state td in stacked view: undo flex layout so it renders as a
     centred block, and suppress the data-label ::before pseudo. */
  .menu-table td.premium-empty-state {
    display: block;
    text-align: center;
  }

  .menu-table td.premium-empty-state::before {
    content: '—';
    flex: none;
    text-transform: none;
    font-size: 1.4rem;
    opacity: 0.4;
    display: block;
    font-weight: 400;
    letter-spacing: 0;
    margin-bottom: 8px;
  }
}

/* ── Ingredient Inventory UI ──────────────────────────────────────────────────
   Styles for Feature 3: ingredient-based inventory.
   Reuses .menu-table (already styled) + .premium-section tokens.
   ──────────────────────────────────────────────────────────────────────────── */

/* Inline add-ingredient form — flex row on desktop, same as #shiftForm */
#ingredientForm {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

#ingredientForm .form-group {
  margin-bottom: 0;
}

/* Keep the submit button from wrapping its text or being squeezed */
#ingredientForm button[type="submit"] {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Low-stock highlight row in the ingredients table */
.ingredient-row-low td {
  background: rgba(225, 29, 72, 0.06) !important;
  color: var(--status-cancelled);
}

/* ── Recipe cards in #recipesContainer ───────────────────────────────────── */

/* One card per menu item */
.recipe-card {
  background: var(--bg-secondary, var(--bg-elevated));
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.recipe-card:last-child {
  margin-bottom: 0;
}

/* Item name heading inside the card */
.recipe-card-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-glass);
}

/* Each ingredient row: name on the left, qty input + remove button on the right */
.recipe-ingredient-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
  min-width: 0;
}

.recipe-ingredient-row:last-of-type {
  border-bottom: none;
}

/* Ingredient name label — let it shrink and wrap rather than overflow */
.recipe-ingredient-name {
  flex: 1 1 0;
  font-size: 0.88rem;
  color: var(--text-primary);
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Qty input inside a recipe row */
.recipe-qty-input {
  width: 80px;
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 16px; /* iOS no-zoom */
  text-align: right;
}

.recipe-qty-input:focus {
  border-color: var(--accent-gold);
  outline: none;
  background: var(--bg-card);
}

/* Remove (×) button per ingredient */
.recipe-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--status-cancelled);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
  transition: var(--transition);
  min-height: 36px; /* slightly smaller than global 44px is acceptable for a × inline control */
}

.recipe-remove-btn:hover {
  background: rgba(225, 29, 72, 0.10);
}

/* Add-ingredient row at the bottom of each recipe card */
.recipe-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* The ingredient <select> in the add row */
.recipe-add-select {
  flex: 1 1 140px;
  min-width: 0;
  padding: 9px 10px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 16px; /* iOS no-zoom */
}

.recipe-add-select:focus {
  border-color: var(--accent-gold);
  outline: none;
}

/* Qty input in the add row */
.recipe-add-qty {
  width: 80px;
  flex-shrink: 0;
  padding: 9px 10px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 16px; /* iOS no-zoom */
  text-align: right;
}

.recipe-add-qty:focus {
  border-color: var(--accent-gold);
  outline: none;
  background: var(--bg-card);
}

/* "Add" button in the add row */
.recipe-add-btn {
  flex-shrink: 0;
  padding: 9px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition);
  min-height: 44px;
}

.recipe-add-btn:hover {
  border-color: var(--accent-gold);
  background: var(--bg-card);
}

/* Save recipe button at the bottom of each card */
.recipe-save-btn {
  margin-top: 14px;
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(232, 89, 12, 0.18);
  transition: var(--transition);
  min-height: 44px;
}

.recipe-save-btn:hover {
  filter: brightness(0.92);
  transform: translateY(-1px);
}

/* ── Ingredient form + recipe cards — mobile (≤768px) ────────────────────── */
@media (max-width: 768px) {
  /* Stack the ingredient add-form full-width (mirrors #shiftForm / #tableForm) */
  #ingredientForm {
    flex-direction: column;
    align-items: stretch;
  }

  #ingredientForm .form-group {
    flex: none;
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Inputs/selects must never spill past the card edge on iOS */
  #ingredientForm .form-input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  #ingredientForm button[type="submit"] {
    width: 100%;
  }

  /* Recipe cards: tighten padding on small screens */
  .recipe-card {
    padding: 14px 16px;
  }

  /* Let qty inputs shrink on very narrow phones (min readable width) */
  .recipe-qty-input,
  .recipe-add-qty {
    width: 64px;
  }

  /* Add row: allow the select to be on its own line if needed */
  .recipe-add-row {
    gap: 6px;
  }

  .recipe-add-select {
    flex-basis: 100%;
  }
}
