/* =========================================================
   لوحة تدقيق مؤسسة يونيك بايونير — نظام تصميم تنفيذي
   ========================================================= */

/* ألوان الهوية مأخوذة من uniquepioneer.com — متغيّرات الموقع نفسها:
   navy #2e3092 · navy-bg #07153f · amber #ca883b · amber-dark #b27430 */
:root {
  --brand: #2e3092;
  --brand-soft: #eceffb;
  --navy-deep: #07153f;
  --gold: #ca883b;
  --gold-soft: #fbf3e8;
  /* الكهرماني الأصلي يعطي 3:1 على الأبيض — يكفي للحدود والأرقام الكبيرة
     لا للنصّ الصغير. هذه نسخة داكنة تتجاوز 6:1 لاستخدامها في النصوص. */
  --gold-ink: #8a5a1f;

  --bg: #f6f7fa;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --ink: #04000b;
  --ink-2: #314158;
  --muted: #62748e;
  --line: #e2e8f0;
  --line-2: #eef1f6;

  --high: #b5342b;
  --high-bg: #fbeceb;
  --med: #a9741a;
  --med-bg: #fbf3e4;
  --low: #4a6785;
  --low-bg: #eef2f7;
  --ok: #1c7a51;
  --ok-bg: #e9f5ef;

  --shadow-sm: 0 1px 2px rgba(21, 26, 33, .05), 0 1px 3px rgba(21, 26, 33, .04);
  --shadow-md: 0 2px 4px rgba(21, 26, 33, .04), 0 8px 24px rgba(21, 26, 33, .07);
  --shadow-lg: 0 4px 12px rgba(21, 26, 33, .06), 0 24px 48px rgba(21, 26, 33, .10);

  --r-sm: 8px;
  --r: 14px;
  --r-lg: 20px;
  --maxw: 1320px;
}

:root[data-theme='dark'] {
  --brand: #8f93e8;
  --brand-soft: #161a3a;
  --navy-deep: #050e2b;
  --gold: #dda861;
  --gold-soft: #241a0e;
  --gold-ink: #dda861;

  --bg: #060b1c;
  --surface: #0e142c;
  --surface-2: #0a1024;
  --ink: #e8ecf7;
  --ink-2: #b6c0da;
  --muted: #8a94b4;
  --line: #1e2646;
  --line-2: #161d38;

  --high: #ef7268;
  --high-bg: #2a1613;
  --med: #dda746;
  --med-bg: #261d0e;
  --low: #7ea3c9;
  --low-bg: #16202b;
  --ok: #46c58c;
  --ok-bg: #0f2419;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .35), 0 24px 48px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  direction: rtl;
  text-align: right;
  font-feature-settings: 'kern' 1;
  -webkit-font-smoothing: antialiased;
}

/* الأرقام بعرض ثابت حتى تتراصّ الأعمدة المالية رأسياً */
.num, td.num, .kpi-val { font-variant-numeric: tabular-nums; }

/* عزل ثنائي الاتجاه: بدونه يقلب المحرّك مقاطع «2026-08-10» إلى «10-08-2026»
   لأن الشرطات محايدة داخل سياق RTL. مطلوب لكل تاريخ ISO ومرجع لاتيني. */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.4; }

a { color: var(--brand); }

button { font: inherit; cursor: pointer; }

/* ===================== شاشة الدخول ===================== */

/* شاشة الدخول تُحاكي هوية uniquepioneer.com: خلفية كحلية عميقة
   بتدرّجين شعاعيين — كهرماني أعلى اليمين وبنفسجي أسفل اليسار.
   ثابتة اللون في الوضعين: هي واجهة العلامة لا جزء من اللوحة. */
#gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(circle at 85% 12%, rgba(202, 136, 59, .18), transparent 42%),
    radial-gradient(circle at 12% 88%, rgba(46, 48, 146, .55), transparent 55%),
    #07153f;
}

.gate-shell { width: 100%; max-width: 430px; }

.gate-brand { text-align: center; margin-bottom: 28px; }
.gate-brand img {
  width: 168px;
  height: auto;
  margin: 0 auto;
  display: block;
  filter: drop-shadow(0 6px 22px rgba(0, 0, 0, .35));
}
.gate-tagline {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: #9aa3c7;
  letter-spacing: .04em;
}

