/*
 * TPC Pages
 * Page-specific styles that sit on top of bootstrap.min.css + sparrow-theme.css.
 * Uses the --tpc-* theme variables defined in sparrow-theme.css so every page
 * follows the active theme (light / dark / fun).
 *
 * Sections:
 *   1. Financial tables (scenario editor, debt repayment, finance records)
 *   2. Scenario action lists (home page controls / reports)
 *   3. Scenario editor controls & period switcher
 *   4. Tablesorter header states
 *   5. Modals (#overlaydiv / #overlaydiv-large)
 *   6. Graphs
 *   7. Landing page (.tpc-welcome)
 *   8. Settings page refinements
 *   9. Bootstrap 4 utility shims still referenced by legacy views
 */

/* ------------------------------------------------------------------ */
/* 1. Financial tables                                                 */
/* ------------------------------------------------------------------ */

#scenario_item_list,
#debtrepaytable,
#finance_item_list {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--tpc-radius-lg);
  overflow: hidden;
  background: var(--tpc-surface-strong);
  border: 1px solid var(--tpc-border);
  font-family: var(--tpc-font-sans);
}

#scenario_item_list th,
#scenario_item_list td,
#debtrepaytable th,
#debtrepaytable td,
#finance_item_list th,
#finance_item_list td {
  padding: 0.8rem 0.92rem;
  border-bottom: 1px solid color-mix(in oklab, var(--tpc-border), transparent 40%);
  color: var(--tpc-text);
  font-size: 0.9rem;
}

#scenario_item_list thead th,
#debtrepaytable thead th,
#finance_item_list thead th {
  background: color-mix(in oklab, var(--tpc-surface), black 6%);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tpc-text-muted);
}

#scenario_item_list tbody tr:nth-child(even) td,
#debtrepaytable tbody tr:nth-child(even) td,
#finance_item_list tbody tr:nth-child(even) td {
  background: color-mix(in oklab, var(--tpc-surface), transparent 18%);
}

#scenario_item_list tbody tr:hover td,
#debtrepaytable tbody tr:hover td,
#finance_item_list tbody tr:hover td {
  background: color-mix(in oklab, var(--tpc-surface), var(--tpc-accent) 10%);
}

#scenario_item_list tfoot td,
#debtrepaytable tfoot td,
#finance_item_list tfoot td {
  background: color-mix(in oklab, var(--tpc-surface), black 6%);
  font-weight: 700;
  border-top: 1px solid var(--tpc-border);
}

/* Editor table column sizing */
#scenario_item_list {
  table-layout: fixed;
}

#scenario_item_list th:nth-child(1),
#scenario_item_list td:nth-child(1) {
  width: 20%;
}

#scenario_item_list th:nth-child(2),
#scenario_item_list td:nth-child(2),
#scenario_item_list th:nth-child(3),
#scenario_item_list td:nth-child(3),
#scenario_item_list th:nth-child(4),
#scenario_item_list td:nth-child(4),
#scenario_item_list th:nth-child(8),
#scenario_item_list td:nth-child(8) {
  width: 9%;
}

#scenario_item_list th:nth-child(5),
#scenario_item_list td:nth-child(5) {
  width: 10%;
}

#scenario_item_list th:nth-child(6),
#scenario_item_list td:nth-child(6),
#scenario_item_list th:nth-child(7),
#scenario_item_list td:nth-child(7) {
  width: 17%;
}

/* Money in / money out columns read as numbers: right aligned */
#scenario_item_list th.sltb_amt,
#scenario_item_list th.sltb_income_mthly,
#scenario_item_list th.sltb_outgoings_mthly,
#scenario_item_list td.sltb_amt,
#scenario_item_list td.sltb_mthly_income,
#scenario_item_list td.sltb_mthly_outgoings,
#scenario_item_list td.table_mthly {
  text-align: right;
}

/* Home page scenario table has 3 columns */
#scenario_list {
  table-layout: fixed;
}

#scenario_list th:nth-child(1),
#scenario_list td:nth-child(1) {
  width: 34%;
}

#scenario_list th:nth-child(2),
#scenario_list td:nth-child(2),
#scenario_list th:nth-child(3),
#scenario_list td:nth-child(3) {
  width: 33%;
}

#scenario_list .scenario_name a {
  color: var(--tpc-text);
  font-weight: 560;
  text-decoration: none;
}

#scenario_list .scenario_name a:hover,
#scenario_list .scenario_name a:focus-visible {
  color: var(--tpc-accent);
}

/* ------------------------------------------------------------------ */
/* 2. Scenario action lists (icon + label rows)                        */
/* ------------------------------------------------------------------ */

