/* محرك المشتريات — أجما جروب
   World: procurement ledger / technical dossier. Warm paper ground, fine ruled
   dividers, a numbered stage rail (the pipeline's sequence is real information).
   Gold #906833→#e9d074 is the ONLY accent, and it means one thing everywhere it
   appears: "this is proven" — a sourced price, a read robots.txt, a verified CR.
   Nothing else on the page borrows it. */

/* self-hosted fonts — Arabic subset only, the weights actually used on this page */
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/tajawal-400.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/tajawal-500.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/tajawal-700.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("fonts/tajawal-900.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Noto Kufi Arabic";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/noto-kufi-arabic-500.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Noto Kufi Arabic";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/noto-kufi-arabic-700.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Noto Kufi Arabic";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/noto-kufi-arabic-800.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

:root {
  --paper: #faf5ea;
  --paper-2: #f2ead9;
  --ink: #241c12;
  --ink-soft: #5c5140;
  --ink-faint: #8c8069;
  --line: #ded0ac;
  --line-soft: #e8ddc2;

  --gold-1: #906833;
  --gold-2: #e9d074;
  --gold-ink: #7a5820;

  --allow: #3c6b46;
  --allow-bg: #e6efe1;
  --deny: #8f3627;
  --deny-bg: #f5e4dc;

  --shadow: 0 1px 2px rgba(36, 28, 18, 0.06), 0 6px 20px -8px rgba(36, 28, 18, 0.18);

  --rail-w: 3.25rem;
  --measure: 68ch;
  --radius: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c170f;
    --paper-2: #241d13;
    --ink: #f1e9d8;
    --ink-soft: #cabfa5;
    --ink-faint: #8f8367;
    --line: #3a3121;
    --line-soft: #2c2518;
    --gold-1: #d9a94a;
    --gold-2: #f2dd8f;
    --gold-ink: #e9d074;
    --allow: #8fc79c;
    --allow-bg: #223326;
    --deny: #e2988a;
    --deny-bg: #3a241f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 24px -8px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --paper: #1c170f; --paper-2: #241d13; --ink: #f1e9d8; --ink-soft: #cabfa5;
  --ink-faint: #8f8367; --line: #3a3121; --line-soft: #2c2518;
  --gold-1: #d9a94a; --gold-2: #f2dd8f; --gold-ink: #e9d074;
  --allow: #8fc79c; --allow-bg: #223326; --deny: #e2988a; --deny-bg: #3a241f;
}
:root[data-theme="light"] {
  --paper: #faf5ea; --paper-2: #f2ead9; --ink: #241c12; --ink-soft: #5c5140;
  --ink-faint: #8c8069; --line: #ded0ac; --line-soft: #e8ddc2;
  --gold-1: #906833; --gold-2: #e9d074; --gold-ink: #7a5820;
  --allow: #3c6b46; --allow-bg: #e6efe1; --deny: #8f3627; --deny-bg: #f5e4dc;
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom, transparent 0 2.4em, var(--line-soft) 2.4em calc(2.4em + 1px)
  );
  color: var(--ink);
  font-family: "Tajawal", "Noto Sans Arabic", sans-serif;
  font-size: 16px;
  line-height: 1.8;
  overflow-x: hidden;
}

:lang(ar), :lang(ar) * { letter-spacing: normal; }

h1, h2, h3 { font-family: "Noto Kufi Arabic", "Tajawal", sans-serif; line-height: 1.45; }

