:root {
  --bg: #0f172a;
  --surface: #f8fafc;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --text-muted: #64748b;
  font-family: -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.landing__content {
  background: var(--surface);
  max-width: 520px;
  width: 100%;
  padding: 48px 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.landing__content h1 {
  font-size: 1.7rem;
  margin: 0 0 16px;
  line-height: 1.4;
}

.landing__subtitle {
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.8;
  margin: 0 0 32px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px 36px;
  font-size: 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

/* ---------------- Upload section ---------------- */

.upload {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px;
}

.upload__content {
  background: var(--surface);
  max-width: 720px;
  width: 100%;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.upload__content h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.upload__hint {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0 0 24px;
}

.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 28px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.file-drop:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.file-drop input[type="file"] {
  display: none;
}

.upload__status {
  margin: 20px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 0.9rem;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  min-width: 560px;
}

.summary-table th,
.summary-table td {
  text-align: right;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
}

.summary-table th {
  color: var(--text-muted);
  font-weight: 600;
}

.muted {
  color: var(--text-muted);
}

.confidence-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.confidence-high {
  background: #dcfce7;
  color: #166534;
}

.confidence-medium {
  background: #fef9c3;
  color: #854d0e;
}

.confidence-low {
  background: #fee2e2;
  color: #991b1b;
}

/* ---------------- Wizard ---------------- */

.wizard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 48px;
}

.wizard-steps {
  display: flex;
  gap: 8px;
  background: var(--surface);
  padding: 8px;
  border-radius: 999px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: not-allowed;
  color: var(--text-muted);
  font-size: 0.9rem;
  opacity: 0.55;
}

.wizard-step.is-reachable {
  cursor: pointer;
  opacity: 1;
}

.wizard-step.is-active {
  background: var(--accent);
  color: #fff;
  opacity: 1;
}

.wizard-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  font-size: 0.8rem;
}

.wizard-step.is-active .wizard-step__num {
  background: rgba(255, 255, 255, 0.25);
}

.wizard-panels {
  background: var(--surface);
  width: 100%;
  max-width: 900px;
  padding: 36px 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  min-height: 320px;
}

.wizard-panels h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.panel-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
  line-height: 1.7;
}

.wizard-nav {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
  border: none;
  padding: 12px 28px;
  font-size: 0.95rem;
  border-radius: 10px;
  cursor: pointer;
}

.btn-secondary:disabled,
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.field-row select,
.mapping-table select,
.mapping-table input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 0.88rem;
  background: #fff;
  min-width: 160px;
}

.entity-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 12px;
}

.entity-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #eef2ff;
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #1e293b;
}

.entity-tab::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  display: inline-block;
}

.entity-tab.entity-tab--ready::before {
  background: #16a34a;
}

.entity-tab.entity-tab--pending::before {
  background: #f59e0b;
}

.entity-tab.entity-tab--skipped::before {
  background: #cbd5e1;
}

.entity-tab.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
}

.entity-tab.is-active::before {
  background: #fff;
}

.entity-skip-note {
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.column-tools {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.column-tools h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.column-tools-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.column-tools-form select,
.column-tools-form input {
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
}

.column-tools-form input[type="text"] {
  width: 110px;
}

.column-tools-form .multi-select {
  min-width: 160px;
  height: 64px;
}

.derived-columns-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.derived-columns-list li {
  background: #e0e7ff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.derived-columns-list button {
  background: none;
  border: none;
  color: #4338ca;
  cursor: pointer;
  font-weight: bold;
  padding: 0;
  line-height: 1;
}

.transform-params {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.transform-params input {
  width: 90px;
  padding: 4px 6px;
  font-size: 0.78rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
}

.transform-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.transform-preview strong {
  color: #0f172a;
}

.errors-summary-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-weight: 600;
}

.errors-summary-banner.has-errors {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.errors-summary-banner.all-clear {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.entity-errors-block {
  margin-bottom: 24px;
}

.entity-errors-block h3 {
  margin-bottom: 8px;
}

.issue-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fff;
}

.issue-card.is-resolved {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.issue-card__message {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.issue-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.issue-card__actions button {
  font-size: 0.8rem;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
}

.issue-card__actions button.is-selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
}

.issue-card__actions input[type="text"] {
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.8rem;
  width: 140px;
}

.issue-card__status {
  font-size: 0.78rem;
  color: #16a34a;
  margin-inline-start: 8px;
}

.duplicate-resolver {
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}

.duplicate-resolver__strategies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.duplicate-resolver__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px dashed #fde68a;
  font-size: 0.85rem;
}

.duplicate-resolver__row input[type="text"] {
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.8rem;
  width: 120px;
}

.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.mapping-table th,
.mapping-table td {
  text-align: right;
  padding: 10px 8px;
  border-bottom: 1px solid #e2e8f0;
}

.mapping-table th {
  color: var(--text-muted);
  font-weight: 600;
}

.preview-summary p {
  margin: 6px 0;
}

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

.preview-columns h3 {
  font-size: 1rem;
  margin: 0 0 8px;
}

.preview-columns ul {
  margin: 0;
  padding-inline-start: 18px;
  font-size: 0.9rem;
  line-height: 1.8;
}

/* ---------------- Templates (حفظ/تحميل قوالب المطابقة) ---------------- */

.templates-box {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
}

.templates-box h3 {
  font-size: 1.05rem;
  margin: 0 0 6px;
}

.templates-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.templates-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f1f5f9;
  border-radius: 10px;
  flex-wrap: wrap;
}

.template-name {
  font-weight: 600;
  flex: 1 1 auto;
}

.template-date {
  font-size: 0.82rem;
}

.mapping-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.save-template-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 8px 0 0;
  min-height: 1.2em;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

.btn-danger:hover {
  background: #fecaca;
}

/* ---------------- Dry Run + Reconciliation Report ---------------- */

#preview-results h3 {
  margin: 28px 0 12px;
  font-size: 1.05rem;
}

#preview-results h3:first-child {
  margin-top: 0;
}

.dry-run-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
}

.dry-run-box h4 {
  font-size: 0.92rem;
  margin: 16px 0 8px;
  color: var(--text-muted);
}

.dry-run-critical,
.dry-run-warnings {
  margin: 8px 0 0;
  padding-inline-start: 20px;
  font-size: 0.9rem;
  line-height: 1.9;
}

.dry-run-critical li {
  color: #991b1b;
}

.dry-run-warnings li {
  color: #854d0e;
}

.export-box {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}

.export-box .btn-primary {
  padding: 14px 40px;
}

#export-status:not(:empty) {
  color: #991b1b;
  margin-top: 10px;
}

.done-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 20px 24px;
}

.done-box h3 {
  font-size: 0.95rem;
  margin: 18px 0 8px;
}

.done-box ul {
  margin: 0;
  padding-inline-start: 20px;
  line-height: 1.9;
}

.done-box .btn-secondary {
  margin-top: 18px;
}

@media (max-width: 640px) {
  .wizard-steps {
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 16px;
  }

  .wizard-panels {
    padding: 24px;
  }

  .preview-columns {
    grid-template-columns: 1fr;
  }

  .templates-list li {
    flex-direction: column;
    align-items: stretch;
  }
}
