/* REDESIGN-2026 · المكوّنات المشتركة (src/ui/) — M0.1: الزر، شارة الحالة، بطاقة الرقم،
   الإشعار، نافذة القرار.

   كل الأصناف بادئتها `ty-` عشان ماتتخبطش في أصناف `styles.css` القديمة، وكل القيم من
   `--ty-*` (‏src/styles/tokens.css) فبتتقلب مع الوضع الداكن لوحدها.
   مفيش `style=` في أي مكوّن: سياسة الأمان (`style-src 'self'`) بتحجبه. */

/* ---------------------------------------------------------------- الزر */
.ty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: var(--ty-touch);
  min-height: var(--ty-touch);
  padding: 0 20px;
  border: 1.5px solid var(--ty-line-strong);
  border-radius: var(--ty-radius-s);
  background: var(--ty-surface);
  color: var(--ty-text);
  font-family: var(--ty-font-body);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .ty-btn:hover {
    border-color: var(--ty-text-3);
  }
}
/* اللمس مالوش hover: الإحساس بالضغط ييجي من `:active` لحظة ما الصباع ينزل (ده بيشتغل مع الماوس كمان). */
.ty-btn:active:not(:disabled):not([aria-disabled="true"]) {
  filter: brightness(0.93);
}
.ty-btn:focus-visible,
.ty-icon-btn:focus-visible {
  outline: 3px solid var(--ty-green);
  outline-offset: 2px;
}
.ty-btn--primary {
  border-color: var(--ty-green);
  background: var(--ty-green);
  color: var(--ty-on-green);
  font-weight: 700;
}
@media (hover: hover) and (pointer: fine) {
  .ty-btn--primary:hover {
    border-color: var(--ty-green-deep);
    background: var(--ty-green-deep);
  }
}
/* «رفض / حذف» في لوحة الأساس: أبيض بحدود ونص أحمر. */
.ty-btn--danger {
  color: var(--ty-bad-fg);
}
/* الزر الأساسي لنافذة خطرة (ألغِ الباقي، ارفض…): أحمر مليان. */
.ty-btn--danger-solid {
  border-color: var(--ty-danger);
  background: var(--ty-danger);
  color: var(--ty-on-danger);
  font-weight: 700;
}
.ty-btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ty-green);
}
@media (hover: hover) and (pointer: fine) {
  .ty-btn--ghost:hover {
    border-color: transparent;
    background: var(--ty-green-soft);
  }
}
.ty-btn--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ty-text-3);
}
@media (hover: hover) and (pointer: fine) {
  .ty-btn--quiet:hover {
    border-color: transparent;
    background: var(--ty-surface-2);
  }
}
/* شاشات المشرف في الموقع: 56px وخط أكبر. */
.ty-btn--field {
  min-height: var(--ty-touch-field);
  font-size: 18px;
}
.ty-btn--block {
  display: flex;
  width: 100%;
}
.ty-btn:disabled,
.ty-btn[aria-disabled="true"] {
  border-color: var(--ty-disabled-bg);
  background: var(--ty-disabled-bg);
  color: var(--ty-disabled-fg);
  cursor: not-allowed;
}
.ty-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.ty-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ty-touch);
  height: var(--ty-touch);
  flex-shrink: 0;
  border: 1px solid var(--ty-line);
  border-radius: var(--ty-radius-s);
  background: var(--ty-surface);
  color: var(--ty-text);
  font-size: 18px;
  cursor: pointer;
}

/* ---------------------------------------------------------------- شارة الحالة */
.ty-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ty-mute-bg);
  color: var(--ty-mute-fg);
  font-family: var(--ty-font-body);
  font-size: var(--ty-fs-xs);
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}
.ty-chip--g {
  background: var(--ty-ok-bg);
  color: var(--ty-ok-fg);
}
.ty-chip--a {
  background: var(--ty-warn-bg);
  color: var(--ty-warn-fg);
}
.ty-chip--r {
  background: var(--ty-bad-bg);
  color: var(--ty-bad-fg);
}
.ty-chip--b {
  background: var(--ty-info-bg);
  color: var(--ty-info-fg);
}

/* ---------------------------------------------------------------- بطاقة الرقم */
.ty-fact {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 16px 20px;
  border: 1px solid var(--ty-line);
  border-radius: var(--ty-radius-m);
  background: var(--ty-surface);
  font-family: var(--ty-font-body);
}
.ty-fact__label {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
  line-height: 1.4;
}
.ty-fact__value {
  color: var(--ty-text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  /* الرقم ما يتكسرش في نص أرقامه («16,315,784.» وتحتها «36»): الكلام بيتلف عند الكلمة، والرقم الطويل خطه بيصغر. */
  overflow-wrap: break-word;
}
@media (max-width: 480px) {
  .ty-fact {
    padding: 14px 12px;
  }
  .ty-fact__value {
    font-size: clamp(14px, 4.1vw, 20px);
  }
}
.ty-fact__unit {
  font-size: var(--ty-fs-xs);
  font-weight: 500;
}
.ty-fact__hint {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
  line-height: 1.4;
}
.ty-fact--g .ty-fact__value {
  color: var(--ty-ok-fg);
}
.ty-fact--a .ty-fact__value {
  color: var(--ty-warn-fg);
}
.ty-fact--r .ty-fact__value {
  color: var(--ty-bad-fg);
}
.ty-fact--b .ty-fact__value {
  color: var(--ty-info-fg);
}
.ty-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

/* ---------------------------------------------------------------- الإشعار (toast) */
.ty-toasts {
  position: fixed;
  inset-inline: 0;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.ty-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, 100%);
  padding: 12px 16px;
  border: 1px solid var(--ty-ok-fg);
  border-radius: var(--ty-radius-s);
  background: var(--ty-ok-bg);
  color: var(--ty-ok-fg);
  box-shadow: var(--ty-shadow);
  font-family: var(--ty-font-body);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  pointer-events: auto;
}
.ty-toast--bad {
  border-color: var(--ty-bad-fg);
  background: var(--ty-bad-bg);
  color: var(--ty-bad-fg);
}
.ty-toast--info {
  border-color: var(--ty-info-fg);
  background: var(--ty-info-bg);
  color: var(--ty-info-fg);
}
.ty-toast__text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.ty-toast__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ty-touch);
  height: var(--ty-touch);
  margin: -8px;
  margin-inline-start: 0;
  flex-shrink: 0;
  border: 0;
  border-radius: var(--ty-radius-s);
  background: transparent;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
}
/* على الموبايل الإشعار فوق: تحت فيه الشريط السفلي والزر الأساسي الثابت للنماذج والسجلات،
   وإشعار خطأ (ما بيختفيش لوحده) كان بيغطّي زر الحفظ ويمنع الضغط عليه. */