#scenario_list .scenario_controls,
#scenario_list .scenario_reports,
#scenario_item_list .scenario_controls,
#debtrepaytable .scenario_controls,
#finance_item_list .scenario_controls {
  margin: 0;
  padding: 0;
  list-style: none;
}

#scenario_list .scenario_controls .scenario_action_list,
#scenario_list .scenario_reports .scenario_action_list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem 0.7rem;
}

#scenario_list .scenario_controls li,
#scenario_list .scenario_reports li {
  list-style: none;
  margin: 0;
  padding: 0;
}

#scenario_list .scenario_controls a,
#scenario_list .scenario_reports a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--tpc-accent);
  text-decoration: none;
  font-weight: 560;
  white-space: nowrap;
  line-height: 1.15;
}

#scenario_list .scenario_controls a:hover,
#scenario_list .scenario_reports a:hover,
#scenario_list .scenario_controls a:focus-visible,
#scenario_list .scenario_reports a:focus-visible {
  color: var(--tpc-accent-strong);
}

#scenario_list .scenario_controls a span,
#scenario_list .scenario_reports a span {
  font-size: 0.86rem;
}

/* Editor row action icons: single row, consistent hit area */
#scenario_item_list td.scenario_controls li,
#debtrepaytable td.scenario_controls li,
#finance_item_list td.scenario_controls li {
  display: inline-block;
  margin: 0 0.18rem;
  vertical-align: middle;
}

#scenario_item_list td.scenario_controls a,
#debtrepaytable td.scenario_controls a,
#finance_item_list td.scenario_controls a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  color: var(--tpc-accent);
  line-height: 1;
}

#scenario_item_list td.scenario_controls a:hover,
#debtrepaytable td.scenario_controls a:hover,
#finance_item_list td.scenario_controls a:hover {
  color: var(--tpc-accent-strong);
}

#scenario_item_list th.sltb_btn,
#scenario_item_list td.scenario_controls.sc_editor_controlls {
  text-align: center;
  white-space: nowrap;
  min-width: 86px;
}

.tpc-action-icon {
  font-size: 0.82rem;
  line-height: 1;
}

/* ------------------------------------------------------------------ */
/* 3. Scenario editor controls & period switcher                       */
/* ------------------------------------------------------------------ */

/* Money in vs money out summary strip */
.tpc-money-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.1rem;
}

.tpc-money-summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1.1rem 1.25rem;
  background: var(--tpc-surface-strong);
  border: 1px solid var(--tpc-border);
  border-radius: var(--tpc-radius-md);
  box-shadow: var(--tpc-shadow-tight);
}

.tpc-money-summary-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--tpc-text-muted);
}

.tpc-money-summary-value {
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: var(--tpc-text);
}

.tpc-money-summary-period {
  font-size: 0.78rem;
  color: var(--tpc-text-muted);
}

.tpc-money-in .tpc-money-summary-label i,
.tpc-money-in .tpc-money-summary-value {
  color: var(--tpc-success);
}

.tpc-money-out .tpc-money-summary-label i,
.tpc-money-out .tpc-money-summary-value {
  color: var(--tpc-danger);
}

.tpc-money-net.is-positive .tpc-money-summary-value {
  color: var(--tpc-success);
}

.tpc-money-net.is-negative .tpc-money-summary-value {
  color: var(--tpc-danger);
}

.tpc-money-net.is-negative {
  border-color: color-mix(in oklab, var(--tpc-danger), transparent 55%);
}

#scenarioeditor {
  display: flex;
  flex-direction: column;
  width: 100%;
}

#scenarioeditor > .fi_insert,
#main-wrapper > #add_scenario {
  margin-left: auto;
  margin-bottom: 0.8rem;
  float: none;
}

#scenariotable {
  width: 100%;
  border-collapse: collapse;
}

#scenario_period_switcher.tpc-period-switcher {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0.9rem auto 0;
  color: var(--tpc-text-soft);
  font-size: 0.84rem;
  letter-spacing: 0.02em;
}

#scenario_period_switcher .tpc-period-switcher-label {
  color: var(--tpc-text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

#scenario_period_switcher .tpc-period-switcher-options {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem;
  border: 1px solid var(--tpc-border);
  border-radius: var(--tpc-radius-pill);
  background: color-mix(in oklab, var(--tpc-surface), transparent 10%);
}

#scenario_period_switcher .tpc-period-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  color: var(--tpc-text-soft);
  cursor: pointer;
  user-select: none;
}

#scenario_period_switcher .tpc-period-option span {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  border-radius: var(--tpc-radius-pill);
  transition: background-color 150ms ease, color 150ms ease;
}

#scenario_period_switcher .tpc-period-option input {
  accent-color: var(--tpc-accent);
  margin: 0;
}

