@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  --ink: #14232b;
  --ink-2: #4b5d66;
  --ink-3: #82939b;
  --line: #e2e8ea;
  --bg: #f5f7f6;
  --card: #ffffff;
  --brand: #0f6b5c;
  --brand-2: #0b5247;
  --brand-soft: #e3f1ee;
  --ok: #1f8a4c;
  --ok-soft: #e6f4ec;
  --warn: #b26a00;
  --warn-soft: #fdf2e0;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --muted-soft: #eef1f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 35, 43, .06), 0 4px 16px rgba(20, 35, 43, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.3; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }

/* ---------- الهيكل ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--ink);
  color: #dbe5e8;
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: #fff; }
.brand img { width: 34px; height: 34px; }
.brand b { font-size: 1.25rem; letter-spacing: .2px; }
.nav button {
  all: unset; display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: 8px; cursor: pointer; color: #c4d1d5; font-size: .95rem;
  box-sizing: border-box;
}
.nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav button.on { background: var(--brand); color: #fff; }
.nav .sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 10px 4px; }
.side .who { margin-top: auto; padding: 10px 12px; font-size: .85rem; color: #9fb0b6; border-top: 1px solid rgba(255,255,255,.08); }
.side .who b { color: #fff; display: block; }
.side .who button { all: unset; cursor: pointer; color: #9fd3c7; margin-top: 6px; display: inline-block; }

main { padding: 28px 34px 60px; max-width: 1240px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.head p { margin: 0; color: var(--ink-2); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g-check { grid-template-columns: minmax(340px, 420px) 1fr; align-items: start; }
.g4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- النماذج ---------- */
label { display: block; font-weight: 500; font-size: .88rem; margin: 0 0 5px; color: var(--ink-2); }
.field { margin-bottom: 14px; position: relative; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: 9px 12px; border: 1px solid #cfd8db; border-radius: 9px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 120px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); margin: 6px 0 14px; cursor: pointer; }
.check input { width: auto; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  padding: 9px 18px; border-radius: 9px; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { background: var(--brand-2); }
.btn.big { width: 100%; padding: 12px; font-size: 1.02rem; }
.btn.ghost { background: #fff; color: var(--ink); border-color: #cfd8db; }
.btn.ghost:hover { background: var(--muted-soft); }
.btn.danger { background: #fff; color: var(--bad); border-color: #ebc2be; }
.btn.sm { padding: 5px 11px; font-size: .85rem; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: default; }

/* اقتراحات البحث */
.suggest {
  position: absolute; inset-inline: 0; top: 100%; z-index: 20; margin-top: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 280px; overflow: auto; display: none;
}
.suggest.open { display: block; }
.suggest div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--muted-soft); }
.suggest div:hover, .suggest div.act { background: var(--brand-soft); }
.suggest small { color: var(--ink-3); display: block; }
.picked { margin-top: 6px; font-size: .88rem; color: var(--brand-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--brand-soft); color: var(--brand-2); border-radius: 999px; padding: 2px 10px 2px 6px; font-size: .85rem; display: inline-flex; gap: 6px; align-items: center; direction: ltr; }
.chip button { all: unset; cursor: pointer; color: var(--ink-3); font-size: 1rem; line-height: 1; }

/* ---------- نتيجة الفحص ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); }
.empty svg { width: 54px; height: 54px; opacity: .45; margin-bottom: 10px; }
.verdict { border-radius: var(--radius); padding: 18px 20px; display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.verdict .ic { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1.4rem; font-weight: 700; flex: none; }
.verdict h2 { margin: 0; font-size: 1.3rem; }
.verdict p { margin: 2px 0 0; }
.v-ok { background: var(--ok-soft); } .v-ok .ic { background: var(--ok); } .v-ok h2 { color: var(--ok); }
.v-action { background: var(--warn-soft); } .v-action .ic { background: var(--warn); } .v-action h2 { color: var(--warn); }
.v-reject { background: var(--bad-soft); } .v-reject .ic { background: var(--bad); } .v-reject h2 { color: var(--bad); }
.v-unknown { background: var(--muted-soft); } .v-unknown .ic { background: var(--ink-3); } .v-unknown h2 { color: var(--ink-2); }

.finding { border-inline-start: 4px solid var(--line); padding: 10px 14px; margin-bottom: 10px; background: #fafbfb; border-radius: 0 8px 8px 0; }
[dir=rtl] .finding { border-radius: 8px 0 0 8px; }
.finding b { display: block; }
.finding p { margin: 3px 0 0; color: var(--ink-2); }
.f-reject { border-color: var(--bad); } .f-action { border-color: var(--warn); } .f-info { border-color: var(--ink-3); }

.hist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.hist div { background: var(--muted-soft); border-radius: 10px; padding: 10px 12px; }
.hist b { font-size: 1.15rem; display: block; }
.hist span { font-size: .8rem; color: var(--ink-2); }

.sub { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- لوحة الإدارة ---------- */
.kpi { padding: 16px 18px; }
.kpi span { color: var(--ink-2); font-size: .85rem; }
.kpi b { display: block; font-size: 1.7rem; font-weight: 700; margin-top: 2px; }
.kpi small { color: var(--ink-3); }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 42px; background: var(--brand); border-radius: 5px 5px 0 0; min-height: 2px; }
.bars .b span { font-size: .72rem; color: var(--ink-3); direction: ltr; }
.bars .b em { font-style: normal; font-size: .72rem; color: var(--ink-2); }
.meter { height: 7px; background: var(--muted-soft); border-radius: 99px; overflow: hidden; min-width: 70px; }
.meter i { display: block; height: 100%; background: var(--bad); }

/* ---------- الجداول ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: start; font-weight: 600; color: var(--ink-2); font-size: .82rem; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfb; }
td { padding: 9px 10px; border-bottom: 1px solid var(--muted-soft); vertical-align: top; }
tr:hover td { background: #fbfcfc; }
.tbl { overflow-x: auto; }
.tag { display: inline-block; font-size: .78rem; padding: 1px 9px; border-radius: 99px; background: var(--muted-soft); color: var(--ink-2); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.action { background: var(--warn-soft); color: var(--warn); }
.tag.reject { background: var(--bad-soft); color: var(--bad); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { max-width: 300px; }

/* ---------- البيانات ---------- */
.kind { display: flex; flex-direction: column; gap: 10px; }
.kind .count { font-size: 1.5rem; font-weight: 700; }
.kind .acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.result-box { margin-top: 10px; font-size: .88rem; }
.result-box.err { color: var(--bad); }
.result-box.ok { color: var(--ok); }

/* ---------- نافذة ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 35, 43, .45); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow: auto; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 760px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal .foot { display: flex; gap: 10px; justify-content: flex-start; margin-top: 8px; }

.toast { position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 99; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

/* ---------- الدخول ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--ink); color: #dbe5e8; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { color: #fff; font-size: 2.2rem; margin-top: 30px; }
.login-art p { font-size: 1.08rem; max-width: 440px; color: #b9c8cd; }
.login-art .steps { display: grid; gap: 12px; margin-top: 26px; }
.login-art .steps div { display: flex; gap: 12px; align-items: center; }
.login-art .steps i { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 700; flex: none; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-form .card { width: 100%; max-width: 380px; padding: 30px; }
.err-msg { color: var(--bad); font-size: .9rem; min-height: 1.4em; margin: 4px 0 10px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .who, .brand { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav button { width: auto; }
  .nav .sep { display: none; }
  main { padding: 18px; }
  .g2, .g-check, .g4 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
}

@media print {
  .side, .toolbar, .btn { display: none !important; }
  .layout { grid-template-columns: 1fr; }
}
