@font-face {
  font-family: "Carta Sans";
  src: url("/fonts/DejaVuSans.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Carta Sans";
  src: url("/fonts/DejaVuSans-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Carta Sans";
  src: url("/fonts/DejaVuSans-Oblique.ttf") format("truetype");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Carta Sans";
  src: url("/fonts/DejaVuSans-BoldOblique.ttf") format("truetype");
  font-style: italic;
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #1d252c;
  --muted: #62707c;
  --line: #d8dee4;
  --paper: #ffffff;
  --canvas: #f3f5f7;
  --brand: #c41f32;
  --brand-dark: #8d1724;
  --accent: #0f6f8f;
  --success: #247a4d;
  --radius: 8px;
  --shadow: 0 16px 40px rgba(31, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.primary:hover {
  background: var(--brand-dark);
}

.secondary {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 32px;
  color: #fff;
  background: #20272e;
}

.app-header h1,
.panel h2 {
  margin: 0;
}

.app-header h1 {
  font-size: 28px;
  line-height: 1.1;
}

.header-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.header-link-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
  text-decoration: none;
}

.header-link-button:hover {
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.78;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(520px, 1.08fr);
  gap: 20px;
  width: min(1500px, calc(100% - 40px));
  margin: 24px auto 40px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.capture-panel,
.template-panel,
.history-panel {
  grid-column: 1;
}

.preview-panel {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: start;
  justify-self: stretch;
  width: 100%;
  overflow: hidden;
}

.form-grid,
.search-grid {
  display: grid;
  gap: 14px;
}

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

.search-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.full-span {
  grid-column: 1 / -1;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

input:read-only,
textarea:read-only,
input:disabled,
select:disabled,
textarea:disabled {
  background: #f7f8fa;
}

.folio-pill,
.access-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  background: #edf2f7;
  color: #344252;
}


.feedback {
  border-radius: 6px;
  margin-bottom: 14px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.success-feedback {
  border: 1px solid rgba(36, 122, 77, 0.25);
  color: var(--success);
  background: rgba(36, 122, 77, 0.08);
}

.error-feedback {
  border: 1px solid rgba(141, 23, 36, 0.25);
  color: var(--brand-dark);
  background: rgba(196, 31, 50, 0.08);
}

.error-feedback p {
  margin: 0;
}

.field-error {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
}

.hint,
.status-line {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.letter-paper {
  width: 8.5in;
  min-height: 11in;
  margin: 0 auto;
  padding: 0.42in 0.66in 0.48in;
  color: #000;
  background: #fff;
  border: 1px solid #cfd5dc;
  font-family: "Carta Sans", Arial, Helvetica, sans-serif;
  font-size: 10pt;
  line-height: 1.22;
  overflow: hidden;
  zoom: 0.74;
}

.letter-paper,
.letter-paper * {
  font-family: "Carta Sans", Arial, Helvetica, sans-serif;
}

.letter-header {
  display: grid;
  grid-template-columns: 1fr 2.3in;
  gap: 0.16in;
  align-items: start;
  margin-bottom: 0.08in;
}

.letter-brand {
  display: flex;
  align-items: center;
  gap: 0.12in;
  min-width: 0;
}

.letter-logo {
  display: block;
  width: 4in;
  height: auto;
}

.letter-address {
  margin: 0;
  font-size: 6.8pt;
  font-style: normal;
  line-height: 1.08;
  text-transform: uppercase;
}


.letter-address strong {
  display: block;
  color: #000;
  font-weight: 700;
}

.letter-address span {
  display: block;
  margin-top: 0.02in;
  color: #1f4e79;
  font-weight: 500;
}
.letter-rule {
  grid-column: 1 / -1;
  height: 1px;
  margin-top: 0.25in;
  background: #3d3d3d;
}

.letter-title-block {
  text-align: center;
  margin-top: 0;
}

.letter-title-block h2 {
  margin: 0;
  color: #1f4e79;
  font-size: 12pt;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
}

.letter-title-block p {
  margin: 0.06in 0 0;
  color: #555;
  font-size: 7.7pt;
  font-weight: 400;
}

.letter-date {
  margin: 0.52in 0 0;
  font-size: 9.6pt;
  font-weight: 700;
  text-align: right;
  text-transform: uppercase;
}

.letter-summary {
  margin: 0.46in 0 0;
  font-size: 10pt;
  text-align: left;
}

.party-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.42in;
  margin: 0.32in 0 0;
  padding: 0 0.13in;
}

.party-card {
  min-height: 0.96in;
  border: 0.75pt solid #000;
  background: #f2f2f2;
}

.party-card h3 {
  margin: 0;
  padding: 0.04in 0.07in;
  color: #fff;
  background: #000;
  font-size: 10pt;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
}

.party-card-body {
  padding: 0.07in 0.07in 0.08in;
}

.party-card p {
  margin: 0 0 0.18in;
  font-size: 8.8pt;
  line-height: 1.12;
}

.party-card p:last-child {
  margin-bottom: 0;
}

.letter-data-table {
  width: 100%;
  margin-top: 0.62in;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 10pt;
}

.letter-data-table caption {
  caption-side: top;
  color: #1f4e79;
  font-size: 9.6pt;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  padding-bottom: 0.03in;
}

.letter-data-table td {
  border: 0.75pt solid #777;
  padding: 0.055in 0.08in;
  vertical-align: middle;
}

.letter-data-table .data-label {
  width: 27%;
  border-left: 0;
  border-top-color: transparent;
  border-bottom-color: transparent;
  background: #fff;
  font-style: italic;
  font-weight: 700;
  text-align: right;
}

.letter-data-table .data-value {
  width: 55%;
  background: #efefef;
  font-weight: 700;
}

.letter-data-table .data-note {
  width: 18%;
  background: #efefef;
  font-style: italic;
  line-height: 1.2;
}

.letter-operation-note,
.letter-recipient,
.letter-body,
.letter-closing {
  font-size: 10pt;
}

.letter-operation-note {
  margin: 0.08in 0 0;
  font-style: italic;
  font-weight: 700;
  text-align: right;
}

.letter-recipient {
  margin: 0.24in 0 0;
  font-weight: 700;
}

.letter-body {
  margin: 0.16in 0 0;
  text-align: justify;
}

.letter-closing {
  margin: 0.2in 0 0;
}

.letter-signature {
  margin-top: 0.52in;
  font-size: 10pt;
  font-weight: 700;
}

.letter-signature p {
  margin: 0;
  text-align: center;
}

.letter-signature p:first-child {
  text-align: left;
  margin-bottom: 0.55in;
}

.signature-line {
  width: 2.9in;
  height: 1px;
  margin: 0 auto 0.06in;
  background: #000;
}


.search-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.clear-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.clear-link:hover {
  text-decoration: underline;
}

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

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

.history-table th,
.history-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  white-space: nowrap;
}

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

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  color: #344252;
  background: #edf2f7;
  font-size: 12px;
  font-weight: 800;
}

.link-button {
  min-height: 32px;
  color: var(--accent);
  background: transparent;
  border: 1px solid transparent;
  padding: 0 8px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .capture-panel,
  .template-panel,
  .history-panel,
  .preview-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .preview-panel {
    order: 3;
  }

  .letter-paper {
    zoom: 0.88;
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .app-shell {
    width: min(100% - 24px, 1500px);
    margin-top: 14px;
  }

  .form-grid,
  .search-grid {
    grid-template-columns: 1fr;
  }

  .letter-paper {
    zoom: 0.43;
  }
}
.loaded-pill {
  color: #fff;
  background: var(--brand);
}

.loaded-feedback {
  border: 1px solid rgba(15, 111, 143, 0.25);
  color: var(--accent);
  background: rgba(15, 111, 143, 0.08);
}

.selected-row {
  background: rgba(196, 31, 50, 0.06);
}

a.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  color: var(--accent);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

a.link-button:hover {
  border-color: var(--accent);
  text-decoration: none;
}
