/* ==========================================================================
   النظام — نظام تصميم عصري (v5)
   RTL · فاتح/غامق مضبوط · متغيّرات يتحكم بها المدير (theme.php)
   ========================================================================== */

:root {
  --primary: #6c5ce7;
  --primary-2: #8e7bff;
  --on-primary: #ffffff;
  --success: #12b886;
  --danger: #fa5252;
  --warning: #f7b731;

  --radius-lg: 20px;
  --btn-radius: 14px;
  --radius-sm: 11px;
  --radius: 15px;
  --radius-xl: 30px;
  --app-font: 'Tajawal', 'Segoe UI', system-ui, sans-serif;

  /* الوضع الفاتح */
  --bg: #f4f4fb;
  --surface: #ffffff;
  --surface-2: #fafaff;
  --surface-3: #f0f1f9;
  --text: #14152a;
  --text-2: #3f4360;
  --text-3: #666b8a;
  --muted: #8b90aa;
  --border: #ebecf6;
  --border-2: #dcdef0;

  --shadow-sm: 0 2px 10px rgba(20, 22, 50, .05);
  --shadow: 0 14px 40px -12px rgba(20, 22, 50, .16);
  --shadow-lg: 0 34px 70px -20px rgba(20, 22, 50, .26);
  --shadow-primary: 0 18px 44px -12px color-mix(in srgb, var(--primary) 55%, transparent);

  --primary-weak: color-mix(in srgb, var(--primary) 10%, transparent);
  --primary-weaker: color-mix(in srgb, var(--primary) 6%, transparent);
  --primary-line: color-mix(in srgb, var(--primary) 34%, var(--border));
  --success-weak: color-mix(in srgb, var(--success) 13%, transparent);
  --danger-weak: color-mix(in srgb, var(--danger) 12%, transparent);
  --warning-weak: color-mix(in srgb, var(--warning) 18%, transparent);
  --ring: color-mix(in srgb, var(--primary) 28%, transparent);
  --grad: linear-gradient(135deg, var(--primary), var(--primary-2));

  --sidebar-bg: var(--surface);
  --sidebar-fg: var(--text-2);
  --sidebar-fg-strong: var(--text);
  --sidebar-fg-muted: var(--muted);
  --sidebar-hover: var(--surface-3);
  --sidebar-active-bg: var(--primary-weak);
  --sidebar-active-fg: var(--primary);
  --sidebar-border: var(--border);

  --sidebar-w: 270px;
  --topbar-h: 66px;
  --pad-card: clamp(20px, 3vw, 28px);
  --pad-cell: 13px 16px;
  --gap: 22px;
  --nav-pad: 10px 12px;

  --ease-spring: cubic-bezier(.34, 1.46, .5, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c13;
  --surface: #14151e;
  --surface-2: #191a24;
  --surface-3: #21222f;
  --text: #edeef8;
  --text-2: #babdd2;
  --text-3: #9297b0;
  --muted: #7a7f99;
  --border: #262837;
  --border-2: #333549;

  --shadow-sm: 0 2px 12px rgba(0, 0, 0, .45);
  --shadow: 0 18px 44px -12px rgba(0, 0, 0, .62);
  --shadow-lg: 0 36px 74px -18px rgba(0, 0, 0, .78);

  --primary-weak: color-mix(in srgb, var(--primary) 22%, transparent);
  --primary-weaker: color-mix(in srgb, var(--primary) 13%, transparent);
  --primary-line: color-mix(in srgb, var(--primary) 44%, var(--border));
  --success-weak: color-mix(in srgb, var(--success) 22%, transparent);
  --danger-weak: color-mix(in srgb, var(--danger) 22%, transparent);
  --warning-weak: color-mix(in srgb, var(--warning) 24%, transparent);

  --sidebar-bg: #0f1017;
  --sidebar-fg: #a8acc6;
  --sidebar-fg-strong: #f3f4fc;
  --sidebar-fg-muted: #6b7089;
  --sidebar-hover: rgba(255, 255, 255, .05);
  --sidebar-active-bg: color-mix(in srgb, var(--primary) 26%, transparent);
  --sidebar-active-fg: color-mix(in srgb, var(--primary-2) 78%, #fff);
  --sidebar-border: #22243255;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 90px; overflow-x: hidden; overscroll-behavior-x: none; }

body {
  margin: 0;
  font-family: var(--app-font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  max-width: 100%;
  position: relative;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 800; letter-spacing: -.014em; }
h1 { font-size: clamp(22px, 3vw, 28px); }
h2 { font-size: clamp(17px, 2.4vw, 20px); }
p { margin: 0 0 1em; }
hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
small { font-size: 12.5px; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; background: var(--surface-3); padding: 2px 7px; border-radius: 6px; font-size: 13px; color: var(--text-2); }

::selection { background: var(--primary); color: var(--on-primary); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 20px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

.ico-svg { display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
.btn .ico-svg { vertical-align: -0.22em; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 24px); }
.container-wide { max-width: 1320px; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.section-title { font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .07em; text-transform: uppercase; margin: 0 0 12px; }
.page-lead { color: var(--text-3); margin: -6px 0 24px; font-size: 14.5px; max-width: 64ch; }

/* ==========================================================================
   الحركات
   ========================================================================== */
@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.9); } 100% { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 100% { background-position: -200% 0; } }
@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes float-y { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-16px); } }
@keyframes float-blob { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(34px, -46px) scale(1.12); } 66% { transform: translate(-24px, 24px) scale(.92); } }
@keyframes bob { 0%, 100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-10px); } }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.content > * { animation: fade-up .55s var(--ease-out) both; }
.content > *:nth-child(2) { animation-delay: .05s; }
.content > *:nth-child(3) { animation-delay: .1s; }
.content > *:nth-child(4) { animation-delay: .15s; }
.content > *:nth-child(5) { animation-delay: .2s; }
.stat-grid .stat { animation: fade-up .55s var(--ease-out) both; }
.stat-grid .stat:nth-child(n) { animation-delay: calc(.06s * var(--i, 0)); }
.stat-grid .stat:nth-child(2) { --i: 1; } .stat-grid .stat:nth-child(3) { --i: 2; }
.stat-grid .stat:nth-child(4) { --i: 3; } .stat-grid .stat:nth-child(5) { --i: 4; }
.stat-grid .stat:nth-child(6) { --i: 5; } .stat-grid .stat:nth-child(7) { --i: 6; }
.stat-grid .stat:nth-child(8) { --i: 7; }

