:root {
  --bg: #f3f6f4;
  --ink: #14201b;
  --accent: #0f766e;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, white);
  --surface: #ffffff;
  --muted: #5b6b64;
  --line: #d7e0db;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(20, 32, 27, 0.08);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at 100% 0%, var(--accent-soft), transparent 42%),
    linear-gradient(180deg, #eef5f1 0%, var(--bg) 38%, #e8efeb 100%);
  color: var(--ink);
  min-height: 100vh;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, white);
  background: color-mix(in srgb, white 86%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 14px;
  flex-shrink: 0;
  background: white;
  border: 1px solid var(--line);
}

.brand-text {
  min-width: 0;
}

.brand-text strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.status-line {
  margin: 0.15rem 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.status-line.is-open {
  color: color-mix(in srgb, var(--accent) 75%, black);
  font-weight: 600;
}

.status-line.is-closed {
  color: var(--danger);
  font-weight: 600;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1.1rem calc(6.5rem + var(--safe-bottom));
}

.ghost {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.3rem;
  border-radius: 999px;
  background: color-mix(in srgb, white 70%, var(--accent-soft));
  border: 1px solid var(--line);
  margin-bottom: 0.9rem;
}

.segment button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 0.65rem 0.8rem;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.segment button.active {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
}

.chip strong { color: var(--ink); font-weight: 600; }

.branch-select {
  width: 100%;
  margin-bottom: 0.85rem;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: white;
  font: inherit;
}

.cats {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.15rem 0 0.85rem;
  margin: 0 -0.15rem 0.35rem;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.cats::-webkit-scrollbar { display: none; }

.cat {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  scroll-snap-align: start;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.cat.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.menu {
  display: grid;
  gap: 0.7rem;
}

.item {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  animation: rise 280ms ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.thumb {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 14px;
  background: #edf2ef;
}

.thumb.placeholder {
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--muted) 55%, white);
  font-size: 1.4rem;
  font-weight: 700;
  background:
    linear-gradient(145deg, #f4f7f5, #e4ebe7);
}

.item-body { min-width: 0; }
.item-body strong {
  display: block;
  font-size: 1rem;
  line-height: 1.3;
}
.item-body .desc {
  margin: 0.25rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-body .price {
  font-weight: 700;
  color: color-mix(in srgb, var(--accent) 70%, black);
}

.qty {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.2rem;
}

.qty button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(20, 32, 27, 0.06);
}

.qty button.add-only {
  width: auto;
  min-width: 72px;
  padding: 0 0.85rem;
  background: var(--accent);
  color: white;
  box-shadow: none;
}

.qty span {
  min-width: 1.4rem;
  text-align: center;
  font-weight: 700;
}

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--bg) 88%, black) 28%);
  pointer-events: none;
}

.dock-inner {
  pointer-events: auto;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 18px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  animation: slide-up 240ms ease both;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.dock-inner .count {
  display: inline-grid;
  place-items: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.dock-inner .summary {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.dock-inner .summary span:first-child {
  font-size: 0.8rem;
  opacity: 0.75;
}

.dock-inner .summary strong {
  font-size: 1.05rem;
}

.dock-inner .go {
  border: 0;
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 0.7rem 1rem;
  cursor: pointer;
  white-space: nowrap;
}

.checkout {
  display: grid;
  gap: 0.9rem;
}

.back {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
  width: fit-content;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

.panel h2, .panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.cart-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.cart-lines li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.cart-lines .line-name {
  min-width: 0;
  font-weight: 600;
}

.cart-lines .line-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.total-row {
  display: flex;
  justify-content: space-between;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--line);
  font-size: 1.05rem;
  font-weight: 700;
}

label {
  display: block;
  margin: 0.65rem 0;
  font-size: 0.92rem;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  font: inherit;
  font-weight: 500;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, white);
  border-color: var(--accent);
  background: white;
}

.hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

.btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 700;
  padding: 0.95rem 1rem;
  cursor: pointer;
  margin-top: 0.35rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.error {
  color: var(--danger);
  min-height: 1.2rem;
  margin: 0.35rem 0;
  font-weight: 600;
}

.map {
  height: 240px;
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  margin-top: 0.5rem;
  z-index: 1;
}

.success {
  text-align: center;
  padding: 1.5rem 1rem;
}

.success h2 {
  margin: 0 0 0.5rem;
  font-size: 1.45rem;
}

.confirm-code {
  font-size: 2.8rem;
  letter-spacing: 0.18em;
  font-weight: 800;
  margin: 1.1rem 0;
  color: var(--accent);
}

.muted { color: var(--muted); font-weight: 500; }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

@media (max-width: 420px) {
  .item {
    grid-template-columns: 64px 1fr;
    grid-template-areas:
      "thumb body"
      "thumb qty";
  }
  .thumb { grid-area: thumb; width: 64px; height: 64px; }
  .item-body { grid-area: body; }
  .qty { grid-area: qty; justify-self: start; }
}
