/* LEDGER — layout & app-specific pieces (tokens only) */
.app-root.ledger {
  position: relative; min-height: 100%; padding: 18px 24px 16px;
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-template-rows: auto 1fr 1fr;
  gap: var(--gap);
  --lg-line: var(--accent); --lg-area: .22; --lg-zone: color-mix(in oklab, var(--text) 4%, transparent); --lg-low: var(--warn);
}
.ledger .lg-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; min-height: 46px; }
.ledger .lg-safe { grid-column: span 3; }
.ledger .lg-bud { grid-column: span 5; }
.ledger .lg-subs { grid-column: span 4; }
.ledger .lg-cash { grid-column: span 5; }
.ledger .lg-goal { grid-column: span 3; }
.ledger .lg-bills { grid-column: span 4; }
.ledger .card { overflow: hidden; }
.ledger .card-h { margin-bottom: 10px; }
.layer[data-skin="brutal"] .app-root.ledger { --lg-line: var(--ink); --lg-low: var(--accent-2); }
.layer[data-skin="swiss"] .app-root.ledger { --lg-area: .08; --lg-low: var(--accent); --lg-zone: color-mix(in oklab, var(--text) 5%, transparent); }
.layer[data-skin="noir"] .app-root.ledger { --lg-area: .14; --lg-low: var(--accent-3); }

