/* ══ ركن — الأساس المشترك (فاتح/داكن · عربي/إنجليزي) ══ */
:root {
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --brand: #0F766E; --brand-ink: #fff; --brand-wash: rgba(15, 118, 110, .1); --accent: #F59E0B;
  --bg: #F6F7F9; --paper: #FFFFFF; --paper-2: #F9FAFB; --sunk: #EEF0F3;
  --ink: #15181D; --ink-2: #4A515C; --ink-3: #8A919C;
  --line: #E4E7EC; --line-2: #EEF0F3;
  --ok: #15803D; --ok-wash: #DCFCE7; --warn: #B45309; --warn-wash: #FEF3C7; --bad: #B91C1C; --bad-wash: #FEE2E2; --info: #1D4ED8; --info-wash: #DBEAFE;
  --st-New: #2563EB; --st-Confirmed: #6D28D9; --st-Preparing: #C2410C; --st-Ready: #0E7490; --st-Delivered: #15803D; --st-Cancelled: #6B7280;
  --r: 12px; --r-sm: 9px; --r-lg: 18px;
  --sh-1: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-2: 0 6px 20px -6px rgba(16, 24, 40, .16), 0 2px 6px -2px rgba(16, 24, 40, .06);
  --sh-3: 0 24px 60px -16px rgba(16, 24, 40, .32);
  --focus: 0 0 0 3px var(--brand-wash);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0D0F12; --paper: #15181D; --paper-2: #1A1E24; --sunk: #20252C;
  --ink: #EDEFF2; --ink-2: #B3BAC4; --ink-3: #7C8491;
  --line: #2A3038; --line-2: #222830;
  --ok: #4ADE80; --ok-wash: rgba(74, 222, 128, .12); --warn: #FBBF24; --warn-wash: rgba(251, 191, 36, .12);
  --bad: #F87171; --bad-wash: rgba(248, 113, 113, .12); --info: #60A5FA; --info-wash: rgba(96, 165, 250, .12);
  --st-New: #60A5FA; --st-Confirmed: #A78BFA; --st-Preparing: #FB923C; --st-Ready: #22D3EE; --st-Delivered: #4ADE80; --st-Cancelled: #9CA3AF;
  --sh-1: none; --sh-2: 0 8px 24px -8px rgba(0, 0, 0, .6); --sh-3: 0 24px 60px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; }
p { margin: 0; }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ic { display: inline-flex; flex: none; }
.ic svg { width: var(--s, 18px); height: var(--s, 18px); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── أزرار ── */
.btn { --bg: var(--paper); --fg: var(--ink); --bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 13px;
  border-radius: var(--r-sm); border: 1px solid var(--bd); background: var(--bg); color: var(--fg);
  font-weight: 600; font-size: 13px; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; user-select: none; }
.btn:hover { background: color-mix(in srgb, var(--bg) 92%, var(--ink)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 0; box-shadow: var(--focus); border-color: var(--brand); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { --bg: var(--brand); --fg: var(--brand-ink); --bd: var(--brand); }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn.danger { --bg: var(--bad); --fg: #fff; --bd: var(--bad); }
.btn.ghost { --bg: transparent; --bd: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.soft { --bg: var(--brand-wash); --fg: var(--brand); --bd: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn.lg { height: 48px; padding: 0 20px; font-size: 15px; border-radius: var(--r); }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.block { width: 100%; }
.btn .spin { width: 16px; height: 16px; }

/* ── حقول ── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input, .select, .textarea { width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); outline: 0; transition: border-color .15s, box-shadow .15s; min-width: 0; }
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input.sm, .select.sm { height: 32px; font-size: 13px; padding: 0 10px; }
.select { appearance: none; padding-inline-end: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A919C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center; }
[dir="ltr"] .select { background-position: right 10px center; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .ic { position: absolute; inset-inline-start: 11px; color: var(--ink-3); pointer-events: none; }
.input-group > .input { padding-inline-start: 36px; }
.input-group > .clear { position: absolute; inset-inline-end: 6px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--ink-3); display: grid; place-items: center; }
.input-group > .clear:hover { background: var(--sunk); color: var(--ink); }
.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: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* مفتاح تشغيل */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--line); transition: background .18s; position: relative; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.check { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; flex: none; }

/* ── شرائح وتبويبات ── */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink-2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--ink-3)); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip b { font-weight: 700; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 9px 10px; border: 0; background: none; color: var(--ink-2); font-weight: 600; font-size: 13px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); }
.tab.on::after { content: ''; position: absolute; inset-inline: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--c, var(--brand)); }
.tab .n { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--sunk); color: var(--ink-2); font-size: 11.5px; display: inline-grid; place-items: center; }
.tab.on .n { background: color-mix(in srgb, var(--c, var(--brand)) 14%, transparent); color: var(--c, var(--brand)); }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--sunk); gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; white-space: nowrap; border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 480px) { .seg button { padding: 0 9px; font-size: 12.5px; gap: 4px; } }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: var(--sh-1); }