@media (max-width: 760px) {
  /* V2 · 11: الإشعار بيقعد فوق الشريط العلوي (71px) مش فوق عنوان الشاشة: كان من 12 لـ83px بسطرين فبيغطّي
     أول العنوان. من 4px وبحشو أقل: سطرين = 64px. */
  .ty-toasts {
    top: calc(4px + env(safe-area-inset-top, 0px));
    bottom: auto;
    padding: 0 8px;
  }
  .ty-toast {
    padding: 8px 12px;
    font-size: 14px;
  }
}
/* M0.6: نفس الحكاية على الويب لما درج نموذج أو نافذة مفتوحة — الخادم لما يرفض، إشعار الخطأ (بيفضل لحد
   ما يتقفل) كان بيقع فوق زر «احفظ» في تذييل الدرج ويخطف الضغطة. فوق الشاشة مفيش حاجة بتتضغط تحته. */
body:has(.ty-form-scrim, .ty-dialog-scrim) .ty-toasts {
  top: calc(12px + env(safe-area-inset-top, 0px));
  bottom: auto;
}

/* ---------------------------------------------------------------- نافذة القرار */
.ty-dialog-scrim {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ty-scrim);
}
.ty-dialog {
  display: flex;
  flex-direction: column;
  width: 520px;
  max-width: 100%;
  max-height: 100%;
  border: 1px solid var(--ty-line);
  border-radius: var(--ty-radius-l);
  background: var(--ty-surface);
  color: var(--ty-text);
  box-shadow: var(--ty-shadow-dialog);
  font-family: var(--ty-font-body);
}
.ty-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 26px 6px;
}
.ty-dialog__heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ty-dialog__section {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
  line-height: 1.4;
}
.ty-dialog__title {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.ty-dialog__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px 26px 22px;
  overflow-y: auto;
}
.ty-dialog__intro {
  margin: 0;
  color: var(--ty-text-2);
  font-size: 14px;
  line-height: 1.7;
}
.ty-dialog__info {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--ty-radius-s);
  background: var(--ty-mute-bg);
  color: var(--ty-mute-fg);
  font-size: 14px;
  line-height: 1.7;
}
.ty-dialog__info--g {
  background: var(--ty-ok-bg);
  color: var(--ty-ok-fg);
}
.ty-dialog__info--a {
  background: var(--ty-warn-bg);
  color: var(--ty-warn-fg);
}
.ty-dialog__info--r {
  background: var(--ty-bad-bg);
  color: var(--ty-bad-fg);
}
.ty-dialog__info--b {
  background: var(--ty-info-bg);
  color: var(--ty-info-fg);
}
.ty-dialog__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 26px 20px;
  border-top: 1px solid var(--ty-line-soft);
}
.ty-dialog__foot .ty-btn--primary,
.ty-dialog__foot .ty-btn--danger-solid {
  padding: 0 22px;
}
/* «إلغاء» في آخر الصف (المرجع: margin-inline-start: auto). */
.ty-dialog__cancel {
  margin-inline-start: auto;
  padding: 0 12px;
  font-size: 15px;
}

/* الحقول جوّه النافذة — نفس قواعد النموذج (SPEC §5): `*` أحمر للإلزامي،
   «(اختياري)» مكتوبة، الوحدة جوّه الحقل الرقمي، والتلميح تحت الحقل. */
.ty-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.ty-field__label {
  color: var(--ty-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}
.ty-field__req {
  color: var(--ty-danger);
}
.ty-field__opt {
  color: var(--ty-text-3);
  font-weight: 400;
}
.ty-field__control {
  display: flex;
  align-items: stretch;
  min-height: 48px;
  border: 1.5px solid var(--ty-line-strong);
  border-radius: var(--ty-radius-s);
  background: var(--ty-surface);
}
.ty-field__control:focus-within {
  border-color: var(--ty-green);
  outline: 2px solid var(--ty-green);
  outline-offset: 0;
}
.ty-field__input {
  flex: 1;
  min-width: 0;
  /* الهدف نفسه 48px (المرجع 48 بالحدود = 45 جوّه، وده تحت حد اللمس). */
  min-height: var(--ty-touch);
  padding: 10px 14px;
  border: 0;
  border-radius: var(--ty-radius-s);
  background: transparent;
  color: var(--ty-text);
  font-family: var(--ty-font-body);
  font-size: 15px;
  line-height: 1.6;
}
.ty-field__input::placeholder {
  color: var(--ty-text-4);
}
.ty-field__control--number .ty-field__input {
  font-weight: 700;
}
.ty-field__input:focus {
  outline: none;
}
textarea.ty-field__input {
  padding: 12px 14px;
  resize: vertical;
}
.ty-field__unit {
  display: inline-flex;
  align-items: center;
  padding-inline: 4px 14px;
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
  font-weight: 600;
  white-space: nowrap;
}
.ty-field__hint {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
  line-height: 1.6;
}
.ty-field__error:empty {
  display: none;
}
.ty-field__error {
  color: var(--ty-bad-fg);
  font-size: var(--ty-fs-xs);
  font-weight: 600;
}
.ty-field.is-invalid .ty-field__control {
  border-color: var(--ty-danger);
}
.ty-field.is-hidden {
  display: none;
}
.ty-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--ty-touch);
  padding: 8px 14px;
  border: 1.5px solid var(--ty-line-strong);
  border-radius: var(--ty-radius-s);
  background: var(--ty-surface);
  color: var(--ty-text);
  font-size: 15px;
  line-height: 1.5;
  cursor: pointer;
}
.ty-toggle:focus-within {
  border-color: var(--ty-green);
  outline: 2px solid var(--ty-green);
}
/* المفتاح: مربع اختيار حقيقي (role="switch") مرسوم 46×28 — لوحة المفاتيح وقارئ الشاشة
   شغالين من غير سطر JS. */
/* `input.` عمدًا: styles.css بيثبّت كل مربع اختيار على 24×24 في الموبايل بمحدِّد
   `input[type="checkbox"]`، والصنف لوحده بيخسر قدامه. */
