/* CAFM Way user guide — colours follow frontend/lib/theme/app_theme.dart */
:root {
  --brand: #EC7D1C;
  --brand-ink: #9C5212;
  --brand-soft: #FEF0E0;
  --navy: #0B1220;
  --navy-2: #151D2E;
  --navy-line: #1E293B;
  --navy-text: #CBD5E1;
  --page: #F4F1EC;
  --surface: #FFFFFF;
  --surface-2: #F8F4EE;
  --line: #E8DFD4;
  --ink: #0F172A;
  --muted: #556376;
  --ok: #16A34A;
  --warn: #B45309;
  --bad: #BB2020;
  --info: #1D4ED8;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --display: "Cairo", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --body: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --side-w: 300px;
  --top-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-ink: #F0984C; --brand-soft: #3A2412;
    --page: #0F1623; --surface: #1B2436; --surface-2: #243044; --line: #3D4B63;
    --ink: #F8FAFC; --muted: #B4C0D0; --ok: #4ADE80; --warn: #FBBF24; --bad: #F98F8F; --info: #79B3FB;
    --shadow: 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand-ink: #F0984C; --brand-soft: #3A2412;
  --page: #0F1623; --surface: #1B2436; --surface-2: #243044; --line: #3D4B63;
  --ink: #F8FAFC; --muted: #B4C0D0; --ok: #4ADE80; --warn: #FBBF24; --bad: #F98F8F; --info: #79B3FB;
  --shadow: 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + 16px); }
