:root {
  --ui-bg: #f3f4f6;
  --ui-panel: #ffffff;
  --ui-border: #d1d5db;
  --ui-text: #111827;
  --ui-muted: #6b7280;

  --page-width: 816px;
  --page-height: 1056px;
  --page-pad-top: 96px;
  --page-pad-bottom: 96px;
  --page-pad-left: 72px;
  --page-pad-right: 72px;

  --page-pad-top-with-logo: 144px;

  --doc-font: "Times New Roman", Times, serif;
  --doc-font-size: 16px;
  --doc-line: 1.22;
  --doc-color: #000000;
  --doc-rule: #000000;
}

* {
  box-sizing: border-box;
}

html, body {
  min-width: 0;
}

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

img {
  max-width: 100%;
}

.app-shell {
  padding: 18px;
}

.app-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.toolbar-left h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.toolbar-left p {
  margin: 0;
  color: var(--ui-muted);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  padding: 10px 14px;
  border: 1px solid var(--ui-border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
}

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr 360px;
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  padding: 16px;
}

.panel h2 {
  margin-top: 0;
  font-size: 16px;
}

#jsonInput {
  width: 100%;
  min-height: 780px;
  resize: vertical;
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  padding: 12px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f9fafb;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 12px;
  min-height: 140px;
  font-size: 12px;
  line-height: 1.45;
}

.panel-preview {
  overflow: auto;
}

.packet-mount {
  min-height: 1100px;
  width: 100%;
  background: #e5e7eb;
  border-radius: 12px;
  padding: 24px 24px 40px;
  display: block;
  overflow: auto;
}

.packet-root {
  width: 100%;
  max-width: calc(var(--page-width) + 48px);
  margin: 0 auto;
  padding-bottom: 8px;
}

.doc-page {
  position: relative;
  width: var(--page-width);
  min-width: var(--page-width);
  max-width: var(--page-width);
  height: var(--page-height);
  min-height: var(--page-height);
  max-height: var(--page-height);
  margin: 0 auto 24px;
  background: #fff;
  color: var(--doc-color);
  font-family: var(--doc-font);
  font-size: var(--doc-font-size);
  line-height: var(--doc-line);
  padding:
    var(--page-pad-top)
    var(--page-pad-right)
    var(--page-pad-bottom)
    var(--page-pad-left);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  page-break-after: always;
  break-after: page;
  overflow: hidden;
  contain: layout paint;
}

