/* ==========================================================================
   تقرير صيانة المغذي — واجهة داكنة
   ========================================================================== */

:root {
  --bg: #0F1620;
  --panel: #131C28;
  --surface: #141E2B;
  --surface-2: #1D2B3C;
  --border: #202B3A;
  --border-2: #2C3B4E;
  --text: #E6EAF0;
  --muted: #93A0B4;
  --dim: #7E8B9D;
  --accent: #6FC0F5;
  --accent-soft: #A5D9FB;
  --accent-ink: #06121E;
  --brand: #FF8D12;
  --ok: #3FCF8E;
  --danger: #FF7A7A;
  --danger-bg: #2A1620;
  --rail: 252px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Readex Pro", "Segoe UI", Tahoma, sans-serif;
  font-weight: 300;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-soft); }

::placeholder { color: #5C6A7C; }

/* ------------------------------------------------------------------ الهيكل */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  flex: none;
  width: var(--rail);
  padding: 32px 20px;
  background: var(--panel);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.brand svg { flex: none; }

.nav { display: flex; flex-direction: column; gap: 6px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
}
.nav a:hover { background: #172130; color: var(--text); }
.nav a.active {
  background: var(--surface-2);
  color: #fff;
  font-weight: 500;
}
.nav a svg { flex: none; stroke: currentColor; opacity: .85; }

.main {
  flex-grow: 1;
  min-width: 0;
  padding: 56px 64px 72px;
}

.wrap { max-width: 680px; }
.wrap-wide { max-width: 900px; }

/* ------------------------------------------------------------------ عناوين */

.page-head { margin-bottom: 32px; }
.page-head h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.page-head p { margin: 0; font-size: 15px; color: var(--muted); }

h2 { font-size: 17px; font-weight: 500; margin: 0 0 14px; }

/* ------------------------------------------------------------------ نماذج */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 200px;
  padding: 28px;
  background: var(--surface);
  border: 1.5px dashed var(--border-2);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #16222F; }
.dropzone svg { stroke: var(--accent); }
.dz-title { font-size: 16px; font-weight: 400; unicode-bidi: plaintext; word-break: break-all; }
.dz-hint { font-size: 13px; color: var(--muted); unicode-bidi: plaintext; }
.dropzone.filled { border-style: solid; border-color: var(--accent); }
.dropzone.filled svg { stroke: var(--ok); }

.file-list {
  margin: 0;
  font-size: 14px;
  color: var(--accent-soft);
  word-break: break-all;
}

.hidden-input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

.field { display: block; margin-top: 24px; }
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 400;
  color: #C3CCD9;
}
.field-label em { font-style: normal; color: var(--dim); font-weight: 300; }

input[type="text"], input[type="search"], select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 300;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 10px;
}
input[type="text"]:focus, input[type="search"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
select { cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  margin-top: 28px;
  padding: 0 32px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
/* a:hover العامة كانت تلوّن نص الزر بلون الخلفية نفسها فيختفي — نثبّت اللون */
.btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
a.btn, a.btn:hover { color: var(--accent-ink); }
a.btn-ghost, a.btn-ghost:hover { color: var(--text); }

.btn-ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: var(--accent); }

.back-link {
  display: inline-block;
  margin-top: 26px;
  font-size: 14px;
  color: var(--muted);
}
.back-link:hover { color: var(--accent); }

.hint { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------------ التقدّم */

.pct {
  font-size: 46px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.progress-wrap {
  height: 8px;
  margin: 18px 0 8px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}

.stats { list-style: none; margin: 26px 0 0; padding: 0; }
.stats li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  font-size: 15px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.stats li:last-child { border-bottom: none; }
.stats b { font-weight: 500; color: var(--text); }

.errors {
  margin: 20px 0;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #4A2430;
  border-radius: 10px;
}

/* ------------------------------------------------- ربط صور "بعد" بالملاحظات */

.summary-line {
  margin: 0 0 24px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.summary-line b { color: var(--accent); font-weight: 500; }

.photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.photo-row .thumb {
  flex: none;
  width: 92px;
  height: 92px;
  object-fit: cover;
  background: #0C121B;
  border: 1px solid var(--border-2);
  border-radius: 9px;
}
.photo-row .grow { flex-grow: 1; min-width: 0; }
.photo-row .opt-search {
  min-height: 40px;
  margin-bottom: 8px;
  font-size: 14px;
  background: #0F1822;
}
.photo-row .match-count {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}
.photo-row .file-name {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--dim);
  word-break: break-all;
  direction: ltr;
  text-align: right;
}

/* ------------------------------------------------------------------ الجوال */

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-inline-end: none;
    border-bottom: 1px solid var(--border);
  }
  .nav { flex-direction: row; gap: 4px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 0 0 auto; white-space: nowrap; }
  .sidebar { min-width: 0; }
  .nav a { font-size: 14px; padding: 0 10px; }
  .main { padding: 32px 20px 56px; }
  .page-head h1 { font-size: 24px; }
  .photo-row .thumb { width: 68px; height: 68px; }
}

@media (max-width: 520px) {
  .brand span { display: none; }
  .nav a svg { display: none; }
}

/* ------------------------------------------------------------ زونات العمل */

.zone-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.zone-bar .field-label { margin: 0; white-space: nowrap; }
.zone-bar input[type="number"] {
  width: 90px;
  min-height: 46px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 300;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 10px;
}
.zone-bar .btn { margin-top: 0; min-height: 46px; padding: 0 20px; font-size: 15px; }

#map {
  height: 520px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.leaflet-popup-content { font-family: inherit; font-size: 13px; line-height: 1.7; }
.leaflet-container { font-family: inherit; }

.zb-item { display: flex; align-items: center; gap: 8px; }
.zb-item .field-label { margin: 0; white-space: nowrap; }
.zone-bar select { width: auto; min-width: 210px; min-height: 46px; }

.copy-all { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -4px 0 18px; }
.copy-all .btn { margin-top: 0; min-height: 44px; font-size: 14px; }
.copy-all .hint { margin-top: 0; color: var(--ok); }

.zone-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.zone-card {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.zc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.zc-head b { font-weight: 500; font-size: 15px; }
.zc-head .zmeta { font-size: 12px; color: var(--muted); }
.zc-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center;
  min-height: 34px; padding: 0 12px;
  font-family: inherit; font-size: 13px; font-weight: 400;
  color: var(--accent); background: #16222F;
  border: 1px solid var(--border-2); border-radius: 8px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent-soft); }
