:root {
  color-scheme: light;
  --ink: #1c2430;
  --muted: #637083;
  --line: #d7dee8;
  --panel: #f6f8fb;
  --white: #ffffff;
  --blue: #285f8f;
  --blue-dark: #1d486d;
  --green: #2f7b5f;
  --gold: #c7962f;
  --coral: #c7604d;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--white);
  line-height: 1.55;
}

a {
  color: var(--blue-dark);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 28px;
  height: 32px;
  border: 3px solid var(--blue);
  border-radius: 4px;
  display: inline-block;
  position: relative;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  height: 3px;
  background: var(--blue);
  border-radius: 3px;
}

.brand-mark::before {
  top: 8px;
}

.brand-mark::after {
  top: 17px;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 14px;
}

.top-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 42px;
}

.hero {
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 38px;
  align-items: center;
  padding: 44px 0 28px;
}

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

h1 {
  margin: 0;
  font-size: clamp(38px, 7vw, 76px);
  line-height: 1.02;
  letter-spacing: 0;
  max-width: 760px;
}

h2 {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 12px;
  font-size: 20px;
}

p {
  margin: 0 0 14px;
}

.intro {
  margin-top: 18px;
  max-width: 680px;
  color: var(--muted);
  font-size: 20px;
}

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

button,
.button-link {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--blue);
  color: var(--white);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.ghost-button,
.tool-actions button,
.line-head button {
  background: var(--panel);
  color: var(--blue-dark);
  border: 1px solid var(--line);
}

.hero-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.hero-preview img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--white);
}

.tool-panel,
.template-section,
.notes-section,
.related-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 22px;
}

.tool-panel {
  box-shadow: 0 14px 38px rgba(28, 36, 48, 0.08);
}

.tool-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  align-items: start;
}

.total-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.total-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.total-card strong {
  display: block;
  margin-top: 4px;
  font-size: 32px;
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(380px, 1.1fr);
  gap: 18px;
  margin-top: 20px;
}

.invoice-form,
.invoice-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

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

label {
  display: grid;
  gap: 6px;
  font-weight: 750;
}

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

textarea {
  min-height: 96px;
  resize: vertical;
}

.line-editor {
  margin: 18px 0;
}

.line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.line-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 70px 100px 38px;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.line-row button {
  min-height: 42px;
  padding: 8px;
  background: var(--coral);
}

.invoice-sheet {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.invoice-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 16px;
}

.sheet-label {
  color: var(--blue-dark);
  font-weight: 850;
  text-transform: uppercase;
}

.sheet-meta {
  min-width: 160px;
  color: var(--muted);
}

.sheet-meta p,
.terms p {
  margin-bottom: 6px;
}

.bill-to {
  margin: 18px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.bill-to span,
.terms span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
}

.totals {
  max-width: 300px;
  margin: 18px 0 0 auto;
}

.totals p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.totals .grand {
  font-size: 22px;
  color: var(--blue-dark);
}

.terms {
  margin-top: 20px;
}

.template-section,
.notes-section,
.related-section {
  margin-top: 22px;
}

.template-section {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 20px;
  background: var(--panel);
}

.template-section ul {
  margin: 0;
  padding-left: 20px;
}

.template-section li + li {
  margin-top: 8px;
}

.table-wrap {
  overflow-x: auto;
}

.template-section table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

.notes-section {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
}

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

.notes-grid p {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

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

.related-card {
  min-height: 140px;
  display: block;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  background: var(--white);
}

.related-card span {
  display: block;
  color: var(--ink);
  font-weight: 850;
  margin-bottom: 8px;
}

.related-card small {
  color: var(--muted);
  line-height: 1.45;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 20px 36px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 960px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    justify-content: flex-start;
  }

  .hero,
  .tool-top,
  .builder-layout,
  .template-section,
  .notes-section {
    grid-template-columns: 1fr;
  }

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

  .notes-grid,
  .related-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .header-inner {
    padding-left: 14px;
    padding-right: 14px;
  }

  h1 {
    font-size: 40px;
  }

  .intro {
    font-size: 17px;
  }

  .tool-panel,
  .template-section,
  .notes-section,
  .related-section {
    padding: 16px;
  }

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

  .line-row button {
    width: 100%;
  }
}

@media print {
  .site-header,
  .hero,
  .invoice-form,
  .tool-actions,
  .template-section,
  .notes-section,
  .related-section,
  .site-footer {
    display: none !important;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .tool-panel,
  .invoice-preview,
  .invoice-sheet {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .builder-layout {
    display: block;
  }
}