.doc-page-body {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.doc-page-body > *:first-child {
  margin-top: 0 !important;
}

.doc-page-body > *:last-child {
  margin-bottom: 0 !important;
}

.doc-page.with-logo {
  padding-top: var(--page-pad-top-with-logo);
}

.doc-page.no-logo {
  padding-top: var(--page-pad-top);
}

.doc-page + .doc-page {
  margin-top: 0;
}

.doc-page-header {
  position: absolute;
  top: 26px;
  left: var(--page-pad-left);
  right: var(--page-pad-right);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 52px;
  pointer-events: none;
}

.doc-page-header img {
  display: block;
  max-width: 260px;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.doc-page-header img.logo-image {
  display: block;
  max-width: 260px;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.doc-page.no-logo .doc-page-header {
  display: none;
}

.doc-page-footer {
  position: absolute;
  left: var(--page-pad-left);
  right: var(--page-pad-right);
  bottom: 26px;
  text-align: center;
  font-family: var(--doc-font);
  font-size: 13.333px; /* 10pt */
  line-height: 1.15;
  color: #000;
  white-space: nowrap;
  pointer-events: none;
}

.doc-page.no-footer .doc-page-footer {
  display: none;
}

.doc-title {
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  margin: 0 0 18px;
}

.doc-title.main {
  font-size: 22px;
}

.doc-title.sub {
  margin-bottom: 8px;
}

.doc-paragraph {
  margin: 0 0 10px;
  text-align: justify;
}

.doc-list {
  margin: 2px 0 12px 22px;
  padding: 0;
}

.doc-list li {
  margin: 0 0 6px;
}

.doc-section {
  margin-bottom: 12px;
}

.doc-clause {
  margin: 0 0 10px;
  text-align: justify;
}

.doc-clause-number {
  font-weight: 700;
}

.doc-center {
  text-align: center;
}

.doc-small-gap {
  margin-top: 4px;
}

.doc-medium-gap {
  margin-top: 12px;
}

.doc-large-gap {
  margin-top: 24px;
}

.doc-note {
  text-align: center;
  font-style: italic;
  margin: 12px 0;
}

.doc-signature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 34px;
}

.doc-signature-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: end;
  column-gap: 10px;
}

.doc-date-label {
  white-space: nowrap;
}

.doc-line-wrap {
  position: relative;
  min-height: 34px;
  border-bottom: 1px solid var(--doc-rule);
}

.doc-signature-caption {
  margin-top: 6px;
  text-align: center;
}

.doc-signature-caption.small {
  font-size: 15px;
}

.doc-signer-stack {
  margin-top: 18px;
}

.doc-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.doc-form-line {
  border-bottom: 1px solid #000;
  min-height: 22px;
  display: inline-block;
  min-width: 120px;
}

.doc-form-line.long {
  min-width: 320px;
}

.doc-form-line.medium {
  min-width: 220px;
}

.doc-form-line.short {
  min-width: 100px;
}

.doc-checkbox-line {
  margin: 8px 0;
}


.doc-field-anchor {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  background: transparent;
}

.doc-field-anchor.signature {
  left: 0;
  top: 2px;
  width: 220px;
  height: 26px;
}

.doc-field-anchor.date {
  left: 0;
  top: 2px;
  width: 110px;
  height: 22px;
}

.doc-field-anchor.initials {
  left: 0;
  top: 0;
  width: 120px;
  height: 18px;
}

.doc-subtitle-strong {
  text-align: center;
  font-weight: 700;
  margin: 2px 0 12px;
}

.doc-sign-stack {
  margin-top: 14px;
}

.doc-sign-row {
  display: grid;
  grid-template-columns: 48px 138px 64px 1fr;
  gap: 6px;
  align-items: end;
  margin-bottom: 2px;
}

.doc-sign-label {
  white-space: nowrap;
  padding-bottom: 1px;
}

.doc-sign-line {
  position: relative;
  min-height: 26px;
  border-bottom: 1px solid #000;
}

.doc-sign-line-filled {
  display: flex;
  align-items: center;
  padding: 0 8px;
}

.doc-sign-line-value {
  display: inline-block;
  width: 100%;
}

.doc-sign-line.doc-sign-date {
  width: 138px;
}

.doc-sign-line.doc-sign-signature {
  width: 100%;
}

.doc-sign-caption-row {
  display: grid;
  grid-template-columns: 48px 138px 64px 1fr;
  gap: 6px;
  align-items: start;
  margin-bottom: 18px;
}

.doc-sign-caption {
  grid-column: 4;
  text-align: center;
  width: 100%;
  padding-top: 2px;
}

.doc-ccpa-sign-stack {
  margin-top: 18px;
}

.doc-payment-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
  margin: 10px 0 12px;
}

.doc-table-lite.schedule-table td,
.doc-table-lite.schedule-table th {
  text-align: center;
  font-size: 14px;
  padding: 5px 6px;
}

.doc-balance-table td:first-child,
.doc-balance-table th:first-child {
  width: 42%;
}

.doc-clause strong,
.doc-paragraph strong,
.doc-center strong {
  font-weight: 700;
}

.doc-bullet-sub {
  margin-left: 18px;
}

.doc-check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin: 10px 0;
}

.doc-check-boxline {
  white-space: pre-wrap;
  margin: 0 0 4px;
}

.doc-form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  margin: 10px 0 12px;
}

.doc-inline-line {
  display: inline-block;
  min-width: 160px;
  border-bottom: 1px solid #000;
  min-height: 20px;
  vertical-align: bottom;
}

.doc-inline-line.short {
  min-width: 100px;
}