input.ty-switch {
  position: relative;
  width: 46px;
  min-width: 46px;
  height: 28px;
  min-height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  flex-shrink: 0;
  border-radius: 14px;
  background: var(--ty-line-strong);
  appearance: none;
  cursor: pointer;
}
input.ty-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ty-surface);
}
input.ty-switch:checked {
  background: var(--ty-green);
}
input.ty-switch:checked::after {
  inset-inline-start: auto;
  inset-inline-end: 3px;
}
input.ty-switch:focus {
  outline: none;
}
/* منطقة رفع الملف: إطار متقطّع بنص المرجع، والـinput مخفي بصريًّا بس. */
.ty-file {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 10px;
  border: 2px dashed var(--ty-line-strong);
  border-radius: var(--ty-radius-s);
  background: var(--ty-bg);
  color: var(--ty-text-2);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  cursor: pointer;
}
.ty-file:focus-within {
  border-color: var(--ty-green);
  outline: 2px solid var(--ty-green);
}
.ty-file__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.ty-file__text {
  overflow-wrap: anywhere;
}
.ty-field.is-invalid .ty-file {
  border-color: var(--ty-danger);
}

/* موبايل: ورقة سفلية بعرض الشاشة (M-Dialog) بمقبض فوق وأزرار بعرض كامل. */
@media (max-width: 640px) {
  .ty-dialog-scrim {
    align-items: flex-end;
    padding: 0;
  }
  .ty-dialog {
    width: 100%;
    max-height: 92%;
    border-width: 1px 0 0;
    border-radius: 24px 24px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .ty-dialog::before {
    content: "";
    align-self: center;
    width: 44px;
    height: 5px;
    margin-top: 10px;
    border-radius: 999px;
    background: var(--ty-line-strong);
  }
  .ty-dialog__head {
    padding: 14px 20px 6px;
  }
  /* المرجع M-Dialog من غير ✕: الورقة بتتقفل بـ«إلغاء» أو بضغطة برّه. */
  .ty-dialog__close {
    display: none;
  }
  .ty-dialog__body {
    padding: 8px 20px 16px;
  }
  .ty-field__control {
    min-height: 56px;
    border-radius: 14px;
  }
  .ty-field__input {
    font-size: 17px;
  }
  textarea.ty-field__input {
    font-size: 16px;
  }
  .ty-dialog__foot {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 20px 24px;
  }
  .ty-dialog__foot .ty-btn {
    width: 100%;
    margin: 0;
    border-radius: 14px;
  }
  .ty-dialog__foot .ty-btn--primary,
  .ty-dialog__foot .ty-btn--danger-solid {
    min-height: 60px;
    border-radius: var(--ty-radius-m);
    font-size: 18px;
  }
}

/* ================================================================ M0.2
   النموذج (W-Form / M-Form) · الحالات (M16) · القائمة (M-List) · صفحة السجل (W/M-Record) */

/* ---------------------------------------------------------------- حقول النموذج */
.ty-auto {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--ty-touch);
  padding: 12px 14px;
  border: 1.5px solid var(--ty-line-soft);
  border-radius: var(--ty-radius-s);
  background: var(--ty-surface-2);
  color: var(--ty-text-2);
  font-size: 15px;
  font-weight: 600;
}
.ty-auto small {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

/* قيمة للعرض والنسخ (مفتاح، رمز): من الشمال لليمين، وضغطة بتحدّدها كلها. */
.ty-copy {
  display: block;
  min-height: var(--ty-touch);
  padding: 12px 14px;
  border: 1.5px solid var(--ty-line-soft);
  border-radius: var(--ty-radius-s);
  background: var(--ty-surface-2);
  color: var(--ty-text);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 15px;
  direction: ltr;
  text-align: start;
  overflow-wrap: anywhere;
  user-select: all;
}

/* ---------------------------------------------------------------- النموذج */
.ty-form-scrim {
  position: fixed;
  inset: 0;
  z-index: 105;
  display: flex;
  justify-content: flex-end;
  background: var(--ty-scrim);
}
.ty-form {
  display: flex;
  flex-direction: column;
  width: 600px;
  max-width: 100%;
  height: 100%;
  border-inline-start: 1px solid var(--ty-line);
  background: var(--ty-surface);
  color: var(--ty-text);
  box-shadow: var(--ty-shadow-dialog);
  font-family: var(--ty-font-body);
}
.ty-form__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--ty-line-soft);
}
.ty-form__heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ty-form__section {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
}
.ty-form__title {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.ty-form__lede {
  color: var(--ty-text-2);
  font-size: 14px;
  line-height: 1.6;
}
.ty-form__body {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 16px;
  padding: 20px 28px 28px;
  overflow-y: auto;
}
.ty-form__body > * {
  flex: 1 1 100%;
}
.ty-form__body > .ty-field--half {
  flex: 1 1 calc(50% - 8px);
  min-width: 200px;
}
.ty-form__scope {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  border-radius: var(--ty-radius-s);
  background: var(--ty-ok-bg);
  color: var(--ty-ok-fg);
  font-size: 14px;
}
.ty-form__scope .ty-btn {
  padding: 0 8px;
  font-size: 14px;
  font-weight: 700;
}
/* REVIEW-1024: «سجل المؤشرات» مطوي في التقارير — السهم جنب العنوان مش فوقه. */
.metric-registry__fold > summary {
  cursor: pointer;
}
.metric-registry__fold > summary h3 {
  display: inline;
}

/* REVIEW-1024: سطر «هيتقبض كام» فوق حقول النموذج. */
.ty-form__summary {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--ty-radius-s);
  background: var(--ty-surface-2);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.ty-form__note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--ty-radius-s);
  background: var(--ty-warn-bg);
  color: var(--ty-warn-fg);
  font-size: 14px;
  line-height: 1.7;
}
.ty-form__note svg {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
}
.ty-form__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 28px 22px;
  border-top: 1px solid var(--ty-line-soft);
  background: var(--ty-surface);
}
.ty-form__foot .ty-btn--primary {
  padding: 0 24px;
}
.ty-form__cancel {
  margin-inline-start: auto;
  padding: 0 14px;
  font-size: 15px;
}

/* ---------------------------------------------------------------- الحالات */
.ty-state {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: var(--ty-font-body);
}
.ty-state--empty {
  gap: 20px;
  padding: 28px 4px;
}
.ty-state__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--ty-radius-l);
  background: var(--ty-green-soft);
  color: var(--ty-green);
}
.ty-state__icon svg {
  width: 36px;
  height: 36px;
}
.ty-state--empty .ty-state__title {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
}
.ty-state--empty .ty-state__text {
  margin: 0;
  color: var(--ty-text-2);
  font-size: 16px;
  line-height: 1.7;
}
.ty-state--loading {
  padding: 8px 0;
}
.ty-skeleton {
  height: 92px;
  border-radius: var(--ty-radius-m);
  background: var(--ty-line-soft);
}
.ty-skeleton--head {
  width: 70%;
  height: 44px;
  border-radius: var(--ty-radius-s);
  background: var(--ty-line);
}
.ty-state__status {
  margin-top: 8px;
  color: var(--ty-text-3);
  font-size: 14px;
  text-align: center;
}
.ty-state--error {
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--ty-bad-fg);
  border-radius: var(--ty-radius-m);
  background: var(--ty-bad-bg);
  color: var(--ty-bad-fg);
}
.ty-state--error .ty-state__title {
  font-size: 16px;
}
.ty-state--error .ty-state__text {
  font-size: 14px;
  line-height: 1.7;
}
.ty-state__retry {
  align-self: flex-start;
  border-color: var(--ty-bad-fg);
  background: var(--ty-bad-fg);
  color: var(--ty-bad-bg);
  font-size: 15px;
  font-weight: 700;
}
@media (hover: hover) and (pointer: fine) {
  .ty-state__retry:hover {
    border-color: var(--ty-bad-fg);
  }
}
/* آخر نسخة اتحمّلت تحت بطاقة الخطأ: بتتبهّت بالحد والخلفية، مش بـopacity على النص
   (تباين النص لازم يفضل ≥ 4.5). */
