:root {
  color-scheme: light dark;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f3f6fc;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-muted: rgba(255, 255, 255, 0.6);
  --accent: #2a7de1;
  --accent-dark: #205da8;
  --accent-soft: rgba(42, 125, 225, 0.12);
  --border: #d7dce5;
  --text: #1f2933;
  --muted: #61748f;
  --shadow: 0 20px 48px rgba(15, 23, 42, 0.08);
  --warning-bg: #fff3cd;
  --warning-text: #8a6d3b;
  --success-bg: #d4edda;
  --success-text: #155724;
  --error-bg: #f8d7da;
  --error-text: #721c24;
  /* Mobile-specific variables */
  --touch-target: 44px;
  --mobile-spacing: 1rem;
  --desktop-spacing: 1.5rem;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f5f7fc 0%, #e6edf9 100%);
  color: var(--text);
  line-height: 1.6;
  /* Improve text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(var(--mobile-spacing), 4vw, var(--desktop-spacing));
  display: grid;
  gap: var(--desktop-spacing);
}

/* Enhanced intro/hero section */
.intro {
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.intro h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  /* Better text wrapping */
  word-wrap: break-word;
  hyphens: auto;
}

.hero-description {
  margin: 0 0 1.5rem;
  color: var(--muted);
  max-width: 65ch;
  line-height: 1.6;
  font-size: clamp(1rem, 2.5vw, 1.125rem);
  margin-left: auto;
  margin-right: auto;
}

.intro p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
  line-height: 1.5;
}

.form-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: clamp(var(--mobile-spacing), 4vw, 2.25rem);
  display: grid;
  gap: var(--desktop-spacing);
  backdrop-filter: blur(8px);
  /* Performance optimization */
  will-change: transform;
  /* Better mobile interaction */
  position: relative;
}

@media (max-width: 768px) {
  .form-card {
    border-radius: 16px;
    gap: var(--mobile-spacing);
  }
}

.group {
  border: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
}