/* ==========================================================================
   الأزرار
   ========================================================================== */
.btn {
  --btn-fg: var(--text);
  --btn-bg: var(--surface);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; cursor: pointer;
  padding: 11px 22px;
  font-family: inherit; font-size: 14px; font-weight: 800;
  border-radius: var(--btn-radius);
  background: var(--btn-bg); color: var(--btn-fg);
  white-space: nowrap; line-height: 1.2;
  transition: transform .2s var(--ease-spring), box-shadow .22s var(--ease-out),
              background .16s ease, border-color .16s ease, opacity .16s ease, color .16s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-3px); }
.btn:active { transform: translateY(-1px) scale(.97); transition-duration: .05s; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
  color: var(--on-primary);
  background: var(--grad);
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.btn-primary:hover { box-shadow: 0 24px 50px -12px color-mix(in srgb, var(--primary) 68%, transparent), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn-primary::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; overflow: hidden;
  background: linear-gradient(120deg, transparent 34%, rgba(255, 255, 255, .35) 50%, transparent 66%);
  background-size: 220% 100%; background-position: 220% 0; opacity: 0; transition: opacity .2s ease;
}
.btn-primary:hover::after { opacity: 1; animation: shimmer 1s ease; }

.btn-outline { color: var(--primary); background: var(--surface); border-color: var(--primary-line); }
.btn-outline:hover { background: var(--primary-weaker); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { color: #fff; background: var(--danger); box-shadow: 0 12px 26px -8px color-mix(in srgb, var(--danger) 55%, transparent); }
.btn-success { color: #fff; background: var(--success); box-shadow: 0 12px 26px -8px color-mix(in srgb, var(--success) 55%, transparent); }
.btn-soft { background: var(--primary-weak); color: var(--primary); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); }
.btn-soft-danger { background: var(--danger-weak); color: var(--danger); }
.btn-soft-danger:hover { background: color-mix(in srgb, var(--danger) 22%, transparent); }
.btn-white { background: #fff; color: var(--primary); }
.btn-white:hover { background: #fff; }

.btn-sm { padding: 7px 13px; font-size: 12.5px; gap: 6px; border-radius: calc(var(--btn-radius) - 4px); }
.btn-sm .ico-svg { width: 15px; height: 15px; }
.btn-lg { padding: 15px 30px; font-size: 16px; border-radius: calc(var(--btn-radius) + 2px); }
.btn-pill { border-radius: 999px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 40px; height: 40px; border-radius: var(--btn-radius); }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 8px; }

/* ==========================================================================
   البطاقات
   ========================================================================== */
.card, .dash-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--pad-card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .22s var(--ease-out), border-color .2s ease, transform .22s var(--ease-out);
}
.card:hover, .dash-card:hover { box-shadow: var(--shadow); }
.card + .card, .dash-card + .dash-card, .card + .dash-card, .dash-card + .card { margin-top: var(--gap); }
.card-tight { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.card-head h2, .card-head h3 { margin: 0; display: flex; align-items: center; gap: 9px; }
.card-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.card-head .ico-svg { color: var(--primary); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.stat {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform .22s var(--ease-out), box-shadow .22s var(--ease-out), border-color .2s ease;
}
.stat:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--primary-line); }
.stat::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.stat.is-success::before { background: var(--success); }
.stat.is-danger::before { background: var(--danger); }
.stat.is-warning::before { background: var(--warning); }
.stat-ico { width: 44px; height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; background: var(--primary-weak); color: var(--primary); }
.stat-ico .ico-svg { width: 22px; height: 22px; }
.stat.is-success .stat-ico { background: var(--success-weak); color: var(--success); }
.stat.is-danger .stat-ico { background: var(--danger-weak); color: var(--danger); }
.stat.is-warning .stat-ico { background: var(--warning-weak); color: color-mix(in srgb, var(--warning) 62%, #6b4e00); }
:root[data-theme="dark"] .stat.is-warning .stat-ico { color: var(--warning); }
.stat-num { font-size: 27px; font-weight: 900; letter-spacing: -.02em; }
.stat-lbl { font-size: 12.5px; color: var(--muted); margin-top: 3px; font-weight: 700; }

/* ==========================================================================
   لوحة التحكم
   ========================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar-bg); border-inline-start: 1px solid var(--sidebar-border); padding: 18px 14px; display: flex; flex-direction: column; gap: 3px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 11px; font-weight: 900; font-size: 17px; color: var(--sidebar-fg-strong); padding: 8px 10px 18px; letter-spacing: -.01em; }
.sidebar .brand img, .sidebar .brand .logo-fallback { width: 36px; height: 36px; border-radius: 11px; object-fit: contain; flex-shrink: 0; }
.sidebar .brand .logo-fallback { display: flex; align-items: center; justify-content: center; background: var(--grad); color: var(--on-primary); }
.nav-group-label { font-size: 10.5px; font-weight: 800; color: var(--sidebar-fg-muted); letter-spacing: .09em; text-transform: uppercase; padding: 15px 12px 6px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 12px; padding: var(--nav-pad); border-radius: 12px; color: var(--sidebar-fg); font-weight: 700; font-size: 14px; transition: background .15s ease, color .15s ease; }
.nav-link .ico-svg { color: var(--sidebar-fg-muted); transition: color .15s ease; width: 19px; height: 19px; }
.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); }
.nav-link:hover .ico-svg { color: var(--sidebar-fg-strong); }
.nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-fg); }
.nav-link.active .ico-svg { color: var(--sidebar-active-fg); }
.nav-link.active::before { content: ""; position: absolute; inset-inline-start: -14px; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--sidebar-active-fg); }
.nav-link .pill { margin-inline-start: auto; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 800; padding: 1px 7px; border-radius: 20px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--sidebar-border); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 clamp(16px, 4vw, 30px); position: sticky; top: 0; z-index: 50;
}
.topbar .page-title { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 12px; border-radius: 30px; border: 1px solid var(--border); background: var(--surface); transition: border-color .15s ease; }
.user-chip:hover { border-color: var(--border-2); }
.user-chip .avatar, .user-chip .avatar-fallback { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.user-chip .avatar-fallback { display: flex; align-items: center; justify-content: center; background: var(--primary-weak); color: var(--primary); font-weight: 800; font-size: 13px; }
.user-chip .u-name { font-size: 13px; font-weight: 700; line-height: 1.2; }
.user-chip .u-role { font-size: 10.5px; color: var(--muted); }

.content { padding: clamp(18px, 3.5vw, 34px); max-width: 1220px; width: 100%; margin: 0 auto; }
.role-badge { font-size: 11.5px; font-weight: 800; padding: 4px 12px; border-radius: 20px; background: var(--primary-weak); color: var(--primary); }

.drawer-overlay { position: fixed; inset: 0; background: rgba(6, 7, 14, .55); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .22s ease; z-index: 90; }
body.drawer-open .drawer-overlay { opacity: 1; pointer-events: auto; }

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; z-index: 100; width: min(84vw, 300px); height: 100vh; transform: translateX(105%); transition: transform .3s var(--ease-out); box-shadow: var(--shadow-lg); }
  body.drawer-open .sidebar { transform: translateX(0); }
  .topbar .menu-btn { display: inline-flex; }
}

/* ==========================================================================
   الجداول
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.data, .admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 540px; }
table.data th, table.data td, .admin-table th, .admin-table td { padding: var(--pad-cell); text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th, .admin-table th { background: var(--surface-2); font-weight: 800; font-size: 12px; color: var(--text-2); white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
table.data tr:last-child td, .admin-table tr:last-child td { border-bottom: none; }
table.data tbody tr, .admin-table tbody tr { transition: background .12s ease; }
table.data tbody tr:hover, .admin-table tbody tr:hover { background: var(--primary-weaker); }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cell-empty { text-align: center; color: var(--muted); padding: 38px 16px; }

/* ==========================================================================
   الشارات
   ========================================================================== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 800; background: var(--surface-3); color: var(--text-2); }
.badge.active, .badge.is-success { background: var(--success-weak); color: var(--success); }
.badge.inactive, .badge.is-danger { background: var(--danger-weak); color: var(--danger); }
.badge.is-warning { background: var(--warning-weak); color: color-mix(in srgb, var(--warning) 52%, #5c4300); }
:root[data-theme="dark"] .badge.is-warning { color: var(--warning); }
.badge.is-primary { background: var(--primary-weak); color: var(--primary); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active .dot { animation: pulse-soft 2s ease infinite; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; font-weight: 700; transition: border-color .14s ease, background .14s ease, color .14s ease; }
.chip:hover { border-color: var(--primary-line); }

/* ==========================================================================
   النماذج
   ========================================================================== */
.form-group { margin-bottom: 18px; }
.form-group > label, .field-label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.req::after { content: " *"; color: var(--danger); font-weight: 800; }

.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
.form-group select, .form-group textarea, .input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-2); font-family: inherit; font-size: 14px;
  color: var(--text); background: var(--surface-2);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.form-group textarea, textarea.input { min-height: 92px; resize: vertical; line-height: 1.7; }
.form-group input:hover, .form-group select:hover, .form-group textarea:hover { border-color: var(--border-2); background: var(--surface); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--ring); }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--muted); }
select {
  -webkit-appearance: none; appearance: none;
  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='%238b90aa' stroke-width='2.5' 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 12px center; padding-inline-end: 38px;
}

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 200px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2px 16px; }

