:root {
  --bg: #f4f6f8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: rgba(255, 255, 255, 0.95);
  --text: #101316;
  --muted: #5f6873;
  --line: rgba(16, 19, 22, 0.12);
  --accent: #0b7a75;
  --accent-soft: rgba(11, 122, 117, 0.12);
  --danger: #d14848;
  --ok: #2f8f6a;

  --chart-capital: #0b7a75;
  --chart-target: #1d2430;
  --chart-pension: #2f8f6a;
  --chart-stock: #52a7a3;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #d4eceb 0%, transparent 42%),
    radial-gradient(circle at 90% 90%, #d8e4ef 0%, transparent 40%),
    var(--bg);
  padding: 18px;
}

body[data-view="results"] {
  overflow: hidden;
}

.page-shell {
  width: min(1400px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

body[data-view="results"] .page-shell {
  height: calc(100vh - 36px);
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(10px);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.brand img {
  width: 28px;
  height: 28px;
}

.layout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-height: calc(100vh - 110px);
}

.bottom-home-wrap {
  display: flex;
  justify-content: center;
  margin-top: 2px;
}

.bottom-home-btn {
  min-width: 190px;
  text-align: center;
  text-decoration: none;
}

body[data-view="results"] .layout-grid {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) 50vh;
  min-height: 0;
  height: 100%;
}

body[data-view="results"] .bottom-home-wrap {
  display: none;
}

body[data-view="results"] #resultsView {
  min-height: 0;
  height: 50vh;
  overflow: auto;
  gap: 10px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  padding: 18px;
  overflow: auto;
  display: none;
}

.panel.view-active {
  display: block;
}

h1,
h2,
h3,
legend {
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.04;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

p {
  margin: 0 0 14px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(11, 122, 117, 0.35);
  border-radius: 999px;
  padding: 6px 12px;
  margin-bottom: 10px;
}

.intro-actions,
.wizard-actions,
.results-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--text);
  background: var(--text);
  color: #f9fbfb;
}

.btn.primary.invalid {
  border-color: #9d2c2c;
  background: #d14848;
  color: #fff;
}

.btn.primary.ready:not(.invalid) {
  border-color: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 45%, transparent);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.7);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wizard-head,
.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.step {
  display: none;
}

.step.step-active {
  display: block;
}

.step-progress {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.step-progress.valid {
  color: #1f694d;
  border-color: rgba(47, 143, 106, 0.45);
  background: rgba(47, 143, 106, 0.15);
}

.step-progress.invalid {
  color: #9d2c2c;
  border-color: rgba(209, 72, 72, 0.45);
  background: rgba(209, 72, 72, 0.15);
}

.field-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.field-grid.one {
  grid-template-columns: 1fr;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid.deposits {
  grid-template-columns: 1fr;
}

.phase-savings-box {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.phase-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  padding: 10px;
}

.phase-card h4 {
  margin: 0 0 8px;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.phase-card input[readonly] {
  background: rgba(16, 19, 22, 0.04);
  color: var(--muted);
}

.deposit-list {
  display: grid;
  gap: 10px;
}

.deposit-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.65);
}

.deposit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.deposit-head h4 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.deposit-remove {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.deposit-fields {
  margin-bottom: 0;
}

.deposit-actions {
  margin-top: 8px;
}

.field-grid.compact {
  margin-bottom: 0;
}

label,
legend {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.input-wrap {
  position: relative;
}

.input-wrap span {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 500;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 15px;
  padding: 8px 10px;
}

input[type="number"] {
  padding-right: 52px;
}

input:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, white);
  outline-offset: 1px;
}

input.invalid,
select.invalid {
  border-color: rgba(209, 72, 72, 0.65);
  background: rgba(255, 232, 232, 0.9);
}

fieldset {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.segmented label {
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.65);
}

.segmented input {
  display: none;
}

.segmented span {
  display: block;
  padding: 8px 12px;
  color: var(--muted);
}

.segmented input:checked+span {
  background: var(--accent-soft);
  color: var(--text);
}

.chart-card,
.status-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  padding: 12px;
}

.chart-card {
  display: none;
  min-height: 260px;
  background: rgba(255, 255, 255, 0.9);
  position: relative;
}

body[data-view="results"] .chart-card {
  display: block;
  min-height: 0;
}

#resultsChart {
  width: 100%;
  height: 100%;
}

.chart-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 34px;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.chart-toggle.active {
  border-color: rgba(11, 122, 117, 0.4);
  background: rgba(11, 122, 117, 0.14);
  color: var(--accent);
}

.chart-toast {
  position: absolute;
  top: 52px;
  right: 12px;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(16, 19, 22, 0.9);
  color: #f9fbfb;
  font-size: 12px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.chart-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.status-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  margin-bottom: 10px;
}

.manual-controls {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.manual-controls label {
  display: grid;
  gap: 4px;
}

.manual-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.manual-value {
  font-weight: 700;
  color: var(--accent);
}

.manual-controls input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
}

.summary-table tr:last-child th,
.summary-table tr:last-child td {
  border-bottom: 0;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(16, 19, 22, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(980px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-close-btn {
  white-space: nowrap;
}

.modal-body {
  display: grid;
  gap: 12px;
}

.help-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.help-section h3 {
  margin-bottom: 8px;
}

.help-section ul {
  margin: 0 0 10px 18px;
  padding: 0;
}

.help-section li {
  margin-bottom: 6px;
  line-height: 1.4;
}

@media (max-width: 880px) {
  body {
    padding: 10px;
  }

  .layout-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .panel {
    min-height: 250px;
  }

  .field-grid.two,
  .field-grid.three,
  .field-grid.deposits,
  .status-grid {
    grid-template-columns: 1fr;
  }

  body[data-view="results"] .page-shell {
    height: calc(100vh - 20px);
  }

  body[data-view="results"] .layout-grid {
    min-height: 0;
    height: 100%;
    grid-template-rows: minmax(0, 1fr) 50vh;
  }

  .topbar {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .topbar-actions {
    width: auto;
    justify-content: flex-end;
    margin-left: auto;
    flex-shrink: 0;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal-card {
    max-height: 92vh;
    border-radius: 14px;
    padding: 12px;
  }
}

