/* ============================================================
   لوحة أثر — نظام بصري هادئ
   ============================================================

   المبدأ: اللوحة تُقرأ كل يوم لا تُزار مرّة. فما يلفت النظر فيها يجب أن
   يكون البيانات نفسها — رقم متأخر، عميل موقوف — لا الأثاث حولها. ولذلك:

   - سطح واحد وحدّ واحد وظلّ واحد لكل البطاقات. اختلافها كان يجعل الشاشة
     تبدو مجمّعة من مصادر شتّى.
   - ظلال خفيفة (`0 2px 8px`) بدل `0 18px 50px`: الظلّ الثقيل يرفع كل شيء
     فلا يبقى شيء مرتفعًا.
   - الشريط الجانبي سطحٌ فاتح لا كتلة داكنة: الكتلة الداكنة تسحب العين إلى
     التنقّل، والتنقّل ليس العمل.
   - لون العلامة للفعل والحالة فقط، لا للزينة.

   الخطوط من النظام لا من الشبكة: `font-src 'self'` في `_headers`، ولا
   يُضعَّف حدّ أمني لأجل خط.
   ============================================================ */

:root {
  color-scheme: light;

  /* الحبر والأسطح */
  --ink: #1F2D33;
  --ink-soft: #3E5058;
  --muted: #5A6C74;
  --faint: #8A9BA3;
  --line: #E2E9EC;
  --line-strong: #CFDBE0;
  --canvas: #F5F8F9;
  --surface: #FFFFFF;
  --surface-sunk: #F7FAFB;

  /* العلامة: أخضر أثر، مهدّأ درجةً كي يحتمل الظهور في كل شاشة */
  --brand: #106E5A;
  --brand-dark: #0F6151;
  --brand-soft: #DEF0EA;

  /* ألوان الحالة — دلالة لا زينة */
  --info: #1F63AE;
  --info-soft: #DCEAF8;
  --gold: #8A5A15;
  --gold-soft: #FAEED8;
  --danger: #A8403C;
  --danger-soft: #FAE4E3;

  --shadow-card: 0 2px 8px rgba(31, 45, 51, .06);
  --shadow-raise: 0 6px 20px rgba(31, 45, 51, .09);
  --shadow-modal: 0 16px 44px rgba(31, 45, 51, .16);

  --r-btn: 12px;
  --r-card: 18px;
  --r-modal: 22px;

  font-family: 'Segoe UI', system-ui, -apple-system, 'Noto Sans Arabic', Tahoma, Arial, sans-serif;
}

/**
 * الوضع الداكن يتبع إعداد النظام.
 *
 * اللوحة تُفتح ليلًا لمتابعة تجديد أو دفعة متأخرة، وشاشة بيضاء في غرفة
 * مظلمة تُتعب. ولا زرّ لتبديله: من ضبط جهازه على الداكن يريده في كل
 * تطبيق، وزرٌّ ثالث يُضاف إلى شريط مزدحم بلا حاجة.
 *
 * الرموز وحدها تُعاد هنا — لا قاعدة عرض ولا مقاس — فلا يتفرّع التنسيق
 * إلى نسختين تتباعدان مع كل تعديل.
 */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --ink: #E9F1F4;
    --ink-soft: #C3D2D9;
    --muted: #9DB2BC;
    --faint: #7C929C;
    --line: #243B47;
    --line-strong: #33505F;
    --canvas: #0E1B22;
    --surface: #16262F;
    --surface-sunk: #1B2E38;

    --brand: #35B394;
    --brand-dark: #4FC7AA;
    --brand-soft: #14382F;

    --info: #6FAEE8;
    --info-soft: #14304A;
    --gold: #D8A34E;
    --gold-soft: #3B2E17;
    --danger: #E28B87;
    --danger-soft: #3F2422;

    --shadow-card: 0 2px 8px rgba(6, 15, 20, .34);
    --shadow-raise: 0 6px 20px rgba(6, 15, 20, .42);
    --shadow-modal: 0 16px 44px rgba(6, 15, 20, .55);
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .04em; }
.muted { color: var(--muted); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.3rem, 2vw, 1.7rem); font-weight: 700; letter-spacing: -.01em; }
h2 { margin-bottom: 0; font-size: 1.16rem; font-weight: 700; }
h3 { margin-bottom: 5px; font-size: .98rem; font-weight: 700; }

