/* ═══════════════════════════════════════════════════
   작업비 출입금 관리 (Billing)
   ═══════════════════════════════════════════════════ */

.bl_wrap {
    width: 100%;
    padding: clamp(20px, calc(1.56vw + 15px), 40px) 0;
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    color: #444;
}

/* ── 상단 ── */
.bl_top_area {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: clamp(20px, calc(1.56vw + 15px), 40px);
    padding: clamp(12px, calc(0.94vw + 9px), 24px);
    background: #f7f7f7;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.bl_ym_selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bl_ym_selector label {
    font-size: 17px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.bl_ym_selector select {
    padding: 8px 32px 8px 14px;
    font-size: 18px;
    font-weight: 600;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.2s;
}

.bl_admin_btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.bl_btn {
    padding: 7px 16px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    background: #fff;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.bl_btn:hover { background: #f0f0f0; border-color: #aaa; }

.bl_btn_save { background: #555; color: #fff; border-color: #555; }
.bl_btn_save:hover { background: #444; }

.bl_btn_del { color: #c44; border-color: #c44; }
.bl_btn_del:hover { background: #c44; color: #fff; }

.bl_btn_add_row {
    margin-top: 10px;
    font-size: 13px;
    padding: 5px 12px;
    color: #999;
    border-style: dashed;
}

.bl_btn_adj {
    color: #c44;
    border-color: #e0b0b0;
}

.bl_btn_sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
}

.bl_btn_del_sm {
    color: #c44;
    border-color: #dcc;
}
.bl_btn_del_sm:hover {
    background: #c44;
    color: #fff;
}

.bl_btn_add_company {
    padding: 6px 14px;
    font-size: 13px;
    color: #2a7ae2;
    border: 1px solid #2a7ae2;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.bl_btn_add_company:hover {
    background: #2a7ae2;
    color: #fff;
}

/* ── 업체 탭 ── */
.bl_tab_area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: clamp(20px, calc(1.56vw + 15px), 40px);
    flex-wrap: wrap;
}

.bl_tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex: 1;
}

.bl_tab {
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #f5f5f5;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    top: 1px;
}

.bl_tab:hover {
    background: #eee;
    color: #555;
}

.bl_tab.active {
    background: #fff;
    color: #333;
    font-weight: 700;
    border-color: #ccc;
    border-bottom: 2px solid #fff;
    z-index: 1;
}

/* ── 탭 콘텐츠 ── */
.bl_tab_content {
    border: 1px solid #e0e0e0;
    border-radius: 0 8px 8px 8px;
    padding: clamp(16px, calc(1.25vw + 12px), 32px);
    background: #fff;
    margin-bottom: clamp(20px, calc(1.56vw + 15px), 40px);
}

/* ── 업체 상세 헤더 ── */
.bl_company_header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: clamp(16px, calc(1.25vw + 12px), 32px);
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.bl_company_name {
    font-size: clamp(18px, calc(0.63vw + 16px), 26px);
    font-weight: 700;
    color: #333;
    margin: 0;
    flex: 1;
}

.bl_company_actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── 전체요약 테이블 ── */
.bl_all_table .bl_td_name {
    text-align: left;
    font-weight: 600;
    color: #333;
}

.bl_all_table .bl_td_inc { color: #2a7ae2; }
.bl_all_table .bl_td_exp { color: #c44; }
.bl_all_table .bl_td_neg { color: #c44; }
.bl_all_table .bl_td_manage { text-align: center; }

/* 빈 상태 */
.bl_empty {
    text-align: center;
    padding: 50px 20px;
    color: #999;
    font-size: 15px;
}
.bl_empty p { margin: 6px 0; }

/* ── 상단 레이아웃 ── */
.bl_top_left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.bl_page_title {
    font-size: clamp(22px, calc(0.94vw + 19px), 32px);
    font-weight: 700;
    color: #333;
    margin: 0;
}

.bl_ym_selector select {
    padding: 6px 28px 6px 12px;
    font-size: 17px;
    font-weight: 700;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* ── 업체 상세 월 네비 ── */
.bl_company_month_nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-right: 12px;
}

.bl_company_month_label {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    min-width: 70px;
    text-align: center;
}

.bl_btn_month_prev,
.bl_btn_month_next {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    line-height: 1;
}

.bl_company_month_select {
    padding: 4px 22px 4px 8px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    margin-left: 4px;
}

/* ── 2단 레이아웃 ── */
.bl_two_col {
    display: flex;
    gap: clamp(20px, calc(1.56vw + 15px), 40px);
}

.bl_two_col > .bl_section {
    flex: 1;
    min-width: 0;
}

@media screen and (max-width: 1024px) {
    .bl_two_col {
        flex-direction: column;
    }
}

/* ── 섹션 ── */
.bl_section {
    margin-bottom: clamp(20px, calc(1.56vw + 15px), 40px);
}

.bl_section_title {
    font-size: clamp(18px, calc(0.47vw + 16.5px), 24px);
    font-weight: 700;
    color: #333;
    margin: 0 0 14px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.bl_unit {
    font-size: 13px;
    font-weight: 400;
    color: #aaa;
}

/* ── 테이블 ── */
.bl_scroll_wrap { position: relative; }
.bl_scroll_inner {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.bl_scroll_inner::-webkit-scrollbar { display: none; }
.bl_scroll_inner .bl_table { min-width: 500px; }

.bl_table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(14px, calc(0.31vw + 13px), 16px);
    table-layout: fixed;
}

.bl_table th,
.bl_table td {
    padding: 11px 12px;
    border-bottom: 1px solid #e5e5e5;
    vertical-align: middle;
}

.bl_table thead th {
    background: #f5f5f5;
    font-weight: 600;
    text-align: center;
    color: #555;
    border-top: 2px solid #333;
    border-bottom: 1px solid #ccc;
    font-size: 14px;
}

.bl_td_label {
    font-weight: 500;
    text-align: left;
}

.bl_td_amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    letter-spacing: -0.3px;
}

.bl_td_vat {
    position: relative;
    color: #888;
}

.bl_td_note {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #999;
    margin-top: 2px;
    line-height: 1.4;
}

.bl_td_adj_label {
    color: #c44;
    font-style: italic;
}

.bl_tr_adj td {
    background: #fff8f8;
}

.bl_tr_total td {
    font-weight: 700;
    background: #f0f0f0;
    border-top: 2px solid #333;
    border-bottom: 2px solid #333;
    text-align: center;
    color: #333;
    padding-top: 16px;
    padding-bottom: 16px;
}

.bl_tr_total td.bl_td_amount {
    text-align: right;
    font-size: 1.05em;
}

/* 행 클릭 */
.bl_clickable { cursor: pointer; transition: background-color 0.15s; }
.bl_clickable:hover { background-color: #f5f5f5 !important; }

/* 행 삭제 버튼 - tr 우측상단 */
.bl_clickable { position: relative; }
.bl_row_del_btn {
    position: absolute;
    right: 2px;
    top: 2px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #eee;
    color: #999;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    display: none;
    z-index: 2;
    border: none; padding: 0;
}
.bl_row_del_btn:hover { background: #c44; color: #fff; }
tr:hover .bl_row_del_btn { display: block; }

/* ── 하단 요약 바 ── */
.bl_summary_bar {
    display: flex;
    gap: 0;
    margin-top: clamp(20px, calc(1.56vw + 15px), 40px);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.bl_sum_item {
    flex: 1;
    padding: clamp(16px, calc(1.25vw + 12px), 32px) clamp(12px, calc(0.94vw + 9px), 24px);
    text-align: center;
    border-right: 1px solid #e0e0e0;
}
.bl_sum_item:last-child { border-right: none; }

.bl_sum_income { background: #f0f7ff; }
.bl_sum_expense { background: #fff5f5; }
.bl_sum_diff { background: #f5fff5; }

.bl_sum_label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    margin-bottom: 6px;
}

.bl_sum_val {
    display: block;
    font-size: clamp(18px, calc(0.78vw + 15.5px), 28px);
    font-weight: 700;
    color: #333;
    font-variant-numeric: tabular-nums;
}

.bl_sum_detail {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: #888;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.bl_sum_neg { color: #c44; }
.bl_sum_neg .bl_sum_detail { color: #c88; }

/* ── 하단 저장 ── */
.bl_bottom_save {
    margin-top: clamp(30px, calc(2.34vw + 22.5px), 60px);
    text-align: center;
}
.bl_btn_save_big {
    display: inline-block;
    width: 100%;
    max-width: 400px;
    padding: 16px 40px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    background: #555;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    letter-spacing: 1px;
}
.bl_btn_save_big:hover { background: #333; }

.bl_bottom_save { margin-bottom: clamp(80px, calc(6.25vw + 60px), 160px); }

/* ── 모달 ── */
.bl_modal_overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2147483640;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.bl_modal_box {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    position: relative;
}
.bl_modal_box.is-dragging { position: fixed; margin: 0; }

.bl_modal_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    cursor: grab;
    user-select: none;
}
.bl_modal_header:active { cursor: grabbing; }

.bl_modal_title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.bl_modal_close {
    width: 28px; height: 28px;
    border: none; background: none;
    font-size: 20px; color: #999;
    cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.bl_modal_close:hover { background: #f0f0f0; color: #555; }

.bl_modal_body { padding: 20px; }

.bl_modal_field { margin-bottom: 14px; }
.bl_modal_field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    margin-bottom: 5px;
}
.bl_modal_field input {
    width: 100%;
    padding: 8px 12px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.bl_modal_field input:focus { border-color: #999; }
.bl_modal_field input[data-type="number"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.bl_modal_footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid #eee;
}

/* ── 토스트 ── */
.bl_toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: #444;
    color: #fff;
    border-radius: 8px;
    font-size: 15px;
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}
.bl_toast.show { transform: translateX(-50%) translateY(0); }

/* ── 반응형 ── */
@media screen and (max-width: 768px) {
    .bl_top_area {
        flex-direction: column;
        align-items: stretch;
    }
    .bl_admin_btns { justify-content: flex-end; }
    .bl_summary_bar { flex-direction: column; }
    .bl_sum_item { border-right: none; border-bottom: 1px solid #e0e0e0; }
    .bl_sum_item:last-child { border-bottom: none; }
}

@media screen and (max-width: 480px) {
    .bl_table th,
    .bl_table td {
        padding: 9px 6px;
        font-size: 13px;
    }
    .bl_table thead th { font-size: 13px; }
}
