/* ============================================================
   مشروبات ٢٤ — نظام التصميم المشترك للوحتين (الإدارة + الفرنشايز)
   الهيكل منقول من لوحات وينه (قرار G-D1)، والألوان والخط من الفيجما:
   docs/design-tokens.md — ممنوع أي لون برّه بلوكات :root تحت.
   ============================================================ */

/* ---------- الـ tokens (نفس أسماء docs/design-tokens.md §1) ---------- */
:root {
    --color-primary: #6A805B;
    --color-primary-dark: #3A5643;
    --color-primary-light: #E2F3D7;
    --color-bg: #FAF9F7;
    --color-surface: #FFFFFF;
    --color-surface-muted: #F1F1EA;
    --color-surface-alt: #EEEEEE;
    --color-border: #EAEAEA;
    --color-text: #1B1C1A;
    --color-text-strong: #1C1C1C;
    --color-text-2: #474747;
    --color-text-3: #666666;
    --color-text-muted: #929292;
    --color-error: #EC2D30;
    /* مش في الفيجما (design-tokens §5 T-5) — للوحتين بس */
    --color-on-primary: #FFFFFF;
    --color-warning: #B54708;
    --color-warning-soft: #FFF4E5;
    --color-error-soft: #FDECEC;
    --color-error-line: #F6C3C4;
    --color-primary-line: #CFE3C1;
    --color-primary-tint: rgba(106, 128, 91, .14);
    --color-shadow: rgba(27, 28, 26, .5);
    --color-scrim: rgba(27, 28, 26, .45);
    --side-bg: #3A5643;
    --side-ink: rgba(255, 255, 255, .72);
    --side-ink-strong: #FFFFFF;
    --side-group: rgba(255, 255, 255, .5);
    --side-hover: rgba(255, 255, 255, .08);
    --side-active: rgba(255, 255, 255, .16);
    --side-line: rgba(255, 255, 255, .1);
    --preview-bar: rgba(255, 255, 255, .55);
    --device-frame: #1B1C1A;
    --toggle-bg: #F1F1EA;
    --toggle-line: #EAEAEA;
    --star: #F59E0B;
    --shadow-sm: 0 0 30px rgba(0, 0, 0, .04);
    --shadow-md: 0 1px 12px rgba(0, 0, 0, .08);

    /* أسماء المكوّنات (من وينه) ⇒ متربوطة بالـ tokens */
    --brand: var(--color-primary);
    --brand-dim: var(--color-primary-tint);
    --green-700: var(--color-primary-dark);
    --green-600: var(--color-primary);
    --green-soft: var(--color-primary-light);
    --ink: var(--color-text);
    --body: var(--color-text-2);
    --muted: var(--color-text-3);
    --bg: var(--color-bg);
    --card: var(--color-surface);
    --line: var(--color-border);
    --line-2: var(--color-surface-alt);
    --danger: var(--color-error);
    --danger-soft: var(--color-error-soft);
    --warn: var(--color-warning);
    --warn-soft: var(--color-warning-soft);
    --side: var(--side-bg);
    --surface-2: var(--color-surface-muted);
    --row-hover: var(--color-bg);
    --row-new: var(--color-primary-light);
    --input-bg: var(--color-surface);
    --input-line: var(--color-border);
    --label: var(--color-text-2);
    --btn-bg: var(--color-primary);
    --btn-ink: var(--color-on-primary);
    --green-line: var(--color-primary-line);
    --flash-ink: var(--color-primary-dark);
    --danger-line: var(--color-error-line);
    --disabled-ink: var(--color-text-muted);
    --pill-bg: var(--color-surface-alt);
    --chart-grid: var(--color-surface-alt);
    --control-h: 42px;
    --radius: 14px;
    --font: "IBM Plex Sans Arabic", "Segoe UI", system-ui, -apple-system, sans-serif;
    color-scheme: light;
}