/* ==================== الدخول ==================== */

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--canvas); }
.login-card { width: min(420px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }
.login-card h1 { margin-bottom: 10px; }
.login-card .muted { line-height: 1.8; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 20px; border-radius: 15px; color: #fff; background: var(--brand); font-size: 1.6rem; font-weight: 800; }
.brand-mark-small { width: 38px; height: 38px; margin: 0; border-radius: 11px; font-size: 1.05rem; }

/* ==================== الهيكل ==================== */

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 0 0 auto; z-index: 30;
  display: flex; flex-direction: column; width: 244px; padding: 20px 14px;
  color: var(--ink); background: var(--surface); border-inline-start: 1px solid var(--line);
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 24px; color: var(--ink); text-decoration: none; }
.sidebar-brand strong { font-size: .96rem; }
.sidebar-brand span:last-child { display: grid; gap: 1px; }
.sidebar-brand small, .sidebar-footer small { color: var(--faint); font-size: .72rem; }
.nav-list { display: grid; gap: 3px; }
/* عناوين المجموعات: سبعة عناصر في قائمة واحدة تُقرأ كسلسلة بلا معنى.
   وثلاث مجموعات تجعل العين تقفز إلى المجموعة ثم تبحث داخلها. */
.nav-group { margin: 16px 8px 6px; color: var(--faint); font-size: .69rem; font-weight: 700; letter-spacing: .06em; }
.nav-group:first-child { margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px;
  border: 0; border-radius: var(--r-btn); color: var(--ink-soft); background: transparent;
  text-align: right; text-decoration: none; font-size: .88rem;
  transition: background .15s ease, color .15s ease;
}
/* الأيقونات صارت SVG، فقاعدتا `.nav-item span` القديمتان لم يبقَ لهما هدف
   إلا شارة العدد — وهي `<span>` — فكانت ترث لون العلامة على خلفية العلامة:
   رقمٌ أخضر على أخضر لا يُرى. حُذفتا. */
.nav-icon { flex: 0 0 19px; width: 19px; height: 19px; color: var(--faint); transition: color .15s ease; }
.nav-item.is-active .nav-icon { color: var(--brand); }
.nav-item:hover { background: var(--surface-sunk); }
.nav-item.is-active { color: var(--brand-dark); background: var(--brand-soft); font-weight: 700; }
.sidebar-footer { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-btn); font-size: .8rem; }
.sidebar-footer span:nth-child(2) { display: grid; gap: 1px; }
.status-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