/* ── بطاقات ── */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.card-h h3 { font-size: 15px; }
.card-b { padding: 14px; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--ink-3)) 13%, transparent); color: var(--c, var(--ink-2)); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--r); background: var(--info-wash); color: var(--ink); font-size: 13px; }
.notice.warn { background: var(--warn-wash); }
.notice.bad { background: var(--bad-wash); }
.notice.ok { background: var(--ok-wash); }
.notice > .ic { margin-top: 1px; }
.empty { display: grid; place-items: center; gap: 8px; text-align: center; padding: 48px 16px; color: var(--ink-3); }
.empty .ic { --s: 34px; opacity: .6; }
.empty h4 { color: var(--ink-2); font-size: 15px; }
hr.sep { border: 0; border-top: 1px solid var(--line-2); margin: 14px 0; }

/* ── مؤشر تحميل ── */
.spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, currentColor 22%, transparent); border-top-color: currentColor; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; padding: 40px; color: var(--ink-3); }
.skel { background: linear-gradient(90deg, var(--sunk) 25%, var(--line-2) 37%, var(--sunk) 63%); background-size: 400% 100%; animation: skel 1.3s ease infinite; border-radius: 8px; }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── نوافذ ── */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(10, 12, 16, .46); display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .16s ease; backdrop-filter: blur(2px); }
.modal { width: min(560px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column; background: var(--paper); border-radius: 20px; box-shadow: var(--sh-3);
  animation: pop .2s cubic-bezier(.2, .9, .3, 1.2); overflow: hidden; }
.modal.lg { width: min(820px, 100%); }
.modal.sm { width: min(420px, 100%); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.modal-h h3 { font-size: 15.5px; flex: 1; }
.modal-b { padding: 4px 16px 14px; overflow: auto; overscroll-behavior: contain; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--line-2); background: var(--paper-2); }
@media (max-width: 640px) {
  .overlay.as-sheet { align-items: flex-end; padding: 0; }
  .overlay.as-sheet .modal { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; animation: up .24s cubic-bezier(.2, .9, .3, 1); }
  .overlay.as-sheet .modal::before { content: ''; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 0; flex: none; }
  .overlay.as-sheet .modal-f { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
@keyframes up { from { transform: translateY(100%); } }

/* ── تنبيهات ── */
.toasts { position: fixed; z-index: 100; inset-inline: 0; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 9px; max-width: min(460px, calc(100vw - 24px)); padding: 11px 16px; border-radius: 14px;
  background: #111418; color: #fff; box-shadow: var(--sh-3); font-size: 13.5px; font-weight: 500; animation: pop .2s ease; }
html[data-theme="dark"] .toast { background: #F1F3F5; color: #111418; }
.toast.ok .ic { color: #4ADE80; } .toast.bad .ic { color: #F87171; }
html[data-theme="dark"] .toast.ok .ic { color: var(--ok); } html[data-theme="dark"] .toast.bad .ic { color: #DC2626; }

/* قائمة منسدلة */
.menu { position: fixed; z-index: 90; min-width: 190px; padding: 6px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--sh-2); animation: pop .14s ease; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 9px; padding: 9px 10px; border: 0; border-radius: 9px; background: none; color: var(--ink); font-size: 13.5px; text-align: start; }
.menu button:hover, .menu a:hover { background: var(--sunk); }
.menu .danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 5px 2px; }

/* توقيع Ozone */
.ozone-sign { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-3); }
.ozone-sign a { color: var(--ink-2); font-weight: 700; letter-spacing: .02em; }
.ozone-sign a:hover { color: var(--brand); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink-3) 35%, transparent); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