#scenario_period_switcher .tpc-period-option input:checked + span {
  background: color-mix(in oklab, var(--tpc-accent), transparent 83%);
  color: var(--tpc-accent);
}

/* ------------------------------------------------------------------ */
/* 3a. Navbar scenario quick-switch selector                           */
/* ------------------------------------------------------------------ */

.nav-scenario-switcher {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.tpc-nav-scenario-select {
  /* override Bootstrap's .form-select width:100% so it sizes to content */
  width: auto;
  min-width: 170px;
  max-width: 240px;
  height: auto;
  padding: 0.3rem 1.6rem 0.3rem 0.7rem;
  font-size: 0.85rem;
  background-color: color-mix(in oklab, var(--tpc-surface), transparent 6%);
  border-color: var(--tpc-border);
  color: var(--tpc-text);
}

@media (max-width: 991.98px) {
  .nav-scenario-switcher {
    width: 100%;
    margin: 0.4rem 0;
  }
  .tpc-nav-scenario-select {
    max-width: none;
    width: 100%;
  }
}

/* ------------------------------------------------------------------ */
/* 3b. Grouped scenarios home (Personal / Trust / Company ...)         */
/* ------------------------------------------------------------------ */

.tpc-scenario-groups {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.tpc-group {
  background: var(--tpc-surface-strong);
  border: 1px solid var(--tpc-border);
  border-radius: var(--tpc-radius-lg);
  overflow: hidden;
  box-shadow: var(--tpc-shadow-tight);
}

.tpc-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid color-mix(in oklab, var(--tpc-border), transparent 34%);
}

.tpc-group-name {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--tpc-text);
}

.tpc-group-count {
  font-size: 0.78rem;
  color: var(--tpc-text-muted);
  background: color-mix(in oklab, var(--tpc-surface), black 6%);
  padding: 0.15rem 0.6rem;
  border-radius: var(--tpc-radius-pill);
}

/* Featured "current" budget */
.tpc-group-current {
  margin: 0.9rem 1.1rem;
  padding: 0.9rem 1rem;
  border: 2px solid color-mix(in oklab, var(--tpc-accent), transparent 55%);
  border-radius: var(--tpc-radius-md);
}

.tpc-current-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.7rem;
  margin-bottom: 0.75rem;
}

.tpc-current-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tpc-accent);
}

.tpc-current-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--tpc-text) !important;
  text-decoration: none;
}

.tpc-current-name:hover,
.tpc-current-name:focus-visible {
  color: var(--tpc-accent) !important;
}

.tpc-money-summary-compact {
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.tpc-money-summary-compact .tpc-money-summary-item {
  padding: 0.85rem 1rem;
}

.tpc-money-summary-compact .tpc-money-summary-value {
  font-size: 1.2rem;
}

/* Other versions list */
.tpc-group-others {
  padding: 0 1.1rem 1rem;
}

.tpc-others-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--tpc-text-muted);
  margin: 0.4rem 0 0.5rem;
}

.tpc-version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  padding: 0.6rem 0;
  border-top: 1px solid color-mix(in oklab, var(--tpc-border), transparent 45%);
}

.tpc-version-main {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  min-width: 0;
}

.tpc-make-current {
  border: 0;
  background: transparent;
  color: var(--tpc-text-muted);
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  border-radius: var(--tpc-radius-sm);
}

.tpc-make-current:hover,
.tpc-make-current:focus-visible {
  color: var(--tpc-accent);
  background: color-mix(in oklab, var(--tpc-accent), transparent 88%);
  outline: none;
}

.tpc-version-name {
  font-weight: 560;
  color: var(--tpc-text) !important;
  text-decoration: none;
}

.tpc-version-name:hover,
.tpc-version-name:focus-visible {
  color: var(--tpc-accent) !important;
}

.tpc-version-net {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.tpc-version-net.is-positive {
  color: var(--tpc-success);
}

.tpc-version-net.is-negative {
  color: var(--tpc-danger);
}

/* Action lists inside groups (reuse scenario_action_list styling but as flex) */
.tpc-group-current .scenario_action_list,
.tpc-version-actions .scenario_action_list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.7rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tpc-group-current .scenario_action_list li,
.tpc-version-actions .scenario_action_list li {
  margin: 0;
}

.tpc-group-current .scenario_action_list a,
.tpc-version-actions .scenario_action_list a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--tpc-accent);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 560;
  white-space: nowrap;
}

.tpc-group-current .scenario_action_list a:hover,
.tpc-version-actions .scenario_action_list a:hover {
  color: var(--tpc-accent-strong);
}

