/* ألوان hex فقط — متوافق مع html2canvas / PDF */
.ad-num {
  direction: rtl;
  unicode-bidi: embed;
  display: inline-block;
}

.ad-root {
  direction: rtl;
  text-align: right;
  unicode-bidi: isolate;
  width: 100%;
  max-width: 210mm;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 0;
  background: #f6e7d8;
  color: #1e293b;
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 12.5px;
  line-height: 1.7;
  letter-spacing: 0;
  word-spacing: normal;
  font-feature-settings: normal;
  box-sizing: border-box;
  box-shadow: 0 12px 32px rgba(27, 67, 50, 0.12);
  border: 1px solid #e8d5c4;
}

.ad-root * {
  letter-spacing: 0;
}

@media (min-width: 768px) {
  .ad-root {
    width: 210mm;
  }
}

.ad-header,
.ad-invoice-header {
  position: relative;
  overflow: hidden;
  padding: 22px 24px 28px;
  color: #ffffff;
  background: linear-gradient(135deg, #1b4332 0%, #14532d 50%, #0f3328 100%);
}

.ad-header-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
}

.ad-header-brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.ad-logo {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  flex-shrink: 0;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.95);
  padding: 4px;
  box-sizing: border-box;
}

.ad-header-sub {
  font-size: 11px;
  color: #b7e4c7;
  margin: 0;
}

.ad-header-title {
  font-size: 24px;
  font-weight: 800;
  margin: 4px 0 0;
  line-height: 1.25;
}

.ad-header-meta {
  font-size: 12px;
  color: #d8f3dc;
  margin: 8px 0 0;
  max-width: 28rem;
}

.ad-date-box {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  padding: 10px 14px;
  font-size: 12px;
}

.ad-date-label {
  color: #b7e4c7;
  margin: 0;
}

.ad-date-value {
  font-size: 17px;
  font-weight: 700;
  margin: 4px 0 0;
}

.ad-branches {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

@media (min-width: 520px) {
  .ad-branches {
    grid-template-columns: repeat(3, 1fr);
  }
}

.ad-branch-card {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 10px;
  line-height: 1.45;
}

.ad-branch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-bottom: 4px;
}

.ad-branch-flag {
  font-size: 13px;
  line-height: 1;
}

.ad-branch-title {
  font-weight: 700;
  color: #ffffff;
  font-size: 10.5px;
}

.ad-branch-badge {
  background: #fbbf24;
  color: #1b4332;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

.ad-branch-address {
  margin: 0;
  color: #d8f3dc;
  font-size: 9.5px;
}

.ad-body {
  padding: 18px 22px;
  background: #f6e7d8;
}

.ad-strong {
  font-weight: 600;
  color: #1b4332;
}

.ad-muted {
  color: #5c4a3a;
}

.ad-parties {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

@media (min-width: 640px) {
  .ad-parties {
    grid-template-columns: 1fr 1fr;
  }
}

.ad-party-a {
  border-radius: 12px;
  border: 1px solid #d4c4b0;
  background: #faf0e6;
  padding: 14px;
}

.ad-party-b {
  border-radius: 12px;
  border: 1px solid #d4c4b0;
  background: #f5ebe0;
  padding: 14px;
}

.ad-party-title {
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #1b4332;
}

.ad-justify {
  text-align: justify;
}

.ad-section-title {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #1b4332;
  margin: 14px 0 10px;
}

.ad-clause-title {
  border-radius: 8px;
  background: #cce3d6;
  padding: 7px 11px;
  font-weight: 700;
  color: #1b4332;
  margin: 0 0 8px;
  font-size: 12.5px;
  position: relative;
  z-index: 1;
  clear: both;
}

.ad-section {
  margin-top: 16px;
  margin-bottom: 16px;
  clear: both;
}

.ad-section-first-clause {
  margin-top: 20px;
  padding-top: 6px;
}

.ad-body > p.ad-justify {
  margin-bottom: 10px;
}

.ad-list {
  margin: 0;
  padding-right: 18px;
}

.ad-list li {
  margin-bottom: 4px;
}

.ad-list-decimal {
  list-style: decimal;
}

.ad-list-disc {
  list-style: disc;
}

.ad-small {
  font-size: 11.5px;
}

.ad-section-compact {
  margin-bottom: 10px;
}

.ad-section-compact .ad-clause-title {
  margin-bottom: 6px;
}

.ad-clause1-list {
  margin-top: 6px;
  margin-bottom: 0;
}

.ad-clause1-list li {
  margin-bottom: 3px;
  line-height: 1.45;
}

.ad-clause1-list-cols {
  column-count: 2;
  column-gap: 18px;
  padding-right: 4px;
}

.ad-clause1-list-cols li {
  break-inside: avoid;
  margin-bottom: 4px;
}

.ad-list-annex {
  font-size: 10.5px;
  line-height: 1.42;
  margin-top: 6px;
}

.ad-list-annex li {
  margin-bottom: 2px;
  break-inside: avoid;
}

.ad-list-annex-cols {
  column-count: 2;
  column-gap: 14px;
  padding-right: 2px;
}

.ad-list-annex-cols li {
  break-inside: avoid;
  margin-bottom: 3px;
}

.ad-annex-page .ad-section-compact {
  margin-bottom: 6px;
}

.ad-annex-page .ad-annex-support {
  margin-top: 10px;
}

.ad-annex-subtitle {
  margin-top: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}

.ad-annex-support {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #d4c4b0;
}

.ad-footer {
  color: #ffffff;
  padding: 0;
  font-size: 10.5px;
  overflow: hidden;
  background: linear-gradient(135deg, #1b4332 0%, #14532d 52%, #0f3328 100%);
  border-top: 1px solid #2d6a4f;
}

.ad-footer-accent {
  height: 3px;
  background: linear-gradient(90deg, #c9a66b 0%, #f6e7d8 50%, #c9a66b 100%);
}

.ad-footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  justify-content: space-between;
  align-items: center;
  padding: 12px 22px 14px;
}

.ad-footer-compact .ad-footer-inner {
  padding: 9px 16px 11px;
  gap: 10px 12px;
}

.ad-footer-main {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.ad-footer-logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.96);
  padding: 4px;
  box-sizing: border-box;
}

.ad-footer-compact .ad-footer-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  padding: 3px;
}

.ad-footer-titles {
  min-width: 0;
}

.ad-footer-name-ar {
  margin: 0;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.35;
  color: #ffffff;
}

.ad-footer-compact .ad-footer-name-ar {
  font-size: 10.5px;
}

.ad-footer-brand {
  margin: 3px 0 0;
  font-size: 10px;
  font-weight: 600;
  color: #b7e4c7;
}

.ad-footer-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  justify-content: flex-start;
}

