/* نظام التصميم: لوحة العضو والإدارة وصفحات الدخول */
@font-face { font-family: 'GESS'; src: url(/fonts/gess-light.woff2) format('woff2'); font-weight: 300; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'GESS'; src: url(/fonts/gess-medium.woff2) format('woff2'); font-weight: 400 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'GESS'; src: url(/fonts/gess-bold.woff2) format('woff2'); font-weight: 600 900; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'Futura'; src: url(/fonts/futura-book.woff2) format('woff2'); font-weight: 300 400; font-display: swap; }
@font-face { font-family: 'Futura'; src: url(/fonts/futura-medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Futura'; src: url(/fonts/futura-demi.woff2) format('woff2'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: 'Futura'; src: url(/fonts/futura-heavy.woff2) format('woff2'); font-weight: 800 900; font-display: swap; }

:root {
  --font: 'Futura', 'GESS', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --ink: #0d0c12;
  --paper: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --text: #15141b;
  --muted: #6c6977;
  --line: rgba(21, 20, 27, 0.11);
  --line-strong: rgba(21, 20, 27, 0.22);
  --accent: #ff4f1f;
  --accent-ink: #ffffff;
  --accent-soft: #fff0ea;
  --ok: #18884b; --ok-soft: #e6f5ec;
  --warn: #b26a00; --warn-soft: #fdf2df;
  --bad: #c62f22; --bad-soft: #fbe9e7;
  --info: #2a5fd6; --info-soft: #e8effc;
  --r: 6px;
  --r-lg: 10px;
  --shadow: 0 1px 2px rgba(13, 12, 18, 0.05);
  --side: 248px;
  --top: 60px;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --paper: #0f0e14;
  --surface: #17161e;
  --surface-2: #1f1d27;
  --text: #f1efe9;
  --muted: #9c98a8;
  --line: rgba(241, 239, 233, 0.1);
  --line-strong: rgba(241, 239, 233, 0.2);
  --accent-soft: rgba(255, 79, 31, 0.14);
  --ok-soft: rgba(24, 136, 75, 0.18);
  --warn-soft: rgba(178, 106, 0, 0.2);
  --bad-soft: rgba(198, 47, 34, 0.2);
  --info-soft: rgba(42, 95, 214, 0.2);
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--paper); color: var(--text); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
.num, td.num, .tab-num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; }
p { margin: 0; }

/* ---------- العلامة ---------- */
.mark { display: inline-flex; align-items: flex-end; gap: 3px; height: 20px; }
.mark i { display: block; width: 5px; background: var(--accent); border-radius: 1px; }
.mark i:nth-child(1) { height: 40%; } .mark i:nth-child(2) { height: 70%; } .mark i:nth-child(3) { height: 100%; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: 0.01em; }

/* ---------- الأزرار والحقول ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible, .input:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) {
  .btn:hover { border-color: var(--text); }
  .btn.primary:hover { background: #ec4313; border-color: #ec4313; }
  .btn.dark:hover { background: #24222c; }
}

.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }
.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px; }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.6; }
select.input { appearance: none; -webkit-appearance: none; padding-inline-end: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236c6977' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; }
[dir='ltr'] select.input { background-position: right 12px center; }
.input:focus { border-color: var(--text); outline: none; }
.input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 16px; }

/* ---------- الصناديق ---------- */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.box-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.box-h h2, .box-h h3 { font-size: 16px; }
.box-b { padding: 18px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 4px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: start; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t .link-cell { max-width: 240px; overflow-wrap: anywhere; direction: ltr; text-align: start; unicode-bidi: plaintext; }
.t .svc-cell { min-width: 220px; max-width: 360px; }
@media (hover: hover) { .t tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); } }

/* تحت 720 الجدول بيصير بطاقات */
@media (max-width: 720px) {
  table.t.cards, .t.cards tbody, .t.cards tr, .t.cards td { display: block; width: 100%; }
  .t.cards thead { display: none; }
  .t.cards tr { border-bottom: 1px solid var(--line); padding: 12px 14px; }
  .t.cards td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 110px 1fr; gap: 10px; max-width: none; }
  .t.cards td::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; }
  .t.cards td.full { grid-template-columns: 1fr; }
  .t.cards td.full::before { display: none; }
}

