/* سجل الشحنات المرفوضة — هوية «الدفتر البحري» (الإصدار 1.2).
   بلا خطوط أو مكتبات من الإنترنت: الخطوط في fonts.css مضمّنة محليًا (ترخيص SIL OFL).
   لا أنماط مضمّنة في القوالب: سياسة أمن المحتوى تمنعها، فكل التنسيق هنا. */
@import url("fonts.css");

:root {
  --bg: #F7F5F0;            /* ورق */
  --paper: #FFFFFF;
  --ink: #182230;           /* حبر */
  --muted: #5B6775;
  --line: #D9DEE5;
  --line-soft: #EEF1F4;
  --line-strong: #C9D2DE;
  --soft: #F7F5F0;
  --soft-2: #EEF1F4;
  --accent: #1F3A5F;        /* لازورد */
  --accent-hover: #162C49;
  --accent-soft: #E6ECF4;
  --brass: #8A6D2F;         /* نحاس: العبارة وما يُسجَّل الآن */
  --brass-soft: #F4EEDF;
  --brass-line: #E3D3A6;
  --on-accent-muted: #D4DCE8;
  --bar: #1F3A5F;
  --strong: #B3261E;        /* تطابق قوي */
  --strong-ink: #8E1E17;
  --strong-bg: #FBECEA;
  --strong-line: #EBB8B3;
  --partial: #C98A1B;       /* يتطلب تحققًا */
  --partial-ink: #7A4A00;
  --partial-bg: #FFF4E0;
  --partial-line: #EFD39A;
  --ok: #2A6B4D;
  --ok-ink: #1F4D37;
  --ok-bg: #E7F3EC;
  --ok-line: #BFE0CC;
  --info: #2F5A86;
  --info-bg: #E9F0F8;
  --info-line: #BCD0EE;
  --focus: #D9B45A;
  --radius: 16px;
  --radius-sm: 10px;
  --font: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --display: "Alexandria", "IBM Plex Sans Arabic", "Segoe UI", sans-serif;
  --tagline: "Aref Ruqaa", "Amiri", "Noto Naskh Arabic", serif;
  --mono: "IBM Plex Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html { direction: rtl; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { line-height: 1.3; margin: 0; }
h1 { font-family: var(--display); font-weight: 800; font-size: 1.9rem; line-height: 1.25; color: var(--accent); }
h2 { font-family: var(--display); font-weight: 700; font-size: 1.25rem; }
h3 { font-weight: 700; font-size: 1.06rem; }
p { margin: 0; }
.icon { flex: 0 0 auto; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- الشريط العلوي */
.trial-banner { background: #B45309; color: #fff; text-align: center; padding: 6px 12px; font-weight: 600; font-size: .9rem; }
.topbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; padding: 10px 0; min-width: 0; }
.brand:hover { color: inherit; }
.brand-mark { display: flex; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 1.125rem; color: var(--accent); }
.brand-sub { font-family: var(--tagline); font-weight: 700; font-size: 1.1rem; line-height: 1.35; color: var(--brass); }
.brand-ver { font-size: .7rem; color: var(--muted); }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.nav-link:hover { background: var(--soft-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-cta {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 700; margin-inline-start: 4px;
}
.nav-cta:hover { background: var(--accent-hover); color: #fff; }
.nav-cta[aria-current="page"] { box-shadow: 0 0 0 3px var(--accent-soft); }
.who { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; padding: 10px 0; flex-wrap: wrap; }
.who form { margin: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.who-text { display: flex; flex-direction: column; line-height: 1.3; }
.who-name { font-weight: 600; font-size: .875rem; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.who-port { font-size: .75rem; color: var(--muted); }
.role-tag {
  font-size: .7rem; font-weight: 700; background: var(--brass-soft); color: var(--brass); border: 1px solid var(--brass-line);
  border-radius: 999px; padding: 1px 8px;
}
.linkbtn {
  font: inherit; font-size: .875rem; font-weight: 600; color: var(--accent); background: transparent;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 12px; min-height: 40px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center;
}
.linkbtn:hover { background: var(--soft-2); }
.linkbtn[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent-soft); }

main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 64px; display: flex; flex-direction: column; gap: 24px; }

/* ---------- عناصر عامة */
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; gap: 20px; min-width: 0;
}
.panel > * { min-width: 0; }
.lead { color: var(--muted); }
.page-head { display: flex; flex-direction: column; gap: 6px; }
.page-head p { color: var(--muted); }
.page-head-row { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: .875rem; }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: .875rem; color: var(--muted); }
.note .icon { margin-top: 3px; }
.push-start { margin-inline-start: auto; }
.divider { height: 1px; background: var(--line-soft); border: 0; margin: 0; }
.block { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.section-label { font-size: .8125rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }

.flash {
  display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 12px;
  background: var(--info-bg); border: 1px solid var(--info-line); color: var(--accent);
}
.flash .icon { color: var(--info); margin-top: 3px; }
.flash.error { background: var(--strong-bg); border-color: var(--strong-line); color: var(--strong-ink); }
.flash.error .icon { color: var(--strong); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--accent);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--soft-2); color: var(--accent-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn.large { min-height: 52px; padding: 0 28px; font-size: 1.03rem; }
.btn.block { width: 100%; }
.btn.danger { border: 1.5px solid var(--strong-line); color: var(--strong); }
.btn.danger:hover { background: var(--strong-bg); color: var(--strong); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* ---------- الحقول */
label { font-weight: 600; font-size: .9rem; }
.req::after { content: " *"; color: var(--strong); }
.optional { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], select, textarea {
  font: inherit;
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
}
input[type=text]:hover, input[type=password]:hover, select:hover, textarea:hover { border-color: #9AA8B8; }
input[type=text]:focus, input[type=password]:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field .error, .reasons-set .error { color: var(--strong); font-size: .875rem; font-weight: 600; }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--strong); background: #FFFBFA; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.row > .field { flex: 1 1 240px; }
.row.end { align-items: flex-end; }

/* الأرقام المرجعية تُكتب من اليسار إلى اليمين داخل نص عربي دون انعكاس
   (بعد قواعد الحقول حتى لا يلغي font: inherit الخط الثابت العرض) */
.id, input.id {
  font-family: var(--mono);
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
input.id { text-align: left; font-size: 1.03rem; }

/* لصق سطر من «تبادل» وفرزه إلى الحقول (يعمل بلا JavaScript كحقل عادي، ومع JavaScript يفرز) */
.paste-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.paste-row input { flex: 999 1 360px; min-height: 48px; }
.paste-row .btn { flex: 0 0 auto; }
.paste-note { display: none; }
.paste-row[data-ready] + .paste-note { display: flex; }
.paste-row:not([data-ready]) .btn { display: none; }

/* ---------- البحث */
.search-form { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.search-form .field { flex: 1 1 220px; }
.search-form .field.wide { flex: 1 1 100%; }
.search-form input { min-height: 50px; font-size: 1.06rem; }
.search-form .btn { flex: 0 0 auto; }

.results { display: flex; flex-direction: column; gap: 16px; }
.results-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.result-summary { color: var(--muted); font-size: .95rem; }
.disclaimer { display: flex; gap: 8px; align-items: flex-start; font-size: .875rem; color: var(--muted); }
.disclaimer .icon { margin-top: 3px; }

/* الحكم: أيقونة + عنوان + شرح */
.verdict-icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.verdict-text { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.verdict-text p { color: var(--muted); font-size: .95rem; }
.verdict-none {
  display: flex; flex-wrap: wrap; gap: 16px 20px; align-items: center; padding: 24px;
  border-radius: var(--radius); border: 1px solid var(--ok-line); background: var(--ok-bg);
}
.verdict-none .verdict-icon { background: var(--ok); }
.verdict-none h3 { font-size: 1.25rem; color: var(--ok-ink); }
.verdict-none p { color: var(--ok-ink); }
.verdict-none .btn { border-color: var(--ok-line); }

/* ---------- بطاقة الشحنة */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
}
.card.strong { border-color: var(--strong-line); box-shadow: inset 6px 0 0 var(--strong); }
.card.partial { border-color: var(--partial-line); box-shadow: inset 6px 0 0 var(--partial); }
.card.importer { border-color: var(--info-line); box-shadow: inset 6px 0 0 var(--info); }
.card-head {
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-start; padding: 20px 24px;
  border-bottom: 1px solid var(--line-soft);
}
.card.strong .verdict-icon { background: var(--strong); }
.card.partial .verdict-icon { background: var(--partial); }
.card.importer .verdict-icon { background: var(--info); }
.level {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  font-size: .8125rem; font-weight: 700; padding: 4px 10px; border-radius: 8px;
}
.level.strong { background: var(--strong-bg); color: var(--strong-ink); }
.level.partial { background: var(--partial-bg); color: var(--partial-ink); }
.level.importer { background: var(--info-bg); color: var(--info); }
.verdict-title { font-size: 1.25rem; line-height: 1.35; }
.match-reason { color: var(--ink); }
.why { display: flex; flex-direction: column; gap: 2px; }
.ports {
  align-self: flex-start; font-size: .875rem; color: var(--muted); background: var(--soft);
  border: 1px solid var(--line); border-radius: 8px; padding: 2px 10px;
}
.ports.other, .ports.multi { border-color: var(--strong-line); color: var(--strong-ink); font-weight: 700; background: var(--strong-bg); }
.card.importer .ports.other, .card.importer .ports.multi { border-color: var(--info-line); color: var(--info); background: var(--info-bg); }
/* عدد مرات الرفض: رقم كبير بخط العناوين */
.tally {
  margin-inline-start: auto; text-align: center; min-width: 140px;
  background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px;
  font-size: .8125rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px;
}
.tally b { font-family: var(--display); font-weight: 800; font-size: 1.75rem; line-height: 1.1; color: var(--accent); }
.card.strong .tally b { color: var(--strong); }
.card.partial .tally b { color: var(--partial-ink); }
.card.importer .tally b { color: var(--info); }
.card-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 22px; }
.card-body > * { min-width: 0; }
.card-foot {
  display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-top: 1px solid var(--line-soft); background: var(--soft);
}

/* اسم مستورد مختلف لنفس الشحنة */
.importer-alert {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px;
  background: var(--strong-bg); border: 1px solid var(--strong-line);
}
.importer-alert .icon { color: var(--strong); margin-top: 2px; }
.importer-alert > div { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.importer-alert strong { color: var(--strong-ink); }
.names { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; font-size: .875rem; }
.names li { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; }
.names li.changed-name { border: 1.5px solid var(--strong); color: var(--strong); font-weight: 700; }

/* مقارنة الأرقام: صف لكل حقل */
.cmp { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cmp li {
  display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 2fr) minmax(170px, 1fr); gap: 4px 16px;
  align-items: center; padding: 10px 14px; border-top: 1px solid var(--line-soft); font-size: .9rem;
}
.cmp li:first-child { border-top: 0; }
.cmp-label { color: var(--muted); font-size: .8125rem; }
.cmp-value { font-size: 1rem; overflow-wrap: anywhere; }
.cmp-state { display: flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 600; color: var(--muted); }
.cmp li.match { background: #F3FAF5; }
.cmp li.match .cmp-state { color: var(--ok); }
.cmp li.differs { background: #FFF8F7; }
.cmp li.differs .cmp-state { color: var(--strong); }
@media (max-width: 640px) { .cmp li { grid-template-columns: minmax(0, 1fr); } }

/* رحلة الشحنة بين المنافذ: خط محطات أفقي */
.journey { list-style: none; margin: 0; padding: 4px 0 8px; display: flex; overflow-x: auto; }
.journey > li { flex: 1 1 240px; min-width: 240px; position: relative; padding: 32px 8px 0; display: flex; flex-direction: column; gap: 0; }
.journey > li::before { content: ""; position: absolute; top: 13px; right: 0; left: 0; height: 2px; background: var(--line-strong); }
.journey > li:first-child::before { right: 50%; }
.journey > li:last-child::before { left: 50%; }
.step-top { position: absolute; top: 0; right: 0; left: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.step-no {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: .8125rem;
  display: flex; align-items: center; justify-content: center; border: 3px solid var(--paper); box-shadow: 0 0 0 2px var(--line-strong);
  position: relative; z-index: 1; margin-top: -2px;
}
.card.strong .step-no { box-shadow: 0 0 0 2px var(--strong-line); }
.journey > li.hit .step-no { box-shadow: 0 0 0 2px var(--strong); }
.journey > li.now .step-no { background: var(--brass); box-shadow: 0 0 0 2px var(--brass); }
.step-date { font-size: .8125rem; position: absolute; top: 34px; opacity: 0; pointer-events: none; }
.step-card {
  margin-top: 8px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px; font-size: .875rem; flex: 1 1 auto;
}
.journey > li.now .step-card { background: #FBF8EF; border-color: var(--brass-line); }
.step-port { font-size: 1rem; }
.step-when { color: var(--muted); font-size: .8125rem; }
.step-when a { color: inherit; }
.reason-chip { font-size: .8125rem; font-weight: 500; background: var(--soft-2); border-radius: 8px; padding: 2px 8px; }
.step-comment { font-size: .875rem; color: var(--ink); border-inline-start: 3px solid var(--line); padding: 2px 10px; background: var(--paper); border-radius: 0 8px 8px 0; }
.step-ids { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 10px; font-size: .8125rem; }
.step-ids dt { color: var(--muted); }
.step-ids dd { margin: 0; overflow-wrap: anywhere; }
.step-importer { font-size: .875rem; }
.changed { color: var(--strong); font-weight: 700; }
.step-officer { font-size: .8125rem; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 6px; }
.hit-tag {
  align-self: flex-start; font-size: .75rem; font-weight: 700; color: var(--strong);
  border: 1.5px solid var(--strong); border-radius: 999px; padding: 0 8px;
}

/* ---------- التسجيل */
.auto-info {
  display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding: 10px 14px;
  background: var(--soft); border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: .875rem;
}
.auto-info strong { color: var(--ink); }
.auto-info span { display: inline-flex; align-items: center; gap: 6px; }
.register-form { display: flex; flex-direction: column; gap: 20px; }
.form-panel { gap: 0; padding-top: 8px; padding-bottom: 8px; }
.form-step { border: 0; margin: 0; padding: 20px 0; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.form-step + .divider { display: none; }
.form-step + .divider + .form-step, .form-step + .divider + .form-step-wrap, .form-step-wrap { border-top: 1px solid var(--line-soft); }
.form-step-wrap { padding: 20px 0; display: flex; flex-direction: column; gap: 14px; }
.step-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.06rem; padding: 0; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: .875rem; font-weight: 700; flex: 0 0 auto;
}
.reasons-set { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.reason-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.reason-option {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 42px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper); font-weight: 500; font-size: .95rem;
}
.reason-option:hover { background: var(--soft-2); }
.reason-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: 0 0 auto; }
.reason-option:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.reason-option:has(input:checked) input { accent-color: #fff; }
.reasons-set.invalid .reason-option { border-color: var(--strong-line); }
.form-bar { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }
.form-bar .hint { flex: 1 1 380px; }

/* سؤال قبل الحفظ عند تطابق رقم واحد */
.warn-panel {
  background: var(--paper); border: 1px solid var(--partial-line); border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; gap: 20px; box-shadow: inset 6px 0 0 var(--partial);
}
.warn-panel > * { min-width: 0; }
.alert-head { display: flex; gap: 14px; align-items: flex-start; }
.alert-head > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.alert-icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--partial); color: #fff;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.alert-head h2 { font-size: 1.25rem; color: var(--partial-ink); }
.alert-head p { color: var(--muted); }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.choice {
  display: flex; gap: 14px; align-items: flex-start; text-align: start; padding: 18px; border-radius: 14px;
  border: 2px solid var(--line-strong); background: var(--paper); color: var(--ink); font: inherit; cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.choice.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.choice-text { display: flex; flex-direction: column; gap: 2px; }
.choice-title { font-size: 1.06rem; font-weight: 700; }
.choice-desc { font-size: .875rem; color: var(--muted); }
.choice.primary .choice-desc { color: var(--on-accent-muted); }
.cancel-link { align-self: flex-start; min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; }
.block-panel {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius);
  background: var(--strong-bg); border: 1px solid var(--strong-line); color: var(--strong-ink);
}
.block-panel .icon { color: var(--strong); margin-top: 3px; }
.prefill-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--info-bg); border: 1px solid var(--info-line); color: var(--accent); font-size: .9rem; }
.prefill-note .icon { color: var(--info); margin-top: 3px; }

/* ---------- التفاصيل */
.crumbs { font-size: .875rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs [aria-current] { color: var(--ink); }
.detail-head { display: flex; gap: 12px 14px; align-items: center; flex-wrap: wrap; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 700;
  border-radius: 8px; padding: 4px 10px;
}
.tag.final { color: var(--ink); background: var(--soft-2); }
.tag.count { color: var(--info); background: var(--info-bg); }
.tag.count.repeat { color: var(--strong-ink); background: var(--strong-bg); }
.void-tag { color: var(--muted); border: 1.5px dashed var(--muted); border-radius: 999px; padding: 2px 10px; font-size: .85rem; }
.void-banner { border: 2px dashed var(--muted); border-radius: var(--radius); padding: 14px 18px; background: var(--soft-2); }
.detail-grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.detail-main { flex: 999 1 560px; }
.detail-side { flex: 1 1 340px; padding: 24px; }
.id-cells { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.id-cells > div { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.id-cells dt { font-size: .8125rem; color: var(--muted); }
.id-cells dd { margin: 0; font-size: 1.06rem; overflow-wrap: anywhere; }
.reason-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.reason-chips li { font-size: .9rem; font-weight: 500; background: var(--soft-2); border-radius: 8px; padding: 4px 12px; }
.comment { margin: 0; padding: 10px 14px; border-radius: 0 10px 10px 0; background: var(--soft); border-inline-start: 3px solid var(--line-strong); overflow-wrap: anywhere; }
.comment footer { margin-top: 4px; font-size: .8125rem; color: var(--muted); }
dl.kv { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px 24px; }
dl.kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
dl.kv dt { font-size: .8125rem; color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }

/* كل مرات الرفض: جدول يُعرض كخط زمني عمودي */
table.timeline { width: 100%; border-collapse: collapse; }
table.timeline td { padding: 0; vertical-align: top; }
.tl-marker { width: 44px; position: relative; }
.tl-marker::after { content: ""; position: absolute; top: 28px; bottom: -8px; right: 13px; width: 2px; background: var(--line-strong); }
table.timeline tbody tr:last-child .tl-marker::after { display: none; }
.tl-no {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: .8125rem;
  display: flex; align-items: center; justify-content: center; position: relative; z-index: 1;
}
tr.current .tl-no { background: var(--brass); }
.tl-card {
  margin: 0 0 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px; font-size: .875rem;
}
tr.current .tl-card { background: #FBF8EF; border-color: var(--brass-line); }
.tl-title { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-title strong { font-size: .95rem; }
.tl-meta { color: var(--muted); }
.tl-reasons { font-weight: 600; }
.here-tag { font-size: .75rem; font-weight: 700; color: var(--brass); background: var(--brass-soft); border: 1px solid var(--brass-line); border-radius: 999px; padding: 0 8px; }
.side-note { border-top: 1px solid var(--line-soft); padding-top: 12px; }

.danger-zone { background: var(--paper); border: 1px solid var(--strong-line); border-radius: var(--radius); }
.danger-zone summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 16px 24px;
  font-weight: 700; color: var(--strong); min-height: 44px;
}
.danger-zone summary::-webkit-details-marker { display: none; }
.danger-zone summary .hint { font-weight: 400; }
.danger-zone summary .chev { margin-inline-start: auto; color: var(--muted); transition: transform .15s; }
.danger-zone[open] summary { border-bottom: 1px solid var(--strong-line); }
.danger-zone[open] summary .chev { transform: rotate(180deg); }
.danger-zone form { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 14px; }
.danger-zone .row > .field { flex: 1 1 360px; }

/* ---------- الإحصاء */
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--paper); }
.segmented a {
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 16px;
  color: var(--muted); font-weight: 600; text-decoration: none;
}
.segmented a:hover { background: var(--soft-2); color: var(--ink); }
.segmented a[aria-current="page"] { background: var(--accent); color: #fff; font-weight: 700; }
.value-band {
  background: var(--accent); color: #fff; border-color: var(--accent);
  display: flex; flex-direction: row; flex-wrap: wrap; gap: 20px 32px; align-items: center;
}
.value-band .value-text { flex: 1 1 360px; display: flex; flex-direction: column; gap: 6px; }
.value-band .value-kicker { font-family: var(--display); font-size: .8125rem; font-weight: 500; color: var(--focus); letter-spacing: .02em; }
.value-band .value-title { font-family: var(--display); font-size: 1.5rem; font-weight: 800; line-height: 1.3; }
.value-band .value-sub { font-size: .9rem; color: var(--on-accent-muted); }
.value-band .value-nums { display: flex; gap: 28px; flex-wrap: wrap; }
.value-band .value-num { text-align: center; display: flex; flex-direction: column; }
.value-band .value-num b { font-family: var(--display); font-size: 2.5rem; font-weight: 800; line-height: 1; }
.value-band .value-num span { font-size: .8125rem; color: var(--on-accent-muted); }
.kpi-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.kpi-group { flex: 1 1 340px; padding: 22px 24px; gap: 14px; }
.kpi-group.warn { flex: 1.6 1 520px; border-color: var(--strong-line); }
.kpi-title { font-size: .875rem; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.kpi-group.warn .kpi-title { color: var(--strong); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-family: var(--display); font-size: 2.4rem; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); }
.stat span { font-size: .875rem; color: var(--muted); }
.kpi-group.warn .stat b { color: var(--strong); }
.share { display: flex; flex-direction: column; gap: 6px; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > .panel { flex: 1 1 420px; }
.none { background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: 12px; padding: 14px 16px; color: var(--ok-ink); }

.table-wrap { overflow-x: auto; min-width: 0; border: 1px solid var(--line); border-radius: 12px; }
table.data { width: 100%; min-width: 760px; border-collapse: collapse; font-size: .95rem; }
table.data th {
  text-align: start; padding: 12px 16px; font-size: .8125rem; font-weight: 700;
  color: var(--muted); background: var(--soft); white-space: nowrap;
}
table.data td { text-align: start; padding: 14px 16px; border-top: 1px solid var(--line-soft); vertical-align: top; }
table.data .nowrap, table.data .id { white-space: nowrap; }
table.data td:last-child { min-width: 10em; }
.times { color: var(--strong); }
.port-chip { font-size: .8125rem; background: var(--soft-2); border-radius: 8px; padding: 3px 10px; white-space: nowrap; }
.cross-tag {
  display: inline-block; margin-top: 6px; font-size: .75rem; font-weight: 700; color: var(--strong);
  border: 1.5px solid var(--strong); border-radius: 999px; padding: 0 10px;
}

/* أشرطة التوزيع: العرض بفئات 5% لأن سياسة أمن المحتوى تمنع الأنماط المضمّنة */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8125rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--bar); }
.swatch.danger { background: var(--strong); }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.bars li { display: flex; flex-direction: column; gap: 6px; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: .95rem; }
.bar-num { white-space: nowrap; }
.bar { height: 12px; border-radius: 999px; background: var(--soft-2); overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 999px; display: flex; overflow: hidden; }
.bar-fill.danger, .bar-seg { background: var(--strong); }
.bar-seg { height: 100%; }
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; }
.w-100 { width: 100%; }

/* ---------- الدخول */
.login-wrap { max-width: 460px; width: 100%; margin: 4vh auto 0; display: flex; flex-direction: column; gap: 20px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login-brand .brand-name { font-size: 1.5rem; }
.login-brand .brand-sub { font-size: 1.35rem; }
.login-mark {
  width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}

@media (max-width: 600px) {
  main { padding: 20px 16px 48px; }
  .topbar-inner { padding: 0 16px; }
  .panel { padding: 20px; }
  .card-head, .card-body { padding: 18px; }
  .card-foot { padding: 14px 18px; }
  h1 { font-size: 1.5rem; }
  .brand-sub { display: none; }
  .tally { margin-inline-start: 0; width: 100%; }
}

/* نص صريح بجانب الاسم المختلف: لا نعتمد على اللون وحده */
.changed-note {
  display: inline-block; font-size: .75rem; font-weight: 700; color: var(--strong);
  border: 1.5px solid var(--strong); border-radius: 999px; padding: 0 8px; margin-inline-start: 4px;
}
.name-note { font-size: .75rem; color: var(--muted); font-weight: 400; }
.detail-head + .importer-alert, .void-banner + .importer-alert { margin-bottom: 20px; }

/* جدول الشحنات المعاد إدخالها: على الشاشات الأضيق يصبح كل صف بطاقة بتسميات، بلا تمرير أفقي */
@media (max-width: 1100px) {
  .table-wrap:has(table.data) { overflow-x: visible; }
  table.data { min-width: 0; }
  table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { padding: 10px 0; border-top: 1px solid var(--line-soft); }
  table.data tbody tr:first-child { border-top: 0; }
  table.data td {
    border-top: 0; padding: 6px 16px;
    display: grid; grid-template-columns: 7.5em minmax(0, 1fr); column-gap: 12px; align-items: start;
  }
  table.data td::before {
    content: attr(data-label); grid-column: 1; grid-row: 1 / span 3;
    color: var(--muted); font-size: .8125rem; font-weight: 700;
  }
  table.data td > * { grid-column: 2; }
  table.data td:last-child { min-width: 0; }
  table.data .nowrap { white-space: normal; }
}