.main-area { min-height: 100vh; margin-right: 244px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 78px; padding: 16px clamp(18px, 3.5vw, 44px);
  border-bottom: 1px solid var(--line); background: rgba(245, 248, 249, .88); backdrop-filter: blur(12px);
}
.topbar > div:first-child { position: relative; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.menu-button { display: none !important; position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
.page-view { padding: 26px clamp(18px, 3.5vw, 44px) 56px; }

/* ==================== الأزرار ==================== */

.button, .icon-button, .text-button { border: 0; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border-radius: var(--r-btn); font-weight: 600; font-size: .87rem; }
.button-primary { color: #fff; background: var(--brand); }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { color: var(--brand-dark); border: 1px solid var(--line-strong); background: var(--surface); }
.button-secondary:hover { border-color: var(--brand); background: var(--brand-soft); }
.button-quiet { color: var(--muted); border: 1px solid var(--line); background: transparent; }
.button-quiet:hover { color: var(--ink); border-color: var(--line-strong); }
.button-light { color: var(--brand-dark); border: 1px solid var(--line-strong); background: var(--surface); }
.button-light:hover { background: var(--brand-soft); }
.button-danger { color: var(--danger); background: var(--danger-soft); }
.button-danger:hover { color: #fff; background: var(--danger); }
.button-wide { width: 100%; }
.button-small { min-height: 32px; padding: 0 11px; border-radius: 9px; font-size: .77rem; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: var(--r-btn); color: var(--ink-soft); background: var(--surface); font-size: 1.05rem; }
.icon-button:hover { border-color: var(--line-strong); background: var(--surface-sunk); }
.text-button { padding: 6px 0; color: var(--brand); background: transparent; font-weight: 600; font-size: .85rem; }
.text-button:hover { color: var(--brand-dark); }

/* ==================== لافتة الحالة ==================== */

.stage-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 22px;
  padding: 20px 22px; border: 1px solid var(--line); border-inline-start: 3px solid var(--brand);
  border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card);
}
.stage-banner strong { font-size: 1rem; }
.stage-banner p { margin: 6px 0 0; color: var(--muted); line-height: 1.75; font-size: .85rem; }
.stage-pill { display: inline-block; margin-left: 8px; padding: 3px 9px; border-radius: 99px; color: var(--brand-dark); background: var(--brand-soft); font-size: .7rem; font-weight: 700; }

/* ==================== المؤشرات ==================== */

.metrics-grid { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 12px; margin: 20px 0 30px; }
.metric-card { min-height: 112px; padding: 18px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }
.metric-label { color: var(--muted); font-size: .79rem; }
.metric-value { display: block; margin: 10px 0 5px; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric-hint { color: var(--faint); font-size: .73rem; }

/* ==================== الأقسام والبطاقات ==================== */

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 26px 0 14px; }
.section-heading:first-child { margin-top: 0; }
.compact-heading { margin-top: 22px; }
.panel { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }

.toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) repeat(2, minmax(150px, .4fr)); gap: 9px; padding: 12px; }
.toolbar input, .toolbar select { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-sunk); }
.toolbar input:focus, .toolbar select:focus { background: var(--surface); }
.toolbar select { padding: 0 11px; }
.search-field { position: relative; }
.search-field span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 1.1rem; }
.search-field input { width: 100%; padding: 0 40px 0 12px; }
.view-toggle { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.view-toggle button { width: 32px; height: 28px; border: 0; border-radius: 7px; color: var(--faint); background: transparent; }
.view-toggle button.is-active { color: var(--brand); background: var(--brand-soft); }

.client-grid { display: grid; grid-template-columns: repeat(3, minmax(250px, 1fr)); gap: 13px; }
.client-card {
  display: flex; flex-direction: column; min-height: 250px; padding: 18px;
  border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface);
  box-shadow: var(--shadow-card); transition: border-color .16s ease, box-shadow .16s ease;
}
.client-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-raise); }
.client-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 13px; }
.product-icon { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; color: var(--brand); background: var(--brand-soft); }
.product-icon svg { width: 21px; height: 21px; }
.client-title { flex: 1; min-width: 0; }
.client-title h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-title p { margin: 0; color: var(--muted); font-size: .76rem; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 15px 0; }
.badge { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 99px; background: var(--surface-sunk); color: var(--muted); font-size: .7rem; font-weight: 600; border: 1px solid var(--line); }
.badge-active { color: var(--brand-dark); background: var(--brand-soft); border-color: transparent; }
.badge-draft { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.badge-suspended, .badge-past_due { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge-demo { color: var(--info); background: var(--info-soft); border-color: transparent; }
.client-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.client-details div { min-width: 0; }
.client-details small { display: block; margin-bottom: 3px; color: var(--faint); font-size: .69rem; }
.client-details strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; font-weight: 600; }
.client-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 13px; border-top: 1px solid var(--line); }
.empty-state { grid-column: 1 / -1; padding: 48px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-card); text-align: center; background: var(--surface); color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); }

.clients-table { grid-column: 1 / -1; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-size: .81rem; }
td { font-variant-numeric: tabular-nums; }
th { color: var(--muted); background: var(--surface-sunk); font-size: .72rem; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 6px; }
.table-panel { overflow: hidden; }

