/* Agely cost ledger. Builds on ../styles.css for tokens, type and the top bar. */

.costs {
  padding-bottom: 64px;
}

.costs-intro {
  max-width: 70ch;
  padding: 24px 0 32px;
}

.costs-intro h1 {
  font-size: clamp(2.25rem, 5vw, 3.25rem);
}

.costs-intro p,
.lead-in {
  color: var(--text-muted);
  max-width: 70ch;
}

.costs-intro p {
  font-size: 1.125rem;
}

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

.total {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
}

.total p {
  margin: 0;
}

.total-label,
.total-note {
  color: var(--text-muted);
}

.total-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.25rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.block {
  margin-top: 56px;
}

.kinds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px 32px;
  margin: 20px 0 0;
}

.kinds dd {
  margin: 6px 0 0;
  color: var(--text-muted);
}

/* The kind of a line is carried by its label and border style, not by colour alone. */
.kind {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  border: 2px solid var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.kind--paid {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.kind--estimate {
  border-style: dashed;
}

.kind--free {
  border-color: var(--border);
  color: var(--text-muted);
}

.kind--missing {
  border-style: dotted;
  border-color: var(--color-accent-strong);
  color: var(--color-accent-strong);
}

.table-scroll {
  overflow-x: auto;
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
}

.ledger {
  width: 100%;
  border-collapse: collapse;
}

.ledger th,
.ledger td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.ledger tbody tr:last-child > *,
.ledger tfoot tr > * {
  border-bottom: 0;
}

.ledger tfoot tr > * {
  border-top: 2px solid var(--text);
}

.ledger thead th {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.ledger td p {
  margin: 4px 0 0;
  max-width: 60ch;
  color: var(--text-muted);
}

.ledger .amount,
#ledger thead th:last-child {
  text-align: right;
}

.amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#ledger .amount {
  font-weight: 600;
}

#ai-table thead th:not(:first-child) {
  text-align: right;
}

.category {
  display: block;
  color: var(--text-muted);
  font-weight: 400;
}

.nowrap {
  white-space: nowrap;
}

.sources {
  max-width: 70ch;
  padding-left: 1.2em;
}

.sources li + li {
  margin-top: 12px;
}

@media (max-width: 700px) {
  .ledger th,
  .ledger td {
    padding: 12px;
  }

  /* On a phone each ledger line becomes a block: what it was, then its kind and amount. */
  #ledger thead,
  #ledger tbody td:first-child {
    display: none;
  }

  #ledger tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
  }

  #ledger tbody tr:last-child {
    border-bottom: 0;
  }

  #ledger tbody td {
    padding: 0;
    border: 0;
  }

  #ledger tbody td:nth-child(2) {
    grid-column: 1 / -1;
  }
}
