/* D.DESIGN identity: burgundy #801d22 (logo / CRM) and #7E1F23 (project documents), Cairo, warm neutral workspace,
   deep burgundy navigation, burgundy table headers like the work-order forms, and the proposal's colour key. */
@font-face { font-family: 'Cairo'; src: url('assets/Cairo-Variable.ttf') format('truetype'); font-weight: 200 1000; font-display: swap; }

:root {
  --brand: #801d22; --brand-doc: #7e1f23; --brand-600: #6a171c; --brand-50: #f9eeee; --brand-100: #f3e4e4;
  --bg: #f8f7f5; --card: #ffffff; --fg: #231a1b; --muted: #6e5c5a; --muted-bg: #f2efec; --border: #e7e1dd; --input: #d9d1cc;
  --row: #fbf6f5; --row-tint: #f6eded;
  --ok: #1e8a56; --ok-bg: #e4f4ec; --warn: #b76b04; --warn-bg: #fdf1dc; --danger: #c22a2a; --danger-bg: #fde8e7; --info: #0b6f99; --info-bg: #e2f1f8;
  /* proposal colour key */
  --k-sign: #f6d5d7; --k-btn: #ddebf7; --k-auto: #e2f0d9; --k-screen: #fff2cc; --k-merge: #ede2f6; --k-client: #fce4d6;
  /* v7 colour key */
  --v-main: #ddebf7; --v-sub: #f6d5d7; --v-opt: #e2f0d9; --v-miss: #ffe600;
  --nav-1: hsl(355 52% 17%); --nav-2: hsl(355 55% 12%); --nav-fg: hsl(350 30% 88%); --nav-acc: hsl(355 42% 21%); --nav-line: hsl(355 34% 24%); --nav-hi: hsl(350 80% 74%);
  --shadow: 0 1px 2px rgb(40 12 14 / .04), 0 4px 16px -6px rgb(40 12 14 / .09);
  --shadow-up: 0 2px 4px rgb(40 12 14 / .05), 0 12px 32px -12px rgb(40 12 14 / .2);
  --r: .75rem; --r-card: .875rem;
}
:root[data-theme="dark"] {
  --bg: #161112; --card: #1f1819; --fg: #f3ecec; --muted: #b8a9a7; --muted-bg: #2a2122; --border: #3a2e2f; --input: #4a3b3c;
  --row: #241c1d; --row-tint: #2c2223; --brand-50: #33191b; --brand-100: #3d1d20;
  --ok: #4cc58a; --ok-bg: #173226; --warn: #f0a640; --warn-bg: #3a2a12; --danger: #f07070; --danger-bg: #3d1a1a; --info: #57b8e0; --info-bg: #132c38;
  --k-sign: #4a2a2d; --k-btn: #22344a; --k-auto: #24382a; --k-screen: #403818; --k-merge: #362a44; --k-client: #452f22;
  --v-main: #22344a; --v-sub: #4a2a2d; --v-opt: #24382a;
  --shadow: 0 1px 2px rgb(0 0 0 / .3); --shadow-up: 0 8px 24px -8px rgb(0 0 0 / .5);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Cairo', system-ui, sans-serif; background: var(--bg); color: var(--fg); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.app { display: flex; min-height: 100vh; }
.nav { width: 264px; flex-shrink: 0; background: linear-gradient(180deg, var(--nav-1), var(--nav-2)); color: var(--nav-fg); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; border-inline-end: 1px solid var(--nav-line); z-index: 40; }
.nav .logo { margin: 16px 16px 8px; background: #fff; border-radius: var(--r); padding: 8px 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgb(0 0 0 / .15); }
.nav .logo img { height: 64px; }
.nav .group { font-size: 11px; font-weight: 600; color: hsl(350 30% 88% / .55); padding: 14px 20px 6px; letter-spacing: .02em; }
.nav a.item { display: flex; align-items: center; gap: 10px; margin: 2px 10px; padding: 8px 12px; border-radius: .625rem; color: var(--nav-fg); font-weight: 500; border-inline-start: 3px solid transparent; }
.nav a.item svg { width: 18px; height: 18px; opacity: .85; flex-shrink: 0; }
.nav a.item:hover { background: var(--nav-acc); color: #fff; }
.nav a.item.on { background: hsl(0 0% 100% / .14); color: #fff; border-inline-start-color: #fff; }
.nav a.item .count { margin-inline-start: auto; background: var(--nav-hi); color: var(--nav-2); font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; }
.nav .foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--nav-line); font-size: 12px; color: hsl(350 30% 88% / .7); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 10px; padding-inline: 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs a:hover { color: var(--brand); }
.crumbs .sep { opacity: .5; }
.crumbs b { color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.topbar .sp { flex: 1; }
.rolebox { white-space: nowrap; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.rolebox select { border: 1px solid var(--brand); background: var(--brand-50); color: var(--brand); font-weight: 700; border-radius: 99px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
:root[data-theme="dark"] .rolebox select { color: #f2b8bc; }
.iconbtn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.iconbtn svg { width: 17px; height: 17px; }
.menu-btn { display: none; }
.content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- typography & cards ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.wordmark { font-family: 'Times New Roman', Georgia, serif; font-weight: 700; letter-spacing: .04em; color: var(--brand-doc); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-b { padding: 16px 18px; }
.sec-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; color: var(--brand-doc); margin: 22px 0 10px; }
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--brand-doc); opacity: .35; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; inset-inline: 16px; bottom: 9px; height: 3px; border-radius: 99px; background: var(--brand); opacity: .85; }
.kpi.ok::after { background: var(--ok); } .kpi.warn::after { background: var(--warn); } .kpi.info::after { background: var(--info); }
.kpi .l { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- buttons, chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; padding: 7px 14px; font-weight: 600; font-size: 13px; border: 1px solid var(--border); background: var(--card); cursor: pointer; white-space: nowrap; transition: background .12s, box-shadow .12s; }
.btn:hover { background: var(--muted-bg); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-50); }
.btn.sm { padding: 3px 10px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 1px 9px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--muted-bg); color: var(--muted); }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); } .chip.info { background: var(--info-bg); color: var(--info); }
.chip.brand { background: var(--brand-50); color: var(--brand); }
:root[data-theme="dark"] .chip.brand { color: #f2b8bc; }
.chip.team { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 500; }
.chip.doc { background: var(--row-tint); color: var(--brand-doc); font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; font-weight: 600; direction: ltr; }
:root[data-theme="dark"] .chip.doc { color: #f2b8bc; }
.k-sign { background: var(--k-sign) !important; } .k-btn { background: var(--k-btn) !important; } .k-auto { background: var(--k-auto) !important; }
.k-screen { background: var(--k-screen) !important; } .k-merge { background: var(--k-merge) !important; } .k-client { background: var(--k-client) !important; }
.chip.key { color: var(--fg); }
.chip.opt { background: var(--v-opt); color: var(--fg); }

/* ---------- progress ---------- */
.bar { height: 6px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--brand); transition: width .3s; }
.bar.ok > span { background: var(--ok); }

/* ---------- tables (work-order style headers) ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th { background: var(--brand-doc); color: #fff; font-weight: 600; text-align: start; padding: 9px 12px; white-space: nowrap; font-size: 12.5px; }
.tbl thead th .en { display: block; font-weight: 400; font-size: 10.5px; opacity: .75; }
.tbl tbody td { border-top: 1px solid var(--border); padding: 9px 12px; vertical-align: middle; }
.tbl tbody tr:nth-child(even) td { background: var(--row); }
.tbl tbody tr.grp td { background: var(--row-tint) !important; color: var(--brand-doc); font-weight: 700; text-align: center; }
:root[data-theme="dark"] .tbl tbody tr.grp td { color: #f2b8bc; }
.tbl tfoot td { border-top: 2px solid var(--brand-doc); padding: 10px 12px; font-weight: 700; }
.tbl input, .tbl select { width: 100%; border: 1px solid var(--input); border-radius: 8px; padding: 5px 8px; background: var(--card); }
.tbl input:focus, .tbl select:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.tbl-wrap { overflow-x: auto; border-radius: var(--r-card); }
.to-tbl td:nth-child(2) { min-width: 190px; }
.to-tbl td:nth-child(5) { min-width: 150px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; }
.field input, .field select, .field textarea { border: 1px solid var(--input); border-radius: 10px; padding: 8px 11px; background: var(--card); }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); cursor: pointer; }
.check:hover { border-color: var(--brand); }
.check input { margin-top: 4px; accent-color: var(--brand); width: 16px; height: 16px; }
.check.on { border-color: var(--brand); background: var(--brand-50); }

/* ---------- phase timeline ---------- */
.phase-list { display: flex; flex-direction: column; gap: 10px; }
.phase-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) 160px 130px 24px; align-items: center; gap: 14px; padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s; }
a.phase-row:hover { box-shadow: var(--shadow-up); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
.phase-row.locked { opacity: .62; }
.phase-row.skipped { opacity: .45; border-style: dashed; box-shadow: none; }
.phase-no { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; background: var(--v-main); color: var(--brand-doc); }
.phase-no.sub { background: var(--v-sub); }
.phase-no.optc { background: var(--v-opt); }
.phase-row .t { font-weight: 700; font-size: 15px; }
.phase-row .en { font-size: 12px; color: var(--muted); direction: ltr; text-align: end; display: inline-block; }
.exec-group { border: 1px solid var(--border); border-radius: calc(var(--r-card) + 4px); padding: 10px; background: color-mix(in srgb, var(--v-main) 30%, transparent); }
.exec-group > .lbl { font-weight: 700; color: var(--brand-doc); padding: 2px 8px 10px; display: flex; gap: 8px; align-items: center; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
:root[data-theme="dark"] .tabs a.on { color: #f2b8bc; border-bottom-color: #f2b8bc; }
.tabs a .chip { font-size: 10.5px; padding: 0 7px; }

/* ---------- steps ---------- */
.steps { display: flex; flex-direction: column; gap: 8px; }
.step { background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.step.done { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.step.lockd { background: var(--muted-bg); }
.step.focus { box-shadow: 0 0 0 2px var(--brand); }
.step-h { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 14px; }
.step-n { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: var(--muted-bg); color: var(--muted); }
.step.done > .step-h .step-n, .sub.done .step-n { background: var(--ok-bg); color: var(--ok); }
.step-t { font-weight: 600; }
.step-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; align-items: center; }
.step-act { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
details.step > summary { list-style: none; cursor: pointer; }
details.step > summary::-webkit-details-marker { display: none; }
details.step > summary .caret { transition: transform .15s; display: inline-block; color: var(--muted); }
details.step[open] > summary .caret { transform: rotate(-90deg); }
.subs { border-top: 1px dashed var(--border); padding: 8px 14px 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.sub-group { font-size: 12px; font-weight: 700; color: var(--brand-doc); margin: 8px 4px 2px; }
:root[data-theme="dark"] .sub-group { color: #f2b8bc; }
.sub { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 10px; background: var(--row); }
.sub .step-n { width: 26px; height: 26px; font-size: 12px; }
.sub.lockd { opacity: .6; }
.tick { width: 22px; height: 22px; accent-color: var(--ok); cursor: pointer; }
.tick:disabled { cursor: not-allowed; }
.lock-note { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.lock-note svg { width: 13px; height: 13px; }

/* card stepper */
.cardflow { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; }
.cardflow span { padding: 1px 7px; border-radius: 6px; background: var(--muted-bg); color: var(--muted); }
.cardflow span.on { background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.cardflow i { color: var(--muted); font-style: normal; opacity: .6; }

/* ---------- gate ---------- */
.gate { border: 1px solid var(--border); border-radius: var(--r-card); background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.gate-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: var(--row-tint); border-bottom: 1px solid var(--border); }
.gate-h b { color: var(--brand-doc); }
:root[data-theme="dark"] .gate-h b { color: #f2b8bc; }
.gate-i { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 16px; border-top: 1px solid var(--border); }
.gate-i:first-of-type { border-top: 0; }
.gate-i .ic { width: 22px; height: 22px; border-radius: 99px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; background: var(--muted-bg); color: var(--muted); }
.gate-i.ok .ic { background: var(--ok-bg); color: var(--ok); }
.gate-i .src { font-size: 11.5px; color: var(--muted); }

/* ---------- next action banner ---------- */
.next { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: var(--r-card); background: linear-gradient(90deg, var(--brand-50), var(--card)); border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--border)); margin-bottom: 16px; }
.next .ico { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.next .ico svg { width: 18px; height: 18px; }
.next .txt { flex: 1; min-width: 0; }
.next .txt b { display: block; }
.banner { padding: 10px 14px; border-radius: 10px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.info { background: var(--info-bg); color: var(--info); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }

/* ---------- wizard ---------- */
.wiz-steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.wiz-steps div { flex: 1; min-width: 140px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); font-size: 13px; color: var(--muted); }
.wiz-steps div b { display: block; color: var(--fg); }
.wiz-steps div.on { border-color: var(--brand); background: var(--brand-50); }
.wiz-steps div.done b { color: var(--ok); }
.wiz-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgb(20 8 9 / .45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--card); border-radius: 16px; width: min(520px, 100%); box-shadow: var(--shadow-up); overflow: hidden; }
.modal .mh { padding: 14px 18px; background: var(--brand-doc); color: #fff; font-weight: 700; }
.modal .mb { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%); background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 600; z-index: 120; box-shadow: var(--shadow-up); animation: tin .2s; }
@keyframes tin { from { opacity: 0; transform: translate(50%, 8px); } }

/* ---------- doc-like print header (BOQ) ---------- */
.doc-head { text-align: center; padding: 18px 0 8px; }
.doc-head .wordmark { font-size: 22px; }
.doc-head .doc-sub { font-size: 11px; color: var(--muted); letter-spacing: .08em; }
.doc-title { font-family: 'Times New Roman', Georgia, serif; color: var(--brand-doc); font-size: 22px; font-weight: 700; margin: 10px 0 0; }
.doc-title-ar { color: var(--brand-doc); font-weight: 700; font-size: 18px; }
.meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 12px 0; }
.meta-grid div { padding: 8px 12px; border-inline-start: 1px solid var(--border); border-top: 1px solid var(--border); background: var(--card); }
.meta-grid div span { display: block; font-size: 11px; color: var(--muted); }
.meta-grid div b { font-size: 13px; }

.empty { border: 1px dashed var(--border); border-radius: var(--r-card); padding: 30px 16px; text-align: center; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.hide-sm { }

@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phase-row { grid-template-columns: 46px minmax(0, 1fr) 110px 22px; }
  .phase-row .col-status { display: none; }
}
@media (max-width: 860px) {
  .nav { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(100%); transition: transform .2s; }
  .nav.open { transform: none; box-shadow: var(--shadow-up); }
  .menu-btn { display: inline-flex; }
  .topbar { padding-inline: 12px; }
  .content { padding: 16px; }
  .rolebox .lbl { display: none; }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .g4, .g3, .g2 { grid-template-columns: minmax(0, 1fr); }
  .phase-row { grid-template-columns: 42px minmax(0, 1fr) 22px; }
  .phase-row .col-prog { display: none; }
  .step-h { grid-template-columns: 30px minmax(0, 1fr); }
  .step-act { grid-column: 1 / -1; justify-content: flex-start; }
  .sub { grid-template-columns: 26px minmax(0, 1fr); }
  .sub .step-act { grid-column: 1 / -1; }
  .page-title { font-size: 20px; }
  .crumbs .hide-sm { display: none; }
  .hide-sm { display: none; }
}
@media print {
  .nav, .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; }
  .tbl thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* user switcher */
.userbox { position: relative; display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); cursor: pointer; white-space: nowrap; }
.userbox:hover { border-color: var(--brand); }
.userbox .avatar { width: 32px; height: 32px; font-size: 13px; border-radius: 99px; background: var(--brand-100); color: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.userbox .who { display: flex; flex-direction: column; line-height: 1.25; }
.userbox .who b { font-size: 13px; }
.userbox .who span { font-size: 11.5px; color: var(--muted); }
.userbox select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
@media (max-width: 600px) { .userbox .who { display: none; } .userbox { padding: 3px; } }

/* ---------- work-order document (same layout as the Drive forms) ---------- */
.wo-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.wo-steps { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.wo-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wo-doc { background: #fff; color: #231a1b; border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 28px 40px 22px; max-width: 900px; margin: 0 auto; }
:root[data-theme="dark"] .wo-doc { background: #fbf8f7; }
.wo-doc .muted { color: #6e5c5a; }
.wo-doc .doc-head { padding-top: 0; }
.wo-doc .doc-head .wordmark { font-size: 22px; }
.wo-doc .doc-sub { font-size: 11px; color: #6e5c5a; letter-spacing: .06em; }
.wo-code { font-size: 12px; font-weight: 700; color: #7e1f23; margin-top: 14px; direction: ltr; text-align: left; }
.wo-title { font-family: 'Times New Roman', Georgia, serif; color: #7e1f23; font-size: 26px; margin: 2px 0 0; direction: ltr; text-align: left; }
.wo-title-ar { color: #7e1f23; font-weight: 800; font-size: 19px; text-align: right; margin-top: -30px; }
.wo-sec { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 15px; color: #7e1f23; border-bottom: 1.5px solid #7e1f23; padding-bottom: 4px; margin: 26px 0 10px; }
.wo-sec span:first-child { font-family: 'Times New Roman', Georgia, serif; direction: ltr; order: 2; }
.wo-sec span:last-child { font-weight: 800; order: 1; }
.wo-grid { display: grid; grid-template-columns: 1fr 1.25fr 1fr 1.25fr; border: 1px solid #e2d7d5; border-radius: 4px; overflow: hidden; }
.wo-grid > div { border-bottom: 1px solid #e2d7d5; padding: 8px 10px; min-height: 52px; font-size: 13px; }
.wo-l { background: #f6eded; display: flex; flex-direction: column; justify-content: center; }
.wo-l b { font-size: 12px; } .wo-l span { font-size: 11.5px; color: #6e5c5a; }
.wo-v { display: flex; flex-direction: column; justify-content: center; }
.wo-v input, .wo-v select { border: 1px solid #d9d1cc; border-radius: 6px; padding: 5px 8px; width: 100%; background: #fff; }
.wo-req { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #e2d7d5; }
.wo-req.single { grid-template-columns: 1fr; }
.wo-req > div + div { border-inline-start: 1px solid #e2d7d5; }
.wo-req-h { background: #7e1f23; color: #fff; padding: 7px 12px; display: flex; flex-direction: column; }
.wo-req-h b { font-size: 13px; } .wo-req-h span { font-size: 11px; opacity: .8; }
.wo-req-b { padding: 10px 14px; margin: 0; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
ul.wo-req-b { padding-inline-start: 30px; }
.wo-chk { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.wo-chk input { accent-color: #7e1f23; width: 15px; height: 15px; }
.wo-sub { font-weight: 700; color: #7e1f23; margin-bottom: 6px; font-size: 13px; }
.wo-tbl tbody td { background: #fff !important; color: #231a1b; }
.wo-tbl tbody tr.grp td { background: #f6eded !important; color: #7e1f23; }
.wo-tbl input { background: #fff; color: #231a1b; }
.wo-text { width: 100%; border: 1px solid #d9d1cc; border-radius: 6px; padding: 10px; min-height: 90px; background: #fff; color: #231a1b; }
.wo-text-view { border: 1px solid #e2d7d5; border-radius: 4px; padding: 12px; min-height: 70px; font-size: 13px; }
.wo-matreq { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.wo-client { font-size: 13px; margin-bottom: 6px; }
.wo-notes { padding-inline-start: 22px; font-size: 13px; margin: 0 0 10px; }
.wo-sign td { height: 46px; }
.wo-sign .wo-role { background: #f6eded !important; }
.wo-role b { display: block; font-size: 12px; } .wo-role span { font-size: 11.5px; color: #6e5c5a; }
.wo-sig { font-family: 'Segoe Script', 'Brush Script MT', cursive; color: #1a3e8c; font-size: 13px; }
.wo-foot { direction: ltr; text-align: center; font-size: 11px; color: #6e5c5a; margin-top: 18px; }
@media (max-width: 760px) {
  .wo-doc { padding: 18px 14px; }
  .wo-grid { grid-template-columns: 1fr 1.4fr; }
  .wo-req { grid-template-columns: 1fr; } .wo-req > div + div { border-inline-start: 0; border-top: 1px solid #e2d7d5; }
  .wo-title { font-size: 20px; } .wo-title-ar { margin-top: 2px; }
  .wo-doc { overflow-x: auto; }
}
@media print { .wo-doc { border: 0; box-shadow: none; padding: 0; max-width: none; } .wo-req-h, .wo-l, .tbl thead th, .wo-tbl tr.grp td { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ---------- folders, viewer, stand-alone documents ---------- */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.folder { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s; }
.folder:hover:not(.nope) { box-shadow: var(--shadow-up); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
.folder.nope { opacity: .7; }
.folder-main { display: flex; gap: 12px; align-items: center; padding: 16px; cursor: pointer; }
.folder.nope .folder-main { cursor: default; }
.folder-ic { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-50); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.folder-ic.priv { background: var(--warn-bg); color: var(--warn); }
.folder-ic svg { width: 22px; height: 22px; }
.folder-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.folder-t b { font-size: 15px; } .folder-t span { font-size: 12px; color: var(--muted); }
.folder-last { margin: 0 16px; padding: 8px 10px; background: var(--row); border-radius: 10px; display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-foot { margin-top: auto; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.ftype { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 22px; border-radius: 6px; background: var(--danger-bg); color: var(--danger); font-size: 10px; font-weight: 800; letter-spacing: .03em; }
.file-row { cursor: pointer; }
.viewer-bg { position: fixed; inset: 0; z-index: 110; background: rgb(20 8 9 / .6); display: flex; align-items: center; justify-content: center; padding: 2vh 2vw; }
.viewer { width: min(1100px, 96vw); height: 94vh; background: var(--card); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-up); }
.viewer-h { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.viewer-h > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewer-h > div span { font-size: 12px; color: var(--muted); }
.viewer iframe { flex: 1; border: 0; width: 100%; background: #525659; }
.viewer-img { flex: 1; overflow: auto; background: #525659; display: flex; align-items: center; justify-content: center; }
.viewer-img img { max-width: 100%; max-height: 100%; }
body.doc-mode { background: #525659; }
.doc-only { padding: 24px 12px; }
.doc-only .wo-doc { max-width: 820px; }
.form-doc { position: relative; }
.form-doc .doc-head { display: flex; flex-direction: column; align-items: center; }
.form-text { font-size: 14px; line-height: 2; padding: 6px 4px; }
.stamp { position: absolute; left: 50px; top: 150px; transform: rotate(-12deg); border: 3px solid #7e1f23; color: #7e1f23; border-radius: 10px; padding: 6px 16px; font-weight: 800; text-align: center; opacity: .8; }
.stamp span { font-size: 11px; font-weight: 600; }
@media print { body.doc-mode { background: #fff; } .doc-only { padding: 0; } }
