/* ============================================================
   نظام تتبّع المعاملات — الهوية البصرية
   المرجع البصري: غلاف الجواز الكحلي، ختم الحبر، النقش الأمني،
   وشريط القراءة الآلية (MRZ) أسفل الوثيقة.
   ============================================================ */

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

:root {
  --ink:        #0E1A2B;
  --ink-2:      #16263A;
  --ink-3:      #1F344C;
  --paper:      #F2EFE8;
  --card:       #FFFFFF;
  --card-2:     #FAF8F4;
  --seal:       #C9A24B;
  --seal-deep:  #8A6A2F;
  --verify:     #0F6E63;
  --verify-soft:#E4F0EE;
  --text:       #16212E;
  --muted:      #6B7785;
  --line:       #E4DFD4;
  --line-2:     #EFEBE2;
  --danger:     #A63A2E;
  --danger-soft:#FBEAE7;
  --warn:       #9A6B12;
  --warn-soft:  #FBF2DF;

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 22px;
  --shadow-1: 0 1px 2px rgba(14,26,43,.05), 0 8px 24px -14px rgba(14,26,43,.18);
  --shadow-2: 0 2px 6px rgba(14,26,43,.06), 0 24px 60px -28px rgba(14,26,43,.35);
  --side-w: 258px;

  --font-display: 'Zain', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;
}

html[data-theme="dark"] {
  --ink:        #071018;
  --ink-2:      #0D1B29;
  --ink-3:      #16293D;
  --paper:      #070E16;
  --card:       #0F1C29;
  --card-2:     #132433;
  --text:       #E7EDF4;
  --muted:      #92A3B5;
  --line:       #1D3247;
  --line-2:     #17293A;
  --seal:       #D8B461;
  --verify:     #2E9C8E;
  --verify-soft:#0F2C2A;
  --danger:     #E2705F;
  --danger-soft:#2B1512;
  --warn:       #D9AB50;
  --warn-soft:  #2A2114;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -18px rgba(0,0,0,.8);
  --shadow-2: 0 2px 8px rgba(0,0,0,.5), 0 30px 70px -30px rgba(0,0,0,.9);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.25;
  margin: 0;
}

a { color: var(--verify); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
  border-radius: 4px;
}

.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ============================ الواجهة العامة ============================ */

.public-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.public-head {
  background: var(--ink);
  color: #fff;
  padding: 18px 0;
  position: relative;
  overflow: hidden;
  border-bottom: 3px solid var(--seal);
}
.public-head::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 12% 120%, rgba(201,162,75,.16), transparent 45%),
                    radial-gradient(circle at 88% -30%, rgba(15,110,99,.22), transparent 45%);
  pointer-events: none;
}
.public-head .inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.crest {
  display: flex;
  align-items: center;
  gap: 13px;
}
.crest .mark {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border: 1.5px solid var(--seal);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--seal);
}
.crest .mark svg { width: 22px; height: 22px; }
.crest b { font-family: var(--font-display); font-size: 20px; font-weight: 700; display: block; }
.crest span { color: #9FB0C4; font-size: 12.5px; display: block; margin-top: -2px; }

.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 720px; }

.public-main { flex: 1; padding: 46px 0 60px; }

.public-foot {
  border-top: 1px solid var(--line);
  padding: 20px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ------- الشعار البصري: الوثيقة ------- */
.doc {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.doc-guilloche {
  position: absolute;
  inset: 0;
  opacity: .5;
  pointer-events: none;
}
html[data-theme="dark"] .doc-guilloche { opacity: .3; }

.doc-body { position: relative; z-index: 1; padding: 30px; }

.doc-eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .16em;
  color: var(--seal-deep);
  text-transform: uppercase;
  margin-bottom: 8px;
}
html[data-theme="dark"] .doc-eyebrow { color: var(--seal); }

.doc-title { font-size: 30px; }
.doc-lead { color: var(--muted); margin: 10px 0 0; max-width: 46ch; }

/* شريط القراءة الآلية */
.mrz {
  background: var(--ink);
  color: var(--seal);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: .32em;
  padding: 15px 20px;
  text-align: center;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid rgba(201,162,75,.35);
}
.mrz::-webkit-scrollbar { display: none; }
.mrz b { color: #fff; letter-spacing: .32em; font-weight: 500; }

/* ------- نموذج الاستعلام ------- */
.lookup { margin-top: 22px; }
.lookup-row { display: flex; gap: 12px; flex-wrap: wrap; }
.lookup-row .field { flex: 1 1 260px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--muted);
  padding: 8px 15px;
  border-radius: 999px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: .18s;
}
.tab:hover { border-color: var(--seal); color: var(--text); }
.tab[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ------- الختم: بطاقة النتيجة ------- */
.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px dashed var(--line);
}
.result-head > *:first-child { min-width: 0; flex: 1 1 240px; }
.result-name { font-size: 25px; overflow-wrap: anywhere; }
.doc-title { overflow-wrap: anywhere; }
.track li { overflow-wrap: anywhere; }
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 2px 18px;
  margin-top: 22px;
}
.kv { padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.kv dt { font-size: 11.5px; color: var(--muted); letter-spacing: .06em; margin: 0 0 2px; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

.seal-badge {
  flex: 0 0 auto;
  width: 104px; height: 104px;
  border: 2px solid var(--seal);
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--seal-deep);
  transform: rotate(-7deg);
  position: relative;
}
html[data-theme="dark"] .seal-badge { color: var(--seal); }
.seal-badge::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px dashed var(--seal);
  border-radius: 50%;
  opacity: .6;
}
.seal-badge .pct { font-family: var(--font-mono); font-size: 25px; font-weight: 600; line-height: 1; }
.seal-badge .lbl { font-size: 10.5px; letter-spacing: .1em; margin-top: 3px; }

