:root {
  --bg-canvas: #F4F6F9; --bg-surface: #FFFFFF; --bg-subtle: #F8FAFC;
  --border-hairline: #D8DEE6; --ink-primary: #0F172A; --ink-secondary: #334155; --ink-muted: #526074;
  --accent-navy: #1B3B6F; --accent-navy-hover: #142D55;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: 'Newsreader', Georgia, serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg-canvas); color: var(--ink-primary); font-family: var(--font-sans); font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

.topbar { background: var(--bg-surface); border-bottom: 1px solid var(--border-hairline); padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; position: sticky; top: 0; z-index: 20; }
.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; border-radius: 4px; background: var(--accent-navy); color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.brand-name { font-weight: 700; font-size: 15px; display: block; line-height: 1.2; }
.brand-tier { font-weight: 500; color: var(--accent-navy); font-size: 12px; }
.brand-note { font-size: 11.5px; color: var(--ink-muted); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 7px 13px; border-radius: 4px; border: 1px solid transparent; font-weight: 500; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--accent-navy); color: #FFFFFF; }
.btn-primary:hover { background: var(--accent-navy-hover); }
.btn-secondary { background: var(--bg-surface); color: var(--ink-primary); border-color: var(--border-hairline); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }

.split-workspace { display: grid; grid-template-columns: 470px 1fr; min-height: calc(100vh - 53px); max-width: 100vw; overflow-x: hidden; }
.editor-column { min-width: 0; padding: 16px 18px 36px; border-right: 1px solid var(--border-hairline); overflow-y: auto; max-height: calc(100vh - 53px); }
.form-card { background: var(--bg-surface); border: 1px solid var(--border-hairline); border-radius: 4px; padding: 14px 15px; margin-bottom: 14px; }
.form-card h2 { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-header-row h2 { margin: 0; }
.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-secondary); margin-bottom: 4px; }
.input { width: 100%; padding: 7px 10px; border: 1px solid var(--border-hairline); border-radius: 4px; background: var(--bg-surface); color: var(--ink-primary); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sig-canvas { width: 100%; height: 110px; background: #FFFFFF; border: 1px dashed #94A3B8; border-radius: 3px; cursor: crosshair; touch-action: none; display: block; }

.pro-callout { background: var(--bg-surface); border: 1px solid var(--border-hairline); border-left: 3px solid var(--accent-navy); border-radius: 4px; padding: 14px 15px; }
.pro-callout-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 13.5px; }
.price-tag { font-family: var(--font-mono); font-size: 12px; font-weight: 600; background: #ECFEF9; color: #0F766E; padding: 2px 7px; border-radius: 3px; }
.pro-callout p { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-muted); }

.preview-column { min-width: 0; background: #E9EEF5; display: flex; flex-direction: column; max-height: calc(100vh - 53px); overflow: hidden; }
.preview-bar { background: var(--bg-surface); border-bottom: 1px solid var(--border-hairline); padding: 9px 18px; display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.save-status { font-size: 12px; color: #0F766E; background: #ECFEF9; border: 1px solid #B2F5EA; padding: 2px 8px; border-radius: 3px; }
.paper-stage { flex: 1; overflow: auto; padding: 24px; display: flex; justify-content: center; align-items: flex-start; }

.document-sheet { width: 210mm; min-height: 297mm; background: #FFFFFF; color: #0F172A; box-shadow: 0 8px 28px rgba(15,23,42,0.11); border: 1px solid #DCE2EA; padding: 16mm 18mm; display: flex; flex-direction: column; justify-content: space-between; flex-shrink: 0; }
.sheet-top-rule { height: 4px; background: var(--accent-navy); margin: -16mm -18mm 14mm; }
.sheet-header { display: flex; justify-content: space-between; padding-bottom: 14px; border-bottom: 1.5px solid #0F172A; }
.sheet-title { font-size: 21px; font-weight: 700; color: var(--accent-navy); }
.sheet-sub { font-size: 12.5px; color: #475569; margin-top: 3px; }
.sheet-ref { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.sheet-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 14px 0; border-bottom: 1px solid #E2E8F0; font-size: 12px; }
.sheet-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #64748B; margin-bottom: 4px; }
.sheet-clause { margin-top: 14px; }
.sheet-clause h3 { margin: 0 0 4px; font-size: 13px; }
.sheet-clause p { margin: 0; font-size: 12px; color: #334155; line-height: 1.55; white-space: pre-line; }
.sheet-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 24px; padding-top: 14px; border-top: 1px solid #CBD5E1; }
.sig-box-img { height: 54px; display: flex; align-items: flex-end; border-bottom: 1px solid #0F172A; padding-bottom: 4px; margin-bottom: 5px; }
.sig-box-img img { max-height: 50px; }
.sig-typed { font-family: var(--font-serif); font-style: italic; font-size: 22px; line-height: 1; }
.sig-meta { font-size: 11px; color: #475569; }
.sheet-footer { margin-top: 20px; padding-top: 10px; border-top: 1px solid #E2E8F0; display: flex; justify-content: space-between; font-size: 10.5px; color: #64748B; }

@media (max-width: 1120px) { .split-workspace { grid-template-columns: 1fr; } .editor-column, .preview-column { max-height: none; } }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } .paper-stage { padding: 12px; } }
@page { size: A4; margin: 0; }
@media print {
  html, body { background: #FFFFFF !important; margin: 0 !important; padding: 0 !important; }
  .no-print { display: none !important; }
  .split-workspace, .preview-column, .paper-stage { display: block !important; margin: 0 !important; padding: 0 !important; max-height: none !important; overflow: visible !important; }
  .document-sheet { width: 210mm !important; min-height: 297mm !important; margin: 0 !important; border: none !important; box-shadow: none !important; transform: none !important; print-color-adjust: exact !important; }
}
