:root {
  --green: #063f20;
  --green-2: #0b632f;
  --gold: #c99a1e;
  --gold-2: #f4cf64;
  --ink: #111513;
  --muted: #4d5851;
  --line: #8c8c8c;
  --paper: #fffdf7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #e8ece7;
  font-family: Arial, Helvetica, sans-serif;
}

.page-shell {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 24px 16px 84px;
}

.membership-form {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 1420px;
  padding: 28px 34px 26px;
  background:
    radial-gradient(circle at 50% 103%, rgba(201, 154, 30, 0.2), transparent 16%),
    linear-gradient(180deg, #fff 0%, var(--paper) 100%);
  border: 5px solid var(--green);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
}

.membership-form::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px solid var(--gold);
  pointer-events: none;
  z-index: 0;
}

.membership-form > * {
  position: relative;
  z-index: 1;
}

.corner {
  position: absolute;
  width: 230px;
  height: 105px;
  background: linear-gradient(135deg, var(--green), var(--green-2) 54%, var(--gold) 55%, var(--gold-2));
  z-index: 0;
}

.corner-top-left {
  top: 0;
  left: 0;
  clip-path: ellipse(85% 70% at 0 0);
}

.corner-top-right {
  top: 0;
  right: 0;
  clip-path: ellipse(85% 70% at 100% 0);
  transform: scaleX(-1);
}

.corner-bottom-left {
  bottom: 0;
  left: 0;
  clip-path: ellipse(85% 70% at 0 100%);
  transform: scaleY(-1);
}

.corner-bottom-right {
  right: 0;
  bottom: 0;
  clip-path: ellipse(85% 70% at 100% 100%);
  transform: scale(-1);
}

.form-header {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 130px;
  gap: 24px;
  align-items: center;
  min-height: 280px;
}

.logo-frame {
  width: 245px;
  height: 245px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fff;
  border: 5px solid var(--green);
  border-radius: 50%;
}

.logo-frame img {
  width: 94%;
  height: 94%;
  object-fit: cover;
  border-radius: 50%;
}

.title-block {
  text-align: center;
  color: var(--green);
}

.title-block h1 {
  margin: 0;
  font-size: clamp(46px, 6vw, 74px);
  line-height: 0.98;
  letter-spacing: 0;
  font-weight: 900;
}

.urdu-title {
  margin: 22px 0 12px;
  color: var(--green);
  font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Nafees Nastaleeq", serif;
  font-size: clamp(34px, 4.6vw, 56px);
  font-weight: 700;
  line-height: 1.5;
}

.motto {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--green);
  font-size: 26px;
}

.motto span {
  width: 56px;
  height: 2px;
  background: var(--gold);
}

.motto b {
  color: var(--gold);
  font-size: 22px;
}

.photo-box {
  width: 126px;
  height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  overflow: hidden;
  border: 3px solid var(--green);
  border-radius: 8px;
  color: #1b1f1d;
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.photo-box input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.photo-box img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-box.has-photo span,
.photo-box.has-photo small {
  display: none;
}

.photo-box.has-photo img {
  display: block;
}

.photo-box span {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
}

.photo-box small {
  font-size: 14px;
}

.ribbon-title {
  width: min(650px, 78%);
  margin: 8px auto 22px;
  padding: 10px 28px 12px;
  color: #fff;
  background:
    linear-gradient(90deg, transparent 0 20px, var(--green) 20px calc(100% - 20px), transparent calc(100% - 20px)),
    linear-gradient(180deg, var(--green-2), var(--green));
  border-top: 4px solid var(--gold);
  border-bottom: 4px solid var(--gold);
  text-align: center;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 3px;
  text-transform: uppercase;
  clip-path: polygon(0 50%, 7% 0, 93% 0, 100% 50%, 93% 100%, 7% 100%);
}

.contact-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 10px 0;
  border-top: 2px solid #d7bd72;
  border-bottom: 2px solid #d7bd72;
  color: #202622;
  font-size: 16px;
}

.contact-strip div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  border-right: 1px solid #9e9e9e;
  white-space: nowrap;
}

.contact-strip div:last-child {
  border-right: 0;
}

.contact-icon {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 28px;
  padding: 0 5px;
  color: var(--green);
  border: 2px solid var(--green);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
}

