:root {
  --navy: #1B2C6B;
  --navy-dark: #111d4a;
  --navy-mid: #223580;
  --gold: #B8935A;
  --gold-light: #d4aa72;
  --gold-pale: #f5ede0;
  --white: #ffffff;
  --off-white: #f8f6f2;
  --gray: #6b7280;
  --gray-dark: #374151;
  --border: #e5e1d9;
  --danger: #dc2626;
  --success: #16a34a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: 'Cairo', sans-serif;
  background: var(--off-white);
  color: var(--gray-dark);
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(17, 29, 74, 0.97);
  border-bottom: 1px solid rgba(184, 147, 90, 0.4);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  width: min(1150px, 92%);
  margin: 0 auto;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  color: var(--gold-light);
}

.brand p {
  margin: 0;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.6);
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.profile-menu-wrap {
  position: relative;
}

.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  min-width: 140px;
  justify-content: space-between;
}

.profile-caret {
  font-size: 0.8rem;
  line-height: 1;
}

.profile-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(184, 147, 90, 0.18);
  border: 1px solid rgba(184, 147, 90, 0.45);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  min-width: 245px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.16);
  z-index: 120;
  padding: 6px;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: right;
  color: var(--gray-dark);
  border-radius: 8px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}

.profile-menu-item:hover {
  background: #f8f3ea;
  color: var(--navy);
}

.profile-menu-item.active {
  background: rgba(27, 44, 107, 0.1);
  color: var(--navy);
}

.profile-menu-item-danger {
  color: #9a3412;
}

.profile-menu-item-danger:hover {
  background: #fff7ed;
  color: #9a3412;
}

.profile-menu-link {
  text-decoration: none;
}

.profile-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px 8px;
}

.profile-menu-lang {
  padding: 2px 6px 8px;
}

.profile-menu-label {
  display: block;
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--gray);
  margin-bottom: 5px;
}

.profile-lang-select {
  width: 100%;
  min-width: 0;
  background: #fff;
  color: var(--gray-dark);
  border-color: var(--border);
}

.lang-chip-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
  padding: 4px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbf7f0, #f4eee2);
  border: 1px solid rgba(184, 147, 90, 0.22);
}

.lang-chip {
  min-height: 54px;
  border-radius: 12px;
  border: 1px solid rgba(184, 147, 90, 0.28);
  background: linear-gradient(180deg, #ffffff, #fbf7ef);
  color: var(--navy);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  font: inherit;
  cursor: pointer;
  transition: 0.2s ease;
}

.lang-chip:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
  box-shadow: 0 10px 22px rgba(27, 44, 107, 0.08);
}

.lang-chip-mark {
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
}

.lang-chip-text {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  opacity: 0.78;
}

.lang-chip.is-active {
  background: linear-gradient(135deg, var(--navy), var(--navy-mid));
  color: var(--white);
  border-color: rgba(27, 44, 107, 0.9);
  box-shadow: 0 12px 24px rgba(27, 44, 107, 0.18);
}

.lang-chip.is-active .lang-chip-text {
  opacity: 1;
}

.payment-consent-wrap {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.consent-box-compact {
  background: #fcfaf6;
  padding: 8px 10px;
}

.lang-select {
  border: 1px solid rgba(184, 147, 90, 0.55);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  min-width: 120px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.lang-select option {
  color: #111827;
}

.btn {
  border: none;
  border-radius: 26px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--gold);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--gold-light);
}

.btn-secondary {
  background: var(--navy);
  color: var(--white);
}

.btn-outline {
  border: 1px solid var(--gold);
  color: var(--gold);
  background: transparent;
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.text-link {
  border: none;
  background: transparent;
  color: var(--navy);
  font: inherit;
  font-size: 0.87rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.main-wrap {
  width: min(1150px, 92%);
  margin: 24px auto 50px;
}

.hero {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: var(--white);
  border-radius: 18px;
  padding: clamp(24px, 4vw, 44px);
  border: 1px solid rgba(184, 147, 90, 0.3);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(184, 147, 90, 0.11) 1px, transparent 1px);
  background-size: 30px 30px;
}

.hero>* {
  position: relative;
}

.hero h2 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.hero p {
  margin: 0;
  max-width: 760px;
  color: rgba(255, 255, 255, 0.83);
  line-height: 1.9;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.grid-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.compact-grid {
  margin-top: 10px;
}

.kpi.kpi-mini {
  padding: 10px;
  border-radius: 10px;
}

.kpi.kpi-mini .label {
  font-size: 0.78rem;
}

.kpi.kpi-mini .value {
  font-size: 1.05rem;
}

.admin-status-strip {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-status-pill {
  border-radius: 999px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  border: 1px solid transparent;
}

.admin-status-pill strong {
  font-size: 0.86rem;
}

.admin-status-new {
  background: #ffedd5;
  border-color: #fdba74;
  color: #9a3412;
}

.admin-status-progress {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e3a8a;
}

.admin-status-done {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.admin-status-failed {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.admin-nav-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.admin-nav-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(184, 147, 90, 0.24);
  background: linear-gradient(135deg, rgba(27, 44, 107, 0.06), rgba(184, 147, 90, 0.12));
  transition: 0.2s ease;
}

.admin-nav-card:hover {
  transform: translateY(-2px);
  border-color: rgba(184, 147, 90, 0.45);
  box-shadow: 0 16px 30px rgba(17, 29, 74, 0.08);
}

.admin-nav-card strong {
  display: block;
  color: var(--navy);
  font-size: 1rem;
  margin-bottom: 6px;
}

.admin-nav-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--gray);
  line-height: 1.8;
}

.admin-nav-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(27, 44, 107, 0.1);
  color: var(--gold);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.summary-row-active {
  background: rgba(27, 44, 107, 0.04);
}

.detail-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-client-name {
  color: var(--navy);
  font-size: 1.25rem;
  font-weight: 900;
}

.detail-contact-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.detail-contact-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: #f7f3eb;
  border: 1px solid rgba(184, 147, 90, 0.22);
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--gray-dark);
}

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(17, 29, 74, 0.05);
}

