:root {
  --ink: #08090a;
  --muted: #666b73;
  --paper: #ffffff;
  --surface: #f7f7f4;
  --line: #d9d9d2;
  --line-strong: #101112;
  --accent: #08090a;
  --shadow: 0 24px 80px rgba(8, 9, 10, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(8, 9, 10, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 9, 10, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 78% 10%, rgba(8, 9, 10, 0.08), transparent 25rem),
    linear-gradient(135deg, #ffffff 0%, #f3f3ef 48%, #ffffff 100%);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 28px;
  min-height: 100vh;
  padding: 28px;
}

.control-panel {
  align-self: start;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
  position: sticky;
  top: 28px;
}

.brand-lockup {
  display: grid;
  gap: 16px;
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--ink);
}

.brand-mark {
  display: block;
  width: min(100%, 280px);
  height: auto;
  border-radius: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: 0;
}

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

fieldset {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 12px;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

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

input::placeholder,
textarea::placeholder {
  color: #8a8d92;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 9, 10, 0.1);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

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

.secondary {
  background: #ecece7;
  color: var(--ink);
}

.invoice-stage {
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 12px 0 56px;
}

.invoice {
  position: relative;
  overflow: hidden;
  width: min(100%, 850px);
  min-height: 1040px;
  background: var(--paper);
  border: 1px solid rgba(18, 19, 26, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 48px;
}

.invoice-glow {
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--accent);
}

.invoice-header,
.invoice-hero,
.invoice-details,
.totals,
.invoice-footer {
  position: relative;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 52px 48px 42px;
  margin: -48px -48px 38px;
  background:
    linear-gradient(rgba(8, 9, 10, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 9, 10, 0.045) 1px, transparent 1px),
    linear-gradient(135deg, #ffffff 0%, #f6f6f1 100%);
  background-size: 34px 34px, 34px 34px, auto;
  border-bottom: 2px solid var(--ink);
}

.invoice-label {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.invoice-mark {
  display: block;
  width: min(100%, 390px);
  height: auto;
  margin-bottom: 24px;
}

h2 {
  margin: 0 0 8px;
  font-size: 2.2rem;
  line-height: 1;
  letter-spacing: 0;
  color: var(--ink);
}

.invoice-header p {
  margin-top: 0;
  color: var(--muted);
}

.invoice-meta {
  display: grid;
  gap: 7px;
  align-content: start;
  justify-items: end;
  color: var(--muted);
  font-weight: 700;
}

.invoice-meta span:first-child {
  color: var(--accent);
}

.invoice-hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  margin-bottom: 28px;
}

.invoice-hero > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: #fff;
}

.invoice-hero p,
.invoice-footer span,
.invoice-details span {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-hero strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.65rem;
  line-height: 1.12;
}

#previewAmount {
  color: var(--ink);
}

.invoice-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 30px;
}

.invoice-details > div {
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 28px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 17px 0;
  text-align: left;
}

th:not(:first-child),
td:not(:first-child) {
  text-align: right;
}

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

td {
  font-weight: 700;
}

.totals {
  display: grid;
  gap: 12px;
  justify-content: end;
  margin-bottom: 62px;
}

.totals > div {
  display: grid;
  grid-template-columns: 130px 160px;
  gap: 22px;
  align-items: center;
}

.totals span {
  color: var(--muted);
  font-weight: 700;
}

.totals strong {
  text-align: right;
  font-size: 1.18rem;
}

.grand-total {
  border-top: 3px solid var(--ink);
  padding-top: 14px;
}

.grand-total strong {
  color: var(--ink);
  font-size: 1.7rem;
}

.invoice-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: end;
  margin-top: auto;
  color: var(--muted);
}

.invoice-footer p {
  margin: 0;
  line-height: 1.5;
}

.invoice-footer > p {
  font-weight: 800;
  color: var(--ink);
}

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

  .control-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .control-panel,
  .invoice {
    padding: 20px;
  }

  .invoice-header {
    margin: -20px -20px 30px;
    padding: 34px 20px 30px;
  }

  .split,
  .invoice-header,
  .invoice-hero,
  .invoice-details,
  .invoice-footer {
    grid-template-columns: 1fr;
  }

  .invoice-header {
    display: grid;
  }

  .invoice-meta {
    justify-items: start;
  }

  .invoice {
    min-height: auto;
  }

  h2 {
    font-size: 1.75rem;
  }

  .invoice-hero strong {
    font-size: 1.32rem;
  }
}

@media print {
  @page {
    margin: 0.35in;
  }

  body {
    background: #fff;
  }

  .control-panel {
    display: none;
  }

  .app-shell,
  .invoice-stage {
    display: block;
    min-height: auto;
    padding: 0;
  }

  .invoice {
    width: 100%;
    min-height: 10.3in;
    border: 0;
    box-shadow: none;
    page-break-inside: avoid;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