/* ---------- الوضع الداكن (design-tokens §2 — اقتراح، الفيجما مفيهوش Dark) ---------- */
:root[data-theme="dark"] {
    --color-primary: #8FA77E;
    --color-primary-dark: #6A805B;
    --color-primary-light: #2A3A24;
    --color-bg: #121411;
    --color-surface: #1C1F1A;
    --color-surface-muted: #23271F;
    --color-surface-alt: #2A2E26;
    --color-border: #30352C;
    --color-text: #EDEDE8;
    --color-text-strong: #FFFFFF;
    --color-text-2: #C4C6BF;
    --color-text-3: #A3A59E;
    --color-text-muted: #80837C;
    --color-error: #FF5A5C;
    --color-on-primary: #121411;
    --color-warning: #F5A524;
    --color-warning-soft: rgba(245, 165, 36, .14);
    --color-error-soft: rgba(255, 90, 92, .12);
    --color-error-line: rgba(255, 90, 92, .35);
    --color-primary-line: rgba(143, 167, 126, .35);
    --color-primary-tint: rgba(143, 167, 126, .16);
    --color-shadow: rgba(0, 0, 0, .6);
    --color-scrim: rgba(0, 0, 0, .55);
    --side-bg: #0E110D;
    --side-line: #23271F;
    --toggle-bg: rgba(255, 255, 255, .06);
    --toggle-line: rgba(255, 255, 255, .14);
    --input-bg: #171A15;
    --input-line: #30352C;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
}


* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; }

/* ---------- الهيكل ---------- */
.shell { display: flex; min-height: 100vh; }

.side {
    width: 248px;
    background:
        var(--side);
    color: var(--side-ink-strong);
    padding: 22px 14px 28px;
    border-inline-end: 1px solid var(--side-line);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--side-line) transparent;
}

.side .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 10px 20px;
    border-bottom: 1px solid var(--side-line);
    margin-bottom: 14px;
}
.side .brand img { height: 34px; width: auto; }
.side .brand .word { color: var(--side-ink-strong); font-weight: 800; font-size: 19px; line-height: 1; }
.side .brand small { display: block; color: var(--side-ink); font-size: 11px; margin-top: 4px; font-weight: 500; }

.side .group { color: var(--side-group); font-size: 10.5px; font-weight: 700; letter-spacing: .6px; padding: 16px 12px 8px; }

.side a.item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin: 2px 0;
    border-radius: 10px;
    color: var(--side-ink);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.side a.item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.side a.item:hover { background: var(--side-hover); color: var(--side-ink-strong); }
.side a.item.on {
    background: var(--side-active);
    color: var(--side-ink-strong);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--side-ink-strong);
}
[dir="ltr"] .side a.item.on {
    background: var(--side-active);
    box-shadow: inset -3px 0 0 var(--side-ink-strong);
}
.side a.item.on svg { opacity: 1; }
.side a.item .badge {
    background: var(--brand);
    color: var(--btn-ink);
    border-radius: 99px;
    font-size: 10.5px;
    font-weight: 800;
    padding: 1px 7px;
    margin-inline-start: auto;
}

.main { flex: 1; min-width: 0; padding: 22px 28px 40px; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.topbar h2 { font-size: 19px; font-weight: 800; letter-spacing: -.2px; }
.topbar .crumb { color: var(--muted); font-size: 12px; margin-top: 3px; }
.topbar .user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar .user .avatar, .avatar-lg {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--green-soft);
    color: var(--green-700);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 13px;
    border: 1px solid var(--green-line);
}
.avatar-lg { width: 56px; height: 56px; font-size: 22px; flex: none; }
.avatar-photo { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; }
.topbar .user .who { text-align: start; line-height: 1.3; }
.topbar .user .who b { font-size: 13px; }
.topbar .user .who span { display: block; color: var(--muted); font-size: 11px; }

