:root {
  --ink: #17211d;
  --muted: #66736d;
  --paper: #f6f8f6;
  --line: #dbe3dd;
  --healthy: #1f7a4c;
  --warning: #a66b00;
  --action: #b42318;
}

body {
  background: var(--paper);
  color: var(--ink);
}

.error-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(145deg, #f3f7f3 0%, #e5eee5 100%);
}

.error-card {
  width: min(100%, 620px);
  padding: clamp(2rem, 6vw, 4rem);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(31, 59, 39, .12);
  text-align: center;
}

.error-card h1 {
  margin-bottom: 1rem;
  font-size: clamp(2rem, 7vw, 3.5rem);
}

.error-eyebrow {
  margin: 1rem 0 .35rem;
  color: var(--brand);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.error-reference {
  margin: 1.5rem 0;
  padding: .75rem;
  border-radius: 8px;
  background: #f3f7f3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: 0;
}

.brand-finance {
  color: #00856f;
}

.scenario-nav-item {
  display: flex;
  align-items: center;
  margin-right: .5rem;
}

.scenario-selector-form {
  min-width: 220px;
}

.funded-hero {
  background: #60805A;
  color: #fff;
  padding: clamp(1.15rem, 2.4vw, 2rem);
  border-radius: 8px;
  box-shadow: 0 14px 35px rgba(15, 61, 51, 0.18);
  margin-bottom: 1.25rem;
}

.funded-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .45rem .75rem;
}

.funded-meta .funded-detail::before {
  content: "|";
  margin-right: .75rem;
}

.funded-kicker,
.funded-detail {
  color: #cce3dc;
  margin: 0;
}

.funded-kicker {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
}

.funded-hero h1 {
  font-size: clamp(2.2rem, 4.8vw, 4.9rem);
  line-height: 1.02;
  margin: .35rem 0 0;
  max-width: 1160px;
  white-space: nowrap;
}

.funded-hero h1 span {
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}

.funded-detail {
  font-size: 1.05rem;
}

.panel,
.timeline-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.section-heading h2 {
  font-size: 1.25rem;
  margin: 0;
}

.section-heading p {
  color: var(--muted);
  margin: .15rem 0 0;
}

.stacked-bar {
  display: flex;
  min-height: 68px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, .08);
}

.stacked-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  text-align: center;
  padding: .5rem;
}

.bucket-empty-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 120px;
  padding: 1.5rem;
  border: 1px dashed #a9b9ad;
  border-radius: 8px;
  background: #f6faf5;
}

.bucket-empty-state h3 {
  margin: 0 0 .35rem;
  font-size: 1.15rem;
}

.bucket-empty-state p {
  margin: 0;
  color: var(--muted);
}

.bucket-grid,
.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #d8e4dc;
  border-radius: 8px;
  background: #f3f8f2;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: .9rem;
}

.summary-strip strong {
  display: block;
  margin-top: .25rem;
  color: var(--ink);
}

.metric-card,
.rule-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #fbfcfb;
}

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

.key-number {
  font-size: 1.65rem;
  font-weight: 800;
}

.metric-card p,
.key-number span,
.rule-card small,
.rule-card span {
  color: var(--muted);
}

.bucket-card-label {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.bucket-card-stats {
  margin: .65rem 0 0;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--ink) !important;
}