.gate-card {
  width: 100%;
  position: relative;
  background: #fff;
  border-radius: var(--r-lg);
  padding: 34px 34px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .38), 0 2px 8px rgba(0, 0, 0, .2);
  text-align: center;
  overflow: hidden;
}
/* الشريط الكهرماني — نفس لمسة الموقع */
.gate-card::before {
  content: '';
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 3px;
  background: linear-gradient(90deg, #ca883b, #2e3092);
}

.gate-card h1 { font-size: 19px; margin-bottom: 5px; color: #04000b; }
.gate-card .sub { color: #62748e; font-size: 13px; margin-bottom: 26px; }

/* البطاقة بيضاء دائماً فوق الخلفية الكحلية — نثبّت ألوان الحقول
   حتى لا يقلبها الوضع الليلي ويكسر التباين */
#gate .field label { color: #314158; }
#gate input {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #04000b;
}
#gate input:focus-visible {
  border-color: #2e3092;
  box-shadow: 0 0 0 3px rgba(46, 48, 146, .16);
}
#gate .btn-primary { background: #2e3092; border-color: #2e3092; color: #fff; }
#gate .btn-primary:hover { background: #262877; }
#gate .linkish { color: #2e3092; }
#gate .linkish:hover { color: #04000b; }
#gate .gate-note { background: #eceffb; color: #314158; }

.gate-foot-brand {
  margin: 22px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: #8e99c8;
}

.field { text-align: right; margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 7px; font-weight: 500; }

input[type='password'], input[type='search'], input[type='text'], input[type='email'] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); color: var(--ink); }
.btn-primary {
  width: 100%;
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  padding: 13px 20px;
  font-weight: 600;
}
:root[data-theme='dark'] .btn-primary { color: #0c1015; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); border-color: transparent; color: #fff; }
:root[data-theme='dark'] .btn-primary:hover { color: #0c1015; }
.btn-primary[disabled] { opacity: .6; cursor: wait; }

.gate-error {
  display: none;
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--high-bg);
  color: var(--high);
  border: 1px solid color-mix(in srgb, var(--high) 30%, transparent);
  border-radius: var(--r-sm);
  font-size: 13.5px;
}
.gate-error.show { display: block; }

.gate-note {
  margin: 0 0 18px;
  padding: 11px 14px;
  background: var(--brand-soft);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.7;
}

/* حقل الكود: أرقام لاتينية معزولة عن اتجاه الصفحة، وتباعد مقروء
   (التتبّع هنا آمن لأن المحتوى أرقام لا حروف عربية متّصلة) */
.code-input {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
  font-size: 26px !important;
  font-weight: 600;
  letter-spacing: .35em;
  text-indent: .35em;
  font-variant-numeric: tabular-nums;
  padding: 14px !important;
}

.gate-links {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.gate-links:empty { display: none; }

.linkish {
  border: none;
  background: none;
  padding: 2px 0;
  font-size: 13px;
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linkish:hover { color: var(--ink); }
.linkish[hidden] { display: none; }
.linkish[disabled] { color: var(--muted); text-decoration: none; cursor: default; }

/* ===================== الهيكل ===================== */

#app[hidden], #gate[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; flex: none;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #000));
  color: #fff; font-weight: 700; font-size: 15px;
}
:root[data-theme='dark'] .brand-mark { color: #0c1015; }
.brand-txt { min-width: 0; }
.brand-txt b, .brand-txt span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-txt b { font-size: 15px; font-weight: 600; }
.brand-txt span { font-size: 12px; color: var(--muted); }

.topbar-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-2);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--muted); }

main { max-width: var(--maxw); margin: 0 auto; padding: 32px 28px 72px; }

.page-head { margin-bottom: 28px; }
.page-head .eyebrow {
  font-size: 12px; font-weight: 600; color: var(--gold-ink);
  text-transform: uppercase; margin-bottom: 8px;
}
/* التتبّع للاتينية فقط — الخط العربي متّصل ويتفكّك بالتتبّع */
.page-head .eyebrow:lang(en) { letter-spacing: .09em; }
.page-head h1 { font-size: 29px; font-weight: 600; letter-spacing: -.01em; }
.page-head .meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--muted); }
.page-head .meta b { color: var(--ink-2); font-weight: 500; }

.section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.section-head h2 { font-size: 19px; }
.section-head .note { font-size: 13px; color: var(--muted); }
.section-head .spacer { margin-inline-start: auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px 24px; }

/* ===================== مؤشرات الأداء ===================== */

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute; inset-block-start: 0; inset-inline: 0;
  height: 3px; background: var(--accent-c, var(--line));
}
.kpi.c-brand { --accent-c: var(--brand); }
.kpi.c-gold  { --accent-c: var(--gold); }
.kpi.c-ok    { --accent-c: var(--ok); }
.kpi.c-high  { --accent-c: var(--high); }
.kpi.c-med   { --accent-c: var(--med); }
.kpi.c-low   { --accent-c: var(--low); }

