/*
 * KuuniFinance — tools.css
 * Layout for the four-tool workbench. Tokens come from theme.css.
 */

.tools-head {
  padding: 1.75rem 0 1.25rem;
  max-width: 44rem;
}

.tools-head h1 {
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.tools-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

@media (min-width: 60rem) {
  .tools-layout {
    grid-template-columns: 16rem minmax(0, 1fr);
  }
}

/* ------------------------------- rail --------------------------------- */

.toolrail {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

@media (min-width: 60rem) {
  .toolrail {
    flex-direction: column;
    overflow: visible;
    position: sticky;
    top: 1rem;
  }
}

.toolbtn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

@media (min-width: 60rem) {
  .toolbtn {
    flex: 1 1 auto;
  }
}

.toolbtn:hover {
  border-color: var(--ink-faint);
}

.toolbtn[aria-selected="true"] {
  background: var(--accent-wash);
  border-color: var(--accent);
}

.toolbtn-name {
  font-size: 0.88rem;
  font-weight: 650;
  white-space: nowrap;
}

.toolbtn[aria-selected="true"] .toolbtn-name {
  color: var(--accent);
}

/* Live figure per tool, so the rail doubles as a summary. */
.toolbtn-note {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* ------------------------------ panels -------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.panel-head {
  padding: 1.25rem 1.35rem;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--surface-sunk);
}

.panel-head h2 {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin-bottom: 0.35rem;
}

.panel-head p {
  font-size: 0.87rem;
  max-width: 46rem;
  line-height: 1.5;
}

.panel-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 56rem) {
  .panel-body {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  }
}

/* ------------------------------ editor -------------------------------- */

.editor {
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.editor-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 0.6rem;
}

.editor-title:first-child {
  margin-top: 0;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/*
 * A row is a grid so labels can be visually hidden without losing the
 * column alignment that makes a list of figures scannable.
 */
.datarow {
  display: grid;
  gap: 0.4rem;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.datarow:hover {
  border-color: var(--rule);
}

.row-income {
  grid-template-columns: minmax(0, 1fr) 7.5rem 2rem;
}

.row-expense {
  grid-template-columns: minmax(0, 1fr) 7rem 7.5rem 5rem 2rem;
}

.row-account {
  grid-template-columns: minmax(0, 1fr) 9rem 7.5rem 2rem;
}

.row-debt {
  grid-template-columns: minmax(0, 1fr) 7rem 5.5rem 6.5rem 5rem 2rem;
}

.row-goal {
  grid-template-columns: minmax(0, 1fr) 7rem 7rem 6.5rem 5rem 5rem 2rem;
}

/* Below the breakpoint every field stacks and shows its own label. */
@media (max-width: 56rem) {
  .row-income,
  .row-expense,
  .row-account,
  .row-debt,
  .row-goal {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .datarow .cell-name {
    grid-column: 1 / -1;
  }

  /*
   * Float the remove control into the corner rather than letting it claim a
   * full row of its own — with five or ten rows on screen that is a lot of
   * wasted scrolling on a phone.
   */
  .datarow {
    position: relative;
    padding-right: 2.1rem;
  }

  .datarow .cell-remove {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
  }

  .datarow .cell-label {
    display: block;
  }
}

.cell-label {
  display: none;
  font-size: 0.68rem;
  font-weight: 650;
  color: var(--ink-faint);
  margin-bottom: 0.15rem;
}

.btn-add {
  align-self: flex-start;
  font-size: 0.85rem;
  padding: 0.42rem 0.8rem;
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.85rem;
}

/* ------------------------------ result -------------------------------- */

.result {
  padding: 1.35rem;
  background: var(--surface-sunk);
  border-top: 1px solid var(--rule-soft);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

@media (min-width: 56rem) {
  .result {
    border-top: 0;
    border-left: 1px solid var(--rule-soft);
  }
}

.result-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.result-figure .fig-lg {
  margin-bottom: 0.1rem;
}

.result-rows {
  margin: 0;
  display: grid;
  gap: 0.4rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.75rem;
}

.result-rows div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.result-rows dt {
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.result-rows dd {
  margin: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.87rem;
  font-weight: 600;
}

.result-note {
  font-size: 0.81rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.result-note.warning {
  color: var(--risk);
  font-weight: 550;
}

.guideblock {
  border-top: 1px solid var(--rule);
  padding-top: 0.75rem;
  display: grid;
  gap: 0.5rem;
}

.guidelist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.guidelist li {
  display: grid;
  gap: 0.25rem;
}

.guide-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.guide-top b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.payoff-order {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.3rem;
  font-size: 0.84rem;
}

.payoff-order span {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.goal-results {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.goal-results li {
  display: grid;
  gap: 0.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.goal-results li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.goal-result-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}

.goal-result-top b {
  font-size: 0.9rem;
  font-weight: 650;
}

.goal-result-when {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}
