:root {
  --indigo: #2e2c78; --indigo-2: #3d3b95; --deep: #1f1d5c; --ink: #14133a;
  --sign: #ffc93c; --gold: #c9971a; --paper: #f3f2ec; --paper-2: #faf9f5; --card: #ffffff;
  --line: #e0ded4; --line-2: #cfccbf; --muted: #5f5e78;
  --ok: #1e7f55; --ok-bg: #e4f4ec; --warn: #9a6a00; --warn-bg: #fff4d6; --bad: #b3261e; --bad-bg: #fde8e6;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 19, 58, .06), 0 6px 20px rgba(20, 19, 58, .06);
  --font: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root.auto-dark { --paper: #15142e; --paper-2: #1b1a3a; --card: #222148; --ink: #f1f0fa; --line: #35346a; --line-2: #45447f; --muted: #aeadd0; --ok-bg: #123a2b; --warn-bg: #3b2e0a; --bad-bg: #4a1613; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--paper); color: var(--ink); font-size: 17px; line-height: 1.7; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--indigo-2); }
[hidden] { display: none !important; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1280px; }

/* رأس الصفحة */
.top { background: var(--indigo); color: #fff; border-bottom: 4px solid var(--sign); }
.top .wrap { display: flex; align-items: center; gap: 14px; padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand img { height: 46px; width: auto; background: #fff; border-radius: 10px; padding: 4px; }
.brand .mark { width: 46px; height: 46px; border-radius: 12px; background: var(--sign); color: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: .5px; }
.brand b { font-size: 21px; display: block; line-height: 1.2; }
.brand small { opacity: .85; font-size: 14px; }
.top .grow { flex: 1; }
.top .who { font-size: 14px; opacity: .9; }

/* بطاقات وحقول */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
h1 { font-size: 26px; margin: 8px 0 4px; line-height: 1.4; }
h2 { font-size: 21px; margin: 0 0 10px; }
h3 { font-size: 17px; margin: 18px 0 8px; color: var(--indigo); }
.lead { color: var(--muted); margin: 0 0 12px; }
.field { margin-bottom: 18px; }
.field > label, .field > .lbl { display: flex; gap: 8px; align-items: baseline; font-weight: 700; margin-bottom: 6px; flex-wrap: wrap; }
.req { color: var(--bad); }
.opt { color: var(--muted); font-weight: 400; font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 4px; }
.err-msg { color: var(--bad); font-size: 15px; margin-top: 4px; font-weight: 600; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea {
  width: 100%; min-height: 52px; padding: 10px 14px; border: 2px solid var(--line-2); border-radius: 12px; background: var(--paper-2); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--indigo-2); box-shadow: 0 0 0 4px rgba(61, 59, 149, .18); }
input:disabled { background: #ece9dc; color: var(--muted); }
.invalid input, .invalid select, .invalid textarea, .invalid .chips { border-color: var(--bad); }
.invalid .chips { outline: 2px solid var(--bad); outline-offset: 4px; border-radius: 12px; }
.phone-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; direction: rtl; }
.phone-row input { direction: ltr; text-align: right; }
.ltr { direction: ltr; unicode-bidi: plaintext; }

/* خيارات كبيرة */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { min-height: 52px; padding: 8px 18px; border-radius: 12px; border: 2px solid var(--line-2); background: var(--paper-2); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.chip[aria-pressed=true] { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.chip:focus-visible, .btn:focus-visible, .tile:focus-visible { outline: 4px solid rgba(61, 59, 149, .4); outline-offset: 2px; }
.unk { margin-top: 8px; background: none; border: 1px dashed var(--line-2); border-radius: 999px; padding: 4px 14px; min-height: 40px; cursor: pointer; color: var(--muted); font-size: 15px; }
.unk[aria-pressed=true] { background: var(--warn-bg); border-color: var(--gold); color: var(--warn); font-weight: 700; }

/* أزرار */
.btn { min-height: 54px; padding: 10px 26px; border-radius: 12px; border: 2px solid transparent; font-weight: 800; cursor: pointer; font-size: 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: transform .1s, background .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-2); }
.btn-sign { background: var(--sign); color: var(--ink); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-sm { min-height: 40px; padding: 4px 14px; font-size: 15px; border-radius: 10px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.actions .grow { flex: 1; }

/* خطوات التقدم */
.steps { display: flex; gap: 6px; margin: 18px 0 8px; padding: 0; list-style: none; }
.steps li { flex: 1; text-align: center; font-size: 14px; color: var(--muted); position: relative; padding-top: 34px; }
.steps li::before { content: attr(data-n); position: absolute; top: 0; inset-inline: 0; margin-inline: auto; width: 30px; height: 30px; border-radius: 50%; background: var(--line); color: var(--muted); display: grid; place-items: center; font-weight: 800; }
.steps li.done::before { content: "✓"; background: var(--ok); color: #fff; }
.steps li.cur::before { background: var(--indigo); color: #fff; box-shadow: 0 0 0 4px rgba(61, 59, 149, .2); }
.steps li.cur { color: var(--ink); font-weight: 800; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.bar > i { display: block; height: 100%; background: var(--sign); transition: width .3s; }

/* بلاطات الخدمات */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tile { text-align: right; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer; display: flex; gap: 14px; align-items: center; min-height: 96px; box-shadow: var(--shadow); transition: transform .12s, border-color .15s; }
.tile:hover { border-color: var(--indigo-2); transform: translateY(-2px); }
.tile[aria-pressed=true] { border-color: var(--indigo); background: #eceafc; }
.tile .ic { font-size: 34px; flex: none; }
.tile b { display: block; font-size: 18px; line-height: 1.4; }
.tile small { color: var(--muted); font-size: 14px; display: block; line-height: 1.5; }

/* تنبيهات */
.notice { padding: 12px 16px; border-radius: 12px; border: 1px solid; margin: 12px 0; font-size: 16px; }
.notice.warn { background: var(--warn-bg); border-color: #e8c76a; color: var(--warn); }
.notice.bad { background: var(--bad-bg); border-color: #efb1ac; color: var(--bad); }
.notice.ok { background: var(--ok-bg); border-color: #a9d9c1; color: var(--ok); }
.notice.info { background: #eceafc; border-color: #c8c5f0; color: var(--deep); }

/* المراجعة */
.review { list-style: none; margin: 0; padding: 0; }
.review li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.review li b { flex: 0 0 38%; color: var(--muted); font-weight: 600; }
.review li span { flex: 1; word-break: break-word; }
.review .miss span { color: var(--warn); font-weight: 700; }
.sect-h { display: flex; align-items: center; justify-content: space-between; }

/* بطاقة الاستلام */
.receipt { background: #fff; border: 2px solid var(--indigo); border-radius: 18px; padding: 24px; position: relative; overflow: hidden; }
.receipt::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 10px; background: var(--sign); }
.receipt .ref { font-size: 32px; font-weight: 900; letter-spacing: 1px; color: var(--indigo); direction: ltr; text-align: center; background: var(--paper); border-radius: 12px; padding: 8px; margin: 12px 0; user-select: all; }
.receipt .conf { background: var(--ok-bg); border-radius: 12px; padding: 12px 16px; margin: 12px 0; }
.receipt dl { margin: 0; display: grid; grid-template-columns: 34% 1fr; gap: 6px 12px; }
.receipt dt { color: var(--muted); }
.receipt dd { margin: 0; font-weight: 600; word-break: break-word; }

/* نافذة */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 19, 58, .6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 18px; padding: 24px; max-width: 460px; width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.toast { position: fixed; bottom: 18px; inset-inline: 0; margin-inline: auto; width: max-content; max-width: 92vw; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; z-index: 60; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.foot { color: var(--muted); font-size: 14px; padding: 22px 16px 40px; }
.hp { position: absolute; inset-inline-start: -9999px; height: 0; overflow: hidden; }
.spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.welcome { text-align: center; padding: 40px 12px; }
.welcome .big { font-size: 22px; padding: 18px 40px; min-height: 70px; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .phone-row { grid-template-columns: 118px 1fr; }
  .steps li { font-size: 12px; }
  .review li { flex-direction: column; gap: 0; } .review li b { flex: none; }
  .actions .btn { flex: 1; }
  .receipt dl { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  body { background: #fff; }
  .top, .foot, .no-print, .actions, .steps, .bar { display: none !important; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .receipt { border-width: 2px; break-inside: avoid; }
}

/* ===== واجهة الموظف والمدير ===== */
.nav { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.nav .wrap { display: flex; gap: 6px; overflow-x: auto; padding-block: 8px; scrollbar-width: thin; }
.nav a { white-space: nowrap; padding: 10px 16px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 700; min-height: 44px; display: inline-flex; align-items: center; }
.nav a.on { background: var(--indigo); color: #fff; }
.nav .sep { width: 1px; background: var(--line-2); margin: 6px 6px; flex: none; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; text-align: right; cursor: pointer; font: inherit; }
.kpi b { display: block; font-size: 28px; line-height: 1.2; color: var(--indigo); }
.kpi span { color: var(--muted); font-size: 14px; }
.kpi.on { border-color: var(--indigo); background: #eceafc; }
.kpi.warn b { color: var(--bad); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.filters .field { margin: 0; } .filters label { font-size: 14px; }
.filters input, .filters select { min-height: 46px; }

.rq { display: grid; grid-template-columns: 175px 1.3fr 1.2fr 130px 130px 120px; gap: 10px; align-items: center; padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; text-decoration: none; color: inherit; }
.rq:hover { border-color: var(--indigo-2); }
.rq.head { background: transparent; border: 0; color: var(--muted); font-size: 14px; font-weight: 700; margin-top: 12px; padding-block: 0; }
.rq small { color: var(--muted); display: block; }
.badge { display: inline-block; padding: 2px 12px; border-radius: 99px; font-size: 14px; font-weight: 700; background: #eceafc; color: var(--deep); white-space: nowrap; }
.badge.s-needs_info { background: var(--warn-bg); color: var(--warn); } .badge.s-ready, .badge.s-completed { background: var(--ok-bg); color: var(--ok); }
.badge.s-referred { background: #f1e6fb; color: #6b2f9a; } .badge.s-in_progress { background: #e2effc; color: #1b5a9a; } .badge.s-closed { background: #e8e7ee; color: #55546e; }
.badge.red { background: var(--bad-bg); color: var(--bad); } .badge.gold { background: var(--warn-bg); color: var(--warn); }
.cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 700; background: var(--paper-2); }
.tbl-wrap { overflow-x: auto; }
.barrow { display: grid; grid-template-columns: 170px 1fr 56px; gap: 10px; align-items: center; margin: 5px 0; font-size: 15px; }
.barrow i { display: block; height: 14px; border-radius: 7px; background: var(--indigo-2); min-width: 3px; }
.log { list-style: none; margin: 0; padding: 0; } .log li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.log small { color: var(--muted); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.def-note { font-size: 14px; color: var(--muted); }
.sw { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 40px; }
.sw input { width: 22px; height: 22px; }
.qrbox { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.qrbox canvas, .qrbox svg, .qrbox img { width: 160px; height: 160px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.mono { direction: ltr; unicode-bidi: plaintext; font-family: ui-monospace, Consolas, monospace; }
.login { max-width: 420px; margin: 40px auto; }
@media (max-width: 960px) {
  .rq { grid-template-columns: 1fr 1fr; } .rq.head { display: none; }
  .cols { grid-template-columns: 1fr; }
  .barrow { grid-template-columns: 110px 1fr 44px; }
}
@media print { .nav, .noprint { display: none !important; } .wrap.wide { max-width: none; } body { font-size: 13px; } .barrow i { print-color-adjust: exact; -webkit-print-color-adjust: exact; } }