/* ------- خط الزمن على شكل أختام ------- */
.track { margin: 30px 0 0; padding: 0; list-style: none; position: relative; }
.track li {
  position: relative;
  padding: 0 62px 26px 0;
  min-height: 52px;
}
.track li:last-child { padding-bottom: 0; }
.track li::before {           /* الخط الواصل */
  content: "";
  position: absolute;
  top: 46px; bottom: -2px;
  right: 21px;
  width: 2px;
  background: var(--line);
}
.track li:last-child::before { display: none; }
.track li.done::before { background: var(--verify); opacity: .45; }

.st-mark {
  position: absolute;
  top: 0; right: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--muted);
  transform: rotate(-6deg);
  transition: .2s;
}
.st-mark svg { width: 19px; height: 19px; }

.track li.pending .st-mark { border-style: dashed; }
.track li.done .st-mark {
  border-color: var(--verify);
  color: var(--verify);
  background: var(--verify-soft);
  box-shadow: inset 0 0 0 1px rgba(15,110,99,.25);
}
.track li.current .st-mark {
  border-color: var(--seal);
  color: var(--seal-deep);
  background: var(--card);
  transform: rotate(0deg) scale(1.04);
  box-shadow: 0 0 0 5px rgba(201,162,75,.16);
  animation: sealPulse 2.6s ease-in-out infinite;
}
html[data-theme="dark"] .track li.current .st-mark { color: var(--seal); }

@keyframes sealPulse {
  0%, 100% { box-shadow: 0 0 0 5px rgba(201,162,75,.16); }
  50%      { box-shadow: 0 0 0 11px rgba(201,162,75,0); }
}

.st-title { font-weight: 600; font-size: 16px; }
.track li.pending .st-title { color: var(--muted); font-weight: 500; }
.st-desc { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.st-note {
  margin-top: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
  background: rgba(201, 162, 75, .08);
  border-right: 3px solid var(--seal);
  border-radius: 4px 10px 10px 4px;
}
.st-note-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--seal-deep);
  border: 1px solid var(--seal);
  border-radius: 999px;
  padding: 1px 8px;
  margin-inline-end: 7px;
  vertical-align: 1px;
}
li.pending .st-note { opacity: .72; }
.st-time { font-family: var(--font-mono); font-size: 12px; color: var(--verify); margin-top: 4px; }
.st-now {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--seal-deep);
  border: 1px solid var(--seal);
  border-radius: 999px;
  padding: 1px 9px;
  margin-inline-start: 8px;
  vertical-align: middle;
}
html[data-theme="dark"] .st-now { color: var(--seal); }

/* ============================ عناصر مشتركة ============================ */