.kpi-label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.kpi-val { font-size: 27px; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; }
.kpi-val small { font-size: 15px; font-weight: 500; color: var(--muted); margin-inline-start: 3px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 5px; }
.kpi.c-high .kpi-val { color: var(--high); }
.kpi.c-med  .kpi-val { color: var(--med); }
.kpi.c-ok   .kpi-val { color: var(--ok); }

.meter { height: 5px; border-radius: 3px; background: var(--line-2); margin-top: 10px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--ok); }

/* ===================== شبكة الرسوم ===================== */

.grid-2 { display: grid; grid-template-columns: 380px 1fr; gap: 18px; align-items: start; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* min-width الافتراضي لعنصر الشبكة هو min-content، فيتمدّد العمود مع أطول نص
   ويدفع اللوحة خارج الشاشة. الصفر يسمح للنص بالانكماش والاقتطاع كما هو مقصود. */
.grid-2 > *, .grid-2-even > *, .bar-row > *, .rank-row > *, .legend-row > * { min-width: 0; }

/* الرسوم مثبّتة على ltr: اتجاه rtl يعكس معنى text-anchor ويقذف التسميات خارج الإطار */
svg.chart { display: block; width: 100%; height: auto; direction: ltr; }
svg.chart text { direction: ltr; }

/* الحلقة لا تتمدّد مع العمود — تبقى بحجم مقروء وتتوسّط البطاقة */
#donut-slot { max-width: 300px; margin: 4px auto 0; }

.chart-foot {
  margin: 14px 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--line-2);
  font-size: 13px;
  color: var(--muted);
}

