:root {
  --brand: #c0392b;
  --brand-dark: #9c2d21;
  --brand-light: #fdf1ef;
  --ink: #1a1c23;
  --ink-soft: #5b5f6b;
  --ink-faint: #8a8f9c;
  --line: #e7e8ec;
  --bg: #f6f6f9;
  --card: #ffffff;
  --success: #12875a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.05), 0 1px 1px rgba(20, 20, 30, 0.03);
  --shadow-md: 0 8px 24px rgba(20, 20, 30, 0.08), 0 2px 6px rgba(20, 20, 30, 0.04);
  --shadow-lg: 0 20px 48px rgba(20, 20, 30, 0.12), 0 6px 16px rgba(20, 20, 30, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 0%, rgba(192, 57, 43, 0.07), transparent 42%),
    radial-gradient(circle at 100% 8%, rgba(15, 23, 42, 0.05), transparent 38%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Header ---------------- */
.app-header {
  background: linear-gradient(120deg, #14152a 0%, #1f2140 55%, #2a1520 100%);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.18);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 4px;
}

.app-header .brand-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.app-header .brand-subtitle {
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ---------------- Layout shell ---------------- */
main {
  max-width: 980px;
  margin: 0 auto;
}

#app-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}

/* ---------------- Step indicator ---------------- */
.step-nav {
  border-bottom: none;
  gap: 8px;
  padding-bottom: 20px;
  margin-bottom: 24px !important;
  position: relative;
}

.step-nav::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--line);
}

.step-nav .nav-link {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-faint);
  background: #f1f2f5;
  border-radius: 999px;
  padding: 8px 16px;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  display: inline-block;
}

.step-nav .nav-link.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(192, 57, 43, 0.35);
  transform: translateY(-1px);
}

.step-nav .nav-link.done {
  background: var(--brand-light);
  color: var(--brand-dark);
}

.step-nav .nav-link.done::before {
  content: "✓ ";
}

/* ---------------- Section headings ---------------- */
.step-section h5 {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.step-num {
  color: var(--brand);
}

/* ---------------- Form controls ---------------- */
.form-label {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.form-control,
.form-select {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.1);
}

.form-check-input:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}

.form-check-input:focus {
  box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.1);
}

/* ---------------- Buttons ---------------- */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 10px 22px;
  transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn-danger {
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 6px 16px rgba(192, 57, 43, 0.28);
}

.btn-danger:hover,
.btn-danger:focus {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  box-shadow: 0 8px 20px rgba(192, 57, 43, 0.36);
  transform: translateY(-1px);
}

.btn-danger:disabled {
  background: #e7c3bd;
  border-color: #e7c3bd;
  box-shadow: none;
  transform: none;
}

