/* FORMWORK-AI - design system: neutral grays, one accent (blue), white cards with a hairline border, RTL.
   Colors with meaning: success green, warning amber, danger red, "corrected by hand" purple. */
:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #f9fafb; --ink: #111827; --ink-2: #374151; --muted: #6b7280; --faint: #9ca3af;
  --line: #e5e7eb; --line-2: #d1d5db;
  --accent: #2563eb; --accent-2: #1d4ed8; --accent-bg: #eff6ff; --accent-line: #bfdbfe;
  --ok: #15803d; --ok-bg: #ecfdf3; --ok-fill: #16a34a;
  --warn: #b45309; --warn-bg: #fffbeb; --warn-fill: #f59e0b; --warn-line: #fde68a;
  --err: #b91c1c; --err-bg: #fef2f2; --err-fill: #dc2626; --err-line: #fecaca;
  --pro: #6d28d9; --pro-bg: #f5f3ff; --pro-fill: #7c3aed;
  --chip: #f3f4f6; --radius: 8px; --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --side-w: 236px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 "Heebo", "Noto Sans", "Noto Sans Arabic", "Segoe UI", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
.ti { font-size: 18px; vertical-align: -3px; }

/* ---------- the frame: side menu + page ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--panel); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--ink); text-decoration: none; }
.side .brand .mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.side .brand img { max-width: 34px; max-height: 34px; border-radius: 6px; flex: none; }
.side .brand b { display: block; font-size: 15px; line-height: 1.2; }
.side .brand small { color: var(--muted); font-size: 12px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--ink-2); font-size: 14px; text-decoration: none; }
.side nav a:hover { background: var(--chip); }
.side nav a.on { background: var(--accent-bg); color: var(--accent-2); font-weight: 500; }
.side nav a .ti { color: var(--faint); } .side nav a.on .ti { color: var(--accent); }
.side nav a .badge { margin-inline-start: auto; }
.side .navsep { margin: 14px 10px 4px; font-size: 11px; color: var(--faint); letter-spacing: .02em; }
.side .sidefoot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.userbox { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 6px 8px; border-radius: var(--radius); cursor: pointer; text-align: start; color: var(--ink); width: 100%; font-weight: 400; }
.userbox:hover { background: var(--chip); }
.userbox .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-2); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex: none; }
.userbox b { display: block; font-size: 13px; font-weight: 500; line-height: 1.2; } .userbox small { color: var(--muted); font-size: 12px; }
.linkbtn { background: none; border: 1px solid var(--line); color: var(--ink-2); padding: 5px 10px; border-radius: var(--radius); font-size: 12px; font-weight: 400; cursor: pointer; text-align: start; }
.linkbtn:hover { background: var(--chip); } .linkbtn:disabled { color: var(--ok); border-color: transparent; cursor: default; background: none; opacity: 1; }
main { padding: 24px 32px 80px; max-width: 1280px; width: 100%; }
body.authpage .app { grid-template-columns: 1fr; } body.authpage .side { display: none; }
body.authpage main { max-width: none; }

/* ---------- type ---------- */
h1 { font-size: 24px; font-weight: 600; margin: 4px 0 18px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 22px 0 10px; }
h3 { font-size: 14px; font-weight: 600; margin: 14px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
td.ltr, .ltr { direction: ltr; unicode-bidi: embed; text-align: left; }
main > .row:first-child { font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* ---------- cards, layout ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel > h2:first-child { margin-top: 0; }
.panel.hl { border-color: var(--accent-line); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.grid2 label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.scroll { max-height: 340px; overflow: auto; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- controls ---------- */
input[type=text], input[type=email], input[type=password], select, textarea {
  padding: 8px 11px; border: 1px solid var(--line-2); border-radius: var(--radius); font: inherit; font-size: 14px; background: #fff; color: var(--ink); min-width: 240px; }
select { min-width: 0; padding: 7px 9px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
input.num { width: 76px; min-width: 0; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px; font-size: 13px; direction: ltr; }
button, .btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: var(--radius); padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1.3; }
button:hover, .btn:hover { background: var(--accent-2); text-decoration: none; }
button.secondary, .btn.secondary { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
button.secondary:hover, .btn.secondary:hover { background: var(--chip); }
button.danger { color: var(--err); border-color: var(--err-line); background: #fff; } button.danger:hover { background: var(--err-bg); }
button:disabled { opacity: .45; cursor: default; }
button.tiny { padding: 0 6px; font-size: 11px; }
.tabs { display: inline-flex; background: var(--chip); border-radius: var(--radius); padding: 3px; gap: 2px; }
.tabs button { background: none; border: 0; color: var(--ink-2); padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.tabs button:hover { background: rgba(255, 255, 255, .6); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
#imgtabs button { padding: 5px 10px; font-size: 13px; background: #fff; color: var(--ink-2); border-color: var(--line-2); }
#imgtabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
table tr:hover td { background: #fafbfc; }
tr.old td { opacity: .5; }
.ztab td { font-size: 13px; } .ztab tr.out td { color: var(--faint); }
table.rules td { vertical-align: top; padding: 10px 6px; } table.rules td:first-child { width: 34%; }

/* ---------- chips and states ---------- */
.chip, .badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--chip); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge { background: var(--warn-fill); color: #fff; padding: 0 7px; min-width: 18px; justify-content: center; }
.badge.bbadge { background: var(--ok-fill); } .badge.bbadge.neg { background: var(--err-fill); }   /* the credits (billing.js) */
.paywarn { display: block; margin: 2px 10px 6px; padding: 6px 10px; border-radius: 6px; font-size: 12px; background: var(--err-fill); color: #fff; text-decoration: none; }   /* payment needed (billing.js) */
body:not([data-billing="meter"]):not([data-billing="enforce"]) .billnav { display: none !important; }
.st-extracted, .st-approved { background: var(--ok-bg); color: var(--ok); }
.st-failed, .st-extract_failed { background: var(--err-bg); color: var(--err); }
.st-extracting, .st-uploaded { background: var(--warn-bg); color: var(--warn); }
.st-understood { background: var(--accent-bg); color: var(--accent-2); }
.st-duplicate, .st-skipped, .st-unpacked { background: var(--chip); color: var(--muted); }

/* ---------- the legend of colors (instead of words) ---------- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: 1px; margin-inline-start: 5px; cursor: help; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); align-items: center; margin: 6px 0 10px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-inline-end: 5px; border: 1px solid rgba(0, 0, 0, .1); }
.legend .dot { margin: 0 0 0 5px; cursor: default; }
.legend .sw.in { opacity: .65; border: 1.5px solid #111; }
.legend .sw.out { background: repeating-linear-gradient(45deg, #6b7280 0 1px, #fff 1px 4px); border: 1px dashed #6b7280; }
.uimgwrap { position: relative; margin-top: 10px; }
.uimgwrap .busy { position: absolute; top: 8px; inset-inline-start: 8px; background: rgba(255, 255, 255, .9); border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; font-size: 12px; color: var(--muted); }
.src-ext { background: var(--ok-fill); } .src-mea, .src-com { background: var(--accent); }
.src-ass { background: var(--warn-fill); } .src-cor { background: var(--pro-fill); }
/* the parallel reading: a ring next to the source dot (agent.parallel_read) */
.cert { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: 1px; margin-inline-start: 3px; cursor: help; border: 2px solid; box-sizing: border-box; }
.legend .cert { margin: 0 0 0 5px; cursor: default; }
.cert-ok { border-color: #16a34a; } .cert-fix { border-color: #2563eb; background: #2563eb33; cursor: pointer; }
.cert-dis { border-color: #ea580c; background: #ea580c33; cursor: pointer; } .cert-note { border-color: #9ca3af; cursor: pointer; }

/* ---------- the path of a project ---------- */
.steps { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.steps .step { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 10px; border-radius: 999px; color: var(--muted); border: 1px solid var(--line); background: #fff; font-size: 13px; text-decoration: none; }
.steps .step .n { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; font-size: 11px; background: var(--chip); color: var(--ink-2); font-weight: 600; }
.steps .step.done { color: var(--ok); border-color: #bbf7d0; }
.steps .step.done .n { background: var(--ok-fill); color: #fff; }
.steps .step.current { color: var(--accent-2); font-weight: 600; border-color: var(--accent-line); background: var(--accent-bg); }
.steps .step.current .n { background: var(--accent); color: #fff; }
.steps .step.here { box-shadow: 0 0 0 2px var(--accent); }      /* the page open now (it may be other than the project's step) */
.steps .sep { width: 14px; height: 1px; background: var(--line-2); }
.msteps { display: flex; gap: 3px; }
.msteps .ms { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.msteps .ms.done { background: var(--ok-fill); } .msteps .ms.current { background: var(--accent); }
.pbar { height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; margin-top: 6px; min-width: 200px; }
.pbar > div { height: 100%; background: var(--accent); transition: width .4s; }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.dcard { margin: 0; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s; }
.dcard:hover { border-color: var(--line-2); }
.dname { font-size: 16px; font-weight: 600; color: var(--ink); text-decoration: none; }

/* ---------- numbers ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.stats div { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stats b { display: block; font-size: 22px; font-weight: 600; line-height: 1.2; } .stats span { color: var(--muted); font-size: 12px; }
.stats .good { color: var(--ok); } .stats .bad { color: var(--err); }

/* ---------- notes ---------- */
.warnbox { border-color: var(--warn-line) !important; background: var(--warn-bg) !important; }
.assum { border: 1px solid var(--warn-line); border-inline-start: 4px solid var(--warn-fill); background: var(--warn-bg); padding: 10px 12px; margin-bottom: 8px; border-radius: var(--radius); }
.assum.high { border-inline-start-color: var(--err-fill); background: #fff7f5; border-color: var(--err-line); }
details { margin: 8px 0; } details summary { cursor: pointer; }

/* ---------- upload, cards of drawings, log ---------- */
.drop { border: 2px dashed var(--line-2); border-radius: var(--radius-lg); padding: 28px; text-align: center; color: var(--muted); background: var(--panel-2); }
.drop.over { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; box-shadow: var(--shadow); }
.card:hover { border-color: var(--line-2); }
.card img { width: 100%; height: 180px; object-fit: contain; background: #fff; border-bottom: 1px solid var(--line); }
.card .t { padding: 9px 12px; font-size: 13px; }
.card .t b { display: block; direction: ltr; text-align: left; word-break: break-all; font-weight: 500; }
.log { background: #0f172a; color: #cbd5e1; border-radius: var(--radius); padding: 10px 12px; height: 220px; overflow: auto; font: 12.5px/1.6 Consolas, "Cascadia Mono", monospace; }
.log div { unicode-bidi: plaintext; text-align: start; }
.log .error { color: #fca5a5; } .log .warn { color: #fcd34d; } .log .done { color: #86efac; } .log .user { color: #93c5fd; }

/* ---------- the approval bar ---------- */
.approvebar { position: sticky; bottom: 12px; background: #fff; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); padding: 12px 16px; border-radius: var(--radius-lg);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.approvebar button:not(.secondary) { background: var(--ok-fill); border-color: var(--ok-fill); } .approvebar button:not(.secondary):hover { background: var(--ok); }

/* ---------- sheets ---------- */
.settings { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.settings label { display: inline-flex; flex-direction: column; gap: 2px; margin-inline-end: 10px; font-size: 12px; color: var(--muted); }
.settings select, .settings input[type=text] { padding: 4px 6px; font-size: 13px; min-width: 0; }

/* ---------- dialogs, toasts ---------- */
.modal { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 40px 12px; z-index: 20; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: var(--radius-lg); max-width: 1100px; width: 100%; padding: 22px; position: relative; box-shadow: 0 20px 50px rgba(16, 24, 40, .2); }
.modal-box .close { position: absolute; inset-inline-end: 12px; top: 12px; background: transparent; color: var(--muted); border: 0; font-size: 18px; }
.modal-box img { max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); }
.modal-box label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; }
.toasts { position: fixed; bottom: 18px; inset-inline-end: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: 380px; }
.toast { background: #111827; color: #fff; padding: 11px 14px; border-radius: var(--radius); box-shadow: 0 10px 30px rgba(16, 24, 40, .25); cursor: pointer; font-size: 13px; }
.toast.error { background: var(--err); } .toast b { display: block; font-weight: 600; }

/* ---------- sign-in ---------- */
.authbox { max-width: 400px; margin: 9vh auto; display: flex; flex-direction: column; gap: 12px; padding: 28px; }
.authbox h1 { margin: 0 0 4px; }
.authbox label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); }
.authbox input { min-width: 0; width: 100%; }
.authbox button { justify-content: center; padding: 10px; }
.authlogo { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-weight: 700; }
.authlogo .mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }

/* ---------- who may do what: hidden for whom the server would refuse anyway ---------- */
body[data-prole="viewer"] .ed { display: none !important; }
/* a paid run (owner 20.10.2026): shown only to a planner / administrator of the project - the server refuses the rest */
body[data-prole="viewer"] .paid, body[data-prole="editor"] .paid { display: none !important; }
/* the account's plan, top-ups and invoices: its administrator only */
body:not([data-orole="admin"]) .payadm, body[data-oonly="1"] .payadm { display: none !important; }
body:not([data-sysadm="1"]) .sysadm { display: none !important; }
body[data-prole="viewer"] .ztab input, body[data-prole="viewer"] .ztab select { pointer-events: none; opacity: .7; }
body:not([data-orole="admin"]) .adm { display: none !important; }
body:not([data-prole="admin"]) .pad { display: none !important; }
body[data-orole="viewer"] .eng-org, body[data-oonly="1"] .eng-org { display: none !important; }

/* ---------- narrow screens: the menu on top ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 8px 10px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .side .brand { padding: 0 6px 0 12px; } .side .brand div { display: none; }
  .side nav { flex-direction: row; } .side .navsep { display: none; }
  .side .sidefoot { margin: 0 auto 0 0; flex-direction: row; border: 0; padding: 0; }
  .userbox span:not(.avatar) { display: none; } #bell { display: none !important; }
  main { padding: 16px 14px 70px; }
  .cols { grid-template-columns: 1fr; }
  input[type=text], input[type=email], input[type=password] { min-width: 0; width: 100%; }
}

/* the questions of the reading */
.qcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; margin-top: 8px; }
.qcard { border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.qcard.done { border-color: var(--line); background: var(--panel-2); }
.qcard button { padding: 6px 11px; font-size: 13px; }
/* a card that helps to decide (questions stage 2): pictures, what is known, a recommendation, a picture per option */
.sqcards, #qpanel .qcards { grid-template-columns: repeat(auto-fill, minmax(min(460px, 100%), 1fr)); }
.qpics { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; align-items: start; }
.qpics figure { margin: 0; display: flex; flex-direction: column; gap: 3px; }
.qpics figure.big { grid-row: span 3; }
.qpics img { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: block; }
.qpics figure:not(.big) img { max-height: 170px; object-fit: contain; }
.qev { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.qev ul { margin: 4px 0 0; padding-inline-start: 18px; }
.qrec { border: 1px solid var(--accent-line); border-radius: 6px; padding: 6px 10px; display: flex; flex-direction: column; gap: 4px; background: var(--accent-bg); }
.qrec button { margin-inline-start: 6px; padding: 3px 9px; }
.qoptions { align-items: flex-end; flex-wrap: wrap; }
.qopt { display: inline-flex; flex-direction: column; gap: 4px; align-items: stretch; }
.qopt-pic { width: 150px; height: 150px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.qinputs label { display: inline-flex; align-items: center; gap: 4px; }
dialog.qlist { max-width: min(900px, 94vw); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
dialog.qlist::backdrop { background: rgba(17, 24, 39, .35); }
dialog.qlist td { vertical-align: top; }
@media (max-width: 600px) { .qpics { grid-template-columns: 1fr; } .qpics figure.big { grid-row: auto; } }

/* the layout alternatives of a sheet (sheets.js altView): the engine's pictures use these colours */
.altv { --zone: #e7e5e4; --zone-edge: #a8a29e; --tower: #1d4ed8; --ul: #0f766e; --lig: #a8a29e; --var: #9333ea; --prop: #c2410c; --open: #dc2626; }
.altv-tabs { margin-bottom: 6px; }
.altv-main { display: flex; align-items: center; gap: 8px; }
.altv-pic { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fafaf9; display: flex; justify-content: center; min-height: 200px; }
.altv-pic svg { width: 100%; max-height: 52vh; height: auto; }
.altv-nav { font-size: 26px; line-height: 1; padding: 10px 14px; }
.altv-info { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-top: 8px; }
.altv-strip { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; }
.altv-thumb { flex: 0 0 auto; width: 104px; padding: 3px; background: #fff; border: 1px solid var(--line); border-radius: 6px; color: var(--ink-2); font-size: 11px; font-weight: 400; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.altv-thumb svg { width: 100%; height: 70px; }
.altv-thumb.bad { opacity: .6; }
.altv-thumb.win { border-color: var(--ok); }
.altv-thumb.on { border: 2px solid var(--ink); opacity: 1; }
.altv .legend span { display: inline-block; margin-inline-end: 14px; }
.altv .legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-inline-end: 4px; }

/* ---------- "Model from plans" (model.js): the steps, the limits line, the 3D view ---------- */
.steps .step.failed { color: var(--err); border-color: var(--err-line); background: var(--err-bg); }
.steps .step.failed .n { background: var(--err-fill); color: #fff; }
.msteps .ms.failed { background: var(--err-fill); }
.mlimits { margin: 6px 0 16px; padding-inline-start: 9px; border-inline-start: 3px solid var(--line-2); }
.msw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-inline-end: 5px; vertical-align: 0; }
.legend .m3k { background: #fff; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 400; gap: 0; }
.legend .m3k:hover { background: var(--chip); }
.legend .m3k[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.m3lv { gap: 4px 14px; margin-bottom: 8px; }
.m3lv label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.m3wrap { position: relative; height: min(64vh, 620px); min-height: 320px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #f8fafc; touch-action: none; }
.m3wrap:fullscreen { height: 100vh; border-radius: 0; border: 0; }
.m3wrap canvas { display: block; width: 100%; height: 100%; outline: none; }
.m3msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.m3info { position: absolute; top: 10px; inset-inline-start: 10px; width: 270px; max-width: calc(100% - 20px); max-height: calc(100% - 20px); overflow: auto;
  background: rgba(255, 255, 255, .96); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; }
.m3info table td { padding: 3px 4px; border: 0; } .m3info table tr:hover td { background: none; }
.m3info .m3as { margin: 4px 0; }
.m3id { cursor: pointer; }
.mscroll { overflow-x: auto; contain: inline-size; }        /* a wide table scrolls inside, never widens the page */
#mres .stats { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
#mres .qcards, #mdash .dash { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
@media (max-width: 900px) {
  .m3wrap { height: 56vh; min-height: 280px; }
  .m3info { width: auto; inset-inline-end: 10px; top: auto; bottom: 10px; max-height: 45%; }
}

/* ---------- "Model from plans": the gaps (model.js mDrawGaps) and their highlight in the 3D view ---------- */
.gstats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gstats div { padding: 8px 12px; } .gstats b { font-size: 18px; }
.gbusy { display: flex; align-items: center; gap: 6px; padding: 8px 12px; margin-bottom: 10px; border-radius: var(--radius); background: var(--accent-bg); color: var(--accent-2); }
.gbusy .ti { animation: gspin 1s linear infinite; }
@keyframes gspin { to { transform: rotate(360deg); } }
.gtype { margin: 10px 0 6px; font-weight: 500; }
.gcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 10px; }
.gimg { width: 100%; max-height: 320px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.gimpact bdi { font-weight: 600; }
.gai { background: var(--accent-bg); border: 1px solid var(--accent-line); border-radius: 6px; padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gcard { border: 1px solid var(--line); border-inline-start: 4px solid var(--line-2); border-radius: var(--radius); padding: 10px 12px; background: #fff; display: flex; flex-direction: column; gap: 6px; transition: box-shadow .3s; }
.gcard.g-open { border-inline-start-color: var(--warn-fill); background: var(--warn-bg); border-color: var(--warn-line); }
.gcard.g-provisional { border-inline-start-color: var(--accent); background: var(--accent-bg); border-color: var(--accent-line); }
.gcard.g-auto, .gcard.g-closed { border-inline-start-color: var(--ok-fill); background: var(--panel-2); }
.gcard.flash { box-shadow: 0 0 0 3px var(--warn-fill); }
.gcard .gsrc { margin: 0; padding-inline-start: 18px; }
.gcard .gopts button, .gcard .ginput button { padding: 5px 10px; font-size: 13px; }
.gcard .ginput { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; margin-top: 4px; }
.gcard .ginput textarea { flex: 1; min-width: 0; font-size: 13px; }
.gcard details summary { color: var(--accent); }
.legend .m3gap .sw { background: #facc15; border-color: #ca8a04; }
.legend .sw.m3prov { background: #94a3b8; opacity: .45; }
@media (max-width: 900px) { .gstats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.m3wrap.m3zoom { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
/* the 3D view's tools (stage 1 of the viewer round, 15.10.2026): views, plan of a level, the cuts, the view cube */
.m3box:fullscreen { background: var(--panel); padding: 12px 16px; overflow: auto; display: flex; flex-direction: column; border-radius: 0; margin: 0; }
.m3box:fullscreen .m3wrap { flex: 1 1 auto; height: auto; min-height: 320px; }
.m3bar { gap: 6px 18px; align-items: center; margin-bottom: 8px; }
.m3bar label { display: inline-flex; align-items: center; gap: 5px; }
.m3bar select { width: auto; padding: 3px 8px; font-size: 12.5px; }
.m3cut { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); padding: 8px 10px; margin-bottom: 8px; }
.m3cutrow { display: grid; grid-template-columns: 90px auto minmax(80px, 1fr) 70px auto minmax(80px, 1fr) 70px; gap: 6px 10px; align-items: center; margin-bottom: 6px; }
.m3cutrow .m3ax { font-weight: 600; color: var(--ink-2); }
.m3cutrow input[type="range"] { width: 100%; margin: 0; }
.m3cutrow input[type="range"]:disabled { opacity: .35; }
.m3cutc { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.m3cutv { font-variant-numeric: tabular-nums; color: var(--muted); }
.m3wrap canvas.m3cube { position: absolute; top: 8px; left: 8px; width: 96px; height: 96px; cursor: pointer; }
.m3tools { gap: 4px; flex-wrap: wrap; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.m3tools button[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent-line); }
@media (max-width: 900px) {
  .m3cutrow { grid-template-columns: auto minmax(60px, 1fr) 62px; }
  .m3cutrow .m3ax { grid-column: 1 / -1; }
  .m3wrap canvas.m3cube { width: 72px; height: 72px; }
}
/* stage 2 of the viewer (15.10.2026): the filter, the colour legend, the tree and the table of the elements */
.m3fsize { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px 14px; margin-bottom: 8px; }
.m3fsize label { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.m3fsize input.num { width: 64px; padding: 3px 6px; }
.m3fstate { gap: 4px 14px; margin-bottom: 8px; }
.m3fstate label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.m3fstate .sw, .m3cleg .sw, .m3tk .sw, #m3list .legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-inline-end: 4px; vertical-align: -1px; }
.m3flt select { width: auto; max-width: 320px; padding: 3px 8px; font-size: 12.5px; }
.m3bar button.m3on { background: var(--accent-bg); border-color: var(--accent-line); color: var(--accent); }
.m3cleg { margin: 0 0 8px; }
#m3q { width: min(320px, 60vw); }
.m3list { max-height: 520px; overflow: auto; margin-top: 8px; }
.m3list details summary { cursor: pointer; padding: 4px 0; }
.m3tl { border-bottom: 1px solid var(--line); padding: 2px 0 6px; }
.m3tk { margin-inline-start: 18px; }
.m3te { margin-inline-start: 22px; font-size: 12.5px; columns: 2 300px; column-gap: 24px; }
.m3te > div { padding: 2px 0; break-inside: avoid; }
.m3st { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-inline-start: 4px; vertical-align: 1px; }
.m3tab th a { cursor: pointer; color: inherit; white-space: nowrap; }
.m3tab tfoot td { border-top: 2px solid var(--line-2); }
/* stage 3 of the viewer (15.10.2026): layers, measuring, saved views, notes */
.m3sep { flex: 0 0 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.m3labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.m3lbl { position: absolute; transform: translate(-50%, -130%); background: #fff; border: 1.5px solid #ea580c; color: #7c2d12; border-radius: 6px; padding: 1px 7px; font-size: 12px; white-space: nowrap; box-shadow: var(--shadow); }
.m3wrap.m3measuring canvas:first-child { cursor: crosshair; }
.m3mres { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; }
.m3mitem { color: #9a3412; }
.m3vlist { margin-top: 6px; }
.m3vrow { gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); align-items: center; }
.m3vrow:last-child { border-bottom: 0; }
.m3views input[type="text"], #m3vname { width: min(300px, 60vw); }
.m3notes { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.m3notes textarea { width: 100%; margin: 6px 0 4px; font-size: 12.5px; }
.m3note { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.m3ntext { white-space: pre-wrap; }
.m3nicon { color: #2563eb; font-size: 13px; vertical-align: -1px; }
#m3list h3 { margin: 10px 0 4px; }
/* compare to the drawing, quantities (15.10.2026) */
.m3cmp { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
  background: rgba(255, 255, 255, .96); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 12px; max-width: calc(100% - 20px); }
.m3cmp label { display: inline-flex; align-items: center; gap: 4px; }
.m3cmp input[type="range"] { width: 110px; }
.m3qtot { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 4px 0 10px; }
.m3qtot > div { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.m3qtot b { display: block; font-size: 18px; }
.m3qtot span { color: var(--muted); font-size: 12px; }
.m3tab tr.m3sub td { background: var(--panel-2); }
.m3tab .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 4px; }
.m3qsel td { padding: 2px 4px; border: 0; }
.m3cmp[hidden], .m3cleg[hidden], .m3wrap [hidden] { display: none; }

/* the products of the company (owner 16.10.2026): a tab of a product it does not have is not shown */
body:not([data-pmodel="1"]) [data-nav="m"] { display: none !important; }

/* the products inside a project (owner 16.10.2026): a tab per product the company has */
.tabs.ptabs { margin: 0 0 12px; }
.tabs.ptabs a { padding: 6px 16px; font-size: 14px; border-radius: 6px; color: var(--ink-2); text-decoration: none; }
.tabs.ptabs a.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.dmodel { margin-top: 4px; }

/* the legal documents (learning.js): drafts until a lawyer approves them */
.legaldoc { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.legaldoc summary { cursor: pointer; font-weight: 600; }
.legaltext { max-height: 260px; overflow: auto; font-size: 13px; line-height: 1.6; }
.legaltext h3 { margin: 6px 0; font-size: 15px; }
.legaltext .draft { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 6px; padding: 4px 8px; font-weight: 600; }
label.pick, .authbox label.pick, .modal-box label.pick { display: flex; flex-direction: row; align-items: flex-start; justify-content: flex-start; gap: 8px; text-align: start; margin: 4px 0; }
label.pick input { width: auto; min-width: 0; margin: 3px 0 0; flex: none; }

/* the system's console (admin.js): its own menu in the side bar, for the system's staff only */
body:not([data-staff="1"]) .staffnav { display: none !important; }
#adminnav { display: none; }
body[data-console="1"] #mainnav { display: none; }
body[data-console="1"] #adminnav { display: block; }
#adminnav .back { opacity: .8; }
.admtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.admtile { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.admtile b { font-size: 26px; }
.admtile span { font-size: 13px; color: var(--ink-2); }
.nowrap { white-space: nowrap; }