.doc-inline-line.medium {
  min-width: 180px;
}

.doc-inline-line.long {
  min-width: 280px;
}

.doc-note-tight {
  text-align: center;
  font-style: italic;
  margin: 8px 0;
}

.doc-info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 10px 0 12px;
}

.doc-info-line {
  display: block;
  margin: 0;
}

.doc-info-label {
  font-weight: 700;
}

.doc-payment-separator {
  border-top: 1px solid #000;
  margin: 12px 0 12px;
}

.doc-payment-box-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0 16px;
}

.doc-payment-box {
  width: 78%;
  border: 1px solid #000;
  padding: 12px 16px;
}

.doc-payment-box-title {
  font-weight: 700;
  font-size: 18px;
  text-decoration: underline;
  margin: 0 0 10px;
}

.doc-payment-subchecks {
  margin: 6px 0 12px;
}

.doc-payment-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  column-gap: 10px;
  align-items: end;
  margin: 6px 0;
}

.doc-payment-row-label {
  white-space: nowrap;
}

.doc-payment-row-label strong {
  font-weight: 700;
}

.doc-answer-line {
  display: inline-block;
  width: 100%;
  min-height: 20px;
  border-bottom: 1px solid #000;
  vertical-align: bottom;
}

.doc-answer-line .doc-field-value {
  display: inline-block;
  padding-bottom: 1px;
}

.doc-legal-fineprint {
  font-size: 14px;
  font-style: italic;
  text-align: justify;
  margin: 12px 0 0;
}

.doc-legal-fineprint.one-point-smaller {
  font-size: 13px;
}

.doc-legal-fineprint.two-points-smaller {
  font-size: 12px;
}

.doc-legal-fineprint.no-top-gap {
  margin-top: 0;
}

.doc-payment-box-wrap + .doc-signatures,
.doc-payment-box-wrap + .doc-sign-stack,
.doc-payment-box-wrap + .doc-ccpa-sign-stack {
  margin-top: 24px;
}

.doc-ccpa-date-center {
  display: flex;
  justify-content: center;
  margin: 18px 0 22px;
}

.intake-section {
  margin-bottom: 14px;
}

.doc-table-lite {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 10px 0 14px;
  font-size: 15px;
}