.btn-outline-secondary {
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-outline-secondary:hover {
  background: #f1f2f5;
  border-color: var(--line);
  color: var(--ink);
}

.btn-outline-primary {
  color: #0d6efd;
  border-color: #cfe0ff;
  background: #f5f9ff;
}

.btn-outline-primary:hover {
  background: #0d6efd;
  border-color: #0d6efd;
}

/* ---------------- Post search & filter ---------------- */
.search-input-wrap {
  position: relative;
}

.search-input-wrap i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-input-wrap .form-control {
  padding-left: 38px;
}

/* ---------------- Pagination ---------------- */
.page-btn {
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.page-ellipsis {
  color: var(--ink-faint);
  font-size: 0.82rem;
  padding: 0 4px;
}

/* ---------------- Post selection cards ---------------- */
.post-card {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  cursor: pointer;
  background: var(--card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.post-card:hover {
  border-color: rgba(192, 57, 43, 0.4);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.post-card.selected {
  border-color: var(--brand);
  background: var(--brand-light);
  box-shadow: 0 4px 14px rgba(192, 57, 43, 0.15);
}

.post-card .post-name {
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--ink);
}

.post-type-tag {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: 6px;
  vertical-align: middle;
}

.post-type-tag.regular {
  background: #e6f4ea;
  color: var(--success);
}

.post-type-tag.contract {
  background: #fff2e0;
  color: #b7620a;
}

.post-card .post-meta {
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.post-card .post-fee {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.post-card .post-vacancy-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef2ff;
  color: #3949ab;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ---------------- Repeatable tables ---------------- */
.repeatable-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.repeatable-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.repeatable-table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  background: #f8f8fa;
  padding: 10px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.repeatable-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.repeatable-table tr:last-child td {
  border-bottom: none;
}

.repeatable-table td.fixed-label {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  padding-left: 12px;
}

.repeatable-table input:not([type="checkbox"]):not([type="radio"]),
.repeatable-table select {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 0.84rem;
  width: 100%;
  min-width: 110px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.repeatable-table input:not([type="checkbox"]):not([type="radio"]):focus,
.repeatable-table select:focus {
  border-color: var(--brand);
  background: #fff;
  outline: none;
}

.repeatable-table input:not([type="checkbox"]):not([type="radio"]):hover,
.repeatable-table select:hover {
  background: #f8f8fa;
}

.repeatable-table input[type="checkbox"] {
  width: 1.15em;
  height: 1.15em;
  margin: 0;
  cursor: pointer;
}

.row-remove-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.row-remove-btn:hover {
  background: #fdecea;
  color: var(--brand);
}

.add-row-btn {
  border: 1.5px dashed var(--line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.add-row-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

/* ---------------- Declarations (Part I) ---------------- */
.declaration-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.declaration-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: #fbfbfc;
}

.declaration-item-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.declaration-item-question span {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

.declaration-item-question .form-select {
  width: auto;
  min-width: 140px;
}

.declaration-item .form-label {
  margin-top: 10px;
}

/* ---------------- Upload fields ---------------- */
.upload-field.uploaded .upload-btn {
  border-color: var(--success);
  color: var(--success);
  background: #ecf9f3;
}

.upload-remove-btn {
  flex: 0 0 auto;
  width: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------- Document checklist (Part K) ---------------- */
.document-checklist-item {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.document-checklist-item:has(.form-check-input:checked) {
  border-color: rgba(192, 57, 43, 0.3);
  background: var(--brand-light);
}

.document-upload-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  margin-left: 26px;
}

.document-upload-row .doc-upload-btn {
  min-width: 160px;
}

.document-upload-row .doc-upload-btn.uploaded {
  border-color: var(--success);
  color: var(--success);
  background: #ecf9f3;
}

.doc-remove-btn {
  flex: 0 0 auto;
  width: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------- Examination Experience (Part F) ---------------- */
.exam-roles-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-role-item {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.exam-role-item:has(.form-check-input:checked) {
  border-color: rgba(192, 57, 43, 0.3);
  background: var(--brand-light);
}

.exam-role-count-wrap {
  margin-top: 8px;
  margin-left: 26px;
}

.exam-role-count-input {
  max-width: 220px;
}

/* ---------------- Resume login ---------------- */
.resume-section {
  background: #f8f8fa;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
}

/* ---------------- Application number banner ---------------- */
.application-number-banner {
  background: linear-gradient(135deg, #eefaf3 0%, #fff 100%);
  border: 1px solid rgba(18, 135, 90, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.application-number-banner i {
  color: var(--success);
  margin-right: 6px;
}

.application-number-banner strong {
  color: var(--ink);
  letter-spacing: 0.02em;
}

/* ---------------- Review summary ---------------- */
#review-summary {
  background: linear-gradient(135deg, var(--brand-light) 0%, #fff 100%);
  border: 1px solid rgba(192, 57, 43, 0.15);
  border-radius: var(--radius-sm);
}

/* ---------------- Submitted state ---------------- */
#submitted-section i.bi-check-circle-fill {
  filter: drop-shadow(0 6px 16px rgba(18, 135, 90, 0.35));
}

/* ---------------- Alerts ---------------- */
.alert {
  border-radius: var(--radius-sm);
  border: none;
}

.alert-danger {
  background: #fdecea;
  color: #b3261e;
}

.alert-warning {
  background: #fff6e5;
  color: #8a5a00;
}

/* ---------------- Mobile ---------------- */
@media (max-width: 576px) {
  .app-header .container {
    gap: 10px;
  }

  .app-logo {
    height: 36px;
  }

  .app-header .brand-title {
    font-size: 0.86rem;
  }

  .app-header .brand-subtitle {
    font-size: 0.68rem;
  }

  main {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  #app-card {
    padding: 16px !important;
    border-radius: var(--radius-sm);
  }

  .step-section h5 {
    font-size: 1rem;
  }

  /* Touch-friendly horizontal scroll for the step pills, no visible scrollbar. */
  .step-nav {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .step-nav::-webkit-scrollbar {
    display: none;
  }

  .step-nav .nav-link {
    font-size: 0.72rem;
    padding: 7px 13px;
  }

  .post-card {
    padding: 14px;
  }

  .post-card .text-end {
    text-align: left !important;
  }

  .resume-section .row.g-2 > div {
    width: 100%;
  }

  .resume-section .col-md-5.d-flex {
    flex-direction: column;
  }

  .resume-section .col-md-5.d-flex .btn {
    width: 100%;
  }

  /* Repeatable tables: readable minimum column width + scroll, rather than
     squeezing inputs illegibly narrow to fit the viewport. */
  .repeatable-table {
    min-width: 560px;
  }

  .repeatable-table th,
  .repeatable-table td {
    padding: 8px 10px;
  }

  #nav-buttons {
    gap: 10px;
  }

  #nav-buttons .btn {
    flex: 1;
    padding-left: 14px;
    padding-right: 14px;
  }

  .application-number-banner {
    font-size: 0.8rem;
  }
}