.ty-stale {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ty-stale .ty-list__row {
  border-style: dashed;
  background: var(--ty-surface-2);
}

/* ---------------------------------------------------------------- القائمة */
.ty-list {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--ty-bg);
  color: var(--ty-text);
  font-family: var(--ty-font-body);
}
.ty-list__head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--ty-line-soft);
}
.ty-list__top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ty-list__back,
.ty-record__back {
  width: 52px;
  height: 52px;
  border-radius: 14px;
}
/* RV2-RTL-ICONS: أسهم الاتجاه المرسومة SVG مرسومة للعربي — «رجوع» شايل يمين (أول السطر) وسهم خطوات الشراء
   شايل شمال (الخطوة الجاية). في الإنجليزي (ltr) أول السطر شمال، فبتتقلب مرآة. العربي ماتلمسش. */
[dir="ltr"] :is(.ty-list__back svg, .ty-record__back svg, .s3-back svg, svg.s2-step__arrow) {
  transform: scaleX(-1);
}
.ty-list__heading {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
.ty-list__section {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
}
.ty-list__name {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 23px;
  font-weight: 700;
  line-height: 1.3;
}
.ty-list__count {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--ty-mute-bg);
  color: var(--ty-mute-fg);
  font-size: var(--ty-fs-xs);
  font-weight: 700;
  white-space: nowrap;
}
.ty-search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--ty-touch);
  padding: 0 14px;
  border: 1.5px solid var(--ty-line-strong);
  border-radius: 14px;
  background: var(--ty-surface);
  color: var(--ty-text-3);
}
.ty-search:focus-within {
  border-color: var(--ty-green);
  outline: 2px solid var(--ty-green);
}
.ty-search input {
  flex: 1;
  min-width: 0;
  min-height: var(--ty-touch);
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ty-text);
  font-family: var(--ty-font-body);
  font-size: 15px;
}
.ty-pills {
  display: flex;
  gap: 8px;
  padding-bottom: 2px;
  overflow-x: auto;
}
.ty-pill {
  flex-shrink: 0;
  min-height: var(--ty-touch);
  padding: 0 16px;
  border: 1.5px solid var(--ty-line-strong);
  border-radius: 999px;
  background: var(--ty-surface);
  color: var(--ty-text);
  font-family: var(--ty-font-body);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.ty-pill[aria-pressed="true"] {
  border-color: var(--ty-green);
  background: var(--ty-green);
  color: var(--ty-on-green);
  font-weight: 700;
}
.ty-pill:focus-visible,
.ty-list__row:focus-visible,
.ty-tab:focus-visible,
.ty-crumb:focus-visible {
  outline: 3px solid var(--ty-green);
  outline-offset: 2px;
}
.ty-list__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 12px 20px 24px;
}
/* AUDIT-1022 · 10: جوّه صفحة الشغل (المستخلصات، الفريق، الشركات) الصفحة ليها هامشها أصلًا — هامش
   القايمة فوقه خلّى الشاشات دي أضيق من جاراتها بـ20px من كل ناحية. */
.main-workspace .ty-list__head,
.main-workspace .ty-list__body {
  padding-inline: 0;
}
.ty-list__row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 72px;
  padding: 12px 16px;
  border: 1px solid var(--ty-line);
  border-radius: var(--ty-radius-m);
  background: var(--ty-surface);
  color: var(--ty-text);
  font-family: var(--ty-font-body);
  text-align: start;
  cursor: pointer;
}
.ty-list__line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.ty-list__title {
  min-width: 0;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.ty-list__value {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.ty-list__sub {
  min-width: 0;
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
  overflow-wrap: anywhere;
}
.ty-list__fab {
  position: sticky;
  bottom: var(--ty-tabbar-h, 0px);
  padding: 12px 20px 22px;
  background: var(--ty-bg);
}
.ty-list__fab .ty-btn {
  min-height: 60px;
  border-radius: var(--ty-radius-m);
}
.ty-list__fab svg {
  width: 22px;
  height: 22px;
}

/* ---------------------------------------------------------------- صفحة السجل */
.ty-record {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--ty-bg);
  color: var(--ty-text);
  font-family: var(--ty-font-body);
}
.ty-record__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 40px;
  border-bottom: 1px solid var(--ty-line-soft);
}
.ty-record__heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ty-record__path {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ty-record__back {
  display: none;
}
.ty-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ty-text-3);
  font-size: 14px;
}
.ty-crumb {
  min-width: var(--ty-touch);
  min-height: var(--ty-touch);
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--ty-text-3);
  font-family: var(--ty-font-body);
  font-size: 14px;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .ty-crumb:hover {
    color: var(--ty-green);
  }
}
.ty-record__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.ty-record__title h2 {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.ty-record__sub {
  color: var(--ty-text-3);
  font-size: 14px;
  line-height: 1.6;
}
.ty-record__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.ty-record__actions--top .ty-btn--primary {
  padding: 0 22px;
}
.ty-record__actions--bottom {
  display: none;
}
.ty-record__main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 22px;
  padding: 24px 40px 48px;
}
.ty-record__main .ty-facts {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.ty-record__main .ty-fact {
  gap: 4px;
  padding: 14px 16px;
  border-radius: 14px;
}
.ty-record__alert {
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.7;
}
.ty-record__cols {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 22px;
}
.ty-card {
  border: 1px solid var(--ty-line);
  border-radius: 18px;
  background: var(--ty-surface);
  overflow: hidden;
}
.ty-card--pad {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px;
}
.ty-card h3 {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 16px;
  font-weight: 700;
}
.ty-record__table {
  flex: 2 1 560px;
  min-width: 0;
}
.ty-record__side {
  display: flex;
  flex: 1 1 300px;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.ty-tabs {
  display: flex;
  gap: 22px;
  padding: 0 20px;
  border-bottom: 1px solid var(--ty-line-soft);
  overflow-x: auto;
}
/* عدّاد التبويب (`<small>`) — بيتقري، فمايقلّش عن 12px (qa-text-fit: «tiny»). */
.ty-tab small {
  font-size: var(--ty-fs-xs);
}
.ty-tab {
  flex-shrink: 0;
  min-width: var(--ty-touch);
  min-height: var(--ty-touch);
  padding: 12px 0;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--ty-text-2);
  font-family: var(--ty-font-body);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.ty-tab[aria-selected="true"] {
  border-bottom-color: var(--ty-green);
  color: var(--ty-green);
  font-weight: 700;
}
.ty-record__scroll {
  overflow-x: auto;
}
.ty-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.ty-table th {
  padding: 10px 16px;
  background: var(--ty-surface-2);
  color: var(--ty-text-2);
  font-size: var(--ty-fs-xs);
  font-weight: 600;
  text-align: start;
  white-space: nowrap;
}
.ty-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--ty-line-soft);
  vertical-align: top;
}
.ty-record__foot,
.ty-record__none {
  margin: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--ty-line-soft);
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
  line-height: 1.6;
}
.ty-record__none {
  border-top: 0;
  font-size: 14px;
}
.ty-kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--ty-line-soft);
  font-size: 14px;
}
.ty-kv span {
  color: var(--ty-text-3);
}
.ty-kv span {
  min-width: 0;
}
/* FIX-ROUND V2 · 3: `overflow-wrap: anywhere` كانت بتخلّي أقل عرض للقيمة حرف واحد، فالصف يعصرها ويكسر
   «13,360,630» سطرين على 360. `break-word` بيسيب أقل عرض = أطول كلمة: العنوان هو اللي بيلفّ، والرقم
   (`dir="ltr"`) ما بيتكسرش خالص. قيمة نص طويلة لسه بتلفّ عند المسافات. */