/* الاسم وزر الخروج فوق، وزر اللغة تحتهم في النص */
.topbar-end { display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* زر اللغة وزر الثيم جنب بعض */
.prefs { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--toggle-line);
    background: var(--toggle-bg);
    color: var(--body);
    cursor: pointer;
    flex: none;
    transition: background .15s ease, color .15s ease, transform .25s cubic-bezier(.16, 1, .3, 1);
}
.theme-toggle:hover { color: var(--ink); }
.theme-toggle:active { transform: rotate(-25deg) scale(.92); }
.theme-toggle:focus-visible { outline: 2px solid var(--green-600); outline-offset: 2px; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle { color: var(--brand); }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* توجل اللغة (عربي/English) */
.lang-toggle { position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; align-items: center; padding: 3px; border-radius: 99px; background: var(--toggle-bg); border: 1px solid var(--toggle-line); font-family: var(--font); flex: none; }
.lang-toggle::before { content: ""; position: absolute; top: 3px; bottom: 3px; inset-inline-start: 3px; width: calc(50% - 3px); border-radius: 99px; background: var(--brand); transition: transform .25s cubic-bezier(.16, 1, .3, 1); }
.lang-toggle.is-en::before { transform: translateX(100%); }
[dir="rtl"] .lang-toggle.is-en::before { transform: translateX(-100%); }
.lang-toggle a { position: relative; z-index: 1; min-width: 62px; padding: 5px 12px; text-align: center; border-radius: 99px; font-size: 12.5px; font-weight: 700; line-height: 1.5; color: var(--body); text-decoration: none; transition: color .2s; white-space: nowrap; }
.lang-toggle a:hover { color: var(--ink); }
.lang-toggle a.on { color: var(--btn-ink); pointer-events: none; }
.lang-toggle.sm a { min-width: 54px; padding: 3px 10px; font-size: 11.5px; }

/* ---------- الكروت ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.card > h3:first-child,
.card > h4:first-child { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.card > h3:first-child::before,
.card > h4:first-child::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-dim);
}

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--card); }
/* th مش لازم يكون جوه thead — أغلب الجداول بتحط صف العناوين على طول في table */
th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .3px;
    padding: 11px 12px;
    text-align: start;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--line-2);
    font-size: 13.5px;
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s ease; }
tr:has(td):hover { background: var(--row-hover); }

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--btn-bg);
    color: var(--btn-ink);
    border: 1px solid var(--btn-bg);
    border-radius: 10px;
    padding: 9px 18px;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    font-family: inherit;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
    width: fit-content;
    max-width: 100%;
    height: var(--control-h);
    padding-block: 0;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -8px var(--color-shadow); }
