/* =========================================================
   مظهر نظام مسارات أزل — الألوان متغيرات تُضبط من الإعدادات ← المظهر
   الهوية: أخضر الشركة + ذهبي الديزل، وزخرفة «الطريق بثلاثة مسارات»
   وخط الطريق المتقطع (علامة الطريق) كعلامة للعنصر النشط
   ========================================================= */
:root {
  --primary: #174A3A;
  --accent: #D4A72C;
  --silver: #D9DEE1;
  --text: #1F2A2E;
  --muted: #66737A;
  --positive: #2E7D5B;
  --danger: #B94A48;
  --warn: #A86B12;
  --radius: 14px;
  --r-sm: 10px;
  --font: 'IBM Plex Sans Arabic', 'Tajawal', system-ui, Tahoma, sans-serif;

  --bg: #EDF1EF;
  --surface: #FFFFFF;
  --surface-2: #F4F7F5;
  --border: #DCE3E0;
  --on-primary: #FFFFFF;
  --shadow: 0 1px 2px rgba(16, 40, 32, .05);
  --float: 0 12px 40px rgba(12, 34, 27, .18);
  --sidebar-w: 236px;
  --dash: repeating-linear-gradient(var(--dash-dir, 180deg), var(--accent) 0 7px, transparent 7px 13px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
:root[data-mode="dark"] {
  --bg: #0E1613;
  --surface: #16201C;
  --surface-2: #1B2723;
  --border: #29372F;
  --text: #E3EAE6;
  --muted: #93A29C;
  --shadow: none;
  --float: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
:root[data-mode="light"] { color-scheme: light; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
:root[data-mode="dark"] a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* الأيقونات */
.ic { display: inline-flex; line-height: 0; flex: none; }
.ic svg { display: block; }
button .ic, button .lbl, a.btn .ic, a.btn .lbl { pointer-events: none; }
.st-ok { color: var(--positive); vertical-align: -3px; }
.st-warn { color: var(--warn); vertical-align: -3px; }

/* ---------- الهيكل ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--primary); color: var(--on-primary); padding: 18px 12px 14px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow: hidden; isolation: isolate;
}
.lanes { position: absolute; pointer-events: none; z-index: -1; line-height: 0; }
.lanes svg { width: 100%; height: 100%; fill: none; }
.lanes .edge { stroke: rgba(255, 255, 255, .13); stroke-width: 2; }
.lanes .lane { stroke: var(--accent); stroke-width: 2.4; stroke-dasharray: 10 12; opacity: .55; }
.lanes .far { stroke: rgba(255, 255, 255, .07); stroke-width: 1.4; }
.lanes.l-side { inset: auto 0 0 0; height: 300px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand img { width: 42px; height: 42px; object-fit: contain; border-radius: 12px; background: rgba(255,255,255,.1); padding: 3px; }
.brand .logo-fallback { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: var(--primary); font-weight: 700; font-size: 20px; }
.brand b { display: block; color: var(--accent); font-size: 17px; font-weight: 700; line-height: 1.3; }
.brand small { opacity: .65; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px;
  color: rgba(255,255,255,.78); text-decoration: none; font-weight: 500; transition: background .15s;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,.11); color: #fff; font-weight: 600; }
/* علامة الطريق المتقطعة بجانب العنصر النشط */
.nav a.active::before { content: ''; position: absolute; inset-inline-start: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 2px; background: var(--dash); }
.nav a.active .ic { color: var(--accent); }
.sidebar .foot { margin-top: auto; font-size: 12px; opacity: .6; padding: 8px; word-break: break-all; }

.brand.mini { display: none; padding: 0; }
.brand.mini img, .brand.mini .logo-fallback { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 26px; min-height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; font-weight: 700; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: inherit; text-decoration: none; }
.topbar .back:hover { background: var(--surface-2); }
.content { padding: 22px 26px 48px; max-width: 1680px; width: 100%; }
.bottom-nav, .fab { display: none; }

/* تابلت: القائمة الجانبية تصير شريط أيقونات لتوفير مساحة للجداول */
@media (min-width: 861px) and (max-width: 1439px) {
  :root { --sidebar-w: 78px; }
  .sidebar { padding: 14px 10px; align-items: center; }
  .brand { padding: 2px 0 18px; }
  .brand > div { display: none; }
  .nav { width: 100%; }
  .nav a { justify-content: center; padding: 12px 0; }
  .nav a .t { display: none; }
  .sidebar .foot { display: none; }
  .lanes.l-side { height: 240px; }
  .content { padding: 18px 18px 40px; }
  .topbar { padding: 10px 18px; }
}

/* جوال: شريط علوي بلون الشركة + قائمة سفلية + زر عائم — مثل التطبيقات */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar {
    padding: calc(var(--safe-t) + 8px) 14px 10px; min-height: calc(56px + var(--safe-t));
    background: var(--primary); color: var(--on-primary); border-bottom: 0;
  }
  /* خط الطريق المتقطع أسفل الشريط */
  .topbar::after { content: ''; position: absolute; inset-inline: 0; bottom: 0; height: 2px; --dash-dir: 90deg; background: var(--dash); opacity: .7; }
  .topbar h1 { font-size: 18px; }
  .topbar .back:hover { background: rgba(255,255,255,.1); }
  .brand.mini { display: flex; }
  .topbar .back:not([hidden]) + .brand.mini { display: none; }
  .content { padding: 14px 14px calc(96px + var(--safe-b)); }
  .bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + var(--safe-b));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; -webkit-user-select: none; user-select: none; }
  .bottom-nav .pill { display: grid; place-items: center; width: 48px; height: 30px; border-radius: 16px; transition: background .15s; }
  .bottom-nav a.active { color: var(--primary); font-weight: 600; }
  .bottom-nav a.active .pill { background: color-mix(in srgb, var(--primary) 13%, transparent); }
  :root[data-mode="dark"] .bottom-nav a.active { color: var(--accent); }
  :root[data-mode="dark"] .bottom-nav a.active .pill { background: color-mix(in srgb, var(--accent) 16%, transparent); }
  .fab {
    display: grid; place-items: center; position: fixed; inset-inline-end: 16px; bottom: calc(76px + var(--safe-b)); z-index: 21;
    width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--primary); box-shadow: var(--float); cursor: pointer;
  }
  .fab[hidden] { display: none; }
  .fab:active { transform: scale(.94); }
  /* لمس مريح ومنع تكبير iOS عند الكتابة */
  .input, select.input, textarea.input, .ginp { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 32px; }
  .btn, .tabs a, .seg button, .nav a { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
}

/* ---------- عناصر عامة ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid > .card, .pt-cards > .card { margin-top: 0; }
.card h2 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
b.row { display: inline-flex; gap: 6px; }
.grow { flex: 1; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; position: relative; }
.stat .n { font-size: 24px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
a.stat:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
:root[data-mode="dark"] .stat .n { color: var(--accent); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: var(--r-sm);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 500; white-space: nowrap;
  color: var(--text); text-decoration: none; transition: background .12s, transform .08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.accent { background: var(--accent); color: #1E1A0C; border-color: var(--accent); }
.btn.accent:hover { filter: brightness(1.05); }
.btn.on-dark { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.btn.on-dark:hover { background: rgba(255,255,255,.2); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; font-size: 13px; gap: 5px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
textarea.input { min-height: 80px; resize: vertical; }
label.field, div.field { display: block; margin-bottom: 12px; }
label.field > span, .f-l { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
label.field .req { color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 22px; background: var(--silver); position: relative; cursor: pointer; transition: .15s; margin: 0; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--positive); }
.switch input:checked::after { right: 19px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 20px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.up { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.badge.down { color: var(--positive); border-color: color-mix(in srgb, var(--positive) 35%, transparent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--positive); }
.dot.off { background: var(--silver); }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { background: var(--surface-2); text-align: start; font-weight: 600; font-size: 13px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.off td { opacity: .5; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t td.first { font-weight: 600; white-space: nowrap; }
table.t th.num { text-align: end; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 0 8px; border-radius: 20px; background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
:root[data-mode="dark"] .chip { color: var(--accent); }
table.t td.actions { white-space: nowrap; text-align: end; width: 1%; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* جدول العمليات يتسع للشاشة: النصوص تلتف، والخط يصغر تلقائياً إذا لزم بدل السحب يميناً ويساراً */
table.t.fit th { white-space: normal; line-height: 1.3; vertical-align: bottom; }
table.t.fit td { white-space: normal; overflow-wrap: break-word; line-height: 1.45; }
table.t.fit td.num, table.t.fit td.idc { white-space: nowrap; }
table.t.fit td.desc { min-width: 150px; }
table.t.fit td.c-ic { text-align: center; }
table.t.fit.dense { font-size: 12.5px; }
table.t.fit.dense th { font-size: 11.5px; padding: 8px 6px; }
table.t.fit.dense td { padding: 7px 6px; }
table.t.fit.dense td.desc { min-width: 120px; }
table.t.fit.dense .tbadge, table.t.fit.dense .badge { font-size: 11.5px; padding: 0 7px; }
table.t.fit.denser { font-size: 11.5px; }
table.t.fit.denser th { font-size: 10.5px; padding: 6px 4px; }
table.t.fit.denser td { padding: 5px 4px; }
table.t.fit.denser td.desc { min-width: 100px; }

/* ---------- التبويبات ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 20px; text-decoration: none; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); white-space: nowrap; font-size: 14px;
}
.tabs a .ic { color: var(--muted); }
.tabs a.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tabs a.active .ic { color: var(--accent); }
.tdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.tdot.sale { background: var(--positive); } .tdot.buy { background: #2F6FB0; } .tdot.money { background: var(--accent); }
.tdot.settle { background: #8A9599; } .tdot.warn { background: var(--warn); }

/* ---------- النوافذ والتنبيهات ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(8, 20, 15, .48); display: grid; place-items: center; grid-template-columns: minmax(0, 1fr); justify-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; width: min(640px, 100%); min-width: 0; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--float); }
.modal header { padding: 14px 18px 14px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.modal header .x { margin-inline-start: auto; padding: 6px; }
.modal .body { padding: 18px 20px; overflow: auto; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 12px; box-shadow: var(--float); max-width: 380px; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--positive); color: #fff; }
@media (max-width: 860px) {
  .toasts { bottom: calc(84px + var(--safe-b)); left: 14px; right: 14px; }
  /* النوافذ على الجوال تطلع من الأسفل مثل التطبيقات */
  .modal-back { padding: 0; place-items: end center; align-items: end; }
  .modal { width: 100%; border-radius: 20px 20px 0 0; max-height: calc(100vh - var(--safe-t) - 24px); animation: sheet-up .22s ease-out; }
  .modal::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 8px auto 0; }
  .modal footer { padding-bottom: calc(12px + var(--safe-b)); }
  .modal.full { height: 100vh; height: 100dvh; max-height: 100dvh; border-radius: 0; padding-top: var(--safe-t); }
  .modal.full::before { display: none; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } .btn, .fab { transition: none; } }

