/* قوائم الحسابات والمشاريع والإجراءات تستخدم مساحة المحتوى الفعلية، بما فيها وضع الشريط الجانبي. */
.records-page {
  container-type: inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--admin-section-gap);
  font-size: var(--admin-ui-text);
}
.records-page .page-head { margin: 0; }
.rd-panel {
  min-width: 0;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--admin-panel-radius);
  box-shadow: var(--admin-panel-shadow);
  padding: 0 var(--admin-inset);
}
/* مرشحات بنمط شريط المشاريع في أفلم، والعدد تابع لاسم المرشح. */
.rd-summary { grid-area: filters; min-width: 0; }
.rd-filter-select { display: none; }
.rd-filters {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  padding: 2px;
  max-width: 100%;
}
.rd-filters button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-1);
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  padding: 0 var(--space-3);
  font-size: var(--admin-ui-text);
  font-weight: var(--weight-medium);
  min-height: var(--admin-control);
}
.rd-filters strong {
  font-size: var(--admin-caption);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}
.rd-filters button:hover { background: var(--surface-3); }
.rd-filters button[aria-pressed="true"] {
  background: var(--action-bg);
  color: var(--action-fg);
}
.rd-filters button:focus-visible, .rd-record:focus-visible, .rd-owner-link:focus-visible, .rd-id summary:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}
.rd-panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'heading heading' 'filters search';
  align-items: center;
  gap: var(--space-2) var(--admin-gap);
  padding-block: var(--admin-gap);
}
.rd-heading { grid-area: heading; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-2); }
.rd-heading small { color: var(--text-secondary); font-size: var(--admin-caption); }
.rd-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-3);
}
.rd-panel-head h2 { margin: 0; font-size: var(--admin-section-title); line-height: var(--leading-tight); }
.rd-search { grid-area: search; display: flex; align-items: stretch; gap: var(--space-1); max-width: 100%; }
.rd-search label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-inline: var(--space-3);
  min-width: 0;
  width: clamp(225px, 28cqi, 260px);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-secondary);
}
.rd-search label:focus-within { border-color: var(--text-primary); }
.rd-search svg { flex: 0 0 var(--admin-icon-small); width: var(--admin-icon-small); height: var(--admin-icon-small); }
.rd-search input { width: 100%; min-width: 0; min-height: calc(var(--admin-control) - 2px); color: var(--text-primary); border: 0; padding: 0; background: none; outline: none; font-size: var(--admin-ui-text); }
.rd-search .button, .rd-export, .rd-pager .button:not(.quiet) { background: var(--surface-2); box-shadow: none; border-radius: var(--radius-full); }
.rd-search .button:hover, .rd-export:hover, .rd-pager .button:not(.quiet):hover { background: var(--surface-3); }
.rd-scope { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); padding-block-end: var(--space-3); font-size: var(--text-sm); overflow-wrap: anywhere; }
.rd-scope > span { border-inline-start: 2px solid var(--border-strong); padding-inline-start: var(--space-2); }
.rd-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: separate; border-spacing: 0; text-align: start; white-space: normal; }
.rd-table th, .rd-table td { padding: var(--space-2); text-align: start; overflow-wrap: anywhere; }
.rd-table th { padding-block: 6px; font-size: var(--admin-caption); background: var(--surface-2); font-weight: var(--weight-medium); color: var(--text-secondary); }
.rd-table th:first-child { border-start-start-radius: var(--radius-md); border-end-start-radius: var(--radius-md); }
.rd-table th:last-child { border-start-end-radius: var(--radius-md); border-end-end-radius: var(--radius-md); }
.rd-table td { padding-block: var(--space-1); border: 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--admin-ui-text); }
.rd-table time { display: inline-block; font-variant-numeric: tabular-nums; }
.rd-table time small { display: block; color: var(--text-secondary); }
.rd-table .pill { padding: 1px var(--space-2); white-space: normal; }
.rd-users th:first-child { width: 36%; }
.rd-projects th:first-child { width: 28%; }
.rd-projects th:nth-child(2) { width: 19%; }
.rd-projects th:nth-child(3), .rd-projects th:nth-child(4) { width: 11%; }
.rd-audit th:first-child { width: 28%; }
.rd-record, .rd-audit-action, .rd-owner-link {
  display: flex;
  align-items: center;
  text-align: start;
  gap: var(--space-2);
  min-width: 0;
  max-width: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
}
.rd-record { width: 100%; }
.rd-record-text { display: grid; min-width: 0; gap: 2px; }
.rd-record-text > *, .rd-owner-link bdi { text-align: start; overflow-wrap: anywhere; }
.rd-record-text strong, .rd-audit-action strong { font-weight: var(--weight-medium); line-height: var(--leading-tight); }
.rd-record-text small { color: var(--text-secondary); font-size: var(--text-xs); }
.rd-record > svg { flex: 0 0 var(--admin-icon-tiny); margin-inline-start: auto; width: var(--admin-icon-tiny); height: var(--admin-icon-tiny); color: var(--text-secondary); }
button.rd-record:hover strong, .rd-owner-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.rd-initial, .rd-project-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  color: var(--text-secondary);
}
.rd-initial { border: 1px solid var(--border-subtle); border-radius: var(--radius-full); font-weight: var(--weight-bold); }
.rd-project-icon { border-radius: var(--radius-md); }
.rd-project-icon svg, .rd-audit-action svg { width: var(--admin-icon-small); height: var(--admin-icon-small); flex: none; }
.rd-audit-action svg { color: var(--text-secondary); }
.rd-owner-link, .rd-id { font-size: var(--text-sm); }
.rd-id { max-width: 100%; }
.rd-id summary { cursor: pointer; }
.rd-id[open] > bdi { display: block; margin-top: var(--space-1); color: var(--text-secondary); overflow-wrap: anywhere; }
.rd-pager { font-size: var(--text-sm); color: var(--text-secondary); }
.rd-pager p { margin: 0; }
.rd-pager small { display: block; margin-top: var(--space-1); }
.rd-pager bdi { color: var(--text-primary); font-weight: var(--weight-bold); }
.rd-permission { display: flex; align-items: flex-start; gap: var(--space-2); color: var(--text-secondary); font-size: var(--text-sm); margin: 0; }
.rd-permission svg { width: var(--admin-icon-small); height: var(--admin-icon-small); margin-top: var(--space-1); flex: none; }

