/* The pots board. Sits on top of /style.css, which brings the Pass & Joyce tokens (paper, ink,
   brass), the fonts, the login screens and the shared parts (.primary, .link, .eyebrow, .notice,
   tone colours). This is a desk page first, but it has to work on a phone too. */

.desk { min-height: 100dvh; display: flex; flex-direction: column; }
.desk .bar { flex-wrap: wrap; row-gap: 10px; background: var(--paper-100); }
.bar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.tool {
  height: 40px; padding: 0 14px; border: 1px solid var(--ink-900); border-radius: 0; background: var(--paper-50);
  font: 600 12px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-900); cursor: pointer;
}
.tool:hover { background: var(--paper-300); }
.tool:active { transform: translateY(1px); }

.link.danger { text-decoration-color: var(--oxblood-500); }
.link.danger[data-armed="1"] { color: var(--paper-100); background: var(--oxblood-500); text-decoration: none; padding: 4px 10px; }
.link:disabled { opacity: 0.4; cursor: not-allowed; }

.sheet { width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px var(--edge) 72px; }

/* ---- the Monzo link ---- */

.monzo-strip {
  display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 10px var(--edge);
  background: var(--paper-50); border-bottom: 1px solid var(--paper-400); font-size: 14px; color: var(--ink-700);
}
.monzo-strip .chip { font-size: 10px; }
.monzo-strip p { margin: 0; flex: 1; min-width: 220px; }
.monzo-strip .link { padding: 4px 0; min-height: 32px; font-size: 13px; font-weight: 600; }
.monzo-strip a.tool { display: inline-flex; align-items: center; text-decoration: none; }
.tag.live { border-color: var(--verdigris-500); color: var(--verdigris-500); margin-left: 6px; }

/* ---- headline numbers ---- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; background: var(--paper-50); border: 1px solid var(--paper-400); border-top: 2px solid var(--ink-900); }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--ink-600); }
.kpi-value { font: 600 32px/1.15 var(--font-sans); letter-spacing: -0.01em; color: var(--ink-900); }
.kpi-note { font-size: 13px; color: var(--ink-500); }

/* ---- sections ---- */

.section-head { display: flex; align-items: center; gap: 16px; margin: 40px 0 10px; }
.section-head h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -0.015em; }
.section-rule { flex: 1; height: 1px; background: var(--brass-400); }
.section-lead { margin: 0 0 16px; max-width: 72ch; font-size: 14px; line-height: 1.55; color: var(--ink-500); font-weight: 400; }
.section-lead strong { color: var(--ink-900); }

/* ---- fund and project cards ---- */

.funds { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; align-items: start; }

/* Funds come in sections (yours, the company's, employees', Nich's), each of which can be hidden. */
.fund-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--paper-400); }
.fund-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.fund-section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.fund-section-head h3 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--brass-600); }
.fund-section-head .quiet { font-size: 13px; flex: 1; }
.fund-section-head .link { padding: 2px 0; min-height: 28px; font-size: 13px; font-weight: 600; }
.fund-section.hidden .fund-section-head { margin-bottom: 0; }
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(460px, 100%), 1fr)); gap: 16px; }

.fund, .project {
  display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px 18px 14px;
  background: var(--paper-50); border: 1px solid var(--paper-400); border-top: 2px solid var(--ink-900);
}
.project.closed { opacity: 0.75; }
.fund-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.fund-head h3 { margin: 2px 0 0; font-family: var(--font-display); font-weight: 700; font-size: 21px; line-height: 1.15; letter-spacing: -0.01em; }
.fund-head .eyebrow { font-size: 10px; }
.fund-head .link { padding: 4px 0; min-height: 32px; font-size: 13px; font-weight: 600; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 4px 8px; border: 1px solid currentColor;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap;
}

.pots, .sums { margin: 0; }
.pot-line, .sums > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pot-line { padding: 7px 0; border-bottom: 1px dashed var(--paper-500); }
.pot-line:first-child { border-top: 1px dashed var(--paper-500); }
.pot-line dt { font-size: 14px; font-weight: 600; min-width: 0; }
.pot-line dt small, .field.inline small { margin-left: 8px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-400); font-weight: 500; }
.pot-line dd, .sums dd { margin: 0; font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.pot-line dd small { display: block; font-size: 11px; color: var(--ink-400); }
.pot-line dd small.stale { color: var(--brass-600); font-weight: 700; }
.pot-line dd.missing { color: var(--ink-300); font-style: italic; font-family: var(--font-sans); font-size: 13px; }

.sums > div { padding: 3px 0; }
.sums dt { font-size: 14px; color: var(--ink-600); }
.sums .total { margin-top: 4px; padding-top: 7px; border-top: 1px solid var(--ink-900); }
.sums .total + .total, .sums .total + .sub { margin-top: 0; padding-top: 3px; border-top: 0; }
.sums .total dt, .sums .total dd { font-weight: 700; color: var(--ink-900); }
.sums .total.tone-done dt, .sums .total.tone-done dd { color: var(--status-done); }
.sums .total.tone-failed dt, .sums .total.tone-failed dd { color: var(--status-failed); }
.sums .sub dt { padding-left: 14px; font-size: 13px; color: var(--ink-500); }
.sums .sub dd { font-size: 13px; color: var(--ink-500); }

/* Holds against owed. The track is a pale step of the fill's own colour, so the state reads
   across the whole bar. */
.meter { height: 8px; border-radius: 2px; overflow: hidden; background: color-mix(in srgb, currentColor 16%, var(--paper-50)); }
.meter > span { display: block; height: 100%; background: currentColor; border-radius: 2px; }

.fund-next { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-600); }
.fund-note { margin: auto 0 0; padding-top: 4px; font-size: 12.5px; line-height: 1.45; color: var(--ink-400); font-weight: 400; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 20px;
  border: 1px dashed var(--brass-400); background: var(--paper-100);
}
.empty-card p { margin: 0; max-width: 64ch; font-size: 14px; line-height: 1.55; color: var(--ink-600); font-weight: 400; }

