.coa-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 100%;
    background: #f3f5fb;
    font-size: 0.77rem;
    color: #1f2937;
}

.coa-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    flex-shrink: 0;
    background: linear-gradient(135deg, #1f2f65 0%, #3655ad 100%);
    color: #fff;
    padding: 0.42rem 0.82rem;
    position: relative;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.2);
}

.coa-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.coa-topbar-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.16);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.coa-topbar-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.1;
}

.coa-topbar-sub {
    display: block;
    font-size: 0.65rem;
    opacity: 0.82;
    margin-top: 0.04rem;
}

.coa-top-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.36rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.coa-btn {
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.23rem 0.62rem;
    font-size: 0.71rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    cursor: pointer;
    background: #fff;
    color: #1f2937;
}

.coa-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.coa-btn--print { border-color: #d1d5db; }
.coa-btn--sync { border-color: #bfdbfe; color: #1d4ed8; background: #eff6ff; }
.coa-btn--add { border-color: #bbf7d0; color: #166534; background: #f0fdf4; }

.coa-body {
    flex: 1 1 auto;
    position: relative;
    z-index: 1;
    max-width: 1380px;
    width: 100%;
    margin: 0 auto;
    padding: 0.65rem 0.7rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.coa-stats-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.38rem;
}

.coa-stat {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.46rem 0.58rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.coa-stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.coa-stat-icon--blue { background: #dbeafe; color: #1d4ed8; }
.coa-stat-icon--green { background: #dcfce7; color: #15803d; }
.coa-stat-icon--red { background: #fee2e2; color: #b91c1c; }
.coa-stat-icon--purple { background: #f3e8ff; color: #7e22ce; }

.coa-stat-label {
    display: block;
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.coa-stat-val {
    display: block;
    margin-top: 0.06rem;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.05;
}

.coa-stat-val--blue { color: #1d4ed8; }
.coa-stat-val--green { color: #15803d; }
.coa-stat-val--red { color: #b91c1c; }
.coa-stat-val--purple { color: #7e22ce; }

.coa-filter-card,
.coa-table-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}

.coa-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
    padding: 0.45rem 0.58rem;
}

.coa-filter-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-left: auto;
}

.coa-page-size-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.24rem;
    font-size: 0.62rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.coa-page-size {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    min-width: 52px;
    height: 24px;
    font-size: 0.64rem;
    padding: 0 0.24rem;
    color: #334155;
}

.coa-search-wrap {
    position: relative;
    flex: 1;
    min-width: 210px;
}

.coa-search-ico {
    position: absolute;
    left: 0.45rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
}

.coa-search-input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    padding: 0.34rem 2rem 0.34rem 1.6rem;
    font-size: 0.74rem;
    background: #fff;
}

.coa-search-input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.14);
}

.coa-search-clear {
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #6b7280;
    width: 20px;
    height: 20px;
    border-radius: 999px;
}

.coa-result-count {
    font-size: 0.68rem;
    color: #6b7280;
    white-space: nowrap;
}

.coa-group-panel {
    margin: 0.32rem 0.32rem 0.2rem;
    border: 1px dashed #cbd5e1;
    background: #f8fafc;
    color: #475569;
    border-radius: 8px;
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 0.32rem;
    padding: 0.2rem 0.42rem;
    font-size: 0.64rem;
}

.coa-group-panel strong {
    color: #1f2937;
}

.coa-group-clear {
    margin-left: auto;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    border-radius: 6px;
    height: 22px;
    padding: 0 0.45rem;
    font-size: 0.6rem;
    font-weight: 600;
}

.coa-table-wrap {
    overflow-x: auto;
}

.coa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.67rem;
}

.coa-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.045em;
    font-size: 0.56rem;
    font-weight: 700;
    padding: 0.24rem 0.3rem;
    text-align: left;
    white-space: nowrap;
}

.coa-th-draggable {
    cursor: grab;
}

.coa-th-draggable:active {
    cursor: grabbing;
}

.coa-table tbody td {
    border-bottom: 1px solid #eef2f7;
    padding: 0.2rem 0.3rem;
    vertical-align: middle;
}

.coa-row--parent {
    background: #f8fbff;
}

.coa-row--child1,
.coa-row--child2 {
    background: #fff;
}

.coa-group-row td {
    background: #eef2ff;
    color: #1e3a8a;
    border-bottom: 1px solid #dbeafe;
    padding: 0.18rem 0.32rem !important;
    font-size: 0.62rem;
}

.coa-group-title {
    font-weight: 700;
    margin-right: 0.25rem;
}

.coa-group-value {
    font-weight: 600;
}

.coa-group-count {
    margin-left: 0.22rem;
    color: #475569;
}

.coa-code-badge {
    display: inline-flex;
    border-radius: 6px;
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
    font-size: 0.61rem;
    font-weight: 700;
    padding: 0.08rem 0.32rem;
}

.coa-name-indent {
    display: inline-flex;
    align-items: center;
    gap: 0.24rem;
}

.coa-name--root { font-weight: 700; }
.coa-tree-arrow { color: #94a3b8; font-size: 0.66rem; }

.coa-global-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.52rem;
    border: 1px solid #cbd5e1;
}

.coa-type-badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 0.08rem 0.34rem;
    font-size: 0.56rem;
    font-weight: 700;
}

.coa-type-badge--asset { background: #dbeafe; color: #1d4ed8; }
.coa-type-badge--liability { background: #fee2e2; color: #b91c1c; }
.coa-type-badge--equity { background: #f3e8ff; color: #7e22ce; }
.coa-type-badge--revenue { background: #fef3c7; color: #92400e; }
.coa-type-badge--expense { background: #dcfce7; color: #166534; }
.coa-type-badge--default { background: #e2e8f0; color: #334155; }

.coa-td-num,
.coa-td-balance {
    text-align: right;
    white-space: nowrap;
}

.coa-num-val {
    font-variant-numeric: tabular-nums;
}

.coa-num-nil {
    color: #94a3b8;
}

.coa-balance {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.coa-balance--dr { color: #1d4ed8; }
.coa-balance--cr { color: #b91c1c; }
.coa-balance-side { margin-left: 0.2rem; font-size: 0.62rem; }

.coa-td-act {
    text-align: center;
}

.coa-act-grp {
    display: inline-flex;
    gap: 0.24rem;
}

.coa-act-btn {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    border: 1px solid transparent;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
}

.coa-act-btn--edit { border-color: #bfdbfe; color: #1d4ed8; }
.coa-act-btn--del { border-color: #fecaca; color: #b91c1c; }

.coa-tfoot-row td {
    background: #f8fafc;
    font-weight: 700;
    border-top: 1px solid #e5e7eb;
    padding: 0.24rem 0.3rem;
}

.coa-pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e5e7eb;
    padding: 0.3rem 0.5rem;
    background: #f8fafc;
}

.coa-pager-meta {
    font-size: 0.64rem;
    color: #64748b;
}

.coa-pager-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
}

.coa-pager-btn {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    height: 24px;
    min-width: 52px;
    font-size: 0.62rem;
    font-weight: 600;
    color: #334155;
}

.coa-pager-btn:disabled {
    opacity: 0.55;
}

.coa-pager-page {
    font-size: 0.62rem;
    color: #475569;
    min-width: 84px;
    text-align: center;
}

.coa-tfoot-label { text-align: right; color: #334155; }
.coa-tfoot-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.coa-loading,
.coa-empty {
    padding: 2rem 0.8rem;
    text-align: center;
    color: #64748b;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: center;
}

.coa-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 999px;
    animation: coa-spin 0.8s linear infinite;
}

@keyframes coa-spin {
    to { transform: rotate(360deg); }
}

.coa-empty-icon { font-size: 1.7rem; opacity: 0.5; }
.coa-empty-title { font-weight: 700; color: #334155; }

.coa-spinner--sm {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(37, 99, 235, 0.25);
    border-top-color: #2563eb;
    border-radius: 999px;
    display: inline-block;
    animation: coa-spin 0.7s linear infinite;
}

.coa-mob-cards {
    display: none;
}

/* Modal styling fallback */
.coa-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0.55rem;
}

.coa-modal-overlay.active {
    display: flex;
}

.coa-modal-container {
    width: min(760px, 100%);
    max-height: 88vh;
    border-radius: 9px;
    border: 1px solid #dbe2f0;
    background: #fff;
    box-shadow: 0 24px 50px rgba(2, 6, 23, 0.24);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.coa-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.45rem;
    padding: 0.32rem 0.46rem;
    color: #fff;
    background: linear-gradient(135deg, #1f2f65 0%, #3655ad 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.coa-header-content {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
}

.coa-icon-circle {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    flex-shrink: 0;
}

.coa-modal-header h3 {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.15;
}

.coa-subtitle {
    margin: 0.08rem 0 0;
    font-size: 0.54rem;
    opacity: 0.82;
}

.coa-modal-body {
    padding: 0.34rem 0.44rem 0.28rem;
    overflow: auto;
}

.coa-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.25rem 0.34rem;
}

.coa-field {
    margin-bottom: 0 !important;
}

.coa-field label {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-bottom: 0.06rem;
    font-size: 0.51rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    color: #64748b;
}

.coa-modal-body .form-control,
.coa-modal-body .form-select {
    min-height: 24px;
    padding: 0.12rem 0.24rem;
    font-size: 0.61rem;
    border-color: #d1d5db;
    border-radius: 7px;
}

.coa-modal-footer {
    margin-top: 0.26rem;
    border-top: 1px solid #e5e7eb;
    padding-top: 0.26rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
}

/* Compact parent picker (inside modal) */
.coa-modal-body .chart-parent-picker .form-label {
    font-size: 0.5rem;
    margin-bottom: 0.06rem;
    letter-spacing: 0.04em;
}

.coa-modal-body .parent-picker-selected {
    font-size: 0.56rem !important;
    margin-bottom: 0.14rem !important;
}

.coa-modal-body .chart-parent-picker .form-control.form-control-sm {
    min-height: 23px;
    font-size: 0.58rem;
    padding: 0.1rem 0.22rem;
    margin-bottom: 0.14rem !important;
}

.coa-modal-body .parent-picker-tree {
    max-height: 168px !important;
}

.coa-modal-body .parent-picker-tree .list-group-item {
    padding: 0.18rem 0.28rem !important;
    font-size: 0.59rem;
}

@media (max-width: 980px) {
    .coa-stats-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .coa-topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.45rem;
    }

    .coa-top-actions {
        justify-content: flex-start;
    }

    .coa-btn {
        padding: 0.2rem 0.5rem;
        font-size: 0.66rem;
    }

    .coa-body {
        padding: 0.42rem 0.42rem 1rem;
        gap: 0.38rem;
    }

    .coa-stats-strip {
        grid-template-columns: 1fr;
    }

    .coa-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.36rem;
    }

    .coa-filter-meta {
        width: 100%;
        justify-content: space-between;
    }

    .coa-table-wrap {
        display: none;
    }

    .coa-mob-cards {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.32rem;
    }

    .coa-mob-card {
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 0.28rem 0.36rem;
        background: #fff;
    }

    .coa-mob-card--root {
        border-color: #bfdbfe;
        background: #f8fbff;
    }

    .coa-mob-card-header {
        display: flex;
        justify-content: space-between;
        gap: 0.35rem;
        align-items: flex-start;
    }

    .coa-mob-left {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;
    }

    .coa-mob-name {
        font-size: 0.66rem;
        color: #1f2937;
    }

    .coa-mob-nums {
        margin-top: 0.3rem;
        border-top: 1px dashed #e2e8f0;
        padding-top: 0.28rem;
        display: flex;
        flex-direction: column;
        gap: 0.22rem;
    }

    .coa-mob-num-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.62rem;
    }

    .coa-mob-num-lbl {
        color: #64748b;
    }

    .coa-mob-card-footer {
        margin-top: 0.3rem;
        border-top: 1px dashed #e2e8f0;
        padding-top: 0.3rem;
    }

    .coa-pager {
        flex-direction: column;
        align-items: stretch;
        gap: 0.24rem;
    }

    .coa-pager-actions {
        justify-content: space-between;
    }

    .coa-form-grid {
        grid-template-columns: 1fr;
        gap: 0.34rem;
    }
}

@media (max-width: 560px) {
    .coa-modal-overlay {
        padding: 0.25rem;
    }

    .coa-modal-header {
        padding: 0.34rem 0.42rem;
    }

    .coa-modal-body {
        padding: 0.34rem 0.42rem 0.32rem;
    }
}
