:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #eef3f4;
  --ink: #18211f;
  --muted: #66736f;
  --line: #dfe6e8;
  --green: #236f59;
  --green-2: #e1f0eb;
  --teal: #1b7789;
  --amber: #b56b2c;
  --amber-2: #fff1df;
  --red: #b33b45;
  --red-2: #fde9eb;
  --blue: #2f67a8;
  --blue-2: #e5effa;
  --shadow: 0 1px 2px rgba(24, 33, 31, 0.04), 0 12px 32px -12px rgba(24, 33, 31, 0.14);
  --shadow-lift: 0 2px 4px rgba(24, 33, 31, 0.05), 0 22px 48px -18px rgba(24, 33, 31, 0.24);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --font: "IBM Plex Sans Arabic", "Noto Kufi Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(1100px 460px at 85% -140px, rgba(27, 119, 137, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(35, 111, 89, 0.09), rgba(246, 248, 251, 0) 380px),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.icon-sprite {
  display: none;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 2.8vw, 3rem);
  line-height: 1.15;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  position: relative;
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(24, 33, 31, 0.06);
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--green);
  color: var(--green);
  outline: none;
}

.icon-button.danger:hover,
.icon-button.danger:focus-visible {
  border-color: var(--red);
  color: var(--red);
}

.icon-button svg,
.searchbox svg,
.filter-title svg,
.legend-pill svg,
.status-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button::after {
  position: absolute;
  bottom: -36px;
  left: 50%;
  z-index: 5;
  width: max-content;
  max-width: 180px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #101716;
  color: #fff;
  content: attr(aria-label);
  font-size: 0.78rem;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-4px);
  transition: 0.18s ease;
}

.icon-button:hover::after,
.icon-button:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mode-tabs,
.program-tabs {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.mode-tabs {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.program-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-tab,
.program-tab {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 16px 18px;
  text-align: start;
  box-shadow: 0 10px 26px rgba(24, 33, 31, 0.05);
}

.mode-tab {
  min-height: 60px;
  justify-content: center;
}

.mode-tab svg,
.text-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-tab span {
  font-weight: 850;
}

.program-tab span {
  font-size: 1.08rem;
  font-weight: 850;
}

.program-tab strong {
  color: var(--muted);
  font-size: 0.92rem;
}

.mode-tab.is-active,
.program-tab.is-active {
  border-color: rgba(35, 111, 89, 0.4);
  background: linear-gradient(135deg, var(--green), #2a8068);
  color: #fff;
}

.program-tab.is-active strong {
  color: rgba(255, 255, 255, 0.84);
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.rail,
.stage {
  min-width: 0;
}

.rail {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
}

.searchbox {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 12px;
  min-height: 48px;
  color: var(--muted);
  box-shadow: 0 10px 24px rgba(24, 33, 31, 0.05);
}

.searchbox input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.filter-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.standard-list,
.criterion-list {
  display: grid;
  gap: 8px;
}

.standard-button,
.criterion-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  text-align: start;
}

.standard-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
}

.standard-button.is-active,
.criterion-button.is-active {
  border-color: rgba(35, 111, 89, 0.5);
  background: var(--green-2);
}

.standard-button span,
.criterion-button span {
  color: var(--muted);
  font-size: 0.82rem;
}

.criterion-list {
  max-height: calc(100vh - 410px);
  overflow: auto;
  padding-inline-end: 2px;
}

.criterion-button {
  display: grid;
  gap: 5px;
  min-height: 74px;
}

.criterion-button strong,
.standard-button strong {
  overflow-wrap: anywhere;
}

.criterion-button p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.loading {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.app-content {
  display: grid;
  gap: 16px;
}

.overview-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-tile,
.quality-signal,
.criterion-focus,
.impact-panel,
.criterion-tools {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-tile {
  min-height: 112px;
  padding: 16px;
}

.metric-tile span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.metric-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 1.7rem;
  line-height: 1.1;
}

.metric-tile small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.6;
}

.quality-signal {
  display: grid;
  grid-column: span 4;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
}

.quality-signal h2 {
  margin-bottom: 6px;
  font-size: 1.18rem;
}

.quality-signal p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.8;
}

.heat-strip {
  display: grid;
  width: min(360px, 32vw);
  min-width: 220px;
  grid-template-columns: repeat(var(--segments), 1fr);
  gap: 3px;
}

.heat-dot {
  height: 34px;
  border-radius: 5px;
  background: var(--green-2);
  border: 1px solid rgba(35, 111, 89, 0.12);
}

.heat-dot.warn {
  background: var(--amber-2);
  border-color: rgba(181, 107, 44, 0.22);
}

.heat-dot.risk {
  background: var(--red-2);
  border-color: rgba(179, 59, 69, 0.22);
}

.criterion-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 16px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.criterion-picker {
  position: relative;
  min-width: 0;
}

.criterion-trigger {
  display: flex;
  min-height: 46px;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  text-align: start;
}

.criterion-trigger::after {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-inline-end: 2px solid currentColor;
  border-block-end: 2px solid currentColor;
  content: "";
  opacity: 0.62;
  transform: rotate(45deg) translateY(-2px);
}

.criterion-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.criterion-trigger:hover,
.criterion-trigger:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 111, 89, 0.12);
}