body { margin: 0; background: var(--page); color: var(--ink); font: 15.5px/1.75 var(--body); -webkit-font-smoothing: antialiased; }
[dir="rtl"] body, body[dir="rtl"] { font-size: 16px; }
img { max-width: 100%; }
a { color: var(--brand-ink); }
[hidden] { display: none !important; }
.mono, code { font-family: var(--mono); font-size: .88em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* top bar */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 20px;
  padding-inline: 20px; background: var(--navy); color: #fff; border-bottom: 1px solid var(--navy-line); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex-shrink: 0; }
.brand img { width: 30px; height: 30px; object-fit: contain; }
.brand span { font: 800 19px/1 var(--display); letter-spacing: -.01em; }
.brand span b { color: var(--brand); font-weight: 800; }
.brand small { color: var(--navy-text); font-size: 12.5px; border-inline-start: 1px solid var(--navy-line); padding-inline-start: 10px; }
.apps { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.app-tab { color: var(--navy-text); text-decoration: none; font: 600 13.5px/1 var(--display); padding: 10px 14px; border-radius: 8px; white-space: nowrap; }
.app-tab:hover { background: var(--navy-2); color: #fff; }
.app-tab.on { background: rgba(236, 125, 28, .18); color: #fff; box-shadow: inset 0 -2px 0 var(--brand); }
.tools { display: flex; gap: 8px; flex-shrink: 0; }
.btn { appearance: none; border: 0; cursor: pointer; font: 600 13px/1 var(--display); padding: 9px 14px; border-radius: 8px;
  background: var(--brand); color: #fff; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #C4620F; }
.btn.ghost { background: transparent; color: var(--navy-text); box-shadow: inset 0 0 0 1px var(--navy-line); }
.btn.ghost:hover { color: #fff; background: var(--navy-2); }

/* layout */
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.side { position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top, 0px)); height: calc(100vh - var(--top-h)); overflow-y: auto;
  padding: 18px 14px 40px; border-inline-end: 1px solid var(--line); background: var(--surface); }
.search input { width: 100%; font: 14px var(--body); padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.side-h { margin: 18px 6px 6px; font: 700 11.5px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li.grp { margin: 16px 6px 4px; font: 700 13px/1.4 var(--display); color: var(--ink); }
.toc a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 13.5px; line-height: 1.45; }
.toc a:hover { background: var(--surface-2); color: var(--ink); }
.toc a.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.empty { color: var(--muted); padding: 6px 10px; font-size: 13px; }

.doc { padding: 36px 48px 120px; max-width: 1060px; width: 100%; }
.doc > * { max-width: 760px; }
.doc > .wf, .doc > figure, .doc > .tbl, .doc > pre { max-width: none; }

.cover { padding: 8px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.cover img { display: none; }
.eyebrow { margin: 0 0 6px; font: 700 12px/1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--brand-ink); }
.title { margin: 0; font: 800 clamp(28px, 4vw, 40px)/1.2 var(--display); letter-spacing: -.01em; text-wrap: balance; }
.lede { margin: 12px 0 0; font-size: 17px; color: var(--muted); max-width: 62ch; }
.stamp { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.print-toc { display: none; }

h1.part { margin: 64px 0 4px; padding-top: 22px; border-top: 3px solid var(--ink); font: 800 26px/1.3 var(--display); text-wrap: balance; }
.wf { padding-top: 12px; }
h2.flow { margin: 44px 0 10px; font: 700 22px/1.35 var(--display); text-wrap: balance; }
h3 { margin: 28px 0 6px; font: 700 17px/1.4 var(--display); }
h4 { margin: 20px 0 4px; font: 700 15px/1.4 var(--display); color: var(--muted); }
.anchor { margin-inline-start: 8px; color: var(--line); text-decoration: none; font-weight: 400; opacity: 0; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
p, li { max-width: 72ch; }
.wf > p, .wf > ul, .wf > ol, .wf > h3, .wf > h4, .wf > aside, .wf > blockquote { max-width: 760px; }

/* meta list right under a workflow title: "- **Role:** …" */
.wf > h2 + ul { list-style: none; padding: 12px 16px; margin: 0 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  display: grid; gap: 4px; font-size: 14.5px; }
.wf > h2 + ul li { max-width: none; }
.wf > h2 + ul strong { color: var(--muted); font-weight: 600; }

/* numbered steps */
.wf ol { counter-reset: s; list-style: none; padding: 0; margin: 12px 0 18px; }
.wf ol > li { counter-increment: s; position: relative; padding-inline-start: 42px; margin: 0 0 10px; }
.wf ol > li::before { content: counter(s); position: absolute; inset-inline-start: 0; top: 1px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font: 700 13px/1 var(--display); background: var(--brand-soft); color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.wf ol ol > li::before { background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
ul { padding-inline-start: 22px; }

/* UI labels quoted in text: **Save** stays bold; `code` for statuses/endpoints */
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; white-space: nowrap; }
kbd { font: 600 12.5px var(--display); background: var(--surface); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 7px; }

/* screenshots */
.shot { margin: 20px 0 28px; }
.shot .frame { border-radius: 10px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.shot.browser .frame::before { content: ""; display: block; height: 22px; background:
  radial-gradient(circle at 12px 11px, #F87171 4px, transparent 4.5px), radial-gradient(circle at 26px 11px, #FBBF24 4px, transparent 4.5px),
  radial-gradient(circle at 40px 11px, #4ADE80 4px, transparent 4.5px), var(--surface-2); border-bottom: 1px solid var(--line); }
[dir="rtl"] .shot.browser .frame::before { transform: scaleX(-1); }
.shot img { display: block; width: 100%; height: auto; }
.shot.phone { display: inline-block; vertical-align: top; width: 280px; max-width: 100%; margin-inline-end: 18px; }
.shot.phone .frame { border-radius: 30px; border: 8px solid var(--navy); box-shadow: var(--shadow); }
.shot figcaption { margin-top: 8px; font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.shot figcaption b { color: var(--ink); font-family: var(--display); margin-inline-end: 6px; }
.shot.missing .ph { display: grid; place-items: center; min-height: 160px; border: 2px dashed var(--line); border-radius: 10px; color: var(--muted); font: 13px var(--mono); }

/* callouts */
.call { margin: 16px 0; padding: 12px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--info); }
.call p { margin: 4px 0; }
.call-k { display: block; font: 700 12px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--info); margin-bottom: 6px; }
.call.warn { border-inline-start-color: var(--warn); } .call.warn .call-k { color: var(--warn); }
.call.rule { border-inline-start-color: var(--brand); } .call.rule .call-k { color: var(--brand-ink); }
.call.tip { border-inline-start-color: var(--ok); } .call.tip .call-k { color: var(--ok); }
.call.example { border-inline-start-color: #7C3AED; background: var(--surface-2); } .call.example .call-k { color: #7C3AED; }
blockquote { margin: 16px 0; padding: 4px 16px; border-inline-start: 3px solid var(--line); color: var(--muted); }

/* tables */
.tbl { overflow-x: auto; margin: 14px 0 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font: 700 12.5px/1.4 var(--display); color: var(--muted); letter-spacing: .02em; }
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

pre.code { overflow-x: auto; background: var(--navy); color: #E2E8F0; border-radius: 10px; padding: 14px 16px; font: 13px/1.6 var(--mono); direction: ltr; text-align: left; }
pre.code code { background: none; border: 0; padding: 0; color: inherit; white-space: pre; }
pre.mermaid { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; overflow-x: auto; direction: ltr; text-align: center; }

/* home */
.home-main { max-width: 1100px; margin: 0 auto; padding-block: 56px 80px; padding-inline: 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 36px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 22px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--brand); transform: translateY(-2px); }
.card h2 { margin: 0; font: 700 20px/1.3 var(--display); }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; flex: 1; }
.card-k { font: 12px var(--mono); color: var(--brand-ink); direction: ltr; text-align: start; }
.card-n { font: 600 13px var(--display); color: var(--muted); }

/* narrow screens */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; max-height: 50vh; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .doc { padding: 24px 16px 80px; }
  .brand small { display: none; }
  .top { gap: 10px; padding-inline: 12px; }
  .tools .btn.ghost[onclick] { display: none; }
}
@media (max-width: 560px) {
  .apps { display: none; }
  .shot.phone { width: 100%; margin-inline-end: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* print / PDF */
@page { size: A4; margin: 14mm 14mm 16mm; }
@media print {
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] {
    --brand-ink: #9C5212; --brand-soft: #FEF0E0; --page: #fff; --surface: #fff; --surface-2: #F8F4EE; --line: #E8DFD4;
    --ink: #0F172A; --muted: #556376; --ok: #16A34A; --warn: #B45309; --bad: #BB2020; --info: #1D4ED8;
    --shadow: none; color-scheme: light;
  }
  body { background: #fff; font-size: 11pt; line-height: 1.6; }
  .top, .side, .anchor { display: none !important; }
  .layout { display: block; }
  .doc { padding: 0; max-width: none; }
  .doc > * { max-width: none; }
  .cover { min-height: 250mm; display: flex; flex-direction: column; justify-content: center; border: 0; page-break-after: always; }
  .cover img { display: block; width: 90px; margin-bottom: 24px; }
  .cover .title { font-size: 34pt; }
  .print-toc { display: block; page-break-after: always; }
  .print-toc h2 { font: 800 20pt var(--display); margin: 0 0 12px; }
  .print-toc ol { list-style: none; padding: 0; columns: 2; column-gap: 28px; font-size: 10pt; }
  .print-toc li.grp { font: 700 11pt var(--display); margin-top: 10px; break-after: avoid; }
  .print-toc a { color: var(--ink); text-decoration: none; }
  h1.part { page-break-before: always; border-top: 0; margin-top: 0; padding-top: 0; font-size: 22pt; }
  .wf { page-break-before: always; }
  h1.part + .wf, h1.part + p + .wf { page-break-before: avoid; }
  .shot, .call, .tbl, pre, table, tr { break-inside: avoid; }
  h2, h3, h4 { break-after: avoid; }
  .shot .frame { box-shadow: none; }
  .shot.browser img { max-height: 150mm; object-fit: contain; }
  .shot.phone { width: 58mm; }
  a { color: inherit; text-decoration: none; }
}

/* full-page captures of long forms: keep them readable without dominating the column */
.shot.tall { max-width: 620px; }
@media print { .shot.tall { max-width: 120mm; } .shot.tall img { max-height: none; } }

/* Mermaid labels in RTL pages: keep Arabic text shaping inside the LTR diagram box */
[dir="rtl"] pre.mermaid .nodeLabel, [dir="rtl"] pre.mermaid .edgeLabel { direction: rtl; unicode-bidi: plaintext; }

/* signed-in user in the top bar */
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--navy-text); font-size: 13px; white-space: nowrap; }
@media (max-width: 700px) { .who { font-size: 0; } .who .btn { font-size: 13px; } }