.btn.out { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.out:hover { background: var(--row-hover); box-shadow: var(--shadow-sm); }
.btn.danger { background: var(--card); color: var(--danger); border: 1px solid var(--danger-line); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }

/* أزرار الإجراءات داخل صفوف الجداول — على صف واحد دايمًا وبنفس الطول (تعديل/تعطيل/حذف) */
.row-actions { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.row-actions form { margin: 0; display: inline-flex; align-items: center; flex: 0 0 auto; }
.row-actions > details.inline-edit { display: inline-flex; flex: 0 0 auto; }
.row-actions .btn.sm { margin: 0; height: 34px; padding: 0 10px; font-size: 12px; white-space: nowrap; }
/* «تعديل» summary بيبقى نسخة طبق الأصل من الزرار: نفس الطول والمحاذاة وبدون مثلث الـ details */
.row-actions > details.inline-edit > summary.btn {
    display: inline-flex; align-items: center; justify-content: center;
    line-height: 1; padding-block: 0; list-style: none;
}
.row-actions > details.inline-edit > summary.btn::-webkit-details-marker { display: none; }

/* ---------- النماذج ---------- */
/* صف فيلدات ثنائي (عربي + إنجليزي) */
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
@media (max-width: 560px) { .form-row { grid-template-columns:1fr; } }
/* زر الحفظ ميلاصقش آخر فيلد */
.card form button.btn { margin-top: 18px; }
/* فورم البحث/التصفية: الفيلدات وزرار البحث في صف واحد، ومسافة 12 بينهم */
.search-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-bar input { flex: 1 1 220px; width: auto; min-width: 0; }
.search-bar select { flex: 0 0 160px; width: 160px; }
.search-bar button.btn,
.card .search-bar button.btn,
.row-actions button.btn,
.card td form button.btn { margin-top: 0; }
label { display: block; margin: 12px 0 6px; font-size: 12.5px; font-weight: 700; color: var(--label); }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--input-line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: var(--input-bg);
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px var(--color-primary-tint);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select {
    height: var(--control-h);
    padding-block: 0;
}
textarea { line-height: 1.8; resize: vertical; }

/* فيلد الجوال: كود الدولة جوه نفس الإطار */
.phone-field {
    display: flex;
    align-items: stretch;
    direction: ltr;
    height: var(--control-h);
    border: 1px solid var(--input-line);
    border-radius: 10px;
    background: var(--input-bg);
    overflow: hidden;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.phone-field:focus-within { border-color: var(--green-600); box-shadow: 0 0 0 3px var(--color-primary-tint); }
.phone-field .prefix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--surface-2);
    border-right: 1px solid var(--input-line);
    color: var(--body);
    font-weight: 600;
    font-size: 13.5px;
    flex-shrink: 0;
}
.phone-field input { flex: 1; min-width: 0; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
.phone-field input:focus { box-shadow: none; }
input[type="checkbox"] { accent-color: var(--green-600); }
input[type="file"] { padding: 8px; background: var(--surface-2); }

/* ---------- الرسائل ---------- */
.flash, .errors {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13.5px;
    font-weight: 600;
}
.flash { background: var(--green-soft); border: 1px solid var(--green-line); color: var(--flash-ink); }
.flash::before { content: "✓"; width: 20px; height: 20px; flex: none; background: var(--green-600); color: var(--color-on-primary); border-radius: 50%; display: grid; place-items: center; font-size: 12px; }
.errors { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger); }
.errors::before { content: "!"; width: 20px; height: 20px; flex: none; background: var(--danger); color: var(--color-on-primary); border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; }

/* ---------- الإحصائيات ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.stat { position: relative; overflow: hidden; }
.stat .n { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin-top: 6px; }
.stat .icon {
    position: absolute;
    top: 18px;
    inset-inline-end: 18px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--green-soft);
    color: var(--green-700);
    display: grid;
    place-items: center;
    font-size: 18px;
}

/* ---------- شرائح الحالة ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 99px;
    padding: 3px 10px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--pill-bg);
    color: var(--body);
}
.pill.ok { background: var(--green-soft); color: var(--green-700); }
.pill.ok::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green-600); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.warn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.bad::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }

/* ---------- الطلبات (سبرنت 6) ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-2 > .card { margin: 0; }
tr.row-active > td:first-child { box-shadow: inset -3px 0 0 var(--warn); }
[dir="ltr"] tr.row-active > td:first-child, html[dir="ltr"] tr.row-active > td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

/* ---------- التنقل بين الصفحات (Laravel pagination) ---------- */
.pagination { display: flex; gap: 6px; list-style: none; padding: 0; margin: 16px 0 0; flex-wrap: wrap; }
.pagination li { display: inline-block; }
.pagination a, .pagination span {
    display: inline-block;
    min-width: 34px;
    padding: 7px 10px;
    text-align: center;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--card);
    font-size: 13px;
    font-weight: 600;
    color: var(--body);
    transition: all .12s ease;
}
.pagination a:hover { border-color: var(--green-600); color: var(--green-700); }
.pagination .active span, .pagination .active a {
    background: var(--btn-bg);
    color: var(--btn-ink);
    border-color: var(--btn-bg);
}
.pagination .disabled span { color: var(--disabled-ink); background: var(--surface-2); }
/* الأسهم ‹ › من غير transform: الحرفين Bidi_Mirrored فالمتصفح بيقلبهم لوحده في RTL
   («السابق» على اليمين وبيشاور يمين). القلب بالـ CSS كان بيعكسهم تاني. */
.bulk-actions { display: flex; align-items: center; gap: 8px; }
.bulk-actions .btn[disabled] { opacity: .45; cursor: not-allowed; }
.check-col { width: 36px; }
.pager-summary { margin: 8px 0 0; }

/* ---------- متنوعات ---------- */
.muted { color: var(--muted); font-size: 12.5px; }
.center { max-width: 420px; margin: 8vh auto; }
.stars { color: var(--star); font-weight: 800; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--card); }
details summary { font-weight: 700; cursor: pointer; }
.hr { border: 0; border-top: 1px solid var(--line-2); margin: 18px 0; }

/* ============ الريسبونسف (موبايل/تابلت) ============ */
.scrim { display: none; }
.menu-btn {
    display: none;
    align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--card); cursor: pointer; flex: none;
}
.menu-btn svg { width: 20px; height: 20px; color: var(--ink); }
[data-theme="dark"] .btn:hover { box-shadow: 0 6px 18px -8px var(--color-primary-tint); }
[data-theme="dark"] .btn.out:hover, [data-theme="dark"] .btn.danger:hover { box-shadow: var(--shadow-sm); }