.closed-projects { margin-top: 8px; grid-column: 1 / -1; }
.closed-projects summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-600); padding: 8px 0; }
.closed-projects .project { margin-top: 12px; }

/* ---- tax forecast ---- */

.forecast { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(480px, 100%), 1fr)); gap: 16px; align-items: start; }
.forecast .fund { gap: 14px; }
.forecast h4 { margin: 6px 0 0; font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass-600); }
.forecast-lead { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-700); font-weight: 400; }
.forecast-lead strong { font-size: 22px; font-weight: 700; color: var(--ink-900); white-space: nowrap; }
.forecast-note { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-500); font-weight: 400; }
.forecast-note strong { color: var(--ink-700); }
.forecast .ledger.fits { min-width: 0; }
@media (max-width: 520px) { .forecast .wide-only { display: none; } }
.forecast .ledger td small { max-width: 34ch; }
.split-line { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 6px 0; border-top: 1px dashed var(--paper-500); font-size: 14px; }
.split-line .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.split-line .num small { display: block; font-size: 11.5px; white-space: nowrap; }

/* ---- ledgers: bills, and a project's spending ---- */

/* min-width: a flex child would otherwise grow to the table. position: so the visually hidden
   header text is clipped with the table instead of widening the page. */
.table-wrap { overflow-x: auto; min-width: 0; max-width: 100%; position: relative; }
.ledger { width: 100%; min-width: 560px; border-collapse: collapse; background: var(--paper-50); border: 1px solid var(--paper-400); }
.ledger th {
  padding: 10px 12px; border-bottom: 1px solid var(--ink-900); text-align: left;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-500);
}
.ledger td { padding: 10px 12px; border-bottom: 1px dashed var(--paper-500); font-size: 14px; vertical-align: top; }
.ledger tr:last-child td { border-bottom: 0; }
.ledger td small { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-400); }
.ledger .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger .when { font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
.ledger tr.overdue .when, .ledger tr.overdue .when small { color: var(--status-failed); font-weight: 700; }
.ledger .row-actions { text-align: right; white-space: nowrap; }
.ledger .row-actions .link { padding: 2px 0; min-height: 28px; margin-left: 12px; font-size: 13px; }
.ledger.compact { min-width: 480px; }
.ledger.compact td, .ledger.compact th { padding: 7px 8px; font-size: 13px; }
.tag {
  margin-left: 8px; padding: 1px 6px; border: 1px solid var(--brass-500); color: var(--brass-600); vertical-align: 2px;
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase;
}

/* ---- dialogs ---- */

.sheet-dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--ink-900);
  border-radius: 0; background: var(--paper-50); color: var(--ink-900); box-shadow: var(--shadow-md);
}
.sheet-dialog::backdrop { background: rgba(20, 17, 15, 0.45); }
.dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 22px 22px 18px; }
.dialog-form h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -0.015em; }
.dialog-lead { font-size: 14px; line-height: 1.5; color: var(--ink-500); font-weight: 400; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass-600); }
.field input, .field select {
  width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--ink-900); border-radius: 0; background: #fff;
  font: 500 16px var(--font-sans); color: var(--ink-900);
}
.field input[inputmode="decimal"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

.balance-lines { display: flex; flex-direction: column; gap: 10px; max-height: 50dvh; overflow-y: auto; padding-right: 4px; }
.balance-group { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 6px; }
.balance-group legend { padding: 0 0 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass-600); }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.field.inline > span { font-size: 14px; letter-spacing: 0; text-transform: none; color: var(--ink-900); font-weight: 600; }
.field.inline input { width: min(190px, 50%); flex: none; height: 42px; text-align: right; font-size: 15px; }
.field.inline input::placeholder { color: var(--ink-300); font-size: 12px; }

.choice { display: flex; gap: 0; margin: 0; padding: 0; border: 0; }
.choice label { flex: 1; position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: block; padding: 11px 10px; border: 1px solid var(--ink-900); text-align: center; cursor: pointer;
  font-size: 13px; font-weight: 600; background: var(--paper-50);
}
.choice label + label span { border-left: 0; }
.choice input:checked + span { background: var(--ink-900); color: var(--paper-100); }
.choice input:focus-visible + span { outline: 2px solid var(--brass-400); outline-offset: 2px; }

.tick { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; cursor: pointer; }
.tick input { width: 18px; height: 18px; accent-color: var(--ink-900); }

.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 6px; }
.dialog-actions .primary { width: auto; height: 48px; padding: 0 24px; }

@media (max-width: 640px) {
  .bar-actions { width: 100%; justify-content: flex-start; }
  .kpi-value { font-size: 26px; }
}
