:root {
  --page-bg: radial-gradient(circle at top left, #1b3b57, #102a43 45%, #071524 100%);
  --panel-bg: rgba(8, 22, 36, 0.9);
  --accent: #ff7a18;
  --accent-soft: rgba(255, 122, 24, 0.15);
  --brand-primary: #4cc9f0;
  --brand-primary-soft: rgba(76, 201, 240, 0.2);
  --brand-secondary: #d9e2ec;
  --brand-highlight: #2bb673;
  --brand-highlight-soft: rgba(43, 182, 115, 0.16);
  --text: #f7f9fc;
  --muted: #d9e2ec;
  --border: rgba(217, 226, 236, 0.18);
  --font-sans: "Space Grotesk", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  --safe-bottom: calc(env(safe-area-inset-bottom, 0px) + 5rem);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--page-bg);
  color: var(--text);
  padding: 2.5rem clamp(1rem, 3vw, 3rem) calc(var(--safe-bottom) + 1.5rem);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero {
  padding: 1rem 0 0.5rem;
}

.hero__header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 2rem;
}

.hero__brand {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  text-decoration: none;
}

.hero__spacer {
  min-height: 1px;
}

.hero__logo {
  width: clamp(88px, 12vw, 144px);
  height: clamp(88px, 12vw, 144px);
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(3, 11, 22, 0.4));
}

.hero__eyebrow {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--brand-primary);
  margin: 0 0 0.4rem;
}

.language-picker {
  justify-self: end;
}

.hero__lede {
  max-width: 640px;
  color: var(--muted);
  margin: 1rem auto 0;
  text-align: center;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 60px rgba(3, 5, 12, 0.65);
}

.form__grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.field--checkbox {
  flex-direction: row;
  gap: 0.75rem;
  align-items: flex-start;
  margin-top: 1rem;
}

.field--checkbox input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.35rem;
}

.field--checkbox span {
  color: var(--text);
  font-weight: 600;
}

.field--checkbox p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  padding: 0.65rem 0.85rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(15, 19, 33, 0.8);
  color: var(--text);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

select option {
  color: #05070c;
  background-color: #ffffff;
}

input:focus,
input:focus-visible,
select:focus,
select:focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--brand-primary-soft), 0 0 18px rgba(76, 201, 240, 0.45);
  background: rgba(25, 32, 52, 0.95);
}

