/* معيار — نظام تصميم هادئ: سطح محايد، لون واحد مميِّز، حدود شعرية، كثافة بيانات عالية بلا زحمة */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap");
:root {
  --bg: #f6f6f3; --surface: #ffffff; --surface-2: #fafaf8; --line: #e7e5df; --line-2: #d9d6cf;
  --ink: #171716; --ink-2: #45443f; --mut: #74726b; --faint: #a3a199;
  --acc: #0c6b58; --acc-ink: #ffffff; --acc-soft: #e4f2ee; --acc-line: #b9ddd3;
  --ok: #0c6b58; --ok-soft: #e4f2ee; --warn: #9a5b06; --warn-soft: #fbf1dc; --warn-line: #efd9a8;
  --err: #b3261e; --err-soft: #fbe9e7; --err-line: #f1c4bf; --info: #1f4fb8; --info-soft: #e8effc;
  --r: 14px; --r-sm: 9px; --shadow: 0 1px 2px rgba(20,20,18,.04), 0 8px 24px -12px rgba(20,20,18,.12);
  --side: 252px; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e100f; --surface: #161918; --surface-2: #1b1f1d; --line: #272b29; --line-2: #343937;
  --ink: #eceeed; --ink-2: #c4c8c6; --mut: #8f9592; --faint: #666c69;
  --acc: #3ecfae; --acc-ink: #06231c; --acc-soft: #12302a; --acc-line: #1f4a40;
  --ok: #3ecfae; --ok-soft: #12302a; --warn: #f0b955; --warn-soft: #33270f; --warn-line: #57431a;
  --err: #ff8a80; --err-soft: #3a1917; --err-line: #5e2925; --info: #8fb4ff; --info-soft: #17233f;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -12px rgba(0,0,0,.6); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.6 "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; -webkit-font-smoothing: antialiased; }
h1 { font-size: 26px; font-weight: 700; margin: 0; letter-spacing: -.01em; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; color: var(--ink-2); }
a { color: var(--acc); text-decoration: none; } a:hover { text-decoration: underline; }
.ic { flex: none; vertical-align: -3px; }
.mut { color: var(--mut); } .sm { font-size: 12.5px; } .nw { white-space: nowrap; } .grow { flex: 1; min-width: 0; }
.n, .code { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: plaintext; text-align: start; }
td.n, th.n { text-align: end; } .ltr { direction: ltr; text-align: left; unicode-bidi: plaintext; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--ink-2); }

/* ---------- الهيكل */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; border-inline-end: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; color: var(--ink); cursor: pointer; }
.brand:hover { text-decoration: none; }
.mark { width: 36px; height: 36px; border-radius: 11px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.brand b { display: block; font-size: 17px; line-height: 1.2; } .brand small { color: var(--mut); font-size: 11.5px; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; }
.side nav a:hover { background: var(--surface-2); text-decoration: none; }
.side nav a.on { background: var(--acc-soft); color: var(--acc); }
.side nav .badge { margin-inline-start: auto; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.userchip { display: flex; align-items: center; gap: 9px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--acc-soft); color: var(--acc); display: grid; place-items: center; font-weight: 700; flex: none; }
.userchip input { border: 0; background: transparent; padding: 2px 0; width: 100%; font-weight: 500; }
.userchip input:focus { outline: none; box-shadow: none; }
.userchip .who-name { font-weight: 600; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { padding: 30px 36px 96px; max-width: 1320px; width: 100%; margin: 0 auto; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--mut); max-width: 62ch; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--mut); font-size: 13px; margin-bottom: 8px; }

