:root {
  --green-900: #075b39;
  --green-800: #08713f;
  --green-700: #0b874a;
  --green-100: #e6f4ed;
  --green-050: #f4faf7;
  --ink: #1c1f24;
  --muted: #6b7280;
  --line: #d8dedb;
  --paper: #ffffff;
  --app-bg: #eef2f0;
  --accent: #d9a441;
  --shadow: 0 18px 45px rgba(12, 27, 20, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--app-bg);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--green-800);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(700px, 1fr);
  min-height: 100vh;
}

.controls {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  background: #f8faf9;
  border-right: 1px solid var(--line);
}

.controls__header {
  margin-bottom: 20px;
}

.admin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 10px 12px;
  color: #ffffff;
  background: var(--green-900);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.admin-bar span {
  min-width: 100%;
}

.admin-bar a {
  flex: 1;
  min-width: 94px;
  padding: 8px 9px;
  color: #ffffff;
  text-align: center;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-800);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.controls h1 {
  margin-bottom: 0;
  font-size: 28px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.form-section h2 {
  margin-bottom: 2px;
  font-size: 16px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: #39433f;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cbd5d0;
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(11, 135, 74, 0.12);
}

textarea {
  resize: vertical;
}

.item-inputs {
  display: grid;
  gap: 10px;
}

.item-input-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 118px 34px;
  gap: 8px;
  align-items: end;
}

.item-input-row .row-number {
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--green-900);
  font-weight: 800;
}

.item-input-row label {
  gap: 4px;
  font-size: 11px;
}

.item-input-row button {
  height: 40px;
  border: 1px solid #d3d9d6;
  border-radius: 6px;
  color: #8b2e2e;
  background: #fff;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-bottom: 24px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 7px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--green-900);
  color: #ffffff;
  background: var(--green-800);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-button,
.ghost-button {
  border: 1px solid #ccd5d0;
  color: #22302a;
  background: #ffffff;
}

.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.auth-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(7, 91, 57, 0.95), rgba(8, 113, 63, 0.88)),
    var(--app-bg);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 430px);
  padding: 28px;
  background: #ffffff;
  border: 1px solid rgba(7, 91, 57, 0.22);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 76px;
  height: 76px;
  object-fit: contain;
  margin-bottom: 16px;
}