.tpc-group-select {
  max-width: 150px;
  height: auto;
  padding: 0.15rem 1.4rem 0.15rem 0.5rem;
  font-size: 0.8rem;
}

@media (max-width: 575.98px) {
  .tpc-money-summary-compact {
    grid-template-columns: 1fr;
  }
  .tpc-version-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ------------------------------------------------------------------ */
/* 4. Tablesorter header states                                        */
/* ------------------------------------------------------------------ */

#scenario_list thead .header,
#scenario_item_list thead .header,
#debtrepaytable thead .header,
#finance_item_list thead .header {
  cursor: pointer;
}

#scenario_list thead .header:hover,
#scenario_list thead .headerSortUp,
#scenario_list thead .headerSortDown,
#scenario_item_list thead .headerSortUp,
#scenario_item_list thead .headerSortDown,
#debtrepaytable thead .headerSortUp,
#debtrepaytable thead .headerSortDown,
#finance_item_list thead .headerSortUp,
#finance_item_list thead .headerSortDown {
  background: color-mix(in oklab, var(--tpc-surface), var(--tpc-accent) 12%);
  color: var(--tpc-text);
  text-decoration: none;
}

/* ------------------------------------------------------------------ */
/* 5. Modals                                                           */
/* ------------------------------------------------------------------ */

#overlaydiv .modal-content,
#overlaydiv-large .modal-content {
  background: var(--tpc-surface-strong);
  border: 1px solid var(--tpc-border);
  border-radius: var(--tpc-radius-lg);
  box-shadow: var(--tpc-shadow-soft);
  color: var(--tpc-text);
}

#overlaydiv .modal-header,
#overlaydiv-large .modal-header,
#overlaydiv .modal-footer,
#overlaydiv-large .modal-footer {
  border-color: color-mix(in oklab, var(--tpc-border), transparent 34%);
}

#overlaydiv .modal-body p,
#overlaydiv-large .modal-body p,
#overlaydiv .modal-body label,
#overlaydiv-large .modal-body label,
#overlaydiv .modal-body .whattodotext,
#overlaydiv-large .modal-body .whattodotext {
  color: var(--tpc-text-soft);
}

.tpc-delete-modal {
  max-width: 760px;
  margin: 0 auto;
}

.tpc-delete-modal-title {
  margin: 0 0 0.65rem;
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--tpc-text);
}

.tpc-delete-modal-copy {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--tpc-text-soft);
}

/* ------------------------------------------------------------------ */
/* 5b. Responsive video embed (about page)                             */
/* ------------------------------------------------------------------ */

.tpc-video-embed {
  position: relative;
  width: 100%;
  max-width: 860px;
  margin: 0 auto 1.5rem;
  aspect-ratio: 16 / 9;
  border-radius: var(--tpc-radius-lg);
  overflow: hidden;
  border: 1px solid var(--tpc-border);
  box-shadow: var(--tpc-shadow-soft);
  background: #000;
}

.tpc-video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ------------------------------------------------------------------ */
/* 6. Graphs                                                           */
/* ------------------------------------------------------------------ */

#graphs {
  display: grid;
  gap: 1rem;
}

.graph {
  background: var(--tpc-surface-strong);
  border: 1px solid var(--tpc-border);
  border-radius: var(--tpc-radius-md);
  padding: 0.9rem;
  box-shadow: var(--tpc-shadow-tight);
}

/* ------------------------------------------------------------------ */
/* 7. Landing page                                                     */
/* ------------------------------------------------------------------ */

.tpc-welcome .tpc-hero {
  position: relative;
  overflow: hidden;
  padding-bottom: 4.5rem;
  background:
    radial-gradient(circle at 12% -10%, color-mix(in oklab, var(--tpc-accent), transparent 84%), transparent 42%),
    radial-gradient(circle at 90% 0%, color-mix(in oklab, var(--tpc-info), transparent 88%), transparent 40%),
    linear-gradient(180deg, var(--tpc-bg) 0%, color-mix(in oklab, var(--tpc-bg), white 5%) 100%);
  border-bottom: 1px solid color-mix(in oklab, var(--tpc-border), transparent 30%);
}

.tpc-welcome .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.6rem;
}

.tpc-welcome .home-link {
  color: var(--tpc-text);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
  text-decoration: none;
}

.tpc-welcome .menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.75rem;
}

.tpc-welcome .banner-text {
  max-width: 820px;
  margin: 9vh auto 0;
  text-align: center;
  color: var(--tpc-text);
}

