/* books.css · P32, Folio: the layout of a laptop's books, the proof and the
   pieces of a ledger the design system has no component for (the lines of
   an entry being written, an amount that opens the lines behind it). The
   buttons, fields, selects, badges, banners, tables, stats and sheets are
   the design system's; this file places them. Every value is a token. */

/* ── a laptop: the navigation on the left, the page on the right ── */
.fo { container: fo / inline-size; flex: 1; display: flex; min-width: 0; min-height: 0; background: var(--paper); }
.fo-nav { display: flex; flex-direction: column; gap: 1px; flex: none; width: 216px; padding: 8px; background: var(--ground); border-right: var(--px) solid var(--line-2); overflow: auto; box-sizing: border-box; }
.fo-head { display: flex; align-items: center; gap: 8px; min-height: var(--h-32); margin-bottom: 8px; padding: 0 6px; color: var(--ink); }
.fo-mark { display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--h-20); height: var(--h-20); border-radius: var(--r-key); background: var(--brand, var(--ink)); color: var(--on-solid); }
.fo-mark > svg { width: var(--icon-12); height: var(--icon-12); }
.fo-co { display: flex; flex-direction: column; min-width: 0; }
.fo-co > b { font-weight: var(--fw-550); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fo-co > span { color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); }
.fo-section { margin: 14px 0 2px; padding: 0 8px; color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); font-weight: var(--fw-500); }
.fo-item {
  display: flex; align-items: center; gap: 8px; height: var(--row-28, var(--h-28)); padding: 0 8px; border: 0; border-radius: var(--r-row);
  background: transparent; color: var(--ink-2); font: inherit; font-weight: var(--fw-500); text-align: left; white-space: nowrap;
  transition: background-color var(--state-out), color var(--state-out);
}
.fo-item > svg { flex: none; color: var(--ink-3); }
.fo-item > .fo-count { margin-left: auto; color: var(--ink-3); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.fo-item[aria-current="page"] { background: var(--ground-selected); color: var(--ink); }
.fo-item[aria-current="page"] > svg { color: var(--brand); }
.fo-item:focus-visible { outline: none; box-shadow: var(--ring-inline); }
@media (hover: hover) { .fo-item:hover { background: var(--ground-hover); color: var(--ink); transition-duration: 0s; } .fo-item[aria-current="page"]:hover { background: var(--ground-selected-hover); } }

.fo-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.fo-main > [data-r="page-header"] { flex: none; }
.fo-main > [data-r="banner"] { margin: 8px 16px 0; flex: none; }
.fo-main > [data-r="scroll-area"] { flex: 1; }
.fo-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.fo-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 20px 64px; max-width: 1180px; box-sizing: border-box; }
.fo-view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.fo-notices { display: flex; flex-direction: column; gap: 8px; }
.fo-notices[hidden] { display: none; }

/* a row of controls above a table, and the small text beside them */
.fo-bar { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.fo-bar > .fo-grow { flex: 1; }
.fo-note { margin: 0; color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); }
.fo-note-ink { color: var(--ink-2); }
.fo-error { margin: 0; color: var(--danger-ink); font-size: var(--fs-12); line-height: var(--lh-12); }
.fo-error[hidden] { display: none; }
.fo-h { margin: 8px 0 0; color: var(--ink); font-size: var(--fs-13); line-height: var(--lh-13); font-weight: var(--fw-550); }
.fo-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.fo-num { font-variant-numeric: tabular-nums; }
.fo [data-part="table"], .fo-sheet [data-part="table"], .fo-proof [data-part="table"] { overflow-x: auto; }
.fo td > .fo-sub, .fo-sheet td > .fo-sub { display: block; color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); font-weight: var(--fw-450); }
.fo-reasons { margin: 4px 0 0; padding-left: 16px; color: var(--ink-2); font-size: var(--fs-12); line-height: var(--lh-12); font-weight: var(--fw-450); }
.fo-reasons > li + li { margin-top: 2px; }
.fo-cell-acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* an amount or a text that opens what is behind it: a link in the ink of the accent */
.fo-link {
  display: inline; padding: 0; border: 0; border-radius: var(--r-key); background: transparent; color: var(--accent-ink);
  font: inherit; font-weight: inherit; text-align: inherit; text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px;
}
.fo-link:focus-visible { outline: none; box-shadow: var(--ring-inline); }
@media (hover: hover) { .fo-link:hover { text-decoration-color: currentColor; } }
/* a total row: the figures in the heavier weight; the first column keeps the table's own */
.fo-total > td:not(:first-child) { font-weight: var(--fw-550); }

