:root {
  /* ثيم مطابق لشعار مجموعة المزاد الدولي — أسود + أحمر + أبيض */
  --navy: #1c191a;        /* أسود الشعار (للهيدر الداكن/التذييل) */
  --navy-2: #38302f;      /* فحمي للتدرّجات */
  --gold: #bf2229;        /* أحمر الشعار (اللون الأساسي) */
  --gold-soft: #f3c3c5;   /* أحمر فاتح للخلفيات اللطيفة */
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1b1718;
  --muted: #6b7785;
  --line: #e2e7ee;
  --good: #0f7a4d;
  --shadow: 0 6px 24px rgba(28, 25, 26, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Tahoma, Arial, "Noto Sans Arabic", sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ===== Header ===== */
.site-header {
  background: #ffffff;
  color: var(--ink);
  padding: 16px;
  border-bottom: 3px solid var(--gold);
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
}
.brand img { width: 74px; height: 74px; flex: none; object-fit: contain; }
.brand-text { line-height: 1.25; }
.brand-text .ar { font-size: 1.5rem; font-weight: 800; letter-spacing: .2px; color: var(--ink); }
.brand-text .en { font-size: .9rem; color: var(--gold); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.brand-text .tag { font-size: .8rem; color: var(--muted); margin-top: 2px; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.lang-toggle button {
  background: transparent;
  color: var(--ink);
  border: 0;
  padding: 7px 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: .85rem;
}
.lang-toggle button.active { background: var(--gold); color: #fff; }

/* ===== Calculator ===== */
.calc-wrap { max-width: 1180px; margin: 22px auto 10px; padding: 0 16px; }
.calc-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}
.calc-head {
  background: linear-gradient(135deg, var(--navy-2), var(--navy));
  color: #fff;
  padding: 16px 20px;
}
.calc-head h2 { margin: 0; font-size: 1.25rem; }
.calc-head .calc-sub { margin: 4px 0 0; color: var(--gold-soft); font-size: .85rem; }

/* طريقة الاستخدام */
.how-to {
  margin: 14px 20px 0;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--gold);
  border-radius: 10px;
  background: #fff8f8;
  padding: 10px 16px;
}
.how-to > summary {
  font-weight: 800; color: var(--navy-2); cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 8px; font-size: .98rem;
}
.how-to > summary::before { content: "▸"; color: var(--gold); transition: transform .2s; }
.how-to[open] > summary::before { transform: rotate(90deg); }
.how-to > summary::-webkit-details-marker { display: none; }
.how-to ol { margin: 10px 0 4px; padding-inline-start: 22px; }
.how-to li { margin: 6px 0; color: var(--ink); font-size: .9rem; line-height: 1.6; }

/* البحث برقم اللوت */
.lot-lookup { margin: 14px 20px 0; padding: 12px 16px; border: 1px dashed var(--gold); border-radius: 10px; background: #fff8f8; }
.lot-lookup > label { display: block; font-weight: 800; color: var(--navy-2); font-size: .92rem; margin-bottom: 8px; }
.lot-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.lot-tag { flex: none; min-width: 96px; text-align: center; font-weight: 800; font-size: .8rem; color: #fff; background: var(--navy); padding: 7px 10px; border-radius: 7px; }
.lot-row input { flex: 1 1 180px; min-width: 150px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; }
.lot-row input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.lot-row .btn-gold { flex: none; padding: 11px 18px; }
.lot-status { margin-top: 8px; font-size: .85rem; font-weight: 600; min-height: 1.1em; }
.lot-status.loading { color: var(--muted); }
.lot-status.ok { color: var(--good); }
.lot-status.err { color: var(--gold); }
.lot-status.warn { color: #c0392b; font-weight: 700; }
/* بطاقة صورة السيارة (رابط لصفحة ماكينا) */
.lot-car { margin-top: 10px; }
.lot-car a { display: flex; align-items: center; gap: 12px; text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; transition: box-shadow .15s, border-color .15s; }
.lot-car a:hover { border-color: var(--gold); box-shadow: var(--shadow); }
.lot-car img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; flex: none; background: #f0f0f0; }
.lot-car-cap { color: var(--ink); font-size: .9rem; line-height: 1.5; }
.lot-car-cta { display: inline-block; margin-top: 4px; color: var(--gold); font-weight: 800; }

/* حاسبة عمولة المزاد السريعة (ACV / Adesa / غيرها) */
.fee-quick { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--gold); }
.fee-quick-label { display: block; font-weight: 800; color: var(--navy-2); font-size: .9rem; margin-bottom: 8px; }
.fee-select { flex: 1 1 140px; min-width: 120px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; background: #fff; }
.fee-select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.fee-result { margin-top: 8px; font-size: .95rem; font-weight: 700; min-height: 1.1em; color: var(--navy-2); }
.fee-result.ok b { color: var(--good); font-size: 1.15rem; }
.fee-result.err { color: var(--gold); }
.fee-sub { color: var(--muted); font-weight: 600; font-size: .85rem; }

/* ===== شريط التنقّل السفلي (PWA / الجوال) ===== */
/* يظهر على أي شاشة صغيرة أو أي جهاز لمسي (هاتف/تابلت/آيفون) — مستقلّ عن التكبير ووضع Desktop site */
.bottom-nav { display: none; }
@media (max-width: 820px), (pointer: coarse) {
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 900;
    background: var(--navy); border-top: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .25);
    justify-content: space-around; align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav button, .bottom-nav .bn-link {
    flex: 1 1 0; min-width: 0; background: transparent; border: 0; color: #d7d2cf;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 7px 2px 6px; font-family: inherit; font-size: .66rem; font-weight: 800; cursor: pointer;
    text-decoration: none; transition: color .15s;
  }
  .bottom-nav .bn-ic { font-size: 1.3rem; line-height: 1; }
  .bottom-nav .bn-logo { width: 30px; height: 30px; object-fit: contain; border-radius: 5px; }
  .bottom-nav .bn-link { color: #e6c24c; font-weight: 900; }
  .bottom-nav .bn-link .bn-tx { color: #e6c24c; }
  .bottom-nav button.active, .bottom-nav button:active { color: var(--gold); }
  .bottom-nav .bn-link:active { opacity: .8; }
  /* مساحة سفلية حتى لا يغطّي الشريط آخر المحتوى */
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
}
/* في وضع التطبيق المثبّت: مساحة علوية آمنة للهيدر */
@media (display-mode: standalone) {
  .site-header { padding-top: env(safe-area-inset-top); }
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 18px 20px;
}
.calc-grid .field input,
.calc-grid .field select { width: 100%; }

.calc-actions { display: flex; gap: 10px; padding: 0 20px 20px; flex-wrap: wrap; }
.btn-gold {
  background: var(--gold); color: #fff; border: 0;
  padding: 12px 20px; border-radius: 10px; font-weight: 800; cursor: pointer; font-size: .95rem;
}
.btn-gold:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--navy-2); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 10px; font-weight: 700; cursor: pointer;
}
.btn-wa {
  background: #25d366; color: #fff; border: 0;
  padding: 12px 18px; border-radius: 10px; font-weight: 800; cursor: pointer; font-size: .95rem;
}
.btn-wa:hover { background: #1ebe59; }

/* النتيجة / عرض السعر */
.quote { margin: 4px 20px 8px; border: 1px solid var(--gold-soft); border-radius: 12px; padding: 18px; background: #fff8f8; }
.quote-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.quote-brand img { width: 46px; height: 46px; }
.quote-brand .qb-ar { font-weight: 800; color: var(--navy-2); font-size: 1.05rem; }
.quote-brand .qb-en { font-size: .72rem; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; }
.quote-title { margin: 6px 0 12px; font-size: 1rem; color: var(--navy-2); }
/* صفوف Flex: الوصف يتمدّد ويلتفّ، والقيمة مثبّتة على اليسار — تظهر دائماً بأي عرض.
   مهم: الجدول نفسه display:block حتى لا يفرض المتصفّح بنية جدول على صفوف الـ flex */
.quote-table { display: block; width: 100%; min-width: 0; max-width: 460px; }
.quote-table tbody, .quote-table tfoot { display: block; }
.quote-table tr { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px dashed #f0d3d4; }
.quote-table td { display: block; padding: 9px 0; font-size: .95rem; border: none; }
.quote-table td:first-child { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.quote-table td.num { flex: 0 0 auto; text-align: end; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.quote-total { border-top: 2px solid var(--gold); border-bottom: none; }
.quote-total td { padding-top: 12px; font-size: 1.15rem; font-weight: 900; color: var(--good); }
.quote-total-local { border-bottom: none; }
.quote-total-local td { color: var(--navy-2); font-weight: 800; }
.quote-disclaimer { margin: 12px 0 0; font-size: .78rem; color: #7a6f43; line-height: 1.6; }

.section-title { max-width: 1180px; margin: 26px auto 0; padding: 0 16px; color: var(--navy-2); font-size: 1.15rem; }

.row-calc {
  background: var(--navy-2); color: #fff; border: 0; border-radius: 8px;
  padding: 6px 12px; font-weight: 700; cursor: pointer; font-size: .8rem;
}
.row-calc:hover { background: var(--gold); color: #fff; }

/* ===== Controls ===== */
.controls {
  max-width: 1180px;
  margin: 18px auto 8px;
  padding: 0 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: .78rem; color: var(--muted); font-weight: 700; }
.field input, .field select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: .95rem;
  background: var(--card);
  color: var(--ink);
  min-height: 44px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.field.search { flex: 1 1 320px; }
.field.search input { width: 100%; }

.result-count { color: var(--muted); font-size: .85rem; padding: 4px 16px; max-width: 1180px; margin: 0 auto; }

/* ===== Table ===== */
.table-wrap {
  max-width: 1180px;
  margin: 6px auto 30px;
  padding: 0 16px;
}
.table-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { border-collapse: collapse; width: 100%; min-width: 1040px; }
thead th {
  background: var(--navy);
  color: #fff;
  font-size: .72rem;
  text-align: start;
  padding: 9px 8px;
  position: sticky;
  top: 0;
  white-space: nowrap;
  z-index: 1;
}
thead th.price-col { text-align: center; }
thead th .sub { display: block; font-weight: 500; color: var(--gold-soft); font-size: .62rem; }

tbody td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: .8rem; vertical-align: middle; }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:hover { background: #fff6df; }

/* عمود «موقع المزاد» مثبّت على اليمين أثناء التمرير الأفقي */
.loc-col {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--card);
  box-shadow: -6px 0 8px -6px rgba(0, 0, 0, .18);
}
thead th.loc-col { z-index: 3; background: var(--navy); }
tbody tr:nth-child(even) .loc-col { background: #fafbfd; }
tbody tr:hover .loc-col { background: #fff6df; }

.loc-name { font-weight: 700; color: var(--navy-2); font-size: .82rem; line-height: 1.3; }
.loc-sub { color: var(--muted); font-size: .68rem; margin-top: 1px; }
.badge {
  display: inline-block;
  font-size: .62rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--navy-2);
  border: 1px solid var(--line);
}
.price-col { text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.price { font-weight: 800; color: var(--good); }
.price-na { color: var(--muted); font-size: .8rem; }
/* أرخص ميناء في السطر — إطار ذهبي */
.price.cheapest {
  display: inline-block; padding: 2px 7px; border-radius: 6px;
  border: 2px solid #d4af37; background: rgba(212, 175, 55, .16);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, .15); font-weight: 900;
}
.table-legend { max-width: 1180px; margin: 8px auto 0; padding: 0 16px; color: var(--navy-2); font-size: .9rem; font-weight: 700; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* ===== Notes / footer ===== */
.notes {
  max-width: 1180px;
  margin: 0 auto 28px;
  padding: 0 16px;
}
.notes-card {
  background: #fff8f8;
  border: 1px solid var(--gold-soft);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: .85rem;
  color: #5b5230;
  line-height: 1.7;
}
.notes-card h3 { margin: 0 0 6px; color: var(--navy-2); font-size: .95rem; }
.notes-card ul { margin: 6px 0 0; padding-inline-start: 20px; }

.site-footer {
  background: var(--navy);
  color: #c7d2de;
  text-align: center;
  padding: 16px;
  font-size: .82rem;
}
.site-footer .gold { color: var(--gold); font-weight: 700; }

/* hidden helper for language */
[data-lang-en], [data-lang-ar] { }

@media (max-width: 720px) {
  .calc-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .brand-text .ar { font-size: 1.2rem; }
  .brand img { width: 50px; height: 50px; }
  thead th, tbody td { padding: 9px 8px; font-size: .82rem; }
  .calc-grid { grid-template-columns: 1fr; }
}

/* ===== Print / PDF ===== */
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .site-header { box-shadow: none; }
  .calc-wrap { margin: 0; padding: 0; }
  .calc-card { box-shadow: none; border: none; }
  .calc-head { display: none; }
  .quote { margin: 0; border: none; background: #fff; padding: 0; }
  .quote-disclaimer { color: #444; }
  @page { margin: 16mm; }
}

/* ===== لوحة الأدمن ===== */
.admin-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 20, 25, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto;
}
.admin-overlay[hidden] { display: none; }
.admin-box {
  background: #fff; width: min(760px, 100%); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; margin: auto;
}
.admin-head {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, var(--navy-2), var(--navy)); color: #fff; padding: 14px 18px;
}
.admin-head h3 { margin: 0; font-size: 1.1rem; }
.admin-x { background: transparent; border: 0; color: #fff; font-size: 1.2rem; cursor: pointer; }
.admin-body { padding: 16px 18px; max-height: 78vh; overflow-y: auto; }
.admin-sec { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.admin-sec h4 { margin: 0 0 10px; color: var(--gold); font-size: .95rem; }
.admin-sec > label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0; font-size: .9rem; font-weight: 600; }
.admin-sec > label input { width: 160px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.adm-dest { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: #fafbfc; }
.adm-dest-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.adm-dest-row input { flex: 1 1 140px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.adm-prices { width: 100%; border-collapse: collapse; font-size: .82rem; }
.adm-prices th, .adm-prices td { padding: 4px; text-align: center; }
.adm-prices td:first-child, .adm-prices th:first-child { text-align: start; font-weight: 600; white-space: nowrap; }
.adm-prices input { width: 72px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; text-align: center; }
.admin-actions { margin-top: 8px; }
@media (max-width: 560px) { .admin-sec > label { flex-direction: column; align-items: stretch; } .admin-sec > label input { width: 100%; } }

/* ===== تفاعل العملاء: تقييم + تسجيل ===== */
.engage-wrap { max-width: 1180px; margin: 6px auto 18px; padding: 0 16px; }
.engage-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
@media (max-width: 760px) { .engage-grid { grid-template-columns: 1fr; } }
.engage-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 18px; }
.engage-card h3 { margin: 0 0 8px; font-size: 1.05rem; color: var(--navy-2); }
.engage-sub { margin: 0 0 12px; color: var(--muted); font-size: .9rem; line-height: 1.6; }
.rate-card { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.stars { display: flex; gap: 6px; direction: ltr; font-size: 2rem; line-height: 1; }
.stars .star { color: #d9d9d9; cursor: pointer; transition: color .12s, transform .12s; }
.stars .star:hover { transform: scale(1.12); }
.stars .star.on { color: #f5b50a; }
.stars.done .star { cursor: default; }
.stars.done .star:hover { transform: none; }
.engage-msg { margin-top: 10px; font-size: .88rem; font-weight: 700; min-height: 1.1em; }
.engage-msg.ok { color: var(--good); }
.engage-msg.err { color: #c0392b; }
.reg-form { display: grid; gap: 10px; }
.reg-form input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 1rem; font-family: inherit; }
.reg-form input:focus { outline: none; border-color: var(--gold); }
.reg-form .btn-gold { padding: 12px; font-size: 1rem; }

/* ===== إدارة المستخدمين (لوحة الأدمن) ===== */
.adm-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.adm-stat { flex: 1 1 90px; background: #f6f8fb; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.adm-stat-n { display: block; font-size: 1.4rem; font-weight: 900; color: var(--navy-2); }
.adm-stat-l { display: block; font-size: .72rem; color: var(--muted); margin-top: 2px; }
.adm-users-bar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.adm-users-bar .btn-ghost { padding: 7px 12px; font-size: .85rem; }
.adm-users-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.adm-users { border-collapse: collapse; width: 100%; min-width: 420px; font-size: .85rem; }
table.adm-users th { background: var(--navy); color: #fff; text-align: start; padding: 8px 10px; white-space: nowrap; font-size: .78rem; }
table.adm-users td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.adm-users tr:nth-child(even) td { background: #fafbfd; }
.adm-u-del { background: transparent; border: 0; cursor: pointer; font-size: 1rem; padding: 2px 6px; border-radius: 6px; }
.adm-u-del:hover { background: #fde8e8; }

/* ===== حظر تجاوز الحصّة المجانية ===== */
.quota-block { margin: 8px 20px; padding: 26px 18px; border: 2px dashed var(--gold); border-radius: 14px; background: #fff8e8; text-align: center; }
.quota-lock { font-size: 2.4rem; line-height: 1; }
.quota-block h3 { margin: 10px 0 6px; color: var(--navy-2); font-size: 1.12rem; }
.quota-block p { margin: 0 auto 14px; color: var(--ink); font-size: .92rem; line-height: 1.6; max-width: 440px; }

/* ===== روابط المداخل في التذييل (بوابة الزبون / دخول الموظفين) ===== */
.footer-links { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.footer-cta { background: var(--gold); color: #fff; padding: 9px 18px; border-radius: 999px; font-weight: 800; text-decoration: none; font-size: .9rem; }
.footer-cta:hover { opacity: .92; }
.footer-staff { color: #9aa6b2; text-decoration: none; font-size: .8rem; opacity: .75; }
.footer-staff:hover { color: var(--gold); }