.chip.zone-dl { width: 100%; justify-content: center; min-height: 40px; font-weight: 500; }
.chip.zone-dl:hover { background: #1A2635; }
.chip.copy { color: var(--muted); }
.chip.copy-zone {
  margin-top: 10px;
  color: var(--text);
  background: transparent;
  border-style: dashed;
}
.chip.copy-zone:hover { border-style: solid; }
.reset-form { margin-top: 16px; }
.reset-form .btn { margin-top: 0; min-height: 44px; font-size: 14px; }
.leaflet-popup-content select {
  width: 100%; min-height: 36px; margin-top: 8px;
  font-family: inherit; font-size: 13px;
  color: #1B2430; background: #fff;
  border: 1px solid #c9d2dd; border-radius: 6px;
}

.zone-legend {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
}
.zone-legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.zone-legend .swatch {
  flex: none; width: 14px; height: 14px; border-radius: 4px;
}
.zone-legend .zname { font-size: 14px; font-weight: 500; }
.zone-legend .zmeta { font-size: 12px; color: var(--muted); margin-inline-start: auto; }

input[type="number"] { -moz-appearance: textfield; }

/* --------------------------------------------- دبابيس مرقّمة ومشاركة الزونات */

.pin { background: none; border: none; }
.pin .pin-dot {
  display: block; width: 14px; height: 14px;
  border: 2px solid #0F1620; border-radius: 50%;
}
.pin .pin-num {
  display: none;
  position: absolute; top: -3px; inset-inline-start: 18px;
  padding: 1px 5px;
  font-family: "Readex Pro", sans-serif; font-size: 10px; font-weight: 500;
  color: #0F1620; background: rgba(255,255,255,.88);
  border-radius: 4px; white-space: nowrap;
  direction: ltr;
}
.show-nums .pin .pin-num { display: block; }
.pin:hover .pin-num { display: block; z-index: 500; }

.pin-photo {
  display: block; width: 100%; max-width: 240px;
  margin: 8px 0; border-radius: 6px;
}
.leaflet-popup-content { max-width: 250px; }

.share-box {
  padding: 16px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.share-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.share-row input[type="text"] {
  flex: 1 1 320px; min-height: 46px;
  font-size: 13px; color: var(--accent-soft); background: #0F1822;
}
.share-row .btn { margin-top: 0; min-height: 46px; padding: 0 20px; font-size: 14px; }
.share-box .hint { margin-top: 10px; }
.share-box .hint#copyAllMsg { margin-top: 0; color: var(--ok); }

.zc-fields { display: flex; gap: 8px; margin-top: 12px; }
.zc-fields input[type="text"] { flex: 1 1 auto; min-height: 42px; font-size: 14px; }
.zc-fields input[type="number"] {
  flex: none; width: 82px; min-height: 42px; padding: 0 10px;
  font-family: inherit; font-size: 14px; font-weight: 300;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: 10px;
}

.howto {
  margin: -6px 0 18px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.howto summary { cursor: pointer; font-size: 14px; color: var(--accent); }
.howto ol { margin: 12px 0 0; padding-inline-start: 20px; font-size: 14px; color: var(--muted); line-height: 2; }
.howto b { color: var(--text); font-weight: 500; }

/* ------------------------------------------------ متابعة الأعمال المنفّذة */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 26px;
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.kpi-num { font-size: 26px; font-weight: 500; color: var(--text); line-height: 1.2; }
.kpi-lbl { font-size: 13px; color: var(--muted); }
.kpi.ok .kpi-num { color: var(--ok); }

.sec-title {
  margin: 34px 0 6px;
  font-size: 16px;
  font-weight: 500;
  color: #C3CCD9;
}
.sec-note { margin: 0 0 14px; font-size: 13px; color: var(--muted); }

.rule {
  display: grid;
  grid-template-columns: 1.2fr 1fr 150px;
  gap: 8px;
  margin-bottom: 8px;
}
.rule select, .rule input[type="text"] { min-height: 46px; font-size: 15px; }
/* display:grid يغلب [hidden] الافتراضي، فنعيد إخفاء القواعد غير المفعّلة */
.rule[hidden] { display: none; }
.rule-fixed {
  grid-template-columns: 1fr 150px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  margin-bottom: 14px;
}
.rule-tag { font-size: 15px; color: var(--text); }
.rule-two { grid-template-columns: 1fr 1fr; }
.rule-lbl { display: block; font-size: 13px; color: var(--muted); }
.rule-lbl select { margin-top: 6px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.check input[type="checkbox"] {
  flex: none;
  width: 18px; height: 18px;
  margin-top: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}
.check span { line-height: 1.7; }

@media (max-width: 720px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .rule, .rule-two { grid-template-columns: 1fr; }
  .rule-fixed { grid-template-columns: 1fr; align-items: stretch; }
  /* عند التكديس رأسيًا تذوب حدود القواعد ببعضها، فنؤطّر كل قاعدة على حدة */
  .rule[data-rule] {
    gap: 6px;
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
  }
}

.color-pick { position: relative; display: block; }
.color-pick .sw {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  width: 16px; height: 16px;
  margin-top: -8px;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  pointer-events: none;
}
.color-pick select { padding-inline-start: 38px; }

.btn-small {
  margin-top: 6px;
  min-height: 42px;
  padding: 0 18px;
  font-size: 14px;
}

.kpi-row.kpi-5 { grid-template-columns: repeat(5, 1fr); }
.rule-one { grid-template-columns: 1fr; }
@media (max-width: 900px) { .kpi-row.kpi-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) { .kpi-row.kpi-5 { grid-template-columns: repeat(2, 1fr); } }

.rule-map { grid-template-columns: 1fr 260px; align-items: center; margin-bottom: 8px; }
.rule-map .rule-tag {
  display: flex; align-items: center; gap: 10px;
  padding-inline-start: 14px; font-size: 15px;
}
.rule-count {
  min-width: 46px; padding: 2px 10px;
  font-size: 13px; color: var(--muted); text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.rule-three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .rule-map, .rule-three { grid-template-columns: 1fr; } }

/* ------------------------------------------------ شاشة فرز الملاحظات */

.pick-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 8px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  position: sticky;                 /* العدّاد يلاحق المستخدم وهو ينزل */
  top: 12px;
  z-index: 5;
}
.pick-live { display: flex; align-items: baseline; gap: 10px; }
.pick-live + .pick-live { margin-inline-start: 26px; }
.pick-live .kpi-num { font-size: 30px; }
.pick-live.muted .kpi-num { color: var(--dim); }
.pick-live .kpi-lbl { font-size: 13px; }

.pick { margin-top: 26px; }
.pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.pick-head h2 { margin: 0; font-size: 16px; font-weight: 500; color: #C3CCD9; }
.pick-head h2 em { font-style: normal; color: var(--dim); font-weight: 300; font-size: 13px; }
.pick-actions { display: flex; align-items: center; gap: 8px; }
.pick-actions input[type="search"] { width: 190px; min-height: 36px; font-size: 14px; }

.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 2px 14px;
}
.pick-scroll { max-height: 340px; overflow-y: auto; padding-inline-end: 6px; }

.pick-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 0 8px;
  font-size: 14px;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
}
.pick-item:hover { background: #16222F; }
.pick-item input[type="checkbox"] {
  flex: none;
  width: 17px; height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}
.pick-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-n {
  flex: none;
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
/* البند الذي لا يبقي صفًا واحدًا مع بقية الاختيارات: يبقى ظاهرًا ليُفهم */
.pick-item.empty .pick-name, .pick-item.empty .pick-n { opacity: 0.38; }

.sw-box {
  flex: none;
  width: 15px; height: 15px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

@media (max-width: 720px) {
  .pick-bar { position: static; }
  .pick-live + .pick-live { margin-inline-start: 0; }
  .pick-grid { grid-template-columns: 1fr; }
  .pick-actions input[type="search"] { width: 100%; }
}
/* اسم المغذي معرّف لاتيني/رقمي («629|M12 الجحفة»)؛ بلا dir=ltr يقلبه
   محرّك الاتجاه فيظهر «M12|629» وهو خطأ يُربك القارئ */
.pick-name[dir="ltr"] { text-align: right; }

/* ------------------------------------- ميزان ملفات التنفيذ في شاشة المطابقة */

.ledger {
  width: 100%;
  margin: 10px 0 6px;
  border-collapse: collapse;
  font-size: 14px;
  color: var(--muted);
}
.ledger th, .ledger td {
  padding: 9px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.ledger th {
  font-size: 12px;
  font-weight: 400;
  color: var(--dim);
  border-bottom-color: var(--border-2);
  white-space: nowrap;
}
.ledger td.ln {
  text-align: start;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #C3CCD9;
}
.ledger td.ok { color: var(--ok); }
/* الخانات التي تعني «لم يدخل الحساب» تُبرز، فالصفر فيها هو الطمأنينة */
.ledger td.warn { color: #F0B429; }
.ledger tr.sum td { border-top: 1px solid var(--border-2); border-bottom: none; }
.ledger tr.sum td:first-child { color: var(--dim); }
.ledger td.ln em {
  display: block;
  font-style: normal;
  font-size: 11px;
  color: var(--dim);
}
/* ورقة أخرى فيها بيانات لم تُقرأ: تحذير يجب ألا يمرّ مرور الكرام */
.ledger tr.note td {
  text-align: start;
  font-size: 12px;
  color: #F0B429;
  background: rgba(240, 180, 41, 0.07);
}

/* --------------------------------------------- شاشة مراجعة الصور بالتمرير */

.rv-bar {
  position: sticky; top: 0; z-index: 8;
  display: flex; align-items: center; flex-wrap: wrap; gap: 18px;
  margin-bottom: 14px; padding: 12px 18px;
  background: rgba(15, 22, 32, 0.96);
  border: 1px solid var(--border-2); border-radius: 12px;
  backdrop-filter: blur(6px);
}
.rv-stat { display: flex; align-items: baseline; gap: 7px; }
.rv-stat b { font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }
.rv-stat span { font-size: 12px; color: var(--dim); }
.rv-stat.muted b { color: var(--dim); }
.rv-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 14px; }
.rv-seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 9px; overflow: hidden; }
.rv-seg button {
  font-family: inherit; font-size: 13px; font-weight: 400;
  padding: 7px 13px; min-height: 36px;
  color: var(--muted); background: transparent; border: 0; cursor: pointer;
}
.rv-seg button + button { border-inline-start: 1px solid var(--border-2); }
.rv-seg button:hover { background: #16222F; }
.rv-seg button.on { color: var(--accent-ink); background: var(--accent); }
.rv-saved { font-size: 12px; color: var(--ok); min-width: 54px; }
.rv-actions .btn-small { margin: 0; }

.rv {
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border);
  /* التمرير في ستمئة ملاحظة: نخبر المتصفح أن يتخطّى رسم ما خرج عن الشاشة */
  content-visibility: auto;
  contain-intrinsic-size: 350px;
}
.rv.touched { background: rgba(111, 192, 245, 0.05); }
.rv-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.rv-id { font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; }
.rv-type { font-size: 14px; color: #C3CCD9; }
.rv-note { font-size: 12px; color: var(--dim); }
.rv-flag {
  margin-inline-start: auto; flex: none;
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border-2); color: var(--dim);
}
.rv-flag.ok { color: var(--ok); border-color: rgba(120, 200, 150, 0.4); }
.rv-flag.weak { color: #F0B429; border-color: rgba(240, 180, 41, 0.4); }

.rv-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.rv-side { position: relative; }
.rv-lbl {
  position: absolute; top: 6px; inset-inline-start: 6px; z-index: 2;
  font-size: 11px; padding: 2px 8px; border-radius: 6px;
  color: #0F1620; background: rgba(255, 255, 255, 0.82);
}
/* contain لا cover: الحكم على الزاوية يقتضي رؤية الإطار كاملًا، والقصّ
   يخفي أطراف المشهد التي يُعرف بها الموقع */
.rv-main {
  display: block; width: 100%; height: 250px; object-fit: contain;
  border-radius: 10px; background: #0B1118; border: 1px solid var(--border);
}
.rv-empty {
  height: 250px; display: flex; align-items: center; justify-content: center;
  color: var(--dim); border: 1px dashed var(--border-2); border-radius: 10px;
}
.rv-alts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.rv-alt {
  width: 66px; height: 50px; object-fit: cover;
  border-radius: 6px; cursor: pointer; opacity: 0.55;
  border: 2px solid transparent; background: #0B1118;
}
.rv-alt:hover { opacity: 0.85; }
.rv-alt.on { opacity: 1; border-color: var(--accent); }

@media (max-width: 720px) {
  .rv-pair { grid-template-columns: 1fr; }
  .rv-main, .rv-empty { height: 240px; }
  .rv-actions { margin-inline-start: 0; width: 100%; }
}

/* ------------------------------ ملاحظات المراجعة والملاحظات المسترجعة */

.rv-stat.red b { color: #FF5A5A; }
.rv-stat.red span { color: #FF8A8A; }
.rv-seg button.seg-red { color: #FF7A7A; }
.rv-seg button.seg-red.on { color: #fff; background: #D92D2D; }

/* المسترجعة: أحمر لا يُخطئه التمرير السريع — شريط جانبي عريض وخلفية وشارة */
.rv.returned {
  background: rgba(217, 45, 45, 0.10);
  border-inline-start: 5px solid #E03131;
  padding-inline-start: 12px;
  border-radius: 6px;
}
.rv-ret {
  flex: none;
  font-size: 12px; font-weight: 500;
  padding: 3px 10px; border-radius: 999px;
  color: #fff; background: #D92D2D;
}

.rv-review {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 10px;
}
.rv-review-lbl { font-size: 12px; color: var(--dim); }
.rv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rv-chip {
  font-family: inherit; font-size: 12px; font-weight: 400;
  min-height: 30px; padding: 0 11px; border-radius: 999px; cursor: pointer;
  color: var(--muted); background: transparent; border: 1px solid var(--border-2);
}
.rv-chip:hover { border-color: #FF8A8A; color: #FFB3B3; }
.rv-chip.on { color: #fff; background: #C92A2A; border-color: #C92A2A; }
.rv-text {
  flex: 1 1 180px; min-width: 160px;
  min-height: 32px !important; height: 32px; font-size: 13px !important;
}
.rv-hide button { font-size: 12px; min-height: 32px; padding: 0 10px; }
.rv-hide[hidden], .rv-stamp[hidden] { display: none !important; }
.rv.noted:not(.returned) { background: rgba(201, 42, 42, 0.05); }

/* الختم فوق صورة «بعد»: شريط أحمر أسفلها إن بقيت، ويغطّيها إن حُذفت —
   فيرى المستخدم في الصفحة ما سيراه في البوربوينت */
.rv-stamp {
  position: absolute; left: 0; right: 0; top: 0; height: 250px;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none; border-radius: 10px; overflow: hidden;
}
.rv-stamp-txt {
  width: 100%; padding: 8px 12px; text-align: center;
  font-size: 13px; font-weight: 500; line-height: 1.6;
  color: #fff; background: rgba(201, 42, 42, 0.92);
}
.rv.hidephoto .rv-side[data-side="after"] .rv-main { opacity: 0.12; }
.rv.hidephoto .rv-stamp { align-items: center; border: 2px solid #E03131; }
.rv.hidephoto .rv-stamp-txt {
  width: auto; max-width: 86%; border-radius: 8px;
  font-size: 15px; padding: 14px 18px;
  color: #FF6B6B; background: rgba(20, 8, 8, 0.85); border: 1px solid #E03131;
}

@media (max-width: 720px) {
  .rv-stamp { height: 240px; }
}
.rv-side.missing .rv-main { visibility: hidden; }
.rv-side.missing::after {
  content: "الصورة غير متاحة عند المستضيف";
  position: absolute; top: 0; left: 0; right: 0; height: 250px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--dim);
  border: 1px dashed var(--border-2); border-radius: 10px;
}
.rv-alt.gone { opacity: 0.25; border-style: dashed; border-color: var(--border-2); }

/* ----------------------------------- شارة الحالة على كل بطاقة */

.rv-st {
  flex: none;
  font-size: 12px; font-weight: 500; line-height: 1;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid transparent;
}
.rv-st.st-ok       { color: #8CE0A8; background: rgba(46, 160, 90, 0.16); border-color: rgba(46, 160, 90, 0.45); }
.rv-st.st-done     { color: #8FD3F4; background: rgba(60, 150, 210, 0.16); border-color: rgba(60, 150, 210, 0.45); }
.rv-st.st-wait     { color: var(--muted); background: rgba(255, 255, 255, 0.04); border-color: var(--border-2); }
.rv-st.st-none,
.rv-st.st-other    { color: var(--dim); border-color: var(--border-2); border-style: dashed; }
/* ما يحتاج قرارًا: مسترجعة بالأحمر، وغير قادر على العمل بالبرتقالي — كلاهما
   صريح اللون، ومختلفان حتى لا يُخلط أحدهما بالآخر في التمرير */
.rv-st.st-returned { color: #fff; background: #D92D2D; }
.rv-st.st-blocked  { color: #1A0E00; background: #F08C00; }

.rv.blocked {
  background: rgba(240, 140, 0, 0.10);
  border-inline-start: 5px solid #F08C00;
  padding-inline-start: 12px;
  border-radius: 6px;
}
.rv-stat.orange b { color: #FFA94D; }
.rv-stat.orange span { color: #FFC078; }

.rv-stsel {
  width: auto !important; min-width: 170px;
  min-height: 36px !important; height: 36px; font-size: 13px !important;
  padding: 0 10px !important;
}
/* أزرار الشريط لا تنكسر داخلها؛ الشريط نفسه يلتفّ إلى سطر ثانٍ عند الضيق */
.rv-seg button, .rv-actions .btn-small { white-space: nowrap; }
.rv-actions { flex-wrap: wrap; justify-content: flex-end; }

/* ------------------------------------------ مفتاح تشغيل/إغلاق */

.switch-row {
  display: flex; align-items: flex-start; gap: 14px;
  margin-top: 24px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 12px; cursor: pointer;
}
.switch { position: relative; flex: none; width: 46px; height: 26px; margin-top: 2px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-knob {
  position: absolute; inset: 0; border-radius: 999px;
  background: #2C3B4E; transition: background .18s;
}
.switch-knob::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #C3CCD9; transition: transform .18s, background .18s;
}
.switch input:checked + .switch-knob { background: var(--accent); }
.switch input:checked + .switch-knob::after { background: #fff; transform: translateX(-20px); }
[dir="ltr"] .switch input:checked + .switch-knob::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-knob { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; gap: 3px; }
.switch-text b { font-size: 14px; font-weight: 500; color: #C3CCD9; }
.switch-text em { font-style: normal; font-size: 12px; color: var(--dim); }

/* ------------------------------------------------------ ملخص الأداء */

.sm-card {
  margin: 16px 0; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px;
}
.sm-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; }
.sm-code { font-size: 18px; color: var(--accent); }
.sm-dim { font-size: 12px; color: var(--dim); }
.sm-file { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-stats { display: flex; flex-wrap: wrap; gap: 18px; margin: 10px 0 12px; font-size: 13px; color: var(--muted); }
.sm-stats b { font-size: 16px; color: var(--text); margin-inline-end: 4px; }
.sm-stats .ok b { color: var(--ok); }
.sm-stats .bad b { color: #FF7A7A; }

.sm-grid { display: grid; grid-template-columns: 1.3fr 1fr 0.8fr; gap: 12px; }
.sm-field { display: flex; flex-direction: column; gap: 5px; }
.sm-field > span { font-size: 12px; color: var(--dim); }
.sm-field em { font-style: normal; }
.sm-field select, .sm-field input { min-height: 40px !important; font-size: 14px !important; }
.sm-field input[type="date"] {
  font-family: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: 10px; padding: 0 10px; color-scheme: dark;
}

.sm-notices { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.sm-sub { font-size: 12px; color: var(--dim); }
.sm-n {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer;
  font-size: 13px; color: var(--muted); opacity: 0.6;
}
.sm-n.on { opacity: 1; border-color: var(--border-2); background: rgba(111, 192, 245, 0.05); }
.sm-n input { width: 17px; height: 17px; accent-color: var(--accent); }
.sm-n b { color: var(--text); font-variant-numeric: tabular-nums; }
.sm-cons { color: #C3CCD9; }
.sm-cnt { font-size: 12px; color: var(--dim); margin-inline-start: auto; }
.sm-n.phone { border-style: dashed; border-color: #F0B429; }
.sm-warn { font-size: 12px; color: #F0B429; }
.sm-d1 { margin-top: 4px; font-size: 13px; color: var(--muted); }
.sm-d1 b { color: var(--text); }

.sm-color { margin-top: 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sm-chip { font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 999px; }

.sm-tab td.nm { color: #C3CCD9; }
.sm-tab th { white-space: normal; }

@media (max-width: 720px) {
  .sm-grid { grid-template-columns: 1fr; }
  .sm-cnt { margin-inline-start: 0; }
}
.sm-grid { grid-template-columns: 1.6fr 1fr; }
.sm-date { display: flex; gap: 8px; align-items: stretch; }
.sm-date input { flex: 1; min-width: 0; text-align: left; }
.sm-date .btn-small { margin: 0; min-height: 40px; white-space: nowrap; }

/* ------------------------------------------- مراجعة الصور: مفاتيح الحالات */

.ph-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 4px 0 12px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px;
  font-size: 14px;
}
.ph-bar .btn-small { margin: 0; }
.ph-sum { color: var(--muted); margin-inline-start: auto; }
.ph-sum b { color: var(--text); }
.ph-sum .ph-drop { color: var(--danger); }
.ph-row {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 8px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px;
  cursor: pointer;
}
.ph-row .switch { margin-top: 0; }
.ph-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; min-width: 0; }
.ph-name b { font-size: 15px; font-weight: 600; }
.ph-cnt { margin-inline-start: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.ph-row.off { border-color: var(--danger-bg); }
.ph-row.off .ph-name b, .ph-row.off .ph-cnt { color: var(--danger); text-decoration: line-through; }
.ph-note {
  margin: 0 0 14px; padding: 10px 14px; font-size: 14px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px;
}
.ph-note b { color: var(--danger); font-weight: 600; }
.ph-note a { margin-inline-start: 8px; }
@media (max-width: 720px) {
  .ph-sum { margin-inline-start: 0; }
  .ph-row { flex-wrap: wrap; }
  .ph-cnt { flex-basis: 100%; margin-inline-start: 60px; }
}

/* ---------------------------------------------------- المنجز والمتبقي */

.pg-tab th em { font-style: normal; font-weight: 400; font-size: 11px; opacity: .8; }
.pg-tab th.pg-done { color: var(--ok); }
.pg-tab th.pg-mv, .pg-tab td.pg-mvn { color: var(--danger); }
.pg-tab td, .pg-tab th { text-align: center; }

/* عناصر مخفية بالخاصية hidden تبقى مخفية مهما كان عرضها في الأنماط */
[hidden] { display: none !important; }
