/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-dark: #2d5016;
  --green-mid: #4a7c2e;
  --green-light: #6fa34a;
  --green-pale: #e8f5e1;
  --earth-dark: #5c4033;
  --earth-mid: #8b6f47;
  --earth-light: #c9a96e;
  --earth-pale: #faf3e8;
  --bg: #f7f9f4;
  --card-bg: #ffffff;
  --text: #1a2e0a;
  --text-muted: #5a6b4a;
  --border: #d4dcc8;
  --accent: #d4870e;
  --red: #c0392b;
  --blue: #2980b9;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* === Header === */
.header {
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  color: white;
  padding: 1.5rem 2rem;
  text-align: center;
  position: relative;
}
.header h1 { font-size: 1.6rem; font-weight: 700; }
.header .subtitle { font-size: 0.9rem; opacity: 0.9; margin-top: 0.3rem; }

/* === Language Toggle === */
.btn-lang {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.3rem 0.8rem;
  border: 1.5px solid white;
  border-radius: 20px;
  background: transparent;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}
.btn-lang:hover {
  background: rgba(255,255,255,0.15);
}

/* === Tabs === */
.tabs {
  display: flex;
  background: var(--card-bg);
  border-bottom: 2px solid var(--border);
  padding: 0 1rem;
  overflow-x: auto;
}
.tab {
  padding: 0.8rem 1.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab:hover { color: var(--green-mid); }
.tab.active {
  color: var(--green-dark);
  border-bottom-color: var(--green-mid);
  font-weight: 600;
}

/* === Content === */
.content { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* === Cards === */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}
.card-header {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.card-green { border-left: 4px solid var(--green-mid); }
.card-earth { border-left: 4px solid var(--earth-mid); }
.card-accent { border-left: 4px solid var(--accent); }

/* === Forms === */
.form-group {
  margin-bottom: 1.2rem;
}
.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: var(--text);
}
.form-group .hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
input[type="number"], input[type="text"], select {
  width: 100%;
  max-width: 300px;
  padding: 0.5rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--card-bg);
  transition: border-color 0.2s;
}
input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(106,163,74,0.15);
}
.input-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.input-inline .unit {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* === Toggle === */
.toggle-group {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 200px;
}
.toggle-btn {
  flex: 1;
  padding: 0.4rem 1rem;
  border: none;
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.toggle-btn.active {
  background: var(--green-mid);
  color: white;
  font-weight: 600;
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  padding: 0.5rem 0.7rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--green-pale);
  color: var(--green-dark);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
td:first-child, th:first-child { text-align: left; }
tr:hover td { background: var(--earth-pale); }
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* === Grid Layouts === */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}
.grid-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 1rem;
}

/* === Stat Cards === */
.stat {
  text-align: center;
  padding: 1rem;
}
.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green-dark);
}
.stat-value.positive { color: var(--green-mid); }
.stat-value.negative { color: var(--red); }
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--green-mid);
  color: white;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary {
  background: var(--earth-pale);
  color: var(--earth-dark);
  border: 1px solid var(--earth-mid);
}
.btn-secondary:hover { background: var(--earth-light); color: white; }

/* === Range Slider === */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--green-mid);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* === Radio Group === */
.radio-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.radio-group label:has(input:checked) {
  border-color: var(--green-mid);
  background: var(--green-pale);
  color: var(--green-dark);
  font-weight: 600;
}
.radio-group input[type="radio"] {
  accent-color: var(--green-mid);
}

/* === Section Headers === */
.section-header {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green-dark);
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--green-pale);
}
.section-header:first-child { margin-top: 0; }

/* === Comparison Table === */
.comparison-table th { text-align: center; }
.comparison-table td { text-align: center; }
.comparison-table td:first-child { text-align: left; font-weight: 500; }
.change-positive { color: var(--green-mid); font-weight: 600; }
.change-negative { color: var(--red); font-weight: 600; }

/* === Charts === */
.chart-container {
  position: relative;
  height: 350px;
  margin: 1rem 0;
}

/* === Computed Value Display === */
.computed-value {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  background: var(--green-pale);
  border-radius: var(--radius);
  font-weight: 600;
  color: var(--green-dark);
  font-size: 0.95rem;
}

/* === Question Numbers === */
.q-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--green-mid);
  color: white;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  margin-right: 0.5rem;
}

/* === Herd Breakdown Table === */
.breakdown-table {
  max-width: 500px;
}
.breakdown-table input {
  max-width: 120px;
  text-align: right;
}
.breakdown-table td { padding: 0.4rem 0.5rem; }
.breakdown-table .total-row {
  font-weight: 700;
  border-top: 2px solid var(--green-mid);
}

/* === Info text === */
.info-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  background: var(--earth-pale);
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  line-height: 1.6;
}

/* === Custom inputs group === */
.custom-inputs {
  display: none;
  margin-top: 0.8rem;
  padding: 1rem;
  background: var(--earth-pale);
  border-radius: var(--radius);
}
.custom-inputs.visible { display: block; }
.custom-inputs .form-group { margin-bottom: 0.8rem; }

/* === Responsive === */
@media (max-width: 768px) {
  .header { padding: 1rem; }
  .header h1 { font-size: 1.3rem; }
  .content { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .tab { padding: 0.6rem 0.8rem; font-size: 0.85rem; }
  .stat-value { font-size: 1.1rem; }
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* === Slider with value display === */
.slider-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.slider-value {
  font-weight: 700;
  color: var(--green-dark);
  min-width: 50px;
  font-size: 1.1rem;
}

/* === Price calculator helper === */
.price-calc {
  background: var(--earth-pale);
  padding: 1rem;
  border-radius: var(--radius);
  margin-top: 0.5rem;
}
.price-calc h4 {
  font-size: 0.9rem;
  color: var(--earth-dark);
  margin-bottom: 0.5rem;
}
.price-calc .calc-row {
  display: flex;
  gap: 1rem;
  align-items: end;
}
.price-calc .form-group { margin-bottom: 0.5rem; }

/* === View toggle for detailed results === */
.view-toggle {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
  width: fit-content;
}
.view-toggle button {
  padding: 0.4rem 1rem;
  border: none;
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.view-toggle button.active {
  background: var(--green-mid);
  color: white;
  font-weight: 600;
}

/* === Highlight row === */
.highlight-row td {
  background: var(--green-pale) !important;
  font-weight: 600;
}