.tpc-welcome .hero-title {
  font-size: clamp(2rem, 4.4vw, 3.3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.tpc-welcome .main-caption {
  margin: 0 auto;
  max-width: 640px;
  font-size: clamp(1.02rem, 1.6vw, 1.22rem);
  line-height: 1.55;
  font-weight: 450;
  color: var(--tpc-text-soft);
}

.tpc-welcome .hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.9rem;
}

.tpc-landing-features {
  padding: 3.25rem 0 1.5rem;
}

.tpc-landing-features .feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1.1rem;
}

.tpc-landing-features .feature-card {
  background: var(--tpc-surface-strong);
  border: 1px solid var(--tpc-border);
  border-radius: var(--tpc-radius-lg);
  padding: 1.4rem 1.35rem;
  box-shadow: var(--tpc-shadow-tight);
}

.tpc-landing-features .feature-icon {
  display: inline-flex;
  font-size: 1.35rem;
  color: var(--tpc-accent);
  margin-bottom: 0.65rem;
}

.tpc-landing-features .feature-card h2 {
  font-size: 1.08rem;
  margin-bottom: 0.45rem;
}

.tpc-landing-features .feature-card p {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.55;
}

/* Three-across feature row (light landing) */
.tpc-landing-features .feature-grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.tpc-landing-features .feature-grid-3 .feature-card h2 {
  font-size: 1.12rem;
  font-weight: 700;
}

/* Single quiet trust line under the features */
.landing-trust {
  text-align: center;
  margin: 2.2rem auto 0;
  max-width: 560px;
  font-size: 0.9rem;
  color: var(--tpc-text-muted);
}

.tpc-landing-features .landing-cta {
  text-align: center;
  margin: 3.25rem auto 2.5rem;
  max-width: 560px;
}

.tpc-landing-features .landing-cta h2 {
  font-weight: 700;
}

.tpc-landing-features .landing-cta p {
  margin-bottom: 1.25rem;
}

/* ------------------------------------------------------------------ */
/* 8. Settings page refinements                                        */
/* ------------------------------------------------------------------ */

#settingspage.settings-page-wrap {
  max-width: 980px;
  margin: 2rem auto;
}

#settingspage .settings-page-title,
#settingspage h1,
#settingspage .h2 {
  font-size: 1.22rem;
  line-height: 1.15;
  font-weight: 650;
}

#settingspage .settings-card-title,
#settingspage h2,
#settingspage .h4 {
  font-size: 0.96rem;
  line-height: 1.15;
  font-weight: 640;
}

#settingspage .settings-equal-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#settingspage .settings-inline-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

#settingspage .settings-equal-card form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

#settingspage .settings-equal-card .btn-modern {
  margin-top: auto;
}

#settingspage .btn-modern-xs,
#settingspage .btn-modern {
  min-height: 30px;
  padding: 0.22rem 0.52rem;
  font-size: 0.74rem;
  line-height: 1.1;
}

#settingspage .settings-password-toggle {
  min-height: auto;
  min-width: auto;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tpc-text);
  text-decoration: none;
}

#settingspage .settings-password-toggle .bi {
  font-size: 0.9rem;
  line-height: 1;
}

/* ------------------------------------------------------------------ */
/* 8a. AI thinking companion                                           */
/* ------------------------------------------------------------------ */

.tpc-companion {
  max-width: 760px;
  margin: 0 auto;
}

.tpc-companion-intro p {
  max-width: 580px;
}

.tpc-companion-unconfigured {
  margin-top: 1rem;
}

.tpc-companion-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.1rem 0 0.8rem;
}

.tpc-companion-toolbar label {
  white-space: nowrap;
  font-size: 0.88rem;
  margin: 0;
}

.tpc-companion-toolbar .form-select {
  max-width: 360px;
}

.tpc-companion-messages {
  min-height: 320px;
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1rem;
  background: color-mix(in oklab, var(--tpc-surface), transparent 20%);
  border: 1px solid var(--tpc-border);
  border-radius: var(--tpc-radius-lg);
}

.tpc-companion-msg {
  max-width: 85%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--tpc-radius-md);
  line-height: 1.5;
  font-size: 0.95rem;
}

.tpc-companion-msg p {
  margin: 0;
  white-space: pre-wrap;
}

.tpc-companion-msg.is-user {
  align-self: flex-end;
  background: color-mix(in oklab, var(--tpc-accent), transparent 86%);
  border: 1px solid color-mix(in oklab, var(--tpc-accent), transparent 70%);
}

.tpc-companion-msg.is-assistant {
  align-self: flex-start;
  background: var(--tpc-surface-strong);
  border: 1px solid var(--tpc-border);
}

.tpc-companion-msg.is-thinking p {
  color: var(--tpc-text-muted);
  font-style: italic;
}