.ad-footer-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(183, 228, 199, 0.28);
  min-width: 90px;
}

.ad-footer-compact .ad-footer-chip {
  padding: 5px 9px;
  border-radius: 8px;
  min-width: 78px;
}

.ad-footer-chip-label {
  font-size: 8.5px;
  font-weight: 700;
  color: #95d5b2;
  line-height: 1.2;
}

.ad-footer-chip-value {
  font-size: 10.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
  word-break: break-word;
}

.ad-footer-compact .ad-footer-chip-value {
  font-size: 9.5px;
}

.ad-client-box {
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid #d4c4b0;
  background: #faf0e6;
  padding: 14px;
}

.ad-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 12px;
}

.ad-table th,
.ad-table td {
  border: 1px solid #d4c4b0;
  padding: 10px;
  text-align: right;
}

.ad-table thead {
  background: #cce3d6;
  color: #1b4332;
}

.ad-totals {
  max-width: 20rem;
  margin-right: auto;
  border-radius: 12px;
  border: 1px solid #d4c4b0;
  background: #faf0e6;
  padding: 14px;
}

.ad-totals-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ad-totals-paid {
  color: #065f46;
}

.ad-totals-remain {
  color: #9f1239;
  border-top: 1px solid #d4c4b0;
  padding-top: 8px;
  margin-top: 4px;
}

.ad-invoice-note {
  margin-top: 20px;
  padding: 10px 14px;
  text-align: center;
  font-size: 10.5px;
  color: #3d4f42;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid #d4c4b0;
  border-radius: 10px;
}

.page-break-after {
  break-after: page;
}

.page-break-before {
  break-before: page;
}

.ad-page {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  min-height: 297mm;
  height: 297mm;
  max-height: 297mm;
  break-after: page;
  page-break-after: always;
  background: #f6e7d8;
  overflow: hidden;
}

.ad-page:last-child {
  page-break-after: auto;
  break-after: auto;
}

.ad-page-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.ad-page-footer-block {
  margin-top: auto;
  flex-shrink: 0;
  width: 100%;
}

.ad-page-signatures {
  flex-shrink: 0;
  padding: 10px 22px 14px;
  border-top: 1px solid #d4c4b0;
  background: #efe5d9;
}

.ad-page-signatures-compact {
  padding-top: 8px;
  padding-bottom: 10px;
}

.ad-page-signatures-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  text-align: center;
}

.ad-page-sign-label {
  font-size: 11px;
  font-weight: 700;
  color: #1b4332;
  margin: 0 0 6px;
}

.ad-page-sign-area {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-page-signatures-stamped .ad-page-sign-area {
  min-height: 110px;
}

.ad-sign-placeholder {
  width: 70%;
  max-width: 160px;
  height: 1px;
  border-top: 1px dashed #94a3b8;
  margin: 20px auto 0;
}

.ad-stamp-image {
  max-width: 240px;
  max-height: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.ad-page-sign-name {
  margin: 6px 0 0;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  html,
  body {
    width: 210mm;
    margin: 0;
    padding: 0;
  }
  .ad-root {
    width: 210mm !important;
    max-width: 210mm !important;
    margin: 0 !important;
    box-shadow: none;
    border-radius: 0;
    border: none;
  }
  .ad-page {
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    page-break-after: always;
  }
  .ad-page-footer-block {
    margin-top: auto !important;
  }
  .ad-section,
  .ad-header,
  .ad-footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