/* ---------- تبويبات وشرائح ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); padding: 0 6px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 12px 12px; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .n { font-size: 12px; color: var(--muted); margin-inline-start: 4px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.chip svg { width: 16px; height: 16px; fill: currentColor; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
:root[data-theme='dark'] .chip.on { background: var(--text); color: var(--ink); border-color: var(--text); }

/* ---------- الهيكل ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--side) 1fr; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--ink); color: #e9e7f0; padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; }
.side .brand { color: #fff; padding: 2px 8px; }
.side-bal { padding: 14px; border-radius: var(--r-lg); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08); }
.side-bal .k { font-size: 12.5px; color: #a7a3b5; }
.side-bal .v { font-size: 24px; font-weight: 700; color: #fff; direction: ltr; text-align: start; unicode-bidi: plaintext; }
.side-bal .btn { margin-top: 10px; }
.nav { display: grid; gap: 2px; }
.nav .grp { font-size: 12px; color: #8a8698; padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r); text-decoration: none; color: #d6d3df; font-size: 14.5px; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav a.on { background: rgba(255, 255, 255, 0.09); color: #fff; }
.nav a.on svg { color: var(--accent); opacity: 1; }
.nav a .dot { margin-inline-start: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; display: grid; place-items: center; }
@media (hover: hover) { .nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; } }
.side-foot { margin-top: auto; display: grid; gap: 6px; font-size: 13px; }
.side-foot button, .side-foot a { background: none; border: 0; color: #a7a3b5; text-align: start; padding: 6px 10px; cursor: pointer; text-decoration: none; border-radius: var(--r); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 18px; }
.topbar .sp { flex: 1; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }
.page { padding: 24px; display: grid; gap: 18px; max-width: 1240px; width: 100%; }
.menu-btn { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); z-index: 50; transform: translateX(110%); transition: transform 0.25s ease; }
  [dir='ltr'] .side { transform: translateX(-110%); }
  .side.open { transform: none !important; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 40; display: none; }
  .scrim.open { display: block; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 14px; }
  .page { padding: 16px 14px 90px; }
  .bottom-nav { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { display: grid; justify-items: center; gap: 2px; padding: 8px 2px 7px; font-size: 11.5px; text-decoration: none; color: var(--muted); }
  .bottom-nav a svg { width: 20px; height: 20px; }
  .bottom-nav a.on { color: var(--accent); }
}
@media (min-width: 961px) { .bottom-nav, .scrim { display: none; } }

/* ---------- أرقام ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: grid; gap: 4px; }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; text-align: start; unicode-bidi: plaintext; }
.kpi .s { font-size: 12.5px; color: var(--muted); }
.kpi.alert { border-color: var(--bad); background: var(--bad-soft); }

/* ---------- رسائل ---------- */
.toast-wrap { position: fixed; z-index: 100; inset-inline: 0; bottom: 20px; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--r); font-size: 14.5px; max-width: min(520px, 92vw); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25); }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
@media (max-width: 960px) { .toast-wrap { bottom: 84px; } }
.note { padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); font-size: 14px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.info { background: var(--info-soft); color: var(--info); }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--text); width: min(560px, 94vw); max-height: 90vh; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
dialog.modal::backdrop { background: rgba(10, 9, 14, 0.55); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-b { padding: 18px; display: grid; gap: 14px; overflow-y: auto; max-height: calc(90vh - 130px); }
.modal-f { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.pager { display: flex; gap: 8px; justify-content: center; padding: 14px; }
.skeleton { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* خريطة الحالات */
.st-pending { background: var(--surface-2); color: var(--muted); }
.st-processing, .st-in_progress { background: var(--info-soft); color: var(--info); }
.st-completed { background: var(--ok-soft); color: var(--ok); }
.st-partial { background: var(--warn-soft); color: var(--warn); }
.st-canceled, .st-failed, .st-rejected, .st-error { background: var(--bad-soft); color: var(--bad); }

/* ---------- الرسوم ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: 220px; }
.chart .labels { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 6px; direction: ltr; }
.chart .tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12.5px; padding: 6px 9px; border-radius: 5px; white-space: nowrap; transform: translate(-50%, -110%); display: none; }
.bars-h { display: grid; gap: 10px; }
.bars-h .r { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13.5px; }
.bars-h .r .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bars-h .r .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bars-h .r .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- صفحة الدخول ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { background: var(--ink); color: #fff; padding: 40px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art .big { font-size: clamp(40px, 6vw, 84px); font-weight: 800; line-height: 0.95; letter-spacing: -0.01em; }
.auth-art .big em { font-style: normal; color: var(--accent); }
.auth-form { display: grid; place-items: center; padding: 40px 20px; }
.auth-form form { width: min(400px, 100%); display: grid; gap: 16px; }
.auth-form h1 { font-size: 26px; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 200px; padding: 24px; }
  .auth-art .big { font-size: 40px; }
}

/* بلا حركة لمن طالبها */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- admin ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.toolbar > .input { flex: 1 1 220px; width: auto; min-width: 0; }
.toolbar > select.input { flex: 0 1 220px; }
.toolbar .chips { min-width: 0; max-width: 100%; }
.t tr.needs { background: var(--warn-soft); }
.err-line { color: var(--bad); font-size: 12.5px; margin-top: 4px; overflow-wrap: anywhere; }
.kpi .btn { justify-self: start; margin-top: 6px; }
.kpi.alert .s b { color: var(--bad); }