@media (max-width: 900px) {
    .shell { display: block; }

    /* السايدبار يبقى درج منزلق من اليمين */
    .side {
        position: fixed; top: 0; right: 0; bottom: 0;
        width: min(84vw, 280px); height: 100vh;
        transform: translateX(100%);
        transition: transform .25s ease;
        z-index: 100;
        box-shadow: -20px 0 60px var(--color-shadow);
    }
    .side.open { transform: translateX(0); }
    /* الإنجليزي (LTR): الدرج من الشمال */
    [dir="ltr"] .side { right: auto; left: 0; transform: translateX(-100%); box-shadow: 20px 0 60px var(--color-shadow); }
    [dir="ltr"] .side.open { transform: translateX(0); }
    .scrim {
        display: block; position: fixed; inset: 0;
        background: var(--color-scrim); z-index: 99;
        opacity: 0; pointer-events: none; transition: opacity .2s ease;
    }
    .scrim.show { opacity: 1; pointer-events: auto; }

    .menu-btn { display: inline-flex; }

    .main { padding: 16px 14px 32px; }
    .topbar { margin-bottom: 14px; }
    .topbar h2 { font-size: 17px; }
    .topbar .user .who { display: none; }
    .topbar-end { flex-direction: row; align-items: center; gap: 10px; }

    /* الجداول: أقل عرض منطقي والكارت بيعمل سكرول أفقي */
    .card { padding: 14px; overflow-x: auto; }
    .card > table { min-width: 560px; }
    .table-wrap > table { min-width: 560px; }
    th { padding: 9px 10px; font-size: 10.5px; }
    tbody td { padding: 9px 10px; font-size: 12.5px; }

    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .stat .n { font-size: 24px; }
    .stat .icon { width: 34px; height: 34px; top: 14px; inset-inline-end: 14px; }

    .btn { padding: 0 14px; font-size: 13px; }
    input, select, textarea { font-size: 16px; } /* منع الزووم التلقائي في iOS */
    .center { margin: 4vh auto; }
}

/* ============================================================
   إضافات مشروبات ٢٤ (مش في وينه)
   ============================================================ */

/* علامة اللوجو المؤقتة لحد ما ملف اللوجو ييجي من الفيجما */
.side .brand .mark,
.auth-brand .mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 12px;
    background: var(--side-active);
    color: var(--side-ink-strong);
    font-weight: 700;
    font-size: 17px;
}

/* صفحات الدخول ونسيت كلمة المرور (من غير سايدبار) */
.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px 16px;
}
.auth-shell .prefs { align-self: flex-end; max-width: 420px; width: 100%; justify-content: flex-end; }
.auth-shell .card { width: 100%; max-width: 420px; margin: 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand .mark { background: var(--brand); color: var(--btn-ink); }
.auth-brand .word { font-weight: 700; font-size: 20px; color: var(--ink); }
.auth-brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.auth-links { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 13px; }
.auth-links a { color: var(--green-700); font-weight: 600; }
.check-line { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--body); }
.check-line input { width: auto; height: auto; margin: 0; }

.field-error { color: var(--danger); margin: 4px 0 0; font-size: 12.5px; }

/* شريط الأدوات فوق أي جدول: البحث يمين والتصدير شمال */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toolbar .search-bar { flex: 1 1 100%; margin: 0; }
.toolbar .search-bar input { flex: 1 1 150px; }
.toolbar .export-bar { margin-inline-start: auto; }
.export-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.export-bar details { position: relative; border: 0; padding: 0; margin: 0; background: none; }
.export-bar summary { list-style: none; cursor: pointer; }
.export-bar summary::-webkit-details-marker { display: none; }
.export-bar .pop {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 6px);
    z-index: 20;
    width: 280px;
    padding: 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.export-bar .pop .row { display: flex; gap: 8px; margin-top: 10px; }

/* ============================================================
   سبرنت 1 — مكوّنات اللوحة (switch · tabs · كروت الأونبوردينج · المعاينة)
   ============================================================ */

