:root {
  --ink: #172126;
  --paper: #eef1ed;
  --panel: #fffefa;
  --line: #c2cac4;
  --muted: #5f6b69;
  --steel: #26343a;
  --blue: #1e6688;
  --amber: #c58b2f;
  --green: #276b4e;
  --shadow: 0 22px 54px rgba(23, 33, 38, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(38, 52, 58, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(30, 102, 136, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 30px 30px;
  font-family: "Aptos", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

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

button:hover,
.invoice-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(23, 33, 38, 0.13);
}

button:active,
.invoice-button:active {
  transform: translateY(0);
}

.primary {
  background: var(--steel);
  color: #fff;
}

.invoice-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  border-bottom: 1px solid rgba(38, 52, 58, 0.18);
  background: rgba(238, 241, 237, 0.94);
  backdrop-filter: blur(12px);
  padding: 0 32px;
}

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

.invoice-brand span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--steel);
  color: #fff;
  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(1240px, calc(100% - 32px));
  margin: 0 auto;
}

.invoice-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 36px;
  align-items: center;
  min-height: 500px;
  padding: 48px 0 24px;
}

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

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

h1 {
  max-width: 900px;
  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: 920px;
  color: #485557;
  font-size: 18px;
  line-height: 1.58;
}

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

.invoice-ledger,
.invoice-panel,
.invoice-sheet,
.demand-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.97);
  box-shadow: var(--shadow);
}

.invoice-ledger {
  padding: 22px;
}

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

.invoice-ledger div,
.summary-strip div {
  border-left: 4px solid var(--amber);
  background: #f7f7f0;
  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 {
  margin: 0 0 22px;
  padding: 16px 18px;
  color: #405052;
  line-height: 1.55;
}

.demand-note p {
  margin: 0;
}

.invoice-workflow {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(0, 1.1fr);
  gap: 22px;
  align-items: start;
  padding-bottom: 60px;
}

.invoice-panel {
  padding: 20px;
}

fieldset {
  min-width: 0;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0 0 22px;
  padding: 18px 0 0;
}

legend {
  padding-right: 10px;
  color: var(--steel);
  font-weight: 900;
}

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

.field-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

textarea {
  resize: vertical;
}

.invoice-row-list {
  display: grid;
  gap: 10px;
}

.invoice-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.75fr) minmax(180px, 2fr) minmax(70px, 0.55fr) minmax(70px, 0.6fr) minmax(80px, 0.7fr) minmax(82px, 0.7fr);
  gap: 10px;
  align-items: end;
  border: 1px solid #cfd6d1;
  border-radius: 8px;
  background: #fbfbf7;
  padding: 12px;
}

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

.instrumentation {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.fine-print {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.invoice-sheet {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 108px);
  overflow: auto;
  padding: 16px;
}

.sheet-label {
  margin-bottom: 12px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.invoice-document {
  border: 1px solid #d5d5ce;
  background: #fff;
  padding: 28px;
  box-shadow: 0 14px 28px rgba(23, 33, 38, 0.09);
}

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

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

.document-header > strong {
  align-self: flex-start;
  border: 1px solid var(--steel);
  border-radius: 8px;
  background: #f5f7f4;
  padding: 12px;
  font-size: 22px;
  white-space: nowrap;
}

.summary-strip,
.report-grid,
.totals-grid,
.signature-row {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.summary-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

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

.report-block {
  border: 1px solid #d6ddd7;
  border-radius: 8px;
  background: #fffefa;
  padding: 14px;
}

.report-block h3 {
  margin-bottom: 8px;
  color: var(--steel);
}

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

th,
td {
  border-bottom: 1px solid #e1e5e0;
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}

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

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

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

.signature-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.signature-row div {
  min-height: 82px;
  border-top: 2px solid var(--steel);
  padding-top: 10px;
}

.signature-row span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .invoice-hero,
  .invoice-workflow,
  .report-grid,
  .totals-grid {
    grid-template-columns: 1fr;
  }

  .invoice-sheet {
    position: static;
    max-height: none;
  }

  .field-grid,
  .field-grid.compact {
    grid-template-columns: 1fr;
  }

  .invoice-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .invoice-topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  main {
    width: min(100% - 22px, 1240px);
  }

  .invoice-hero {
    min-height: auto;
    padding-top: 34px;
  }

  .summary-strip,
  .signature-row,
  .invoice-ledger dl {
    grid-template-columns: 1fr;
  }

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

  .document-header > strong {
    white-space: normal;
  }

  .invoice-document {
    padding: 18px;
  }
}

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

  .invoice-topbar,
  .invoice-panel,
  .demand-note {
    display: none;
  }

  main,
  .invoice-workflow {
    display: block;
    width: 100%;
  }

  .invoice-sheet {
    position: static;
    max-height: none;
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  .invoice-document {
    border: 0;
    box-shadow: none;
  }
}
