/* Account ledger — banking-style */
.ldg-wrap {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 52px);
    width: 100%;
    max-width: none;
    background: linear-gradient(180deg, #e8edf7 0%, #f1f5f9 42%, #f8fafc 100%);
    font-size: 0.8rem;
    color: #1e293b;
    line-height: 1.35;
}

.ldg-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.38rem 0.75rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 48%, #2563eb 100%);
    color: #fff;
    border-radius: 0;
    position: relative;
    z-index: 1;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
    flex-wrap: wrap;
}

.ldg-back {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-decoration: none;
    font-size: 0.8rem;
    transition: background 0.12s;
}
.ldg-back:hover { background: rgba(255, 255, 255, 0.22); color: #fff; }

.ldg-top-main {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    flex: 1;
}

.ldg-top-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.ldg-top-text { min-width: 0; }
.ldg-top-text h1 {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ldg-top-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.08rem;
    flex-wrap: wrap;
}
.ldg-code {
    font-family: ui-monospace, monospace;
    font-size: 0.62rem;
    font-weight: 600;
    padding: 0.04rem 0.28rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.95);
}
.ldg-type {
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.82;
}
.ldg-type--asset { color: #93c5fd; }
.ldg-type--liability { color: #fdba74; }
.ldg-type--equity { color: #c4b5fd; }
.ldg-type--revenue { color: #86efac; }
.ldg-type--expense { color: #fca5a5; }

.ldg-closing {
    margin-left: auto;
    text-align: right;
    flex-shrink: 0;
    padding: 0.2rem 0.45rem;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
}
.ldg-closing span {
    display: block;
    font-size: 0.52rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.75;
}
.ldg-closing strong {
    font-size: 0.88rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
}
.ldg-closing.is-negative strong { color: #fecaca; }

.ldg-meta-sep {
    color: #94a3b8;
    font-weight: 400;
    opacity: 0.85;
    padding: 0 0.12rem;
}
.ldg-top-meta .ldg-meta-sep {
    color: rgba(255, 255, 255, 0.45);
}

.ldg-body {
    flex: 1;
    padding: 0.65rem 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-width: none;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
}

.ldg-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(30, 45, 90, 0.05);
}

.ldg-field {
    display: flex;
    flex-direction: column;
    gap: 0.08rem;
}
.ldg-field > span {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}
.ldg-date-input {
    width: 132px;
    height: 26px;
    padding: 0 0.4rem;
    border: 1px solid #d1d9ef;
    border-radius: 5px;
    font-size: 0.68rem;
    color: #1e293b;
    background: #fff;
}
.ldg-date-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.ldg-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    padding: 0.4rem 0.65rem;
    background: linear-gradient(135deg, #eff6ff, #f0f9ff);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 0.7rem;
    color: #1e40af;
}
.ldg-banner i { font-size: 0.95rem; flex-shrink: 0; margin-top: 0.05rem; }

.ldg-state-hint {
    margin: 0.35rem 0 0;
    font-size: 0.68rem;
    color: #94a3b8;
}
.ldg-retry {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.28rem 0.75rem;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
}
.ldg-retry:hover { opacity: 0.92; }

.ldg-apply {
    height: 26px;
    padding: 0 0.65rem;
    border: none;
    border-radius: 5px;
    background: linear-gradient(135deg, #ea580c, #f97316);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    box-shadow: 0 1px 3px rgba(234, 88, 12, 0.35);
    transition: opacity 0.12s;
}
.ldg-apply:hover { opacity: 0.92; }
.ldg-apply:disabled { opacity: 0.55; cursor: not-allowed; }

.ldg-field--page { margin-left: 0.15rem; }
.ldg-page-size {
    width: 72px;
    height: 30px;
    padding: 0 0.35rem;
    border: 1px solid #d1d9ef;
    border-radius: 6px;
    font-size: 0.74rem;
    color: #1e293b;
    background: #fff;
}
.ldg-page-size:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.ldg-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-top: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #fafbfd 0%, #f8fafc 100%);
}
.ldg-page-info {
    font-size: 0.74rem;
    font-weight: 600;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}
.ldg-page-btns {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.ldg-page-btn {
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.35rem;
    border: 1px solid #d1d9ef;
    background: #fff;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.ldg-page-btn:hover:not(:disabled) {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}
.ldg-page-btn--active {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    border-color: #1d4ed8;
    color: #fff;
}
.ldg-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.ldg-kpis {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-left: auto;
}
.ldg-kpi {
    display: flex;
    flex-direction: column;
    padding: 0.35rem 0.55rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    min-width: 88px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.ldg-kpi span {
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
}
.ldg-kpi strong {
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #1e293b;
}
.ldg-kpi--dr strong { color: #15803d; }
.ldg-kpi--cr strong { color: #b45309; }
.ldg-kpi--bal strong { color: #1d4ed8; }
.ldg-kpi--bal.is-negative strong { color: #dc2626; }

.ldg-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(30, 45, 90, 0.06);
}

.ldg-state {
    padding: 2rem 1rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.75rem;
}
.ldg-state i { font-size: 1.5rem; opacity: 0.35; display: block; margin-bottom: 0.35rem; }
.ldg-state--inline {
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.ldg-scroll--dim {
    opacity: 0.45;
    pointer-events: none;
}
.ldg-legs-loading {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0;
    font-size: 0.72rem;
    color: #64748b;
}

.ldg-scroll { overflow-x: auto; }

.ldg-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.74rem;
}
.ldg-col-exp { width: 36px; }
.ldg-col-date { width: 76px; }
.ldg-col-src { width: 108px; }
.ldg-col-ref { width: auto; }
.ldg-col-vch { width: 96px; }
.ldg-col-amt { width: 108px; }
.ldg-col-bal { width: 112px; }
.ldg-table thead tr {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}
.ldg-table thead th {
    padding: 0.22rem 0.4rem;
    font-size: 0.54rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.88);
    white-space: nowrap;
    border: none;
}
.ldg-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ldg-th-exp { width: 28px; padding: 0 !important; }

.ldg-table tbody tr { border-bottom: 1px solid #f1f5f9; }
.ldg-table tbody tr.ldg-row:nth-child(4n+1) { background: #fafbfd; }
.ldg-table tbody tr:last-child { border-bottom: none; }

.ldg-row {
    cursor: pointer;
    transition: background 0.1s;
}
.ldg-row:hover { background: #f8fafc; }
.ldg-row.is-expanded { background: #eff6ff; }
.ldg-row td {
    padding: 0.2rem 0.4rem;
    vertical-align: middle;
}

.ldg-date { color: #64748b; white-space: nowrap; font-size: 0.64rem; }
.ldg-src {
    display: inline-block;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.64rem;
    color: #1d4ed8;
    background: #eff6ff;
    padding: 0.06rem 0.28rem;
    border-radius: 4px;
}
.ldg-ref {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #64748b;
    font-size: 0.64rem;
}
.ldg-vch {
    font-family: ui-monospace, monospace;
    font-size: 0.62rem;
    color: #475569;
}
.ldg-amt-dr { color: #15803d; font-weight: 600; }
.ldg-amt-cr { color: #c2410c; font-weight: 600; }
.ldg-amt-nil { color: #cbd5e1; }
.ldg-nil {
    display: inline-block;
    min-width: 0.5rem;
    color: #cbd5e1;
    font-weight: 500;
    text-align: center;
}
.ldg-bal {
    font-weight: 700;
    color: #1e40af;
}
.ldg-bal.is-negative { color: #dc2626; }

.ldg-expand {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    color: #2563eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.58rem;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}
.ldg-expand:hover { background: #eff6ff; border-color: #93c5fd; }
.ldg-row.is-expanded .ldg-expand {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.ldg-detail td {
    padding: 0 !important;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.ldg-detail-inner {
    padding: 0.3rem 0.45rem 0.35rem 2rem;
}
.ldg-detail-hd {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.ldg-detail-hd i { font-size: 0.7rem; color: #2563eb; }

.ldg-sub {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.64rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}
.ldg-sub thead tr { background: #e0e7ff; }
.ldg-sub thead th {
    padding: 0.14rem 0.35rem;
    font-size: 0.52rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #4338ca;
    text-align: left;
}
.ldg-sub thead th.num { text-align: right; }
.ldg-sub tbody td {
    padding: 0.14rem 0.35rem;
    border-top: 1px solid #eef2ff;
}
.ldg-sub tr.is-focus {
    background: #dbeafe;
    font-weight: 600;
}
.ldg-sub-code {
    font-family: ui-monospace, monospace;
    font-size: 0.58rem;
    color: #64748b;
    margin-right: 0.25rem;
}
.ldg-focus-tag {
    font-size: 0.52rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.02rem 0.22rem;
    border-radius: 3px;
    background: #2563eb;
    color: #fff;
    margin-left: 0.25rem;
    vertical-align: middle;
}

.ldg-open-row td {
    background: #fafafa;
    font-size: 0.64rem;
    font-weight: 600;
    color: #64748b;
    padding: 0.22rem 0.4rem;
    border-bottom: 1px dashed #e2e8f0;
}

.ldg-spin {
    width: 1rem;
    height: 1rem;
    border: 2px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: ldg-spin 0.65s linear infinite;
    margin: 0 auto;
}
@keyframes ldg-spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
    .ldg-kpis { margin-left: 0; width: 100%; }
    .ldg-kpi { flex: 1; min-width: 0; }
    .ldg-closing { margin-left: 0; width: 100%; text-align: left; margin-top: 0.25rem; }
}