.criterion-menu {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline: 0;
  z-index: 20;
  max-height: min(360px, calc(100vh - 260px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(24, 33, 31, 0.16);
  overflow: hidden;
}

.criterion-menu-list {
  display: grid;
  max-height: inherit;
  overflow: auto;
  padding: 6px;
}

.criterion-menu-option {
  display: grid;
  width: 100%;
  min-height: 50px;
  gap: 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 10px;
  text-align: start;
}

.criterion-menu-option:hover,
.criterion-menu-option:focus-visible,
.criterion-menu-option.is-active {
  background: var(--green-2);
  outline: none;
}

.criterion-menu-option strong {
  font-size: 0.88rem;
}

.criterion-menu-option span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.5;
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.legend-pill,
.tag,
.state-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.legend-pill.available,
.state-pill.good,
.state-pill.very-good,
.state-pill.excellent,
.tag.core {
  background: var(--green-2);
  color: var(--green);
}

.legend-pill.partial,
.state-pill.watch,
.tag.important {
  background: var(--amber-2);
  color: var(--amber);
}

.legend-pill.missing,
.state-pill.blocked,
.tag.governing {
  background: var(--red-2);
  color: var(--red);
}

.tag.support {
  background: var(--blue-2);
  color: var(--blue);
}

.criterion-focus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 20px;
  padding: 20px;
}

.criterion-focus h2 {
  margin-bottom: 10px;
  font-size: 1.42rem;
  line-height: 1.5;
}

.criterion-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.criterion-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 5px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.criterion-text {
  margin-bottom: 0;
  color: #33413d;
  font-size: 1rem;
  line-height: 1.9;
}

.progress-card {
  display: grid;
  place-items: center;
  gap: 10px;
  align-content: center;
}

.progress-ring {
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 58%, transparent 59%),
    conic-gradient(var(--ring-color) calc(var(--value) * 1%), #e7edf0 0);
}

.progress-ring strong {
  font-size: 1.9rem;
}

.progress-ring span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.evidence-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.evidence-list {
  display: grid;
  gap: 10px;
}

.evidence-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  box-shadow: 0 10px 26px rgba(24, 33, 31, 0.05);
}