form {
  margin-top: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 2px solid #d7bd72;
}

.form-section {
  min-height: 350px;
  padding: 0 20px 22px 0;
  border-bottom: 2px solid #d7bd72;
}

.form-section:nth-child(even) {
  padding-right: 0;
  padding-left: 24px;
  border-left: 2px solid #d7bd72;
}

.membership-details,
.declaration {
  border-bottom: 0;
  padding-top: 16px;
}

.form-section h2,
.office-panel h2 {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 310px;
  margin: 0 0 18px;
  padding: 7px 22px 7px 71px;
  color: #fff;
  background: var(--green);
  border-right: 10px solid transparent;
  clip-path: polygon(0 0, 92% 0, 100% 50%, 92% 100%, 0 100%, 8% 50%);
  font-size: 22px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
}

.form-section h2 span {
  position: absolute;
  left: 33px;
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green-2);
  border: 3px solid var(--gold);
  border-radius: 50%;
  font-size: 18px;
}

.line-field,
.stacked-field {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  min-height: 38px;
  margin: 9px 0;
  font-size: 17px;
  font-weight: 700;
}

.stacked-field {
  display: block;
  margin: 14px 0;
}

.stacked-field span {
  display: block;
  margin-bottom: 8px;
}

.line-field span {
  flex: 0 0 auto;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  color: #111;
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  font: 600 17px Arial, Helvetica, sans-serif;
  outline: none;
}

textarea {
  min-height: 64px;
  resize: vertical;
  line-height: 1.65;
}

input:focus,
textarea:focus {
  border-bottom-color: var(--green);
  box-shadow: 0 2px 0 rgba(201, 154, 30, 0.35);
}

.cnic-field input {
  height: 29px;
  border: 2px solid #898989;
  text-align: center;
}

.cnic-field input:nth-of-type(1) {
  flex: 0 0 110px;
}

.cnic-field input:nth-of-type(2) {
  flex: 0 0 158px;
}

.cnic-field input:nth-of-type(3) {
  flex: 0 0 44px;
}

.cnic-field b,
.date-field b {
  font-size: 18px;
}

.date-field input {
  flex: 0 0 76px;
  text-align: center;
}

.date-field input:last-of-type {
  flex-basis: 96px;
}

.date-labels {
  display: grid;
  grid-template-columns: 1fr 76px 76px 96px;
  gap: 9px;
  margin: -7px 0 8px;
  color: #202020;
  font-size: 12px;
  text-align: center;
}

.date-labels em {
  font-style: normal;
}

fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
  margin: 14px 0;
}

legend {
  padding: 0;
  margin-bottom: 12px;
  font-size: 17px;
  font-weight: 700;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 30px;
}

.option-row legend {
  margin: 0;
}

label:has(input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--green);
}

.membership-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px 24px;
}

.membership-options legend {
  grid-column: 1 / -1;
}

.two-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.postal-field {
  width: 58%;
}

.declaration p {
  margin: 0 0 22px;
  font-size: 17px;
  line-height: 1.55;
  font-weight: 600;
}

.signature-field {
  margin-top: 24px;
}

.office-panel {
  position: relative;
  margin-top: 18px;
  padding: 24px 20px 18px;
  border: 2px solid var(--gold);
  border-radius: 8px;
}

.office-panel h2 {
  position: absolute;
  left: 50%;
  top: -20px;
  min-width: 315px;
  justify-content: center;
  padding: 7px 25px;
  transform: translateX(-50%);
  border-top: 3px solid var(--gold);
  border-bottom: 3px solid var(--gold);
  clip-path: polygon(5% 0, 95% 0, 100% 50%, 95% 100%, 5% 100%, 0 50%);
  font-size: 21px;
}

.office-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 150px;
  gap: 28px;
  align-items: center;
}

.office-grid > div:nth-child(2) {
  padding-left: 26px;
  border-left: 2px solid var(--gold);
}

.stamp {
  width: 118px;
  height: 118px;
  display: grid;
  place-items: center;
  justify-self: center;
  color: var(--green);
  border: 2px dashed var(--green);
  border-radius: 50%;
  text-align: center;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.25;
}