.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.logo-box { width: 120px; height: 120px; border: 1px dashed var(--border); border-radius: var(--radius); display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.logo-box img { max-width: 100%; max-height: 100%; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; }
.seg button.on { background: var(--primary); color: var(--on-primary); }
.soon { text-align: center; padding: 50px 20px; }

/* ---------- الرئيسية ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  background: var(--primary); color: #fff; border-radius: 20px; padding: 22px 26px; margin-bottom: 16px; min-height: 150px;
}
.lanes.l-hero { inset-block: 0; inset-inline-start: 34%; width: 340px; }
.hero-text { flex: 1; min-width: 220px; }
.hero-text small { color: var(--accent); font-weight: 600; }
.hero-text h2 { margin: 2px 0 4px; font-size: 26px; font-weight: 700; line-height: 1.25; }
.hero-text p { margin: 0; opacity: .78; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .hero { padding: 18px; border-radius: 18px; }
  .hero-text h2 { font-size: 22px; }
  .lanes.l-hero { width: 220px; opacity: .55; }
}

/* ---------- العمليات ---------- */
.modal.wide { width: min(880px, 100%); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters .f-q { flex: 1 1 240px; }
.filters .f-d { display: flex; align-items: center; gap: 6px; }
.filters .f-d span { font-size: 13px; color: var(--muted); }
.filters .f-d input { width: 150px; }
.filters select.input { width: auto; }
.totals { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 14px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; color: var(--muted); }
.totals b { color: var(--text); font-variant-numeric: tabular-nums; }
.num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
td.desc { min-width: 200px; }
td.idc { white-space: nowrap; font-size: 12.5px; }
.pos-up { color: var(--danger); }
.pos-down { color: var(--positive); }
.warn { margin-inline-start: 4px; cursor: help; }
tr.date-row td { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); font-weight: 600; font-size: 12.5px; padding: 6px 12px; color: var(--primary); }
:root[data-mode="dark"] tr.date-row td { color: var(--accent); }
tr.opening td { background: var(--surface-2); font-weight: 600; }
tr.op { cursor: pointer; }
.tbadge { display: inline-block; padding: 1px 9px; border-radius: 20px; font-size: 12.5px; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--border); }
.tbadge.sale { background: color-mix(in srgb, var(--positive) 12%, transparent); border-color: transparent; color: var(--positive); }
.tbadge.buy { background: color-mix(in srgb, #2F6FB0 12%, transparent); border-color: transparent; color: #2F6FB0; }
.tbadge.money { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: transparent; color: #7D5F0B; }
.tbadge.settle { background: color-mix(in srgb, var(--muted) 14%, transparent); border-color: transparent; }
:root[data-mode="dark"] .tbadge.money { color: var(--accent); }
:root[data-mode="dark"] .tbadge.buy { color: #7FB0E6; }

.op-cards { display: none; flex-direction: column; gap: 8px; }
.op-cards.always { display: flex; }
.op-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; cursor: pointer; }
.op-card:active { background: var(--surface-2); }
.op-card .l1 { display: flex; align-items: center; gap: 8px; }
.op-card .l1 a { text-decoration: none; }
.op-card .l2 { font-size: 13.5px; margin: 4px 0; }
.op-card .l3 { display: flex; gap: 10px; font-size: 12.5px; flex-wrap: wrap; align-items: center; }
.op-card.opening { display: flex; justify-content: space-between; cursor: default; background: var(--surface-2); }
.date-sep { font-weight: 600; font-size: 12.5px; color: var(--primary); margin-top: 6px; }
:root[data-mode="dark"] .date-sep { color: var(--accent); }
@media (max-width: 860px) {
  .ops-table { display: none; }
  .op-cards { display: flex; }
  .filters .f-d input { width: 135px; }
}

/* نموذج العملية */
.combo { position: relative; }
.combo-menu { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--float); max-height: 260px; overflow: auto; }
.combo-opt { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.combo-opt:hover, .combo-opt.on { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.op-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) { .op-grid { grid-template-columns: 1fr 1fr; } }
.op-grid [hidden], .field[hidden] { display: none !important; }
.op-summary { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-top: 4px; }
.sum-grid { display: flex; flex-wrap: wrap; gap: 8px 26px; }
.sum-grid > div { display: flex; flex-direction: column; }
.sum-grid small { color: var(--muted); font-size: 12px; }
.sum-grid b { font-size: 17px; font-variant-numeric: tabular-nums; }
.missing { margin-top: 8px; color: var(--warn); font-size: 13.5px; }
details.more { margin: 4px 0 12px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }
.modal footer .grow { flex: 1; }
.op-info { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 12px; margin-bottom: 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; color: var(--muted); }
.op-info b { color: var(--text); font-weight: 600; }
.input.calc { background: var(--surface-2); color: var(--muted); cursor: default; }

/* ---------- الأطراف ---------- */
.avatar { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); font-weight: 700; font-size: 18px; }
:root[data-mode="dark"] .avatar { color: var(--accent); }
.avatar.lg { width: 58px; height: 58px; border-radius: 16px; font-size: 26px; background: var(--primary); color: var(--accent); }
.party-hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.party-hero h2 { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.3; }
.party-hero .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; font-size: 13.5px; }
.party-hero .hero-actions { margin-inline-start: auto; }
.pt-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 14px; }
.pt-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 13px; overflow: hidden; }
.pt-card::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--pt-accent, var(--accent)); }
.pt-card small { display: block; color: var(--muted); font-size: 13px; }
.pt-card b { display: block; font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.35; margin-top: 2px; }
.pt-card .sub { font-size: 12.5px; color: var(--muted); }
.pt-card.bal.in b, .pt-card.in b { color: var(--positive); }
.pt-card.bal.out b, .pt-card.out b { color: var(--danger); }
.pt-card.bal.in::before, .pt-card.in::before { background: var(--positive); }
.pt-card.bal.out::before, .pt-card.out::before { background: var(--danger); }
.pt-card.bal .sub { font-weight: 600; }
.pt-card.bal.in .sub { color: var(--positive); } .pt-card.bal.out .sub { color: var(--danger); }
.party-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.party-tile { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: inherit; }
.party-tile:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.party-tile.off { opacity: .55; }
.party-tile .pt-top { display: flex; gap: 10px; align-items: center; }
.party-tile .pt-top b { display: block; line-height: 1.35; }
.party-tile .pt-top small { font-size: 12.5px; }
.pt-bal { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.pt-bal b { font-size: 19px; font-variant-numeric: tabular-nums; }
.pt-bal small { font-size: 12.5px; color: var(--muted); }
.pt-bal.in b, .pt-bal.in small { color: var(--positive); }
.pt-bal.out b, .pt-bal.out small { color: var(--danger); }
@media (max-width: 860px) {
  .party-hero { gap: 12px; }
  .party-hero h2 { font-size: 20px; }
  .party-hero .hero-actions { margin-inline-start: 0; width: 100%; }
  .party-hero .hero-actions .btn { flex: 1; }
  .pt-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pt-card { padding: 11px 12px; }
  .pt-card b { font-size: 18px; }
  .pt-card.bal { grid-column: 1 / -1; }
  .party-grid { grid-template-columns: 1fr; }
}

/* قالب صفحة الطرف (من قوالب صفحات الأطراف) */
.ptpl table.t { font-family: var(--pt-font, var(--font)); font-size: var(--pt-size, 14px); color: var(--pt-text, inherit); }
.ptpl table.t th { background: var(--pt-head, var(--surface-2)); color: var(--pt-head-text, var(--muted)); }
.ptpl tr.date-row td { background: var(--pt-date, color-mix(in srgb, var(--primary) 6%, var(--surface))); }
.ptpl.has-stripe tr.op:nth-child(even) td { background: var(--pt-stripe); }
.ptpl .pt-card b { font-family: var(--pt-font, var(--font)); }
.ptpl.d-compact table.t td { padding-block: 5px; }
.ptpl.d-comfy table.t td { padding-block: 13px; }
.ptpl table.t.fit.dense { font-size: calc(var(--pt-size, 14px) - 1.5px); }
.ptpl table.t.fit.denser { font-size: calc(var(--pt-size, 14px) - 2.5px); }

/* محرر القوالب */
.tpl-editor { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 18px; height: 100%; min-height: 0; }
.tpl-form, .tpl-side { overflow: auto; min-height: 0; }
.tpl-form { padding-inline-end: 6px; }
.tpl-side { background: var(--bg); border-radius: var(--radius); padding: 12px; }
.tpl-preview { margin-top: 8px; }
.w-in { width: 84px; padding: 5px 8px; font-size: 13px; }
.c-opt { margin: 6px 0; }
.c-opt input[type=checkbox] { width: 16px; height: 16px; }
.chk-list { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.tpl-pick { width: 100%; background: transparent; border: 0; text-align: start; cursor: pointer; padding: 11px 8px; align-items: center; }
.tpl-pick.on { color: var(--primary); font-weight: 600; }
@media (max-width: 860px) { .tpl-editor { grid-template-columns: 1fr; height: auto; } .tpl-side { order: -1; } }

/* اللوحة */
.warn-card { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.warn-card .n { color: var(--warn); }
.dash-cols { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; margin-top: 16px; align-items: start; }
.dash-cols .card + .card { margin-top: 0; }
@media (max-width: 860px) { .dash-cols { grid-template-columns: 1fr; } .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .stat .n { font-size: 19px; } .card.stat { padding: 13px; } }
.bal-list { display: flex; flex-direction: column; }
.bal-row { display: flex; gap: 8px; padding: 10px 4px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.bal-row:last-child { border-bottom: 0; }
.bal-row:hover { background: var(--surface-2); }

/* ---------- الجدول الجماعي ---------- */
.modal.full { width: min(1500px, 100%); height: calc(100vh - 32px); height: calc(100dvh - 32px); }
.modal.full .body { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
/* الجدول ياخذ باقي ارتفاع النافذة ويتحرك لحاله (فوق/تحت ويمين/يسار) */
.modal.full .body > div { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.modal.full .body > div > * { flex-shrink: 0; }
.modal.full .body > div > .grid-wrap, .modal.full .body > div > .grid-box { flex: 1 1 auto; flex-shrink: 1; }
.grid-box { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.grid-box > .grid-wrap { flex: 1; }
.grid-wrap { flex: 1; overflow: auto; min-width: 0; min-height: 0; max-width: 100%; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.grid-wrap thead th { position: sticky; top: 0; z-index: 2; }
.gtools { margin-bottom: 6px; }
table.gtable td { padding: 2px 3px; }
table.gtable th { padding: 8px 6px; font-size: 13px; }
.ginp { width: 100%; border: 1px solid var(--border); background: var(--surface-2); padding: 6px 6px; border-radius: 6px; outline: none; font-size: 14px; }
.ginp:focus { border-color: var(--primary); background: var(--surface); }
.ginp.na { opacity: .35; }
.ginp.changed { background: color-mix(in srgb, var(--accent) 22%, transparent); }
tr.dirty td.gnum { box-shadow: inset -3px 0 0 var(--accent); }
tr.err td { background: color-mix(in srgb, var(--danger) 12%, transparent); }
td.gnum { color: var(--muted); font-size: 12px; text-align: center; white-space: nowrap; }
td.gcalc { font-size: 13px; color: var(--muted); }
td.gmiss { text-align: center; cursor: help; }
td.gact { white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.sel-bar { position: sticky; top: 64px; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; margin-bottom: 10px; border-radius: var(--radius); background: var(--primary); color: var(--on-primary); }
.sel-bar .btn { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
.sel-bar .btn.danger { background: var(--danger); }
td.sel, .op-card .sel { width: 1%; }
.op-card .sel { margin-inline-end: 4px; }
.ord-btns { display: inline-flex; gap: 2px; }
.ord-btns .btn { padding: 2px 6px; }
@media (max-width: 860px) { .sel-bar { top: calc(58px + var(--safe-t)); } .toolbar { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; } .toolbar::-webkit-scrollbar { display: none; } }

/* ---------- المرفقات ---------- */
.files-sec { border: 1px dashed var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.fchips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.fchip { display: flex; align-items: flex-start; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.fchip a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: inherit; width: 92px; }
.fchip img { width: 92px; height: 70px; object-fit: cover; border-radius: 6px; }
.fchip .ficon { width: 92px; height: 70px; display: grid; place-items: center; color: var(--muted); }
.fchip small { font-size: 11px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip { margin-inline-start: 3px; color: var(--muted); vertical-align: -3px; }
.col-list { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow: auto; }
.col-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 8px; }
.col-row:hover { background: var(--surface-2); }
.miss-cell { color: var(--warn); font-size: 12.5px; cursor: help; }
.ok-cell { font-size: 12px; }
.op-grid .field.wide { grid-column: 1 / -1; }
.field.need > span::after { content: ' *'; color: var(--danger); }
.input.bad { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent); }
.doc-dup { color: var(--danger); font-weight: 600; }

/* ---------- مصمم الكشوف ---------- */
.designer-frame { width: 100%; height: calc(100vh - 150px); min-height: 520px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: block; }
@media (max-width: 860px) { .designer-frame { height: calc(100vh - 190px - var(--safe-t) - var(--safe-b)); } }

.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.danger-zone h2 { color: var(--danger); }

/* الاستهلاك */
.meters { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.meter-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.meter { height: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: 10px 0 8px; }
.meter i { display: block; height: 100%; background: var(--positive); border-radius: 10px; }
.meter.warn i { background: var(--warn); } .meter.bad i { background: var(--danger); }
.fchip.archived { border-style: dashed; }
.fchip.archived small { color: var(--primary); }
.code-box { direction: ltr; text-align: left; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px; max-height: 220px; overflow: auto; white-space: pre; }
.progress { height: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: 8px 0; }
.progress i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* ---------- الدخول ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b)); background: var(--primary); position: relative; overflow: hidden; isolation: isolate; }
.login .lanes.l-hero { inset-inline-start: auto; inset-inline-end: -40px; width: 360px; opacity: .9; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: calc(var(--radius) + 6px); padding: 28px 24px 22px; box-shadow: var(--float); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-brand img, .login-brand .logo-fallback { width: 48px; height: 48px; border-radius: 13px; object-fit: contain; display: grid; place-items: center; background: var(--accent); color: var(--primary); font-weight: 700; font-size: 22px; }
.login-brand b { display: block; font-size: 18px; }
.login-brand small { color: var(--muted); }
.login h1 { font-size: 20px; margin: 0 0 16px; display: flex; align-items: center; gap: 6px; }
.login .field { display: block; margin-bottom: 14px; }
.login .field > span { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.login .input { width: 100%; font-size: 16px; padding: 12px 14px; }
.login .code-in { font-size: 26px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.btn.block { width: 100%; justify-content: center; padding: 12px; font-size: 16px; }
.login-hello { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; margin: 0 0 14px; }
.login-err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.login-links { justify-content: space-between; margin-top: 10px; }
.login-help { margin: 16px 0 0; text-align: center; }

/* زر الخروج في القائمة الجانبية */
.sidebar .foot { display: flex; align-items: center; gap: 4px; }
.sidebar .foot .logout { color: inherit; padding: 4px; opacity: 1; }

/* خطوات مرقمة */
ol.steps { margin: 10px 0; padding-inline-start: 22px; line-height: 1.9; }
ol.steps li { padding-inline-start: 2px; }

/* المستخدمين */
.users { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); flex-wrap: wrap; }
.user-row.off { opacity: .55; }
.user-av { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 700; font-size: 18px; }
.user-row .grow { flex: 1; min-width: 180px; }
.user-row .small, .muted.small { font-size: 13px; margin-top: 2px; }
.user-act { gap: 6px; flex-wrap: wrap; }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
@media (max-width: 600px) { .user-act { width: 100%; } }
@media (min-width: 861px) and (max-width: 1439px) {
  .sidebar .foot { display: flex; justify-content: center; padding: 8px 0; }
  .sidebar .foot .grow { display: none; }
}

/* أوقات النسخ التلقائي */
.hours { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; margin-top: 4px; }
.hour { border: 1px solid var(--border); background: var(--surface); color: inherit; border-radius: var(--r-sm); padding: 8px 4px; font: inherit; font-size: 13px; cursor: pointer; }
.hour.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
table.t td.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t .input.sm { padding: 6px 8px; min-width: 120px; font-size: 14px; }

/* ---------- المخازن ---------- */
.wh-tabs .wh-pct { opacity: .7; font-size: 11px; margin-inline-start: 4px; }
.stock-hero { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); padding: 18px; margin-bottom: 16px; align-items: center; }
.tank-box { display: grid; place-items: center; }
.tank { position: relative; width: 200px; }
.tank svg { width: 100%; height: auto; display: block; overflow: visible; }
.tank .shell { fill: var(--surface-2); stroke: color-mix(in srgb, var(--text) 22%, transparent); stroke-width: 3; }
.tank .cap, .tank .leg { fill: color-mix(in srgb, var(--text) 30%, var(--surface)); }
.tank .liquid { transition: transform 1.2s cubic-bezier(.2,.8,.2,1); }
.tank .liq-a { stop-color: color-mix(in srgb, var(--accent) 85%, #fff); }
.tank .liq-b { stop-color: color-mix(in srgb, var(--accent) 80%, #6b4a00); }
.tank.low .liq-a { stop-color: #e58a7f; } .tank.low .liq-b { stop-color: var(--danger); }
.tank .wave { animation: tank-wave 5s linear infinite; }
.tank .wave.w2 { animation-duration: 7s; animation-direction: reverse; }
@keyframes tank-wave { from { transform: translateX(0); } to { transform: translateX(140px); } }
@media (prefers-reduced-motion: reduce) { .tank .wave, .tank .liquid { animation: none; transition: none; } }
.tank .tick { stroke: color-mix(in srgb, var(--text) 35%, transparent); stroke-width: 1.5; }
.tank .tick-t { font-size: 10px; fill: color-mix(in srgb, var(--text) 55%, transparent); font-family: var(--font); }
.tank-label { position: absolute; inset: 22% 0 auto 0; text-align: center; display: grid; gap: 2px; pointer-events: none; }
.tank-label b { font-size: 34px; line-height: 1; color: var(--text); text-shadow: 0 1px 0 var(--surface); font-variant-numeric: tabular-nums; }
.tank-label span { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.tank-label small { color: var(--muted); font-size: 12px; }
.stock-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stock-head h2 { margin: 0 0 2px; font-size: 22px; }
.st-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.st-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.st-card .st-ic { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
.st-card small { display: block; color: var(--muted); font-size: 12.5px; }
.st-card b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.st-card .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.st-card.main { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.st-card.in .st-ic { background: color-mix(in srgb, var(--positive) 14%, transparent); color: var(--positive); }
.st-card.out .st-ic { background: color-mix(in srgb, var(--accent) 22%, transparent); color: color-mix(in srgb, var(--accent) 70%, #000); }
.st-card.diff.good .st-ic { background: color-mix(in srgb, var(--positive) 14%, transparent); color: var(--positive); }
.st-card.diff.bad { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.st-card.diff.bad .st-ic { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.st-card.diff.bad b { color: var(--danger); }
.stock-t .mv { font-size: 13px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.stock-t .mv.in { background: color-mix(in srgb, var(--positive) 14%, transparent); color: var(--positive); }
.stock-t .mv.out { background: color-mix(in srgb, var(--accent) 22%, transparent); color: color-mix(in srgb, var(--accent) 60%, #000); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.seg button { border: 0; background: transparent; padding: 10px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button.on.in { color: var(--positive); } .seg button.on.out { color: color-mix(in srgb, var(--accent) 60%, #000); }
.input.big { font-size: 24px; padding: 12px 14px; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 700px) {
  .stock-hero { grid-template-columns: 1fr; padding: 14px; }
  .tank { width: 170px; }
  .st-grid { grid-template-columns: 1fr 1fr; }
  .st-card { flex-direction: column; gap: 6px; }
  .st-card b { font-size: 16px; }
}

/* لوحة أسهم تحريك الجدول */
.scroll-pad { position: absolute; inset-inline-end: 12px; bottom: 12px; z-index: 5; display: grid; grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(2, 42px); gap: 4px; padding: 6px; border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--float); border: 1px solid var(--border); direction: ltr; }
.scroll-pad button { border: 0; border-radius: 11px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; opacity: .92; }
.scroll-pad button:active { opacity: 1; transform: scale(.94); }
.scroll-pad button[hidden] { display: grid !important; visibility: hidden; }
.scroll-pad .up { grid-column: 2; grid-row: 1; } .scroll-pad .down { grid-column: 2; grid-row: 2; }
.scroll-pad .left { grid-column: 1; grid-row: 2; } .scroll-pad .right { grid-column: 3; grid-row: 2; }
.scroll-pad .ar { width: 0; height: 0; border: 8px solid transparent; }
.scroll-pad .ar.up { border-bottom: 11px solid currentColor; border-top-width: 0; margin-top: -2px; }
.scroll-pad .ar.down { border-top: 11px solid currentColor; border-bottom-width: 0; margin-bottom: -2px; }
.scroll-pad .ar.left { border-right: 11px solid currentColor; border-left-width: 0; }
.scroll-pad .ar.right { border-left: 11px solid currentColor; border-right-width: 0; }
@media (pointer: fine) { .scroll-pad { grid-template-columns: repeat(3, 36px); grid-template-rows: repeat(2, 36px); } }

/* الإعدادات: اختيار الخانات وترتيبها + قوالب رسائل البوت */
.picker { display: flex; flex-direction: column; gap: 4px; max-width: 560px; }
.pk-row { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.pk-row.off { opacity: .55; background: var(--surface-2); }
.pk-lbl { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; padding: 4px 0; }
.pk-lbl input { width: 18px; height: 18px; accent-color: var(--primary); }
.chev { display: inline-block; width: 0; height: 0; border: 6px solid transparent; }
.chev.up { border-bottom: 8px solid currentColor; border-top-width: 0; }
.chev.down { border-top: 8px solid currentColor; border-bottom-width: 0; }
.pf-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.pf-chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 14px; font: inherit; cursor: pointer; color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.pf-chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pf-chip.add { border-style: dashed; }
.pf-sec { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; background: var(--surface-2); }
.pf-sec > summary { cursor: pointer; padding: 4px 0; list-style-position: inside; }
.pf-sec[open] > summary { margin-bottom: 8px; }
.pf-parties { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 12px; max-height: 260px; overflow: auto; margin-top: 8px; padding: 4px; background: var(--surface); border-radius: 10px; border: 1px solid var(--border); }
