:root {
  --bg: #f8f9fc;
  --surface: #ffffff;
  --text: #1a1d26;
  --muted: #8b95a8;
  --primary: #ff6b35;
  --primary-dark: #e85a24;
  --primary-soft: #fff1eb;
  --outline: #eceff4;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(26, 29, 38, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px calc(100px + var(--safe-bottom));
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid var(--outline);
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.deliver-label {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.status-pill {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.status-pill.open {
  background: #dcfce7;
  color: #166534;
}

.status-pill.closed {
  background: #fee2e2;
  color: #991b1b;
}

/* Cover */
.hero-cover {
  position: relative;
  height: 140px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.hero-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent);
}

.status-banner {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Search */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 16px;
  padding: 4px 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--outline);
}

.search-icon {
  color: var(--muted);
  font-size: 1.1rem;
}

.search-wrap input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 12px 0;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}

/* Section */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.link-btn {
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Chips */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 14px;
  margin-bottom: 6px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip-row button {
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 16px;
  white-space: nowrap;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.chip-row button.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: #ffc9b0;
}

/* Product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.product-card {
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--outline);
  display: flex;
  flex-direction: column;
}

.product-image-wrap {
  position: relative;
  aspect-ratio: 1.15;
  background: linear-gradient(145deg, var(--primary-soft), #f3f4f6);
}

.product-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  opacity: 0.35;
}

.product-body {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-name {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.product-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.product-price {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text);
  min-width: 0;
  flex: 1;
  line-height: 1.2;
}

.product-add {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.45);
}

.product-add:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.product-card.sold-out {
  opacity: 0.65;
}

/* Cart bar */
.cart-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(12px + var(--safe-bottom));
  max-width: 448px;
  margin: 0 auto;
  z-index: 20;
}

.cart-bar-btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(255, 107, 53, 0.45);
}

.cart-count-badge {
  background: #fff;
  color: var(--primary-dark);
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 800;
}

.cart-bar-label {
  flex: 1;
  text-align: right;
}

/* Sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.28s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--outline);
}

.sheet-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #f3f4f6;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text);
}

.sheet-steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dde1ea;
}

.step-dot.active {
  background: var(--primary);
  width: 22px;
  border-radius: 999px;
}

.sheet-step {
  padding: 0 16px 24px;
  overflow-y: auto;
  flex: 1;
}

.step-hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 14px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.field em {
  color: #dc2626;
  font-style: normal;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--outline);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.95rem;
  background: #fafbfc;
  color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(255, 107, 53, 0.35);
  border-color: var(--primary);
}

.cart-items {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  max-height: 40dvh;
  overflow-y: auto;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--outline);
  border-radius: 14px;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-info strong {
  display: block;
  font-size: 0.9rem;
}

.cart-item-info span {
  font-size: 0.8rem;
  color: var(--muted);
}

.cart-qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-qty button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 1rem;
  cursor: pointer;
  font-weight: 700;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 16px;
  font-size: 1rem;
}

.summary-row strong {
  font-size: 1.15rem;
  color: var(--primary-dark);
}

.primary-btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  padding: 14px;
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 107, 53, 0.35);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.review-box {
  background: #fafbfc;
  border: 1px solid var(--outline);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.7;
}

.review-box h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.checkout-message {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  min-height: 1.2em;
}

.checkout-message.error {
  color: #dc2626;
}

/* Loading */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg);
  z-index: 50;
}

.loader {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--outline);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Toast */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(24px + var(--safe-bottom));
  max-width: 448px;
  margin: 0 auto;
  background: #166534;
  color: #fff;
  border-radius: 16px;
  padding: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.toast p {
  margin: 0;
  font-weight: 700;
}