/* شريط فلترة/بحث موحّد للوحات (طلاب، مدفوعات، أكواد ...) */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.filter-bar input:not([type="checkbox"]):not([type="radio"]), .filter-bar select {
  padding: 10px 13px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-2);
  font-family: inherit; font-size: 13.5px; color: var(--text); background: var(--surface-2);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; min-width: 0;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--ring); }
.filter-bar .fb-search { flex: 1 1 220px; min-width: 180px; }
.filter-bar select { -webkit-appearance: none; appearance: none; padding-inline-end: 36px;
  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='%238b90aa' stroke-width='2.5' 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 11px center; }
@media (max-width: 620px) { .filter-bar { width: 100%; } .filter-bar .fb-search { flex-basis: 100%; } }

/* أزرار مقسّمة (تبويبات فلترة) */
.seg { display: inline-flex; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--btn-radius); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a { padding: 7px 14px; border-radius: calc(var(--btn-radius) - 3px); font-size: 13px; font-weight: 700; color: var(--text-2); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .14s ease, color .14s ease; }
.seg a:hover { color: var(--text); }
.seg a.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.seg .seg-count { background: var(--primary-weak); color: var(--primary); border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 800; }
.seg a.on .seg-count { background: var(--primary); color: #fff; }

/* قسم فرعي جوه فورم طويل (فورم المنتج/الفرع): عنوان صغير وخط فاصل بدل كارت جديد */
.form-section { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; }
.form-section > h3 { font-size: 14px; font-weight: 800; margin: 0 0 10px; display: flex; align-items: center; gap: 7px; color: var(--text); }
.form-section > .muted:first-of-type { margin-top: -4px; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1.5px solid var(--border-2); border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; font-weight: 600; transition: border-color .14s ease, background .14s ease; }
.check:hover { border-color: var(--primary-line); }
.check input { margin-top: 2px; width: 17px; height: 17px; accent-color: var(--primary); flex-shrink: 0; }
.check.checked, .check:has(input:checked) { border-color: var(--primary); background: var(--primary-weaker); }
.check .c-body small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px; font-size: 12px; }