/* switch تشغيل/إطفاء — checkbox حقيقي (يشتغل مع الفورم والكيبورد) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--body); margin: 0; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 40px; height: 22px; flex: none; border-radius: 99px; background: var(--line); border: 1px solid var(--line); transition: background .2s, border-color .2s; }
.switch .track::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow-md); transition: transform .2s cubic-bezier(.16, 1, .3, 1); }
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }
.switch-form { margin: 0; display: inline-flex; }
.switch-form button.switch { background: none; border: 0; padding: 0; font: inherit; }
.switch-form button.switch .track { pointer-events: none; }
.switch-form button.switch.on .track { background: var(--brand); border-color: var(--brand); }
.switch-form button.switch.on .track::after { transform: translateX(18px); }
[dir="rtl"] .switch-form button.switch.on .track::after { transform: translateX(-18px); }

/* تابات صفحات (الإعدادات) */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; font-size: 13.5px; font-weight: 700; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }

/* صفوف الإعدادات */
.setting-group + .setting-group { border-top: 1px solid var(--line-2); margin-top: 18px; padding-top: 6px; }
.setting-group h4 { margin: 12px 0 2px; font-size: 14px; font-weight: 800; color: var(--ink); }
.setting-group .muted { margin: 0 0 6px; }
.banner-warn { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 700; font-size: 13px; margin-bottom: 16px; }

/* عنوان صفحة مع أزرار (مسافة بينهم) — شاشات المحتوى والرسايل */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2, .page-head h3 { margin: 0; }
/* نص رسالة / رد — فقاعة هادية بتحترم الأسطر */
.banner-info { padding: 12px 14px; border-radius: 12px; background: var(--row-hover); font-size: 14px; line-height: 1.8; white-space: pre-line; margin-bottom: 16px; }
.small { font-size: 12px; }

/* جدول المفاتيح */
.section-title { margin: 22px 0 8px; font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: .3px; }
.section-title:first-child { margin-top: 0; }
.key-code { font-size: 11.5px; color: var(--muted); direction: ltr; unicode-bidi: isolate; }

/* كروت الأونبوردينج (بتتسحب للترتيب) */
.ob-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.ob-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); cursor: grab; transition: transform .15s, box-shadow .15s, opacity .15s; }
.ob-card:active { cursor: grabbing; }
.ob-card.dragging { opacity: .45; }
.ob-card.over { box-shadow: 0 0 0 2px var(--brand); }
.ob-card.off .ob-thumb { filter: grayscale(1); opacity: .55; }
.ob-thumb { position: relative; aspect-ratio: 430 / 932; background: var(--surface-2); }
.ob-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ob-thumb .en { position: absolute; bottom: 8px; inset-inline-end: 8px; width: 34%; aspect-ratio: 430 / 932; border-radius: 6px; border: 2px solid var(--card); overflow: hidden; box-shadow: var(--shadow-md); background: var(--surface-2); }
.ob-order { position: absolute; top: 8px; inset-inline-start: 8px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; background: var(--brand); color: var(--btn-ink); font-weight: 800; font-size: 12.5px; box-shadow: var(--shadow-md); }
.ob-body { padding: 10px; display: grid; gap: 8px; }
.ob-body .row-actions .btn { flex: 1; }
.ob-body .row-actions form { display: flex; flex: 1; }
.ob-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ob-card details { border: 0; padding: 0; margin: 0; background: none; }
.ob-card details > summary { list-style: none; display: flex; width: 100%; }
.ob-card details[open] > summary { margin-bottom: 4px; }
.ob-card details > summary::-webkit-details-marker { display: none; }
.ob-card details form { margin-top: 8px; }
.ob-card details label { margin-top: 8px; }