.sr-only {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* fixed hairline down the stage-number gutter */
.rail {
  position: fixed;
  inset-block: 0;
  inset-inline-start: calc(var(--rail-w) / 2);
  inline-size: 1px;
  background: linear-gradient(to bottom, transparent, var(--line) 4%, var(--line) 96%, transparent);
  z-index: 0;
}
@media (max-width: 640px) { .rail { display: none; } }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-block-end: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand .mark {
  inline-size: 1.6rem; block-size: 1.6rem; border-radius: 50%;
  background: conic-gradient(from 220deg, var(--gold-1), var(--gold-2), var(--gold-1));
  box-shadow: inset 0 0 0 2px var(--paper), 0 0 0 1px var(--line);
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-family: "Noto Kufi Arabic", sans-serif; font-size: 1.02rem; }
.brand-text span { font-size: 0.8rem; color: var(--ink-soft); }

.run-meta { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.run-status {
  padding: 0.2rem 0.65rem; border-radius: 999px; font-weight: 700;
  background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-soft);
}
.run-status[data-state="running"] { color: var(--gold-ink); border-color: var(--gold-1); }
.run-status[data-state="reconnecting"] { color: var(--gold-ink); border-color: var(--gold-1); }
.run-status[data-state="done"] { color: var(--allow); border-color: var(--allow); }
.run-status[data-state="error"] { color: var(--deny); border-color: var(--deny); }
.run-id { color: var(--ink-faint); }

main {
  position: relative; z-index: 1;
  max-inline-size: 56rem;
  margin-inline: auto;
  padding: 1.5rem 1.25rem 4rem;
}

.stage {
  position: relative;
  padding-inline-start: calc(var(--rail-w) + 0.25rem);
  padding-block: 1.75rem;
  border-block-end: 1px solid var(--line);
  opacity: 0; transform: translateY(10px);
  animation: stage-in 0.5s cubic-bezier(0, 0.6, 0.2, 1) forwards;
}
.stage:last-of-type { border-block-end: none; }
@keyframes stage-in { to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .stage { animation: none; opacity: 1; transform: none; }
}

.stage::before {
  content: attr(data-stage);
  position: absolute;
  inset-inline-start: 0;
  top: 1.8rem;
  inline-size: var(--rail-w);
  text-align: center;
  font-family: "Noto Kufi Arabic", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-faint);
  background: var(--paper);
}
.stage.stage-active::before { color: var(--paper); background: linear-gradient(160deg, var(--gold-1), var(--gold-2)); border-radius: 50%; inline-size: 1.7rem; inset-inline-start: calc((var(--rail-w) - 1.7rem) / 2); block-size: 1.7rem; display: grid; place-items: center; }

.stage h2 {
  margin: 0 0 0.3rem;
  font-size: 1.15rem;
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
}
.stage-sub { font-family: "Tajawal", sans-serif; font-weight: 400; font-size: 0.82rem; color: var(--ink-faint); }
.stage-note { margin: 0 0 0.9rem; font-size: 0.88rem; color: var(--ink-soft); max-inline-size: var(--measure); }

.stage-body { margin-top: 0.9rem; }
.empty {
  color: var(--ink-faint);
  font-size: 0.92rem;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  max-inline-size: var(--measure);
}

/* ---- brief form ---- */
.brief-form textarea {
  inline-size: 100%;
  font: inherit; font-size: 0.98rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  resize: vertical;
  line-height: 1.8;
}
.brief-form textarea:focus-visible { outline: 2px solid var(--gold-1); outline-offset: 1px; }
.brief-actions { display: flex; gap: 0.6rem; margin-top: 0.75rem; flex-wrap: wrap; }

button {
  font: inherit; font-weight: 700; font-size: 0.92rem;
  padding: 0.65rem 1.3rem;
  border-radius: var(--radius);
  border: 1px solid var(--gold-1);
  background: linear-gradient(160deg, var(--gold-1), var(--gold-2));
  color: #211405;
  cursor: pointer;
}
button:hover { filter: brightness(1.04); }
button:focus-visible { outline: 2px solid var(--gold-1); outline-offset: 2px; }
button:disabled { opacity: 0.55; cursor: progress; filter: none; }
button.ghost {
  background: transparent; color: var(--ink); border-color: var(--line);
}
button.ghost:hover { border-color: var(--gold-1); color: var(--gold-ink); }
.run-error {
  margin-top: 0.6rem; font-size: 0.85rem; color: var(--deny);
}

