:root {
  --ink: #182331;
  --paper: #f5f7f2;
  --panel: #ffffff;
  --line: #cbd2d8;
  --muted: #64707c;
  --blue: #24313f;
  --red: #a64235;
  --gold: #b9822c;
  --green: #46684d;
  --shadow: 0 22px 56px rgba(24, 35, 49, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(36, 49, 63, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(36, 49, 63, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Aptos", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
.po-button {
  min-height: 44px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--panel);
  color: var(--blue);
  padding: 0 14px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 140ms ease-out, box-shadow 140ms ease-out, background-color 140ms ease-out;
}

button:hover,
.po-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(24, 35, 49, 0.12);
}

.primary {
  background: var(--blue);
  color: white;
}

.po-topbar {
  min-height: 68px;
  border-bottom: 1px solid rgba(36, 49, 63, 0.18);
  background: rgba(245, 247, 242, 0.94);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.po-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.po-brand span {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--red);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

nav a {
  text-decoration: none;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.po-hero {
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 370px);
  gap: 36px;
  align-items: center;
  padding: 54px 0 26px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  margin-bottom: 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 7vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
}

.lede {
  max-width: 820px;
  color: #45505c;
  font-size: 18px;
  line-height: 1.62;
}

.hero-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.po-ledger,
.po-panel,
.po-sheet,
.demand-note {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.po-ledger {
  border-radius: 8px;
  padding: 22px;
  transform: rotate(0.35deg);
}

.po-ledger dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.po-ledger div,
.summary-strip div {
  border-left: 4px solid var(--gold);
  background: #f8faf7;
  padding: 12px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

dd {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 900;
}

.demand-note {
  border-radius: 8px;
  margin: 0 0 22px;
  padding: 16px 18px;
  color: #40505e;
  line-height: 1.55;
}

.demand-note p {
  margin: 0;
}

.po-workflow {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(0, 1.1fr);
  gap: 22px;
  align-items: start;
  padding: 0 0 52px;
}

.po-panel,
.po-sheet {
  border-radius: 8px;
}

.po-panel {
  padding: 20px;
}

fieldset {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 20px 0 6px;
}

fieldset:first-child {
  border-top: 0;
  padding-top: 0;
}

legend {
  padding-right: 12px;
  color: var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
  color: #304050;
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid #bfc9d0;
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
  padding: 10px 11px;
  font: inherit;
}

textarea {
  resize: vertical;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.line-item-list {
  display: grid;
  gap: 12px;
}

.line-item-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.9fr) minmax(170px, 1.35fr) repeat(3, minmax(82px, 0.7fr));
  gap: 10px;
  border: 1px solid #d5dde2;
  border-radius: 8px;
  background: #f7fafb;
  padding: 12px;
}

.status-message,
.fine-print,
.instrumentation {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-message {
  min-height: 20px;
  margin: 12px 0;
  color: var(--green);
  font-weight: 800;
}

.instrumentation {
  border: 1px dashed #bfc9d0;
  border-radius: 8px;
  margin: 18px 0 10px;
  padding: 14px;
  background: #f9fbfa;
}

.instrumentation h2 {
  margin-bottom: 8px;
  font-size: 16px;
}

code {
  color: var(--red);
}

.po-sheet {
  position: sticky;
  top: 88px;
  overflow: hidden;
}

.sheet-label {
  border-bottom: 1px solid var(--line);
  background: var(--blue);
  color: white;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

#purchase-order-output {
  padding: 18px;
}

.po-document {
  border: 1px solid var(--line);
  background: white;
  padding: 18px;
}

.document-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 3px solid var(--blue);
  padding-bottom: 16px;
}

.document-header h2 {
  margin-bottom: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
}

.document-header strong {
  color: var(--red);
  font-size: 28px;
  white-space: nowrap;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.summary-strip strong {
  display: block;
  margin-top: 4px;
}

.report-block {
  border: 1px solid #dbe2e6;
  border-radius: 8px;
  margin-top: 14px;
  padding: 14px;
}

.report-block h3 {
  margin-bottom: 10px;
  color: var(--blue);
  font-size: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #e4e9ec;
  padding: 9px 7px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.totals-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.75fr);
  gap: 14px;
}

.total-card p {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
}

.total-card p:last-child {
  border-top: 2px solid var(--blue);
  margin-bottom: 0;
  padding-top: 10px;
  font-size: 18px;
}

@media (max-width: 900px) {
  .po-topbar,
  .po-hero,
  .po-workflow,
  .totals-grid {
    grid-template-columns: 1fr;
  }

  .po-topbar {
    align-items: flex-start;
    padding: 14px 18px;
  }

  .po-hero {
    min-height: auto;
  }

  .po-sheet {
    position: static;
  }

  .line-item-row,
  .field-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .document-header {
    flex-direction: column;
  }
}

@media print {
  body {
    background: white;
  }

  .po-topbar,
  .po-hero,
  .demand-note,
  .po-panel,
  .sheet-label {
    display: none;
  }

  main,
  .po-workflow {
    width: auto;
    display: block;
  }

  .po-sheet,
  .po-document {
    box-shadow: none;
    border: 0;
  }
}
