:root {
  --bg: #f2efe8;
  --panel: #fffdf8;
  --ink: #2a2824;
  --muted: #6f695e;
  --line: #d8d1c5;
  --accent: #2f6b7f;
  --accent-soft: #e5f1f5;
  --ok: #1f7a46;
  --bad: #a13e2d;
}

body.dark {
  --bg: #11161c;
  --panel: #1a222c;
  --ink: #e5edf7;
  --muted: #9aabbe;
  --line: #2b3948;
  --accent: #66a7c0;
  --accent-soft: #203443;
  --ok: #56c488;
  --bad: #ff7f75;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Avenir Next", sans-serif;
  background: radial-gradient(circle at top right, #f6f0df, var(--bg) 45%);
}

body.dark {
  background: radial-gradient(circle at top right, #1a2631, var(--bg) 45%);
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.2rem 1rem 2.8rem;
}

#settings {
  max-width: 1400px;
  margin: 0 auto;
}

.hero {
  position: relative;
  margin-bottom: 0.85rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.badge {
  display: inline-flex;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03rem;
  text-transform: uppercase;
}

.badge-beta {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0;
}

.theme-toggle .material-symbols-outlined {
  font-size: 22px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

h1 {
  margin: 0.2rem 0 0.1rem;
  font-size: 2rem;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
}

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

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

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tab {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

body.dark .tab {
  background: #f3f6fa;
  color: #1a2430;
  border-color: #b9c6d6;
}

body.dark .tab.active {
  background: #2a3948;
  color: #e7f0fa;
  border-color: #5f89a1;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 0.85rem;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.04);
}

.hint {
  margin-top: 0.3rem;
  margin-bottom: 0.55rem;
  font-size: 0.88rem;
}

.info-tip {
  display: inline;
  font-size: 14px;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 2px;
  color: var(--muted);
  opacity: 0.5; /*Icon itself is faded */
  transition: opacity 0.15s ease;
}

.info-tip:hover {
  opacity: 1;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #2a2824; /* Solid dark background for light mode */
  color: #fff;
  border: 1px solid #000;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 400;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  line-height: 1.5;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease;
  z-index: 1000;
}

body.dark .info-tip::after {
  background: #eef4fb; /* Solid light background for dark mode */
  color: #11161c;
  border-color: #fff;
}

.info-tip:hover::after {
  opacity: 1;
  visibility: visible;
}

.budget {
  margin-bottom: 0.55rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

.budget-green {
  color: var(--ok);
}

.budget-neutral {
  color: var(--muted);
}

details > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::after {
  content: "+";
  float: right;
  color: var(--accent);
}

details[open] > summary::after {
  content: "-";
}

details .grid {
  margin-top: 0.65rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.fire-toggle-fields.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.fire-toggle-fields {
  align-items: start;
}

.fire-toggle-hint {
  font-style: italic;
  font-size: 0.78rem;
  margin-top: 0.15rem;
  margin-bottom: 0;
}


.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  align-items: start;
}

.contrib-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  grid-column: span 2;
  align-items: end;
}

.account-group {
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.account-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.account-group-title {
  margin: 0.65rem 0 0.45rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
}

.allocation-row {
  display: flex;
  align-items: end;
  gap: 1rem;
  grid-column: span 2;
}

.allocation-row > label:first-child {
  flex: 0 0 auto;
  width: 180px;
}

.allocation-row > .checkbox-label {
  padding-bottom: 0.48rem;
}

label {
  display: grid;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

input {
...
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  padding: 0.48rem 0.56rem;
  height: 2.3rem;
}

/* Hide number spinners */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  padding: 0.48rem 0.56rem;
  resize: vertical;
}

body.dark input {
  background: #f3f6fa;
  color: #16212c;
  border-color: #b9c6d6;
}

body.dark textarea {
  background: #f3f6fa;
  color: #16212c;
  border-color: #b9c6d6;
}

.full {
  grid-column: 1 / -1;
  margin-top: 0.6rem;
}

input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.chart-card {
  padding: 0.85rem;
}

.chart-controls {
  margin-bottom: 0.5rem;
}

.networth-label {
  letter-spacing: 0.1em;
  font-weight: 700;
  color: #6e6a63;
  font-size: 0.78rem;
}

.networth-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.15rem;
}

.networth-row h2 {
  margin: 0;
  font-size: 2.5rem;
}

.change.positive {
  color: var(--ok);
}

.change.negative {
  color: var(--bad);
}

.projection-chart {
  margin-top: 0.45rem;
  height: 520px;
  position: relative;
}

.simulation-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  opacity: 0.95;
  z-index: 10;
  gap: 1rem;
}

.simulation-overlay.hidden {
  display: none;
}

.exhaustion-warning {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: left;
}
.exhaustion-warning.hidden {
  display: none;
}

.simulation-overlay p {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.simulation-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.projection-chart canvas {
  width: 100%;
  height: 100%;
}

.coverage-wrap {
  margin-top: 0.8rem;
}

.coverage-title {
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  color: #6e6a63;
  font-weight: 700;
}

body.dark .networth-label,
body.dark .coverage-title {
  color: #d4e0ee;
}

.coverage-chart {
  height: 220px;
  margin-top: 0.25rem;
}

.coverage-chart canvas {
  width: 100%;
  height: 100%;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.range-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.range-row output {
  min-width: 3rem;
  text-align: right;
  font-weight: 600;
  font-size: 0.95rem;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  opacity: 0.5;
  margin-top: 0.15rem;
}

.career-toggles {
  display: flex;
  gap: 1.5rem;
  padding: 0.5rem 0;
  flex-wrap: wrap;
}

.career-section {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(128,128,128,0.15);
}

.career-section:last-child {
  border-bottom: none;
}

.career-section h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 0.15rem;
}

.career-section .hint {
  font-size: 0.78rem;
  opacity: 0.6;
  margin: 0 0 0.5rem;
}

button {
  border: 1px solid var(--accent);
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  cursor: pointer;
}

button.ghost {
  color: var(--accent);
  background: transparent;
}

.status {
  margin-left: auto;
  font-size: 0.88rem;
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--bad);
}

.status.info {
  color: var(--muted);
}

.footer {
  margin-top: 3rem;
  padding: 2.5rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.65;
  text-align: center;
}

.footer-content {
  max-width: 900px;
  margin: 0 auto;
}

.footer strong {
  color: var(--bad);
  font-weight: 600;
}

@media (max-width: 760px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .contrib-pair {
    grid-column: span 1;
  }

  .allocation-row {
    grid-column: span 1;
    flex-wrap: wrap;
  }

  .actions {
    flex-wrap: wrap;
  }

  .status {
    margin-left: 0;
    width: 100%;
  }
}

/* Tax Brackets Visualization */
.tax-brackets-container {
  margin-top: 0.65rem;
}

.tax-schedule-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--panel);
}

.tax-schedule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.tax-schedule-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.tax-schedule-year-input {
  width: 80px;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
}

.btn-delete-schedule {
  background: transparent;
  border: none;
  color: var(--bad);
  padding: 0.3rem;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-delete-schedule:hover {
  background: rgba(161, 62, 45, 0.1);
}

/* Tax brackets grid layout */
.tax-brackets-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.tax-brackets-row {
  display: flex;
  gap: 0.5rem;
  min-width: min-content;
}

.tax-rates-row {
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.5rem;
}

.tax-cutoffs-row {
  padding-top: 0.25rem;
}

.tax-bracket-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 70px;
  flex: 0 0 auto;
}

.tax-input-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.tax-inflation-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.tax-inflation-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}

.tax-rate-input,
.tax-cutoff-input {
  width: 65px;
  padding: 0.35rem 0.25rem;
  font-size: 0.85rem;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.tax-cutoff-header {
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-delete-bracket {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ff6b9d;
  border: none;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-delete-bracket:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  background: #ff5a8a;
}

.btn-add-bracket {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

.btn-add-bracket:hover {
  opacity: 0.9;
}

.btn-add-schedule {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 1rem;
}

.btn-add-schedule:hover {
  opacity: 0.9;
}

.json-collapsed {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.json-collapsed:last-child {
  margin-bottom: 0;
}

.json-collapsed > summary {
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

body.dark .tax-rate-input,
body.dark .tax-cutoff-input {
  background: #f3f6fa;
  color: #16212c;
  border-color: #b9c6d6;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2rem;
  max-width: 460px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.modal h2 {
  margin-top: 0;
}

.modal p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0.75rem 0;
}

.modal-accept {
  margin-top: 1.2rem;
  padding: 0.65rem 2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.modal-accept:hover {
  opacity: 0.9;
}