/* ---- ledger rows (bom, offers, steps) ---- */
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 1rem;
  padding: 0.65rem 0;
  border-block-end: 1px solid var(--line-soft);
}
.ledger-row:last-child { border-block-end: none; }
.ledger-title { font-weight: 700; }
.ledger-meta { font-size: 0.82rem; color: var(--ink-faint); grid-column: 1 / -1; }
.ledger-qty { font-variant-numeric: tabular-nums; color: var(--ink-soft); white-space: nowrap; }
.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line);
}

/* ---- permission ledger ---- */
.perm-row {
  display: grid; gap: 0.35rem;
  padding: 0.85rem 0;
  border-block-end: 1px solid var(--line-soft);
}
.perm-row:last-child { border-block-end: none; }
.perm-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.perm-host { font-weight: 700; }
.perm-path { color: var(--ink-faint); font-size: 0.85rem; }
.badge {
  font-weight: 700; font-size: 0.76rem;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  border: 1px solid currentColor;
}
.badge.allow { color: var(--allow); background: var(--allow-bg); }
.badge.deny {
  color: var(--deny); background: var(--deny-bg);
  transform: rotate(-1.5deg);
  display: inline-block;
}
.perm-rule {
  display: block; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  direction: ltr; text-align: start; unicode-bidi: isolate;
  font-size: 0.78rem; color: var(--ink-soft);
  background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 0.5rem 0.65rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
.perm-source {
  font-size: 0.8rem; color: var(--ink-faint);
}
.perm-source a { color: var(--gold-ink); border-block-end: 1px solid var(--gold-1); text-decoration: none; }

/* a policy row is a rule WE chose, not one the site published — distinct from a
   robots.txt-sourced row (dashed inline-start bar instead of the plain divider,
   and the source line reads as a label, not a link, since there is nothing to link to) */
.perm-row-policy { border-inline-start: 2px dashed var(--ink-faint); padding-inline-start: 0.6rem; }
.perm-source-tag {
  display: inline-block; font-style: italic; color: var(--ink-soft);
  border-block-end: 1px dashed var(--ink-faint); padding-block-end: 1px;
}

/* ---- offers ---- */
.offer-group { margin-block-end: 1.1rem; }
.offer-group:last-child { margin-block-end: 0; }
.offer-group h3 { font-size: 0.95rem; margin: 0 0 0.4rem; }
.offer-line { color: var(--ink-faint); font-size: 0.8rem; margin: 0 0 0.5rem; }
.offer-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: 0.5rem 0; border-block-end: 1px solid var(--line-soft);
  font-size: 0.92rem;
}
.offer-row:last-child { border-block-end: none; }
.offer-unpriced {
  font-size: 0.85rem; color: var(--deny); padding: 0.5rem 0;
}

/* ---- money ---- */
.money { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; }
.money .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.money .prov { font-size: 0.74rem; }
.money.sourced .prov { color: var(--gold-ink); border-block-end: 1px dashed var(--gold-1); padding-block-end: 1px; }
.money.estimated .amt { color: var(--ink-soft); }
.money.estimated .prov {
  color: var(--ink-faint); border: 1px dashed var(--line); border-radius: 999px;
  padding: 0 0.5rem;
}
.money-missing { color: var(--ink-faint); }

/* ---- verification ---- */
.verify { font-size: 0.78rem; font-weight: 700; padding: 0.1rem 0.55rem; border-radius: 999px; }
.verify.ok { color: var(--allow); background: var(--allow-bg); }
.verify.no { color: var(--ink-faint); background: var(--paper-2); border: 1px solid var(--line); font-weight: 500; }