.bucket-card-stats strong {
  font-weight: 800;
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.portfolio-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.portfolio-step-empty {
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfb;
}

.portfolio-lookup-value {
  min-height: 38px;
  background: #f5f6f5;
  color: var(--muted);
}

.portfolio-account + .portfolio-account {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.portfolio-account-list {
  display: grid;
  gap: 1rem;
}

.portfolio-account-editor {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.portfolio-account-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.portfolio-holdings-table {
  min-width: 900px;
}

.portfolio-holdings-table.custom-columns-visible {
  min-width: 1180px;
}

.portfolio-holdings-table th:nth-child(1),
.portfolio-holdings-table td:nth-child(1) {
  min-width: 180px;
}

.portfolio-holdings-table th:nth-child(2),
.portfolio-holdings-table td:nth-child(2) {
  min-width: 100px;
}

.portfolio-holdings-table th:nth-child(6),
.portfolio-holdings-table td:nth-child(6),
.portfolio-holdings-table th:nth-child(7),
.portfolio-holdings-table td:nth-child(7) {
  min-width: 140px;
}

.portfolio-holding-actions {
  display: flex;
  gap: .4rem;
  white-space: nowrap;
}

.purpose-panel {
  border: 1px dashed #98ad9c;
  border-radius: 8px;
  background: #f4f8f3;
}

.investment-heading-inline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .45rem;
}

.investment-heading-inline h2,
.investment-heading-inline p {
  margin: 0;
}

.investment-heading-divider {
  color: var(--muted);
}

.pane-heading-inline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .45rem;
}

.pane-heading-inline h2,
.pane-heading-inline p {
  margin: 0;
}

.pane-heading-divider {
  color: var(--muted);
}

.rule-card {
  border-left: 6px solid var(--healthy);
}

.rule-card strong,
.status-green strong {
  color: var(--healthy);
}

.status-yellow {
  border-left-color: var(--warning);
}

.status-yellow strong {
  color: var(--warning);
}

.status-red {
  border-left-color: var(--action);
}

.status-red strong {
  color: var(--action);
}

.auth-shell {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(100%, 430px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2rem;
}

.auth-panel-compact {
  width: min(100%, 560px);
  padding: 1.5rem;
}

.auth-logo {
  width: 58px;
  height: 58px;
  margin-bottom: 1rem;
}

.auth-logo-compact {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.auth-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.auth-title-row h1 {
  margin: 0;
  font-size: 2.25rem;
  line-height: 1;
}

.auth-compact-form {
  display: grid;
  gap: .9rem;
}

.auth-field-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
}

.auth-field-row .form-label {
  margin-bottom: 0;
  font-weight: 600;
}

.auth-submit-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 1rem;
}

.auth-submit-row .btn {
  grid-column: 2;
}

@media (max-width: 900px) {
  .dashboard-columns,
  .portfolio-entry-grid,
  .bucket-grid,
  .rule-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .funded-hero h1 {
    white-space: normal;
  }

  .section-heading {
    flex-direction: column;
  }

  .stacked-bar {
    min-height: 104px;
  }
}

@media (max-width: 575px) {
  .bucket-empty-state {
    align-items: flex-start;
    flex-direction: column;
  }

  .bucket-empty-state .btn {
    width: 100%;
  }
}

@media (max-width: 575px) {
  .auth-panel-compact {
    padding: 1.25rem;
  }

  .auth-title-row h1 {
    font-size: 1.9rem;
  }

  .auth-field-row,
  .auth-submit-row {
    grid-template-columns: 1fr;
    gap: .4rem;
  }

  .auth-submit-row .btn {
    grid-column: 1;
  }
}

.expenses-panel {
  max-width: 1200px;
}

.cash-flows-panel {
  max-width: 1400px;
}

.scenario-name-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 360px);
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.scenario-name-row .form-label {
  margin-bottom: 0;
  font-weight: 700;
}

.expense-total-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 180px;
  gap: 1rem;
  align-items: center;
  background: #edf7f3;
  border: 1px solid #cbe5db;
  border-radius: 8px;
  margin: 1rem 0;
  padding: 1rem;
}

.cash-flow-total-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 180px 180px;
  gap: 1rem;
  align-items: center;
  background: #edf7f3;
  border: 1px solid #cbe5db;
  border-radius: 8px;
  margin: 1rem 0;
  padding: 1rem;
}

.cash-flow-total-bar span {
  color: var(--muted);
  font-weight: 700;
}

.cash-flow-total-bar strong {
  color: #0f3d33;
  font-size: 1rem;
  text-align: right;
}

.expense-total-bar span {
  color: var(--muted);
  font-weight: 700;
}

.expense-total-bar strong {
  color: #0f3d33;
  font-size: 1.35rem;
  text-align: right;
}

.expense-money-col {
  width: 180px;
}

.expenses-table input,
.expenses-table select {
  min-width: 0;
}

.annual-expense-label {
  font-weight: 700;
  white-space: nowrap;
}

.expense-actions {
  display: flex;
  justify-content: flex-end;
}

.cash-flow-year-col {
  width: 110px;
}

.cash-flow-money-col {
  width: 150px;
}

.cash-flows-table input,
.cash-flows-table select {
  min-width: 0;
}

.cash-flow-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

.ticker-search-form {
  max-width: 620px;
}

.ticker-editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

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

@media (max-width: 700px) {
  .expense-total-bar {
    grid-template-columns: 1fr;
  }

  .cash-flow-total-bar {
    grid-template-columns: 1fr;
  }

  .expense-total-bar strong,
  .cash-flow-total-bar strong {
    text-align: left;
  }

  .ticker-editor-grid {
    grid-template-columns: 1fr;
  }

  .ticker-editor-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
