:root {
  --bg: #f5f5f1;
  --panel-bg: #ffffff;
  --accent: #0b735b;
  --accent-soft: #e0f0eb;
  --accent-dark: #055141;
  --border: #ddddcf;
  --text-main: #222018;
  --text-muted: #6b6757;
  --danger: #b3261e;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.08);
  --transition-fast: 150ms ease-out;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, 
*::before, 
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-main);
}

.app {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  height: 100vh;
  max-height: 100vh;
}

/* Panels */

.panel {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 12px;
  min-height: 0;
}

.panel--inputs {
  flex: 0 0 auto;
}

.panel--results {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

/* Form */

.form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

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

.field input,
.field select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 8px 9px;
  font-size: 14px;
  outline: none;
  background: #fdfdfb;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
  background: #ffffff;
}

.field--inline {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 6px 8px 6px;
}

.field--inline legend {
  padding: 0 4px;
  font-size: 11px;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 10px;
  font-size: 12px;
}

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

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Buttons */

.btn {
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid transparent;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform 80ms ease-out;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent-dark);
}

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

.btn--ghost {
  background: transparent;
  color: var(--accent-dark);
  border-color: rgba(11, 115, 91, 0.16);
}

.btn--ghost:hover {
  background: var(--accent-soft);
}

/* Error */

.error {
  min-height: 16px;
  font-size: 12px;
  color: var(--danger);
}

/* Results */

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.result-card {
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.result-label {
  font-size: 11px;
  color: var(--accent-dark);
}

.result-value {
  font-size: 24px;
  font-weight: 700;
}

.result-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Chart + data layout */

.chart-layout {
  display: flex;
  flex-direction: row;
  gap: 10px;
}

.chart-layout__data {
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-layout__graph {
  flex: 1 1 auto;
  min-width: 0;
}

/* On very small screens, keep a single column but data above the chart */
@media (max-width: 480px) {
  .chart-layout {
    flex-direction: row;
  }

  .chart-layout__data {
    flex: 0 0 45%;
  }

  .result-value {
    font-size: 16px;
  }
}

/* Tabs */

.tabs {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.tabs-nav {
  display: inline-flex;
  align-self: flex-start;
  padding: 2px;
  border-radius: 999px;
  background: #f3f0e5;
  margin-bottom: 6px;
}

.tabs-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.tabs-btn--active {
  background: #ffffff;
  color: var(--accent-dark);
}

.tabs-content {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.tab-panel {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.tab-panel--active {
  opacity: 1;
  pointer-events: auto;
}

/* Chart */

#growth-chart {
  width: 100%;
  height: 100%;
}

/* Table */

.table-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fdfdf9;
}

.results-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.results-table thead {
  position: sticky;
  top: 0;
  background: #f6f3e5;
  z-index: 1;
}

.results-table th,
.results-table td {
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid #e7e1cf;
}

.results-table th:first-child,
.results-table td:first-child {
  text-align: left;
}

.results-table tbody tr:nth-child(even) {
  background: rgba(244, 241, 231, 0.6);
}

.results-total-row td {
  font-weight: 600;
  background: #f0ebd6;
}

/* Info block */

.info-block {
  font-size: 13px;
  color: var(--text-main);
  padding-right: 4px;
  overflow: auto;
}

.info-block h2 {
  margin-top: 0;
  font-size: 16px;
}

.info-block h3 {
  font-size: 14px;
  margin-top: 10px;
}

.info-block p {
  margin: 4px 0;
}

.info-block ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

/* Responsive layout */

@media (min-width: 720px) {
  .app {
    flex-direction: row;
    padding: 16px;
  }

  .panel--inputs {
    flex: 0 0 40%;
  }

  .panel--results {
    flex: 1 1 60%;
  }
}