/* Books (general ledger). Register, chart of accounts, trial balance. */

.books {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.books .page-header {
  margin-bottom: 0;
}

.books .segmented {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
}

.books-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}

.books-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex: 1 1 100%;
  min-width: 0;
}

.books-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 11rem;
  min-width: 0;
}

.books-field-label {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* One line saying what to type, under the box (rd Y3): the Location, Lease and
   Source boxes are free text and nothing on screen said so. */
.books-field-hint {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.3;
}

.books-field input,
.books-field select {
  width: 100%;
  min-width: 0;
  min-height: var(--tap-min);
}

.books-filters [hidden],
.books-toolbar > [hidden] {
  display: none !important;
}

.books-search-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 2 1 24rem;
  min-width: 0;
}

.books-search-field > .books-field {
  flex: 0 0 auto;
}

.books-search-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.books-search-summary {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.books-search-table .num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.books-search-table .books-search-month,
.books-search-table .books-search-date {
  color: var(--muted);
  white-space: nowrap;
}

.books-search-direction {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.books-search-table .books-search-accounts {
  overflow-wrap: anywhere;
}

.books-search-hit {
  cursor: pointer;
}

.books-search-hit:hover,
.books-search-hit:focus-visible {
  background: var(--warn-bg);
}

.books-search-headline {
  display: block;
  font-weight: var(--weight-semibold);
}

.books-search-subline {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
}

.books-band {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-3) var(--space-4);
}

.books-band p {
  margin: 0 0 var(--space-1);
}

.books-band p:last-child {
  margin-bottom: 0;
}

.books-band-state {
  font-weight: var(--weight-semibold);
}

.books-band--closed {
  background: var(--ok-bg);
  border-color: transparent;
}

.books-band--closed .books-band-state {
  color: var(--ok);
}

.books-band--stale {
  background: var(--warn-bg);
  border-color: transparent;
  color: var(--warn-text);
}

.books-refresh-copy {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.books-journal {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.books-entry {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.books-entry-main {
  display: grid;
  grid-template-columns: 6.75rem minmax(0, 1fr) auto auto;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  width: 100%;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: var(--tap-min);
}

.books-entry-what {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.books-headline {
  font-weight: var(--weight-semibold);
}

.books-subline,
.books-date,
.books-cash-account,
.books-figure-label {
  color: var(--muted);
  font-size: var(--text-sm);
}

.books-cash {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.books-cash--in {
  color: var(--ok);
}

.books-cash--out {
  color: var(--ink);
}

.books-account-figures {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
}

.books-figure {
  display: flex;
  flex-direction: column;
  min-width: 6rem;
  font-variant-numeric: tabular-nums;
}

.books-humanised {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.books-export-status {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.books-postings .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.books-posting-totals {
  font-weight: var(--weight-semibold);
}

.books-entry .disclosure {
  margin: 0 var(--space-3) var(--space-3);
}

.books-journal-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.books-group-title {
  margin: var(--space-4) 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-regular);
}

.books-account-link {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--info);
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: var(--tap-min);
}

.books-row-highlight {
  background: var(--warn-bg);
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

.books-trial-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
  font-weight: var(--weight-semibold);
}

.books-trial-status--ok {
  color: var(--ok);
}

.books-trial-status--bad {
  color: var(--crit);
}

.books-check {
  display: inline-flex;
  color: var(--ok);
}

.books-unpublished {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.books-empty-title {
  margin-top: 0;
  font-weight: var(--weight-semibold);
}

.books-check-host [data-action="check-now"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.books-drawer-body h3 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-md);
}

.books .drawer {
  width: min(440px, 100%);
}

.books .num,
.books-cash,
.books-figure {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  .books-field,
  .books-search-field {
    flex-basis: 100%;
  }

  .books-entry-main {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "date source"
      "what what"
      "cash cash"
      "figures figures";
  }

  .books-date { grid-area: date; }
  .books-source { grid-area: source; justify-self: end; }
  .books-entry-what { grid-area: what; }
  .books-cash {
    grid-area: cash;
    align-items: flex-start;
  }
  .books-account-figures { grid-area: figures; }

  .books .drawer {
    width: 100%;
  }
}

/* --- Months rows (rd Y3) ---------------------------------------------------
   The Months page has no stylesheet of its own and `.list-row` lives in
   styles.css (another lane's file), so the one layout rule the row chevron
   needs sits here, beside the other list-row surfaces this lane owns.
   Absolute positioning takes the chevron out of `.list-row`'s column flow, so
   the row keeps its height and the chevron sits at the trailing edge. */
[data-role="month-row"] {
  position: relative;
  padding-right: calc(var(--space-3) + 1.5rem);
}

.month-chevron {
  position: absolute;
  top: 50%;
  right: var(--space-3);
  display: inline-flex;
  color: var(--muted);
  transform: translateY(-50%) rotate(-90deg);
  transition: transform var(--motion-fast) var(--ease-out);
  pointer-events: none;
}

.month-chevron[data-open="true"] {
  transform: translateY(-50%) rotate(0deg);
}
