:root {
  --brand: #2d9fc9;
  --bg: #f3f8fb;
  --surface: #ffffff;
  --surface-2: #e9f3f8;
  --fg: #1d2a31;
  --muted: #5d6f78;
  --border: #d6e4ec;
  --accent: #17698c;
  --accent-fg: #ffffff;
  --accent-soft: #dcf0f8;
  --coffee: #6b4a2e;
  --success: #2f7d4f;
  --success-soft: #e1f1e7;
  --warning: #a86a00;
  --warning-soft: #fbefd6;
  --danger: #b3372f;
  --danger-soft: #f8e1df;
  --info: #2c5e9e;
  --info-soft: #e2ecf8;
  --shadow: 0 1px 2px rgba(23, 60, 80, 0.06), 0 4px 16px rgba(23, 60, 80, 0.07);
  --radius: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #2d9fc9;
  --bg: #0f171c;
  --surface: #172229;
  --surface-2: #1f2d35;
  --fg: #ecf3f6;
  --muted: #9fb3bd;
  --border: #2a3b45;
  --accent: #62c3e8;
  --accent-fg: #05202c;
  --accent-soft: #143444;
  --coffee: #d6a77c;
  --success: #6cc792;
  --success-soft: #1d3326;
  --warning: #e9b45a;
  --warning-soft: #3a2d14;
  --danger: #ef8a82;
  --danger-soft: #3d1f1c;
  --info: #8db5ea;
  --info-soft: #1c2a3d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #2d9fc9;
    --bg: #0f171c;
    --surface: #172229;
    --surface-2: #1f2d35;
    --fg: #ecf3f6;
    --muted: #9fb3bd;
    --border: #2a3b45;
    --accent: #62c3e8;
    --accent-fg: #05202c;
    --accent-soft: #143444;
    --coffee: #d6a77c;
    --success: #6cc792;
    --success-soft: #1d3326;
    --warning: #e9b45a;
    --warning-soft: #3a2d14;
    --danger: #ef8a82;
    --danger-soft: #3d1f1c;
    --info: #8db5ea;
    --info-soft: #1c2a3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--accent); }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.brand-bar {
  background: var(--brand);
  color: #fff;
}
.brand-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand { margin: 0; line-height: 0; flex: none; }
.brand img { height: 96px; width: auto; display: block; }
.brand-bar.compact .brand img { height: 64px; }
.tagline { margin: 0; font-weight: 700; font-size: 1.05rem; line-height: 1.5; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); }
.tagline small { display: block; font-weight: 400; font-size: 0.9rem; opacity: 0.95; }
.brand-inner .spacer { flex: 1; }
.brand-bar .btn.secondary { background: rgba(255, 255, 255, 0.95); color: #0b5f61; border-color: transparent; }

h2 { font-size: 1.2rem; margin: 28px 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stack > * + * { margin-top: 12px; }

/* Category tabs */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
.chip[aria-pressed="true"], .chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* Promo banner */
.promo {
  position: relative;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 16px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 12% 20%, rgba(255, 255, 255, 0.22) 0 18%, transparent 19%),
    radial-gradient(circle at 92% 110%, rgba(255, 255, 255, 0.16) 0 28%, transparent 29%),
    linear-gradient(135deg, #0f5f82 0%, #2d9fc9 60%, #5cc4e6 100%);
  color: #fff;
  box-shadow: 0 6px 24px rgba(15, 95, 130, 0.28);
  overflow: hidden;
}
.promo:has(img) { padding: 0; background: none; box-shadow: var(--shadow); }
.promo img { display: block; width: 100%; height: auto; }
.promo-pct {
  flex: none;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: #ffc83d;
  color: #0f3d52;
  display: grid;
  place-content: center;
  text-align: center;
  font-family: "Lalezar", "Cairo", sans-serif;
  font-size: 2.4rem;
  line-height: 1;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.35), 0 4px 12px rgba(0, 0, 0, 0.18);
  transform: rotate(-8deg);
}
.promo-pct small { font-size: 1.15rem; margin-top: 2px; }
.promo-text { display: grid; gap: 2px; }
.promo-text strong {
  font-family: "Lalezar", "Cairo", sans-serif;
  font-weight: 400;
  font-size: 2.3rem;
  line-height: 1.2;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.promo-text > span:not(.promo-tag) { font-size: 1.05rem; font-weight: 600; }
.promo-tag {
  justify-self: start;
  margin-top: 8px;
  padding: 3px 14px;
  border-radius: 999px;
  background: #fff;
  color: #0f5f82;
  font-weight: 800;
  font-size: 0.9rem;
  white-space: nowrap;
}
@media (max-width: 380px) {
  .promo-pct { width: 88px; height: 88px; font-size: 2rem; }
  .promo-text strong { font-size: 1.6rem; }
}

/* Step headings */
.step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.95rem;
  margin-inline-end: 4px;
  vertical-align: 2px;
}

/* Coffee type picker */
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.type {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 14px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.type-icon { font-size: 2rem; line-height: 1; }
.type[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.type:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Quantity / size buttons */
.sizes { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.size {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
}
.size small { font-weight: 600; font-size: 0.8rem; color: var(--muted); }
.size small .was { display: block; line-height: 1.2; }
.size small { white-space: nowrap; line-height: 1.3; }
.size[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-fg); }
.size[aria-pressed="true"] small, .size[aria-pressed="true"] .was { color: var(--accent-fg); }
.size:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.was { color: var(--muted); font-weight: 400; font-size: 0.85em; }
.totals .discount { color: var(--success); font-weight: 700; }

/* Menu items */
.items { display: grid; gap: 12px; }
.item h3 { margin: 0; font-size: 1.05rem; }
.item .desc { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.item .price { font-weight: 800; color: var(--accent); white-space: nowrap; }
.item-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented .chip { padding: 4px 12px; font-size: 0.9rem; }

.field-label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }

.item-foot { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.qty button {
  width: 36px;
  height: 36px;
  border: 0;
  background: var(--surface-2);
  color: var(--fg);
  font-size: 1.2rem;
  cursor: pointer;
}
.qty span { min-width: 32px; text-align: center; font-weight: 700; }

/* Buttons & inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: var(--accent-fg);
  min-height: 44px;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--fg); border-color: var(--border); }
.btn.success { background: var(--success); color: #fff; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.whatsapp { background: #1fa855; color: #fff; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[type="tel"] { direction: ltr; text-align: right; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :first-child { grid-column: 1 / -1; }
}

.hint { font-size: 0.85rem; color: var(--muted); margin: 4px 0 0; }

.toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle .btn[aria-pressed="false"] { background: var(--surface); color: var(--fg); border-color: var(--border); }

.notice {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}
.notice.ok { background: var(--success-soft); color: var(--success); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warning-soft); color: var(--warning); }

/* Map pin picker */
.map { height: 280px; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; z-index: 0; }
.leaflet-container { font-family: inherit; }

/* Cart */
.cart-line { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cart-line:last-child { border-bottom: 0; }
.cart-line > :last-child { flex: none; white-space: nowrap; }
.cart-line .meta { color: var(--muted); font-size: 0.85rem; }
.totals { display: grid; gap: 4px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-weight: 800; font-size: 1.15rem; }

.empty { color: var(--muted); text-align: center; padding: 12px 0; }

.cart-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  z-index: 10;
}
.cart-bar .btn { max-width: 728px; margin: 0 auto; display: flex; width: 100%; justify-content: space-between; }
.has-cart-bar { padding-bottom: 90px; }

/* Status badges & timeline */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge.pending { background: var(--warning-soft); color: var(--warning); }
.badge.confirmed { background: var(--info-soft); color: var(--info); }
.badge.out_for_delivery { background: var(--accent-soft); color: var(--accent); }
.badge.delivered { background: var(--success-soft); color: var(--success); }
.badge.cancelled { background: var(--danger-soft); color: var(--danger); }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.timeline li { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.timeline .dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  flex: none;
}
.timeline li.done { color: var(--fg); font-weight: 700; }
.timeline li.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.timeline li.current .dot { border-color: var(--accent); color: var(--accent); }

/* Admin */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.order-card .row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.order-card h3 { margin: 0; font-size: 1.1rem; }
.order-card .muted { color: var(--muted); font-size: 0.9rem; }
.order-card ul { margin: 6px 0; padding-inline-start: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 0.95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.ltr { direction: ltr; unicode-bidi: embed; }

.footer { color: var(--muted); font-size: 0.85rem; text-align: center; padding: 24px 0; }

.hidden { display: none !important; }
