/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

:root {
  --ink: #1c2430;
  --muted: #6b7684;
  --line: #d8dee6;
  --accent: #1f5fbf;
  --paper: #ffffff;
  --bg: #eef1f5;
}

body {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
  background: var(--bg);
}

.app-header,
.form-panel {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial,
    sans-serif;
}

/* ---------- App header ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.app-tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.primary-button {
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.primary-button:hover {
  background: #17498f;
}

.print-controls {
  text-align: right;
}

.print-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  max-width: 16rem;
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  align-items: flex-start;
}

.form-panel {
  flex: 0 0 26rem;
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}

.preview-panel {
  flex: 1;
  min-width: 0;
}

@media (max-width: 60rem) {
  .layout {
    flex-direction: column;
  }
  .form-panel {
    flex: none;
    position: static;
    max-height: none;
    width: 100%;
  }
}

/* ---------- Form ---------- */

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  margin: 0 0 1rem;
  padding: 1rem;
}

legend {
  font-weight: 600;
  padding: 0 0.4rem;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

label.inline-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
}

label.inline-field input {
  display: inline-block;
  width: 6rem;
  margin-top: 0;
}

textarea {
  resize: vertical;
}

.row-list {
  margin-bottom: 0.5rem;
}

.row {
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed var(--line);
}

.line-item-row {
  display: grid;
  grid-template-columns: 1fr 4.5rem 5rem 2rem;
  gap: 0.4rem;
  align-items: center;
}

.milestone-row .row-top {
  display: grid;
  grid-template-columns: 1fr 6rem 2rem;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.row input {
  margin-top: 0;
}

.remove-button {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem;
}

.remove-button:hover {
  color: #b23b3b;
}

.add-button {
  border: 1px dashed var(--line);
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

.add-button:hover {
  border-color: var(--accent);
}

/* ---------- Proposal preview ---------- */

.sheet {
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  padding: 3rem 3.5rem;
  margin-bottom: 1.5rem;
  line-height: 1.55;
}

.sheet h1 {
  font-size: 2rem;
  margin: 0.5rem 0 0.75rem;
}

.sheet h2 {
  font-size: 1.3rem;
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--ink);
}

.sheet h2:first-child {
  margin-top: 0;
}

.sheet h3 {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.4rem;
}

.cover-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.8rem;
  color: var(--muted);
}

.cover-client {
  font-size: 1.1rem;
  margin: 0 0 0.25rem;
}

.cover-byline {
  color: var(--muted);
  margin: 0 0 2rem;
}

.placeholder {
  color: #a5aeb8;
  font-style: italic;
}

.section-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 1.25rem;
}

/* Quote table */

.quote-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.quote-table th,
.quote-table td {
  padding: 0.5rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.quote-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.quote-table .num {
  text-align: right;
  white-space: nowrap;
}

.quote-table tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--ink);
  font-weight: bold;
  padding-top: 0.6rem;
}

/* Timeline */

.timeline {
  padding-left: 1.25rem;
  margin: 0;
}

.timeline li {
  margin-bottom: 1rem;
}

.timeline p {
  margin: 0.2rem 0 0;
}

.milestone-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.timeframe {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Terms */

.sheet ul {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.25rem;
}

.sheet ul li {
  margin-bottom: 0.35rem;
}

.contact-block {
  margin-top: 0.25rem;
}

.contact-line {
  display: block;
}

.contact-block a {
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Footer ---------- */

.site-footer {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial,
    sans-serif;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem 1.5rem 2rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Print (A4 via browser Print to PDF) ---------- */

@page {
  size: A4;
  margin: 18mm 16mm;
}

@media print {
  .no-print {
    display: none;
  }

  body {
    background: #fff;
  }

  .layout {
    display: block;
    padding: 0;
  }

  .preview-panel {
    width: 100%;
  }

  /* Empty optional fields are omitted entirely from printed output. */
  .placeholder {
    display: none !important;
  }

  .sheet {
    box-shadow: none;
    padding: 0;
    margin: 0 0 2.5rem;
  }

  /* Cover gets its own page; sections 2-5 flow continuously. */
  .cover {
    break-after: page;
  }

  /* Semantic blocks stay on one page; row/item rules below are the
     fallback for blocks too long to fit a single page. */
  .keep-together {
    break-inside: avoid;
  }

  .quote-table tr,
  .timeline li,
  .sheet ul li {
    break-inside: avoid;
  }

  .sheet h2,
  .sheet h3 {
    break-after: avoid;
  }

  .contact-block a {
    color: var(--ink);
  }
}