.doc-table-lite th,
.doc-table-lite td {
  border: 1px solid #000;
  vertical-align: top;
  text-align: left;
  padding: 5px 8px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.doc-table-lite th {
  width: 58%;
  font-weight: 700;
}

.doc-table-lite td {
  width: 42%;
}

.doc-table-lite tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

.doc-upload-grid {
  display: block;
}

.doc-upload-col {
  margin-bottom: 12px;
}

.doc-signatures {
  margin-top: 20px;
}

.doc-ccpa-date-line-only {
  position: relative;
  width: auto;
  min-height: auto;
  border-bottom: 0;
  text-align: center;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0;
}

.doc-ccpa-date-line-only .doc-field-value,
.doc-ccpa-date-line-only .doc-date-text {
  display: inline-block;
  border: 0;
  padding: 0;
}

.doc-ccpa-name-sign-row {
  display: grid;
  grid-template-columns: 54px 220px 70px 220px;
  gap: 10px;
  align-items: end;
  justify-content: center;
  margin-bottom: 14px;
}

.doc-ccpa-name-sign-row .doc-sign-line {
  min-height: 24px;
  border-bottom: 1px solid #000;
}

.doc-page-spacer,
.doc-page-break-marker {
  display: none !important;
}

.doc-hidden {
  display: none !important;
}

.collapsible-wrap {
  margin-bottom: 14px;
}

.collapsible-wrap details {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.collapsible-wrap summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 700;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  user-select: none;
}

.collapsible-wrap .collapsible-body {
  padding: 12px;
}

.panel-shell {
  display: block;
}

.panel-toggle {
  position: absolute;
  top: 12px;
  width: 28px;
  height: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  cursor: pointer;
  z-index: 20;
  line-height: 1;
  font-size: 16px;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel-input,
.panel-output {
  position: relative;
  overflow: hidden;
  min-height: 200px;
}

.panel-input .panel-toggle {
  right: 8px;
}

.panel-output .panel-toggle {
  left: 8px;
}

.panel-title-mini {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  color: #374151;
  margin: 48px auto 0;
  text-align: center;
  display: none;
}

.workspace {
  display: grid !important;
  grid-template-columns: var(--left-panel-width, 340px) minmax(760px, 1fr) var(--right-panel-width, 340px) !important;
  gap: 16px;
  align-items: start;
  transition: grid-template-columns 0.22s ease;
}

.workspace.left-collapsed {
  --left-panel-width: 40px;
}

.workspace.right-collapsed {
  --right-panel-width: 40px;
}

.workspace.left-collapsed .panel-input .panel-shell,
.workspace.right-collapsed .panel-output .panel-shell {
  display: none;
}

.workspace.left-collapsed .panel-input .panel-title-mini,
.workspace.right-collapsed .panel-output .panel-title-mini {
  display: block;
}

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

  .app-toolbar,
  .panel-input,
  .panel-output,
  .panel-toggle,
  .panel-title-mini {
    display: none !important;
  }

  .workspace {
    display: block !important;
    grid-template-columns: 0 1fr 0 !important;
  }

  .panel-preview {
    border: 0;
    padding: 0;
    background: #fff;
    overflow: visible;
  }

  .packet-mount {
    background: #fff;
    padding: 0;
    overflow: visible;
  }

  .packet-root {
    width: var(--page-width);
    max-width: none;
  }

  .doc-page {
    width: var(--page-width);
    min-width: var(--page-width);
    max-width: var(--page-width);
    height: var(--page-height);
    min-height: var(--page-height);
    max-height: var(--page-height);
    box-shadow: none;
    margin: 0;
    overflow: hidden;
    break-after: page;
    page-break-after: always;
  }

  .doc-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .doc-page-header img,
  .doc-page-header img.logo-image {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .collapsible-wrap details {
    border: 0 !important;
  }

  .collapsible-wrap summary {
    display: none !important;
  }

  .collapsible-wrap .collapsible-body {
    padding: 0 !important;
  }
}

.doc-money-emphasis {
  font-weight: 700;
  text-decoration: underline;
}

.doc-initials-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px auto 14px;
  width: 62%;
  page-break-inside: avoid;
  break-inside: avoid;
}

.doc-initials-row .doc-initials-label {
  white-space: nowrap;
  font-size: 16px;
}

.doc-initials-line {
  position: relative;
  flex: 1 1 auto;
  min-width: 150px;
  height: 18px;
  border-bottom: 1px solid #000;
}

.doc-disclaimer-justify {
  text-align: justify;
  font-weight: 700;
  margin: 18px 0 10px;
}

.doc-subtitle-strong.payment-schedule-subtitle {
  margin-top: 0;
  margin-bottom: 16px;
}

.doc-conflict-title {
  text-align: center;
  font-weight: 700;
  margin: 0 0 14px;
}

.doc-letter-list {
  margin: 0 0 12px 40px;
  padding: 0;
}

.doc-letter-list li {
  margin: 0 0 8px;
  text-align: justify;
}

.doc-letter-list li::marker {
  font-weight: 700;
}

.doc-page-body > .doc-page-footer {
  display: none !important;
}


.doc-note-tight {
  width: 100%;
  text-align: center;
  font-style: italic;
  font-weight: 700;
  margin: 14px auto;
}

.doc-info-grid {
  gap: 8px;
  margin: 10px 0 18px;
}

.doc-info-label {
  font-weight: 400;
}

.doc-payment-box-wrap {
  display: flex;
  justify-content: center;
  margin: 18px 0 34px;
}

.doc-payment-row-label {
  white-space: nowrap;
  font-weight: 400;
}

.doc-initials-row {
  margin: 30px auto 18px;
  width: 40%;
}

.doc-initials-line {
  flex: 0 0 72px;
  min-width: 72px;
  max-width: 72px;
  height: 18px;
  border-bottom: 1px solid #000;
}

.doc-section17-email {
  margin-bottom: 18px !important;
}

.doc-conflict-signatures {
  margin-top: 34px;
}

.doc-inline-blank {
  display: inline-block;
  vertical-align: baseline;
  border-bottom: 1px solid #000;
  height: 16px;
}

.doc-ccpa-gap-sm {
  margin-bottom: 16px !important;
}

.doc-ccpa-gap-md {
  margin-bottom: 28px !important;
}

.doc-ccpa-sign-gap {
  height: 28px;
}

.doc-ccpa-name-sign-row {
  margin-bottom: 0;
}

/* Service Level Selection */
.service-level-page {
  --page-pad-top-with-logo: 132px;
}

.service-level-body {
  font-size: 13px;
  line-height: 1.16;
}

.service-level-body .doc-title.main {
  font-size: 20px;
  line-height: 1.08;
  margin-bottom: 8px;
}

.service-meta-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 8px;
}