.field { margin-bottom: 15px; }
.field > label, .lbl {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.req::after { content: " *"; color: var(--danger); font-weight: 700; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.inp, .sel, .ta {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
}
.ta { min-height: 92px; resize: vertical; }
.inp:hover, .sel:hover, .ta:hover { border-color: #C9C2B4; }
.inp:focus, .sel:focus, .ta:focus {
  outline: none;
  border-color: var(--verify);
  box-shadow: 0 0 0 3.5px rgba(15,110,99,.13);
}
.inp[readonly] { background: var(--card-2); color: var(--muted); }
.inp.big {
  font-family: var(--font-mono);
  font-size: 19px;
  letter-spacing: .14em;
  text-align: center;
  padding: 15px 13px;
}
.sel {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7785' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 34px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s, filter .18s, background .18s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.14); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn-gold { background: var(--seal); border-color: var(--seal); color: #1A1305; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--muted); filter: none; background: var(--card-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { color: var(--verify); border-color: rgba(15,110,99,.35); background: var(--verify-soft); }
.badge.gold { color: var(--seal-deep); border-color: var(--seal); background: var(--warn-soft); }
html[data-theme="dark"] .badge.gold { color: var(--seal); }
.badge.bad { color: var(--danger); border-color: rgba(166,58,46,.3); background: var(--danger-soft); }
.badge.pass { color: #2C4A73; border-color: #C3D2E6; background: #EDF2F9; }
html[data-theme="dark"] .badge.pass { color: #9CC0EE; border-color: #23405F; background: #10243A; }

.alert {
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--muted);
  background: var(--card-2);
  border-radius: var(--r-sm);
  padding: 13px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert.ok { border-inline-start-color: var(--verify); background: var(--verify-soft); }
.alert.bad { border-inline-start-color: var(--danger); background: var(--danger-soft); }
.alert.warn { border-inline-start-color: var(--seal); background: var(--warn-soft); }
.alert b { display: block; margin-bottom: 2px; }

/* ============================ لوحة التحكم ============================ */

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

.side {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: var(--ink);
  color: #C9D5E2;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side .crest b { color: #fff; font-size: 17.5px; }
.side .crest .mark { width: 36px; height: 36px; flex-basis: 36px; }
.side .crest .mark svg { width: 19px; height: 19px; }

.nav-group { margin-bottom: 14px; }
.nav-group > span {
  display: block;
  font-size: 10.5px;
  letter-spacing: .16em;
  color: #64798F;
  padding: 0 12px 8px;
  font-weight: 600;
}
.side nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9.5px 12px;
  border-radius: 10px;
  color: #C9D5E2;
  font-size: 14px;
  font-weight: 500;
  transition: .15s;
  margin-bottom: 2px;
}
.side nav a svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .8; }
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side nav a.on {
  background: rgba(201,162,75,.14);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--seal);
}
.side nav a.on svg { opacity: 1; color: var(--seal); }
.side nav a .count {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 1px 8px;
}
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding-top: 14px; font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot .role { color: #7C90A6; font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 13px 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 20px; }
.topbar .grow { flex: 1; }
.icon-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: .15s;
  flex: 0 0 38px;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.icon-btn svg { width: 18px; height: 18px; }
.burger { display: none; }

.content { padding: 26px; flex: 1; }
.content > .display { margin-bottom: 18px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  margin-bottom: 22px;
  overflow: hidden;
}
.panel-h {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--card-2);
}
.panel-h h2 { font-size: 17px; }
.panel-h .grow { flex: 1; }
.panel-b { padding: 20px; }
.panel-b.tight { padding: 0; }

hr.sep { border: 0; border-top: 1px dashed var(--line); margin: 20px 0; }

.radio-row { display: flex; flex-wrap: wrap; gap: 12px; }
.radio-card {
  flex: 1 1 260px;
  display: block;
  cursor: pointer;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  transition: border-color .15s, background .15s;
}
.radio-card b { display: block; margin: 6px 0 4px; font-size: 15px; }
.radio-card span { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.65; }
.radio-card:hover { border-color: var(--seal); }
.radio-card.on { border-color: var(--seal); background: rgba(201, 162, 75, .07); }
.radio-card input[disabled] ~ b,
.radio-card input[disabled] ~ span { opacity: .5; }
.radio-card:has(input[disabled]) { cursor: not-allowed; opacity: .72; }

.grid { display: grid; gap: 18px; }
/* شبكة لوحين: المحتوى الرئيسي + جانب. تنهار إلى عمود واحد على الشاشات
   المتوسطة والصغيرة بدل إجبار عمودين لا يتّسع لهما العرض فيتراكبان */
.split-2 { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); align-items: start; }
@media (max-width: 900px) {
  .split-2 { grid-template-columns: 1fr; }
}
.g-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 17px 19px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.stat .t { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .v {
  font-family: var(--font-mono);
  font-size: 29px;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 4px;
}
.stat .d { font-size: 12px; color: var(--muted); }
.stat::after {
  content: "";
  position: absolute;
  inset-inline-start: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--seal);
}
.stat.teal::after { background: var(--verify); }
.stat.navy::after { background: var(--ink-3); }
.stat.red::after { background: var(--danger); }

/* ------- الجداول ------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--line-2); }
.tbl th {
  background: var(--card-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .03em;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.tbl tbody tr:hover { background: var(--card-2); }
.tbl td.acts { white-space: nowrap; }
.tbl .strong { font-weight: 600; }
.tbl .trk { font-family: var(--font-mono); font-size: 13px; letter-spacing: .05em; }

.act {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--card);
  margin-inline-start: 4px;
  transition: .15s;
  cursor: pointer;
}
.act:hover { color: var(--text); border-color: var(--muted); text-decoration: none; }
.act.gold:hover { color: var(--seal-deep); border-color: var(--seal); }
.act.red:hover { color: var(--danger); border-color: var(--danger); }
.act svg { width: 16px; height: 16px; }

.empty { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: .35; margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

.pager { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; padding: 15px 20px; border-top: 1px solid var(--line); }
.pager a, .pager span {
  min-width: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--muted);
}
.pager a:hover { border-color: var(--muted); color: var(--text); text-decoration: none; }
.pager .on { background: var(--ink); border-color: var(--ink); color: #fff; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 150px; flex: 1 1 150px; }
.filters .field.wide { flex: 2 1 240px; }

/* ------- تسجيل الدخول ------- */
.login-page {
  min-height: 100vh;
  display: flex;
  display: grid;
  align-items: center;
  justify-content: center;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(15,110,99,.18), transparent 42%),
    radial-gradient(circle at 85% 90%, rgba(201,162,75,.14), transparent 42%),
    var(--ink);
}
.login-card {
  width: 100%;
  max-width: 860px;
  display: flex;
  align-items: stretch;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  position: relative;
}
.login-brand { flex: 1.05 1 0; }
.login-main  { flex: 1 1 0; }

/* اللوح التعريفي (يمين في RTL) */
.login-brand {
  position: relative;
  background:
    radial-gradient(circle at 80% 10%, rgba(201,162,75,.22), transparent 55%),
    linear-gradient(155deg, var(--ink-2), var(--ink));
  color: #EAF0F6;
  padding: 44px 36px;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.login-brand .doc-guilloche { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; }
.login-brand-in { position: relative; z-index: 1; }
.login-crest {
  display: grid; place-items: center;
  width: 58px; height: 58px;
  border-radius: 16px;
  background: rgba(201,162,75,.16);
  border: 1px solid rgba(201,162,75,.4);
  margin-bottom: 20px;
}
.login-crest svg { width: 30px; height: 30px; color: var(--seal); }
.login-brand-in > b {
  display: block;
  font-family: var(--font-display);
  font-size: 25px;
  line-height: 1.35;
  color: #fff;
}
.login-tag { display: block; color: #9FB0C4; font-size: 14px; margin-top: 8px; line-height: 1.7; }
.login-brand-foot {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 28px; padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  color: #8DA0B6; font-size: 12.5px;
}
.login-brand-foot svg { width: 15px; height: 15px; color: var(--seal); }

/* لوح النموذج (يسار في RTL) */
.login-main { padding: 44px 40px; display: flex; flex-direction: column; justify-content: center; min-height: 430px; }
.login-head { margin-bottom: 24px; }
.login-head b { display: block; font-family: var(--font-display); font-size: 23px; color: var(--ink); }
.login-head span { display: block; color: var(--muted); font-size: 13.5px; margin-top: 5px; }
.login-main .field { margin-bottom: 16px; }
.login-main .btn-block { margin-top: 8px; padding-block: 13px; }

@media (max-width: 720px) {
  .login-card { flex-direction: column; max-width: 420px; }
  .login-brand, .login-main { flex: 0 0 auto; }
  .login-brand { padding: 30px 30px 26px; }
  .login-crest { width: 48px; height: 48px; margin-bottom: 14px; }
  .login-crest svg { width: 25px; height: 25px; }
  .login-brand-in > b { font-size: 21px; }
  .login-brand-foot { display: none; }
  .login-main { padding: 28px 28px 30px; min-height: 0; }
}

/* ------- المفاتيح ------- */
/* ------- حقل التاريخ ------- */
.date-inp {
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: .09em;
  text-align: center;
}
.date-inp::placeholder { font-family: var(--font-body); font-size: 14px; letter-spacing: 0; }
.warn-inp { border-color: var(--seal); box-shadow: 0 0 0 3.5px rgba(201,162,75,.16); }

.ui-sig {
  text-align: center;
  padding: 14px 16px 20px;
  font-size: 12px;
  color: var(--muted);
  opacity: .78;
}
.ui-sig a { color: inherit; text-decoration: none; }
.ui-sig a:hover { color: var(--seal-deep); text-decoration: underline; }
@media print { .ui-sig { display: none !important; } }

.switch-stack { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 18px; align-items: flex-start; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
/* داخل .field ترث الوسوم label قاعدة display:block الأقوى تخصيصًا، فتنهار
   بنية flex ويقع زرّ المفتاح فوق النص — هذه القاعدة تستعيدها وتحاذيها
   بارتفاع الحقول المجاورة */
.field > label.switch {
  display: inline-flex;
  min-height: 43px;
  margin: 0;
  font-size: 14.5px;
  font-weight: 400;
  line-height: 1.5;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch > span:not(.track-sw) { flex: 1 1 auto; min-width: 0; }
.switch .track-sw {
  width: 44px; height: 25px;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  transition: .2s;
  flex: 0 0 44px;
}
.switch .track-sw::after {
  content: "";
  position: absolute;
  top: 3px; right: 3px;
  width: 19px; height: 19px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .track-sw { background: var(--verify); }
.switch input:checked + .track-sw::after { right: 22px; }
.switch input:focus-visible + .track-sw { outline: 2px solid var(--seal); outline-offset: 2px; }

/* ------- المشروط (Modal) ------- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(8,14,22,.55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 90;
}
.modal {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow-2);
  width: 100%;
  max-width: 470px;
  overflow: hidden;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }

/* ------- التنبيهات العائمة ------- */
.toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 120; display: grid; gap: 9px; }
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 17px;
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  font-size: 14px;
  border-inline-start: 3px solid var(--seal);
  animation: slidein .22s ease-out;
  max-width: 360px;
}
.toast.ok { border-inline-start-color: var(--verify); }
.toast.bad { border-inline-start-color: var(--danger); }
@keyframes slidein { from { transform: translateX(-16px); opacity: 0; } }

/* ------- سجل الحركات ------- */
.log-row { display: flex; gap: 13px; padding: 13px 20px; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.log-row:last-child { border-bottom: 0; }
.log-dot {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.log-dot svg { width: 15px; height: 15px; }
.log-main { min-width: 0; flex: 1; }
.log-main b { font-weight: 600; }
.log-meta { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }

/* ------- قابلية الوصول والحركة ------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------- الاستجابة ------- */
@media (max-width: 1024px) {
  .side {
    /* لا نستخدم inset-inline-end هنا: في RTL تعني الحافة اليسرى، فينزلق
       الشريط إلى وسط الشاشة فوق المحتوى بدل أن يختفي خارجها */
    position: fixed;
    right: 0;
    left: auto;
    top: 0;
    bottom: 0;
    height: 100%;
    max-width: 86vw;
    z-index: 60;
    transform: translateX(100%);
    transition: transform .22s ease-out;
    box-shadow: var(--shadow-2);
  }
  body.nav-open .side { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(8,14,22,.5);
    z-index: 50;
  }
  .burger { display: grid; }
  .content, .topbar { padding-inline: 18px; }
  /* الجداول العريضة تنزلق أفقيًا بدل أن تمدّ الصفحة كلها */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 620px; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .content, .topbar { padding: 16px; }
  /* الجدول ينزلق أفقيًا بعرض كافٍ بدل أن تتراكب الأعمدة */
  .tbl { min-width: 860px; }
  .tbl th, .tbl td { white-space: nowrap; padding: 10px; }
  .tbl .cell-wrap { white-space: normal; min-width: 190px; }
  .tbl-wrap { margin-inline: -16px; padding-inline: 16px; }
  /* الأشرطة العلوية ورؤوس اللوحات تلتفّ بدل أن تتزاحم */
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar h1 { font-size: 17px; }
  .panel-h { flex-wrap: wrap; row-gap: 10px; }
  .panel-h .grow { flex: 1 1 100%; }
  /* حقول التصفية عمودًا واحدًا */
  .filters .field, .filters .field.wide { flex: 1 1 100%; min-width: 0; }
  .filters { flex-direction: column; align-items: stretch; }
  .radio-row { flex-direction: column; }
  .doc-body { padding: 22px 18px; }
  .doc-title { font-size: 24px; }
  .result-head { gap: 14px; }
  .seal-badge { width: 82px; height: 82px; }
  .seal-badge .pct { font-size: 20px; }
  .mrz { font-size: 12px; letter-spacing: .22em; }
  .panel-b { padding: 16px; }
  .stat .v { font-size: 24px; }
}

/* ------- الطباعة ------- */
@media print {
  body { background: #fff; }
  .public-head, .public-foot, .lookup, .no-print, .side, .topbar { display: none !important; }
  .doc { box-shadow: none; border-color: #999; }
  .track li.current .st-mark { animation: none; }
  a[href]::after { content: ""; }
}