/* ── the sheet: an entry, a form, the lines behind a figure ── */
.fo-sheet { width: min(760px, 100vw); }
.fo-sheet > [data-part="body"] { display: flex; flex-direction: column; gap: 14px; }
.fo-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fo-form > .fo-wide { grid-column: 1 / -1; }
.fo-lines { display: flex; flex-direction: column; gap: 6px; }
.fo-line { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr) var(--h-28); gap: 6px; align-items: center; }
.fo-line [data-r="select"] { width: 100%; min-width: 0; }
.fo-line-head { color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); font-weight: var(--fw-500); }
.fo-line-auto { color: var(--ink-2); font-size: var(--fs-12); line-height: var(--lh-12); }
.fo-line-auto > span:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.fo-totals { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; padding: 8px 10px; border-radius: var(--r-value); background: var(--well); font-variant-numeric: tabular-nums; }
.fo-totals > span > b { margin-left: 4px; }
.fo-sheet-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fo-props { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
.fo-cands { display: flex; flex-direction: column; gap: 10px; }
.fo-cand { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: var(--r-contain); background: var(--raised); box-shadow: 0 0 0 var(--px) var(--line-2); }
.fo-cand-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fo-cand-head > b { color: var(--ink); }

@container fo (max-width: 860px) {
  .fo { flex-direction: column; }
  .fo-nav { flex-direction: row; align-items: center; width: auto; padding: 6px 8px; border-right: 0; border-bottom: var(--px) solid var(--line-2); overflow-x: auto; scrollbar-width: none; }
  .fo-head, .fo-section { display: none; }
  .fo-item { flex: none; }
  .fo-item > .fo-count { display: none; }
  .fo-body { padding: 12px 12px 48px; }
  .fo-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 759px) {
  .fo-sheet { width: 100vw; }
  .fo-form { grid-template-columns: minmax(0, 1fr); }
  .fo-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .fo-line > :first-child { grid-column: 1 / -1; }
  .fo-line-head { display: none; }
  .fo-props { grid-template-columns: minmax(0, 1fr); }
}

/* ── the proof ── */
.fo-proof { flex: 1; min-height: 0; overflow: auto; background: var(--paper); }
.fo-proof-wrap { display: flex; flex-direction: column; gap: 16px; max-width: 1120px; margin: 0 auto; padding: 32px 32px 80px; box-sizing: border-box; }
.fo-proof-head { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.fo-proof-head > h1 { font-size: var(--fs-16); line-height: var(--lh-16); color: var(--ink); }
.fo-proof-head > p { color: var(--ink-2); text-wrap: pretty; }
.fo-proof-run { display: flex; align-items: flex-end; gap: 8px 12px; flex-wrap: wrap; }
.fo-proof-run [data-r="form-row"] { width: 120px; }
.fo-proof-cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.fo-proof-log { margin: 0; padding: 12px 14px 12px 32px; max-height: 420px; overflow: auto; border-radius: var(--r-contain); background: var(--raised); box-shadow: 0 0 0 var(--px) var(--line-2); color: var(--ink-2); font-size: var(--fs-12); line-height: var(--lh-12); font-variant-numeric: tabular-nums; }
.fo-proof-log > li + li { margin-top: 3px; }
.fo-bar-meter { height: 4px; border-radius: var(--r-press); background: var(--well); overflow: hidden; }
.fo-bar-meter > i { display: block; height: 100%; width: 0; background: var(--brand); }
@media (max-width: 899px) { .fo-proof-cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 759px) { .fo-proof-wrap { padding: 20px 16px 48px; } .fo-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
