/* 02-accounts-reports.css — Chart of Accounts tree and detail panel, ledger / group reports, report tables and summary cards.
   Loaded after the files with a smaller number (later rules win). */

/* ---------- Chart of Accounts ---------- */
.page-head h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; }
.crumbs { font-size: .82rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--blue); }

.core-card { display: block; padding: 1rem 1.1rem; border-radius: 16px; background: #fff; border: 1px solid var(--border); text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .2s ease, border-color .2s; height: 100%; }
.core-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--text); }
.core-card.on { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft), var(--shadow); }
.core-card .ci { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 1.05rem; }
.core-card .ct { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }

.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.seg a { border: 0; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 600; padding: .35rem .8rem; border-radius: 6px; text-decoration: none; white-space: nowrap; }
.seg a.on { background: #fff; color: var(--blue); box-shadow: var(--shadow); }
.seg-scroll { overflow-x: auto; max-width: 100%; }
.coa-search { width: 260px; max-width: 100%; }
.coa-search .form-control { border-radius: 999px; background: var(--bg); border: 0; padding-top: .5rem; padding-bottom: .5rem; }
.coa-search > i { top: 50%; }

.coa-table td, .coa-table th { padding-left: 1.25rem; padding-right: 1.25rem; }
.coa-table tr.is-group td { background: #fafbfc; }
.coa-table tr.depth-0 td { background: #f5f8ff; }
.coa-table tr.depth-0 .acc-name { font-weight: 800; }
.acc-name { display: flex; align-items: center; gap: .6rem; }
.acc-name .ai { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: .95rem; flex-shrink: 0; }
.tree-line { display: inline-block; width: 14px; height: 14px; border-left: 2px solid var(--border-strong); border-bottom: 2px solid var(--border-strong); border-bottom-left-radius: 6px; margin-top: -8px; flex-shrink: 0; }
.row-actions { display: flex; gap: .25rem; justify-content: flex-end; opacity: .55; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }
.act { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); text-decoration: none; }
.act:hover { background: var(--hover); color: var(--blue); }
.act.danger:hover { background: var(--red-soft); color: var(--red); }
.neg { color: var(--red); }
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; }

.alert-danger { background: var(--red-soft); border-color: #f7c3cc; color: #a3122b; }

/* form */
.type-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem; }
.type-pick label { cursor: pointer; border: 1.5px solid var(--border); border-radius: 12px; padding: .75rem .5rem; text-align: center; font-weight: 600; font-size: .85rem; transition: all .15s; background: #fff; }
.type-pick label i { display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto .35rem; border-radius: 10px; font-size: 1rem; }
.type-pick input { position: absolute; opacity: 0; pointer-events: none; }
.type-pick input:checked + label { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.type-pick input:focus-visible + label { box-shadow: 0 0 0 3px var(--blue-soft); }
.type-pick.locked { opacity: .55; pointer-events: none; }
.input-group-text { background: var(--hover); border-color: #dddfe2; border-radius: 8px; color: var(--muted); font-weight: 600; }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; }
.preview-acc { border-radius: 18px; padding: 1.25rem; background: var(--grad); color: #fff; position: relative; overflow: hidden; }
.preview-acc::after { content: ""; position: absolute; width: 200px; height: 200px; border-radius: 50%; right: -70px; top: -90px; background: rgba(255,255,255,.12); }
.preview-acc > * { position: relative; z-index: 1; }
.sticky-side { position: sticky; top: 90px; }
.modal-content { border: 0; border-radius: 18px; box-shadow: var(--shadow-lg); }

/* Dr / Cr */
.drcr { display: inline-flex; padding: 3px; gap: 2px; background: var(--hover); border: 1px solid #dddfe2; border-left: 0; border-radius: 0 8px 8px 0; }
.drcr input { position: absolute; opacity: 0; pointer-events: none; }
.drcr label { padding: 0 .8rem; display: grid; place-items: center; border-radius: 6px; font-weight: 700; font-size: .85rem; color: var(--muted); cursor: pointer; }
.drcr input:checked + label { background: #fff; color: var(--blue); box-shadow: var(--shadow); }
.drcr input:focus-visible + label { box-shadow: 0 0 0 2px var(--blue-soft); }
.input-group > .form-control:has(+ .drcr) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.side-tag { font-size: .68rem; font-weight: 700; color: var(--subtle); margin-left: .25rem; }
.coa-table tfoot td { background: #f5f8ff; border-top: 2px solid var(--border-strong); font-weight: 800; padding-top: .9rem; padding-bottom: .9rem; }

/* ==========================================================
   Report table (from erp2all table-report.html)
   ========================================================== */
:root {
    --report-text: #2E3A4E;
    --report-bg: #FFFFFF;
    --report-border: #CDDAEA;
    --report-row-border: #E8EEF4;
    --report-row-hover: #F5F8FB;
    --report-border-head: #9AB4CC;
    --report-text-muted: #5a6a80;
    --report-bg-head: #F0F4F8;
    --report-subtotal-bg: #E8F5F0;
    --report-subtotal-border: #7EC8B0;
    --report-subtotal-text: #0F6E56;
    --report-total-bg: #E8EDF8;
    --report-total-border: #9AB4CC;
    --report-total-text: #126782;
    --report-warning-bg: #FEF6E8;
    --report-warning-border: #E8C070;
}

.table-report {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Roboto Condensed', var(--font);
    font-size: 13px;
    color: var(--report-text);
    background: var(--report-bg);
    font-variant-numeric: tabular-nums;
}
.table-report th,
.table-report td { padding: 5px 10px; border-top: 1px solid var(--report-row-border); white-space: nowrap; }

.table-report thead th {
    font-weight: 600;
    font-size: 11.5px;
    color: var(--report-text-muted);
    background: var(--report-bg-head);
    border-right: 1px solid var(--report-border);
    border-top: 1px solid var(--report-border);
    border-bottom: 1px solid var(--report-border-head);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.table-report thead th:last-child { border-right: none; }
.table-report a { text-decoration: none; color: var(--report-text); }
.table-report tbody tr:hover td { background: var(--report-row-hover); }

.table-report .row-subtotal td {
    background: var(--report-subtotal-bg);
    color: var(--report-subtotal-text);
    font-weight: 600;
    font-size: 11.5px;
    letter-spacing: 0.05em;
    border-top: 1px solid var(--report-subtotal-border);
    border-bottom: 1px solid var(--report-subtotal-border);
}
.table-report .row-total td {
    background: var(--report-total-bg);
    color: var(--report-total-text);
    font-weight: 700;
    font-size: 11.5px;
    letter-spacing: 0.05em;
    border-top: 1px solid var(--report-total-border);
    border-bottom: 1px solid var(--report-total-border);
}
.table-report .row-warning td {
    font-size: 11.5px;
    letter-spacing: 0.05em;
    background: var(--report-warning-bg);
    border-top: 1px solid var(--report-warning-border);
    border-bottom: 1px solid var(--report-warning-border);
}
.table-report .row-group td { font-weight: 600; }

/* Chart of Accounts tree inside the report table */
.table-report .num { text-align: right; width: 130px; }
.table-report .rt-name { display: flex; align-items: center; gap: 6px; }
.table-report .rt-name i { color: var(--report-text-muted); font-size: 13px; }
.table-report .row-subtotal .rt-name i { color: var(--report-subtotal-text); }
.table-report .rt-code { color: var(--report-text-muted); }
.table-report .rt-meta { color: var(--report-text-muted); font-size: 11px; margin-left: 4px; }
.table-report .rt-actions { width: 96px; text-align: right; }
.table-report .rt-actions .act { width: 26px; height: 26px; border-radius: 6px; display: inline-grid; font-size: 13px; }
.table-report tbody tr .rt-actions .act { opacity: 0; }
.table-report tbody tr:hover .rt-actions .act,
.table-report tbody tr .rt-actions .act:focus-visible { opacity: 1; }
@media (hover: none) { .table-report tbody tr .rt-actions .act { opacity: 1; } }
.table-report .dash { color: #b7c3d1; }
.report-card { overflow: hidden; }

/* ==========================================================
   Chart of Accounts: toolbar, collapsible tree, search highlight
   ========================================================== */
.d-contents { display: contents; }

.coa-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; padding: 1rem 1.25rem .85rem; }
.coa-sub { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; padding: 0 1.25rem .9rem; border-bottom: 1px solid var(--border); }

/* Action buttons: pill with a tinted icon badge */
.coa-actions { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.tb-group { display: flex; flex-wrap: wrap; gap: .55rem; }
.tb-btn { --c: var(--blue); --cb: var(--blue-soft); display: inline-flex; align-items: center; gap: .6rem; padding: .38rem 1.05rem .38rem .4rem; background: #fff; border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow); color: var(--text); font-size: .88rem; font-weight: 600; white-space: nowrap; transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease; }
.tb-btn .ti { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 1rem; background: var(--cb); color: var(--c); transition: background .2s, color .2s; }
.tb-btn:hover { transform: translateY(-2px); border-color: var(--c); box-shadow: 0 10px 22px -10px var(--c); color: var(--text); }
.tb-btn:hover .ti { background: var(--c); color: #fff; }
.tb-btn:active { transform: translateY(0); }
.tb-btn:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.tb-btn:disabled { opacity: .6; pointer-events: none; }
.tb-btn .spin, .spin { display: inline-block; animation: coaSpin .8s linear infinite; }
@keyframes coaSpin { to { transform: rotate(360deg); } }
.c-blue   { --c: #1877f2; --cb: #e7f3ff; }
.c-violet { --c: #7b3cff; --cb: #f1eaff; }
.c-teal   { --c: #0aa5a5; --cb: #e1f5f5; }
.c-amber  { --c: #d98a00; --cb: #fef5de; }
.c-green  { --c: #1f9d55; --cb: #e6f4e2; }
@media (max-width: 575px) {
    .tb-btn { padding: .38rem; }
    .tb-btn .lbl { display: none; }
}

/* Search */
.coa-search { width: 300px; max-width: 100%; }
.coa-search .form-control { padding-right: 2.4rem; }
.coa-search input[type=search]::-webkit-search-cancel-button { display: none; }
.coa-clear { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border: 0; border-radius: 50%; background: #dfe2e7; color: var(--muted); display: grid; place-items: center; font-size: .6rem; padding: 0; }
.coa-clear:hover { background: #cfd3d9; color: var(--text); }
.coa-clear[hidden] { display: none; }

/* Highlight */
mark.hl { background: #fff3a3; color: inherit; padding: 0 1px; border-radius: 3px; box-shadow: 0 0 0 1px #f2dc6b; }

/* Tree */
.tgl { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px; background: transparent; display: inline-grid; place-items: center; color: var(--report-text-muted); flex-shrink: 0; }
.tgl:hover { background: rgba(0, 0, 0, .07); color: var(--blue); }
.tgl i { font-size: 11px; transition: transform .15s ease; }
.tgl[aria-expanded="true"] i { transform: rotate(90deg); }
.tgl-gap { display: inline-block; width: 20px; flex-shrink: 0; }
.searching .tgl { visibility: hidden; }
.table-report .rt-code { margin-right: 4px; color: var(--report-text-muted); }
.table-report .row-subtotal .rt-code { color: var(--report-subtotal-text); opacity: .75; }
.rt-count { font-size: 10.5px; font-weight: 600; line-height: 1; padding: 2px 6px; border-radius: 99px; background: rgba(0, 0, 0, .06); color: var(--report-text-muted); }
.table-report .empty-row { text-align: center; padding: 2rem 1rem; color: var(--report-text-muted); font-size: 14px; }
.table-report .empty-row i { display: block; font-size: 1.6rem; margin-bottom: .35rem; }
.table-report tbody tr[hidden] { display: none; }

/* Row that was just added or edited */
.table-report tr.row-flash td { animation: rowFlash 2.6s ease-out; }
@keyframes rowFlash { 0%, 40% { background-color: #fff3a3; } }

/* ==========================================================
   Chart of Accounts v3: split view (tree + detail panel)
   ========================================================== */
.coa-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (min-width: 1200px) { .coa-split { grid-template-columns: minmax(0, 1fr) 380px; } }
.detail-wrap { position: sticky; top: 84px; }
@media (max-width: 1199.98px) { .detail-wrap { position: static; } }
.detail { --bs-offcanvas-bg: #f0f2f5; --bs-offcanvas-width: 410px; }
.detail .offcanvas-body { padding: 0; }
@media (max-width: 1199.98px) { .detail .offcanvas-body { padding: 0 1rem 1rem; } .detail .dp { box-shadow: none; } }
.dp { width: 100%; overflow: hidden; }

/* Type tabs */
.type-tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: 2px; max-width: 100%; }
.type-tabs a { display: inline-flex; align-items: center; gap: .45rem; padding: .38rem .8rem; border-radius: 999px; background: var(--hover); color: var(--muted); font-weight: 600; font-size: .82rem; text-decoration: none; white-space: nowrap; transition: background .15s, color .15s; }
.type-tabs a:hover { background: #e4e6eb; color: var(--text); }
.type-tabs a.on { background: var(--blue); color: #fff; }
.type-tabs a.on .dot { background: #fff !important; }
.type-tabs a em { font-style: normal; font-size: .72rem; opacity: .7; }
.type-tabs .dot { width: 8px; height: 8px; border-radius: 50%; }

/* Tree */
.coa-grid-head, .coa-row, .coa-foot { display: grid; grid-template-columns: minmax(0, 1fr) 112px 112px; align-items: center; column-gap: .5rem; }
@media (max-width: 575px) { .coa-grid-head, .coa-row, .coa-foot { grid-template-columns: minmax(0, 1fr) 82px 82px; column-gap: .25rem; } }
.coa-grid-head { padding: .55rem 1.1rem; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--subtle); background: #fafbfc; border-bottom: 1px solid var(--border); }
.coa-grid-head span:not(:first-child) { text-align: right; }
.coa-tree { outline: none; }
.coa-tree:focus-visible { box-shadow: inset 0 0 0 2px var(--blue-soft); }

.coa-row { position: relative; padding: .4rem 1.1rem; border-bottom: 1px solid #f0f2f5; cursor: pointer; font-size: .92rem; transition: background .12s; }
.coa-row[hidden] { display: none; }
.coa-row:hover { background: #f5f8ff; }
.coa-row.is-root { background: #f7f9fc; border-bottom-color: var(--border); }
.coa-row.is-root:hover { background: #eef4ff; }
.coa-row.selected { background: var(--blue-soft); }
.coa-row.selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--blue); }

.cr-name { display: flex; align-items: center; gap: .5rem; min-width: 0; padding-left: calc(var(--d) * 22px); }
.cr-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: .85rem; flex-shrink: 0; }
.cr-ic-leaf { background: var(--hover); color: var(--subtle); }
.cr-text { display: flex; align-items: baseline; gap: .5rem; min-width: 0; overflow: hidden; }
.cr-code { font-family: var(--mono); font-size: .72rem; color: var(--muted); background: var(--hover); border-radius: 5px; padding: 1px 6px; flex-shrink: 0; }
.cr-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-group .cr-title { font-weight: 700; }
.cr-num { text-align: right; font-family: var(--mono); font-size: .83rem; font-feature-settings: "tnum"; white-space: nowrap; }
.cr-num.zero { color: #c3c9d2; }
.cr-num.has { font-weight: 600; }
.is-root .cr-num.has { color: var(--blue); }

.coa-empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.coa-empty i { display: block; font-size: 1.8rem; margin-bottom: .4rem; }
.coa-empty[hidden] { display: none; }
.coa-foot { padding: .85rem 1.1rem; background: #f5f8ff; border-top: 2px solid var(--border-strong); font-weight: 700; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; color: #126782; }
.coa-foot .cr-num { font-size: .9rem; font-weight: 700; color: #126782; }
.coa-row.row-flash { animation: rowFlash 2.6s ease-out; }

/* Detail panel */
.dp-head { padding: 1.25rem 1.25rem 1rem; }
.dp-icon { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; font-size: 1.3rem; }
.dp-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; margin: .9rem 0 .15rem; overflow-wrap: anywhere; }
.dp-sub { color: var(--muted); font-size: .85rem; }
.dp-path { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; margin-top: .6rem; font-size: .78rem; color: var(--subtle); }
.dp-path button { border: 0; background: none; padding: .1rem .25rem; border-radius: 5px; color: var(--muted); font-weight: 500; }
.dp-path button:hover { background: var(--hover); color: var(--blue); }
.dp-path i { font-size: .6rem; }

.dp-balance { margin: 0 1.25rem; padding: 1rem 1.15rem; border-radius: 16px; color: #fff; background: var(--grad); position: relative; overflow: hidden; box-shadow: 0 14px 30px -16px rgba(24, 119, 242, .8); }
.dp-balance::after { content: ""; position: absolute; width: 170px; height: 170px; border-radius: 50%; right: -60px; top: -80px; background: rgba(255, 255, 255, .13); }
.dp-balance > * { position: relative; z-index: 1; }
.dp-balance .amt { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; }
.dp-balance .side, .dp-stat .side { font-family: var(--font); font-size: .72rem; font-weight: 700; padding: .1rem .5rem; margin-left: .4rem; border-radius: 99px; vertical-align: middle; }
.dp-balance .side { background: rgba(255, 255, 255, .22); }
.dp-stat .side { background: var(--blue-soft); color: var(--blue); }

.dp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .9rem 1.25rem 0; }
.dp-stat { background: var(--bg); border-radius: 12px; padding: .65rem .8rem; }
.dp-stat .k { font-size: .72rem; font-weight: 600; color: var(--muted); }
.dp-stat .v { font-size: .98rem; font-weight: 700; margin-top: .1rem; }

.dp-sec { padding: 1.1rem 1.25rem .25rem; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--subtle); }
.dp-list { padding: 0 .75rem; max-height: 280px; overflow-y: auto; }
.dp-item { width: 100%; display: flex; align-items: center; gap: .65rem; padding: .5rem; border: 0; background: none; border-radius: 10px; text-align: left; text-decoration: none; color: var(--text); }
.dp-item:hover { background: var(--hover); color: var(--text); }
.dp-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.dp-item .grow b { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-item .grow small { color: var(--subtle); font-size: .72rem; }
.dp-item .side { font-family: var(--font); font-size: .65rem; font-weight: 700; margin-left: .3rem; color: var(--subtle); }

.dp-actions { display: grid; gap: .5rem; padding: 1.1rem 1.25rem 1.25rem; }
.dp-del { color: var(--red); }
.dp-del:hover { background: var(--red-soft); color: var(--red); }

.dp-empty { padding: 2.2rem 1.5rem 1rem; text-align: center; }
.dp-empty > i { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 1rem; font-size: 2rem; color: var(--blue); background: var(--blue-soft); }

.coa-search { flex: 1 1 220px; max-width: 320px; width: auto; margin-left: auto; }
.report-card > .coa-sub { padding-top: .95rem; }

/* ---------- Expand / toolbar polish ---------- */
/* Search fills whatever room is left on the buttons' row, or drops to its own row */
.coa-search { flex: 1 1 240px; max-width: none; width: auto; }

/* Medium screens: smaller buttons so all five labels fit on one line */
@media (min-width: 576px) and (max-width: 1099.98px) {
    .tb-group { gap: .35rem; }
    .tb-btn { gap: .4rem; padding: .28rem .7rem .28rem .28rem; font-size: .8rem; }
    .tb-btn .ti { width: 26px; height: 26px; font-size: .88rem; }
}

/* Never clip the account code chip; only the name shortens (with …) */
.cr-text { overflow: visible; }
.cr-title { min-width: 0; }

/* Phones: tighter tree so codes and amounts stay readable */
@media (max-width: 575px) {
    .coa-row { padding: .4rem .75rem; }
    .coa-grid-head, .coa-foot { padding-left: .75rem; padding-right: .75rem; }
    .coa-grid-head, .coa-row, .coa-foot { grid-template-columns: minmax(0, 1fr) 74px 74px; column-gap: .2rem; }
    .cr-name { padding-left: calc(var(--d) * 12px); gap: .35rem; }
    .cr-ic { width: 22px; height: 22px; font-size: .75rem; border-radius: 7px; }
    .tgl, .tgl-gap { width: 18px; }
    .cr-text { gap: .35rem; }
    .cr-code { font-size: .68rem; padding: 1px 5px; }
    .cr-title { font-size: .86rem; }
    .cr-num { font-size: .76rem; }
}

/* Chevron flips instantly (no half-rotated frame) */
.tgl i { transition: none; }

/* Phones: code sits under the name, long names wrap instead of "Ass…" */
@media (max-width: 575px) {
    .cr-text { flex-direction: column; align-items: flex-start; gap: 0; }
    .cr-title { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.2; overflow-wrap: anywhere; }
    .cr-code { order: 2; background: none; padding: 0; margin-top: 1px; font-size: .68rem; color: var(--subtle); }
    .coa-row { padding-top: .5rem; padding-bottom: .5rem; }
}

@media (max-width: 575px) {
    .cr-ic-leaf { display: none; }
    .coa-grid-head, .coa-row, .coa-foot { grid-template-columns: minmax(0, 1fr) 70px 70px; }
}

/* Detail panel: history */
.dp-hist { display: grid; gap: .5rem; padding: .35rem 1.25rem 0; font-size: .82rem; line-height: 1.35; color: var(--muted); }
.dp-hist > div { display: flex; align-items: flex-start; gap: .55rem; }
.dp-hist i { flex-shrink: 0; margin-top: .12rem; font-size: .9rem; color: var(--subtle); }
.dp-hist span { min-width: 0; overflow-wrap: anywhere; }
.dp-hist b { color: var(--text); font-weight: 600; }

/* ---------- Ledger / Group report pages ---------- */
.filter-card { padding: 1rem 1.25rem; }
.report-head { text-align: center; padding: 1.75rem 1rem 1.25rem; }
.report-head h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.report-head h2 { font-size: 1.1rem; font-weight: 600; margin: .35rem 0 .15rem; }
.report-head p { margin: 0; color: var(--muted); font-size: .88rem; }
.table-report .rt-code { color: var(--report-text-muted); font-weight: 500; }
.table-report td.num, .table-report th.num { text-align: right; width: auto; min-width: 110px; }
.table-report td a:hover { color: var(--blue); }
.table-report .empty-row { text-align: center; padding: 1.5rem 1rem; color: var(--report-text-muted); }
.hide-trn .col-trn, .hide-type .col-type, .hide-reference .col-reference, .hide-details .col-details { display: none; }
.table-report td.col-details { white-space: normal; min-width: 220px; }

/* ==========================================================
   Report pages (ledger / group): same look as the Chart of Accounts
   ========================================================== */
.print-only { display: none; }

/* Summary cards */
.rep-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 991.98px) { .rep-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rep-kpi { position: relative; overflow: hidden; padding: 1rem 1.15rem; border-radius: 18px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .2s ease; }
.rep-kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.rep-kpi .k { font-size: .8rem; font-weight: 600; color: var(--muted); }
.rep-kpi .v { margin-top: .35rem; font-family: var(--mono); font-size: clamp(1.1rem, 2.2vw, 1.55rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.rep-kpi .s { margin-top: .3rem; font-size: .74rem; color: var(--subtle); }
.rep-kpi .ic { position: absolute; right: .9rem; top: .9rem; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-size: 1.05rem; }
.rep-kpi .side { font-family: var(--font); font-size: .66rem; font-weight: 700; margin-left: .35rem; padding: .12rem .5rem; border-radius: 99px; background: var(--blue-soft); color: var(--blue); vertical-align: middle; }
.rep-kpi.main { color: #fff; border: 0; background: var(--grad); box-shadow: 0 16px 34px -16px rgba(24, 119, 242, .85); }
.rep-kpi.main::after { content: ""; position: absolute; width: 190px; height: 190px; border-radius: 50%; right: -70px; bottom: -110px; background: rgba(255, 255, 255, .13); }
.rep-kpi.main > :not(.ic) { position: relative; z-index: 1; }
.rep-kpi.main .ic { z-index: 1; }
.rep-kpi.main .k, .rep-kpi.main .s { color: rgba(255, 255, 255, .82); }
.rep-kpi.main .ic { background: rgba(255, 255, 255, .2); color: #fff; }
.rep-kpi.main .side { background: rgba(255, 255, 255, .24); color: #fff; }

/* Filters */
.filter-card { padding: 1rem 1.25rem 1.1rem; }
.filter-label { font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--subtle); margin-bottom: .45rem; }
.filter-card .type-tabs { padding-bottom: .15rem; }
.filter-card .type-tabs span.on { display: inline-flex; align-items: center; gap: .45rem; padding: .38rem .8rem; border-radius: 999px; font-weight: 600; font-size: .82rem; white-space: nowrap; background: var(--blue); color: #fff; }
.filter-card .form-label { font-size: .75rem; margin-bottom: .3rem; color: var(--muted); }
.filter-card .seg a { display: inline-block; }

/* Table card */
.rep-card { overflow: hidden; }
.rep-head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.rep-head .t { font-weight: 700; letter-spacing: -0.01em; }
.rep-head .sub { font-size: .8rem; color: var(--muted); }
.rep-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.rep-table thead th { padding: .65rem 1rem; background: #fafbfc; border-bottom: 1px solid var(--border); font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--subtle); white-space: nowrap; text-align: left; }
.rep-table td { padding: .7rem 1rem; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.rep-table tbody tr:hover td { background: #f5f8ff; }
.rep-table th.num, .rep-table td.num { text-align: right; white-space: nowrap; min-width: 112px; }
.rep-table td.num { font-family: var(--mono); font-size: .84rem; font-feature-settings: "tnum"; }
.rep-table td.num:empty::after { content: "—"; color: #c3c9d2; }
.rep-table td.dr.has { color: var(--blue); font-weight: 600; }
.rep-table td.cr.has { color: #b4432f; font-weight: 600; }
.rep-table td.bal { font-weight: 700; }
.rep-table .side { font-family: var(--font); font-size: .66rem; font-weight: 700; margin-left: .35rem; color: var(--subtle); }
.rep-table .muted { color: var(--subtle); font-size: .82rem; }
.rep-table .nowrap { white-space: nowrap; }
.rep-table td.col-details { color: var(--muted); font-size: .85rem; min-width: 220px; }
.rep-table .acc { display: inline-flex; align-items: center; gap: .55rem; font-weight: 500; }
.rep-table .acc .cr-ic { width: 26px; height: 26px; }
.rep-table .acc a { color: var(--text); text-decoration: none; }
.rep-table .acc a:hover { color: var(--blue); }
.rep-table tr.row-subtotal td { background: var(--green-soft); color: #1d6b10; font-weight: 600; border-bottom-color: #c3e6bb; }
.rep-table tr.row-subtotal td .acc { font-weight: 700; }
.rep-table tr.row-total td { background: var(--blue-soft); color: #0c5ec4; font-weight: 700; border-top: 2px solid #b9d7fb; border-bottom: 0; }
.rep-table tr.row-total td.num { font-size: .9rem; }
.rep-table tr.rep-link { cursor: pointer; }
.rep-table tr.row-group td { background: #f7f9fc; }
.rep-table tr.row-group:hover td { background: #eef4ff; }
.rep-table .empty-row { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.rep-table .empty-row i { display: block; font-size: 1.8rem; margin-bottom: .35rem; color: var(--subtle); }
.rep-table .go { color: var(--subtle); font-size: .8rem; }
.rep-table tr.rep-link:hover .go { color: var(--blue); transform: translateX(2px); }

/* Report pages on phones */
.filter-card .btn { white-space: nowrap; }
@media (max-width: 575px) {
    .rep-kpi .ic { display: none; }
    .rep-kpis { gap: .65rem; }
    .rep-kpi { padding: .85rem .95rem; }
    .rep-head { padding: .85rem 1rem; }
}

/* Detail panel: View / Edit / Add child on one line */
.dp-actions { gap: .6rem; }
.dp-btn-row { display: flex; gap: .5rem; }
.dp-btn-row .btn { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem .5rem; font-size: .88rem; white-space: nowrap; }
.dp-btn-row .btn i { flex-shrink: 0; }
@media (max-width: 575px) {
    .dp-btn-row { gap: .4rem; }
    .dp-btn-row .btn { font-size: .8rem; padding: .5rem .3rem; gap: .3rem; }
}

/* ---------- Chart of Accounts: inline actions on row hover ---------- */
.coa-row { --rowbg: #fff; }
.coa-row:hover { --rowbg: #f5f8ff; }
.coa-row.is-root { --rowbg: #f7f9fc; }
.coa-row.is-root:hover { --rowbg: #eef4ff; }
.coa-row.selected { --rowbg: var(--blue-soft); }
.cr-name { position: relative; }
.cr-actions {
    position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    display: inline-flex; gap: .3rem; padding-left: 28px;
    background: linear-gradient(90deg, transparent, var(--rowbg) 26px);
    opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.coa-row:hover .cr-actions, .cr-actions:focus-within { opacity: 1; pointer-events: auto; }
.ca { display: inline-flex; align-items: center; gap: .3rem; height: 26px; padding: 0 .6rem; border-radius: 999px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--muted); font-size: .74rem; font-weight: 600; text-decoration: none; white-space: nowrap; transition: color .12s, border-color .12s, background .12s; }
.ca i { font-size: .78rem; }
.ca:hover { color: var(--blue); border-color: var(--blue); }
.ca:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.ca-view { background: var(--grad); border-color: transparent; color: #fff; }
.ca-view:hover { color: #fff; border-color: transparent; filter: brightness(1.07); }
/* Narrow tree: icons only */
.report-card { container-type: inline-size; }
@container (max-width: 640px) {
    .ca .lbl { display: none; }
    .ca { width: 26px; padding: 0; justify-content: center; }
}
/* Touch screens have no hover: use the detail panel instead */
@media (hover: none) { .cr-actions { display: none; } }
/* Place the hover buttons right after the name (not over it) */
.cr-actions { position: static; transform: none; background: none; padding-left: 0; margin-left: .4rem; flex-shrink: 0; display: none; opacity: 1; pointer-events: auto; }
.coa-row:hover .cr-actions { display: inline-flex; }
@media (hover: none) { .coa-row:hover .cr-actions { display: none; } }
/* Compact: "View" keeps its label, Edit / Add child are round icon buttons (tooltip shows the name) */
.ca:not(.ca-view) { width: 26px; padding: 0; justify-content: center; }
.ca:not(.ca-view) .lbl { display: none; }
@container (min-width: 900px) {
    .ca:not(.ca-view) { width: auto; padding: 0 .6rem; }
    .ca:not(.ca-view) .lbl { display: inline; }
}

/* Switch styled as a form field (same height/border as the date inputs) */
.switch-field { display: flex; align-items: center; gap: .7rem; min-height: calc(1.5em + 1.4rem + 2px); margin: 0; padding: 0 .9rem; border: 1px solid #dddfe2; border-radius: 8px; background: #fff; color: var(--text); font-size: .92rem; cursor: pointer; transition: border-color .15s; }
.switch-field:hover { border-color: var(--border-strong); }
.switch-field .form-check-input { float: none; margin: 0; cursor: pointer; }

/* Ledger: Against Ledger column */
.rep-table td.col-against { min-width: 200px; }
.against { display: flex; align-items: center; gap: .5rem; width: max-content; max-width: 100%; color: var(--text); font-weight: 500; text-decoration: none; border-radius: 8px; }
.against + .against { margin-top: .35rem; }
.against .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.against .cr-ic { width: 26px; height: 26px; }
.against .go { font-size: .7rem; color: var(--blue); opacity: 0; transition: opacity .12s; }
a.against:hover { color: var(--blue); }
a.against:hover .go { opacity: 1; }
a.against:hover .cr-ic { background: var(--blue-soft); color: var(--blue); }


/* Ledger: what the Opening Balance line is made of */
.rep-table tr.row-open-parts td { padding: .2rem 1rem .7rem; background: #fbfdf9; }
.rep-table tr.row-open-parts:hover td { background: #fbfdf9; }
.op-list { max-width: 640px; position: sticky; left: 0; margin-left: 2.2rem; border-left: 2px solid #d9ead3; padding-left: .9rem; }
.op-head { font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--subtle); margin-bottom: .2rem; }
.op-item { display: flex; align-items: baseline; gap: .55rem; padding: .18rem 0; font-size: .83rem; color: var(--muted); }
.op-item > .bi { color: var(--subtle); }
.op-item a { color: var(--text); font-weight: 600; text-decoration: none; }
.op-item a:hover { color: var(--blue); text-decoration: underline; }
.op-item small { color: var(--subtle); }
.op-item .op-amt { margin-left: auto; white-space: nowrap; }