/* ---------- عناصر أساسية */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .row.sp { justify-content: space-between; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 16px; }
.card > h2:first-child, .card > .row:first-child h2 { margin-bottom: 0; } .card > .row:first-child { margin-bottom: 14px; } .card > h2:first-child { margin-bottom: 14px; }
button, .btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; transition: background .12s, border-color .12s, transform .06s; white-space: nowrap; }
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--faint); text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.pri, .btn.pri { background: var(--ink); border-color: var(--ink); color: var(--bg); }
button.pri:hover, .btn.pri:hover { opacity: .9; background: var(--ink); }
button.ok { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
button.ok:hover { background: var(--acc); opacity: .92; }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-2); } button.ghost:hover { background: var(--surface-2); }
button.lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 11px; }
button.x { width: 30px; height: 30px; padding: 0; border-color: transparent; background: transparent; color: var(--faint); } button.x:hover { color: var(--err); background: var(--err-soft); }
button.link { height: auto; padding: 0; border: 0; background: none; color: var(--acc); }
a > button { pointer-events: none; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px; min-height: 34px; width: 100%; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
input[type="checkbox"] { width: 16px; min-height: 16px; height: 16px; accent-color: var(--acc); }
input[type="number"] { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
label { font-size: 12.5px; color: var(--mut); font-weight: 500; display: grid; gap: 5px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.fields label span { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2); } .fields small { color: var(--faint); direction: ltr; }

/* ---------- شارات وتنبيهات */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.plain::before { display: none; }
.pill.ok, .pill.approved { background: var(--ok-soft); color: var(--ok); border-color: var(--acc-line); }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.pill.err { background: var(--err-soft); color: var(--err); border-color: var(--err-line); }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge, .cnt { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--err); color: #fff; margin-inline-start: 6px; }
.cnt.w { background: var(--warn); } .cnt.g { background: var(--line-2); color: var(--ink-2); }
.note { border: 1px solid var(--line); border-radius: 11px; padding: 11px 14px; margin: 0 0 10px; background: var(--surface-2); }
.note.ok { background: var(--ok-soft); border-color: var(--acc-line); } .note.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.note.err { background: var(--err-soft); border-color: var(--err-line); } .note.info { background: var(--info-soft); border-color: transparent; }
.note b { font-weight: 600; }
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
.conf { display: inline-block; width: 8px; height: 8px; border-radius: 50%; } .conf.h { background: var(--ok); } .conf.m { background: var(--warn); } .conf.l { background: var(--err); }

/* ---------- جداول */
.tbl { overflow: auto; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--mut); font-weight: 600; font-size: 12px; text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; } tfoot th { position: static; font-size: 13.5px; color: var(--ink); border-top: 1px solid var(--line); border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
tr.bad td { background: var(--err-soft); } tr.low td { background: var(--warn-soft); }
tr.trace td { background: var(--surface-2); padding: 6px 12px; } tr.trace table { font-size: 12.5px; } tr.trace td td { border: 0; padding: 3px 8px; background: transparent; }
td input, td select { min-height: 30px; padding: 4px 8px; min-width: 64px; }
.wo { font-weight: 700; font-size: 14.5px; font-variant-numeric: tabular-nums; letter-spacing: .01em; }

/* ---------- الرئيسية */
.drop { border: 1.5px dashed var(--line-2); border-radius: var(--r); background: var(--surface); padding: 30px 24px; text-align: center; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--acc); background: var(--acc-soft); }
.drop.hero { padding: 40px 24px; margin-bottom: 16px; }
.drop .big { width: 54px; height: 54px; border-radius: 16px; background: var(--acc-soft); color: var(--acc); display: grid; place-items: center; margin: 0 auto 14px; }
.drop h2 { font-size: 19px; margin-bottom: 6px; } .drop p { margin: 0 auto 16px; color: var(--mut); max-width: 58ch; }
.drop .row { justify-content: center; } .drop.mini { padding: 18px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; cursor: pointer; transition: border-color .12s; }
.stat:hover, .stat.on { border-color: var(--ink); } .stat b { display: block; font-size: 26px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; } .stat span { color: var(--mut); font-size: 12.5px; }
.search { position: relative; width: min(320px, 100%); } .search .ic { position: absolute; inset-inline-start: 10px; top: 9px; color: var(--faint); } .search input { padding-inline-start: 34px; }
.empty { text-align: center; padding: 34px 16px; color: var(--mut); }

/* ---------- أمر العمل */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; }
.kpi b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; } .kpi span { color: var(--mut); font-size: 12.5px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 18px; overflow-x: auto; width: fit-content; max-width: 100%; }
.tabs button { border: 0; background: transparent; color: var(--mut); height: 34px; border-radius: 8px; }
.tabs button:hover { color: var(--ink); background: var(--surface-2); } .tabs button.on { background: var(--ink); color: var(--bg); }
.review { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.rv-side { position: sticky; top: 18px; display: grid; gap: 12px; }
.ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; margin: 4px auto 12px; display: grid; place-items: center; background: conic-gradient(var(--acc) calc(var(--p) * 1%), var(--line) 0); }
.ring > div { width: 108px; height: 108px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; line-height: 1.2; }
.ring b { font-size: 26px; font-weight: 700; display: block; font-variant-numeric: tabular-nums; } .ring span { font-size: 11.5px; color: var(--mut); }
.steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 2px; }
.steps li { display: flex; align-items: center; gap: 9px; padding: 7px 4px; font-size: 13.5px; border-bottom: 1px solid var(--line); } .steps li:last-child { border: 0; }
.steps .dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--line); color: var(--mut); }
.steps li.done .dot { background: var(--acc); color: var(--acc-ink); } .steps li.todo .dot { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.steps li em { margin-inline-start: auto; font-style: normal; color: var(--mut); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 8px; }
.sec-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 10px; } .sec-h:first-child { margin-top: 0; }
.sec-h h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.q { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.q .q-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); }
.q.done { background: transparent; padding: 9px 16px; } .q.done .q-ic { background: var(--acc-soft); color: var(--acc); width: 26px; height: 26px; border-radius: 8px; margin-inline-start: 4px; }
.q.err .q-ic { background: var(--err-soft); color: var(--err); } .q.rule .q-ic { background: var(--info-soft); color: var(--info); }
.q-text { font-weight: 600; line-height: 1.45; } .q.done .q-text { font-weight: 500; color: var(--ink-2); }
.q-hint { color: var(--mut); font-size: 12.5px; margin-top: 2px; } .q-item { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.q-hint.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.q-act { display: flex; align-items: center; gap: 8px; } .q-act input { width: 84px; } .q-act .unit { color: var(--mut); font-size: 12px; }
details.more > summary { cursor: pointer; color: var(--mut); font-size: 13px; padding: 6px 0; list-style: none; } details.more > summary::before { content: "＋ "; } details.more[open] > summary::before { content: "－ "; }
.viewer { border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); overflow: auto; max-height: 78vh; } .viewer img { display: block; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sticky-save { position: fixed; inset-inline: 0; bottom: 18px; margin: 0 auto; width: fit-content; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 9px 12px 9px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); }
.sticky-save button { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, transparent); } .sticky-save button.pri { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }

