/* Ledgers tab. Uses the board's colours and buttons from styles.css; everything here is scoped to #ledgers. */
#ledgers .stack > * + * { margin-top: 12px; }
#ledgers .card { margin: 0; }
#ledgers h3 { margin: 0; font-size: 1.05rem; }
#ledgers .small { font-size: .82rem; }
#ledgers .due { color: var(--bad); }
#ledgers .pay { color: var(--ok); }
#ledgers .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
#ledgers .lg-label { margin: 0 0 4px; font-size: .9rem; color: var(--muted); }
#ledgers label > input, #ledgers label > select, #ledgers label > textarea { margin-top: 4px; }
#ledgers textarea { min-height: 150px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
#ledgers .lg-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#ledgers p { margin: 0; }
#ledgers a:not(.btn):not(.lg-item):not(.lg-fig) { color: var(--brand); }

#ledgers .lg-msg { border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
#ledgers .lg-msg.err { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
#ledgers .lg-msg.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
#ledgers .lg-msg.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

#ledgers .lg-link { background: none; color: var(--brand); padding: 0; text-decoration: underline; border-radius: 0; }

#ledgers .lg-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
#ledgers .lg-chips::-webkit-scrollbar { display: none; }
#ledgers .lg-chip { flex: none; background: transparent; color: var(--text); border: 1px solid var(--line);
                    border-radius: 999px; padding: 7px 14px; white-space: nowrap; }
#ledgers .lg-chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

#ledgers .lg-search { padding: 14px; font-size: 1.05rem; border-radius: 12px; }
#ledgers .lg-total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
#ledgers .lg-total b { font-size: 1.6rem; }
#ledgers .lg-list { list-style: none; margin: 0; padding: 0; }
#ledgers .lg-list li + li { border-top: 1px solid var(--line); }
#ledgers .lg-item { display: flex; align-items: center; justify-content: space-between; gap: 12px;
                    padding: 12px 2px; text-decoration: none; color: inherit; }
#ledgers .lg-item .name { font-weight: 600; overflow-wrap: anywhere; }
#ledgers .lg-item .amt { text-align: right; font-weight: 700; }

#ledgers .lg-hero { text-align: center; padding: 18px 14px; }
#ledgers .lg-hero .label { font-size: .9rem; color: var(--muted); }
#ledgers .lg-hero .big { font-size: 2.4rem; font-weight: 800; line-height: 1.1; margin: 4px 0; overflow-wrap: anywhere; }
#ledgers .lg-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#ledgers .lg-firm { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
                    padding: 10px 4px; text-align: center; }
#ledgers .lg-firm b { display: block; font-size: .95rem; }
#ledgers .lg-age { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
#ledgers .lg-age div { border-radius: 10px; padding: 8px 4px; background: var(--bg); }
#ledgers .lg-age div.hot { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
#ledgers .lg-age b { display: block; font-size: .88rem; }
#ledgers .lg-age span { font-size: .7rem; opacity: .85; }

#ledgers .lg-stmt { width: 100%; border-collapse: collapse; font-size: .88rem; }
#ledgers .lg-stmt th { text-align: left; font-size: .75rem; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
#ledgers .lg-stmt td { padding: 9px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
#ledgers .lg-stmt .r { text-align: right; }
#ledgers .lg-stmt tr.tap { cursor: pointer; }
#ledgers .lg-stmt tr.void td { text-decoration: line-through; color: var(--muted); }
#ledgers .lg-tag { display: inline-block; font-size: .7rem; font-weight: 700; border-radius: 6px; padding: 1px 6px;
                   background: var(--bg); color: var(--muted); margin-right: 4px; }

#ledgers .lg-shade { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10; display: flex;
                     align-items: flex-end; justify-content: center; }
#ledgers .lg-sheet { background: var(--card); color: var(--text); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
                     border-radius: 14px 14px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
#ledgers .lg-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
@media (min-width: 640px) { #ledgers .lg-shade { align-items: center; } #ledgers .lg-sheet { border-radius: 14px; } }

/* Tally figures */
#ledgers .lg-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#ledgers .lg-fig { display: block; background: var(--bg); border-radius: 10px; padding: 10px 12px; text-decoration: none; color: var(--text); }
#ledgers .lg-fig b { display: block; font-size: clamp(.95rem, 4.6vw, 1.15rem); white-space: nowrap; }
#ledgers .lg-stamp.old { color: var(--warn); }

#ledgers .print-only { display: none; }
@media print {
  :root { --bg: #fff; --card: #fff; --text: #000; --muted: #444; --line: #bbb; --bad: #000; --ok: #000; }
  .top, .tabs, #toast, #ledgers .no-print, #ledgers .fab { display: none !important; }
  #ledgers .print-only { display: block; }
  main { max-width: none; padding: 0; }
  body { font-size: 12px; }
  #ledgers .lg-stmt th, #ledgers .lg-stmt td { padding: 4px; }
  #ledgers .lg-stmt thead { display: table-header-group; }
  #ledgers .lg-stmt tr { break-inside: avoid; }
}

/* Easy to tap on a phone: the back link at the top of a screen, and the small text links. */
#ledgers .stack > a.small:first-child, #ledgers .stack > div:first-child > a.small:first-child {
  display: inline-block; font-size: .95rem; padding: 10px 14px 10px 0; margin: -6px 0 -4px; text-decoration: none; }
#ledgers .lg-more { display: inline-block; padding: 12px 0; }
#ledgers .lg-link { min-height: 44px; }
#ledgers .lg-total > span { flex: none; }
#ledgers .lg-total b { font-size: clamp(1.15rem, 6vw, 1.6rem); text-align: right; }
#ledgers .lg-bill { color: var(--brand); font-weight: 600; white-space: nowrap; }
@media print { #ledgers .lg-bill { color: inherit; font-weight: 400; } }

/* Dues across the firms */
#ledgers .lg-flag { display: inline-block; font-size: .7rem; font-weight: 700; border-radius: 6px; padding: 2px 7px;
                    background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); white-space: nowrap; }
