:root {
  --bg: #eef3ee;
  --panel: rgba(249, 248, 243, 0.95);
  --panel-border: rgba(18, 52, 45, 0.12);
  --surface: #ffffff;
  --surface-border: rgba(18, 52, 45, 0.16);
  --ink: #17332c;
  --muted: #5d736c;
  --accent: #0e6b55;
  --accent-soft: #d5efe5;
  --shadow: 0 20px 60px rgba(12, 38, 31, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(85, 173, 144, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(209, 231, 214, 0.85), transparent 26%),
    linear-gradient(160deg, #f7faf7 0%, #ebf1ec 42%, #e4ede7 100%);
}

button,
input,
textarea {
  font: inherit;
}

textarea {
  resize: vertical;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 28px;
  padding: 24px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.intro-card,
.form-section,
.sheet-card,
.preview-header {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.intro-card {
  padding: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.06;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.65rem);
}

h2 {
  font-size: 1.35rem;
}

.intro-copy,
.print-hint,
.section-heading p,
.status-message {
  margin: 0;
  line-height: 1.6;
  color: var(--muted);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 22px 0 14px;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #fefefe;
  background: linear-gradient(135deg, #0f7c61, #165e50);
  box-shadow: 0 14px 28px rgba(15, 108, 85, 0.2);
}

.button-secondary {
  background: var(--accent-soft);
  color: var(--ink);
}

.document-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-section {
  padding: 20px;
}

.section-heading {
  margin-bottom: 16px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.field span {
  font-size: 0.92rem;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(24, 69, 60, 0.16);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(15, 108, 85, 0.5);
  box-shadow: 0 0 0 4px rgba(15, 108, 85, 0.12);
  background: #ffffff;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  padding: 12px 14px;
  min-height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(24, 69, 60, 0.16);
  background: rgba(255, 255, 255, 0.86);
}

.choice-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.preview-stage {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.preview-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
}

.sheet-card {
  padding: 18px;
  overflow: auto;
}

#documentCanvas {
  display: block;
  width: min(100%, 920px);
  height: auto;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 18px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-header {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
    gap: 16px;
  }

  .intro-card,
  .form-section,
  .preview-header,
  .sheet-card {
    border-radius: 20px;
  }

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

@page {
  size: A4 portrait;
  margin: 0;
}

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

  .app-shell {
    display: block;
    padding: 0;
  }

  .control-panel,
  .preview-header {
    display: none !important;
  }

  .sheet-card {
    padding: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  #documentCanvas {
    width: 210mm;
    max-width: none;
    margin: 0 auto;
    background: transparent;
    border-radius: 0;
  }
}