.ty-kv b {
  text-align: end;
  overflow-wrap: break-word;
}
.ty-kv b[dir="ltr"] {
  flex-shrink: 0;
  white-space: nowrap;
}
.ty-timeline__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--ty-line-soft);
  font-size: 14px;
}
.ty-timeline__dot {
  width: 8px;
  height: 8px;
  margin-top: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--ty-green);
}
.ty-timeline__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ty-timeline__text small {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
}

/* ---------------------------------------------------------------- موبايل M0.2 */
@media (max-width: 640px) {
  /* النموذج شاشة كاملة (M-Form): ✕ في الأول، العنوان 22، الحقول 56، الزر الأساسي 60 ثابت تحت. */
  .ty-form {
    width: 100%;
    border: 0;
    background: var(--ty-bg);
  }
  .ty-form__head {
    flex-direction: row-reverse;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px 12px;
  }
  .ty-form__close {
    width: 52px;
    height: 52px;
    border-radius: 14px;
  }
  .ty-form__title {
    font-family: var(--ty-font-head);
    font-size: 22px;
    font-weight: 700;
  }
  .ty-form__body {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 18px;
    padding: 16px 20px 24px;
  }
  .ty-form__body > *,
  .ty-form__body > .ty-field--half {
    flex: 0 0 auto;
    min-width: 0;
  }
  .ty-form__foot {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 20px 22px;
    border-top-color: var(--ty-line);
  }
  .ty-form__foot .ty-btn {
    width: 100%;
    border-radius: 14px;
  }
  .ty-form__foot .ty-btn--primary {
    min-height: 60px;
    border-radius: var(--ty-radius-m);
    font-size: 18px;
  }
  /* المرجع M-Form من غير «إلغاء»: القفل من ✕ فوق. */
  .ty-form__cancel {
    display: none;
  }

  /* صفحة السجل (M-Record): رجوع + مسار، عنوان 21، بطاقتين في الصف، أزرار ثابتة تحت. */
  .ty-record__head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 20px;
  }
  .ty-record__back {
    display: inline-flex;
  }
  .ty-record__path {
    justify-content: space-between;
  }
  .ty-crumbs {
    flex: 1;
    font-size: var(--ty-fs-xs);
  }
  .ty-record__title h2 {
    font-size: 21px;
    line-height: 1.35;
  }
  .ty-record__actions--top > :not([data-record-menu]) {
    display: none;
  }
  .ty-record__actions--top {
    position: absolute;
    inset-inline-end: 20px;
  }
  .ty-record__head {
    position: relative;
  }
  .ty-record__path {
    padding-inline-end: 62px;
  }
  .ty-record__actions--top .ty-icon-btn {
    width: 52px;
    height: 52px;
    border-radius: 14px;
  }
  .ty-record__main {
    gap: 16px;
    padding: 16px 20px 24px;
  }
  .ty-record__main .ty-facts {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .ty-record__main .ty-fact {
    padding: 12px 14px;
  }
  .ty-record__cols {
    flex-direction: column;
    /* nowrap عمدًا: عمود بـwrap بيقيس عرض كل ابن بمحتواه، فصف التبويبات مدّ البطاقة 35px. */
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 16px;
  }
  .ty-record__table,
  .ty-record__side {
    flex: 0 0 auto;
  }
  .ty-card {
    border-radius: var(--ty-radius-m);
  }
  .ty-card--pad {
    gap: 6px;
    padding: 14px 16px;
  }
  .ty-card h3 {
    font-size: 15px;
  }
  /* PHONE-FIT: كل التبويبات باينة مرة واحدة — سطرين بدل صف بيتسحب يمين وشمال. */
  .ty-tabs {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: visible;
  }
  .ty-pills {
    flex-wrap: wrap;
    overflow-x: visible;
  }
  .ty-tab {
    padding: 0 14px;
    border: 1.5px solid var(--ty-line-strong);
    border-radius: 999px;
    font-size: 14px;
  }
  .ty-tab[aria-selected="true"] {
    border-color: var(--ty-green);
    background: var(--ty-green);
    color: var(--ty-on-green);
  }
  /* الجدول بيبقى بطاقات: أول خانتين في سطر، والباقي في السطر اللي تحته. */
  .ty-table thead {
    display: none;
  }
  .ty-table,
  .ty-table tbody {
    display: block;
  }
  .ty-table tr {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--ty-line-soft);
  }
  .ty-table td {
    padding: 0;
    border: 0;
    color: var(--ty-text-3);
    font-size: var(--ty-fs-xs);
  }
  .ty-table td:empty {
    display: none;
  }
  .ty-table td:first-child {
    flex: 1 1 55%;
    color: var(--ty-text);
    font-size: 15px;
    font-weight: 700;
  }
  .ty-table td:nth-child(2) {
    color: var(--ty-text-2);
    font-size: 15px;
  }
  .ty-record__actions--bottom {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 20px 22px;
    border-top: 1px solid var(--ty-line);
    background: var(--ty-surface);
  }
  .ty-record__actions--bottom .ty-btn--primary {
    min-height: 60px;
    border-radius: var(--ty-radius-m);
  }
  .ty-record__more {
    display: flex;
    align-items: flex-start;
    gap: 8px;
  }
  .ty-record__more:empty {
    display: none;
  }
  .ty-record__more .ty-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 10px;
    border-radius: 14px;
    font-size: 14px;
  }
}