#ledgers .lg-three { grid-template-columns: repeat(3, 1fr); }
#ledgers .lg-three .lg-fig { min-height: 44px; }
#ledgers .lg-three .lg-fig b { font-size: 1.5rem; }
#ledgers .lg-tapline { display: inline-flex; align-items: center; min-height: 44px; }
#ledgers a.lg-more { min-height: 44px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
#ledgers .lg-duesfirms th { white-space: normal; vertical-align: bottom; }
#ledgers .lg-duesfirms td { vertical-align: middle; }
#ledgers .lg-total { flex-wrap: wrap; }
#ledgers .lg-wrapchips .lg-chips { flex-wrap: wrap; overflow: visible; }   /* all three lists stay in sight on a narrow phone */
/* Local name of a party, on its ledger. */
.lg-local label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 2px; }
.lg-local .row { flex-wrap: nowrap; gap: 8px; }
.lg-local input { flex: 1; min-width: 0; min-height: 44px; margin: 0; }
.lg-local button { min-height: 44px; }
p.lg-local { margin: 0; }

/* The Party tab: one card per party for a name typed. */
#ledgers .lg-pc { margin-bottom: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
#ledgers .lg-pc-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
#ledgers .lg-pc-name .small { display: block; font-weight: 500; letter-spacing: 0; }
#ledgers .lg-pc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
#ledgers .lg-pc-top b { font-size: clamp(1.7rem, 9vw, 2.2rem); line-height: 1.05; letter-spacing: -.035em; margin-left: auto; }
#ledgers .lg-pc-firms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#ledgers .lg-pc-firms > span { background: var(--soft, var(--bg)); border-radius: 12px; padding: 7px 9px; min-width: 0; }
#ledgers .lg-pc-firms .small { display: block; }
#ledgers .lg-pc-firms b { display: block; font-size: clamp(.8rem, 3.7vw, .98rem); white-space: nowrap; letter-spacing: -.02em; }
#ledgers .lg-pc-bank { margin: -4px 0 0; }
#ledgers .lg-pc-last { margin: 0; border-top: 1px solid var(--line); }
#ledgers .lg-pc-last > div { display: flex; align-items: center; gap: 10px; min-height: 44px; border-bottom: 1px solid var(--line); }
#ledgers .lg-pc-last dt { flex: none; width: 4.2rem; font-size: .8rem; color: var(--muted); }
#ledgers .lg-pc-last dd { margin: 0; flex: 1; min-width: 0; font-size: .88rem; white-space: normal; padding: 4px 0; }
#ledgers .lg-pc-last dd b { white-space: nowrap; }
#ledgers .lg-pc-bill { display: inline-flex; align-items: center; font-weight: 800; text-decoration: none; }
#ledgers .lg-pc-do { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
#ledgers .lg-pc-do > * { min-height: 46px; padding: 0 6px; display: grid; place-items: center; text-align: center; white-space: nowrap; font-size: clamp(.78rem, 3.6vw, .9rem); letter-spacing: -.01em; }
@media (min-width: 700px) { #ledgers .lg-find { max-width: 620px; margin-inline: auto; } }
#ledgers .lg-jump { margin-bottom: 0; display: grid; gap: 6px; }
#ledgers .lg-jump-screens { display: flex; flex-wrap: wrap; gap: 8px; }
#ledgers .lg-jump-row { width: 100%; background: none; border: 0; border-radius: 0; box-shadow: none; color: var(--text); text-align: left; font: inherit; padding: 10px 0; min-height: 44px; }
#ledgers .lg-jump-row + .lg-jump-row { border-top: 1px solid var(--line); }

/* A long party list folded by amount: one line per range with its count and total, opened by a tap. */
#ledgers .lg-band-side { margin: 14px 0 2px; font-weight: 700; letter-spacing: .02em; }
#ledgers .lg-band:first-child .lg-band-side { margin-top: 0; }
#ledgers .lg-band-head { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; width: 100%; min-height: 52px;
  padding: 0 2px; margin: 0; background: transparent; color: inherit; border: 0; border-top: 1px solid var(--line); border-radius: 0;
  box-shadow: none; text-align: left; font-size: .95rem; font-weight: 600; }
#ledgers .lg-band-head b { font-variant-numeric: tabular-nums; }
#ledgers .lg-band > .lg-list { border-top: 1px solid var(--line); }