.service-meta-field {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.service-meta-field span {
  display: inline-block;
  border-bottom: 1px solid #000;
  min-height: 18px;
  padding: 0 8px 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.service-meta-client {
  flex: 1 1 31%;
}

.service-meta-matter {
  flex: 1.35 1 42%;
}

.service-meta-date {
  flex: 0.85 1 27%;
}

.service-meta-client span,
.service-meta-matter span,
.service-meta-date span {
  flex: 1 1 auto;
}

.service-intro {
  margin-bottom: 8px;
}

.service-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0 8px;
}

.service-option-box {
  border: 1.5px solid #000;
  padding: 9px 9px 7px;
  min-height: 292px;
  display: flex;
  flex-direction: column;
}

.service-option-box h2 {
  font-size: 13.5px;
  text-align: center;
  margin: 0 0 7px;
  font-weight: 700;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.12;
}

.service-total-line {
  border: 1px solid #000;
  min-height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 7px;
}

.service-list {
  margin-left: 14px;
  margin-bottom: 6px;
  flex: 1;
}

.service-list li,
.service-ack-list li {
  margin-bottom: 4px;
}

.service-selected-line {
  margin-top: auto;
  font-weight: 700;
  display: flex;
  gap: 6px;
  align-items: center;
}

.service-selected-centered {
  justify-content: center;
  text-align: center;
}

.service-initial-box {
  display: inline-block;
  width: 88px;
  height: 20px;
  border-bottom: 1px solid #000;
  position: relative;
}

.service-initial-box .doc-field-anchor {
  position: absolute;
  left: 8px;
  top: 1px;
  width: 66px;
  height: 16px;
}

.service-ack-title {
  font-size: 14px;
  margin: 8px 0 5px;
  text-align: center;
  text-transform: uppercase;
}

.service-ack-list {
  margin-left: 18px;
  margin-bottom: 6px;
}

.service-signature-section {
  margin-top: 16px;
}

.service-signature-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-top: 12px;
  min-height: 14px;
}

.service-signature-spacer {
  height: 58px;
  display: block;
  flex: 0 0 auto;
}

.service-date-wrap,
.service-sign-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.service-date-wrap {
  flex: 0 0 185px;
}

.service-sign-wrap {
  flex: 1 1 auto;
  position: relative;
}

.service-date-line,
.service-sign-line {
  display: inline-block;
  border-bottom: 1px solid #000;
  height: 24px;
  position: relative;
}

.service-date-line {
  width: 132px;
}

.service-sign-line {
  flex: 1 1 auto;
  min-width: 390px;
}

.service-sign-caption {
  position: absolute;
  left: 72px;
  right: 0;
  top: 27px;
  text-align: center;
  font-size: 12px;
  text-transform: uppercase;
}

.service-signature-section .doc-field-anchor.date {
  left: 0;
  top: 0;
  width: 125px;
  height: 22px;
}

.service-signature-section .doc-field-anchor.signature {
  left: 0;
  top: 0;
  width: 100%;
  height: 22px;
}