/* ================================================================ M0.3
   شريحة الاتصال · شريط المسودة · دليل الشاشة · الوضع التجريبي · قالب الطباعة */

/* ---------------------------------------------------------------- شريحة الاتصال (6 حالات) */
.ty-conn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--ty-ok-bg);
  color: var(--ty-ok-fg);
  font-family: var(--ty-font-body);
  font-size: var(--ty-fs-xs);
  font-weight: 700;
  line-height: 1.4;
}
.ty-conn--sync {
  background: var(--ty-info-bg);
  color: var(--ty-info-fg);
}
.ty-conn--warn {
  background: var(--ty-warn-bg);
  color: var(--ty-warn-fg);
}
.ty-conn--bad {
  background: var(--ty-bad-bg);
  color: var(--ty-bad-fg);
}
.ty-conn__dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
}
.ty-conn__text {
  min-width: 0;
}
.ty-conn__action {
  min-width: var(--ty-touch);
  min-height: var(--ty-touch);
  margin-block: -8px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--ty-font-body);
  font-size: var(--ty-fs-xs);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------------------------------------------------------------- شريط استرجاع المسودة */
.ty-draft {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 14px;
  border-radius: var(--ty-radius-s);
  background: var(--ty-info-bg);
  color: var(--ty-info-fg);
  font-family: var(--ty-font-body);
  font-size: 14px;
  line-height: 1.6;
}
.ty-draft svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.ty-draft__text {
  flex: 1 1 200px;
  min-width: 0;
}
.ty-draft__clear {
  min-height: var(--ty-touch);
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--ty-font-body);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------------------------------------------------------------- دليل الشاشة (درج) */
.ty-help-scrim {
  position: fixed;
  inset: 0;
  z-index: 104;
  display: flex;
  justify-content: flex-end;
  background: var(--ty-scrim);
}
.ty-help {
  display: flex;
  flex-direction: column;
  width: 420px;
  max-width: 100%;
  height: 100%;
  border-inline-start: 1px solid var(--ty-line);
  background: var(--ty-surface);
  color: var(--ty-text);
  box-shadow: var(--ty-shadow-dialog);
  font-family: var(--ty-font-body);
}
/* ORGANIZE-1101: «الدليل» نفس الدرج بس أعرض — شبكة «كل الأقسام» محتاجة عمودين على الويب. */
.ty-help--wide {
  width: 720px;
}
/* جسم «الدليل»: كروت ورا بعض (تفاصيل الكروت في s4.css مع كروت الرئيسية). */
.ty-guide__body {
  gap: 14px;
}
/* نفس عيب .ac-page: كارت بـoverflow: hidden جوّه عمود flex بيتعصر لـ34px — flex: none يخلّيه ياخد طوله. */
.ty-guide__body > * {
  flex: none;
}
.ty-help__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--ty-line-soft);
}
.ty-help__head h2 {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 19px;
  font-weight: 800;
  line-height: 1.35;
}
.ty-help__body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 22px 28px;
  overflow-y: auto;
}
.ty-help__body h3 {
  margin: 0 0 6px;
  font-family: var(--ty-font-head);
  font-size: 15px;
  font-weight: 700;
}
.ty-help__body p {
  margin: 0;
  color: var(--ty-text-2);
  font-size: 15px;
  line-height: 1.8;
}
.ty-help__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding-inline-start: 20px;
  color: var(--ty-text-2);
  font-size: 15px;
  line-height: 1.7;
}

/* ---------------------------------------------------------------- الوضع التجريبي */
.ty-demo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  padding: 6px 16px;
  background: var(--ty-warn-bg);
  color: var(--ty-warn-fg);
  font-family: var(--ty-font-body);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}
.ty-demo.is-hidden {
  display: none;
}
.ty-demo button {
  min-height: var(--ty-touch);
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--ty-font-body);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------------------------------------------------------------- قالب الطباعة الواحد
   الورق فاتح دايمًا: الألوان هنا ثابتة مش من الرموز اللي بتتقلب مع الوضع الداكن. */
.ty-print {
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: #16231f;
  font-family: var(--ty-font-body);
  font-size: 14px;
  line-height: 1.6;
}
.ty-print__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 2px solid #16231f;
}
.ty-print__head strong {
  font-family: var(--ty-font-head);
  font-size: 18px;
}
.ty-print__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.ty-print__title h1 {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 22px;
  font-weight: 800;
}
.ty-print__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 24px;
  margin: 0;
}
.ty-print__meta div,
.ty-print__totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.ty-print__meta dt,
.ty-print__totals dt {
  color: #4a5551;
}
.ty-print__meta dd,
.ty-print__totals dd {
  margin: 0;
  font-weight: 700;
}
/* 5-أ-٢: جدول البنود (6+ أعمدة بأرقام ملايين) أعرض من التليفون — بيتمرر أفقيًا جوه الورقة
   بدل ما يتقصّ من الشمال، والصفحة نفسها ما بتعرضش. في الطباعة الحاوية بتتفرد (s3.css). */
.ty-print__table-wrap {
  max-width: 100%;
  overflow-x: auto;
}
.ty-print__table {
  width: 100%;
  border-collapse: collapse;
}
.ty-print__table th,
.ty-print__table td {
  padding: 8px 10px;
  border: 1px solid #cbd5d0;
  text-align: start;
}
.ty-print__table th {
  background: #f7f8f4;
  font-weight: 700;
}
.ty-print__num {
  text-align: end;
  white-space: nowrap;
}
.ty-print__totals {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(320px, 100%);
  margin: 0;
  margin-inline-start: auto;
}
.ty-print__totals .is-strong {
  padding-top: 6px;
  border-top: 2px solid #16231f;
  font-size: 16px;
}
.ty-print__notes {
  margin: 0;
  color: #4a5551;
}
/* M0.5: نص حر، ملخّص تراكمي قبل الإجماليات، وصور الدليل (ورقة المستخلص والإرسالية). */
.ty-print__body p {
  margin: 0 0 6px;
}
.ty-print__summary h2 {
  margin: 0 0 6px;
  font-size: 14px;
}
.ty-print__summary dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #cbd5d0;
}
.ty-print__summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.ty-print__summary dt {
  color: #4a5551;
}
.ty-print__summary dd {
  margin: 0;
  font-weight: 700;
}
.ty-print__summary .is-strong {
  font-size: 15px;
}
.ty-print__photos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.ty-print__photos figure {
  margin: 0;
  break-inside: avoid;
}
.ty-print__photos img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid #cbd5d0;
}
.ty-print__photo-none {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  padding: 8px;
  border: 1px dashed #8a9692;
  color: #4a5551;
  font-size: var(--ty-fs-xs);
  text-align: center;
}
.ty-print__photos figcaption {
  margin-top: 4px;
  color: #4a5551;
  font-size: var(--ty-fs-xs);
}
.ty-print__signs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 28px;
}
.ty-print__signs div {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-top: 8px;
  border-top: 1px solid #16231f;
}
.ty-print__signs span {
  color: #4a5551;
}

