:root{
  --pine:#123c3a; --pine-2:#1d5c57; --brass:#8a6414; --paper:#f4f6f3; --card:#fff; --line:#d5ddd9; --ink:#17302d;
  --pos:#176b3f; --neg:#a53422;
  --bs-primary:#1d5c57; --bs-primary-rgb:29,92,87; --bs-link-color:#1d5c57; --bs-link-hover-color:#123c3a;
  --bs-body-bg:var(--paper); --bs-body-color:var(--ink);
}
[data-bs-theme=dark]{
  --paper:#0f1816; --card:#162321; --line:#2c3d39; --ink:#e3ece8; --pos:#5fcf94; --neg:#ff9c86; --brass:#e0b45a;
  --bs-primary:#4fa89f; --bs-primary-rgb:79,168,159; --bs-link-color:#7cc7bf; --bs-link-hover-color:#a6ddd7;
  --bs-body-bg:var(--paper); --bs-body-color:var(--ink);
}
body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;font-variant-numeric:tabular-nums}
.btn-primary{--bs-btn-bg:#1d5c57;--bs-btn-border-color:#1d5c57;--bs-btn-hover-bg:#123c3a;--bs-btn-hover-border-color:#123c3a;--bs-btn-active-bg:#123c3a;--bs-btn-disabled-bg:#1d5c57;--bs-btn-disabled-border-color:#1d5c57}
[data-bs-theme=dark] .btn-primary{--bs-btn-bg:#2f7f77;--bs-btn-border-color:#2f7f77;--bs-btn-hover-bg:#3b948b;--bs-btn-hover-border-color:#3b948b;--bs-btn-color:#fff}
.pos{color:var(--pos)} .neg{color:var(--neg)}
.skip-link{position:absolute;left:.5rem;top:.5rem;z-index:2000;background:#fff;color:#000;padding:.4rem .8rem;border-radius:.3rem}

/* shell */
.app-shell{display:flex;min-height:100vh}
.sidebar{background-color:#123c3a!important}
.sidebar{--bs-offcanvas-width:16rem;background:var(--pine)!important;color:#dce8e4;width:16rem;flex:0 0 16rem}
.sidebar.offcanvas-lg{--bs-offcanvas-bg:var(--pine);--bs-offcanvas-color:#dce8e4}
@media (min-width:992px){.sidebar{position:sticky;top:0;height:100vh;overflow-y:auto}}
.sidebar-head{display:flex;align-items:center;justify-content:space-between;padding:1.1rem 1rem .8rem}
.brand{display:flex;align-items:center;gap:.65rem;color:#fff;text-decoration:none;font:600 1.05rem/1.2 Georgia,"Times New Roman",serif}
.brand-mark{display:inline-grid;place-items:center;width:2rem;height:2rem;border:1.5px solid #d9b25c;color:#d9b25c;border-radius:.3rem;font:700 1.1rem Georgia,serif}
.sidebar-nav{padding:.4rem .6rem 1.5rem}
.nav-link-x{display:flex;align-items:center;gap:.7rem;width:100%;padding:.6rem .75rem;border:0;background:none;color:#cfe0db;text-decoration:none;border-radius:.4rem;font:inherit;text-align:left;margin-bottom:2px}
.nav-link-x:hover{background:rgba(255,255,255,.08);color:#fff}
.nav-link-x.active{background:#f4f6f3;color:var(--pine);font-weight:600}
.nav-link-x:focus-visible,.btn:focus-visible,a:focus-visible,.form-control:focus,.form-select:focus{outline:3px solid #d9b25c;outline-offset:1px}
.content-col{flex:1 1 auto;min-width:0;display:flex;flex-direction:column}
.topbar{display:flex;align-items:center;gap:.75rem;padding:.8rem 1.25rem;border-bottom:1px solid var(--line);background:var(--card);position:sticky;top:0;z-index:30}
.page-title{font:600 1.35rem Georgia,"Times New Roman",serif;margin:0;flex:1 1 auto}
.topbar-actions{display:flex;align-items:center;gap:.5rem}
.user-chip{max-width:11rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration:none;font-weight:600;padding:.25rem .6rem;border:1px solid var(--line);border-radius:2rem;color:var(--ink)}
@media (max-width:575px){.user-chip{display:none}}
.dot{position:absolute;top:2px;right:2px;width:.55rem;height:.55rem;background:#d9902f;border-radius:50%}
.page{padding:1.25rem;flex:1 1 auto;width:100%;max-width:82rem}
.app-footer{padding:1rem 1.25rem;color:#5b6d68;font-size:.85rem;border-top:1px solid var(--line)}
[data-bs-theme=dark] .app-footer{color:#8fa39d}

/* panels */
.panel{background:var(--card);border:1px solid var(--line);border-radius:.5rem;padding:1.1rem 1.25rem;height:auto}
/* equal-height boxes only when they sit side by side in a grid column */
.row>[class*="col"]>.panel{height:100%}
.panel.narrow{max-width:46rem;height:auto}
.panel h2{font:600 1.1rem Georgia,"Times New Roman",serif;margin:0 0 .8rem}
.table{--bs-table-bg:transparent}
.list-group-item.unread{border-left:4px solid #d9902f}
.ver{font:600 2.2rem Georgia,serif;line-height:1.1}

/* the ledger strip: net cash flow, ruled like a statement */
.ledger{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);gap:1.5rem;background:var(--card);border:1px solid var(--line);border-top:4px solid var(--brass);border-radius:.5rem;padding:1.4rem 1.5rem}
.ledger-label{font-weight:600;color:#52645f}
[data-bs-theme=dark] .ledger-label{color:#9db1ab}
.ledger-figure{font:600 clamp(1.9rem,5vw,2.9rem)/1.15 Georgia,"Times New Roman",serif;margin:.25rem 0}
.ledger-note{font-size:.95rem}
.ledger-lines{margin:0;display:grid;align-content:center}
.ledger-lines>div{display:flex;justify-content:space-between;gap:1rem;padding:.55rem 0;border-bottom:1px solid var(--line)}
.ledger-lines dt{font-weight:500}.ledger-lines dd{margin:0;font-weight:600}
.ledger-lines .total{border-bottom:0;border-top:3px double var(--ink);margin-top:.2rem}
@media (max-width:767px){.ledger{grid-template-columns:1fr}}
.acct-list li{display:flex;justify-content:space-between;gap:1rem;padding:.6rem 0;border-bottom:1px solid var(--line)}
.acct-list li:last-child{border-bottom:0}

/* empty states */
.empty{text-align:center;padding:2.5rem 1rem;color:#52645f}
[data-bs-theme=dark] .empty{color:#9db1ab}
.empty i{font-size:2rem;color:var(--brass)}
.empty h2,.empty h3{font:600 1.1rem Georgia,serif;margin:.5rem 0 .25rem;color:var(--ink)}
.empty p{margin:0 auto;max-width:28rem}
.empty.compact{padding:1.25rem .5rem}

/* sign-in */
.auth-body{background:var(--pine);min-height:100vh;display:grid;place-items:center}
.auth-wrap{width:100%;max-width:26rem;padding:1.25rem}
.auth-brand{display:flex;align-items:center;gap:.7rem;color:#fff;font:600 1.3rem Georgia,serif;margin-bottom:1rem}
.auth-card{background:var(--card);color:var(--ink);border-radius:.5rem;padding:1.6rem}
.auth-title{font:600 1.3rem Georgia,serif;margin:0 0 1rem}
.auth-foot{color:#a9c1bb;font-size:.8rem;text-align:center;margin:1rem 0 0}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
@media print{.sidebar,.topbar,.app-footer,.btn{display:none!important}.page{padding:0}}

/* Phase 2 additions */
.sub{padding:0 0 .3rem 1.9rem;margin:0}
.sub .nav-link-x{padding:.4rem .75rem;font-size:.95rem}
.panel.h-auto{height:auto}
.narrow-form{max-width:32rem}
.form-control,.form-select{background-color:var(--card)}

/* Phase 3 additions */
.stat{background:var(--card);border:1px solid var(--line);border-radius:.5rem;padding:.9rem 1.1rem;height:100%}
.stat .k{font-size:.85rem;color:#52645f;font-weight:600}[data-bs-theme=dark] .stat .k{color:#9db1ab}
.stat .v{font:600 1.45rem/1.2 Georgia,serif;margin-top:.2rem}
.progress{height:.6rem;background:var(--line)}
.progress-bar{background:var(--pine-2)}[data-bs-theme=dark] .progress-bar{background:#4fa89f}
.cal{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px}
.cal .d{min-height:5.2rem;border:1px solid var(--line);border-radius:.3rem;padding:.25rem .35rem;font-size:.8rem;background:var(--card)}
.cal .d.off{opacity:.45}.cal .h{font-weight:600;text-align:center;font-size:.8rem}
.cal .chip{display:block;margin-top:2px;padding:1px 4px;border-radius:3px;border:1px solid var(--line);text-decoration:none;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media (max-width:575px){.cal .d{min-height:3.6rem;font-size:.7rem}}

/* Phase 4 additions */
.chart-box{position:relative;height:16rem}
@media print{.no-print,.sidebar,.topbar,.app-footer,form.panel{display:none!important}.panel{border:0}}

/* 1.0.6 additions */
.book-btn{display:inline-flex;align-items:center;gap:.4rem;max-width:12rem}
.book-btn .book-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:8rem}
@media (max-width:575px){.book-btn .book-name{display:none}}
.dropdown-menu .dropdown-item.active{background:var(--bs-primary);color:#fff}
.dropdown-menu form{margin:0}
.book-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.35rem 1rem;align-items:center;padding:.8rem 0;border-bottom:1px solid var(--line)}
.book-row:last-child{border-bottom:0}
.book-name-form{display:flex;gap:.4rem;max-width:26rem}
.book-meta{grid-column:1}
.book-actions{grid-column:2;grid-row:1 / span 2;display:flex;flex-wrap:wrap;gap:.4rem;justify-content:flex-end}
.book-actions form{margin:0}
@media (max-width:575px){.book-row{grid-template-columns:1fr}.book-actions{grid-column:1;grid-row:auto;justify-content:flex-start}}

/* Categories: rows wrap instead of overflowing, so nothing is cut off or hidden */
.cat-row{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .75rem;padding:.65rem 0;border-bottom:1px solid var(--line)}
.cat-row:last-child{border-bottom:0}
.cat-row.is-off .cat-name .form-control{opacity:.7}
.cat-name{display:flex;gap:.4rem;flex:1 1 16rem;min-width:0}
.cat-name .form-control{min-width:0}
.cat-info{flex:0 0 auto;min-width:5.5rem}
.cat-actions{display:flex;flex-wrap:wrap;gap:.4rem;flex:1 1 auto;justify-content:flex-end;align-items:center}
.cat-actions form{margin:0}
.cat-delete{display:flex;gap:.4rem;align-items:center;flex-wrap:wrap}
.cat-delete .form-select{width:auto;max-width:12rem}
@media (max-width:575px){.cat-actions{justify-content:flex-start;flex-basis:100%}}