.card h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 1.06rem;
}

.card p,
.card li,
.muted {
  color: var(--gray);
  line-height: 1.75;
  font-size: 0.92rem;
}

.kpi {
  background: linear-gradient(135deg, rgba(27, 44, 107, 0.08), rgba(184, 147, 90, 0.12));
  border: 1px solid rgba(184, 147, 90, 0.25);
  border-radius: 12px;
  padding: 12px;
}

.kpi .value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--navy);
}

.kpi .label {
  font-size: 0.83rem;
  color: var(--gray);
}

.section-title {
  margin: 20px 0 10px;
  color: var(--navy);
  font-size: 1.15rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field {
  margin-bottom: 12px;
}

.form-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.86rem;
  color: var(--navy);
  font-weight: 700;
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.form-field textarea {
  min-height: 108px;
  resize: vertical;
}

.upload-dropzone {
  border: 1px dashed rgba(184, 147, 90, 0.7);
  border-radius: 12px;
  background: #fcfaf6;
  padding: 12px;
}

.upload-dropzone:hover {
  border-color: var(--navy);
}

.upload-dropzone:focus-within,
.upload-dropzone.is-dragover {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 44, 107, 0.12);
}

.upload-dropzone-title {
  margin: 0 0 6px;
  color: var(--navy);
  font-weight: 700;
  font-size: 0.9rem;
}

.attachment-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.attachment-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note,
.warning,
.success {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.87rem;
}

.note {
  background: #f4f7ff;
  border: 1px solid #d5ddff;
  color: #334155;
}

.warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 9px 8px;
  text-align: right;
  vertical-align: top;
}

th {
  color: var(--navy);
  font-size: 0.82rem;
  background: #faf7f2;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge.active {
  color: #166534;
  background: #dcfce7;
}

.badge.pending {
  color: #92400e;
  background: #fef3c7;
}

.badge.inactive {
  color: #4b5563;
  background: #e5e7eb;
}

.badge.done {
  color: #14532d;
  background: #bbf7d0;
}

.badge.in-progress {
  color: #1e3a8a;
  background: #dbeafe;
}

.badge.new {
  color: #7c2d12;
  background: #ffedd5;
}

.empty {
  text-align: center;
  color: var(--gray);
  padding: 20px;
}

.split-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.split-actions-icons {
  gap: 6px;
}

.icon-action-btn {
  min-width: 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
}

.info-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.consent-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fdfaf3;
  padding: 10px 12px;
}

.consent-box input[type='checkbox'] {
  margin-top: 3px;
  accent-color: var(--navy);
}

.consent-box label {
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--gray-dark);
  cursor: pointer;
}

.btn.btn-disabled {
  opacity: 0.6;
}

.footer-lite {
  text-align: center;
  margin-top: 18px;
  color: var(--gray);
  font-size: 0.8rem;
}

body.ltr-mode {
  direction: ltr;
  text-align: left;
}

body.ltr-mode th,
body.ltr-mode td {
  text-align: left;
}

body.ltr-mode .split-actions {
  justify-content: flex-start;
}

body.ltr-mode .profile-menu-item {
  text-align: left;
}

@media (max-width: 980px) {
  .grid-2,
  .grid-3,
  .form-row,
  .admin-nav-grid,
  .detail-stats-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-inner {
    min-height: 70px;
  }

  .topbar-links {
    justify-content: flex-end;
  }

  .profile-menu {
    inset-inline-start: auto;
    inset-inline-end: 0;
  }
}

/* Smooth panel toggle transition */
.card[id*="Panel"],
#termsPanel,
#packageTermsPanel {
  animation: panelSlideIn 0.3s ease;
}

@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading spinner overlay */
.insurance-loading {
  position: fixed;
  inset: 0;
  background: rgba(248, 246, 242, 0.92);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity 0.3s ease;
}

.insurance-loading.fade-out {
  opacity: 0;
  pointer-events: none;
}

.insurance-loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(184, 147, 90, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: insuranceSpin 0.8s linear infinite;
}

.insurance-loading-text {
  color: var(--navy);
  font-size: 0.9rem;
  font-weight: 700;
}

@keyframes insuranceSpin {
  to { transform: rotate(360deg); }
}
