:root {
  --primary: rgb(5, 150, 105);
  --primary-dark: rgb(4, 120, 87);
  --primary-light: rgb(209, 250, 229);
  --primary-bg: rgb(240, 253, 244);
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-color: #d1d5db;
  --white: #ffffff;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background-color: var(--primary-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-main);
}

/* Main container - not full width, centered */
body {
  max-width: 900px;
  margin: 0 auto;
  background-color: var(--white);
  min-height: 100vh;
  padding: 2rem 2rem 120px 2rem; /* Extra bottom padding for sticky buttons */
  box-shadow: var(--shadow-lg);
  position: relative;
}

/* Typography */
h3 {
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid var(--primary-light);
  line-height: 1.3;
}

h4 {
  color: var(--primary-dark);
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

p {
  margin-bottom: 1rem;
  color: var(--text-main);
}

b {
  color: var(--primary-dark);
  font-weight: 600;
}

/* Form Elements */
label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  background-color: transparent;
  border: 1px solid transparent;
}

label:hover {
  background-color: var(--primary-bg);
  border-color: var(--primary-light);
}

input[type="radio"],
input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  padding: 0.875rem;
  border: 2px solid var(--border-color);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s;
  background-color: var(--white);
  color: var(--text-main);
  margin-bottom: 1rem;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5rem 0;
  background-color: var(--white);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--primary-light);
}

th {
  background-color: var(--primary);
  color: var(--white);
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.95rem;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover {
  background-color: var(--primary-bg);
}

/* Table inputs specific styling */
td input[type="text"],
td input[type="number"] {
  margin-bottom: 0;
  width: 100%;
  min-width: 120px;
}

/* Horizontal rule */
hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--primary-light), transparent);
  margin: 2.5rem 0;
}

/* Sticky Bottom Buttons Container */
body::after {
  content: "";
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0.8));
  backdrop-filter: blur(8px);
  border-top: 2px solid var(--primary-light);
  z-index: 40;
  pointer-events: none;
}

/* Button Styling & Positioning */
button {
  position: fixed;
  bottom: 20px;
  z-index: 50;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
}

/* Back Button - Bottom Left */
button[onclick*="history.back()"] {
  left: max(20px, calc((100vw - 900px) / 2 + 20px));
  background-color: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
}

button[onclick*="history.back()"]:hover {
  background-color: var(--primary-bg);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(5, 150, 105, 0.2);
}

/* Save Button - Bottom Right */
button[onclick*="saveAnswers()"] {
  right: max(20px, calc((100vw - 900px) / 2 + 20px));
  background-color: var(--primary);
  color: var(--white);
}

button[onclick*="saveAnswers()"]:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(5, 150, 105, 0.3);
}

button:active {
  transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 940px) {
  body {
    margin: 0 1rem;
    padding: 1.5rem 1.5rem 100px 1.5rem;
  }
  
  button[onclick*="history.back()"] {
    left: 20px;
  }
  
  button[onclick*="saveAnswers()"] {
    right: 20px;
  }
}

@media (max-width: 640px) {
  body {
    padding: 1rem 1rem 100px 1rem;
    margin: 0;
    box-shadow: none;
  }
  
  html {
    background-color: var(--white);
  }
  
  h3 {
    font-size: 1.25rem;
  }
  
  h4 {
    font-size: 1.1rem;
  }
  
  table {
    font-size: 0.875rem;
  }
  
  th, td {
    padding: 0.5rem;
  }
  
  button {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    bottom: 15px;
  }
  
  button[onclick*="history.back()"] {
    left: 10px;
  }
  
  button[onclick*="saveAnswers()"] {
    right: 10px;
  }
  
  /* Stack buttons on very small screens */
  @media (max-width: 480px) {
    button {
      position: fixed;
      width: calc(50% - 15px);
      justify-content: center;
    }
    
    button[onclick*="history.back()"] {
      left: 10px;
    }
    
    button[onclick*="saveAnswers()"] {
      right: 10px;
    }
  }
}

/* Print styles */
@media print {
  button {
    display: none;
  }
  
  body {
    padding-bottom: 2rem;
    box-shadow: none;
  }
  
  body::after {
    display: none;
  }
}