.auth-card h1 {
  margin-bottom: 18px;
  font-size: 28px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form .primary-button {
  width: 100%;
  margin-top: 4px;
}

.alert {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
}

.alert--error {
  color: #842029;
  background: #f8d7da;
  border: 1px solid #f1aeb5;
}

.alert--success {
  color: #0f5132;
  background: #d1e7dd;
  border: 1px solid #a3cfbb;
}

.auth-help {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.auth-links a {
  padding: 10px;
  text-align: center;
  text-decoration: none;
  border: 1px solid #ccd5d0;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
}

.preview-area {
  overflow: auto;
  padding: 28px;
}

.receipt-sheet {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 14mm 12mm 12mm;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-family: "Times New Roman", Times, serif;
}

.watermark {
  position: absolute;
  z-index: 0;
  top: 112mm;
  left: 50%;
  width: 72mm;
  opacity: 0.08;
  transform: translate(-50%, -50%);
}

.receipt-header,
.receipt-title,
.receipt-content,
.receipt-footer {
  position: relative;
  z-index: 1;
}

.receipt-header {
  display: grid;
  grid-template-columns: 28mm 1fr 47mm;
  gap: 4mm;
  align-items: center;
  padding-bottom: 4mm;
  border-bottom: 1.2pt solid #111111;
}

.logo-box img {
  width: 27mm;
  height: 30mm;
  object-fit: contain;
}

.brand-copy {
  font-family: Arial, Helvetica, sans-serif;
  color: #111111;
}

.brand-copy p {
  margin: 0;
  font-size: 8.5pt;
  line-height: 1.22;
}

.brand-kicker {
  margin-bottom: 1mm !important;
  font-size: 10pt !important;
  letter-spacing: 0;
}

.brand-name {
  margin-bottom: 1mm !important;
  font-size: 27pt !important;
  line-height: 1 !important;
  font-weight: 900;
}

.header-mission {
  min-height: 30mm;
  display: grid;
  align-content: center;
  gap: 1.8mm;
  padding-left: 5mm;
  border-left: 1.3pt solid #111111;
  color: var(--green-800);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15.5pt;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.receipt-title {
  padding: 7mm 0 4mm;
  text-align: center;
}

.receipt-title h2 {
  margin-bottom: 4mm;
  color: #111111;
  font-size: 14pt;
  text-decoration: underline;
}

.receipt-number {
  display: inline-grid;
  grid-template-columns: auto auto auto auto;
  gap: 3mm;
  align-items: center;
  font-size: 10.5pt;
}

.receipt-number span {
  color: #333333;
}

.receipt-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 51mm;
  gap: 5mm;
  align-items: start;
}

.donation-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: Arial, Helvetica, sans-serif;
}

.donation-table th {
  padding: 3.5mm 2mm;
  color: #ffffff;
  background: var(--green-800);
  border: 1px solid var(--green-800);
  font-size: 15pt;
  line-height: 1;
}

.donation-table .col-number {
  width: 13mm;
}

.donation-table .col-amount {
  width: 43mm;
}

.donation-table td {
  height: 12mm;
  padding: 1.5mm 2mm;
  border-bottom: 1px solid rgba(8, 113, 63, 0.76);
  color: var(--green-900);
  font-size: 12pt;
  font-weight: 700;
  vertical-align: middle;
}

.donation-table tbody td:first-child {
  text-align: center;
}

.donation-table .item-name {
  display: flex;
  align-items: center;
  gap: 2mm;
  min-width: 0;
}

.donation-table .item-label {
  flex-shrink: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.donation-table .dot-line {
  flex: 1;
  min-width: 5mm;
  border-bottom: 1px dotted rgba(8, 113, 63, 0.8);
}

.amount-line {
  display: flex;
  align-items: center;
  gap: 2mm;
}

.amount-line span:first-child {
  font-weight: 900;
}

.amount-line .amount-value {
  flex: 1;
  min-height: 5mm;
  border-bottom: 1px solid rgba(8, 113, 63, 0.72);
  color: #111111;
  font-weight: 700;
}

.donation-table tfoot td {
  height: 13mm;
  color: #ffffff;
  background: var(--green-800);
  border-bottom: 0;
  font-size: 17pt;
  font-weight: 900;
  text-align: right;
}

.donation-table tfoot td:last-child {
  color: #111111;
  background: #ffffff;
  border-top: 1px solid rgba(8, 113, 63, 0.76);
  border-bottom: 1px solid rgba(8, 113, 63, 0.76);
  font-size: 13pt;
  text-align: left;
  white-space: nowrap;
}

.donor-panel {
  padding: 4mm;
  border: 1.4pt solid rgba(8, 113, 63, 0.55);
  border-radius: 8px;
  font-family: Arial, Helvetica, sans-serif;
}

.donor-panel h3 {
  margin: -4mm -4mm 4mm;
  padding: 3mm 4mm;
  border-radius: 7px 7px 0 0;
  color: #ffffff;
  background: var(--green-800);
  font-size: 15pt;
  text-align: center;
}

.donor-panel dl {
  margin: 0;
  display: grid;
  gap: 3mm;
}

.donor-panel div {
  display: grid;
  grid-template-columns: 18mm 1fr;
  gap: 2mm;
  align-items: baseline;
}

.donor-panel dt {
  color: var(--green-800);
  font-size: 10.5pt;
  font-weight: 900;
}

.donor-panel dt::after {
  content: ":";
}

.donor-panel dd {
  min-height: 7mm;
  margin: 0;
  border-bottom: 1px solid rgba(8, 113, 63, 0.7);
  color: #111111;
  font-family: "Comic Sans MS", "Segoe Print", cursive;
  font-size: 12pt;
  line-height: 1.25;
  word-break: break-word;
}

.receipt-footer {
  margin-top: 9mm;
  font-family: Arial, Helvetica, sans-serif;
}

.closing {
  margin-bottom: 6mm;
  color: var(--green-900);
  font-size: 9.5pt;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
}

.signature-row {
  display: grid;
  grid-template-columns: 1fr 28mm 1fr;
  gap: 6mm;
  align-items: end;
}

.signature-block {
  text-align: center;
}

.signature-block p {
  margin-bottom: 17mm;
  font-family: "Times New Roman", Times, serif;
  font-size: 10pt;
}

.signature-block span {
  display: block;
  border-top: 1.2pt solid #111111;
}

.signature-block strong {
  display: block;
  margin-top: 3mm;
  font-family: "Times New Roman", Times, serif;
  font-size: 10pt;
}

.stamp-box img {
  width: 26mm;
  opacity: 0.88;
}

.contact-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3mm;
  margin-top: 8mm;
  padding-top: 3mm;
  border-top: 1px solid rgba(8, 113, 63, 0.3);
  color: var(--green-800);
  font-size: 8.5pt;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-section--wide,
  .actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .controls,
  .preview-area {
    padding: 16px;
  }

  .form-grid,
  .actions {
    grid-template-columns: 1fr;
  }

  .receipt-sheet {
    width: 100%;
    min-width: 210mm;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  body {
    background: #ffffff;
  }

  .controls {
    display: none;
  }

  .admin-bar {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .preview-area {
    overflow: visible;
    padding: 0;
  }

  .receipt-sheet {
    width: 210mm;
    min-height: 297mm;
    box-shadow: none;
  }
}
