/* Build 07 — the demo console. Calm government style: light cool background, one deep
   accent, OS Arabic fonts, 17px base, right sidebar, 1366×768 first. No web fonts,
   no images, no external resources (ADR-009 Decision 5). */
:root {
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --ink: #1B2430;
  --muted: #5B6670;
  --line: #D9DEE3;
  --accent: #0F5F5C;
  --accent-ink: #FFFFFF;
  --banner: #FFF4D6;
  --banner-ink: #5A3E00;
  --ws: #E9F0FA;
  --ws-ink: #1F3F7A;
  --focus: #0F5F5C;
  --state-PROVEN: #145A32; --tint-PROVEN: #DDF3E6;
  --state-VIOLATED: #8B1A12; --tint-VIOLATED: #FBE1DF;
  --state-SPLIT: #6B4A00; --tint-SPLIT: #FBEFD0;
  --state-ABSTAIN: #3C454D; --tint-ABSTAIN: #E6E9EC;
  --state-WARNING_ONLY: #7A5A00; --tint-WARNING_ONLY: #FFF6DD;
  --state-CHANNEL_SPECIFIC: #1F3F7A; --tint-CHANNEL_SPECIFIC: #DDE8FA;
  --state-CUSTOM_DISABLED_PENDING_RECONCILIATION: #4A3573; --tint-CUSTOM_DISABLED_PENDING_RECONCILIATION: #E8E1F5;
  --state-DEVIATING_PENDING_RECONCILIATION: #7A3A00; --tint-DEVIATING_PENDING_RECONCILIATION: #FDE5D0;
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "SF Arabic", "Geeza Pro", Arial, sans-serif; line-height: 1.6;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
code { font-family: Menlo, Consolas, "SF Mono", monospace; font-size: 0.88em; direction: ltr; unicode-bidi: isolate; }
code.small { font-size: 0.78em; }
.en { direction: ltr; text-align: left; unicode-bidi: isolate; display: inline-block; max-width: 100%; }
.num { direction: ltr; unicode-bidi: isolate; }
li.en, p.en { display: block; }
td.en { display: table-cell; }
.skip { position: absolute; top: -40px; inset-inline-start: 8px; background: var(--accent); color: var(--accent-ink); padding: 6px 12px; }
.skip:focus { top: 8px; }

/* top bar, banner, label */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand strong { font-size: 1.15rem; margin-inline-end: 14px; }
.brand span { color: var(--muted); }
.actor { display: flex; gap: 10px; align-items: center; }
.pill { display: inline-block; padding: 2px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font-size: 0.9rem; }
.pill.ws { background: var(--ws); color: var(--ws-ink); border-color: transparent; }
.banner { background: var(--banner); color: var(--banner-ink); font-weight: 700; text-align: center; padding: 8px 16px; border-bottom: 1px solid #E9D9A8; }
.ws-label { background: var(--ws); color: var(--ws-ink); font-weight: 700; text-align: center; padding: 6px 16px; }

/* shell */
.shell { display: flex; min-height: calc(100vh - 160px); }
.sidebar { width: 248px; flex: 0 0 248px; background: var(--surface); border-inline-start: 1px solid var(--line); padding: 20px 0; position: sticky; top: 0; align-self: flex-start; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { display: block; padding: 9px 24px; color: var(--ink); border-inline-end: 4px solid transparent; }
.sidebar li.active a { color: var(--accent); border-inline-end-color: var(--accent); font-weight: 700; background: #EEF4F3; }
.sidebar li a:hover { background: var(--bg); text-decoration: none; }
.side-status { margin: 24px 24px 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 0.92rem; display: grid; gap: 2px; }
.side-status .k { color: var(--muted); }
.side-status strong { margin-bottom: 10px; }
.content { flex: 1; min-width: 0; max-width: 1040px; padding: 22px 32px 48px; overflow-wrap: break-word; overflow-x: auto; }
.table { table-layout: auto; }
.table td { overflow-wrap: break-word; }
.table code { white-space: nowrap; }
.table code.wrap { white-space: normal; overflow-wrap: anywhere; }
.table td.en, .table th.en { direction: ltr; text-align: left; overflow-wrap: normal; }
.table td.section { min-width: 16rem; }
.table.fixed { table-layout: fixed; }
.table.fixed code { white-space: normal; overflow-wrap: anywhere; }
.table td.rule code { white-space: normal; overflow-wrap: anywhere; }
.table td.amounts { white-space: normal; }
.table .sub { display: block; font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

/* type */
h1 { font-size: 1.75rem; line-height: 1.3; margin: 0 0 10px; }
h2 { font-size: 1.3rem; margin: 30px 0 10px; }
h3 { font-size: 1.08rem; margin: 20px 0 6px; }
.lead { font-size: 1.05rem; color: var(--ink); max-width: 72ch; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.k { color: var(--muted); }
.crumbs { color: var(--muted); margin: 0 0 4px; }
.status-line { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 14px; }
.status-line .sep { width: 1px; height: 18px; background: var(--line); }
.quote { background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--accent); padding: 12px 16px; margin: 8px 0 12px; }
.letter { display: inline-block; min-width: 1.7em; padding: 0 6px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-align: center; }

/* badges */
.badge { display: inline-block; padding: 1px 10px; border-radius: 4px; font-size: 0.9rem; font-weight: 700; white-space: nowrap; background: var(--tint-ABSTAIN); color: var(--state-ABSTAIN); }
.badge-PROVEN { background: var(--tint-PROVEN); color: var(--state-PROVEN); }
.badge-VIOLATED { background: var(--tint-VIOLATED); color: var(--state-VIOLATED); }
.badge-SPLIT { background: var(--tint-SPLIT); color: var(--state-SPLIT); }
.badge-ABSTAIN { background: var(--tint-ABSTAIN); color: var(--state-ABSTAIN); }
.badge-WARNING_ONLY { background: var(--tint-WARNING_ONLY); color: var(--state-WARNING_ONLY); }
.badge-CHANNEL_SPECIFIC { background: var(--tint-CHANNEL_SPECIFIC); color: var(--state-CHANNEL_SPECIFIC); }
.badge-CUSTOM_DISABLED_PENDING_RECONCILIATION { background: var(--tint-CUSTOM_DISABLED_PENDING_RECONCILIATION); color: var(--state-CUSTOM_DISABLED_PENDING_RECONCILIATION); }
.badge-DEVIATING_PENDING_RECONCILIATION { background: var(--tint-DEVIATING_PENDING_RECONCILIATION); color: var(--state-DEVIATING_PENDING_RECONCILIATION); }
.badge-out-CONFORMS { background: var(--tint-PROVEN); color: var(--state-PROVEN); }
.badge-out-BREACH { background: var(--tint-VIOLATED); color: var(--state-VIOLATED); }
.badge-out-UNDECIDABLE { background: var(--tint-ABSTAIN); color: var(--state-ABSTAIN); }
.tag-modelled { display: inline-block; padding: 0 8px; border: 1px dashed var(--muted); border-radius: 4px; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
a.why { display: inline-block; padding: 0 10px; border: 1px solid var(--accent); border-radius: 999px; font-size: 0.88rem; white-space: nowrap; }
a.why:hover { background: var(--accent); color: var(--accent-ink); text-decoration: none; }

/* stats and cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); padding: 14px 16px; display: grid; gap: 4px; align-content: start; }
.stat .n { font-size: 2rem; line-height: 1.1; }
.stat .n small { font-size: 0.95rem; font-weight: 400; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 8px; }
.card { display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--state-ABSTAIN); padding: 12px 14px; color: var(--ink); }
.card:hover { text-decoration: none; border-color: var(--accent); }
.card.state-PROVEN { border-inline-start-color: var(--state-PROVEN); }
.card.state-VIOLATED { border-inline-start-color: var(--state-VIOLATED); }
.card.state-SPLIT { border-inline-start-color: var(--state-SPLIT); }
.card.state-ABSTAIN { border-inline-start-color: var(--state-ABSTAIN); }
.card.state-WARNING_ONLY { border-inline-start-color: var(--state-WARNING_ONLY); }
.card.state-CHANNEL_SPECIFIC { border-inline-start-color: var(--state-CHANNEL_SPECIFIC); }
.card.state-CUSTOM_DISABLED_PENDING_RECONCILIATION { border-inline-start-color: var(--state-CUSTOM_DISABLED_PENDING_RECONCILIATION); }
.card.state-DEVIATING_PENDING_RECONCILIATION { border-inline-start-color: var(--state-DEVIATING_PENDING_RECONCILIATION); }
.card-letter { font-weight: 700; color: var(--accent); }
.card-title { font-weight: 700; line-height: 1.35; }
.card-id { font-size: 0.8rem; color: var(--muted); }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.9rem; }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); margin: 6px 0 10px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.table th { background: var(--bg); font-weight: 700; }
.table.compact th, .table.compact td { padding: 6px 10px; font-size: 0.95rem; }
.table .num, .table td.num, .table th.num { direction: ltr; text-align: end; white-space: nowrap; }
.table tfoot th { background: var(--surface); }
.table tr.case-row:hover td { background: #FAFBFC; }
.kv { display: grid; grid-template-columns: minmax(12ch, 26%) minmax(0, 1fr); gap: 6px 18px; margin: 8px 0 12px; }
.kv dt { color: var(--muted); font-weight: 400; overflow-wrap: break-word; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: break-word; }
.reading { background: var(--surface); border: 1px solid var(--line); padding: 10px 16px; margin: 10px 0; }
.reading h3 { margin-top: 4px; }

/* forms, buttons */
.btn { display: inline-block; padding: 7px 16px; border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 3px 10px; font-size: 0.88rem; font-weight: 400; }
.btn.danger { border-color: var(--state-VIOLATED); color: var(--state-VIOLATED); }
.btn[disabled] { opacity: 0.6; cursor: wait; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; margin: 10px 0 14px; }
.filters label { display: grid; gap: 4px; color: var(--muted); font-size: 0.92rem; }
select, input, textarea { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); min-width: 160px; }
input.num, .num input { direction: ltr; text-align: left; }
.run-panel { background: var(--surface); border: 1px solid var(--line); padding: 14px 18px; margin: 14px 0; }
.run-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.run-status { color: var(--muted); }

/* the pipeline diagram — right to left, each stage links to its page */
.pipeline { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 6px; padding: 0; }
.pipeline li { display: flex; align-items: center; gap: 6px; }
.pipeline li + li::before { content: "←"; color: var(--muted); font-size: 1.2rem; }
.pipeline li a { display: inline-block; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-weight: 700; }
.pipeline li a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* the why chain */
.chain { list-style: none; margin: 10px 0; padding: 0; counter-reset: stage; }
.chain .stage { position: relative; background: var(--surface); border: 1px solid var(--line); padding: 10px 18px 6px; margin-bottom: 10px; border-inline-start: 5px solid var(--accent); }
.chain .stage h2 { margin: 2px 0 8px; font-size: 1.15rem; }
.chain .stage + .stage::before { content: "↑"; position: absolute; top: -18px; inset-inline-start: 18px; color: var(--muted); }
.chain .stage-case { border-inline-start-color: var(--muted); }

/* diff (Phase 2) */
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff .col { background: var(--surface); border: 1px solid var(--line); padding: 10px 14px; }
.diff .changed { background: var(--tint-SPLIT); }

/* footer legend */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 28px 20px; border-top: 1px solid var(--line); background: var(--surface); }
.legend-title { color: var(--muted); margin-inline-end: 6px; }
.foot-note { width: 100%; margin: 6px 0 0; color: var(--muted); font-size: 0.88rem; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Phase 2: forms, actions, diff */
.form label { display: grid; gap: 4px; margin: 10px 0; }
.form textarea, .form input:not([type=number]):not([type=date]) { width: 100%; max-width: 72ch; }
.form table textarea { width: 100%; min-width: 18rem; direction: ltr; text-align: left; font-family: Menlo, Consolas, monospace; font-size: 0.85rem; }
.inline { display: inline-flex; gap: 8px; align-items: center; margin-inline-end: 12px; }
.inline input { min-width: 14rem; }
.error { color: var(--state-VIOLATED); font-weight: 700; }
td.changed, .changed { background: var(--tint-SPLIT); }
.topbar .inline { margin: 0; }

/* Fix round D3: the parameter / text contradiction notice */
.notice { background: var(--surface); border: 1px solid var(--line); padding: 10px 16px; margin: 10px 0 14px; }
.notice.warn { background: var(--tint-SPLIT); border-color: #E6C77A; color: var(--state-SPLIT); }
.notice h2, .notice h3 { margin-top: 2px; }
.pill.warn { background: var(--tint-SPLIT); color: var(--state-SPLIT); border-color: transparent; }
label.inline { display: inline-flex; gap: 6px; align-items: center; margin-inline-end: 10px; font-weight: 400; }

/* Fix round C2/C3: the technical toggle, the subtitle under a plain title */
.btn.small.on { background: var(--accent); color: var(--accent-ink); }
.subtitle { margin: -6px 0 10px; font-size: 0.95rem; }
.card-sub { font-size: 0.85rem; line-height: 1.35; }
.en.small { font-size: 0.82rem; display: block; }

/* Fix round C1: the two layers per case */
.badge-layer-entity_data { background: var(--tint-CHANNEL_SPECIFIC); color: var(--state-CHANNEL_SPECIFIC); white-space: normal; }
.badge-layer-out_of_scope { background: var(--tint-WARNING_ONLY); color: var(--state-WARNING_ONLY); white-space: normal; }
.badge-layer-missing_data { background: var(--tint-ABSTAIN); color: var(--state-ABSTAIN); white-space: normal; }
.layers dt { font-weight: 700; color: var(--ink); }
.stat.groups { gap: 6px; }
.stat .group { font-size: 0.9rem; line-height: 1.45; }
.stats { grid-template-columns: 1fr 1.6fr 1.2fr 0.8fr; }

/* Fix round C4: the other facts of the case, folded */
details#facts-other { margin: 6px 0 12px; }
details#facts-other summary { cursor: pointer; color: var(--accent); font-weight: 700; }

/* Fix round C5: the sentence under the primary badge */
.interim { margin: -4px 0 12px; color: var(--muted); }

/* Fix round P2: the home «لماذا؟» link is a grid item — inline width like every other one */
.stat a.why { justify-self: start; }

/* an Arabic phrase with a number inside a left-to-right cell: isolated, right-to-left */
.phrase { direction: rtl; unicode-bidi: isolate; display: inline-block; white-space: nowrap; }

/* the deviation dashboard (/dashboard) */
.lede { font-size: 1.05rem; color: var(--muted); margin-top: -6px; }
.block { display: block; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; margin: 18px 0; }
.panel h2 { margin-top: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi-k { color: var(--muted); font-size: 0.92rem; }
.kpi-n { font-size: 2rem; line-height: 1.2; }
.kpi-n { white-space: nowrap; }
.kpi-n small { font-size: 0.9rem; color: var(--muted); }
.kpi-sub { color: var(--muted); font-size: 0.85rem; }
.kpi-deviation { border-top-color: var(--state-VIOLATED); }
.kpi-deviation .kpi-n { color: var(--state-VIOLATED); }
.kpi-config { border-top-color: var(--state-SPLIT); }
.kpi-config .kpi-n { color: var(--state-SPLIT); }
.kpi-insufficient { border-top-color: var(--state-ABSTAIN); }

/* class colours: deviation / partial / config / insufficient / conforms */
.cls-deviation { background: var(--state-VIOLATED); color: #fff; }
.cls-partial { background: var(--state-WARNING_ONLY); color: #fff; }
.cls-config { background: var(--state-SPLIT); color: #fff; }
.cls-insufficient { background: #8A939B; color: #fff; }
.cls-conforms { background: var(--state-PROVEN); color: #fff; }
.stackbar { display: flex; height: 34px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.stackbar .seg { display: flex; align-items: center; justify-content: center; font-weight: 700; min-width: 28px; }
.legend-inline { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.legend-inline li { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cls-tag { display: block; width: fit-content; margin-top: 4px; padding: 0 8px; border-radius: 999px; font-size: 0.78rem; }

/* evidence groups */
.g-defect { --g: var(--state-VIOLATED); --gt: var(--tint-VIOLATED); }
.g-config { --g: var(--state-SPLIT); --gt: var(--tint-SPLIT); }
.g-unseen { --g: #3F5A7A; --gt: #E3EAF3; }
.g-applied { --g: var(--state-PROVEN); --gt: var(--tint-PROVEN); }
.g-context { --g: #1F3F7A; --gt: #E6ECF7; }
.g-other { --g: #5B6670; --gt: #ECEFF2; }
.dot.g-defect, .dot.g-config, .dot.g-unseen, .dot.g-context, .dot.g-applied, .dot.g-other { background: var(--g); }
.chip { display: inline-block; margin: 2px; padding: 0 8px; border-radius: 999px; font-size: 0.8rem; background: var(--gt); color: var(--g); border: 1px solid var(--g); white-space: nowrap; }
.ev-kind { display: inline-block; padding: 0 8px; border-radius: 6px; font-size: 0.8rem; font-weight: 700; background: var(--gt); color: var(--g); margin-inline-end: 4px; }

/* the matrix */
.matrix { width: 100%; table-layout: fixed; }
.matrix col.w-rule { width: 20%; } .matrix col.w-text { width: 27%; } .matrix col.w-verdict { width: 15%; }
.matrix col.w-where { width: 28%; } .matrix col.w-cases { width: 10%; }
.matrix td { vertical-align: top; overflow-wrap: anywhere; }
.matrix .c-text, .matrix .c-where { font-size: 0.9rem; line-height: 1.55; }
.chips-row { display: block; margin-top: 6px; }
.row-links { display: block; margin-top: 4px; }
.row-links a { margin-inline-end: 8px; }
.matrix tr.row-deviation td:first-child { border-inline-start: 5px solid var(--state-VIOLATED); }
.matrix tr.row-config td:first-child { border-inline-start: 5px solid var(--state-SPLIT); }
.matrix tr.row-insufficient td:first-child { border-inline-start: 5px solid #8A939B; }
.matrix tr.row-partial td:first-child { border-inline-start: 5px solid var(--state-WARNING_ONLY); }
.matrix tr.row-conforms td:first-child { border-inline-start: 5px solid var(--state-PROVEN); }
.rule-link { font-weight: 700; }
.letter-chip { display: inline-block; min-width: 22px; text-align: center; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: 0.82rem; font-weight: 700; padding: 0 4px; }
.minibar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; min-width: 90px; text-decoration: none !important; }
.mseg { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 0.78rem; font-weight: 700; min-width: 18px; }
.out-CONFORMS { background: var(--state-PROVEN); }
.out-BREACH { background: var(--state-VIOLATED); }
.out-UNDECIDABLE { background: #8A939B; }
.dot.out-CONFORMS, .dot.out-BREACH, .dot.out-UNDECIDABLE { color: transparent; }
.more { color: var(--state-VIOLATED); font-weight: 700; }
.less { color: var(--state-CHANNEL_SPECIFIC); font-weight: 700; }

/* two columns: top defects and impact bars */
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.two-col .panel { margin: 0; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
.toplist { margin: 0; padding-inline-start: 22px; }
.toplist li { margin: 0 0 10px; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; margin: 0 0 14px; }
.bars li .bar-label { grid-column: 1 / -1; font-weight: 700; }
.bars li .block { grid-column: 1 / -1; }
.bar-track { background: var(--bg); border-radius: 6px; height: 14px; overflow: hidden; }
.bar { display: block; height: 100%; border-radius: 6px; }
.bar.more { background: var(--state-VIOLATED); }
.bar.less { background: var(--state-CHANNEL_SPECIFIC); }

/* evidence blocks */
.evblock { border: 1px solid var(--line); border-inline-start: 5px solid #8A939B; border-radius: 8px; padding: 8px 14px; margin: 10px 0; background: var(--surface); }
.evblock.row-deviation { border-inline-start-color: var(--state-VIOLATED); }
.evblock.row-config { border-inline-start-color: var(--state-SPLIT); }
.evblock.row-conforms { border-inline-start-color: var(--state-PROVEN); }
.evblock summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 4px 0; }
.ev-head { margin: 12px 0 4px; color: var(--g); }
.evlist { margin: 0; padding-inline-start: 0; list-style: none; }
.evlist li { padding: 6px 10px; margin: 4px 0; border-inline-start: 3px solid var(--g, var(--line)); background: var(--bg); border-radius: 4px; }
.evlist.plain li { border-inline-start-color: var(--line); }
.ev-links { margin: 10px 0 2px; }
.matrix .badge, .evblock summary .badge { white-space: normal; display: inline-block; max-width: 100%; line-height: 1.4; }
.matrix .c-verdict .cls-tag { white-space: normal; }

/* -- سير قرار الانتداب ------------------------------------------------------ */
.flow { list-style: none; margin: 20px 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 34px; }
@media (max-width: 1100px) { .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.flow-step { position: relative; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.flow-step:not(:nth-child(4n)):not(:last-child)::after { content: "◀"; position: absolute; inset-inline-end: -26px; top: 22px; color: var(--accent); font-size: 1.1rem; }
.flow-step.flow-gap { border-top-color: var(--muted); background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 10px, var(--bg) 10px, var(--bg) 20px); }
.flow-head { display: flex; gap: 10px; align-items: flex-start; }
.flow-n { flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.flow-gap .flow-n { background: var(--muted); }
.flow-title { margin: 0; font-size: 1.05rem; }
.flow-actor { margin: 2px 0 0; color: var(--muted); font-size: 0.88rem; }
.flow-rules { display: grid; gap: 4px; margin-top: 10px; }
.flow-rule { display: grid; gap: 2px; justify-items: start; font-size: 0.88rem; color: var(--ink); padding: 4px 0; border-bottom: 1px dashed var(--line); min-width: 0; }
.flow-rule span { overflow-wrap: anywhere; }
.flow-rule:hover { text-decoration: none; background: var(--bg); }
.flow-checks { margin-top: 10px; font-size: 0.92rem; }
.flow-checks summary { cursor: pointer; color: var(--accent); font-weight: 700; }
.flow-checks ul { margin: 8px 0 0; padding-inline-start: 18px; display: grid; gap: 4px; }
.flow-check.kind-REQUEST::marker { color: #145A32; }
.flow-check.kind-DATA::marker, .flow-check.kind-CONFIG::marker { color: #6B4A00; }
.flow-note { margin: 10px 0 0; padding: 8px 10px; background: var(--banner); color: var(--banner-ink); border-radius: 6px; font-size: 0.88rem; }

/* -- اسأل وكيل الدعم --------------------------------------------------------- */
.chat { max-width: 920px; }
.chat-log { display: grid; gap: 12px; margin: 16px 0 20px; }
.bubble { max-width: 78%; padding: 12px 16px; border-radius: 14px; line-height: 1.7; }
.bubble.agent { background: var(--surface); border: 1px solid var(--line); justify-self: start; border-start-start-radius: 4px; }
.bubble.user { background: var(--ws); color: var(--ws-ink); justify-self: end; border-start-end-radius: 4px; }
.bubble .quote { margin: 6px 0 0; font-style: italic; }
.answer { border-inline-start: 5px solid var(--accent); }
.answer.status-CONFIRMED { border-inline-start-color: #145A32; }
.answer.status-EXPLAINED_FROM_TEXT { border-inline-start-color: var(--accent); }
.answer.status-NOT_REPRODUCED, .answer.status-CANNOT_EVALUATE { border-inline-start-color: #7A3A00; }
.answer-status { margin: 0 0 6px; font-weight: 700; }
.chat-form { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 10px; }
.chat-form .row { display: flex; gap: 12px; }
.chat-form .row.wrap { flex-wrap: wrap; }
.chat-form label { display: grid; gap: 4px; font-size: 0.88rem; color: var(--muted); }
.chat-form label.grow { flex: 1; }
.chat-form label.block textarea { width: 100%; }
.chat-form input, .chat-form select, .chat-form textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.chat-form input { width: 140px; }
.examples h2 { font-size: 1rem; margin: 22px 0 8px; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; padding: 6px 14px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); background: var(--surface); }
.chip:hover { background: #EEF4F3; text-decoration: none; }
.flow-rule .badge { white-space: normal; max-width: 100%; line-height: 1.5; }

/* The agent home (approved redesign 2026-10-20, boards 1–3) */
.ag-intro { display: flex; gap: 16px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.ag-intro h1 { margin: 0 0 6px; font-size: 1.35rem; }
.ag-avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 1.3rem; }
.ag-links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 6px 0 0; }
.ag-options { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; counter-reset: ag; }
.ag-options li { counter-increment: ag; }
.ag-options a { display: block; height: 100%; box-sizing: border-box; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; color: var(--ink); text-decoration: none; }
.ag-options a::before { content: counter(ag); display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ws); color: var(--ws-ink); font-weight: 700; margin-inline-end: 8px; }
.ag-options a:hover, .ag-options a:focus-visible { border-color: var(--accent); }
.ag-options span { display: block; color: var(--muted); margin-top: 6px; font-size: .92rem; }
.ag-choices, .ag-rule-choices { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.ag-rule-choices { flex-direction: column; }
.ag-rule-choices a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; color: var(--ink); text-decoration: none; }
.ag-asked { color: var(--muted); margin-bottom: 8px; }
.ag-answer { background: var(--surface); border-inline-start: 4px solid var(--accent); border-radius: 10px; padding: 14px 18px; margin-bottom: 16px; }
.ag-headline { font-size: 1.12rem; font-weight: 700; margin: 0 0 6px; }
.ag-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.ag-chip, .ag-pill, .ag-tag { display: inline-block; border-radius: 999px; font-weight: 700; }
.ag-chip { padding: 4px 12px; font-size: .9rem; }
.ag-pill { padding: 5px 14px; font-size: .92rem; white-space: nowrap; }
.ag-tag { padding: 2px 10px; font-size: .82rem; }
.ag-dev.ag-chip, .ag-dev.ag-pill, .ag-tag.ag-dev { background: #FBE1DF; color: #8B1A12; }
.ag-cfg.ag-chip, .ag-cfg.ag-pill { background: #FBEFD0; color: #6B4A00; }
.ag-ins.ag-chip, .ag-ins.ag-pill, .ag-tag.ag-gap { background: #E6E9EC; color: #3C454D; }
.ag-tag.ag-ok { background: #DDF3E6; color: #145A32; }
.ag-tag.ag-ctx { background: #DDE8FA; color: #1F3F7A; }
.ag-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; }
.ag-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.ag-card-head h3 { margin: 0 0 2px; font-size: 1.08rem; }
.ag-card-head h3 a { color: var(--ink); }
.ag-says-does { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.ag-says, .ag-does { border-radius: 10px; padding: 10px 14px; background: #F4F6F8; }
.ag-dev .ag-does { background: #FDF1F0; }
.ag-cfg .ag-does { background: #FDF8EA; }
.ag-says p, .ag-does p { margin: 4px 0 0; }
.ag-case-line { margin: 10px 0 4px; }
.ag-evidence summary { cursor: pointer; color: var(--accent); font-weight: 700; margin-top: 6px; }
.ag-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 10px; }
.ag-cols section { background: #F9FAFB; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.ag-cols h4 { margin: 0 0 8px; }
.ag-cols blockquote { margin: 8px 0 0; padding: 6px 10px; border-inline-start: 3px solid var(--line); color: var(--muted); }
.ag-item { border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 8px; }
.ag-item p { margin: 4px 0; }
.ag-loc { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.ident { font-family: ui-monospace, Menlo, monospace; font-size: .85em; }
.ag-cfg-status { font-weight: 700; margin-top: 10px; }
.ag-impact { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 14px; }
.ag-impact-row { margin-bottom: 12px; }
.ag-impact-head { display: flex; justify-content: space-between; gap: 10px; }
.ag-amount { font-weight: 700; direction: ltr; unicode-bidi: isolate; }
.ag-bar-track { background: #EEF1F4; border-radius: 6px; height: 12px; margin: 6px 0 2px; }
.ag-bar { height: 12px; border-radius: 6px; }
.ag-bar.ag-over { background: #8B1A12; }
.ag-bar.ag-under { background: #1F3F7A; }
@media (max-width: 900px) { .ag-says-does, .ag-cols { grid-template-columns: 1fr; } }

/* Board 4 — data and charts */
.dt-filters { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 10px 0; }
.dt-filter .k { display: block; margin-bottom: 6px; }
.dt-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.dt-seg a { border: 1px solid #C9D0D6; background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 14px; text-decoration: none; }
.dt-seg a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.dt-howto { background: var(--ws); color: var(--ws-ink); border-radius: 10px; padding: 10px 14px; }
.dt-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 12px 0; }
.dt-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.dt-kpi strong { font-size: 1.7rem; direction: ltr; unicode-bidi: isolate; text-align: start; }
.dt-kpi.dt-bad strong { color: #8B1A12; }
.dt-empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 18px; }
.dt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dt-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; min-width: 0; }
.dt-panel h2 { font-size: 1rem; margin: 0 0 10px; }
.dt-hbar { margin-bottom: 10px; }
.dt-hbar-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.dt-stack { display: flex; height: 24px; background: #EEF1F4; border-radius: 6px; overflow: hidden; }
.dt-stack span { display: flex; align-items: center; justify-content: center; color: #FFF; font-size: .8rem; font-weight: 700; min-width: 22px; }
.dt-seg-dev, .dt-ev-dev { background: #A8322A; }
.dt-seg-cfg, .dt-ev-config { background: #C8961E; }
.dt-seg-ins, .dt-ev-gap { background: #7D8790; }
.dt-ev-ctx { background: #2F5DA8; }
.dt-ev-ok, .dt-out-agree { background: #2E7D4F; }
.dt-out-diverge { background: #B3261E; }
.dt-out-none { background: #9AA3AC; }
.dt-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.dt-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 5px; vertical-align: middle; }
.dt-vbars { display: flex; justify-content: space-around; align-items: flex-end; gap: 10px; min-height: 190px; }
.dt-vbar { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; text-align: center; }
.dt-vbar > span:not(.small) { width: 100%; max-width: 56px; border-radius: 6px 6px 0 0; }
.dt-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.dt-table th, .dt-table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: start; }
@media (max-width: 900px) { .dt-grid { grid-template-columns: 1fr; } }

/* Board 5 — the rules registry */
.rg-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0; }
.rg-tabs a { padding: 10px 12px; color: #3C454D; text-decoration: none; border-bottom: 3px solid transparent; }
.rg-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.rg-flow { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.rg-flow span { white-space: nowrap; }
.rg-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; margin: 10px 0; }
.rg-group { margin-top: 18px; }
.rg-group h2 { margin-bottom: 2px; }
.rg-approval { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700; background: #FFF6DD; color: #7A5A00; }
.rg-approval.ok { background: #DDF3E6; color: #145A32; }
.rg-actions { white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Support on the local model, and the escalation queue */
.ask-chat { margin-bottom: 22px; }
.model-reply { white-space: pre-line; }
.check-card { border-inline-start: 4px solid var(--accent); }
.refer { margin: 10px 0; }
.ok-note { background: #DDF3E6; color: #145A32; border-radius: 10px; padding: 10px 14px; }
.ag-provenance { background: #FFF6DD; color: #5A3E00; border-radius: 8px; padding: 6px 10px; margin-top: 8px; }

/* ===================================================================================================
   Enterprise theme (owner 2026-10-24: «واجهات شبيهة بواجهات الأنظمة المؤسسية الكبرى»). A dark shell bar
   with the environment tag, a grouped side navigation, a neutral canvas, white cards with a light border,
   denser type. Logical properties only, so Arabic (rtl) and English (ltr) share every rule. No web fonts,
   no external resources (ADR-009 Decision 5).
   =================================================================================================== */
:root {
  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --ink: #1D2733;
  --muted: #5F6B7A;
  --line: #DDE2E8;
  --accent: #0B5CAD;
  --accent-ink: #FFFFFF;
  --accent-soft: #E8F1FB;
  --shell: #15233B;
  --shell-ink: #E6ECF5;
  --shell-muted: #9FB0C8;
  --focus: #0B5CAD;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(21, 35, 59, 0.06), 0 1px 1px rgba(21, 35, 59, 0.04);
}
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI", "Geeza Pro", Tahoma, Arial, sans-serif;
  line-height: 1.55;
}
body.lang-en { line-height: 1.5; }

/* shell bar */
.topbar { display: none; }
.banner { display: none; }
.shellbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  min-height: 52px; padding: 6px 20px;
  background: var(--shell); color: var(--shell-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.shellbar a { color: inherit; }
.shellbar-brand { display: flex; align-items: center; gap: 10px; text-decoration: none !important; min-width: 0; }
.shellbar-logo {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 0.85rem; letter-spacing: 0.02em;
}
.shellbar-names { display: grid; line-height: 1.2; }
.shellbar-names strong { font-size: 1rem; }
.shellbar-names span { font-size: 0.78rem; color: var(--shell-muted); }
.env-tag {
  padding: 2px 10px; border-radius: 4px; border: 1px solid #F0B429;
  background: rgba(240, 180, 41, 0.14); color: #FFD27A; font-size: 0.8rem; font-weight: 700; white-space: nowrap;
}
.shellbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shell-btn {
  display: inline-block; padding: 4px 12px; border: 1px solid rgba(230, 236, 245, 0.28); border-radius: 6px;
  background: transparent; color: var(--shell-ink); font: inherit; font-size: 0.85rem; cursor: pointer; white-space: nowrap;
}
.shell-btn:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.shell-btn.on { background: rgba(255, 255, 255, 0.14); }
.shellbar .pill { background: rgba(255, 255, 255, 0.08); border-color: transparent; color: var(--shell-ink); font-size: 0.82rem; }
.shellbar .pill.ws { background: rgba(255, 255, 255, 0.12); color: var(--shell-ink); }
.shell-user { display: inline-flex; align-items: center; gap: 6px; }
.avatar {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: #2E4A78; color: #fff; font-size: 0.8rem; font-weight: 700;
}
.ws-label { background: var(--accent-soft); color: var(--accent); }

/* side navigation */
.shell { min-height: calc(100vh - 52px); }
.sidebar.sidenav {
  width: 252px; flex: 0 0 252px; padding: 12px 0 20px;
  background: var(--surface); border-inline-start: 0; border-inline-end: 1px solid var(--line);
  position: sticky; top: 52px; max-height: calc(100vh - 52px); overflow-y: auto;
}
.sidenav .nav-group {
  margin: 14px 18px 4px; font-size: 0.74rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.sidenav li a {
  padding: 7px 18px; margin: 1px 8px; border-radius: 6px; border-inline-end: 0; font-size: 0.93rem; color: var(--ink);
}
.sidenav li.active a { background: var(--accent-soft); color: var(--accent); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] .sidenav li.active a { box-shadow: inset -3px 0 0 var(--accent); }
.sidenav li a:hover { background: var(--bg); }
.side-status { margin: 18px 18px 0; font-size: 0.82rem; }

/* content canvas */
.content { max-width: 1240px; padding: 22px 28px 48px; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.15rem; }
.source-note {
  margin: 0 0 14px; padding: 6px 12px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 0.85rem;
}
.lead { font-size: 1rem; color: var(--muted); }

/* surfaces */
.stat, .card, .table, .reading, .run-panel, .quote, .ag-card, .dt-kpi, .agent-tile {
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.table { overflow: hidden; }
.table th { background: #F7F9FB; color: var(--muted); font-size: 0.82rem; text-transform: none; }
.btn { border-radius: 6px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: #094C90; text-decoration: none; }
select, input, textarea { border-radius: 6px; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* the start page */
.page-head { margin: 4px 0 18px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.agent-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; margin: 8px 0 12px; }
.agent-tile {
  display: grid; gap: 10px; align-content: start;
  background: var(--surface); border: 1px solid var(--line); padding: 20px 22px;
}
.agent-tile-head { display: flex; align-items: center; gap: 12px; }
.agent-tile-head h2 { margin: 0; font-size: 1.2rem; }
.agent-tile p { margin: 0; }
.agent-icon {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 10px;
  font-size: 1.2rem; font-weight: 800; color: #fff;
}
.agent-icon.compliance { background: #0B5CAD; }
.agent-icon.support { background: #0E7C66; }
.agent-stats { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.agent-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.section-title { font-size: 1rem; margin: 26px 0 10px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 0.9rem; }

/* footer legend */
.legend { background: var(--surface); border-top: 1px solid var(--line); font-size: 0.82rem; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar.sidenav { position: static; width: 100%; flex: none; max-height: none; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .shellbar { flex-wrap: wrap; }
  .shellbar-names span { display: none; }
}