/* ---- quote comparison ---- */
.quote-table-wrap { overflow-x: auto; }
table.quotes {
  inline-size: 100%; border-collapse: collapse; font-size: 0.88rem;
  min-inline-size: 640px;
}
table.quotes th, table.quotes td {
  text-align: start; vertical-align: top;
  padding: 0.7rem 0.8rem;
  border-block-end: 1px solid var(--line-soft);
}
table.quotes thead th {
  font-family: "Noto Kufi Arabic", sans-serif; font-size: 0.8rem;
  color: var(--ink-soft); border-block-end: 1px solid var(--line);
  font-weight: 700;
}
table.quotes tbody tr:hover { background: var(--paper-2); }
table.quotes .supplier-cell { font-weight: 700; }
table.quotes .supplier-cr { display: block; font-size: 0.74rem; color: var(--ink-faint); font-weight: 400; margin-top: 0.15rem; }
.quote-quorum { font-size: 0.82rem; color: var(--ink-soft); margin: 0 0 0.7rem; }
.quote-quorum b { color: var(--gold-ink); }

@media (max-width: 640px) {
  .quote-table-wrap { display: none; }
  .quote-cards { display: grid; gap: 1rem; }
  .quote-card {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 0.9rem 1rem; background: var(--paper-2);
  }
  .quote-card h3 { margin: 0 0 0.5rem; font-size: 0.98rem; }
  .quote-card dl { margin: 0; display: grid; gap: 0.55rem; }
  .quote-card dt { font-size: 0.75rem; color: var(--ink-faint); font-weight: 700; }
  .quote-card dd { margin: 0.1rem 0 0; }
}
@media (min-width: 641px) { .quote-cards { display: none; } }

/* ---- adjustments / missing ---- */
.adj-group { margin-block-end: 1rem; }
.adj-group:last-child { margin-block-end: 0; }
.adj-group h3 { font-size: 0.92rem; margin: 0 0 0.4rem; }
.adj-list, .missing-list { list-style: none; margin: 0; padding: 0; font-size: 0.86rem; }
.adj-item { padding: 0.4rem 0; border-block-end: 1px solid var(--line-soft); }
.adj-item:last-child { border-block-end: none; }
.adj-field { font-weight: 700; }
.adj-arrow { color: var(--ink-faint); margin-inline: 0.3rem; }
.adj-reason { display: block; color: var(--ink-soft); font-size: 0.82rem; margin-top: 0.15rem; }
.missing-item { color: var(--deny); padding: 0.25rem 0; }

/* ---- PO draft ---- */
.po-form { display: grid; gap: 0.7rem; max-inline-size: var(--measure); }
.po-form label { display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-soft); font-weight: 700; }
.po-form select, .po-form input[type="text"] {
  font: inherit; padding: 0.55rem 0.7rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper-2); color: var(--ink);
}
.po-result { margin-top: 1rem; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; background: var(--paper-2); }
.po-result pre { white-space: pre-wrap; overflow-wrap: anywhere; direction: ltr; text-align: start; font-size: 0.78rem; }

/* ---- steps ---- */
.step-row { display: flex; gap: 0.75rem; padding: 0.5rem 0; border-block-end: 1px solid var(--line-soft); font-size: 0.86rem; }
.step-row:last-child { border-block-end: none; }
.step-tool { flex: none; font-weight: 700; color: var(--gold-ink); min-inline-size: 4.5rem; }
.step-summary { flex: 1; }
.step-time { flex: none; color: var(--ink-faint); font-size: 0.78rem; white-space: nowrap; }

footer {
  max-inline-size: 56rem; margin-inline: auto; padding: 1.5rem 1.25rem 3rem;
  color: var(--ink-faint); font-size: 0.82rem; border-block-start: 1px solid var(--line);
}

/* ltr runs embedded in rtl copy: hosts, ids, urls */
bdi { unicode-bidi: isolate; }

@media (max-width: 480px) {
  :root { --rail-w: 2.4rem; }
  main { padding-inline: 0.9rem; }
  .topbar { padding-inline: 0.9rem; }
}