.tpc-companion-form {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.tpc-companion-form textarea {
  flex: 1;
  resize: none;
  min-height: 56px;
}

@media (max-width: 575.98px) {
  .tpc-companion-msg {
    max-width: 95%;
  }
}

/* ------------------------------------------------------------------ */
/* 7b. Goals: guided form, guide panel, nested to-dos, possibilities   */
/* ------------------------------------------------------------------ */

.tpc-goal-step {
  position: relative;
}

.tpc-step-eyebrow {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tpc-accent);
  margin-bottom: 0.35rem;
}

.tpc-goal-form-page .form-text {
  color: var(--tpc-text-muted);
}

/* "How to set goals" collapsible guide */
.tpc-goal-guide {
  border: 1px solid var(--tpc-border);
  border-radius: var(--tpc-radius-lg);
  background: var(--tpc-surface);
}

.tpc-goal-guide summary {
  cursor: pointer;
  padding: 0.85rem 1.1rem;
  font-weight: 500;
  color: var(--tpc-text);
  list-style: none;
}

.tpc-goal-guide summary::-webkit-details-marker {
  display: none;
}

.tpc-goal-guide summary i {
  color: var(--tpc-accent);
  margin-right: 0.4rem;
}

.tpc-goal-guide[open] summary {
  border-bottom: 1px solid var(--tpc-border);
}

.tpc-goal-guide-body {
  padding: 1rem 1.25rem 0.5rem;
}

.tpc-goal-guide-body ol {
  padding-left: 1.1rem;
}

.tpc-goal-guide-body li {
  margin-bottom: 0.7rem;
  line-height: 1.55;
}

/* Goal cards on the listing */
.tpc-goal-card .tpc-goal-actions a {
  color: var(--tpc-text-muted);
  margin-left: 0.5rem;
  font-size: 0.95rem;
}

.tpc-goal-card .tpc-goal-actions a:hover {
  color: var(--tpc-accent);
}

.tpc-goal-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  font-size: 0.82rem;
}

.tpc-goal-want {
  font-size: 0.92rem;
  color: var(--tpc-text-soft);
}

.tpc-goal-antigoal {
  font-size: 0.85rem;
  color: var(--tpc-text-muted);
  font-style: italic;
}

.tpc-goal-antigoal i {
  margin-right: 0.25rem;
}

/* Nested to-dos under each goal */
.tpc-goal-todos {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid color-mix(in oklab, var(--tpc-border), transparent 30%);
}

.tpc-todos-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--tpc-text-muted);
  margin-bottom: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tpc-todos-count {
  background: color-mix(in oklab, var(--tpc-accent), transparent 88%);
  color: var(--tpc-accent);
  border-radius: var(--tpc-radius-pill);
  padding: 0.1rem 0.55rem;
  text-transform: none;
  letter-spacing: 0;
}

.tpc-todo-list {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
}

.tpc-todo {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.3rem 0;
}

.tpc-todo label {
  margin: 0;
  font-weight: 400;
  color: var(--tpc-text);
  cursor: pointer;
  line-height: 1.4;
}

.tpc-todo .form-check-input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.tpc-todo.is-done label {
  text-decoration: line-through;
  color: var(--tpc-text-muted);
}

.tpc-todo-add {
  display: flex;
  gap: 0.5rem;
}

.tpc-todo-add input[type="text"] {
  flex: 1;
}

/* 100 possibilities */
.tpc-poss-section {
  margin-top: 1.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--tpc-border);
}

.tpc-poss-list {
  padding-left: 2rem;
  margin-top: 0.8rem;
}

.tpc-poss-list li {
  margin: 0.9rem 0;
  line-height: 1.55;
}

.tpc-poss-list li::marker {
  color: var(--tpc-text-muted);
  font-size: 0.85rem;
}

.tpc-poss-text {
  color: var(--tpc-text);
}

.tpc-poss-note {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--tpc-text-muted);
}

/* ------------------------------------------------------------------ */
/* 7c. Legal pages (privacy, terms) + footer disclaimer                */
/* ------------------------------------------------------------------ */

.tpc-legal-page h2 {
  margin-top: 1.6rem;
}

.tpc-legal-page ul {
  padding-left: 1.2rem;
}

.tpc-legal-page li {
  margin-bottom: 0.45rem;
  line-height: 1.55;
}

.tpc-footer-disclaimer {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  color: var(--tpc-text-muted);
}

/* ------------------------------------------------------------------ */
/* 8b. Email verification gate                                         */
/* ------------------------------------------------------------------ */

html.tpc-auth-gate body#TPC {
  min-height: 100dvh;
  background:
    linear-gradient(90deg, rgba(239, 240, 236, 0.74) 0%, rgba(239, 240, 236, 0.66) 33%, rgba(0, 91, 83, 0.78) 60%, rgba(0, 91, 83, 0.86) 100%),
    url("/assets/img/interior-13-f.jpg") center / cover no-repeat fixed;
}