.plans-grid { display: grid; grid-template-columns: repeat(3, minmax(250px, 1fr)); gap: 13px; }
.plan-card { padding: 19px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }
.plan-card-top { display: flex; justify-content: space-between; gap: 12px; }
.plan-price { margin: 16px 0; padding: 13px; border-radius: var(--r-btn); background: var(--surface-sunk); }
.plan-price strong { display: block; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.plan-edit { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.plan-edit input { min-width: 0; }

/* ==================== النماذج ==================== */

.form-stack { display: grid; gap: 10px; margin-top: 26px; }
.form-stack input, .field input, .field select, .field textarea, .plan-edit input {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink); background: var(--surface);
  transition: border-color .15s ease;
}
.form-stack input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.form-stack input, .field input, .field select, .plan-edit input { min-height: 42px; padding: 0 12px; }
.field textarea { padding: 10px 12px; resize: vertical; }
.form-stack label, .field { color: var(--ink-soft); font-size: .79rem; font-weight: 600; }
.field { display: grid; gap: 6px; }
.form-error { min-height: 18px; margin: 4px 0 0; color: var(--danger); font-size: .78rem; }
.check-field { display: flex; align-items: center; gap: 8px; margin-top: 15px; color: var(--muted); font-size: .8rem; }
.check-field input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ==================== النوافذ ==================== */

.modal { width: min(740px, calc(100% - 28px)); max-height: calc(100vh - 34px); padding: 0; overflow: auto; border: 0; border-radius: var(--r-modal); color: var(--ink); background: var(--surface); box-shadow: var(--shadow-modal); }
.modal::backdrop { background: rgba(31, 45, 51, .45); backdrop-filter: blur(3px); }
.modal > form, .modal > div:not(.modal-header), .modal > .modal-header { padding-inline: 26px; }
.modal > form { padding-top: 22px; padding-bottom: 22px; }
.modal-small { width: min(570px, calc(100% - 28px)); padding: 22px 26px; }
.modal-small > form { padding: 0; }
.modal-small > .modal-header, .modal-small > div:not(.modal-header) { padding-inline: 0; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.modal-header .icon-button { font-size: 1.4rem; }
.modal-note { padding: 12px 14px; border-radius: var(--r-btn); color: var(--brand-dark); background: var(--brand-soft); line-height: 1.75; font-size: .79rem; }
.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-block: 16px; }
.detail { padding: 13px; border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface-sunk); }
.detail span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .74rem; }
.detail strong { display: block; font-size: 1rem; font-weight: 600; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-wide { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.history-list { display: grid; gap: 8px; }
.history-item { display: flex; justify-content: space-between; gap: 16px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-btn); }
.history-item p { margin: 0; }
.history-item small { color: var(--muted); }

/* ==================== التنبيهات العابرة ==================== */

.toast-region { position: fixed; z-index: 100; left: 20px; bottom: 20px; display: grid; gap: 8px; width: min(380px, calc(100% - 40px)); }
.toast { padding: 12px 14px; border: 1px solid var(--line); border-inline-start: 3px solid var(--brand); border-radius: var(--r-btn); color: var(--ink); background: var(--surface); box-shadow: var(--shadow-raise); animation: toast-in .2s ease; font-size: .85rem; }
.toast.is-error { color: var(--danger); border-color: var(--danger-soft); border-inline-start-color: var(--danger); background: var(--surface); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==================== الشاشات الضيّقة ==================== */

@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
  .client-grid, .plans-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
  .sidebar { transform: translateX(100%); transition: transform .2s ease; box-shadow: var(--shadow-modal); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main-area { margin-right: 0; }
  .topbar { min-height: 72px; padding-right: 68px; }
  .menu-button { display: inline-grid !important; right: -50px; }
  .topbar-actions .button-quiet, #refresh-button { display: none; }
  .page-view { padding-top: 20px; }
  .stage-banner { align-items: flex-start; flex-direction: column; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .client-grid, .plans-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .login-card { padding: 28px 22px; }
  .topbar-actions #new-client-button { min-width: 40px; width: 40px; padding: 0; overflow: hidden; color: transparent; font-size: 0; }
  .topbar-actions #new-client-button::after { content: "+"; color: white; font-size: 1.2rem; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 104px; padding: 15px; }
  .metric-value { font-size: 1.35rem; }
  .form-grid { grid-template-columns: 1fr; }
  .details-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .modal > form { padding-inline: 18px; }
  .modal-small { padding-inline: 18px; }
}

/* ==================== تفاصيل بعينها ==================== */

/* خطوات الحذف النهائي: ترتيب صريح يمنع الضغط على الزر قبل النسخة الاحتياطية. */
/* الحذف النهائي: خطوة واحدة واعية.
   النسخة الاحتياطية تُنزَّل تلقائيًا — الخادم يرفض الحذف بلا بصمتها — فلا
   يبقى على صاحب اللوحة إلا كتابة المعرّف، وهي الفعل الذي يمنع حذف الخطأ. */
.purge-backup { margin: 14px 0 4px; padding: 11px 13px; border-radius: var(--r-btn); background: var(--surface-sunk); color: var(--muted); font-size: .82rem; }
#purge-form code { background: var(--surface-sunk); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-weight: 600; }
#purge-form .field { margin-top: 6px; }

.optional-label { color: var(--muted); font-size: .8em; font-weight: 400; }
.school-logo-field { display: grid; gap: 8px; }
.school-logo-field input[type="file"] { padding: 10px; border: 1px dashed var(--line-strong); border-radius: var(--r-btn); background: var(--surface-sunk); }
.school-logo-field small { color: var(--muted); line-height: 1.65; }
.school-logo-upload-preview { width: 72px; height: 72px; object-fit: contain; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn); }

/* الشارة تُظهر ما لم يُقرأ دون فتح التبويب: العميل المحتمل تفسده الساعات. */
.nav-badge { min-width: 19px; padding: 2px 6px; border-radius: 99px; margin-inline-start: auto; background: var(--brand); color: #fff; font-size: .68rem; font-weight: 700; text-align: center; }

/* حدّ جانبي لا لون خلفية: البطاقة تُقرأ في شبكة، وتلوين الخلفية يجعل غير
   المقروء يصرخ بينما المقروء يبدو معطّلًا. */
.client-card.is-unread { border-inline-start: 3px solid var(--brand); }

/* الرسالة نصّ حرّ من زائر: `pre-wrap` يحفظ أسطره، و`overflow` يمنع سطرًا
   واحدًا طويلًا (رابط بلا مسافات) من توسيع البطاقة وكسر الشبكة. */
.lead-message { flex: 1; margin: 13px 0; padding: 12px 13px; border-radius: var(--r-btn); background: var(--surface-sunk); color: var(--ink-soft); font-size: .82rem; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 190px; overflow-y: auto; }

/* حشوة رؤوس الأقسام داخل اللوحات.
   كانت سمة `style` مضمّنة في خمسة مواضع — و`style-src 'self'` يُلغيها بلا
   رسالة، فلم تُطبَّق يومًا. والسمة المضمّنة هنا ممنوعة أصلًا، فمكانها صنف. */
.panel-heading { padding: 18px 20px 0; }
.icon-sprite { position: absolute; }

/* ==================== رسم المحصَّل ==================== */

.chart { padding: 16px 20px 4px; }
.chart-empty { margin: 0 0 14px; font-size: .85rem; }
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 132px; }
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
/* العمود يملأ من الأسفل: `justify-content:flex-end` يجعل الارتفاع يُقرأ من
   خطّ القاعدة كما تتوقّع العين، لا من الأعلى. */
.chart-track { position: relative; flex: 1; width: 100%; }
.chart-fill { position: absolute; inset-inline: 0; bottom: 0; height: 100%; transform-origin: bottom; border-radius: 6px 6px 2px 2px; background: var(--brand-soft); transition: background .15s ease; }
.chart-bar:hover .chart-fill { background: var(--brand); }
/* أعلى شهر بلون العلامة: رقمٌ واحد يستحق التمييز في اثني عشر. */
.chart-bar.is-peak .chart-fill { background: var(--brand); }
.chart-bar small { color: var(--faint); font-size: .68rem; font-variant-numeric: tabular-nums; }
.chart-note { margin: 12px 0 0; font-size: .76rem; }

@media (max-width: 520px) {
  .chart-bars { height: 104px; gap: 3px; }
  .chart-bar small { font-size: .6rem; }
}

/* ============================================================
   تعديلات الوضع الداكن على المكوّنات
   ============================================================
   في آخر الملف لا مع الرموز في أوّله: هذه قواعد مكوّنات بالوزن نفسه الذي
   لقواعدها الفاتحة، فالمتأخّر يفوز. وضعُها في الأعلى يجعلها تُكتب ثم
   تُلغى — وهو ما حدث فعلًا: بقي الزرّ الأساسي أبيض على أخضر فاتح بتباين
   2.6:1، أي نصّ لا يكاد يُقرأ.
   ============================================================ */
@media (prefers-color-scheme: dark) {
  /* الأبيض الصريح على أخضر فاتح لا يُقرأ: الحبر الداكن يعطي 8:1. */
  .button-primary, .nav-badge, .brand-mark { color: var(--canvas); }
  .button-danger:hover { color: var(--canvas); }
  .topbar { background: rgba(14, 27, 34, .88); }
  .toolbar input:focus, .toolbar select:focus { background: var(--surface-sunk); }
}

/* زرّا النافذة: الموقع العام ولوحة الإدارة جنبًا إلى جنب. */
.credential-links { display: flex; flex-wrap: wrap; gap: 10px; }