/* معاينة التسلسل — موبايل وهمي */
.preview-dialog { border: 0; padding: 0; background: transparent; max-width: 100vw; }
.preview-dialog::backdrop { background: var(--color-scrim); }
.phone { position: relative; width: min(320px, 86vw); aspect-ratio: 430 / 932; border-radius: 36px; border: 10px solid var(--device-frame); overflow: hidden; background: var(--device-frame); box-shadow: var(--shadow-md); }
.phone .slide { position: absolute; inset: 0; opacity: 0; transition: opacity .45s ease; }
.phone .slide.on { opacity: 1; }
.phone .slide img { width: 100%; height: 100%; object-fit: cover; }
.phone .bars { position: absolute; top: 6.5%; inset-inline: 5%; display: flex; gap: 6px; z-index: 2; }
.phone .bars span { flex: 1; height: 3px; border-radius: 3px; background: var(--preview-bar); overflow: hidden; }
.phone .bars span i { display: block; height: 100%; width: 0; background: var(--brand); }
.phone .bars span.done i { width: 100%; }
.phone .start { position: absolute; bottom: 4%; inset-inline: 6%; z-index: 2; height: 44px; border-radius: 99px; border: 0; background: var(--brand); color: var(--btn-ink); font: inherit; font-weight: 700; }
.preview-tools { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
@media (max-width: 560px) {
    .ob-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* جدول المفاتيح — نفس عرض الأعمدة في كل الأقسام */
.toggles-table { table-layout: fixed; min-width: 760px; }
.toggles-table .c-name { width: 34%; }
.toggles-table .c-status { width: 20%; }
.toggles-table .c-scope { width: 18%; }
.toggles-table .c-date { width: 14%; }
.toggles-table .c-by { width: 14%; }

/* ============ سبرنت 2 — الشجرة الجغرافية · فورمات مطوية · الخريطة · QR ============ */
.geo-tree details.geo-node { margin-bottom: 8px; padding: 0; overflow: hidden; }
.geo-tree details.geo-node > summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; }
.geo-tree details.geo-node.child { margin: 8px 0; background: var(--surface-2); }
.geo-tree .geo-name { font-weight: 800; color: var(--ink); }
.geo-body { padding: 4px 14px 14px; display: grid; gap: 8px; }
.geo-leaf { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.geo-leaf .row-actions { margin-inline-start: auto; }
/* صف العقدة + زر الإضافة في آخره: العقدة بياخد الباقي والزر (inline-edit) قصاد حدّ الصف */
.geo-node-row { display: flex; align-items: flex-start; gap: 10px; }
.geo-node-row > details.geo-node { flex: 1 1 auto; min-width: 0; }
.geo-node-row > details.inline-edit { flex: 0 0 auto; margin-top: 7px; }
.geo-node-row > details.inline-edit .pop { inset-inline-start: auto; inset-inline-end: 0; }
details.inline-edit { position: relative; border: 0; padding: 0; margin: 0; background: none; display: inline-block; }
details.inline-edit > summary { list-style: none; display: inline-flex; }
details.inline-edit > summary::-webkit-details-marker { display: none; }
details.inline-edit .pop { position: absolute; z-index: 20; inset-inline-start: 0; top: calc(100% + 6px); min-width: 260px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-md); }
details.inline-edit .pop label:first-of-type { margin-top: 0; }
.map-pick { height: 320px; border-radius: 12px; border: 1px solid var(--line); margin-top: 6px; z-index: 0; }
.qr-box { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr-box img { width: 200px; height: 200px; background: var(--color-surface); border-radius: 12px; border: 1px solid var(--line); padding: 8px; }
.hours-grid { display: grid; grid-template-columns: 110px repeat(4, minmax(0, auto)); gap: 8px 12px; align-items: center; }
.hours-grid input[type="time"] { max-width: 140px; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); display: block; }
.thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 11px; }
@media (max-width: 640px) { .hours-grid { grid-template-columns: 1fr 1fr; } }

/* الجرس (3ب.5 · 3ب.14) */
.bell { position: relative; }
.bell > summary { list-style: none; cursor: pointer; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--muted); position: relative; }
.bell > summary::-webkit-details-marker { display: none; }
.bell > summary svg { width: 20px; height: 20px; }
.bell-count { position: absolute; top: -6px; inset-inline-end: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: var(--color-on-primary); font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.bell-menu { position: absolute; top: 46px; inset-inline-end: 0; width: min(340px, 86vw); background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); z-index: 40; overflow: hidden; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.bell-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; font-size: 13px; }
.bell-item:hover { background: var(--row-hover); }
.bell-item.unread { background: var(--green-soft); }
.bell-all { display: block; text-align: center; padding: 10px; font-size: 13px; font-weight: 700; }