.group legend {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.group.optional legend {
  color: var(--muted);
}

.field-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Better mobile grid layout */
@media (max-width: 768px) {
  .field-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

@media (max-width: 480px) {
  .field-grid {
    gap: 1rem;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
}

.field span {
  color: var(--text);
}

/* Field help text styles */
.field-help {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.4;
  margin-top: 0.25rem;
}

.field input,
.field select,
.field textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  background: #fff;
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease;
  /* Better mobile interaction */
  min-height: var(--touch-target);
  font-size: 16px; /* Prevents zoom on iOS */
}

/* Mobile-specific input improvements */
@media (max-width: 768px) {
  .field input,
  .field select,
  .field textarea {
    font-size: 16px; /* Prevent zoom on focus */
    padding: 0.875rem;
    border-radius: 8px;
  }
  
  .field input[type="number"] {
    -webkit-appearance: none;
    appearance: none;
  }
  
  /* Better mobile textarea */
  .field textarea {
    min-height: 120px;
    resize: vertical;
  }
  
  /* Mobile-friendly select styling */
  .field select {
    background-image: url("data:image/svg+xml;charset=US-ASCII,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%23666' d='M8 12L3 7h10z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem;
  }
}

/* Loading and disabled states for better UX */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.field input,
.field select,
.field textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.field select option {
  color: var(--text);
}

.field textarea {
  resize: vertical;
  min-height: 110px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* Required field indicator */
.field span:has(+ [required])::after,
.field span:contains("*")::after {
  content: " *";
  color: #d32f2f;
  font-weight: bold;
}

/* Alternative for browsers that don't support :has() */
.field:has([required]) span::after {
  content: " *";
  color: #d32f2f;
  font-weight: bold;
}

.checkbox-field {
  gap: 0.6rem;
}

.checkbox-group {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem;
  display: grid;
  gap: 0.35rem;
  background: var(--surface-muted);
}

.checkbox-group label {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-group input {
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 0.875rem 1.5rem;
  font-weight: 600;
  font-size: 1rem;
  min-height: var(--touch-target);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  /* Better touch interaction */
  touch-action: manipulation;
  user-select: none;
}

/* Mobile button improvements */
@media (max-width: 768px) {
  button {
    padding: 1rem 1.5rem;
    font-size: 1.05rem;
    border-radius: 8px;
    min-height: 48px;
  }
}

button.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(42, 125, 225, 0.25);
}

button.primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button.secondary {
  background: rgba(97, 116, 143, 0.14);
  color: var(--text);
}

button.secondary:hover {
  background: rgba(97, 116, 143, 0.22);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.feedback {
  border-radius: 12px;
  padding: 0.75rem 1rem;
  background: rgba(42, 125, 225, 0.12);
  color: var(--accent-dark);
  font-weight: 500;
}

.feedback.error {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

.followups {
  border: 1px dashed var(--border);
}

.followup-info {
  margin: 0;
  color: var(--muted);
}

.steps {
  display: grid;
  gap: 1rem;
}

.question-step {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  background: #fff;
  display: grid;
  gap: 0.75rem;
  position: relative;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.question-step.active {
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(42, 125, 225, 0.15);
}

.question-step.answered {
  background: var(--surface-muted);
}

.step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.step-header strong {
  color: var(--text);
  font-size: 1rem;
}

.step-question {
  margin: 0;
  font-weight: 600;
  line-height: 1.45;
}

.step-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.step-input input {
  width: 100%;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}

.step-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.step-actions {
  display: flex;
  justify-content: flex-end;
}

.step-error {
  color: #b91c1c;
  font-size: 0.9rem;
}

.answer-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(42, 125, 225, 0.1);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-dark);
  width: fit-content;
}

.form-card.locked [data-lockable],
.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: rgba(248, 250, 253, 0.9);
  color: var(--text);
  opacity: 1;
}

.result .range {
  font-size: 1.45rem;
  font-weight: 700;
}

.breakdown {
  display: grid;
  gap: 0.75rem;
}

.breakdown-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  background: #fff;
  display: grid;
  gap: 0.35rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.breakdown-item h3 {
  margin: 0;
  font-size: 1.05rem;
}

.breakdown-item strong {
  font-size: 1rem;
}

.breakdown-item p {
  margin: 0;
  color: var(--muted);
}

.warnings {
  display: grid;
  gap: 0.5rem;
}

.warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(250, 176, 5, 0.35);
  font-size: 0.95rem;
}

.disclaimer {
  font-size: 0.9rem;
  color: var(--muted);
  border-left: 4px solid var(--accent);
  padding-left: 0.75rem;
  margin: 0;
}

@media (max-width: 640px) {
  .form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  button {
    width: 100%;
  }
  
  .page {
    padding: var(--mobile-spacing);
    gap: var(--mobile-spacing);
  }
  
  .form-card {
    padding: var(--mobile-spacing);
  }
  
  .intro h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }
}

/* RGPD Banner */
.gdpr-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(31, 41, 51, 0.98);
  color: white;
  padding: 1.5rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  backdrop-filter: blur(10px);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

.gdpr-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gdpr-content p {
  margin: 0;
  line-height: 1.6;
  font-size: 0.95rem;
}

.gdpr-content a {
  color: #6db3f2;
  text-decoration: underline;
}

.gdpr-content a:hover {
  color: #8fc8ff;
}

.gdpr-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.gdpr-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.gdpr-btn.primary {
  background: #2a7de1;
  color: white;
}

.gdpr-btn.primary:hover {
  background: #205da8;
  transform: translateY(-1px);
}

.gdpr-btn.secondary {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.gdpr-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Legal Notice */
.legal-notice {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--warning-bg);
  border-left: 4px solid #f0ad4e;
  border-radius: 8px;
}

.legal-notice p {
  margin: 0;
  color: var(--warning-text);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Footer */
.legal-footer {
  background: rgba(31, 41, 51, 0.95);
  color: rgba(255, 255, 255, 0.8);
  padding: 2rem 1.5rem;
  margin-top: 3rem;
}

.footer-content {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  align-items: center;
}

.footer-links a,
.footer-links .link-button {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.footer-links .link-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.footer-links a:hover,
.footer-links .link-button:hover {
  color: #6db3f2;
  text-decoration: underline;
}

.footer-disclaimer {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.5;
  max-width: 600px;
}

@media (max-width: 640px) {
  .gdpr-actions {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .gdpr-btn {
    width: 100%;
    min-height: var(--touch-target);
  }
  
  .footer-links {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .gdpr-banner {
    padding: 1rem;
  }
  
  .gdpr-content p {
    font-size: 0.9rem;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus improvements for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000;
    --text: #000;
    --muted: #333;
  }
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--accent);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
}

.skip-link:focus {
  top: 6px;
}

/* Improved form validation styles */
.field input:invalid,
.field select:invalid,
.field textarea:invalid {
  border-color: #dc3545;
}

.field input:valid,
.field select:valid,
.field textarea:valid {
  border-color: #28a745;
}

/* Error message styling */
.field-error {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: block;
}

/* Button help text */
.button-help {
  margin-top: 0.5rem;
  text-align: center;
}

.button-help small {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0.25rem 0;
}

/* Improved button content layout */
button span {
  display: block;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

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

.modal-header {
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0.5rem;
  border-radius: 50%;
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-content {
  padding: 1.5rem 2rem 2rem;
}

.modal-result {
  margin-bottom: 2rem;
}

.modal-compensation {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--accent);
  margin: 1rem 0;
  text-align: center;
}

.modal-summary {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.modal-cta {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.modal-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(42, 125, 225, 0.3);
}

.contact-form {
  display: none;
  margin-top: 1.5rem;
}

.contact-form.show {
  display: block;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.btn-submit {
  flex: 1;
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.btn-submit:hover {
  background: var(--accent-dark);
}

.btn-submit:disabled {
  background: var(--muted);
  cursor: not-allowed;
}

.btn-cancel {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.btn-cancel:hover {
  background: var(--border);
}

.success-message,
.error-message {
  padding: 1rem;
  border-radius: 6px;
  margin-top: 1rem;
}

.success-message {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid #c3e6cb;
}

.error-message {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid #f5c6cb;
}

@media (max-width: 768px) {
  .modal {
    width: 95%;
    margin: 1rem;
    max-height: 95vh;
  }
  
  .modal-header,
  .modal-content {
    padding: 1.25rem;
  }
  
  .modal-title {
    font-size: 1.25rem;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  /* Improve mobile scroll behavior */
  .modal {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Better touch targets for mobile */
  .modal-close {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.25rem;
  }
}

/* Additional mobile improvements */
@media (max-width: 480px) {
  .modal {
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-height: 100vh;
  }
  
  .modal-header,
  .modal-content {
    padding: 1rem;
  }
}
