:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #5b6676;
  --line: #dde2ea;
  --brand: #1f4e78;
  --ok: #1e7b3a;
  --bad: #b42318;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Cairo", "Noto Naskh Arabic", Tahoma, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  direction: rtl;
}
a { color: var(--brand); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--brand); color: #fff; flex-wrap: wrap;
}
.topbar a, .topbar .linkbtn { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 18px; }
.topnav { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.topnav form { margin: 0; }
.linkbtn { background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }
.page { max-width: 960px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 20px 0 10px; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; text-decoration: none; color: var(--ink);
}
.card strong { display: block; font-size: 17px; color: var(--brand); }
.card span { color: var(--muted); font-size: 14px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.msg { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; background: #e8f1fb; }
.msg-success { background: #e6f4ea; color: var(--ok); }
.msg-error { background: #fdecea; color: var(--bad); }
form p, .field { margin: 0 0 14px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; font: inherit; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.helptext, .help { display: block; color: var(--muted); font-size: 13px; }
.errorlist { color: var(--bad); margin: 4px 0; padding: 0; list-style: none; font-size: 14px; }
.btn {
  display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-light { background: #e8eef5; color: var(--brand); }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: start; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { background: #eef2f7; white-space: nowrap; }
.tag { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; background: #eef2f7; }
.tag-off { background: #fdecea; color: var(--bad); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.caps fieldset, .caps > div > div { border: 0; padding: 0; margin: 0 0 10px; }
.caps label { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.muted { color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { width: auto; min-width: 160px; }
.login { max-width: 380px; margin: 40px auto; }
pre.changes { white-space: pre-wrap; direction: ltr; text-align: left; margin: 0; font-size: 12px; }
.log { display: grid; gap: 10px; }
.log-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.log-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
ul.changes { margin: 6px 0 0; padding-inline-start: 18px; }
a.order-row { display: block; text-decoration: none; color: var(--ink); }
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: #eef2f7; white-space: nowrap; }
.st-draft { background: #f1ecfa; color: #5b3d8f; }
.st-pending { background: #fde8d8; color: #9a3c00; }
.st-open { background: #e8f1fb; color: #1f4e78; }
.st-received { background: #fff4e0; color: #8a5300; }
.st-in_progress { background: #fff1c2; color: #6b5200; }
.st-finished { background: #e6f4ea; color: #1e7b3a; }
.st-delivered { background: #d7efdf; color: #14572a; }
.st-closed { background: #e3e6ea; color: #3b4450; }
.st-cancelled { background: #fdecea; color: var(--bad); }
.tag-high { background: #fff4e0; color: #8a5300; }
.tag-urgent { background: #fdecea; color: var(--bad); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.btn-danger { background: var(--bad); }
details.danger summary { cursor: pointer; color: var(--bad); font-weight: 600; }
.filters input[type=text] { width: auto; flex: 1 1 200px; }
.label { display: flex; gap: 14px; align-items: center; background: #fff; border: 1px dashed var(--line); border-radius: 8px; padding: 10px; width: max-content; max-width: 100%; }
.label-qr svg { display: block; }
.label-code { font-size: 26px; font-weight: 700; letter-spacing: 1px; }
@media print {
  .topbar, .no-print, .msg { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; }
  .label { border: 0; }
}

/* Customers (Q30) */
.stars { color: #b7791f; white-space: nowrap; }
.score-pick { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.score-pick label { display: inline-flex; align-items: center; gap: 4px; font-size: 1.1rem; }
.hint { display: block; margin-top: 4px; color: #2f6f3e; }

/* Order stages (Q64) */
.stage-row { border-top: 1px solid #e5e9f0; padding: 10px 0; }
.stage-row:first-of-type { border-top: 0; }
.sg-waiting { background: #eef2f7; color: #5a6270; }
.sg-ready { background: #e8f1fb; color: #1f4e78; }
.sg-in_progress { background: #fff1c2; color: #6b5200; }
.sg-done { background: #e6f4ea; color: #1e7b3a; }
.sg-inspection { background: #f3e8fb; color: #5b2a86; }
.bar { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; margin: 6px 0 2px; }
.bar span { display: block; height: 100%; background: #2e8b57; }
.tasks { list-style: none; padding: 0; margin: 6px 0; }
.tasks li { margin: 4px 0; }
.task-btn { background: none; border: 1px solid #dde3ea; border-radius: 8px; padding: 8px 10px; width: 100%; text-align: start; font: inherit; cursor: pointer; min-height: 44px; }
.task-btn.done, .tasks .done { color: #1e7b3a; }

/* Requested items and their questions (Q68) */
.item-box { border: 1px solid #e5e9f0; border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.item-tick { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.item-tick input { width: 22px; height: 22px; }
.item-questions { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e5e9f0; }
fieldset.choices { border: 0; padding: 0; margin: 0; }
fieldset.choices legend { font-weight: 600; margin-bottom: 4px; }
.choice { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.choice input { width: 20px; height: 20px; }
.other-box { margin-top: 4px; }
.answers dt { color: #5a6270; }

/* Question types (Q69) */
fieldset.scale { display: flex; flex-wrap: wrap; gap: 4px 14px; }
fieldset.scale legend { width: 100%; }
input[type=time], input[type=month] { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ccd3dc; border-radius: 8px; font: inherit; }
.hint.warn { color: #9a5b00; }

/* Work logs (Q73) */
.work-logs, .work-form { margin-top: 8px; }
.work-logs summary, .work-form summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: #1f4e78; }
fieldset.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0 10px; }
fieldset.people legend { grid-column: 1 / -1; }
.inline-cancel { display: inline-block; margin-inline-start: 6px; }
.inline-cancel summary { color: #b42318; font-size: 13px; cursor: pointer; }
.inline-cancel form { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* Attendance (Q75) */
.att-row.needs { border-inline-start: 4px solid #b42318; }
.changes.flags li { color: #b42318; }
.row-flag td { background: #fdecea; }
.btn-big { width: 100%; min-height: 52px; font-size: 18px; }

/* Notifications (Q77) */
.bell .count { background: #b42318; color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.note-row { display: flex; justify-content: space-between; gap: 10px; padding: 12px 4px; border-bottom: 1px solid #e5e9f0; color: inherit; text-decoration: none; min-height: 44px; flex-wrap: wrap; }
.note-row.unread span { font-weight: 700; }
.changes li.far { color: #b42318; font-weight: 600; }
.check-buttons form { flex: 1 1 140px; }

/* Org chart (Q79) */
.tree { list-style: none; margin: 0; padding-inline-start: 18px; border-inline-start: 2px solid #e5e9f0; }
.tree.root { padding-inline-start: 0; border: 0; }
.tree li { padding: 6px 0; }
.section-card { border-inline-start: 4px solid #1f4e78; }
.section-card .muted { display: block; margin-top: 4px; font-size: 13px; }

/* Payroll month (Q93) */
.table.payroll { font-size: 13px; white-space: nowrap; }
.table.payroll th, .table.payroll td { padding: 6px 8px; }
.slip-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 12px 0; }
.signatures { display: flex; justify-content: space-between; margin-top: 48px; gap: 24px; }
.signatures div { flex: 1; border-top: 1px solid #333; padding-top: 6px; text-align: center; }
@media print { .topbar, .no-print, .msg { display: none !important; } body { background: #fff; } .page { padding: 0; } }

/* Intake and delivery reports (Q95) */
.handover input:not([type=radio]):not([type=file]), .handover textarea { width: 100%; }
.choices { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0; }
.choices label { white-space: nowrap; }
.sign canvas { width: 100%; max-width: 420px; height: auto; aspect-ratio: 320 / 140; border: 1px dashed #9aa5b5;
  border-radius: 8px; background: #fff; touch-action: none; display: block; }
.thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; margin: 4px; }
.signs { display: flex; flex-wrap: wrap; gap: 16px; }
.signs img { max-width: 260px; width: 100%; border: 1px solid #e5e9f0; border-radius: 8px; background: #fff; }

/* Back link (Q99-2) */
.back-link { display: inline-block; margin-bottom: 10px; padding: 6px 0; color: var(--brand); font-weight: 600; text-decoration: none; }

/* Q106: the item list under the search box */
.suggest { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line, #ddd); border-radius: 8px; max-height: 50vh; overflow-y: auto; }
.suggest li { border-bottom: 1px solid var(--line, #eee); }
.suggest li:last-child { border-bottom: 0; }
.suggest li.muted { padding: 10px 12px; }
.suggest button { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 12px; font: inherit; color: inherit; cursor: pointer; }
.suggest button:hover, .suggest button:focus { background: rgba(0, 0, 0, .05); }