/* بطاقة التفاصيل تحمل المعرّف الكامل وتجمع أوامر الحساب خارج صفوف القائمة. */
.rd-profile { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); }
.rd-profile > div { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.rd-profile h2 { font-size: var(--admin-section-title); margin: 0; }
.rd-profile small { color: var(--text-secondary); }
.rd-profile .rd-initial, .rd-profile .rd-project-icon { width: var(--space-10); height: var(--space-10); }
.rd-details .detail-grid { gap: var(--admin-gap); margin-block: var(--admin-inset); }
.rd-details .detail-grid dd { overflow-wrap: anywhere; font-size: var(--admin-ui-text); }
.rd-detail-actions, .rd-name-form { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-top: var(--space-3); }
.rd-name-form { border-top: 1px solid var(--border-subtle); padding-top: var(--space-3); align-items: flex-end; }
.rd-name-form .field { flex: 1 1 180px; min-width: 0; margin: 0; }
.rd-project-stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); margin: var(--admin-inset) 0; padding: var(--space-2) var(--space-1); background: var(--surface-2); border-radius: var(--radius-lg); }
.rd-project-stats div { text-align: center; }
.rd-project-stats div + div { border-inline-start: 1px solid var(--border-strong); }
.rd-project-stats dt { color: var(--text-secondary); font-size: var(--text-xs); }
.rd-project-stats dd { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-bold); overflow-wrap: anywhere; }

/* يتغير توزيع الخلايا مع بقاء العناوين وعلاقات الجدول متاحة لقارئ الشاشة. */
@container (max-width: 660px) {
  .rd-panel-head { grid-template-areas: 'heading filters'; padding-block: var(--space-2); }
  .rd-panel-head:has(.rd-search) { grid-template-areas: 'heading filters' 'search search'; }
  .rd-filters { display: none; }
  .rd-filter-select {
    display: block; min-height: var(--admin-control); max-width: 100%;
    padding-inline: var(--space-3); color: var(--text-primary); background: var(--surface-2);
    border: var(--border-width) solid var(--border-subtle); border-radius: var(--radius-md);
  }
  .rd-search { width: 100%; }
  .rd-search label { flex: 1; width: auto; }
  .rd-table { display: block; }
  .rd-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .rd-table tbody { display: grid; }
  .rd-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: var(--space-1) var(--space-3);
    padding-block: var(--space-2);
    border-top: 1px solid var(--border-subtle);
  }
  .rd-table tbody tr:last-child { border-bottom: 1px solid var(--border-subtle); }
  .rd-table td { display: flex; flex-wrap: wrap; align-content: center; align-items: center; gap: 0 var(--space-1); padding: 0; border: 0; min-width: 0; }
  .rd-table td:first-child { grid-column: 1 / -1; margin-bottom: var(--space-1); }
  .rd-table td:not(:first-child)::before { content: attr(data-label); color: var(--text-secondary); font-size: var(--text-xs); }
  .rd-table time small { display: inline; margin-inline-start: var(--space-1); }
  button.rd-record, .rd-owner-link { min-height: var(--admin-control); }
  /* تتقابل هوية السجل وحالته وتبقى البيانات القصيرة على السطر نفسه مع تسميتها. */
  .rd-users td:first-child, .rd-projects td:first-child { grid-column: auto; margin-bottom: 0; }
  .rd-users td:nth-child(2), .rd-projects td:last-child { grid-row: 1; grid-column: 2; justify-content: flex-end; }
  .rd-users td:nth-child(2)::before, .rd-projects td:last-child::before { content: none; }
  .rd-projects td:nth-child(5) { grid-row: 2; grid-column: 2; }
}
@container (max-width: 460px) {
  .rd-heading { display: grid; }
  .rd-panel-head { gap: var(--space-2); }
}