/* ---------- عائم */
#toast { display: none; position: fixed; bottom: 22px; inset-inline: 0; margin: 0 auto; width: fit-content; max-width: min(560px, 92vw); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; }
#toast.err { background: var(--err); color: #fff; }
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(15, 15, 14, .45); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 18px; animation: fade .12s ease-out; }
.dialog { width: min(560px, 100%); max-height: 88vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); animation: pop .16s ease-out; }
.dialog h2 { font-size: 18px; margin-bottom: 6px; } .dialog .foot { display: flex; gap: 8px; justify-content: flex-start; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.filelist { display: grid; gap: 6px; margin: 12px 0; } .filelist > div { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; }
.filelist .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }

/* ---------- الدخول */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(400px, 100%); padding: 30px; margin: 0; } .login h1 { font-size: 22px; margin: 16px 0 4px; } .login form { display: grid; gap: 14px; margin-top: 20px; }
.login .err { color: var(--err); font-size: 13px; min-height: 20px; }

@media (max-width: 1080px) { .review { grid-template-columns: 1fr; } .rv-side { position: static; order: -1; } .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; } .side { display: none; } .side.open { display: flex; position: fixed; inset: 0; z-index: 40; width: min(300px, 86vw); box-shadow: var(--shadow); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 30; }
  main { padding: 18px 14px 96px; } h1 { font-size: 21px; } .stats { grid-template-columns: repeat(2, 1fr); } .kpis { grid-template-columns: 1fr; }
  .q { grid-template-columns: 34px minmax(0, 1fr); } .q-act { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
}
@media print { .side, .topbar, .tabs, .sticky-save { display: none; } }