.evidence-card.is-missing {
  border-color: rgba(179, 59, 69, 0.42);
  background: linear-gradient(90deg, rgba(253, 233, 235, 0.75), #fff 44%);
}

.evidence-card.is-partial {
  border-color: rgba(181, 107, 44, 0.4);
  background: linear-gradient(90deg, rgba(255, 241, 223, 0.8), #fff 44%);
}

.evidence-main {
  min-width: 0;
}

.evidence-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 9px;
}

.evidence-title strong {
  font-size: 0.95rem;
}

.evidence-card p {
  margin-bottom: 0;
  color: #33413d;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.evidence-note {
  display: inline-block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-actions {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  gap: 6px;
}

.status-action {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.status-action.is-active[data-status="available"] {
  border-color: var(--green);
  background: var(--green-2);
  color: var(--green);
}

.status-action.is-active[data-status="partial"] {
  border-color: var(--amber);
  background: var(--amber-2);
  color: var(--amber);
}

.status-action.is-active[data-status="missing"] {
  border-color: var(--red);
  background: var(--red-2);
  color: var(--red);
}

.impact-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.impact-panel h2 {
  margin-bottom: 2px;
  font-size: 1.08rem;
}

.impact-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.impact-number {
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.impact-number span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.impact-number strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}

.impact-list {
  display: grid;
  gap: 8px;
}

.impact-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.impact-item strong {
  display: block;
  margin-bottom: 5px;
  color: var(--red);
}

.impact-item p,
.impact-panel > p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

.library-view {
  display: grid;
  gap: 16px;
}

.library-controls,
.library-results {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.text-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 12px;
  font-weight: 850;
}

.text-button:hover,
.text-button:focus-visible {
  border-color: var(--green);
  color: var(--green);
  outline: none;
  box-shadow: 0 0 0 3px rgba(35, 111, 89, 0.12);
}

.library-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(3, minmax(180px, 0.8fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.library-searchbox {
  min-height: 50px;
}

.select-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.select-field select {
  min-height: 50px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.select-field select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 111, 89, 0.12);
}

.library-content {
  display: grid;
  gap: 16px;
}

.library-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.library-results {
  padding: 16px;
}

.library-table-wrap {
  max-height: 690px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.library-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

.library-table th,
.library-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: start;
  vertical-align: top;
}

.library-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: #33413d;
  font-size: 0.82rem;
  font-weight: 900;
}

.library-table tbody tr:hover {
  background: #fbfcfd;
}

.book-cell {
  min-width: 310px;
}

.book-cell strong,
.copy-cell strong,
.library-table td > strong {
  display: block;
  line-height: 1.65;
}

.book-cell small,
.copy-cell small,
.library-table td small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.6;
}

.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.mini-chip,
.relation-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 850;
  line-height: 1.4;
}

.mini-chip {
  background: var(--blue-2);
  color: var(--blue);
}

.relation-pill {
  margin: 0 0 6px 6px;
}

.relation-pill.core {
  background: var(--green-2);
  color: var(--green);
}

.relation-pill.supporting {
  background: var(--amber-2);
  color: var(--amber);
}

.relation-pill.muted {
  background: var(--surface-soft);
  color: var(--muted);
}

.mono-value {
  direction: ltr;
  display: inline-block;
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 4px 6px;
  color: #33413d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.record-details summary {
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 850;
}

.record-details dl {
  display: grid;
  grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
  gap: 5px 8px;
  margin: 10px 0 0;
  min-width: 260px;
}

.record-details dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.record-details dd {
  margin: 0;
  color: #33413d;
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.empty-cell {
  color: var(--muted);
  text-align: center !important;
}

.toast {
  position: fixed;
  right: 50%;
  bottom: 20px;
  z-index: 10;
  max-width: min(420px, calc(100% - 32px));
  border-radius: var(--radius);
  background: #101716;
  color: #fff;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 10px);
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(50%, 0);
}

@media (max-width: 1100px) {
  .workspace,
  .evidence-layout,
  .criterion-focus,
  .library-controls {
    grid-template-columns: 1fr;
  }

  .rail,
  .impact-panel {
    position: static;
  }

  .criterion-list {
    max-height: 300px;
  }

  .quality-signal {
    grid-template-columns: 1fr;
  }

  .heat-strip {
    width: 100%;
  }
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 16px;
  }

  .topbar,
  .program-tab,
  .section-heading {
    align-items: stretch;
  }

  .topbar,
  .section-heading {
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .mode-tabs,
  .program-tabs,
  .overview-band,
  .library-summary,
  .criterion-tools,
  .impact-summary {
    grid-template-columns: 1fr;
  }

  .quality-signal {
    grid-column: span 1;
  }

  .criterion-tools {
    align-items: stretch;
  }

  .status-legend {
    justify-content: flex-start;
  }

  .evidence-card {
    grid-template-columns: 1fr;
  }

  .status-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-action {
    width: 100%;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 12mm;
  }

  body {
    background: #fff;
  }

  .topbar-actions,
  .mode-tabs,
  .program-tabs,
  .page-hero-actions,
  .library-controls,
  .rail,
  .criterion-tools,
  .status-actions,
  .toast {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .workspace,
  .evidence-layout,
  .criterion-focus,
  .overview-band {
    display: block;
  }

  .library-table-wrap {
    max-height: none;
    overflow: visible;
  }

  .library-table {
    min-width: 0;
    font-size: 0.76rem;
  }

  .library-table th {
    position: static;
  }

  .record-details,
  .library-table th:nth-child(7),
  .library-table td:nth-child(7) {
    display: none;
  }

  .metric-tile,
  .criterion-focus,
  .impact-panel,
  .evidence-card,
  .quality-signal,
  .page-hero,
  .library-results {
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 10px;
  }
}

/* ═══════════════ التبويبات المرجعية: مسار العمل، الأدلة المؤسسية، دليل الكتابة ═══════════════ */

.doc-view {
  display: grid;
  gap: 18px;
}

.state-pill.ok {
  background: var(--green-2);
  color: var(--green);
}

.state-pill.warn {
  background: var(--amber-2);
  color: var(--amber);
}

.state-pill.risk {
  background: var(--red-2);
  color: var(--red);
}

.state-pill.info {
  background: var(--blue-2);
  color: var(--blue);
}

.state-pill.muted {
  background: var(--surface-soft);
  color: var(--muted);
}

.tag.soft {
  background: var(--surface-soft);
  color: var(--muted);
}

.warn-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: var(--amber-2);
  padding: 6px 12px;
  color: var(--amber);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.6;
}

.warn-chip svg,
.rule-banner svg,
.doc-version svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── مسار العمل ── */

.stage-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.stage-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  color: var(--ink);
  text-align: start;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stage-chip:hover {
  border-color: var(--green);
}

.stage-chip.is-active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
  background: var(--green-2);
}

.stage-num {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  font-weight: 900;
  font-size: 0.85rem;
}

.stage-chip.is-active .stage-num {
  background: var(--green);
  color: #fff;
}

.stage-name {
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.5;
}

.stage-detail {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.stage-head h3 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.stage-question {
  margin: 0;
  color: var(--teal);
  font-weight: 800;
}

.stage-purpose {
  margin: 0;
  color: var(--muted);
  line-height: 1.9;
}

.stage-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.stage-col {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px 16px;
}

.stage-col h4,
.callout h4,
.do-box h4,
.dont-box h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.stage-col ul,
.callout ul,
.callout ol,
.do-box ul,
.dont-box ul,
.check-items,
.checklist {
  margin: 0;
  padding-inline-start: 20px;
  line-height: 1.9;
}

.stage-gate {
  display: grid;
  gap: 6px;
  border-inline-start: 4px solid var(--green);
  border-radius: var(--radius);
  background: var(--green-2);
  padding: 14px 16px;
}

.stage-gate p {
  margin: 0;
  line-height: 1.9;
}

.gate-label {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
}

.stage-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.layers-block {
  display: grid;
  gap: 14px;
}

.decision-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.decision-banner h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.decision-banner p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
  max-width: 70ch;
}

.decision-banner.ok {
  border-color: var(--green);
  background: var(--green-2);
}

.decision-banner.warn {
  border-color: var(--amber);
  background: var(--amber-2);
}

.decision-banner.risk {
  border-color: var(--red);
  background: var(--red-2);
}

.decision-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.layer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.layer-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  text-align: start;
  color: var(--ink);
}