html.tpc-auth-gate[data-theme="dark"] body#TPC {
  background:
    linear-gradient(90deg, rgba(22, 24, 24, 0.78) 0%, rgba(22, 24, 24, 0.68) 34%, rgba(0, 71, 67, 0.84) 62%, rgba(0, 71, 67, 0.9) 100%),
    url("/assets/img/interior-13-f.jpg") center / cover no-repeat fixed;
}

body.tpc-auth-gate-body #main-wrapper {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
}

.tpc-verify-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(1.2rem, 5vh, 4.4rem) 1rem;
  padding-left: clamp(1rem, 40vw, calc(100vw - 580px - 1rem));
  overflow-x: hidden;
}

.tpc-verify-card {
  box-sizing: border-box;
  width: min(580px, calc(100vw - 2rem));
  min-height: min(52vh, 480px);
  display: flex;
  flex-direction: column;
  padding: clamp(1.7rem, 3.65vw, 4.3rem);
  border: 1px solid color-mix(in oklab, var(--tpc-border), transparent 20%);
  border-radius: 0.35rem;
  background: var(--tpc-surface-strong);
  color: var(--tpc-text);
  box-shadow: 0 22px 60px rgba(15, 15, 15, 0.16);
}

.tpc-verify-icon {
  color: color-mix(in oklab, var(--tpc-text-muted), transparent 36%);
  font-size: clamp(2.15rem, 3.35vw, 3.2rem);
  line-height: 1;
  margin-bottom: clamp(1.45rem, 2.65vw, 2.6rem);
}

.tpc-verify-card h1 {
  max-width: 12ch;
  margin-bottom: 1.15rem;
  font-size: clamp(1.75rem, 3.35vw, 2.8rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0;
}

.tpc-verify-copy {
  margin: 0 0 clamp(1.55rem, 3vw, 3.05rem);
  color: var(--tpc-text);
  font-size: clamp(1rem, 1.35vw, 1.18rem);
  line-height: 1.5;
}

.tpc-verify-copy strong {
  font-weight: 650;
}

.tpc-verify-form {
  width: 100%;
}

.tpc-code-grid {
  width: 100%;
  max-width: 30.7rem;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(0.48rem, 1.45vw, 1.35rem);
  align-items: center;
}

.tpc-code-box {
  min-width: 0;
  width: 100%;
  height: clamp(2.7rem, 6vw, 4.75rem);
  border: 2px solid #3d927c;
  border-radius: 0.42rem;
  background: var(--tpc-surface-strong);
  color: var(--tpc-text);
  font-size: clamp(1.35rem, 2.7vw, 2.15rem);
  font-weight: 650;
  line-height: 1;
  text-align: center;
  transition: border-color var(--tpc-transition), box-shadow var(--tpc-transition), transform var(--tpc-transition);
}

.tpc-code-box:focus {
  outline: none;
  border-color: #3d927c;
  box-shadow: 0 0 0 0.18rem rgba(62, 166, 255, 0.42);
  transform: translateY(-1px);
}

.tpc-verify-status {
  min-height: 1.2rem;
  margin-top: 0.45rem;
  color: #2d9a66;
  font-size: 0.9rem;
  font-weight: 500;
}

.tpc-verify-status.is-info {
  color: var(--tpc-text-muted);
}

.tpc-verify-status.is-error {
  color: var(--tpc-danger);
}

.tpc-trust-browser {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.75rem;
  color: var(--tpc-text-soft);
  font-size: 0.9rem;
  cursor: pointer;
}

.tpc-trust-browser input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--tpc-accent);
}

.tpc-verify-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.9rem;
  margin-top: 1.85rem;
}

.tpc-verify-actions .btn {
  min-width: 5.35rem;
  padding-inline: 1rem;
  background: transparent;
}

.tpc-verify-divider {
  width: 100%;
  height: 1px;
  margin: auto 0 1.45rem;
  background: color-mix(in oklab, var(--tpc-border), transparent 18%);
}

.tpc-different-account {
  width: fit-content;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

@media (max-width: 767.98px) {
  html.tpc-auth-gate body#TPC {
    background:
      linear-gradient(180deg, rgba(239, 240, 236, 0.72) 0%, rgba(0, 91, 83, 0.8) 100%),
      url("/assets/img/interior-13-f.jpg") center / cover no-repeat fixed;
  }

  .tpc-verify-shell {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 1rem;
  }

  .tpc-verify-card {
    width: min(100%, 320px);
    max-width: calc(100vw - 2rem);
    min-height: auto;
    padding: 1.45rem 0.9rem;
  }

  .tpc-verify-card h1 {
    max-width: 8.8ch;
    font-size: clamp(1.8rem, 8vw, 2.2rem);
  }

  .tpc-code-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.32rem;
  }

  .tpc-code-box {
    height: 3rem;
    border-width: 2px;
    border-radius: 0.42rem;
  }

  .tpc-verify-actions {
    justify-content: stretch;
    gap: 0.7rem;
  }

  .tpc-verify-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 0.55rem;
    font-size: 0.9rem;
  }
}