/* header */
.lg-logo { display: flex; align-items: center; gap: 10px; }
.lg-logo-i { width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--accent); color: var(--on-accent); }
.layer[data-skin="brutal"] .lg-logo-i { border: 2.5px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.layer[data-skin="swiss"] .lg-logo-i { border-radius: 0; color: var(--on-accent); }
.lg-logo b { font-size: 24px; }
.lg-greet { display: flex; flex-direction: column; line-height: 1.25; padding-left: 16px; margin-left: 6px; border-left: max(1px, var(--border-w)) solid var(--line); }
.lg-greet b { font-size: 14px; } .lg-greet span { font-size: 12px; }
.lg-month { display: flex; align-items: center; gap: 10px; padding-right: 14px; border-right: max(1px, var(--border-w)) solid var(--line); }
.lg-month > div { display: flex; flex-direction: column; align-items: center; line-height: 1.2; min-width: 104px; }
.lg-month b { font-size: 14px; }
.lg-month .ibtn { width: 28px; height: 28px; }
.lg-month .ibtn .ic { width: 14px; height: 14px; }
.lg-acct .ic { width: 14px; height: 14px; }
.lg-acct { font-variant-numeric: tabular-nums; }

/* 1 · safe to spend */
.lg-big { display: flex; align-items: flex-end; min-height: 52px; margin: 2px 0 10px; }
.lg-safe-n .unit { font-size: 14px; }
.lg-math { display: flex; flex-direction: column; font-size: 12px; font-variant-numeric: tabular-nums; border-top: max(1px, var(--border-w)) solid var(--line); padding-top: 6px; }
.lg-m { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 1.5px 0; }
.lg-m span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-m b { font-weight: 600; white-space: nowrap; }
.lg-m.minus b { color: var(--text-2); font-weight: 500; }
.lg-m.tot { margin-top: 3px; padding-top: 5px; border-top: 1px solid var(--line-2); }
.lg-m.tot span, .lg-m.div span { color: var(--text); }
.lg-m.div b { color: var(--accent-ink); font-size: 13px; }
.lg-note { margin-top: auto; padding-top: 6px; font-size: 11.5px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer[data-skin="swiss"] .lg-m.tot { border-top: 2px solid var(--text); }
.layer[data-skin="swiss"] .lg-m.div b { color: var(--accent); }
.layer[data-skin="noir"] .lg-math { font-size: 11.5px; }
.layer[data-skin="noir"] .lg-m.tot { border-top: 1px solid var(--accent); }
.layer[data-skin="brutal"] .lg-math { border-top: 2.5px solid var(--ink); }
.layer[data-skin="brutal"] .lg-m.tot { border-top: 2.5px solid var(--ink); }
.layer[data-skin="brutal"] .lg-m.div b { color: var(--text); background: var(--accent); padding: 0 6px; border: 2px solid var(--ink); border-radius: 5px; }
.layer[data-skin="brutal"][data-mode="light"] .lg-safe.tinted .lg-m span, .layer[data-skin="brutal"][data-mode="light"] .lg-safe.tinted .lg-m.minus b { color: #111; }
.layer[data-skin="dots"] .lg-math { font-family: var(--font-mono); font-size: 11px; }

/* 2 · budget */
.lg-bud-grid { flex: 1; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; min-height: 0; }
.lg-b-rows { display: flex; flex-direction: column; min-width: 0; }
.lg-b-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 70px; align-items: center; gap: 8px; padding: 4px 6px; margin: 0 -6px; border-radius: var(--radius-sm); text-align: left; transition: background .2s; font-size: 12px; }
.lg-b-row:hover { background: var(--surface-2); }
.lg-b-row.on { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.lg-b-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.lg-b-row.on .lg-b-name { font-weight: 700; }
.lg-b-bar { position: relative; display: block; }
.lg-b-bar .bar-h { height: 6px; }
.lg-pace { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); opacity: .55; border-radius: 1px; }
.lg-b-amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 11.5px; }
.lg-b-amt b { font-weight: 600; }
.lg-b-key { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 6px; font-size: 10.5px; color: var(--text-3); }
.lg-b-key i { width: 2px; height: 10px; background: var(--text); opacity: .55; }
.lg-tx { display: flex; flex-direction: column; min-width: 0; padding-left: 14px; border-left: max(1px, var(--border-w)) solid var(--line); }
.lg-tx-h { font-size: 12.5px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-tx-l { display: flex; flex-direction: column; }
.lg-tx-r { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 6px; align-items: baseline; padding: 4px 0; border-top: 1px solid var(--line); font-size: 11.5px; }
.lg-tx-r:first-child { border-top: 0; }
.lg-tx-d { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); white-space: nowrap; }
.lg-tx-n { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.lg-tx-n b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-tx-n small { font-size: 10.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-tx-a { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.lg-tx-empty { font-size: 12px; padding: 8px 0; }
.lg-tx-f { margin-top: auto; padding-top: 6px; font-size: 11.5px; }
.layer[data-skin="swiss"] .lg-b-row, .layer[data-skin="noir"] .lg-b-row { border-radius: 0; }
.layer[data-skin="swiss"] .lg-b-row.on { background: transparent; box-shadow: inset 3px 0 0 var(--accent); }
.layer[data-skin="swiss"] .lg-b-bar .bar-h > i { border-radius: 0; }
.layer[data-skin="brutal"] .lg-b-bar .bar-h { height: 11px; border-width: 2px; }
.layer[data-skin="brutal"] .lg-b-row.on { background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink); color: #111; }
.layer[data-skin="brutal"] .lg-b-row.on .faint { color: color-mix(in oklab, #111 78%, transparent); }
.layer[data-skin="brutal"] .lg-pace { background: var(--ink); opacity: 1; width: 3px; top: -4px; bottom: -4px; }
.layer[data-skin="brutal"] .lg-tx { border-left: 2.5px dashed color-mix(in oklab, var(--ink) 35%, transparent); }
.layer[data-skin="noir"] .lg-b-row.on { background: transparent; box-shadow: inset 1px 0 0 var(--accent); }
.layer[data-skin="noir"] .lg-pace { background: var(--accent); opacity: .9; width: 1px; }
.layer[data-skin="dots"] .lg-b-bar .bar-h { background: radial-gradient(circle, var(--line-2) 1.4px, transparent 1.7px) 0 50% / 6px 6px; height: 6px; border-radius: 0; }
.layer[data-skin="dots"] .lg-b-bar .bar-h > i { background: radial-gradient(circle, var(--accent) 2px, transparent 2.4px) 0 50% / 6px 6px !important; border-radius: 0; }
.layer[data-skin="dots"] .lg-b-row.over .bar-h > i { background: radial-gradient(circle, var(--bad) 2px, transparent 2.4px) 0 50% / 6px 6px !important; }
.layer[data-skin="dots"] .lg-b-row.fixed .bar-h > i { background: radial-gradient(circle, var(--text-3) 2px, transparent 2.4px) 0 50% / 6px 6px !important; }
.layer[data-skin="glass"] .lg-b-row.over .bar-h > i { box-shadow: 0 0 12px var(--bad); }
.layer[data-skin="nordic"] .lg-b-row.on { box-shadow: none; background: var(--accent-soft); }

/* 3 · subscriptions */
.lg-s-rows { display: flex; flex-direction: column; }
.lg-s-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 46px auto; align-items: center; gap: 8px; padding: 1px 0; min-height: 25px; border-top: 1px solid var(--line); font-size: 12px; }
.lg-s-row:first-child { border-top: 0; }
.lg-s-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-s-hint { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-s-hint.warn { color: var(--warn); font-weight: 600; }
.lg-s-price { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 11.5px; }
.lg-s-row.off .lg-s-name, .lg-s-row.off .lg-s-price { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
.lg-s-row.off .lg-s-hint { color: var(--good); }
.lg-s-row .tgl { transform: scale(.8); transform-origin: right center; margin: -2px 0; }
.lg-cut { margin-top: auto; padding-top: 6px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; border-top: max(1px, var(--border-w)) solid var(--line-2); }
.lg-cut > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lg-cut-l { font-size: 11px; line-height: 1.3; }
.lg-subs-tot { white-space: nowrap; }
.layer[data-skin="brutal"] .lg-s-row { border-top: 2px dashed color-mix(in oklab, var(--ink) 30%, transparent); }
.layer[data-skin="brutal"] .lg-s-hint.warn { color: var(--text); background: var(--warn); padding: 0 5px; border-radius: 4px; justify-self: start; max-width: 100%; }
.layer[data-skin="brutal"] .lg-cut { border-top: 2.5px solid var(--ink); }
.layer[data-skin="swiss"] .lg-cut { border-top: 2px solid var(--text); }
.layer[data-skin="noir"] .lg-s-name { font-family: var(--font-display); font-weight: 400; font-size: 15px; }

/* 4 · cash flow */
.lg-cash-sum { display: grid; grid-template-columns: auto auto 1fr; gap: 18px; align-items: end; margin: -6px 0 6px; }
.lg-cash-sum > div { display: flex; flex-direction: column; gap: 1px; }
.lg-cash-sum b { font-size: 17px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.lg-cash-sum small { font-size: 11px; }
.lg-cash-note { margin: 0; font-size: 11.5px; line-height: 1.35; align-self: end; }
.lg-plot { min-height: 120px; }
.lg-svg { position: absolute; inset: 0; }
.lg-svg > svg { position: absolute; inset: 0; overflow: visible; }
.lg-plot text.lg-t-strong { fill: var(--text); font-weight: 600; }
.lg-plot text.lg-t-acc { fill: var(--accent-ink); font-weight: 600; }
.lg-plot text.lg-t-low { fill: var(--text); font-weight: 600; }
.layer[data-skin="brutal"] .lg-plot text.lg-t-acc { fill: var(--accent-ink); }
.layer[data-skin="swiss"] .lg-plot text.lg-t-acc { fill: var(--accent); }

/* 5 · goal */
.lg-g-top { display: flex; align-items: center; gap: 14px; }
.lg-ring-c { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lg-ring-c .lbl { font-size: 9.5px; }
.lg-g-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; line-height: 1.25; }
.lg-arr { font-size: 19px; font-variant-numeric: tabular-nums; font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-track); }
.lg-arr-s { font-size: 12px; font-weight: 600; }
.lg-arr-t { font-size: 11px; }
.lg-g-sld { margin-top: 12px; }
.lg-g-sh { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: -2px; }
.lg-mo { font-variant-numeric: tabular-nums; }
.lg-g-ru { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; }
.lg-g-ru .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer[data-skin="brutal"] .lg-g-ru { border-top: 2px dashed color-mix(in oklab, var(--ink) 35%, transparent); }

/* 6 · bills */
.lg-bills-l { display: flex; flex-direction: column; }
.lg-bill { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 1px 6px; margin: 0 -6px; min-height: 20px; text-align: left; border-radius: var(--radius-sm); font-size: 12px; transition: background .2s; }
button.lg-bill:hover, .lg-bill.on { background: var(--surface-2); }
.lg-bill-d { display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.lg-bill-d small { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; color: var(--text-3); letter-spacing: .04em; width: 18px; }
.lg-bill-d b { font-size: 12.5px; font-weight: 700; }
.lg-bill-n { display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
.lg-bill-n b { font-weight: 600; }
.lg-bill-n small { font-size: 10.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.lg-bill-a { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; font-size: 11.5px; }
.lg-bill.off .lg-bill-n b, .lg-bill.off .lg-bill-a { text-decoration: line-through; color: var(--text-3); }
.lg-bill.save .lg-bill-n b { color: var(--accent-ink); }
.lg-bill.pay { margin-top: 3px; border-top: max(1px, var(--border-w)) solid var(--line-2); border-radius: 0; padding-top: 4px; }
.lg-bill.pay .lg-bill-a { color: var(--good); }
.layer[data-skin="swiss"] .lg-bill { border-radius: 0; }
.layer[data-skin="swiss"] .lg-bill.on { background: transparent; box-shadow: inset 3px 0 0 var(--accent); }
.layer[data-skin="swiss"] .lg-bill.pay { border-top: 2px solid var(--text); }
.layer[data-skin="brutal"] .lg-bill.on { background: var(--accent); color: #111; box-shadow: inset 0 0 0 2px var(--ink); }
.layer[data-skin="brutal"] .lg-bill.pay { border-top: 2.5px solid var(--ink); }
.layer[data-skin="brutal"] .lg-bill.save .lg-bill-n b { color: var(--text); }
.layer[data-skin="noir"] .lg-bill.pay { border-top-color: var(--accent); }
.layer[data-skin="noir"] .lg-bill-d b { font-family: var(--font-display); font-weight: 400; font-size: 15px; }

/* ---------- tablet ---------- */
@container screen (max-width: 960px) {
  .app-root.ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; padding: 22px; grid-auto-flow: row dense; }
  .ledger .lg-safe, .ledger .lg-goal, .ledger .lg-subs, .ledger .lg-bills { grid-column: span 1; }
  .ledger .lg-bud, .ledger .lg-cash { grid-column: 1 / -1; }
  .ledger .lg-cash { min-height: 320px; }
  .lg-greet, .lg-acct { display: none; }
}
/* ---------- phone ---------- */
@container screen (max-width: 560px) {
  .app-root.ledger { grid-template-columns: minmax(0, 1fr); padding: 58px 14px 30px; gap: 12px; }
  .ledger > * { grid-column: 1 / -1 !important; }
  .lg-month { display: none; }
  .lg-safe-n { font-size: 72px !important; }
  .lg-bud-grid { grid-template-columns: minmax(0, 1fr); }
  .lg-tx { padding-left: 0; border-left: 0; padding-top: 10px; border-top: max(1px, var(--border-w)) solid var(--line); }
  .ledger .lg-cash { min-height: 300px; }
  .lg-cash-sum { grid-template-columns: auto auto; }
  .lg-cash-note { grid-column: 1 / -1; }
}

/* ---------- watch ---------- */
.app-root.ledger-w { position: absolute; inset: 0; padding: 16px 16px 14px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.lgw-top { align-self: stretch; display: flex; align-items: center; justify-content: space-between; font-size: 11px; }
.lgw-app { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--accent-ink); }
.lgw-app .ic { width: 13px; height: 13px; }
.lgw-ring { margin: 4px 0 2px; }
.lgw-c { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.lgw-sub { font-size: 9.5px; }
.lgw-u { font-size: 10.5px; color: var(--text-2); }
.lgw-l1 { font-size: 13px; }
.lgw-l2 { font-size: 10px; }

/* ---------- widgets ---------- */
.ledger-wd { position: absolute; inset: 0; padding: 14px; display: flex; gap: 14px; }
.lgwd-l { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.lgwd-medium .lgwd-l { flex: 0 0 44%; }
.lgwd-h { display: flex; align-items: center; gap: 6px; }
.lgwd-h .lbl { font-size: 10.5px; white-space: nowrap; }
.lgwd-ic { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); flex: none; }
.layer[data-skin="swiss"] .lgwd-ic { border-radius: 0; color: var(--on-accent); }
.layer[data-skin="brutal"] .lgwd-ic { border: 2px solid var(--ink); }
.lgwd-ic .ic { width: 12px; height: 12px; }
.lgwd-num { display: flex; align-items: baseline; gap: 5px; margin-top: 8px; }
.lgwd-num { flex-wrap: wrap; row-gap: 0; }
.lgwd-num small { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.lgwd-s { font-size: 11px; margin-top: auto; }
.lgwd-cyc { flex: none; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.lgwd-cyc i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.layer[data-skin="swiss"] .lgwd-cyc, .layer[data-skin="noir"] .lgwd-cyc { border-radius: 0; height: 3px; }
.layer[data-skin="brutal"] .lgwd-cyc { height: 10px; border: 2px solid var(--ink); background: var(--surface); }
.layer[data-skin="brutal"] .lgwd-cyc i { background: var(--accent-2); border-radius: 0; border-right: 2px solid var(--ink); }
.layer[data-skin="dots"] .lgwd-cyc { background: radial-gradient(circle, var(--line-2) 1.4px, transparent 1.7px) 0 50% / 6px 6px; border-radius: 0; height: 6px; }
.layer[data-skin="dots"] .lgwd-cyc i { background: radial-gradient(circle, var(--accent) 2px, transparent 2.4px) 0 50% / 6px 6px; }
.lgwd-r { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-left: 14px; border-left: max(1px, var(--border-w)) solid var(--line); }
.lgwd-r .lbl { font-size: 10px; }
.lgwd-cat { font-size: 16px; font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-track); }
.lgwd-amt { font-size: 12px; font-variant-numeric: tabular-nums; }
.lgwd-r .bar-h { margin-top: 2px; }
.lgwd-n { font-size: 10.5px; margin-top: auto; line-height: 1.3; }