.form-footer {
  display: grid;
  grid-template-columns: 1fr 260px 1fr;
  align-items: end;
  gap: 38px;
  margin-top: 20px;
}

.leader-card {
  overflow: hidden;
  border: 2px solid var(--green);
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.leader-card strong {
  display: block;
  padding: 7px;
  color: #fff;
  background: linear-gradient(180deg, var(--green-2), var(--green));
  font-size: 20px;
}

.signature-line {
  display: block;
  width: 62%;
  height: 28px;
  margin: 12px auto 3px;
  border-bottom: 2px solid #333;
}

.leader-card p {
  margin: 3px 10px 0;
  font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.45;
}

.leader-card small {
  display: block;
  margin: 0 8px 10px;
  font-size: 15px;
}

.flag-block {
  display: grid;
  justify-items: center;
  align-content: end;
  color: var(--green);
  font-size: 24px;
  font-weight: 900;
}

.flag-block img {
  width: 110px;
  height: 82px;
  object-fit: cover;
  object-position: 50% 34%;
  border-radius: 4px;
}

.bottom-contact {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1.2fr;
  gap: 14px;
  align-items: center;
  margin: 18px -34px -26px;
  padding: 14px 54px;
  color: #fff;
  background: linear-gradient(180deg, var(--green-2), var(--green));
  font-size: 15px;
}

.action-bar {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  gap: 10px;
  z-index: 10;
}

button {
  min-height: 44px;
  padding: 0 18px;
  color: #fff;
  background: var(--green);
  border: 2px solid var(--gold);
  border-radius: 6px;
  font: 800 15px Arial, Helvetica, sans-serif;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

button:hover {
  background: var(--green-2);
}

@media (max-width: 900px) {
  .page-shell {
    padding: 12px 8px 90px;
  }

  .membership-form {
    min-height: 0;
    padding: 22px 18px;
  }

  .form-header {
    grid-template-columns: 120px 1fr 96px;
    gap: 12px;
    min-height: 170px;
  }

  .logo-frame {
    width: 118px;
    height: 118px;
    border-width: 3px;
  }

  .title-block h1 {
    font-size: 34px;
  }

  .urdu-title {
    margin: 8px 0;
    font-size: 25px;
  }

  .motto {
    gap: 8px;
    font-size: 15px;
  }

  .motto span {
    width: 24px;
  }

  .photo-box {
    width: 94px;
    height: 126px;
  }

  .photo-box span {
    font-size: 15px;
  }

  .ribbon-title {
    width: 96%;
    font-size: 30px;
    letter-spacing: 1px;
  }

  .contact-strip,
  .form-grid,
  .office-grid,
  .form-footer,
  .bottom-contact {
    grid-template-columns: 1fr;
  }

  .contact-strip div {
    border-right: 0;
    border-bottom: 1px solid #d7bd72;
  }

  .contact-strip div:last-child {
    border-bottom: 0;
  }

  .form-section,
  .form-section:nth-child(even) {
    padding: 14px 0;
    border-left: 0;
  }

  .form-section h2,
  .office-panel h2 {
    min-width: min(100%, 330px);
    font-size: 18px;
  }

  .line-field,
  .option-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .line-field span {
    width: 100%;
  }

  .cnic-field input:nth-of-type(1),
  .cnic-field input:nth-of-type(2),
  .cnic-field input:nth-of-type(3),
  .date-field input,
  .date-field input:last-of-type {
    flex: 1 1 64px;
  }

  .date-labels {
    display: none;
  }

  .membership-options,
  .two-fields {
    grid-template-columns: 1fr;
  }

  .postal-field {
    width: 100%;
  }

  .office-panel {
    padding-top: 30px;
  }

  .office-grid > div:nth-child(2) {
    padding-left: 0;
    border-left: 0;
  }

  .flag-block {
    order: 3;
  }

  .bottom-contact {
    margin: 18px -18px -22px;
    padding: 14px 24px;
    text-align: center;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  body {
    background: #fff;
  }

  .page-shell {
    width: 100%;
    padding: 0;
  }

  .membership-form {
    min-height: auto;
    border-width: 4px;
    box-shadow: none;
    break-inside: avoid;
  }

  .action-bar {
    display: none;
  }

  input,
  textarea {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
