:root {
  --page-bg: linear-gradient(180deg, #dff3ff 0%, #b5daf6 100%);
  --card-bg: #ffffff;
  --text-main: #111111;
  --text-muted: #5d6773;
  --border: #cfe2f0;
  --border-strong: #89b5d6;
  --accent: #0e79c8;
  --accent-dark: #085f9e;
  --danger: #c43333;
  --success-bg: #eaf8ef;
  --success-text: #1f6d42;
  --error-bg: #fdecec;
  --error-text: #a12626;
  --surface: #f7fbfe;
  --shadow: 0 24px 60px rgba(20, 62, 105, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-main);
  background: var(--page-bg);
}

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

.hidden {
  display: none !important;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 14px 40px;
}

.form-card {
  width: min(100%, 760px);
  background: var(--card-bg);
  border-radius: 24px;
  padding: 22px 18px 28px;
  box-shadow: var(--shadow);
}

.brand-block {
  text-align: center;
  margin-bottom: 22px;
}

.brand-logo {
  width: 112px;
  max-width: 40%;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.7rem;
  margin-bottom: 8px;
}

.intro-text,
.section-heading p,
.helper-text,
.upload-hint,
.existing-file {
  color: var(--text-muted);
}

.field-group,
.field-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.search-select {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-weight: 600;
}

.required-mark {
  color: var(--danger);
}

input[type="text"],
input[type="date"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#interventionSelect {
  min-height: 240px;
}

input[type="text"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(14, 121, 200, 0.12);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.feedback {
  padding: 14px 16px;
  border-radius: 14px;
  margin: 18px 0;
}

.feedback.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.feedback.error {
  background: var(--error-bg);
  color: var(--error-text);
}

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

.dynamic-fields {
  display: grid;
  gap: 4px;
}

.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 128px;
  padding: 18px;
  border: 2px dashed var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

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

.signature-canvas {
  width: 100%;
  height: 220px;
  display: block;
  border: 2px dashed var(--border-strong);
  border-radius: 18px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.signature-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #edf7ff;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.existing-files {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.existing-file {
  word-break: break-word;
}

a.existing-file {
  color: var(--accent-dark);
}

input[readonly],
select:disabled,
textarea[readonly] {
  background: #f4f7fa;
  color: var(--text-muted);
}

.secondary-button,
.primary-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover,
.primary-button:focus {
  background: var(--accent-dark);
}

.secondary-button {
  background: #dceffc;
  color: var(--accent-dark);
  font-weight: 600;
}

.secondary-button:hover,
.secondary-button:focus {
  background: #c8e5fb;
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.error-text {
  color: var(--danger);
  font-size: 0.92rem;
}

.field-wrapper.has-error input,
.field-wrapper.has-error textarea,
.field-wrapper.has-error select,
.field-wrapper.has-error .dropzone {
  border-color: var(--danger);
}

.actions {
  margin-top: 24px;
}

.toast-container {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(calc(100% - 24px), 520px);
  z-index: 1000;
  pointer-events: none;
}

.toast {
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 18px 40px rgba(20, 62, 105, 0.18);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-error {
  background: #a12626;
  color: #fff;
}

.toast-success {
  background: #1f6d42;
  color: #fff;
}

@media (min-width: 768px) {
  .page-shell {
    padding: 36px 20px 50px;
  }

  .form-card {
    padding: 36px 34px 40px;
  }

  h1 {
    font-size: 2.1rem;
  }

  .primary-button {
    width: auto;
    min-width: 180px;
  }
}
