:root {
  --bs-primary: #e6a520;
  --app-bg: #fff8e7;
  --card-bg: #ffffff;
  --text-base: #2b2e33;
  --text-muted: #6f6b63;
  --accent-light: #ffd77a;
  --accent: #e6a520;
  --accent-dark: #7a4a00;
  --shadow-soft: 0 12px 32px rgba(122, 74, 0, 0.1);
  --shadow-card: 0 10px 24px rgba(122, 74, 0, 0.12);
  --radius-card: 16px;
}

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--app-bg);
  color: var(--text-base);
}

[dir="rtl"] body {
  font-family: "Noto Sans Arabic", "Noto Naskh Arabic", "Tahoma", "Arial", system-ui, sans-serif;
}

.bg-light {
  background: var(--app-bg) !important;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(122, 74, 0, 0.65), rgba(230, 165, 32, 0.5));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(122, 74, 0, 0.25);
}

.login-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-badge {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.02em;
}

body.auth-locked {
  overflow: hidden;
}

body.auth-locked nav,
body.auth-locked main,
body.auth-locked #contract-print-area {
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.page-section {
  min-height: 75vh;
}

.card {
  border: 0;
  border-radius: var(--radius-card);
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
}

.card-header {
  font-weight: 600;
  border-bottom: 1px solid rgba(122, 74, 0, 0.12);
  border-radius: var(--radius-card) var(--radius-card) 0 0 !important;
  background: #ffffff;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px;
  background: linear-gradient(135deg, #ffffff, #fff2d6);
}

.stat-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 2rem;
  line-height: 1;
  font-weight: 700;
  color: var(--text-base);
}

@media (max-width: 992px) {
  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 1.75rem;
  }
}

.list-group-item.active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #2b2e33;
}

.table td,
.table th {
  vertical-align: middle;
}

.table td,
.table th {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

[dir="rtl"] .table td,
[dir="rtl"] .table th {
  text-align: right;
}

#page-contracts .table-responsive table,
#page-payments .table-responsive table {
  min-width: 1100px;
  table-layout: fixed;
}

#page-contracts .table th,
#page-contracts .table td,
#page-payments .table th,
#page-payments .table td {
  font-size: 0.9rem;
}

#page-contracts .table th:nth-child(1),
#page-contracts .table td:nth-child(1) {
  width: 80px;
}

#page-contracts .table th:nth-child(2),
#page-contracts .table td:nth-child(2) {
  width: 170px;
}

#page-contracts .table th:nth-child(5),
#page-contracts .table td:nth-child(5) {
  width: 140px;
}

#page-contracts .table th:nth-child(6),
#page-contracts .table td:nth-child(6) {
  width: 180px;
}

.table thead th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-accent-bg: #fff4dd;
}

.navbar {
  background: linear-gradient(135deg, #e6a520, #ffd77a) !important;
  box-shadow: 0 12px 28px rgba(122, 74, 0, 0.2);
}

.navbar .nav-link {
  font-weight: 500;
}

.navbar .nav-link.active {
  background: rgba(122, 74, 0, 0.18);
  border-radius: 999px;
  padding-inline: 14px;
}

.btn {
  border-radius: 10px;
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-base);
  box-shadow: 0 10px 22px rgba(122, 74, 0, 0.25);
}

.btn-primary:hover,
.btn-primary:focus {
  background: #d9951d;
  border-color: #d9951d;
  color: var(--text-base);
}

.btn-outline-primary {
  color: var(--accent-dark);
  border-color: var(--accent);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-base);
}

.btn-success {
  background: #2f8f52;
  border-color: #2f8f52;
}

.btn-outline-light {
  border-color: rgba(122, 74, 0, 0.35);
  color: var(--accent-dark);
}

.form-control,
.form-select {
  border-radius: 10px;
  border-color: rgba(122, 74, 0, 0.18);
  padding: 0.55rem 0.75rem;
  color: var(--text-base);
  background: #fffdf7;
}

[dir="rtl"] .form-control,
[dir="rtl"] .form-select {
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

.form-select option {
  color: var(--text-base);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(230, 165, 32, 0.2);
}

.badge-status {
  font-size: 0.75rem;
}

.bulk-whatsapp {
  border: 1px solid rgba(122, 74, 0, 0.15);
  background: #fff;
  padding: 16px;
  border-radius: 12px;
}

.bulk-preview {
  margin-top: 12px;
  border: 1px dashed rgba(122, 74, 0, 0.35);
  border-radius: 10px;
  padding: 10px;
  max-height: 180px;
  overflow: auto;
  background: #fff4dd;
  display: grid;
  gap: 6px;
}

.print-area {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(122, 74, 0, 0.15);
}

.print-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.print-box {
  min-height: 80px;
  border: 1px solid rgba(122, 74, 0, 0.15);
  padding: 12px;
  border-radius: 8px;
  background: #fff8e7;
}

.print-signatures {
  margin-top: 48px;
  display: flex;
  justify-content: space-between;
}

.signature-line {
  width: 220px;
  border-bottom: 2px solid var(--accent-dark);
  margin-bottom: 8px;
}

@media print {
  nav,
  .page-section {
    display: none !important;
  }

  #contract-print-area {
    display: block !important;
  }

  body {
    background: #fff;
  }
}
