/* ============ variables & reset ============ */
:root {
  --green: #0b6b53;
  --green-2: #0e8a6a;
  --green-3: #0a5642;
  --gold: #c9a44c;
  --ink: #10201b;
  --muted: #5d7069;
  --line: #dfe7e3;
  --bg: #eef4f1;
  --card: #ffffff;
  --danger: #c0362c;
  --ok: #14855f;
  --radius: 22px;
  --shadow: 0 18px 40px -22px rgba(10, 65, 50, 0.45);
  --shadow-sm: 0 6px 18px -12px rgba(10, 65, 50, 0.5);
  --font: 'Tajawal', 'Segoe UI', 'Noto Naskh Arabic', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
img {
  max-width: 100%;
  display: block;
}
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}
.hidden {
  display: none !important;
}
input[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(35%) sepia(30%) saturate(600%) hue-rotate(120deg);
  cursor: pointer;
}

/* ============ background ============ */
.page-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 45% at 100% 0%, rgba(11, 107, 83, 0.16), transparent 70%),
    radial-gradient(50% 40% at 0% 100%, rgba(201, 164, 76, 0.14), transparent 70%),
    linear-gradient(180deg, #f6faf8 0%, var(--bg) 100%);
}

/* ============ header ============ */
.site-head {
  background: linear-gradient(135deg, var(--green-3) 0%, var(--green) 55%, var(--green-2) 100%);
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 26px;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 28px 28px;
  box-shadow: 0 14px 30px -20px rgba(6, 54, 42, 0.9);
}
.site-head::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.5;
  pointer-events: none;
}
.head-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.logo {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.logo svg {
  width: 30px;
  height: 30px;
}
.head-text {
  flex: 1;
  min-width: 0;
}
.head-text h1 {
  font-size: 1.18rem;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.head-text p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  opacity: 0.9;
}
.admin-link {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: background 0.2s;
}
.admin-link:hover {
  background: rgba(255, 255, 255, 0.22);
}
.admin-link svg {
  width: 20px;
  height: 20px;
}

/* ============ layout ============ */
.wrap {
  width: 100%;
  max-width: 760px;
  margin: -14px auto 0;
  padding: 0 14px 28px;
  flex: 1;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid rgba(11, 107, 83, 0.06);
}

/* intro */
.intro-top h2 {
  font-size: 1.12rem;
  margin: 10px 0 6px;
  font-weight: 800;
}
.intro-top p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--green);
  background: rgba(11, 107, 83, 0.1);
  border-radius: 999px;
  padding: 3px 12px;
}
.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px 0 0;
  margin: 0;
}
.steps li {
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
}
.steps b {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(11, 107, 83, 0.1);
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
}
.banner-warn {
  margin-top: 14px;
  background: #fff7e6;
  border: 1px solid #f0d9a8;
  color: #7a5b12;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.84rem;
}

