/* ═══════════════════════════════════════════════════════════════
   Beta Food IQ — design system (shared by the store and the dashboard)
   Palette: forest green · warm cream · terracotta. Fonts: Manrope (Latin & digits),
   Noto Kufi Arabic (headings), Noto Sans Arabic (body) — both cover Kurdish ڕ ڵ ێ ۆ ە.
   ═══════════════════════════════════════════════════════════════ */
:root {
  --font: "Manrope", "Noto Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Manrope", "Noto Kufi Arabic", "Noto Sans Arabic", system-ui, sans-serif;

  --brand: #1F7A4D;
  --brand-strong: #17603C;
  --brand-strong: color-mix(in srgb, var(--brand) 80%, #000);
  --brand-soft: #E6F2EA;
  --brand-soft: color-mix(in srgb, var(--brand) 11%, #fff);
  --brand-line: #BFDCCB;
  --brand-line: color-mix(in srgb, var(--brand) 30%, #fff);
  --on-brand: #fff;
  --accent: #D9573B;
  --accent-soft: #FBE9E3;
  --gold: #E8A317;

  --bg: #FAF7F1;
  --surface: #FFFFFF;
  --surface-2: #F5F1E9;
  --surface-3: #ECE6DA;
  --line: #E8E2D6;
  --line-2: #D9D1C2;
  --text: #16201B;
  --text-2: #4C5751;
  --text-3: #87908A;

  --ok: #1B9653;   --ok-soft: #E3F4EA;
  --warn: #C9800F; --warn-soft: #FBF0DA;
  --err: #CF3B36;  --err-soft: #FBE7E5;
  --info: #2C6ACF; --info-soft: #E6EEFA;

  --r-xs: 8px; --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(22, 32, 27, .06), 0 1px 1px rgba(22, 32, 27, .03);
  --sh-2: 0 10px 24px -12px rgba(22, 32, 27, .22), 0 2px 6px rgba(22, 32, 27, .05);
  --sh-3: 0 30px 70px -24px rgba(12, 48, 30, .45);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t: .2s var(--ease);
  color-scheme: light;
}
[data-theme="dark"] {
  --brand-soft: #173326;
  --brand-soft: color-mix(in srgb, var(--brand) 22%, #101512);
  --brand-line: #285C42;
  --brand-line: color-mix(in srgb, var(--brand) 45%, #101512);
  --accent-soft: #3A211B;
  --bg: #0E1311;
  --surface: #151C18;
  --surface-2: #1B231F;
  --surface-3: #232D28;
  --line: #26302B;
  --line-2: #33403A;
  --text: #EEF3EF;
  --text-2: #B3BEB7;
  --text-3: #7D8983;
  --ok-soft: #12301F; --warn-soft: #33270F; --err-soft: #3A1715; --info-soft: #142440;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 12px 28px -12px rgba(0, 0, 0, .6);
  --sh-3: 0 30px 70px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ── reset ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
html.layer-open, html.layer-open body { overflow: hidden; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.35; margin: 0; font-weight: 800; }
p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--brand); color: var(--on-brand); }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
bdi, .ltr { unicode-bidi: isolate; }
[dir="ltr"], .ltr { direction: ltr; }
html[lang="en"] .caps, html[lang="tr"] .caps { letter-spacing: .06em; text-transform: uppercase; }

.ic { width: 20px; height: 20px; flex: 0 0 auto; display: inline-block; vertical-align: -.28em; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }
html[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ── buttons ── */
.btn {
  --h: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 18px; border-radius: var(--r-sm);
  font-weight: 700; font-size: 14.5px; white-space: nowrap; user-select: none;
  border: 1px solid transparent; transition: background var(--t), border-color var(--t), color var(--t), transform .12s, box-shadow var(--t);
}
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: 0 6px 16px -8px rgba(31, 122, 77, .7); box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--brand) 75%, transparent); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-soft { background: var(--brand-soft); color: var(--brand-strong); }
[data-theme="dark"] .btn-soft { color: #9FE0BC; }
.btn-soft:hover { border-color: var(--brand-line); }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-3); }
.btn-plain { background: transparent; color: var(--text-2); }
.btn-plain:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger-soft { background: var(--err-soft); color: var(--err); }
.btn-wa { background: #1FAF54; color: #fff; }
.btn-wa:hover { background: #179446; }
.btn-dark { background: var(--text); color: var(--bg); }
.btn-sm { --h: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 9px; }
.btn-xs { --h: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-lg { --h: 52px; padding: 0 22px; font-size: 16px; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }
.btn .spin { display: none; }
.btn.is-busy .spin { display: inline-block; }

.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── form ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.55; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 13px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text);
  transition: border-color var(--t), box-shadow var(--t); font-size: 15px;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3.5px var(--brand-soft); }
.input.bad { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.select { appearance: none; -webkit-appearance: none; padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2387908A' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 18px; background-position: left 12px center; }
html[dir="ltr"] .select { background-position: right 12px center; }
.input-num { direction: ltr; text-align: start; }
html[dir="rtl"] .input-num { text-align: right; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* switch */
.switch { position: relative; display: inline-flex; width: 46px; height: 27px; flex: 0 0 auto; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-2); transition: background var(--t); }
.switch span::after { content: ""; position: absolute; top: 2.5px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--t); }
.switch input:checked + span { background: var(--brand); border-color: var(--brand); }
.switch input:checked + span::after { transform: translateX(19px); }
html[dir="rtl"] .switch input:checked + span::after { transform: translateX(-19px); }
.switch input:focus-visible + span { outline: 2.5px solid var(--brand); outline-offset: 2px; }

.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.seg button { height: 34px; padding: 0 14px; border-radius: 9px; font-weight: 700; font-size: 13.5px; color: var(--text-2); transition: background var(--t), color var(--t); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* ── chips & badges ── */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 13.5px; color: var(--text-2); white-space: nowrap; transition: all var(--t); }
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 800; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--err-soft); color: var(--err); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand-strong); }
[data-theme="dark"] .badge-brand { color: #9FE0BC; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(27,150,83,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(27,150,83,.5); } 70% { box-shadow: 0 0 0 9px rgba(27,150,83,0); } 100% { box-shadow: 0 0 0 0 rgba(27,150,83,0); } }

/* ── cards ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--sh-1); }
.card-title { font-family: var(--font-head); font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.empty { text-align: center; padding: 42px 18px; color: var(--text-3); }
.empty .ic { width: 42px; height: 42px; margin: 0 auto 10px; opacity: .55; }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

/* ── layers: modal (center) and sheet (bottom on phones, side/center on desktop) ── */
.layer {
  position: fixed; inset: 0; z-index: 1000; display: flex;
  background: rgba(10, 20, 15, .48); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .24s var(--ease);
}
.layer.open { opacity: 1; }
.layer-center { align-items: center; justify-content: center; padding: 18px; }
.layer-bottom { align-items: flex-end; justify-content: center; }
.dialog { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--sh-3); transform: translateY(12px) scale(.98); transition: transform .26s var(--ease); }
.layer.open .dialog { transform: none; }
.dialog-title { font-family: var(--font-head); font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.dialog-text { color: var(--text-2); font-size: 14px; margin-bottom: 18px; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }

.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--sh-3);
  border-radius: var(--r-xl) var(--r-xl) 0 0; transform: translateY(30px); transition: transform .3s var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.layer.open .sheet { transform: none; }
.sheet-grab { width: 42px; height: 5px; border-radius: 9px; background: var(--line-2); margin: 9px auto 0; flex: 0 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px 12px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.sheet-title { font-family: var(--font-head); font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 8px; min-width: 0; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 18px; }
@media (pointer: coarse) { .sheet-body { scrollbar-width: none; } .sheet-body::-webkit-scrollbar { display: none; } }
.sheet-foot { flex: 0 0 auto; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface); }
.x-btn { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); flex: 0 0 auto; transition: background var(--t); }
.x-btn:hover { background: var(--surface-3); color: var(--text); }
@media (min-width: 769px) {
  .layer-bottom { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--r-xl); max-height: 88vh; transform: translateY(16px) scale(.985); }
  .sheet-grab { display: none; }
  .layer-side { justify-content: flex-end; align-items: stretch; padding: 0; }
  .layer-side .sheet { max-width: 440px; max-height: none; height: 100%; border-radius: 0; transform: translateX(-30px); }
  html[dir="ltr"] .layer-side .sheet { transform: translateX(30px); }
  html[dir="rtl"] .layer-side { justify-content: flex-start; }
  .layer.open.layer-side .sheet { transform: none; }
}

/* ── toasts ── */
.toasts { position: fixed; z-index: 3000; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
html.layer-open .toasts { bottom: auto; top: calc(14px + env(safe-area-inset-top)); }
.toast { padding: 11px 18px; border-radius: 12px; background: #16201B; color: #fff; font-weight: 700; font-size: 14px; box-shadow: var(--sh-2); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s var(--ease); text-align: center; }
.toast.in { opacity: 1; transform: none; }
.toast-ok { background: #16603C; }
.toast-err { background: #B3302C; }
.toast-warn { background: #8A5A08; }

/* ── skeleton ── */
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 10px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* image that failed to load */
img.img-dead { opacity: 0; }

/* misc */
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.num { font-family: "Manrope", var(--font); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hstack { display: flex; align-items: center; gap: 10px; }
.wrap-gap { display: flex; flex-wrap: wrap; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
