* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8f9fa;
  color: #1a1a1a;
  line-height: 1.6;
}

/* ─── Шапка компании ─── */
.company-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: #1a1a1a;
  color: #fff;
}

.company-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.company-name {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}

.company-email {
  font-size: 0.85rem;
  color: #e53935;
  text-decoration: none;
}

.company-email:hover {
  text-decoration: underline;
}

/* ─── Тулбар ─── */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.toolbar-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-status {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
}

.toolbar-right {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.toolbar-btn {
  padding: 7px 14px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.toolbar-btn:hover {
  background: #f0f0f0;
  border-color: #bbb;
}

.toolbar-btn.primary {
  background: #2d6a4f;
  color: #fff;
  border-color: #2d6a4f;
}

.toolbar-btn.primary:hover {
  background: #1b4332;
  border-color: #1b4332;
}

/* ─── Flash ─── */
.flash {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #1a1a1a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  white-space: nowrap;
}

.flash.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Макет ─── */
.app-layout {
  display: flex;
  gap: 24px;
  max-width: 1300px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  align-items: flex-start;
}

.form-column {
  flex: 1;
  min-width: 0;
  max-width: 720px;
}

.preview-column {
  width: 360px;
  flex-shrink: 0;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

/* ─── Прогресс ─── */
header {
  margin-bottom: 24px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: #2d6a4f;
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 0.82rem;
  color: #888;
  text-align: right;
}

/* ─── Секции ─── */
.section {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px 20px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.section-header {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e8f5e9;
}

.section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2d6a4f;
}

.question {
  margin-bottom: 24px;
}

.question:last-of-type {
  margin-bottom: 8px;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

textarea, input[type="text"], input[type="email"], input[type="tel"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  color: #1a1a1a;
  background: #fafafa;
  transition: border-color 0.2s;
  resize: vertical;
}

textarea {
  min-height: 72px;
}

textarea:focus, input:focus {
  outline: none;
  border-color: #2d6a4f;
  background: #fff;
}

textarea.comment {
  min-height: 44px;
  margin-top: 6px;
  font-size: 0.85rem;
  color: #555;
  background: #f5f5f5;
}

textarea.comment::placeholder {
  color: #aaa;
  font-style: italic;
}

/* ─── Кнопки добавления ─── */
.add-field-btn {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 12px;
  background: none;
  border: 1.5px dashed #c8e6c9;
  border-radius: 8px;
  color: #2d6a4f;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.add-field-btn:hover {
  background: #f0faf4;
  border-color: #2d6a4f;
}

.add-section-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  background: none;
  border: 1.5px dashed #ddd;
  border-radius: 10px;
  color: #888;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.add-section-btn:hover {
  background: #f8f8f8;
  border-color: #aaa;
  color: #444;
}

/* Динамические поля */
.dynamic-question {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.dynamic-question-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.dynamic-question input.field-title {
  flex: 1;
  font-weight: 500;
  font-size: 0.92rem;
  border: none;
  border-bottom: 1.5px solid #ddd;
  border-radius: 0;
  background: transparent;
  padding: 4px 0;
}

.dynamic-question input.field-title:focus {
  border-bottom-color: #2d6a4f;
  background: transparent;
}

.remove-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}

.remove-btn:hover {
  color: #e53935;
  background: #fff0f0;
}

/* Динамические секции */
.dynamic-section .section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dynamic-section h2[contenteditable="true"] {
  flex: 1;
  outline: none;
  border-bottom: 2px solid #2d6a4f;
  padding-bottom: 4px;
}

/* ─── Submit ─── */
button[type="submit"] {
  display: block;
  width: 100%;
  padding: 15px;
  background: #2d6a4f;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, transform 0.1s;
  margin-top: 24px;
}

button[type="submit"]:hover { background: #1b4332; }
button[type="submit"]:active { transform: scale(0.99); }
button[type="submit"]:disabled { background: #aaa; cursor: not-allowed; }

.submit-note {
  text-align: center;
  color: #888;
  font-size: 0.82rem;
  margin-top: 10px;
}

/* ─── Превью панель ─── */
.preview-panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  overflow: hidden;
}

.preview-header {
  padding: 12px 20px;
  background: #f0faf4;
  border-bottom: 1px solid #e8f5e9;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2d6a4f;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-a4 {
  padding: 24px 20px;
  min-height: 400px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.preview-empty {
  color: #bbb;
  font-style: italic;
  text-align: center;
  padding: 40px 0;
}

.preview-section {
  margin-bottom: 20px;
}

.preview-section-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #2d6a4f;
  border-bottom: 1.5px solid #e8f5e9;
  padding-bottom: 4px;
  margin-bottom: 10px;
}

.preview-item {
  margin-bottom: 10px;
}

.preview-item-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: #555;
  margin-bottom: 2px;
}

.preview-item-value {
  color: #1a1a1a;
  white-space: pre-wrap;
}

.preview-item-comment {
  font-size: 0.8rem;
  color: #888;
  font-style: italic;
  margin-top: 2px;
}

/* ─── Кнопка внизу ─── */
.bottom-contact {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

.bottom-contact-btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.bottom-contact-btn:hover {
  background: #e53935;
}

/* ─── Модальное окно ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
}

.modal-close:hover {
  color: #333;
  background: #f0f0f0;
}

.modal-body {
  padding: 20px 24px 24px;
}

.modal-subtitle {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.modal-field {
  margin-bottom: 16px;
}

.modal-field label {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 6px;
  display: block;
}

.modal-field textarea {
  min-height: 100px;
}

.required {
  color: #e53935;
}

.optional {
  color: #aaa;
  font-weight: 400;
  font-size: 0.82rem;
}

.modal-submit {
  display: block;
  width: 100%;
  padding: 14px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.2s;
}

.modal-submit:hover {
  background: #e53935;
}

.modal-submit:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.modal-note {
  font-size: 0.75rem;
  color: #bbb;
  text-align: center;
  margin-top: 10px;
}

.modal-success {
  text-align: center;
  padding: 20px 0;
}

.modal-success-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.modal-success h4 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.modal-success p {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ─── Планшет ─── */
@media (max-width: 1024px) {
  .app-layout {
    flex-direction: column;
  }

  .form-column {
    max-width: 100%;
  }

  .preview-column {
    width: 100%;
    position: static;
    max-height: none;
  }
}

/* ─── Телефон ─── */
@media (max-width: 600px) {
  .toolbar {
    padding: 8px 12px;
    gap: 8px;
  }

  .toolbar-title {
    display: none;
  }

  .save-status {
    font-size: 0.72rem;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .toolbar-right {
    gap: 6px;
    margin-left: auto;
  }

  .toolbar-btn {
    padding: 7px 10px;
    font-size: 0.9rem;
  }

  .btn-text {
    display: none;
  }

  .app-layout {
    padding: 16px 12px 80px;
    gap: 16px;
  }

  .section {
    padding: 20px 14px 14px;
  }

  .bottom-contact {
    padding: 0 12px 40px;
  }
}