/* ============ form ============ */
.form-card {
  padding: 20px 18px 22px;
}
.form-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.form-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}
.required-note {
  font-size: 0.72rem;
  color: var(--muted);
}
.field {
  margin-bottom: 20px;
  position: relative;
}
.field > label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #17332b;
}
.req {
  color: var(--danger);
  font-style: normal;
}
.input {
  width: 100%;
  border: 1.6px solid var(--line);
  background: #fbfdfc;
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 0.98rem;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  min-height: 50px;
}
.input.ltr {
  direction: ltr;
  text-align: left;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
/* تاريخ الميلاد */
.cal-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #eef4f1;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 10px;
}
.cal-btn {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  padding: 8px 20px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.cal-btn.active {
  background: #fff;
  color: var(--green-3);
  box-shadow: 0 2px 8px -4px rgba(6, 54, 42, 0.5);
}
.cal-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-right: auto;
  padding-left: 8px;
}
.date-row {
  display: grid;
  grid-template-columns: 1fr 1.35fr 1.1fr;
  gap: 8px;
}
.date-row .select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235d7069' stroke-width='2'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 10px center;
  padding-left: 28px;
  padding-right: 12px;
  cursor: pointer;
}
.date-row .select:invalid,
.date-row .select option[value=''] {
  color: #96a8a2;
}
.date-row .select option {
  color: var(--ink);
}
.hint.hijri {
  color: var(--green-3);
  font-weight: 600;
  background: rgba(11, 107, 83, 0.07);
  border-radius: 9px;
  padding: 5px 10px;
  display: inline-block;
}
.input::placeholder {
  color: #96a8a2;
  letter-spacing: 0;
}
.input:focus {
  outline: none;
  border-color: var(--green-2);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(14, 138, 106, 0.12);
}
.hint {
  margin: 7px 2px 0;
  font-size: 0.76rem;
  color: var(--muted);
}
.err {
  margin: 7px 2px 0;
  font-size: 0.8rem;
  color: var(--danger);
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 6px;
}
.field.invalid .err {
  display: flex;
}
.field.invalid .input,
.field.invalid .combo input,
.field.invalid .upload {
  border-color: var(--danger);
  background: #fff8f7;
}
.field.invalid .err::before {
  content: '!';
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.field.shake {
  animation: shake 0.4s;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* combo */
.combo {
  position: relative;
}
.combo input {
  padding-left: 44px;
  padding-right: 14px;
  cursor: pointer;
}
.combo input.typing {
  cursor: text;
}
.combo-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
  transition: transform 0.2s;
}
.combo.open .combo-icon {
  transform: translateY(-50%) rotate(180deg);
}
.combo-clear {
  position: absolute;
  left: 38px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 0;
  background: #eef4f1;
  border-radius: 50%;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.combo-clear svg {
  width: 13px;
  height: 13px;
}
.combo-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 50px -22px rgba(6, 54, 42, 0.6);
  max-height: 290px;
  overflow-y: auto;
  padding: 6px;
  overscroll-behavior: contain;
}
.combo-list .opt-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.combo-list .opt small {
  flex: 0 0 auto;
}
.combo input.in-transfer {
  color: var(--danger);
  font-weight: 700;
}
.combo-list .opt {
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.combo-list .opt:hover,
.combo-list .opt.active {
  background: rgba(11, 107, 83, 0.08);
}
.combo-list .opt[aria-selected='true'] {
  background: rgba(11, 107, 83, 0.14);
  font-weight: 700;
}
.combo-list .opt small {
  color: var(--ok);
  font-size: 0.68rem;
  background: rgba(20, 133, 95, 0.1);
  padding: 1px 7px;
  border-radius: 999px;
  flex: 0 0 auto;
}
.combo-list .opt.notdb .opt-name {
  color: var(--danger);
}
.combo-list .opt small.tr {
  color: var(--danger);
  background: rgba(192, 54, 44, 0.1);
  font-weight: 700;
}
.db-warn {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: #8f2a22;
  background: #fdecea;
  border: 1px solid #f3c9c4;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 0.78rem;
  line-height: 1.5;
}
.db-warn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  margin-top: 3px;
}
.combo-list .empty-opt {
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.combo-list::-webkit-scrollbar {
  width: 8px;
}
.combo-list::-webkit-scrollbar-thumb {
  background: #cfdcd7;
  border-radius: 8px;
}

/* upload */
.upload {
  border: 2px dashed #c3d6d0;
  border-radius: 18px;
  background: #f9fcfb;
  min-height: 150px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}
.upload:focus-visible {
  outline: 3px solid rgba(14, 138, 106, 0.35);
  outline-offset: 2px;
}
.upload:hover {
  border-color: var(--green-2);
  background: #f3fbf8;
}
.upload-empty {
  text-align: center;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.upload-ico {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(11, 107, 83, 0.1);
  color: var(--green);
  display: grid;
  place-items: center;
  margin-bottom: 6px;
}
.upload-ico svg {
  width: 24px;
  height: 24px;
}
.upload-empty strong {
  font-size: 0.92rem;
}
.upload-empty span {
  font-size: 0.8rem;
  color: var(--muted);
}
.upload-empty small {
  font-size: 0.7rem;
  color: #93a8a1;
  margin-top: 4px;
}
.upload-preview {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
}
.upload-preview img {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #eef4f1;
}
.preview-meta {
  flex: 1 1 120px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
  text-align: right;
  min-width: 0;
}
.preview-meta span:first-child {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.84rem;
}
.preview-actions {
  flex: 0 0 100%;
  display: flex;
  gap: 8px;
}

/* buttons */
.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, opacity 0.15s;
  text-decoration: none;
  color: inherit;
  background: #eef4f1;
}
.btn:active {
  transform: scale(0.985);
}
.btn.primary {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-2) 100%);
  color: #fff;
  box-shadow: 0 16px 28px -16px rgba(11, 107, 83, 0.9);
}
.btn.primary:hover {
  box-shadow: 0 18px 30px -14px rgba(11, 107, 83, 0.85);
}
.btn.ghost {
  background: #fff;
  border: 1.4px solid var(--line);
  color: var(--green-3);
}
.btn.ghost:hover {
  border-color: var(--green-2);
  background: #f7fbf9;
}
.btn.danger {
  color: var(--danger);
}
.btn.sm {
  padding: 8px 14px;
  font-size: 0.8rem;
  border-radius: 11px;
}
.btn.big {
  width: 100%;
  padding: 16px;
  font-size: 1.02rem;
  border-radius: 16px;
}
.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2.4px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.submit-wrap {
  margin-top: 6px;
}
.privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 10px 0 0;
  text-align: center;
}
.privacy svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

