/* Quarterly ledger: a two-page accounting book over the centre and right columns */

.ledger {
  grid-column: 2 / 4;
  grid-row: 1;
  min-height: 0;
}
.ledger[hidden] { display: none; }

#pad.is-ledger #folder,
#pad.is-ledger #side { display: none; }

.ledger__book {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 10px;
  background: #1d3a2b;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.4), 0 12px 24px rgba(0, 0, 0, 0.55);
}

.ledger__page {
  position: relative;
  min-height: 0;
  padding: 14px 18px 12px 26px;
  overflow-y: auto;
  color: var(--text);
  background-color: #f1e9cf;
  background-image:
    var(--paper-grain),
    linear-gradient(90deg, transparent 18px, rgba(160, 50, 40, 0.5) 18px 19px, transparent 19px);
}
.ledger__page--left { border-radius: 4px 0 0 4px; box-shadow: inset -14px 0 18px -10px rgba(60, 40, 10, 0.5); }
.ledger__page--right { border-radius: 0 4px 4px 0; box-shadow: inset 14px 0 18px -10px rgba(60, 40, 10, 0.5); }

.ledger__page h2 { margin: 0; font-family: var(--font-head); font-weight: 400; font-size: 21px; letter-spacing: 0.03em; }
.ledger__page h3 {
  margin: 10px 0 4px;
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(43, 36, 24, 0.5);
}
.ledger__sub { margin: 2px 0 6px; font-size: 11px; line-height: 1.3; opacity: 0.8; }

/* Rows sit on the green ruled lines of the book (28px pitch) */
.ledger__rows {
  background: repeating-linear-gradient(transparent 0 27px, rgba(50, 120, 80, 0.38) 27px 28px);
}

.lrow {
  display: grid;
  grid-template-columns: 124px minmax(60px, 1fr) 54px 18px;
  align-items: center;
  gap: 8px;
  height: 28px;
}
.lrow--tax { grid-template-columns: 112px minmax(50px, 1fr) 54px 74px; }

.lrow__name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lrow__ctl { position: relative; display: block; height: 20px; }
.lrow__ctl input { position: absolute; inset: 0; width: 100%; margin: 0; }
.lrow__tick {
  position: absolute;
  top: 1px;
  width: 2px;
  height: 18px;
  background: var(--ink-red);
  opacity: 0.7;
  pointer-events: none;
}
.lrow__val { white-space: nowrap; font-family: var(--font-num); font-weight: 700; font-size: 13px; text-align: right; color: var(--ink); }
.lrow.is-changed .lrow__val { color: var(--ink-red); }
.lrow__q { text-align: center; font-size: 11px; cursor: help; }
.lrow__q.up { color: var(--ink-green); }
.lrow__q.down { color: var(--ink-red); }
.lrow__q.flat { opacity: 0.5; }
.lrow__yield { font-size: 11px; text-align: right; opacity: 0.8; }

.ledger__total {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  border-top: 2px solid var(--ink);
  padding-top: 3px;
}
.ledger__total b { font-family: var(--font-num); }

.sum { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; margin: 0; font-size: 13px; }
.sum dd { margin: 0; text-align: right; font-family: var(--font-num); font-weight: 700; }
.sum small { display: block; font-weight: 400; font-size: 11px; }
.sum dt:nth-of-type(4), .sum dd:nth-of-type(4) { border-top: 1px solid var(--ink); }
.sum__balance { font-weight: 700; }
.sum__balance.good { color: var(--ink-green); }
.sum__balance.bad { color: var(--ink-red); }

.proj { width: 100%; border-collapse: collapse; font-size: 12px; }
.proj th { font-weight: 400; text-align: left; padding: 1px 0; }
.proj thead th { text-align: right; font-size: 11px; opacity: 0.8; }
.proj td { white-space: nowrap; text-align: right; font-family: var(--font-num); padding: 1px 0 1px 6px; }
.proj tbody tr:nth-child(odd) { background: rgba(50, 120, 80, 0.08); }

.ledger__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.ledger__actions .brass { white-space: nowrap; padding: 5px 12px; font-size: 13px; }
.ledger__actions .brass--wide { margin-top: 0; }
.ledger__error { color: var(--ink-red); margin: 6px 0 0; font-size: 12px; }
.ledger__error[hidden] { display: none; }

/* Range sliders: an ink rule with a brass knob */
.ledger input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.ledger input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--ink); border-radius: 2px; }
.ledger input[type="range"]::-moz-range-track { height: 4px; background: var(--ink); border-radius: 2px; }
.ledger input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  border: 1px solid #6e5316;
  background: radial-gradient(circle at 35% 30%, #f1d98c, #b98e32);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.ledger input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #6e5316;
  background: radial-gradient(circle at 35% 30%, #f1d98c, #b98e32);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.ledger input[type="range"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.ledger__emergency {
  margin: 0 0 6px;
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.3;
  color: #8a1c14;
  border: 1.5px solid #8a1c14;
  border-radius: 2px;
  transform: rotate(-0.6deg);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