/* ------------------------------------------------------------------ */
/* 8c. Printable budget listing (html.tpc-print)                       */
/* Always render light so printed budgets are readable: most browsers  */
/* do not print background colors, so dark-theme light text would be   */
/* invisible on paper.                                                 */
/* ------------------------------------------------------------------ */

html.tpc-print,
html.tpc-print[data-theme="dark"] {
  --tpc-bg: #ffffff;
  --tpc-bg-elevated: #ffffff;
  --tpc-surface: #ffffff;
  --tpc-surface-strong: #ffffff;
  --tpc-border: #c9cdd4;
  --tpc-border-strong: #aab0ba;
  --tpc-text: #16181d;
  --tpc-text-soft: #3a3f48;
  --tpc-text-muted: #5d646f;
  --tpc-accent: #1f2937;
  --tpc-accent-strong: #000000;
  --tpc-accent-contrast: #ffffff;
  --tpc-navbar-bg: #ffffff;
  --tpc-focus: rgba(31, 41, 55, 0.25);
}

html.tpc-print body#TPC {
  background: #ffffff;
}

html.tpc-print body#TPC::before {
  content: none;
}

/* ------------------------------------------------------------------ */
/* 8d. Hardship access page                                            */
/* ------------------------------------------------------------------ */

html.tpc-hardship-page,
html.tpc-hardship-page[data-theme="dark"],
html.tpc-hardship-page[data-theme="fun"] {
  --tpc-bg: #ffffff;
  --tpc-bg-elevated: #ffffff;
  --tpc-surface: #ffffff;
  --tpc-surface-strong: #ffffff;
  --tpc-border: #d8dde5;
  --tpc-border-strong: #b8c0cc;
  --tpc-text: #101828;
  --tpc-text-soft: #344054;
  --tpc-text-muted: #4b5565;
  --tpc-accent: #1f2937;
  --tpc-accent-strong: #000000;
  --tpc-accent-contrast: #ffffff;
  --tpc-navbar-bg: #ffffff;
  --tpc-focus: rgba(31, 41, 55, 0.22);
}

html.tpc-hardship-page,
html.tpc-hardship-page body#TPC {
  min-height: 100%;
}

html.tpc-hardship-page body#TPC {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  color: var(--tpc-text);
}

html.tpc-hardship-page body#TPC::before {
  content: none;
}

html.tpc-hardship-page #main-wrapper {
  width: 100%;
  flex: 1 0 auto;
  margin: 0;
}

html.tpc-hardship-page .tpc-hardship-request {
  width: min(880px, calc(100% - 2rem));
  margin: 0 auto;
  color: var(--tpc-text);
}

html.tpc-hardship-page .text-muted {
  color: var(--tpc-text-muted) !important;
}

html.tpc-hardship-page .card-modern {
  background: #ffffff;
  border-color: var(--tpc-border);
}

html.tpc-hardship-page .sparrow-footer {
  background: #ffffff;
  color: var(--tpc-text-soft);
  border-top: 1px solid var(--tpc-border);
}

@media print {
  body#TPC {
    background: #ffffff !important;
    color: #000000 !important;
  }

  body#TPC::before {
    content: none !important;
  }
}

/* ------------------------------------------------------------------ */
/* 8e. Screen-reader-only utility                                      */
/* Bootstrap 5 renamed .sr-only to .visually-hidden, but the codebase  */
/* still uses .sr-only in many views. Restore it.                      */
/* ------------------------------------------------------------------ */

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ------------------------------------------------------------------ */
/* 9. Accessibility: skip links                                        */
/* skip-links.js injects its own styles that hide links with top:-40px,*/
/* which leaks when the link text wraps. Override with a robust hidden */
/* pattern (higher specificity beats the injected <style>).            */
/* ------------------------------------------------------------------ */

a.skip-link {
  top: 0;
  transform: translateY(-150%);
  white-space: nowrap;
}

a.skip-link:focus {
  top: 0;
  transform: none;
}

@media (max-width: 767.98px) {
  .tpc-welcome .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .tpc-welcome .banner-text {
    margin-top: 10vh;
    text-align: left;
  }

  #scenario_period_switcher.tpc-period-switcher {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