@media (max-width: 640px) {
  .ty-help {
    width: 100%;
    border: 0;
  }
  .ty-print__meta {
    grid-template-columns: 1fr;
  }
}

/* ================================================================ M0.3a · شاشة مسجّلة
   شاشة سجّلتها جلسة (src/ui/registry.js) بتاخد ساحة العمل كلها تحت الشريط العلوي: العنوان
   القديم وزرّه ولوحات الرئيسية القديمة بيستخبّوا، والشاشة بترسم رأسها بنفسها. */
body.ty-screen .workspace-header,
body.ty-screen .next-step-wrap,
body.ty-screen .field-board-wrap,
body.ty-screen .waste-board-wrap,
body.ty-screen .risk-banner,
body.ty-screen .workflow-strip,
body.ty-screen .command-column {
  display: none;
}
body.ty-screen .workspace-grid {
  grid-template-columns: minmax(0, 1fr);
}

@media (prefers-reduced-motion: no-preference) {
  .ty-dialog {
    animation: ty-rise 160ms ease-out;
  }
  .ty-toast {
    animation: ty-rise 160ms ease-out;
  }
  .ty-form {
    animation: ty-fade 160ms ease-out;
  }
}
@keyframes ty-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes ty-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------------------------------------------------------------- اختيار المشروع (G01 / GM01) */
.ty-picker {
  position: relative;
  min-width: 0;
}
.ty-picker__caption {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
}
.ty-picker__button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: var(--ty-touch);
  padding: 0 12px;
  border: 1.5px solid var(--ty-line);
  border-radius: 12px;
  background: var(--ty-surface);
  color: var(--ty-text);
  font-family: var(--ty-font-body);
  font-size: 15px;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}
.ty-picker.is-open .ty-picker__button,
.ty-picker__button:focus-visible {
  border-color: var(--ty-green);
}
.ty-picker__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ty-picker__chev {
  color: var(--ty-green);
  flex-shrink: 0;
}
.ty-picker__backdrop {
  position: fixed;
  inset: 0;
  z-index: 109;
  background: transparent;
}
.ty-picker__panel {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  z-index: 110;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  overflow: hidden;
  border: 1px solid var(--ty-line);
  border-radius: 14px;
  background: var(--ty-surface);
  box-shadow: var(--ty-shadow-dialog);
}
.ty-picker__panel[hidden],
.ty-picker__backdrop[hidden],
.ty-picker__none[hidden],
.ty-picker__list li[hidden] {
  display: none;
}
.ty-picker__title {
  display: none;
  font-family: var(--ty-font-head);
  font-size: 19px;
}
.ty-picker__search {
  flex-shrink: 0;
  min-height: 40px;
  margin: 8px;
  padding: 0 14px;
  border: 1.5px solid var(--ty-line);
  border-radius: 12px;
  background: var(--ty-surface);
  color: var(--ty-text);
  font-family: var(--ty-font-body);
  font-size: 15px;
}
.ty-picker__list {
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
.ty-picker__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: var(--ty-touch);
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--ty-text);
  font-family: var(--ty-font-body);
  font-size: 15px;
  text-align: start;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .ty-picker__row:hover {
    background: var(--ty-surface-2);
  }
}
.ty-picker__row.is-current {
  background: var(--ty-ok-bg);
  color: var(--ty-ok-fg);
  font-weight: 700;
}
.ty-picker__label {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ty-picker__label small {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
  font-weight: 400;
}
.ty-picker__side {
  flex-shrink: 0;
  font-size: var(--ty-fs-xs);
}
.ty-picker__none {
  margin: 0;
  padding: 12px 14px;
  color: var(--ty-text-2);
  font-size: 14px;
}
.ty-picker__new {
  min-height: var(--ty-touch);
  padding: 0 14px;
  border: 0;
  border-top: 1px solid var(--ty-line-soft);
  background: transparent;
  color: var(--ty-green);
  font-family: var(--ty-font-body);
  font-size: 14px;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}
/* الموبايل: ورقة سفلية بغطاء (GM01). */
@media (max-width: 760px) {
  .ty-picker__backdrop {
    background: var(--ty-scrim);
  }
  .ty-picker__panel {
    position: fixed;
    inset-inline: 0;
    top: auto;
    bottom: 0;
    max-height: 78vh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-radius: 20px 20px 0 0;
    z-index: 110;
  }
  .ty-picker__title {
    display: block;
    padding: 16px 20px 0;
  }
  .ty-picker__search {
    min-height: 48px;
    margin: 12px 20px;
    font-size: 17px;
  }
  .ty-picker__row {
    min-height: 52px;
    margin: 0 12px 6px;
    width: calc(100% - 24px);
    border: 1px solid var(--ty-line);
    border-radius: 14px;
    font-size: 16px;
  }
}

/* ---------------------------------------------------------------- الجولة التفاعلية (T00-Tour · S6) */
.ty-tour-scrim {
  position: fixed;
  inset: 0;
  z-index: 108;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ty-scrim);
}
.ty-tour {
  display: flex;
  flex-direction: column;
  width: min(1040px, 100%);
  max-height: 100%;
  border: 1px solid var(--ty-line);
  border-radius: var(--ty-radius-l);
  background: var(--ty-bg);
  color: var(--ty-text);
  box-shadow: var(--ty-shadow-dialog);
  font-family: var(--ty-font-body);
  overflow: hidden;
}
.ty-tour__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--ty-line-soft);
  background: var(--ty-surface);
}
.ty-tour__head h2 {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 22px;
}
.ty-tour__head p {
  margin: 4px 0 0;
  color: var(--ty-text-2);
  font-size: 14px;
}
.ty-tour__body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  min-height: 0;
  padding: 20px 24px 24px;
  overflow: auto;
}
.ty-tour__nav ol {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ty-tour__group {
  margin-top: 10px;
  padding: 0 10px;
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
}
.ty-tour__step {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--ty-touch);
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ty-text);
  font-family: inherit;
  font-size: 15px;
  text-align: start;
  cursor: pointer;
}
.ty-tour__step b {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--ty-surface-2);
  font-size: var(--ty-fs-xs);
}
.ty-tour__step.is-current {
  background: var(--ty-charcoal);
  color: var(--ty-on-charcoal);
  font-weight: 700;
}
.ty-tour__step.is-current b {
  background: var(--ty-on-charcoal);
  color: var(--ty-charcoal);
}
.ty-tour__step:focus-visible {
  outline: 2px solid var(--ty-green);
  outline-offset: 2px;
}
.ty-tour__card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--ty-line);
  border-radius: var(--ty-radius-m);
  background: var(--ty-surface);
}
.ty-tour__count {
  color: var(--ty-text-3);
  font-size: var(--ty-fs-xs);
}
.ty-tour__name {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 24px;
}
.ty-tour__what {
  margin: 0;
  color: var(--ty-text-2);
  font-size: 16px;
  line-height: 1.7;
}
.ty-tour__block {
  padding: 12px 14px;
  border-radius: var(--ty-radius-s);
  background: var(--ty-surface-2);
}
.ty-tour__block h3 {
  margin: 0 0 4px;
  font-size: var(--ty-fs-xs);
  font-weight: 700;
}
.ty-tour__block p {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
}
.ty-tour__block--after {
  background: var(--ty-ok-bg);
}
.ty-tour__block--after h3,
.ty-tour__block--after p {
  color: var(--ty-ok-fg);
}
.ty-tour__block--try {
  background: var(--ty-warn-bg);
}
.ty-tour__block--try h3,
.ty-tour__block--try p {
  color: var(--ty-warn-fg);
}
.ty-tour__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
@media (max-width: 760px) {
  .ty-tour-scrim {
    padding: 0;
  }
  .ty-tour {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }
  .ty-tour__body {
    display: flex;
    flex-direction: column-reverse;
    gap: 16px;
    padding: 16px;
  }
  .ty-tour__foot > * {
    flex: 1 1 auto;
  }
}