/* success */
.success {
  text-align: center;
  padding: 30px 20px;
}
.success-badge {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  margin: 0 auto 14px;
  background: rgba(20, 133, 95, 0.12);
  color: var(--ok);
  display: grid;
  place-items: center;
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.success-badge svg {
  width: 34px;
  height: 34px;
}
@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.success h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}
.success > p {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 auto;
  max-width: 44ch;
}
.summary {
  text-align: right;
  margin: 18px auto 0;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fbfdfc;
}
.summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.summary div:last-child {
  border-bottom: 0;
}
.summary dt {
  color: var(--muted);
}
.summary dd {
  margin: 0;
  font-weight: 700;
  text-align: left;
  direction: ltr;
}
.summary dd.ar {
  direction: rtl;
  text-align: right;
}
.success-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.success-actions .btn {
  flex: 1;
  min-width: 140px;
}
.muted-note {
  font-size: 0.74rem;
  color: #93a8a1;
  margin-top: 14px;
}

/* footer */
.site-foot {
  text-align: center;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.78rem;
}
.site-foot p {
  margin: 2px 0;
}
.site-foot .tiny {
  font-size: 0.7rem;
  opacity: 0.75;
}

/* toast */
.toast-wrap {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
  padding: 0 14px;
}
.toast {
  background: #17332b;
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 0.86rem;
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.6);
  max-width: 460px;
  animation: toastIn 0.25s ease;
}
.toast.err {
  background: #8f2a22;
}
.toast.ok {
  background: #10674d;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@media (max-width: 380px) {
  .card {
    padding: 16px 14px;
  }
  .head-text h1 {
    font-size: 1.05rem;
  }
  .steps li {
    font-size: 0.7rem;
  }
}
@media (min-width: 720px) {
  .site-head {
    padding-bottom: 34px;
  }
  .head-text h1 {
    font-size: 1.4rem;
  }
  .card {
    padding: 26px 28px;
  }
  .upload-preview {
    grid-template-columns: 120px 1fr;
  }
  .upload-preview img {
    width: 120px;
    height: 120px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