.layer-card:hover {
  border-color: var(--teal);
}

.layer-card.is-active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

.layer-card header,
.layer-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.layer-card h3 {
  margin: 0;
  font-size: 1rem;
}

.layer-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

.layer-card footer {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.layer-order {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.layer-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}

.layer-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--green);
}

.layer-detail {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--shadow);
}

.layer-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.layer-detail-head h3 {
  margin: 0 0 4px;
}

.layer-detail-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
  max-width: 80ch;
}

.layer-section h4 {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 0.95rem;
}

.layer-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 12px;
}

.layer-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.layer-item.is-available {
  border-color: var(--green);
  background: var(--green-2);
}

.layer-item.is-partial {
  border-color: var(--amber);
  background: var(--amber-2);
}

.layer-item.is-missing {
  border-color: var(--red);
  background: var(--red-2);
}

.layer-item header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.layer-item h5 {
  margin: 4px 0 0;
  font-size: 0.95rem;
}

.layer-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.7;
}

.check-items {
  margin: 0;
  color: var(--ink);
  font-size: 0.82rem;
}

/* ── سجل الأدلة المؤسسية ── */

.rule-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  background: var(--amber-2);
  padding: 14px 18px;
  color: var(--amber);
}

.rule-banner strong {
  display: block;
  margin-bottom: 4px;
}