.accounts__header {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.accounts__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.accounts {
  display: grid;
  gap: 1.25rem;
  margin-top: 1rem;
}

.account-card {
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.account-card header {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.account-card header input[type="text"] {
  flex: 1;
}

.account-card__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.account-card [data-withdrawal-min] {
  display: none;
}

.account-card--withdrawals-enabled [data-withdrawal-min] {
  display: flex;
}

.field--span-all {
  grid-column: 1 / -1;
}

button.primary {
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.7rem;
  background: linear-gradient(120deg, var(--accent), #ff3d77);
  color: #05070c;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

button.ghost {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0.6rem 1.4rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

button.primary,
button.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.btn-icon {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 12, 0.18);
}

.btn-icon svg {
  width: 1rem;
  height: 1rem;
}

.btn-label {
  display: inline-flex;
  align-items: center;
}

button.primary .btn-icon {
  background: rgba(5, 7, 12, 0.15);
}

button.ghost .btn-icon {
  border: 1px solid rgba(255, 255, 255, 0.15);
}

button.ghost--danger {
  color: #ff9cab;
  border-color: rgba(255, 156, 171, 0.5);
}

button.primary:hover,
button.primary:focus-visible {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 0 20px rgba(255, 122, 24, 0.35);
  transform: translateY(-1px);
}

button.ghost:hover,
button.ghost:focus-visible {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 20px rgba(76, 201, 240, 0.35);
  transform: translateY(-1px);
}

button.ghost:hover,
button.ghost:focus-visible {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.form__hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

.actions {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.actions__note {
  font-size: 0.8rem;
  color: var(--muted);
}

.form__cta-row {
  margin-top: 1.2rem;
  display: flex;
  justify-content: flex-end;
}

.primary--wide {
  width: min(320px, 100%);
}

.results h2 {
  margin-top: 0;
}

.placeholder {
  background: var(--brand-primary-soft);
  border-radius: 1rem;
  padding: 1rem 1.5rem;
  color: var(--brand-primary);
  font-family: var(--font-mono);
}

.summary__cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.release-diagram {
  margin-top: 1.25rem;
  border-radius: 1.25rem;
  border: 1px solid var(--border);
  padding: 1.25rem;
  background: radial-gradient(circle at 15% 20%, rgba(76, 201, 240, 0.16), transparent 55%),
    linear-gradient(145deg, rgba(10, 22, 38, 0.92), rgba(6, 14, 26, 0.9));
  box-shadow: inset 0 0 35px rgba(0, 0, 0, 0.35);
}

.release-diagram__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
}

.release-diagram__header h3 {
  margin: 0;
}

.release-diagram__header p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  max-width: 540px;
}

.release-diagram__legend {
  display: grid;
  grid-template-columns: repeat(2, max-content max-content);
  gap: 0.35rem 0.65rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend__swatch {
  width: 2.1rem;
  height: 0.45rem;
  border-radius: 999px;
  display: inline-block;
}

.legend__swatch--bar {
  background: linear-gradient(120deg, var(--brand-primary), var(--brand-highlight));
}

.legend__swatch--marker {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.summary__diagram {
  margin-top: 1.25rem;
  position: relative;
  min-height: 180px;
}

.summary__diagram[hidden] {
  display: none;
}

.summary__diagram-empty {
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 1rem;
  padding: 1rem;
  text-align: center;
}

.diagram__axis {
  position: relative;
  padding-top: 0.25rem;
  margin-bottom: 1.25rem;
}

.diagram__axis::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

.diagram__axis-label {
  position: absolute;
  bottom: 0;
  transform: translate(-50%, 120%);
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: 0.03em;
  left: var(--pos, 0%);
}

.diagram__axis-label--start {
  transform: translate(0, 120%);
}

.diagram__axis-label--end {
  transform: translate(-100%, 120%);
}

.diagram__rows {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.diagram-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 1rem;
  align-items: center;
}

.diagram-row__label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.diagram-row__name {
  font-weight: 600;
}

.diagram-row__meta {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.diagram-row__bar {
  position: relative;
  height: 1rem;
}

.diagram-bar {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.diagram-bar__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: linear-gradient(120deg, hsl(var(--bar-hue, 20), 85%, 60%), hsl(var(--bar-hue-accent, 60), 70%, 55%));
  box-shadow: 0 10px 25px rgba(8, 22, 36, 0.35), 0 0 25px rgba(76, 201, 240, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: #05070c;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.diagram-bar__duration {
  padding: 0 0.4rem;
}

.diagram-bar__marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  border: 2px solid rgba(5, 7, 12, 0.85);
  background: #ffffff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
  pointer-events: none;
  z-index: 3;
}

.diagram-row + .diagram-row {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 1rem;
}

.diagram-row:first-child {
  padding-top: 0.25rem;
}

.diagram-row:last-child {
  padding-bottom: 0.5rem;
}

.summary__debt-note {
  margin: 0.35rem 0 0.6rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px dashed rgba(76, 201, 240, 0.45);
  background: rgba(76, 201, 240, 0.12);
  color: var(--brand-primary);
  font-weight: 600;
}

.summary__debt-note[data-state="success"] {
  color: var(--brand-highlight);
  border-color: rgba(43, 182, 115, 0.5);
  background: var(--brand-highlight-soft);
}

.summary__debt-note[data-state="warning"] {
  color: #ffe4a3;
  border-color: rgba(255, 228, 163, 0.5);
  background: rgba(255, 228, 163, 0.12);
}
.summary__debt-note[data-state="success"]::after {
  content: " ✨";
}

.summary-card {
  border-radius: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.summary-card h3 {
  margin: 0 0 0.5rem;
}

.summary-card__meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.summary-card__figure {
  font-size: 1.5rem;
  color: var(--brand-primary);
}

.timeline__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.timeline details {
  border: 1px solid var(--border);
  border-radius: 1rem;
  margin-bottom: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
}

.timeline summary {
  cursor: pointer;
  list-style: none;
  padding: 0.9rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.timeline__label {
  flex: 1;
}

.timeline__debt {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.timeline__payment {
  flex: 1;
  text-align: right;
}

.timeline table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
}

.timeline__row--focus {
  background: rgba(76, 201, 240, 0.14);
}

.timeline__row--focus td {
  color: var(--text);
  font-weight: 600;
}

.timeline th,
.timeline td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.timeline tbody tr:last-child td {
  border-bottom: none;
}

#sim-form,
#accounts-grid,
#results {
  scroll-margin-top: calc(var(--safe-bottom) + 1rem);
}

.sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  background: rgba(5, 7, 12, 0.92);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(18px);
  box-shadow: 0 -10px 30px rgba(2, 3, 8, 0.8);
  z-index: 999;
}

.sticky-bar__nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}


.toast-stack {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 1.5rem);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(90vw, 380px);
  z-index: 1000;
  pointer-events: none;
}

.toast {
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: toast-in 0.25s ease forwards;
}

.toast[data-tone="success"] {
  background: rgba(43, 182, 115, 0.92);
  color: #e8fff5;
}

.toast[data-tone="error"] {
  background: rgba(159, 37, 53, 0.92);
  color: #ffe4ea;
}

.toast[data-tone="info"] {
  background: rgba(20, 86, 128, 0.92);
  color: #e4f7ff;
}

.toast[data-tone="warning"] {
  background: rgba(173, 102, 23, 0.92);
  color: #fff2dc;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.ghost--compact {
  padding: 0.45rem 0.95rem;
  font-size: 0.85rem;
}

.sticky-nav__btn {
  background: rgba(5, 7, 12, 0.65);
  border-color: rgba(255, 255, 255, 0.12);
  padding: 0.35rem 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  margin: 0.1rem 0;
  font-size: 1rem;
}

.sticky-nav__btn:focus-visible,
.sticky-nav__btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: rgba(5, 7, 12, 0.9);
}

.sticky-nav__icon {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: rgba(76, 201, 240, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sticky-nav__icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

.sticky-nav__label {
  white-space: nowrap;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.sticky-nav__label--cta {
  font-size: 1.1rem;
}

.sticky-bar__cta {
  flex-shrink: 0;
  min-width: 190px;
  padding-inline: 1.2rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1.1rem;
}

.sticky-bar__cta-icon {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: rgba(5, 7, 12, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #05070c;
}

.sticky-bar__cta-icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

.timeline__scroller {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.5rem;
}

.timeline__scroller::-webkit-scrollbar {
  height: 6px;
}

.timeline__scroller::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

.timeline__scroller::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.timeline table {
  min-width: 560px;
}

.timeline__row--withdrawal {
  background: rgba(76, 201, 240, 0.18);
}

.timeline__row--payoff {
  background: rgba(43, 182, 115, 0.2);
  font-weight: 600;
}

.withdrawals {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.withdrawals__header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.withdrawals__header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.withdrawals__list {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.withdrawal-card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  background: rgba(8, 12, 22, 0.6);
}

.withdrawal-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.withdrawal-card ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
  display: grid;
  gap: 0.35rem;
}

@media (max-width: 720px) {
  body {
    padding: 1.1rem clamp(0.9rem, 5vw, 1.4rem) calc(var(--safe-bottom) + 1rem);
  }

  .panel {
    padding: 1.25rem;
  }

  .account-card header {
    flex-direction: column;
    align-items: stretch;
  }

  .field--checkbox {
    flex-direction: row;
    align-items: flex-start;
  }

  .field--checkbox > div {
    flex: 1;
  }

  .panel button.ghost,
  .panel button.primary,
  .accounts__actions button,
  .actions button,
  .primary--wide {
    width: 100%;
    text-align: center;
  }

  .release-diagram__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .release-diagram__legend {
    grid-template-columns: max-content max-content;
  }

  .diagram-row {
    grid-template-columns: 1fr;
  }

  .diagram-row__bar {
    height: 1.1rem;
  }

  .form__cta-row {
    justify-content: stretch;
  }

  .sticky-bar {
    flex-wrap: wrap;
    padding-inline: clamp(0.8rem, 4vw, 1.25rem);
    gap: 0.65rem;
  }

  .sticky-bar__nav {
    order: 1;
    flex: 1;
    min-width: 0;
    justify-content: flex-start;
    margin-bottom: 0;
  }

  .sticky-bar__cta {
    order: 1;
    min-width: 0;
  }
}

@media (max-width: 900px) {
  .sticky-nav__label {
    display: none;
  }

  .sticky-nav__label--cta {
    display: inline;
    font-size: 1.1rem;
  }

  .sticky-nav__btn {
    width: 3.1rem;
    height: 3.1rem;
    min-width: 3.1rem;
    padding: 0;
    justify-content: center;
    border-radius: 999px;
  }

  .sticky-bar__nav > .sticky-nav__btn {
    padding: 0;
  }

  .sticky-nav__btn .sticky-nav__icon {
    width: 2rem;
    height: 2rem;
  }

  .sticky-bar__nav {
    gap: 0.6rem;
  }

  .sticky-bar__cta {
    min-width: 0;
    width: auto;
    padding: 0.35rem 1.2rem;
    gap: 0.35rem;
  }

  .sticky-bar__cta-icon {
    width: 2rem;
    height: 2rem;
  }
}

@media (max-width: 600px) {
  .sticky-nav__btn {
    padding: 0;
  }

  .sticky-bar__cta {
    height: 3.1rem;
    padding: 0 1rem;
    font-size: 1rem;
    gap: 0.3rem;
    max-width: 150px;
  }

  .sticky-bar__cta-icon {
    background: rgba(5, 7, 12, 0.15);
    width: 1.6rem;
    height: 1.6rem;
  }

  .timeline summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .timeline__label,
  .timeline__debt,
  .timeline__payment {
    width: 100%;
    text-align: left;
  }

  .timeline table {
    font-size: 0.78rem;
    min-width: 520px;
  }

  .timeline th,
  .timeline td {
    padding: 0.4rem 0.5rem;
  }
}