/* ================================================================ FIX-ROUND V2
   9 · بطاقة الموبايل: كل رقم له اسم. `ty-table` بيبقى بطاقات ورأسه بيستخبى، فالصف كان «972,000 0 0 شغال».
   الاسم = عنوان العمود، بيتكتب على الخانة في `data-label` (`src/ui/table-labels.js`) وبيتعرض هنا. والخانة
   اللي كلها شرطة (`data-blank`) بتستخبى في البطاقة. على الويب الجدول برأسه زي ما هو. */
@media (max-width: 640px) {
  .ty-table td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--ty-text-3);
    font-size: var(--ty-fs-xs);
    font-weight: 400;
  }
  .ty-table td[data-blank] {
    display: none;
  }
}

/* 10 · صندوق بيتسحب بالعرض (شرايح، تبويبات، جدول عريض): طرفه بيبهت طول ما فيه باقي ما اتشافش — كان آخر
   عمود مقصوص على حرف، وخامس شريحة ظاهر منها 27px، من غير أي علامة. البهتان قناع مربوط بمكان التمرير:
   من غير تمرير (المحتوى سايع) مفيش قناع خالص، وفي آخر التمرير بيختفي. المتصفح اللي ما بيدعمش
   `animation-timeline` بيفضل زي ما كان (من غير علامة). */
@supports (animation-timeline: scroll()) {
  .ty-pills,
  .s1-tabs,
  .s1-table__scroll,
  .s2-card-scroll,
  .s3-scroll,
  .ty-record__scroll,
  .ac-table__scroll {
    --ty-fade: 36px;
    mask-image: linear-gradient(to right, transparent 0, black var(--ty-fade));
    mask-repeat: no-repeat;
    mask-position: 100% 0;
    mask-size: calc(100% + var(--ty-fade)) 100%;
    animation: ty-scroll-fade linear both;
    animation-timeline: scroll(self inline);
  }
  [dir="ltr"] :is(.ty-pills, .s1-tabs, .s1-table__scroll, .s2-card-scroll, .s3-scroll, .ty-record__scroll, .ac-table__scroll) {
    mask-image: linear-gradient(to left, transparent 0, black var(--ty-fade));
    mask-position: 0 0;
  }
}
@keyframes ty-scroll-fade {
  from,
  94% {
    mask-size: 100% 100%;
  }
  to {
    mask-size: calc(100% + var(--ty-fade)) 100%;
  }
}

/* عنوان الحالة الفاضية على التليفون: 24px كانت بتكسر «مفيش طلبات مستنية عروض» و«مفيش مخرجات مستنياك» سطرين
   على 360 (بعد ما V3 قصّرت العناوين). 18px: سطر واحد (مقيس)، ولو اتكسر السطرين متوازنين. */
@media (max-width: 480px) {
  .ty-state--empty .ty-state__title {
    font-size: 18px;
    text-wrap: balance;
  }
}

/* PHONE-FIT: المتصفح ما يكبّرش الخط من عنده (سفاري لما التليفون يتلف بالعرض) — الصفحة بمقاسها. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* PHONE-FIT: جداول التقارير على التليفون بطاقات — صف = بطاقة، وكل خانة سطر «اسمها: قيمتها». كانت
   جدول 860px (ومسجّل المؤشرات 1800px) بيتسحب يمين وشمال. الطباعة بتفضل جدول (`screen` بس). */
@media screen and (max-width: 640px) {
  .report-table-wrap {
    overflow-x: visible;
    border: 0;
    background: transparent;
  }
  .report-table,
  .report-table tbody,
  .report-table tr,
  .report-table td {
    display: block;
    width: 100%;
  }
  .report-table thead {
    display: none;
  }
  .report-table tr {
    margin-bottom: 10px;
    padding: 6px 12px;
    border: 1px solid var(--ty-line);
    border-radius: 12px;
    background: var(--ty-surface);
  }
  .report-table td,
  .report-table td.num {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 7px 0;
    border-bottom: 0;
    text-align: start;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .report-table td + td,
  .report-table tr.report-totals td + td {
    border-top: 1px solid var(--ty-line-soft);
  }
  .report-table tr.report-totals td:first-child {
    border-top: 0;
  }
  .report-table tr.report-totals {
    border: 2px solid var(--ty-green);
  }
  .report-table tr > td:last-child {
    border-bottom: 0;
  }
  .report-table td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 40%;
    color: var(--ty-text-2);
    font-weight: 600;
  }
  .report-table td.is-blank {
    display: none;
  }
}