.rule-banner p {
  margin: 0;
  color: var(--ink);
  line-height: 1.85;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

.doc-card {
  display: grid;
  gap: 10px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.doc-card.is-pending {
  border-inline-start: 4px solid var(--amber);
}

.doc-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.doc-card h3 {
  margin: 6px 0 2px;
  font-size: 1.02rem;
  line-height: 1.6;
}

.doc-issuer {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.doc-badges {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.doc-usage,
.doc-version,
.doc-note {
  margin: 0;
  line-height: 1.85;
  font-size: 0.87rem;
}

.doc-version {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px 12px;
  color: var(--muted);
}

.doc-version.is-warn {
  background: var(--amber-2);
  color: var(--amber);
}

.doc-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.doc-tags,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.doc-criteria {
  display: grid;
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.doc-criteria-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.criterion-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 4px 10px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
}

.criterion-chip:hover {
  border-color: var(--teal);
  background: var(--blue-2);
}

/* ── دليل الكتابة ── */

.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sub-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 8px 16px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.sub-tab.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.writing-body {
  display: grid;
  gap: 16px;
}

.doc-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
}

.doc-panel h3 {
  margin: 0;
  font-size: 1.15rem;
}

.panel-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.8;
}

.two-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.do-box,
.dont-box,
.callout {
  border-radius: var(--radius);
  padding: 14px 16px;
}

.do-box {
  background: var(--green-2);
  color: var(--green);
}

.dont-box {
  background: var(--red-2);
  color: var(--red);
}

.do-box li,
.dont-box li,
.callout li {
  color: var(--ink);
}

.callout {
  background: var(--surface-soft);
}

.callout-foot {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.8;
}

.do-box svg,
.dont-box svg,
.check-box svg,
.swap-bad svg,
.swap-good svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.adli-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.adli-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.adli-card h4 {
  margin: 0 0 6px;
  color: var(--green);
}

.adli-q {
  margin: 0 0 8px;
  font-size: 0.85rem;
  line-height: 1.7;
}

.sample {
  margin: 0;
  border-inline-start: 3px solid var(--teal);
  border-radius: var(--radius);
  background: var(--blue-2);
  padding: 10px 12px;
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.95;
}

.sample + .sample {
  margin-top: 8px;
}

.rule-list,
.finding-list,
.swap-list {
  display: grid;
  gap: 12px;
}

.rule-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.rule-item h4 {
  margin: 0 0 6px;
}

.rule-item p {
  margin: 0 0 8px;
  line-height: 1.85;
}

.phrase-group {
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}

.phrase-group h4 {
  margin: 0 0 10px;
  color: var(--teal);
}

.swap-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.swap-bad,
.swap-good,
.swap-why {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 6px;
  line-height: 1.8;
}

.swap-bad {
  color: var(--red);
  font-weight: 800;
}

.swap-good {
  margin-bottom: 0;
  color: var(--green);
  font-weight: 800;
}

.swap-why {
  color: var(--muted);
  font-size: 0.82rem;
}

.criterion-quote {
  margin: 0;
  border-inline-start: 4px solid var(--green);
  border-radius: var(--radius);
  background: var(--green-2);
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.95;
}

.model-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.model-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.model-head h4 {
  margin: 0;
  font-size: 0.98rem;
}

.model-text {
  margin: 0;
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px 16px;
  line-height: 2.15;
}

.checklist-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}

.checklist-progress .layer-bar {
  flex: 1;
}

.checklist-progress span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.checklist {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.check-row {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  color: var(--ink);
  text-align: start;
  line-height: 1.8;
}

.check-row.is-done {
  border-color: var(--green);
  background: var(--green-2);
}

.check-box {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: transparent;
}

.check-row.is-done .check-box {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.elements-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-inline-start: 20px;
}

.elements-list li {
  line-height: 1.85;
}

.elements-list strong {
  display: block;
  color: var(--green);
}

.elements-list span {
  color: var(--muted);
  font-size: 0.87rem;
}

.finding-item {
  display: flex;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.finding-num {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: var(--red-2);
  color: var(--red);
  font-weight: 900;
}

.finding-item h4 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.finding-item p {
  margin: 0 0 4px;
  line-height: 1.8;
  font-size: 0.87rem;
}

.finding-impact {
  color: var(--muted);
}

@media (max-width: 720px) {
  .stage-track {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .doc-grid,
  .layer-items {
    grid-template-columns: 1fr;
  }
}

@media print {
  .stage-track,
  .sub-tabs,
  .library-controls,
  .mode-tabs {
    display: none !important;
  }

  .doc-panel,
  .doc-card,
  .stage-detail,
  .layer-detail {
    break-inside: avoid;
    box-shadow: none;
  }
}

.criterion-institutional {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.ci-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.ci-head svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ci-head .text-button {
  margin-inline-start: auto;
}

/* ══════════════ ترويسة الصفحة الموحّدة ══════════════ */

.page-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(620px 220px at 100% 0, rgba(27, 119, 137, 0.1), transparent 70%),
    linear-gradient(135deg, rgba(35, 111, 89, 0.07), rgba(255, 255, 255, 0) 55%),
    var(--surface);
  padding: 26px 28px;
  box-shadow: var(--shadow);
}

.page-hero::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--green), var(--teal));
}

.page-hero-text {
  min-width: 0;
}

.page-hero h2 {
  margin-bottom: 10px;
  font-size: clamp(1.4rem, 2.2vw, 1.85rem);
  letter-spacing: -0.01em;
}

.page-hero-lead {
  max-width: 78ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.97rem;
  line-height: 1.9;
}

.page-hero-actions {
  display: flex;
  flex-wrap: wrap;
  flex: 0 0 auto;
  gap: 8px;
}

.page-hero-figure {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
}

.hero-dial {
  position: relative;
  display: grid;
  width: 88px;
  height: 88px;
  place-items: center;
  border-radius: 999px;
  background: conic-gradient(var(--green) var(--dial, 0%), var(--surface-soft) 0);
}

.hero-dial::after {
  content: "";
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: 999px;
  background: var(--surface);
}

.hero-dial-value {
  position: relative;
  z-index: 1;
  color: var(--green);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.hero-dial-value small {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.hero-dial-caption {
  display: grid;
  gap: 3px;
}

.hero-dial-caption strong {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.hero-dial-caption span {
  font-size: 0.98rem;
  font-weight: 700;
}

/* ══════════════ مسار العمل — شريط الرحلة ══════════════ */

.journey {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 20px 18px 16px;
  box-shadow: var(--shadow);
}

.journey-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.journey-track::before {
  content: "";
  position: absolute;
  inset-inline: 6%;
  top: 21px;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
}

.journey-node {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  padding: 0 6px 10px;
  color: var(--muted);
  text-align: center;
  transition: color 0.15s ease, transform 0.15s ease;
}

.journey-dot {
  position: relative;
  z-index: 1;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  transition: all 0.18s ease;
}

.journey-dot svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.journey-label {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.45;
}

.journey-skill {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.journey-node:hover {
  color: var(--ink);
}

.journey-node:hover .journey-dot {
  border-color: var(--green);
  color: var(--green);
}

.journey-node.is-past .journey-dot {
  border-color: var(--green);
  background: var(--green-2);
  color: var(--green);
}

.journey-node.is-past .journey-label {
  color: var(--ink);
}

.journey-node.is-active {
  color: var(--ink);
  transform: translateY(-2px);
}

.journey-node.is-active .journey-dot {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  box-shadow: 0 0 0 5px rgba(35, 111, 89, 0.14);
}

.journey-node.is-active .journey-label {
  color: var(--green);
}

.journey-node.is-active .journey-skill,
.journey-node:hover .journey-skill {
  opacity: 1;
}

.journey-node:focus-visible {
  outline: none;
}

.journey-node:focus-visible .journey-dot {
  box-shadow: 0 0 0 4px rgba(35, 111, 89, 0.25);
}

/* ══════════════ بطاقة المرحلة ══════════════ */

.stage-detail {
  border-radius: var(--radius-lg);
  padding: 26px;
}

.stage-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.stage-col.is-in {
  border-inline-start: 3px solid var(--blue);
}

.stage-col.is-out {
  border-inline-start: 3px solid var(--teal);
}

.stage-rule {
  display: grid;
  gap: 6px;
  border-inline-start: 4px solid var(--amber);
  border-radius: var(--radius);
  background: var(--amber-2);
  padding: 14px 16px;
}

.stage-rule p {
  margin: 0;
  line-height: 1.9;
}

.stage-rule .gate-label {
  color: var(--amber);
}

.gate-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.gate-label svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage-foot {
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.stage-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ghost-button {
  display: inline-flex;
  max-width: 260px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 8px 16px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.ghost-button svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ghost-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-button:not(:disabled):hover {
  border-color: var(--green);
  background: var(--green-2);
  color: var(--green);
}

.ghost-button:disabled {
  cursor: default;
  opacity: 0.45;
}

/* ══════════════ مبدّل الأقسام ══════════════ */

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px;
  box-shadow: var(--shadow);
}

.segment {
  display: inline-flex;
  flex: 1 1 220px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 11px 18px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.16s ease;
}

.segment svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.segment strong {
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 2px 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

.segment:hover {
  color: var(--ink);
}

.segment.is-active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(35, 111, 89, 0.6);
}

.segment.is-active strong {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* ══════════════ أزرار التنزيل ══════════════ */

.download-block {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.download-row-label {
  min-width: 92px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.download-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.download-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 7px 14px;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.download-chip svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.download-chip small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
}

.download-chip:hover,
.download-chip:focus-visible {
  outline: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.download-chip.is-docx:hover {
  border-color: var(--blue);
  background: var(--blue-2);
  color: var(--blue);
}

.download-chip.is-pdf:hover {
  border-color: var(--red);
  background: var(--red-2);
  color: var(--red);
}

.download-chip.is-docx:hover small,
.download-chip.is-pdf:hover small {
  color: inherit;
  opacity: 0.75;
}

/* ══════════════ بطاقات الوثائق ══════════════ */

.doc-card {
  border-radius: var(--radius-lg);
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.doc-card:hover {
  transform: translateY(-2px);
  border-color: rgba(35, 111, 89, 0.35);
  box-shadow: var(--shadow-lift);
}

.doc-card.is-template {
  background:
    linear-gradient(180deg, rgba(47, 103, 168, 0.05), rgba(255, 255, 255, 0) 120px),
    var(--surface);
}

.doc-card.is-template .mono-value {
  color: var(--blue);
}

/* ══════════════ لمسات عامة ══════════════ */

.mode-tabs,
.segmented,
.page-hero {
  position: relative;
}

.view-panel,
.doc-view,
.library-view {
  animation: rise 0.22s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .view-panel,
  .doc-view,
  .library-view {
    animation: none;
  }

  .doc-card:hover,
  .download-chip:hover,
  .journey-node.is-active {
    transform: none;
  }
}

@media (max-width: 1080px) {
  .journey-track {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }

  .journey-track::before {
    display: none;
  }
}

@media (max-width: 720px) {
  .page-hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
  }

  .journey-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .journey-skill {
    display: none;
  }

  .stage-detail {
    padding: 18px;
  }

  .stage-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .segment {
    flex: 1 1 100%;
  }
}

@media print {
  .journey,
  .segmented,
  .stage-nav,
  .download-block {
    display: none !important;
  }

  .doc-card:hover {
    transform: none;
    box-shadow: none;
  }
}

.library-pagination { display:flex; flex-wrap:wrap; align-items:center; gap:0.65rem; }
.library-pagination[hidden] { display:none; }
@media print { .library-pagination { display:none; } }