.toast button {
  border: 0;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.empty-menu {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

/* Track banner */
.track-banner {
  width: 100%;
  border: 0;
  background: #eef6ff;
  color: #1d4ed8;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
}

.track-banner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2563eb;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.track-banner-arrow {
  margin-inline-start: auto;
  font-size: 1.2rem;
}

.track-head {
  text-align: center;
  padding: 8px 0 16px;
}

.track-head .order-no {
  font-size: 1.4rem;
  font-weight: 800;
}

.track-head .order-state {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.track-head .order-state.cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.track-head .order-state.delivered {
  background: #dcfce7;
  color: #166534;
}

.track-timeline {
  margin: 8px 0 18px;
  overflow-x: hidden;
  padding-bottom: 4px;
}

/* Horizontal order progress */
.track-progress {
  position: relative;
  width: 100%;
  max-width: 100%;
  padding: 8px 0 0;
}

.track-progress-rail {
  position: absolute;
  top: 22px;
  left: 12%;
  right: 12%;
  height: 4px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
  z-index: 0;
}

.track-progress-fill {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 55%, #15803d 100%);
  box-shadow: 0 0 12px rgba(22, 163, 74, 0.35);
  transition: width 0.85s cubic-bezier(0.4, 0, 0.2, 1);
}

.track-progress-fill--run {
  width: var(--progress, 0%);
}

.track-progress:not(.track-progress--complete) .track-progress-fill::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 28px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55));
  animation: track-progress-shine 1.6s ease-in-out infinite;
}

@keyframes track-progress-shine {
  0%, 100% { opacity: 0.35; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(-6px); }
}

.track-progress-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: space-between;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.track-progress-step {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.track-progress-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f1f3f7;
  border: 2px solid #d1d5db;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
  transition:
    background 0.35s ease,
    border-color 0.35s ease,
    transform 0.35s ease,
    box-shadow 0.35s ease;
}

.track-progress-step.done .track-progress-dot {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

.track-progress-step.active .track-progress-dot {
  background: #fff;
  border-color: #16a34a;
  color: #166534;
  transform: scale(1.08);
  box-shadow:
    0 0 0 4px rgba(22, 163, 74, 0.18),
    0 4px 14px rgba(22, 163, 74, 0.25);
  animation: track-dot-pulse 1.8s ease-in-out infinite;
}

@keyframes track-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.18), 0 4px 14px rgba(22, 163, 74, 0.2); }
  50% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0.1), 0 4px 18px rgba(22, 163, 74, 0.35); }
}

.track-progress-step.pending-step .track-progress-dot {
  opacity: 0.85;
}

.track-progress-label {
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--muted);
  max-width: 100%;
  padding: 0 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.track-progress-label--short {
  display: none;
}

.track-progress-step.done .track-progress-label,
.track-progress-step.active .track-progress-label {
  color: var(--text);
}

.track-progress-step.active .track-progress-label {
  color: #166534;
}

.track-progress--complete .track-progress-fill {
  background: linear-gradient(90deg, #16a34a, #15803d);
}

@media (min-width: 400px) {
  .track-progress-label {
    font-size: 0.68rem;
  }
}

/* Phones: compact layout */
@media (max-width: 420px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  .top-bar {
    gap: 8px;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

  .brand-text h1 {
    font-size: 1.05rem;
  }

  .status-pill {
    padding: 5px 10px;
    font-size: 0.68rem;
  }

  .product-grid {
    gap: 10px;
  }

  .product-body {
    padding: 8px 10px 10px;
  }

  .product-name {
    font-size: 0.86rem;
  }

  .product-price {
    font-size: 0.82rem;
  }

  .track-progress-dot {
    width: 30px;
    height: 30px;
    font-size: 0.72rem;
  }

  .track-progress-rail {
    top: 19px;
    left: 6%;
    right: 6%;
  }

  .track-progress-label--full {
    display: none;
  }

  .track-progress-label--short {
    display: block;
    font-size: 0.58rem;
  }
}

@media (max-width: 359px) {
  .product-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .product-card {
    flex-direction: row;
    align-items: stretch;
  }

  .product-image-wrap {
    width: 96px;
    min-width: 96px;
    aspect-ratio: 1;
    border-radius: 0;
  }

  .product-body {
    padding: 10px 12px;
  }

  .track-progress-label--full,
  .track-progress-label--short {
    display: none;
  }

  .track-progress {
    padding-bottom: 4px;
  }

  .cart-bar {
    left: 10px;
    right: 10px;
  }

  .sheet-step {
    padding-left: 12px;
    padding-right: 12px;
  }
}

.ghost-btn {
  width: 100%;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

/* منيو الهاتف: عمودين دائماً داخل عرض 480px */
