/* ledger-sim viewer: an accountant's columnar pad. Pale green ruled paper,
   green rules between money columns, red ink for negatives and for anything
   out of the ordinary, a double rule under totals. */
:root {
  --paper: #f2f6ea;
  --sheet: #f8faf3;
  --rule: #bcd0b2;
  --rule-strong: #8fae86;
  --ink: #1e2b23;
  --muted: #5d6d61;
  --binding: #2d5b3c;
  --binding-ink: #eef4e8;
  --red: #a8261d;
  --focus: #1f6fb2;
  --book: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --text: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--text);
}

body {
  margin: 0;
}

.book {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  min-height: 100vh;
}

/* ---- the spine: one tab per ledger ---- */
.spine {
  background: var(--binding);
  color: var(--binding-ink);
  padding: 1.25rem 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.product {
  margin: 0 1.25rem;
  font: 600 1.05rem/1.2 var(--book);
  letter-spacing: 0.01em;
}

.spine ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.spine a {
  display: grid;
  padding: 0.55rem 1.25rem;
  color: inherit;
  text-decoration: none;
  border-left: 4px solid transparent;
}

.spine a:hover {
  background: rgb(255 255 255 / 0.07);
}

.spine a[aria-current='page'] {
  background: var(--sheet);
  color: var(--ink);
  border-left-color: var(--red);
}

.tab-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tab-count {
  font-size: 0.8rem;
  opacity: 0.75;
}

button {
  font: inherit;
  border: 1px solid var(--binding);
  background: var(--binding);
  color: var(--binding-ink);
  border-radius: 3px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
}

button.quiet {
  margin: auto 1.25rem 0;
  background: transparent;
  border-color: rgb(255 255 255 / 0.4);
  color: inherit;
  align-self: flex-start;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---- the page ---- */
main {
  padding: 1.75rem 2rem 3rem;
  min-width: 0;
}

main:focus {
  outline: none;
}

.ledger-head h1 {
  margin: 0;
  font: 400 2.25rem/1.1 var(--book);
  letter-spacing: -0.005em;
}

.ledger-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

/* index tabs, cut into the top of the sheet */
.index-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 1.5rem;
  border-bottom: 2px solid var(--rule-strong);
}

.index-tabs a {
  padding: 0.45rem 0.9rem 0.4rem;
  color: var(--binding);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  margin-bottom: -2px;
}

.index-tabs a:hover {
  background: var(--sheet);
}

.index-tabs a[aria-current='page'] {
  background: var(--sheet);
  color: var(--ink);
  font-weight: 600;
  border-color: var(--rule-strong);
  border-bottom: 2px solid var(--sheet);
}

.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule-strong);
  border-top: none;
  padding: 1.25rem 1.25rem 1.75rem;
  overflow-x: auto;
}

.tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.tools label {
  font-weight: 600;
}

.tools input {
  font: inherit;
  color: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  background: #fff;
  min-width: 16rem;
}

.tools input[type='date'] {
  min-width: 0;
}

.count,
.note {
  color: var(--muted);
}

.note {
  margin: -0.4rem 0 1rem;
  max-width: 70ch;
}

/* ---- the columnar pad ---- */
table.pad {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.pad th,
.pad td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.pad thead th {
  font-weight: 600;
  color: var(--binding);
  border-bottom: 2px solid var(--rule-strong);
  white-space: nowrap;
}

/* money columns: ruled off on both sides, as on a columnar pad */
.pad .num {
  text-align: right;
  white-space: nowrap;
  width: 7.5rem;
  border-left: 1px solid var(--rule-strong);
}

.pad .num:last-child {
  border-right: 1px solid var(--rule-strong);
}

.neg {
  color: var(--red);
}

/* totals: a single rule above, a double rule below */
.pad tfoot th,
.pad tfoot td {
  font-weight: 700;
  border-bottom: none;
  border-top: 1px solid var(--ink);
}

.pad tfoot td.total {
  border-bottom: 3px double var(--ink);
}

.date,
.ext {
  white-space: nowrap;
}

.memo {
  max-width: 34rem;
}

tr.entry.open td {
  border-bottom-color: transparent;
  font-weight: 600;
}

tr.line td {
  color: var(--muted);
  font-size: 0.93rem;
}

tr.line td.num {
  color: var(--ink);
}

/* credit lines are indented, as they are written in a journal */
tr.line td.credit-side {
  padding-left: 2.2rem;
}

.disclose {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--binding);
  line-height: 1;
}

.disclose::before {
  content: '+';
  font-weight: 700;
}

.disclose[aria-expanded='true']::before {
  content: '−';
}

.mark {
  color: var(--red);
  font-weight: 600;
}

.empty {
  color: var(--muted);
  max-width: 60ch;
}

.segments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1.5rem 2rem;
}

.segment h2 {
  margin: 0 0 0.5rem;
  font: 400 1.35rem/1.2 var(--book);
}

.segment + .segment {
  margin-top: 1.5rem;
}

.segments .segment + .segment {
  margin-top: 0;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1.5rem;
  margin: 0;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

/* ---- token form, notices ---- */
.token,
.notice {
  max-width: 30rem;
}

.token h1,
.notice h1 {
  font: 400 1.9rem/1.2 var(--book);
  margin: 0 0 0.5rem;
}

.token label {
  display: block;
  font-weight: 600;
  margin: 1rem 0 0.3rem;
}

.token input {
  font: inherit;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  margin-bottom: 0.9rem;
}

.loading {
  color: var(--muted);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

@media (max-width: 760px) {
  .book {
    grid-template-columns: 1fr;
  }

  .spine {
    padding: 0.75rem 0;
  }

  .spine ul {
    display: flex;
    overflow-x: auto;
  }

  .spine a {
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }

  .spine a[aria-current='page'] {
    border-bottom-color: var(--red);
  }

  button.quiet {
    margin: 0 1.25rem;
  }

  main {
    padding: 1.25rem 0.75rem 2rem;
  }

  .ledger-head h1 {
    font-size: 1.75rem;
  }

  .tools input {
    min-width: 0;
    flex: 1;
  }
}