.legend { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-row .lg-label { color: var(--ink-2); }
.legend-row .lg-val { margin-inline-start: auto; font-weight: 600; }
.legend-row .lg-amt { color: var(--muted); font-size: 12px; min-width: 92px; text-align: left; }

/* ===================== أشرطة أفقية ===================== */

.bars { display: flex; flex-direction: column; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 14px; font-size: 13.5px; }
.bar-row .bl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { display: block; height: 9px; background: var(--line-2); border-radius: 5px; overflow: hidden; }
/* display:block إلزامي — <i> سطريّ افتراضياً فيتجاهل width/height تماماً */
.bar-fill { display: block; height: 100%; border-radius: 5px; transition: width .5s cubic-bezier(.2, .8, .3, 1); }
.bar-row .bv { font-weight: 600; min-width: 84px; text-align: left; font-variant-numeric: tabular-nums; }
.bar-row .bv small { color: var(--muted); font-weight: 400; font-size: 11.5px; }

/* ===================== تنبيه المكرّرات ===================== */

.alert-strip {
  display: flex; align-items: center; gap: 14px;
  background: var(--high-bg);
  border: 1px solid color-mix(in srgb, var(--high) 28%, transparent);
  border-radius: var(--r);
  padding: 15px 20px;
  margin-bottom: 16px;
}
.alert-strip .ic { font-size: 20px; flex: none; }
.alert-strip b { color: var(--high); }
.alert-strip p { margin: 0; font-size: 13.5px; color: var(--ink-2); }

.dupe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.dupe {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.dupe.exact { border-color: color-mix(in srgb, var(--high) 40%, transparent); background: var(--surface); }
.dupe-head { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.dupe-ref { font-weight: 600; font-size: 15px; direction: ltr; unicode-bidi: isolate; }
.dupe-total { font-size: 12.5px; color: var(--muted); margin-bottom: 11px; }
.dupe-list { display: flex; flex-direction: column; gap: 7px; }
.dupe-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 7px;
}
.dupe-item .di-id { font-weight: 600; direction: ltr; unicode-bidi: isolate; }
.dupe-item .di-date { color: var(--muted); direction: ltr; unicode-bidi: isolate; }
.dupe-item .di-amt { margin-inline-start: auto; font-variant-numeric: tabular-nums; font-weight: 500; }
.dupe-remark {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.65;
}

/* ===================== الشارات ===================== */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tag.high { background: var(--high-bg); color: var(--high); border-color: color-mix(in srgb, var(--high) 25%, transparent); }
.tag.med  { background: var(--med-bg);  color: var(--med);  border-color: color-mix(in srgb, var(--med) 25%, transparent); }
.tag.low  { background: var(--low-bg);  color: var(--low);  border-color: color-mix(in srgb, var(--low) 25%, transparent); }
.tag.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.tag.plain { background: var(--surface-2); color: var(--muted); border-color: var(--line); }

/* ===================== أدوات الجدول ===================== */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search-wrap { position: relative; flex: 1 1 260px; max-width: 380px; }
.search-wrap input { padding-inline-start: 38px; }
.search-wrap .si {
  position: absolute; inset-inline-start: 13px; inset-block-start: 50%;
  transform: translateY(-50%); color: var(--muted); pointer-events: none; display: grid;
}

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  transition: all .15s;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed='true'] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
:root[data-theme='dark'] .chip[aria-pressed='true'] { color: #0c1015; }
.chip .cnt { opacity: .65; font-size: 11.5px; margin-inline-start: 4px; }

select {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
}

/* ===================== الجدول ===================== */

/* منطقة تمرير مستقلّة: overflow-x وحده يجعل الحاوية scrollport بلا ارتفاع محدود،
   فلا ينشط الرأس اللاصق أبداً. تحديد max-height يُفعّله ويُبقي الصفحة قصيرة. */
.table-wrap {
  overflow: auto;
  max-height: 72vh;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  z-index: 2;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
thead th .arrow { opacity: 0; font-size: 10px; margin-inline-start: 4px; }
thead th[data-dir] .arrow { opacity: 1; }
tbody tr { border-bottom: 1px solid var(--line-2); }
tbody tr:last-child { border-bottom: none; }
tbody tr.row { cursor: pointer; transition: background .12s; }
tbody tr.row:hover { background: var(--surface-2); }
tbody tr.row.open { background: var(--brand-soft); }
td { padding: 12px 16px; vertical-align: middle; }
td.num { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono { direction: ltr; unicode-bidi: isolate; text-align: right; font-weight: 600; white-space: nowrap; }
td.date { direction: ltr; unicode-bidi: isolate; text-align: right; color: var(--muted); white-space: nowrap; font-size: 12.5px; }
td.party { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail td { background: var(--surface-2); padding: 0; }
.detail-in { padding: 18px 22px 22px; border-block-start: 1px dashed var(--line); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 26px; margin-bottom: 16px; }
.dd { font-size: 13px; }
.dd .k { color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
.dd .v { color: var(--ink); }
.dd .v-ltr { direction: ltr; unicode-bidi: isolate; text-align: right; }
.issue-list { display: flex; flex-direction: column; gap: 8px; }
.issue {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 13px;
  border-radius: 9px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--muted);
}
.issue.high { border-inline-start-color: var(--high); }
.issue.med { border-inline-start-color: var(--med); }
.issue.low { border-inline-start-color: var(--low); }
.remark { font-size: 13px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 11px 14px; }

.empty-state { padding: 56px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* ===================== قوائم مصغّرة ===================== */

.rank { display: flex; flex-direction: column; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.rank-row:last-child { border-bottom: none; }
.rank-n { width: 22px; height: 22px; flex: none; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-size: 11px; font-weight: 600; color: var(--muted); }
.rank-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.rank-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-amt { color: var(--muted); font-size: 12px; min-width: 96px; text-align: left; font-variant-numeric: tabular-nums; }

.notes-list { display: flex; flex-direction: column; gap: 10px; }
.note-item { display: flex; gap: 10px; font-size: 13.5px; color: var(--ink-2); padding: 10px 14px; background: var(--surface-2); border-radius: 9px; border: 1px solid var(--line-2); }

footer.foot { max-width: var(--maxw); margin: 0 auto; padding: 26px 28px 44px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 8px 22px; }
footer.foot .conf { color: var(--gold-ink); font-weight: 500; }

/* ===================== حالات التحميل ===================== */

.loading { display: grid; place-items: center; min-height: 60vh; gap: 14px; color: var(--muted); }
.spinner { width: 26px; height: 26px; border: 2.5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.reveal { animation: rise .45s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===================== الاستجابة ===================== */

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  main { padding: 22px 16px 60px; }
  .topbar-in { padding: 10px 16px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2-even { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 23px; }
  .bar-row { grid-template-columns: 118px 1fr auto; }
  .brand-txt span { display: none; }
  .table-wrap { max-height: 65vh; }

  /* أهداف اللمس ≥ 44px على الجوال — 38px تُخطئها الإصبع */
  .icon-btn { width: 44px; height: 44px; }
  .chip { padding: 11px 16px; }
  .linkish { padding: 10px 4px; }
  select, .search-wrap input { min-height: 44px; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
}

/* ===================== الطباعة ===================== */

@media print {
  :root { --bg: #fff; --surface: #fff; --shadow-sm: none; --shadow-md: none; --shadow-lg: none; }
  .topbar, .toolbar, .icon-btn, #gate { display: none !important; }
  main { max-width: none; padding: 0; }
  /* الطباعة تحتاج الجدول كاملاً لا منطقة تمرير مقتطعة */
  .table-wrap { max-height: none; overflow: visible; }
  thead th { position: static; }
  details { display: block; }
  details > div { display: block !important; }
  .card, .kpi, .dupe { break-inside: avoid; box-shadow: none; }
  .section { break-inside: avoid-page; margin-top: 22px; }
  tbody tr.row { cursor: default; }
}