.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.switch .track { position: relative; width: 44px; height: 25px; border-radius: 20px; background: var(--border-2); transition: background .2s var(--ease-spring); flex-shrink: 0; align-self: center; }
.switch .track::after { content: ""; position: absolute; width: 19px; height: 19px; border-radius: 50%; background: #fff; top: 3px; inset-inline-start: 3px; transition: transform .22s var(--ease-spring); box-shadow: 0 2px 5px rgba(0, 0, 0, .25); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(19px); }
[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-19px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }
/* لو الـ switch جوّه form-group، قاعدة ".form-group > label" كانت بتخليه block وتكسر التصميم */
.form-group > label.switch { display: inline-flex; margin-bottom: 0; font-size: 13.5px; }

.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type="color"] { width: 46px; height: 40px; padding: 3px; border: 1px solid var(--border-2); border-radius: 9px; background: var(--surface); cursor: pointer; }
.color-field input[type="text"] { width: 120px; font-family: ui-monospace, monospace; }

.progress { height: 9px; background: var(--surface-3); border-radius: 20px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--grad); border-radius: 20px; transition: width .35s var(--ease-out); }

/* رافع الصور مع شريط التقدم */
.img-up { margin-top: 6px; }
.img-up-drop { display: flex; align-items: center; gap: 14px; border: 2px dashed var(--border-2); border-radius: var(--radius); padding: 14px 16px; background: var(--surface-2); transition: border-color .16s ease, background .16s ease; cursor: pointer; }
.img-up-drop:hover, .img-up.drag .img-up-drop { border-color: var(--primary); background: var(--primary-weaker); }
.img-up-thumb { width: 66px; height: 66px; border-radius: 13px; flex-shrink: 0; background: var(--surface-3) center / cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); border: 1px solid var(--border); }
.img-up-thumb .ico-svg { width: 24px; height: 24px; }
.img-up-body { flex: 1; min-width: 0; }
.img-up-title { font-size: 13.5px; font-weight: 700; color: var(--text-2); }
.img-up-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.img-up-bar { height: 6px; border-radius: 20px; background: var(--surface-3); overflow: hidden; margin-top: 8px; display: none; }
.img-up.uploading .img-up-bar { display: block; }
.img-up-bar > i { display: block; height: 100%; width: 0; border-radius: 20px; background: var(--grad); transition: width .2s ease; }
.img-up.done .img-up-thumb { border-color: var(--success); }
.img-up.error .img-up-title { color: var(--danger); }
.img-up input[type="file"] { display: none; }
.img-up-clear { border: none; background: var(--surface-3); color: var(--text-2); border-radius: 9px; width: 30px; height: 30px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.img-up-clear:hover { background: var(--danger-weak); color: var(--danger); }

.upload-preview-wrap { display: flex; align-items: center; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.upload-preview { width: 72px; height: 72px; border-radius: 13px; object-fit: cover; border: 1px solid var(--border-2); background: var(--surface-3); }
input[type="file"] { font-size: 13px; color: var(--muted); max-width: 100%; }
input[type="file"]::file-selector-button { font-family: inherit; font-weight: 700; font-size: 13px; padding: 8px 14px; margin-inline-end: 12px; border: 1px solid var(--primary-line); border-radius: var(--radius-sm); background: var(--primary-weaker); color: var(--primary); cursor: pointer; transition: background .14s ease; }
input[type="file"]::file-selector-button:hover { background: var(--primary-weak); }

#topProgress { position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 9999; background: transparent; pointer-events: none; }
#topProgress > i { display: block; height: 100%; width: 0; background: var(--grad); box-shadow: 0 0 12px var(--primary); transition: width .2s ease; }
/* التنقّل جوه اللوحة (nav.js): شريط بيتحرك فوق لحد ما الصفحة الجديدة توصل */
#navProgress { position: fixed; top: 0; inset-inline-start: 0; height: 3px; width: 0; z-index: 9999; background: var(--grad); box-shadow: 0 0 12px var(--primary); opacity: 0; pointer-events: none; }
html.is-navigating #navProgress { opacity: 1; animation: navProgress 2.5s ease-out forwards; }
@keyframes navProgress { 0% { width: 0; } 30% { width: 45%; } 100% { width: 85%; } }
html.is-navigating main.content { opacity: .75; transition: opacity .2s; }

/* ==========================================================================
   التنبيهات
   ========================================================================== */
.alert { border-radius: var(--radius); padding: 13px 16px; margin-bottom: 16px; font-size: 13.5px; font-weight: 600; line-height: 1.6; display: flex; align-items: flex-start; gap: 11px; border: 1px solid transparent; animation: fade-up .4s var(--ease-out) both; }
.alert::before { content: ""; width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; background: currentColor; -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; }
.alert-error, .alert-danger { background: var(--danger-weak); color: color-mix(in srgb, var(--danger) 80%, #380707); border-color: color-mix(in srgb, var(--danger) 26%, transparent); }
.alert-error::before, .alert-danger::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }
.alert-success { background: var(--success-weak); color: color-mix(in srgb, var(--success) 80%, #032c22); border-color: color-mix(in srgb, var(--success) 26%, transparent); }
.alert-success::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E"); }
.alert-info { background: var(--primary-weak); color: color-mix(in srgb, var(--primary) 82%, #0e0930); border-color: color-mix(in srgb, var(--primary) 22%, transparent); }
.alert-info::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E"); }
.alert-warning { background: var(--warning-weak); color: color-mix(in srgb, var(--warning) 50%, #40300a); border-color: color-mix(in srgb, var(--warning) 38%, transparent); }
.alert-warning::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.268 21a2 2 0 0 0 3.464 0'/%3E%3Cpath d='M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.268 21a2 2 0 0 0 3.464 0'/%3E%3Cpath d='M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] .alert-error, :root[data-theme="dark"] .alert-danger { color: color-mix(in srgb, var(--danger) 42%, #fff); }
:root[data-theme="dark"] .alert-success { color: color-mix(in srgb, var(--success) 45%, #fff); }
:root[data-theme="dark"] .alert-warning { color: color-mix(in srgb, var(--warning) 78%, #fff); }
:root[data-theme="dark"] .alert-info { color: color-mix(in srgb, var(--primary-2) 62%, #fff); }

/* ==========================================================================
   التبويبات / النوافذ
   ========================================================================== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab { padding: 11px 16px; font-weight: 700; font-size: 13.5px; color: var(--muted); border-bottom: 2.5px solid transparent; white-space: nowrap; cursor: pointer; background: none; border-top: none; border-inline: none; font-family: inherit; transition: color .14s ease, border-color .14s ease; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* عنصر <dialog> الأصلي بدل الأوفرلاي المبني يدويًا: بيترسم في "الطبقة العليا" الخاصة
   بالمتصفح تلقائيًا (topLayer)، بمنأى تمامًا عن أي تعارض z-index/stacking-context
   مع باقي عناصر الصفحة، ومعاه تركيز لوحة المفاتيح والإغلاق بـ Escape مجانًا. */
dialog.modal { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); padding: 0; margin: auto; }
dialog.modal::backdrop { background: rgba(6, 7, 14, .58); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: pop-in .22s var(--ease-spring) both; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal-close { border: none; background: var(--surface-3); width: 32px; height: 32px; border-radius: 9px; cursor: pointer; color: var(--text-2); display: flex; align-items: center; justify-content: center; }

.empty { text-align: center; padding: 52px 24px; color: var(--muted); animation: pop-in .4s var(--ease-out) both; }
.empty .e-ico { width: 66px; height: 66px; margin: 0 auto 16px; border-radius: 20px; display: flex; align-items: center; justify-content: center; background: var(--primary-weaker); color: var(--primary); }
.empty .e-ico .ico-svg { width: 30px; height: 30px; }
.empty h3 { color: var(--text-2); font-size: 16px; margin-bottom: 6px; }
.empty p { font-size: 13.5px; max-width: 360px; margin: 0 auto 18px; }

/* ==========================================================================
   الدخول / التسجيل
   ========================================================================== */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside { color: #fff; padding: clamp(40px, 5vw, 64px); display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; isolation: isolate; background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 95%, #000), var(--primary) 52%, var(--primary-2)); }
.auth-aside .blob { position: absolute; border-radius: 50%; filter: blur(72px); z-index: -1; animation: float-blob 22s ease-in-out infinite; }
.auth-aside .blob.a1 { width: 380px; height: 380px; background: var(--primary-2); top: -120px; inset-inline-start: -60px; opacity: .55; }
.auth-aside .blob.a2 { width: 300px; height: 300px; background: #fff; bottom: -140px; inset-inline-end: -60px; opacity: .12; animation-duration: 28s; }
.auth-aside .auth-brand { display: flex; align-items: center; gap: 11px; font-weight: 900; font-size: 20px; margin-bottom: auto; }
.auth-aside .auth-brand .logo-fallback, .auth-aside .auth-brand img { width: 42px; height: 42px; border-radius: 12px; background: rgba(255, 255, 255, .16); display: flex; align-items: center; justify-content: center; }
.auth-aside h2 { font-size: clamp(24px, 3.4vw, 33px); margin: 34px 0 16px; line-height: 1.25; }
.auth-aside p { opacity: .92; line-height: 1.85; max-width: 420px; margin: 0; }
.auth-aside ul { list-style: none; padding: 0; margin: 30px 0 auto; display: grid; gap: 15px; }
.auth-aside li { display: flex; gap: 12px; align-items: flex-start; font-weight: 700; font-size: 14.5px; }
.auth-aside li .li-ic { width: 32px; height: 32px; flex-shrink: 0; border-radius: 10px; background: rgba(255, 255, 255, .16); display: flex; align-items: center; justify-content: center; }
.auth-aside li small { display: block; font-weight: 500; opacity: .78; font-size: 12.5px; margin-top: 2px; }
.auth-aside .auth-quote { margin-top: 34px; padding: 18px 20px; border-radius: 16px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); font-size: 13.5px; line-height: 1.8; }

.auth-main { position: relative; display: flex; align-items: center; justify-content: center; padding: 40px 20px; background: var(--bg); overflow: hidden; }
.auth-card { width: 100%; max-width: 420px; animation: fade-up .55s var(--ease-out) both; position: relative; z-index: 2; }
.auth-card .brand { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; font-weight: 900; font-size: 19px; }
.auth-card .brand > span { display: inline-flex; align-items: center; gap: 9px; }
.auth-card .brand .logo-fallback, .auth-card .brand img { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; object-fit: contain; }
.auth-card h1 { font-size: 26px; margin-bottom: 8px; }
.auth-card .sub { color: var(--text-3); margin-bottom: 26px; font-size: 14.5px; line-height: 1.7; }
.auth-card .g_id_signin { display: flex; justify-content: center; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 22px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-points { display: grid; gap: 10px; margin: 22px 0; }
.auth-points div { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.auth-points .ico-svg { color: var(--success); flex-shrink: 0; }
.auth-form { display: grid; gap: 4px; margin-top: 4px; }
.auth-form .btn-block { margin-top: 10px; }
.link-sm { color: var(--primary); font-weight: 700; font-size: 13px; text-decoration: none; }
.link-sm:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  /* خلفية زخرفية للموبايل عشان الصفحة ما تبقاش فاضية */
  .auth-main::before { content: ""; position: absolute; top: -160px; inset-inline-end: -120px; width: 340px; height: 340px; border-radius: 50%; background: var(--grad); filter: blur(70px); opacity: .35; z-index: 0; }
  .auth-main::after { content: ""; position: absolute; bottom: -160px; inset-inline-start: -120px; width: 300px; height: 300px; border-radius: 50%; background: var(--primary-2); filter: blur(70px); opacity: .22; z-index: 0; }
  .auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 30px 24px; box-shadow: var(--shadow-lg); }
}

/* ==========================================================================
   زر تبديل الوضع
   ========================================================================== */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--btn-radius); border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; transition: border-color .14s ease, background .14s ease, color .14s ease; }
.app .theme-toggle, .auth-main .theme-toggle { border-color: var(--border); background: var(--surface); color: var(--text-2); }
.theme-toggle:hover { border-color: var(--primary-line); color: var(--primary); background: var(--primary-weaker); }
/* أيقونة واحدة بس في كل وضع: شمس في الفاتح، قمر في الغامق — تعتمد على [data-theme] اللي بيحطه سكربت الرأس دايمًا */
.theme-toggle .tt-sun, .theme-toggle .tt-moon { align-items: center; justify-content: center; line-height: 0; }
.theme-toggle .tt-sun { display: inline-flex !important; }
.theme-toggle .tt-moon { display: none !important; }
:root[data-theme="dark"] .theme-toggle .tt-sun,
.theme-toggle[data-mode="dark"] .tt-sun { display: none !important; }
:root[data-theme="dark"] .theme-toggle .tt-moon,
.theme-toggle[data-mode="dark"] .tt-moon { display: inline-flex !important; }

/* ==========================================================================
   مساعدات
   ========================================================================== */
.spinner { width: 22px; height: 22px; border: 2.5px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.card .spinner, .btn .spinner { border-color: var(--border-2); border-top-color: var(--primary); }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--border) 37%, var(--surface-3) 63%); background-size: 200% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }

@media print { .sidebar, .topbar, .btn, .no-print { display: none !important; } .app { display: block; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .content > *, .stat-grid .stat, .reveal { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* ==========================================================================
   منصة الطلبات — مكوّنات اللوحة وواجهة الدليفري
   ========================================================================== */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); margin-top: var(--gap); }
.grid-2 > .card { margin: 0; }
.grid-2 + .card, .card + .grid-2 { margin-top: var(--gap); }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 18px; margin-top: 14px; font-size: 14px; }
.kv-grid > div { display: flex; flex-direction: column; gap: 2px; }
.kv-grid .muted { font-size: 12px; }
.list-rows { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.seg label { padding: 7px 14px; border-radius: calc(var(--btn-radius) - 3px); font-size: 13px; font-weight: 700; color: var(--text-2); display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.seg label:has(input:checked) { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.seg label input { accent-color: var(--primary); }
.tabs-seg { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
select.multi { min-height: 150px; padding: 6px; }
select.multi option { padding: 6px 8px; border-radius: 6px; }
.pager { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.hint { font-size: 12px; }

/* الطلبات */
.pending-card { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.order-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.order-card { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--radius); border: 1.5px solid var(--border); background: var(--surface-2); transition: border-color .15s ease, transform .15s ease; }
.order-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.order-card.is-new { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); animation: pulse-border 2s ease infinite; }
@keyframes pulse-border { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 30%, transparent); } 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--danger) 10%, transparent); } }
.oc-top, .oc-bot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.oc-mid { font-size: 13px; color: var(--text-2); }
table.data tr.row-new td { background: color-mix(in srgb, var(--danger) 5%, transparent); }
table.data tr.row-removed td { opacity: .55; }
table.data tr.row-removed td strong { text-decoration: line-through; }
.order-actions .action-form { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.order-actions .action-form:first-child { padding-top: 0; }
.order-actions .action-form:last-of-type { border-bottom: 0; }
.order-actions .flex { flex-wrap: wrap; }
.order-actions select.input { flex: 1; min-width: 200px; }
.totals { max-width: 360px; margin: 14px 0 0 auto; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.totals > div { display: flex; justify-content: space-between; gap: 10px; }
.totals .grand { font-size: 17px; font-weight: 900; border-top: 1px solid var(--border); padding-top: 8px; }
.timeline { list-style: none; margin: 0; padding: 0 16px 0 0; border-inline-start: 2px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.timeline li { position: relative; font-size: 13.5px; display: flex; flex-direction: column; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -23px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); }
.timeline li .muted { font-size: 12px; }
.live-flash { animation: live-flash 1.2s ease; }
@keyframes live-flash { 0% { box-shadow: 0 0 0 3px var(--ring); } 100% { box-shadow: none; } }

/* الكتالوج */
.prod-cell { display: flex; align-items: center; gap: 10px; }
.prod-cell img, .prod-ph { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.toggle-pill { border: 1.5px solid var(--border-2); background: var(--surface-3); color: var(--muted); padding: 5px 12px; border-radius: 20px; font-family: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.toggle-pill.on { background: var(--success-weak); color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 12px 0; }
.gallery-item { display: flex; flex-direction: column; gap: 4px; font-size: 12px; cursor: pointer; }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.banner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.banner-item { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.banner-item img { width: 100%; aspect-ratio: 12 / 5; object-fit: cover; }
.banner-meta { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.hours-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.hours-day { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.hours-period { display: flex; align-items: center; gap: 6px; }
.hours-period .input { padding: 7px 8px; }
.check.is-locked { opacity: .55; cursor: not-allowed; }
.perm-table table.data { min-width: 480px; }
.perm-table td.center, .perm-table th.center { text-align: center; }
.gw-box, .ntf-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-top: 12px; background: var(--surface-2); }
.zone-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.zone-row .input:first-of-type { flex: 1; min-width: 160px; }
.big-switch { font-size: 15px; font-weight: 800; }
.notif-list { display: flex; flex-direction: column; }
.notif-item button { all: unset; box-sizing: border-box; display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 12px 10px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 10px; }
.notif-item button:hover { background: var(--surface-3); }
.notif-item.unread button { background: var(--primary-weaker); }
.notif-item.unread strong::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-inline-end: 6px; }
details.diff { margin-top: 6px; font-size: 12px; }
details.diff > div { margin-top: 3px; word-break: break-word; }
.bar-chart { display: block; overflow: visible; }
.bar-chart .bar { fill: var(--primary); opacity: .85; }
.bar-chart g:hover .bar { opacity: 1; fill: var(--primary-2); }
.bar-chart .bar-lbl { fill: var(--muted); font-size: 10px; font-family: inherit; }
.stat { color: inherit; }
a.stat:hover { border-color: var(--primary); }

/* الشريط العلوي: التنبيهات والجرس */
.install-app-btn[hidden] { display: none; }
@media (max-width: 640px) { .install-app-btn span { display: none; } }

/* ============ خانة كلمة المرور (إظهار/توليد) ============ */
.pw-field { display: flex; gap: 6px; align-items: center; }
.pw-field input { flex: 1; min-width: 0; }
.pw-field input[type="text"] { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .5px; direction: ltr; text-align: left; }
.pw-field .btn { flex: 0 0 auto; }

/* ============ عجلة الحظ والمسابقات ============ */
.wheel-preview { width: 190px; height: 190px; border-radius: 50%; flex: 0 0 auto; position: relative; box-shadow: 0 0 0 6px var(--surface), 0 0 0 7px var(--border), 0 10px 28px rgba(0,0,0,.12); margin: 8px auto; }
.wheel-preview > span { position: absolute; inset: 50% auto auto 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: var(--surface); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.tier-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 12px; align-items: end; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: var(--surface-2, var(--surface)); }
.tier-row .form-group { margin: 0; }
.tier-row[hidden] { display: none; }
/* محرر اختيارات المنتج (assets/js/options-editor.js) */
.opt-group { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: var(--surface-2, var(--surface)); }
.opt-group .input { background: var(--surface); }
.opt-head { display: flex; gap: 8px; align-items: center; }
.opt-head .opt-name { flex: 1; min-width: 0; font-weight: 800; }
.opt-tools { display: flex; gap: 4px; flex-shrink: 0; }
.opt-settings { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; margin: 10px 0 12px; }
.opt-settings .form-group { margin: 0; min-width: 150px; flex: 0 1 220px; }
.opt-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--text-2); cursor: pointer; white-space: nowrap; min-height: 40px; }
.opt-check input { width: 17px; height: 17px; accent-color: var(--primary); margin: 0; }
.opt-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto 36px; gap: 8px; align-items: center; margin-bottom: 6px; }
.opt-row-head { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.opt-flags { display: flex; gap: 12px; }
.opt-remove { padding-inline: 0; width: 36px; justify-content: center; }
.opt-hint { margin: 8px 0 0; }
.opt-add { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-error { margin: 10px 0 0; }
.opt-head-label { font-size: 13px; font-weight: 800; color: var(--text-2); white-space: nowrap; }
.opt-presets { display: flex; gap: 2px; flex-wrap: wrap; }
.opt-variant .opt-head { flex-wrap: wrap; }
.opt-variant .opt-head .opt-name { max-width: 260px; }
.opt-images { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -2px 0 6px; }
.opt-images-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.opt-images-hint { font-size: 11.5px; color: var(--muted); }
.opt-thumb { position: relative; width: 44px; height: 44px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface) center / cover no-repeat; flex-shrink: 0; }
.opt-thumb.uploading { background-image: none !important; opacity: .6; }
.opt-thumb.uploading::after { content: ''; position: absolute; inset: 12px; border: 2px solid var(--primary); border-top-color: transparent; border-radius: 50%; animation: optspin .8s linear infinite; }
@keyframes optspin { to { transform: rotate(360deg); } }
.opt-thumb-x { position: absolute; top: -6px; inset-inline-end: -6px; width: 20px; height: 20px; min-height: 0; padding: 0; border-radius: 50%; font-size: 11px; line-height: 1; justify-content: center; background: var(--danger); color: #fff; border: 0; }
.opt-thumb-add { display: inline-flex; align-items: center; justify-content: center; width: auto; min-width: 58px; padding: 0 8px; border-style: dashed; color: var(--primary); font-size: 12px; font-weight: 800; cursor: pointer; background: var(--primary-weaker); }
.bundle-row .bundle-opts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; }
.bundle-row .bundle-opts[hidden] { display: none; }
.bundle-opts .form-group { margin: 0; min-width: 170px; flex: 0 1 240px; }
/* محرر منتجات الهدية في عجلة الحظ (assets/js/gift-editor.js) */
.gift-row { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--surface-2, var(--surface)); }
.gift-row-head { display: flex; gap: 8px 12px; align-items: flex-end; flex-wrap: wrap; }
.gift-row .form-group { margin: 0; }
.gift-pick { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.gift-pick .gift-count:empty { display: none; }
.gift-qty { flex: 0 0 96px; }
.gift-remove { flex-shrink: 0; min-height: 44px; }
.gift-remove[hidden] { display: none; }
.gift-opts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; }
.gift-opts[hidden] { display: none; }
.gift-opts > .hint { flex-basis: 100%; margin: 0; }
.gift-flags { flex-wrap: wrap; gap: 4px 14px; }
@media (max-width: 720px) {
  .opt-row { grid-template-columns: minmax(0, 1fr) 96px 36px; }
  .opt-row .opt-flags { grid-column: 1 / -1; grid-row: 2; margin-top: -4px; }
  .opt-row-head span:nth-child(n+3) { display: none; }
  .opt-settings .form-group { flex-basis: 100%; }
}
.alerts-toggle, .bell-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--btn-radius); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.alerts-toggle .at-on { display: none; } .alerts-toggle .at-off { display: inline-flex; color: var(--danger); }
.alerts-toggle.is-on .at-on { display: inline-flex; color: var(--success); } .alerts-toggle.is-on .at-off { display: none; }
.alerts-toggle.is-off { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
/* مفعّلة والمتصفح مستني أول ضغطة في الصفحة — مش "مقفول"، فمن غير أحمر */
.alerts-toggle.is-wait .at-on { display: inline-flex; color: var(--text-2); opacity: .7; } .alerts-toggle.is-wait .at-off { display: none; }
.bell-count { position: absolute; top: -5px; inset-inline-end: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 20px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.alerts-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px clamp(16px, 4vw, 30px); background: var(--warning-weak); color: color-mix(in srgb, var(--warning) 50%, #40300a); font-size: 13.5px; font-weight: 700; border-bottom: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); }
:root[data-theme="dark"] .alerts-banner { color: var(--warning); }
.alerts-banner[hidden] { display: none; }
.sticky-actions { margin-top: 16px; }

/* واجهة الدليفري */
body.is-delivery .content { max-width: 760px; }
.avail-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-radius: var(--radius-lg); border: 2px solid var(--border-2); background: var(--surface); margin-bottom: 14px; }
.avail-card.on { border-color: var(--success); background: color-mix(in srgb, var(--success) 7%, var(--surface)); }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.trip-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm); }
.trip-card.status-ready { border-color: var(--primary); }
.trip-card.status-out_for_delivery { border-color: var(--success); }
.trip-card.status-failed { border-color: var(--danger); opacity: .85; }
.trip-main { display: flex; flex-direction: column; gap: 4px; }
.trip-num { font-size: 20px; font-weight: 900; }
.trip-name { font-weight: 800; font-size: 15px; }
.trip-addr { font-size: 13px; }
.pay-cash { display: inline-block; font-weight: 900; font-size: 16px; color: var(--text); background: var(--warning-weak); padding: 4px 12px; border-radius: 10px; }
.pay-paid { display: inline-block; font-weight: 800; font-size: 14px; color: var(--success); background: var(--success-weak); padding: 4px 12px; border-radius: 10px; }
.collect-box { margin-top: 12px; padding: 14px; border-radius: var(--radius); background: var(--warning-weak); font-size: 16px; text-align: center; }
.collect-box strong { font-size: 22px; }
.collect-box.paid { background: var(--success-weak); color: var(--success); font-weight: 800; }
.btn-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.code-input { font-size: 26px !important; letter-spacing: .4em; text-align: center; font-weight: 900; }
.print-only { display: none; }

/* الموبايل: الجداول بتتحوّل كروت، والفلاتر ورا زرار، والأزرار المهمة ثابتة تحت */
.filter-toggle { display: none; }
@media (max-width: 720px) {
  .content { padding: 14px 12px 90px; }
  .card, .dash-card { padding: 16px; border-radius: var(--radius); }
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar .page-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-chip .uc-text { display: none; }
  .user-chip { padding: 4px; }
  .filter-toggle { display: inline-flex; margin-bottom: 8px; }
  form[data-collapsible] { display: none; }
  form[data-collapsible].open { display: flex; }
  .filter-bar > * { flex: 1 1 100%; }
  .card-head { align-items: stretch; }
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  table.data.responsive { min-width: 0; }
  table.data.responsive thead { display: none; }
  table.data.responsive, table.data.responsive tbody, table.data.responsive tr, table.data.responsive td { display: block; width: 100%; }
  table.data.responsive tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; padding: 8px 12px; }
  table.data.responsive td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: start; }
  table.data.responsive td[data-label]::before { content: attr(data-label); font-size: 12px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
  table.data.responsive td[data-label=""]::before { display: none; }
  table.data.responsive td.cell-empty { justify-content: center; }
  table.data.responsive td.cell-empty::before { display: none; }
  table.data.responsive tbody tr:hover { background: var(--surface); }
  .perm-table table.data.responsive td { justify-content: flex-start; }
  .sticky-actions, .order-actions { position: sticky; bottom: 0; z-index: 40; }
  .sticky-actions { background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); padding: 10px 0; margin: 12px -12px 0; padding-inline: 12px; }
  .order-actions { box-shadow: 0 -8px 24px rgba(0, 0, 0, .08); }
  .btn-lg { padding: 16px 22px; font-size: 16.5px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat-num { font-size: 22px; }
  .totals { max-width: none; }
  dialog.modal { max-width: calc(100vw - 24px); }
}
@media print {
  .alerts-banner, .filter-toggle, dialog, .pager { display: none !important; }
  .print-only { display: block; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .content { padding: 0; max-width: none; }
}
