/* =========================================================================
   1. ĐỊNH NGHĨA BIẾN MÀU SẮC VÀ ĐĂNG KÝ HỆ THỐNG (CSS VARIABLES)
   ========================================================================= */
:root {
    --primary-color: #1c5399;
    --secondary-bg: #f8f9fa;
    --text-main: #2c3e50;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-green: #2e7d32;
    --success-bg: #f1f8e9;
    --dark-invoice-bg: #1e293b;
    --border-radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Màu trạng thái cốt lõi của sơ đồ ô cờ */
    --bh-blue: #1c5399;
    --bh-blue-dark: #0f2d54;
    --text-dark: #1e293b;
    --text-slate: #64748b;
    --bg-con-trong: #ffffff;
    --border-con-trong: #cbd5e1;
    --bg-da-ban: #fef2f2;
    --border-da-ban: #fca5a5;
    --text-da-ban: #ef4444;
}

/* Khung bọc bảng hàng ngoài trang chính hỗ trợ thanh cuộn ngang di động */
.table-responsive-wrapper,
.cms-bang-hang-wrapper {
    overflow-x: auto; 
    max-width: 100%; 
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius); 
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
}

/* =========================================================================
   2. BỘ ĐIỀU KHIỂN ĐA TIỆN ÍCH NGOÀI BẢNG HÀNG (BỐ CỤC THÁP DỌC)
   ========================================================================= */
.cms-bh-master-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
    align-items: flex-start;
}

/* Thanh tab chuyển đổi kiểu xem */
.cms-bh-switcher-zone {
    display: inline-flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: var(--border-radius);
}
.bh-switch-btn {
    background: transparent; border: none; padding: 8px 16px; font-size: 13px;
    font-weight: 600; color: var(--text-slate); cursor: pointer; border-radius: 6px;
    display: flex; align-items: center; gap: 6px; transition: all 0.2s ease;
    margin: 5px !important;
}
.bh-switch-btn:hover { color: var(--text-dark); }
.bh-switch-btn.active-btn {
    background: #ffffff; color: var(--bh-blue); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

/* Khối chọn phân khu tòa thả xuống mượt mà */
.filter-select-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 320px;
}
.filter-select-label {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-dark);
    white-space: nowrap;
}
#bh_select_toa {
    flex: 1; height: 38px; padding: 0 32px 0 12px; font-size: 13.5px; font-weight: 700;
    color: var(--bh-blue); border: 2px solid var(--bh-blue); border-radius: 6px;
    background: #fff; cursor: pointer; outline: none; -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%231c5399" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat; background-position: right 12px center; background-size: 14px;
}

/* =========================================================================
   3. RE-DESIGN SƠ ĐỒ Ô CỜ (PREMIUM COMPACT & KHỬ HOÀN TOÀN MÀU VÀNG THEME)
   ========================================================================= */
.grid-table-excel {
    width: 100%; border-collapse: separate; border-spacing: 4px; text-align: center; font-size: 13px;
}
.grid-table-excel thead tr td { padding: 6px 10px; font-weight: 600; }
.grid-table-excel .head-row-h td { background: #f8fafc; color: var(--text-slate); font-style: italic; font-size: 11.5px; }
.grid-table-excel .head-row-main td { background: var(--bh-blue); color: #ffffff; font-weight: 700; font-size: 13px; }

/* Ghim chặt biên bên trái và góc lầu khi cuộn ngang */
.grid-table-excel .sticky-corner-header { position: sticky; left: 0; background: #f8fafc; z-index: 5; font-weight: 700; width: 85px; box-shadow: 2px 0 5px rgba(0,0,0,0.03); }
.grid-table-excel .sticky-corner-dark { position: sticky; left: 0; background: var(--bh-blue-dark); color: #fff; z-index: 5; font-weight: 700; box-shadow: 2px 0 5px rgba(0,0,0,0.08); }
.grid-table-excel .sticky-left-floor { position: sticky; left: 0; background: #e2e8f0; color: var(--text-dark); font-weight: 800; z-index: 4; box-shadow: 2px 0 5px rgba(0,0,0,0.03); border-right: 1px solid #cbd5e1; }

/* 🛑 TRIỆT TIÊU HOÀN TOÀN HOVER MÀU VÀNG CỦA THEME CŨ */
.grid-table-excel tbody tr:hover, 
.grid-table-excel tbody tr:hover td { 
    background-color: transparent !important; background: transparent !important; 
}
.grid-table-excel tbody tr:hover td.sticky-left-floor { 
    background-color: #e2e8f0 !important; background: #e2e8f0 !important; 
}

/* THÈ CĂN HỘ CÒN TRỐNG (MÁY TÍNH) */
.grid-cell-apartment {
    background: var(--bg-con-trong); border: 1px solid var(--border-con-trong); padding: 8px 6px !important;
    cursor: pointer; min-width: 95px; height: 56px; vertical-align: middle; display: table-cell; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.grid-cell-apartment .cell-macan { display: block; font-weight: 800; font-size: 13.5px; color: var(--text-dark); letter-spacing: 0.2px; }
.grid-cell-apartment .cell-price { display: block; font-size: 11.5px; color: var(--bh-blue); font-weight: 700; margin-top: 3px; background: #f0f7ff; padding: 1px 4px; border-radius: 4px; display: inline-block; }

/* Hiệu ứng đưa chuột cất cánh nhấc nhẹ card */
.grid-table-excel td.grid-cell-apartment.st-con_trong:hover {
    background-color: #ffffff !important; background: #ffffff !important; border-color: var(--bh-blue) !important;
    transform: translateY(-3px) !important; box-shadow: 0 10px 15px -3px rgba(28, 83, 153, 0.12) !important;
}

/* THẺ CĂN ĐÃ BÁN KHÓA TRỰC GIÁC TUYỆT ĐỐI */
.grid-table-excel tbody tr:hover td.st-da_ban,
.grid-table-excel td.st-da_ban:hover,
.grid-cell-apartment.st-da_ban { 
    background-color: var(--bg-da-ban) !important; border-color: var(--border-da-ban) !important; cursor: not-allowed !important;
    background-image: linear-gradient(45deg, rgba(239, 68, 68, 0.03) 25%, transparent 25%, transparent 50%, rgba(239, 68, 68, 0.03) 50%, rgba(239, 68, 68, 0.03) 75%, transparent 75%, transparent) !important;
    background-size: 12px 12px !important; box-shadow: none !important; transform: none !important;
}
.grid-cell-apartment .cell-macan-sold { display: block; font-weight: 700; font-size: 13px; color: #94a3b8; text-decoration: line-through; }
.grid-cell-apartment .cell-sold-tag { display: block; font-size: 10px; color: var(--text-da-ban); font-weight: 800; margin-top: 3px; background: #fee2e2; padding: 1px 5px; border-radius: 4px; display: inline-block; letter-spacing: 0.3px; }

/* Ô TRỐNG GIẤU HOÀN TOÀN KHÔNG CHO PHẢN ỨNG */
.grid-table-excel tbody tr:hover td.grid-cell-empty,
.grid-table-excel td.grid-cell-empty:hover,
.grid-cell-empty { background: #f8fafc !important; border: 1px solid #f1f5f9 !important; color: transparent !important; pointer-events: none; box-shadow: none !important; }

/* =========================================================================
   4. DẠNG 2: CHI TIẾT BẢNG HÀNG (DANH SÁCH HÀNG NGANG)
   ========================================================================= */
.list-horizontal-table { width: 100%; border-collapse: collapse; font-size: 13.5px; text-align: left; }
.list-horizontal-table th { background: var(--bh-blue); color: #ffffff; padding: 12px 14px; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.list-horizontal-table td { padding: 10px 14px; border-bottom: 1px solid var(--bh-border-light); vertical-align: middle; }
.list-horizontal-table tbody tr:hover { background: #f8fafc; }

.table-tag-macan { background: #eff6ff; color: var(--bh-blue); font-weight: 700; padding: 4px 10px; border-radius: 4px; border: 1px solid #bfdbfe; font-size: 12.5px; }
.cell-double-row { display: flex; flex-direction: column; gap: 3px; }
.cell-double-row .row-main-txt { font-weight: 600; color: var(--text-dark); }
.cell-double-row .row-sub-txt { font-size: 11.5px; color: var(--text-slate); }

.table-badge-huong { background: #f1f5f9; color: #475569; padding: 3px 8px; border-radius: 4px; font-size: 11.5px; font-weight: 500; }
.price-tiendo-bold { font-weight: 700; color: #1e3a8a; font-size: 14px; }
.price-per-meter { font-size: 11.5px; color: #059669; font-weight: 500; }

.bg-light-green { background: #fdfdfd; }
.bg-deep-green { background: #f0fdf4; }
.price-tts-medium { font-weight: 600; color: #166534; }
.price-tts-bold { font-weight: 700; color: #15803d; font-size: 14px; }

.bh-badge-status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-align: center; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-empty { background: #dcfce7; color: #15803d; }
.badge-coc { background: #e2e8f0; color: #475569; }
.badge-ban { background: #fee2e2; color: var(--text-da-ban); }

.bh-btn-action-view { background: #ffffff; border: 1px solid #cbd5e1; color: #475569; padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.2s; text-transform: uppercase; }
.bh-btn-action-view:hover { background: var(--bh-blue); border-color: var(--bh-blue); color: #fff; box-shadow: 0 4px 6px -1px rgba(28, 83, 153, 0.3); }
.table-so-do-co td[data-macan]:hover { transform: none !important; box-shadow: none !important; }

/* =========================================================================
   5. CẤU TRÚC POPUP MÁY TÍNH (MẶC ĐỊNH KIỂU HỘP Ở GIỮA - KHÔNG PHẢI FULL SCREEN)
   ========================================================================= */
.cms-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 99999; opacity: 0; visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.cms-modal-overlay.is-active { opacity: 1; visibility: visible; }

/* Giữ nguyên khuôn mốc hộp 1050px thanh thoát trên PC */
.cms-modal-container {
    background: #ffffff; width: 90%; max-width: 1050px; max-height: 85vh;
    border-radius: calc(var(--border-radius) * 1.5); box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; overflow: hidden;
    transform: scale(0.95); transition: transform 0.3s ease;
}
.cms-modal-overlay.is-active .cms-modal-container { transform: scale(1); }

/* THÂN PHÂN CHIA CHI TIẾT POPUP MÁY TÍNH */
.cms-modal-body { padding: 24px; display: flex; gap: 24px; overflow-y: auto; background: var(--secondary-bg); }
.modal-body-left { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.modal-body-right { width: 360px; flex-shrink: 0; }

.control-card-segment { background: #ffffff; padding: 18px; border-radius: var(--border-radius); border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); }
.control-card-segment h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; margin: 0 0 15px 0; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
.control-card-segment .step-num { background: var(--primary-color); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; }

.modern-radio-group { display: flex; flex-direction: column; gap: 10px; }
.modern-radio-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: #ffffff; border: 2px solid var(--border-color); border-radius: var(--border-radius); cursor: pointer; transition: all 0.2s; }
.modern-radio-card input[type="radio"] { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--primary-color); flex-shrink: 0; }
.modern-radio-card:hover { border-color: #cbd5e1; background: #f8fafc; }
.modern-radio-card:has(input:checked) { border-color: var(--primary-color); background: #f0f7ff; }
.modern-radio-card input[type="radio"]:checked + .card-content .card-title { color: var(--primary-color); }

.modern-checkbox-card { display: flex; align-items: center; gap: 12px; padding: 14px; background: #ffffff; border: 2px solid var(--border-color); border-radius: var(--border-radius); cursor: pointer; transition: all 0.2s; }
.modern-checkbox-card input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--success-green); flex-shrink: 0; }
.modern-checkbox-card:has(input:checked) { border-color: var(--success-green); background: var(--success-bg); }

.card-content { display: flex; flex-direction: column; gap: 3px; }
.card-title { font-weight: 600; font-size: 14px; color: #334155; }
.card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* =========================================================================
   6. FIX LỖI VỠ CHỮ HEADER POPUP: THIẾT KẾ PHẲNG SINGLE-ROW PREMIUM
   ========================================================================= */
.cms-modal-header {
    background: #1e293b !important; 
    padding: 10px 20px !important; 
    height: 52px !important; 
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08); color: #ffffff; flex-shrink: 0;
}
.header-left-workspace {
    display: flex; align-items: center; gap: 8px; 
    overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch;
    padding-right: 40px; 
}
.header-left-workspace::-webkit-scrollbar { display: none; }
.header-building-icon { font-size: 16px; margin-right: 2px; }
.header-main-label { font-size: 13px; font-weight: 500; color: #94a3b8; }

/* Thẻ Tag Mã Căn sắc nét */
.header-tag-premium-macan {
    background: #22c55e !important; color: #ffffff !important; font-weight: 800 !important;
    font-size: 13.5px !important; padding: 3px 10px !important; border-radius: 4px !important;
    letter-spacing: 0.5px; display: inline-block;
}
/* Thẻ thông số phụ mịn màng */
.header-tag-sub-info {
    background: rgba(255, 255, 255, 0.08) !important; color: #f1f5f9 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important; padding: 3px 10px !important;
    border-radius: 4px !important; font-size: 12.5px !important; font-weight: 600 !important;
    display: inline-flex; align-items: center; gap: 4px;
}

/* NÚT ĐÓNG XOAY TRÒN SVG CHỐNG MÉO KHUÔN */
.cms-pure-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    padding: 0;
    flex-shrink: 0;
    right: -10px !important;
    top: 35% !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    min-height: unset !important;
}
.cms-pure-close svg {
    transition: transform 0.3s ease;
    width: 8px;
    height: 10px;
}
.cms-pure-close:hover { background: #ef5350; border-color: #ef5350; box-shadow: 0 4px 12px rgba(239, 83, 80, 0.4); }
.cms-pure-close:hover svg { transform: rotate(90deg); }

/* =========================================================================
   7. KHỐI TRA CỨU MÃ CĂN PHẲNG (TRIỆT TIÊU TOÀN BỘ BOX-SHADOW & MARGIN)
   ========================================================================= */
.modern-search-zone {
    background: #ffffff !important; border: 1px solid var(--border-color) !important; padding: 14px !important;
    box-shadow: none !important; margin-bottom: 0 !important;
}
.search-premium-group {
    display: flex; align-items: center; border: 2px solid #cbd5e1; border-radius: 6px;
    padding: 2px 2px 2px 12px; background: #ffffff; box-shadow: none !important; transition: all 0.2s ease;
}
.search-premium-group:has(input:focus) { border-color: var(--primary-color) !important; box-shadow: none !important; }
.search-inner-icon { font-size: 14px; color: #94a3b8; user-select: none; margin-right: 8px; }

.search-premium-group input[type="text"],
.search-premium-group input[type="text"]:focus,
.search-premium-group input[type="text"]:active {
    flex: 1; border: none !important; outline: none !important; height: 34px; font-size: 13.5px;
    font-weight: 600; color: #1e293b; padding: 0 !important; margin-bottom: 0 !important;
    background: transparent !important; box-shadow: none !important; -webkit-appearance: none !important;
}
.search-premium-group input::placeholder { color: #94a3b8; font-weight: 400; font-size: 13px; }

.search-premium-group button,
.search-premium-group button:focus,
.search-premium-group button:active {
    background: #1e293b; color: #ffffff; border: none; height: 34px; padding: 0 16px;
    font-size: 12.5px; font-weight: 700; text-transform: uppercase; border-radius: 4px;
    cursor: pointer; margin-bottom: 0 !important; margin-right: 0 !important; box-shadow: none !important; outline: none !important;
    transition: background 0.2s ease; white-space: nowrap;
}
.search-premium-group button:hover { background: var(--primary-color); }
.search-msg { font-size: 11.5px; font-weight: 600; margin-top: 6px; padding-left: 24px; }

.event-code-zone { margin-top: 15px; padding-top: 15px; border-top: 1px dashed #e2e8f0; }
.event-code-zone label { display: block; font-size: 12.5px; font-weight: 700; color: #475569; margin-bottom: 6px; }
.event-input-flex { display: flex; gap: 10px; align-items: center; }
.event-input-flex input { flex: 1; height: 36px; padding: 0 12px; border: 2px solid #e2e8f0; border-radius: 4px; font-size: 13px; background: #ffffff; box-shadow: none !important; }
.zalo-contact-btn { display: inline-flex; align-items: center; gap: 5px; background: #0068ff; color: #ffffff !important; padding: 0 12px; height: 36px; border-radius: 4px; font-size: 12px; font-weight: 600; text-decoration: none !important; transition: all 0.2s; white-space: nowrap; flex-shrink: 0; box-shadow: 0 2px 4px rgba(0,104,255,0.2); }
.zalo-contact-btn:hover { background: #0056d6; box-shadow: 0 4px 8px rgba(0,104,255,0.3); }

/* =========================================================================
   8. PHIẾU HÓA ĐƠN TỔNG GIÁ ĐÍCH (STICKY INVOICE)
   ========================================================================= */
.invoice-sticky-card { background: var(--dark-invoice-bg); color: #f8fafc; padding: 22px; border-radius: var(--border-radius); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3); position: sticky; top: 0; }
.invoice-title { margin: 0 0 18px 0; font-size: 13px; font-weight: 700; letter-spacing: 1px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); padding-bottom: 12px; color: #94a3b8; }
.invoice-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 12px; }
.invoice-row span:first-child { color: #cbd5e1; }
.val-neutral { font-weight: 500; color: #f8fafc; }
.val-discount { font-weight: 600; color: #4ade80; }
.invoice-divider { border: 0; border-top: 1px dashed rgba(255, 255, 255, 0.2); margin: 18px 0; }
.invoice-total-block { text-align: center; background: rgba(255, 255, 255, 0.04); padding: 16px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.05); }
.total-label { font-size: 11px; font-weight: 700; color: #cbd5e1; letter-spacing: 1px; }
.total-price-tag { font-size: 26px; font-weight: 800; color: #ff9800; margin: 6px 0; text-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.invoice-note { font-size: 11px; color: #94a3b8; margin: 0; font-style: italic; }
.invoice-debug-box { margin-top: 18px; background: #fffde7; padding: 12px; border-radius: 4px; font-size: 11px; color: #4a5568; line-height: 1.5; border-left: 4px solid #fdd835; box-shadow: none !important; }

/* =========================================================================
   9. VÙNG CHỌN KINH PHÍ BẢO TRÌ INLINE GẠCH SỐ REALTIME TRỰC QUAN
   ========================================================================= */
.invoice-kpbt-toggle-zone {
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px; border-radius: 6px; margin-top: 15px; margin-bottom: 15px; transition: all 0.25s ease;
}
.kpbt-inline-label { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; user-select: none; }
.kpbt-inline-label input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.kpbt-checkbox-mock { width: 16px; height: 16px; border: 2px solid #64748b; border-radius: 3px; display: inline-block; position: relative; transition: all 0.2s ease; flex-shrink: 0; }
.kpbt-checkbox-mock::after { content: ""; position: absolute; display: none; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #ffffff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.kpbt-text-title { font-size: 13px; color: #cbd5e1; font-weight: 500; }
.kpbt-price-display { font-size: 13.5px; font-weight: 600; color: #94a3b8; text-decoration: line-through; opacity: 0.5; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); }

.invoice-kpbt-toggle-zone:has(input:checked) { background: rgba(0, 230, 118, 0.03); border-color: rgba(0, 230, 118, 0.3); }
.invoice-kpbt-toggle-zone input:checked + .kpbt-checkbox-mock { background: #00e676; border-color: #00e676; }
.invoice-kpbt-toggle-zone input:checked + .kpbt-checkbox-mock::after { display: block; }
.invoice-kpbt-toggle-zone input:checked ~ .kpbt-text-title { color: #ffffff; }
.invoice-kpbt-toggle-zone:has(input:checked) .kpbt-price-display { color: #00e676; text-decoration: none; opacity: 1; transform: scale(1.03); }

/* =========================================================================
   10. BẢNG PHÂN RÃ TÀI CHÍNH ĐỘNG (FINANCE PANEL MINI)
   ========================================================================= */
.invoice-finance-actions-zone { margin-top: 15px; display: flex; flex-direction: column; gap: 8px; }
.finance-trigger-btn { width: 100%; padding: 10px; font-size: 12.5px; font-weight: 700; border: 1px solid transparent; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.2s ease; }
.btn-blue-outline { background: rgba(255,255,255,0.05); color: #cbd5e1; border-color: rgba(255,255,255,0.15); }
.btn-blue-outline:hover { background: var(--bh-blue); color: #fff; border-color: var(--bh-blue); }
.btn-orange-outline { background: rgba(255, 152, 0, 0.1); color: #ff9800; border-color: rgba(255, 152, 0, 0.3); }
.btn-orange-outline:hover { background: #ff9800; color: #fff; border-color: #ff9800; }

.finance-expand-panel { background: #ffffff; border: 1px solid var(--border-color); border-radius: var(--border-radius); margin-top: 15px; display: none; box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-header-flex { background: #f8fafc; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }
.panel-header-flex h4 { margin: 0; font-size: 12.5px; font-weight: 700; color: #1e293b; }
#btn_close_finance_panel { background: transparent; border: none; font-size: 20px; cursor: pointer; color: #94a3b8; line-height: 1; }
#btn_close_finance_panel:hover { color: #ef4444; }
.panel-content-scroll { padding: 14px; max-height: 250px; overflow-y: auto; font-size: 12px; }
.finance-mini-table { width: 100%; border-collapse: collapse; text-align: left; }
.finance-mini-table th { background: #f1f5f9; padding: 8px; font-weight: 600; color: #475569; }
.finance-mini-table td { padding: 8px; border-bottom: 1px solid #f1f5f9; color: #334155; }

/* Laptop 13-14 inch */
@media (max-width: 1366px) {
    .modal-body-left { flex: 0 0 60%; }
    .modal-body-right { width: 40%; flex-shrink: 0; }
}
@media (max-width: 992px) {
    .cms-modal-body { flex-direction: column; }
    .modal-body-right { width: 100%; }
    .cms-modal-container { max-height: 90vh; width: 95%; }
}

/* =========================================================================
   📱 11. KÍCH HOẠT CHẾ ĐỘ WORKSPACE TRÀN VIỀN ĐỘC QUYỀN TRÊN DI ĐỘNG (MOBILE)
   ========================================================================= */
@media (max-width: 767px) {
    /* Đóng băng overscroll giật trang nền */
    .cms-modal-overlay { padding: 0 !important; align-items: flex-start !important; overscroll-behavior: contain; }
    
    /* Ép container chiếm kín khít 100% màn hình thiết bị, xóa bo tròn */
    .cms-modal-container { 
        width: 100vw !important; height: 100vh !important; max-height: 100vh !important; 
        border-radius: 0 !important; margin: 0 !important; 
    }
    
    .cms-modal-header { padding: 10px 14px !important; height: 50px; }
    .cms-modal-header h2 { font-size: 12.5px !important; }
    
    /* Đổ dọc cột nhập liệu và hóa đơn tính toán, kích hoạt cuộn quán tính iOS */
    .cms-modal-body { flex-direction: column !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; padding: 0 !important; }
    
    /* Thu hẹp padding từ 30px xuống 14px ôm vừa sát mép kính điện thoại */
    .modal-body-left { flex: none !important; width: 100% !important; grid-template-columns: 1fr !important; gap: 12px !important; padding: 14px !important; background: #f1f5f9; }
    .modal-body-right { flex: none !important; width: 100% !important; padding: 14px !important; background: #ffffff; border-top: 2px dashed var(--border-color); }
    
    /* Thu nhỏ khoảng cách các card */
    .modern-radio-card, .modern-checkbox-card { padding: 10px !important; }
    .invoice-sticky-card { position: static !important; box-shadow: none !important; }
    
    /* Cấu trúc thu nhỏ thẻ Header trên màn hình cực hẹp */
    @media (max-width: 375px) {
        .header-main-label { display: none; } 
        .header-tag-premium-macan, .header-tag-sub-info { font-size: 11.5px !important; padding: 2px 6px !important; }
    }
}

/* =========================================================================
   📱 TỐI ƯU BIẾN BẢNG HÀNG NGANG THÀNH THẺ DANH SÁCH TRÊN MOBILE (DƯỚI 767PX)
   ========================================================================= */
@media (max-width: 767px) {
    /* Ẩn hoàn toàn thanh tiêu đề thô cũ của bảng */
    .list-horizontal-table thead {
        display: none !important;
    }

    /* Biến mỗi dòng <tr> thành một hộp Card độc lập, có khoảng cách */
    .list-horizontal-table tbody, 
    .list-horizontal-table tr.horizontal-row-item {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    .list-horizontal-table tr.horizontal-row-item {
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 8px !important;
        padding: 12px !important;
        margin-bottom: 12px !important;
        gap: 8px !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.02) !important;
    }

    /* Ép tất cả các ô <td> biến thành các khối inline tự do */
    .list-horizontal-table tr.horizontal-row-item td {
        display: block !important;
        padding: 0 !important;
        border: none !important;
        width: 100% !important;
        background: transparent !important;
    }

    /* TẦNG 1: Dòng đầu tiên chứa Mã căn, Hướng và Badge Trạng thái */
    .list-horizontal-table tr.horizontal-row-item td:nth-child(1) {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 4px;
    }
    
    /* Đẩy badge trạng thái và hướng lên chung dòng với mã căn */
    .list-horizontal-table tr.horizontal-row-item td:nth-child(3) { 
        display: inline-block !important;
        width: auto !important;
    }

    /* TẦNG 2: Khu vực cấu hình diện tích */
    .list-horizontal-table tr.horizontal-row-item td:nth-child(2) {
        margin-bottom: 8px;
    }
    .list-horizontal-table .cell-double-row .row-sub-txt {
        font-size: 12px !important;
        color: #64748b !important;
    }

    /* TẦNG 3: KHỐI GIÁ BAO PHỦ (Biến 3 cột giá thành 3 cột nhỏ song song gọn gàng) */
    .list-horizontal-table tr.horizontal-row-item td:nth-child(4),
    .list-horizontal-table tr.horizontal-row-item td:nth-child(5),
    .list-horizontal-table tr.horizontal-row-item td:nth-child(6) {
        background: #f8fafc !important;
        padding: 8px !important;
        border-radius: 4px !important;
        margin-bottom: 4px;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    /* Tạo nhãn giả bằng CSS để Sale đọc vẫn hiểu đây là giá gì */
    .list-horizontal-table tr.horizontal-row-item td:nth-child(4)::before { content: "Giá Tiến độ:"; font-size: 11px; color: #64748b; font-weight: 600; }
    .list-horizontal-table tr.horizontal-row-item td:nth-child(5)::before { content: "Sớm (Chưa KPBT):"; font-size: 11px; color: #64748b; font-weight: 600; }
    .list-horizontal-table tr.horizontal-row-item td:nth-child(6)::before { content: "Sớm (Có KPBT):"; font-size: 11px; color: #64748b; font-weight: 600; }

    /* Ép nút bấm thao tác chiếm trọn chiều rộng để ngón tay dễ chạm gõ */
    .list-horizontal-table tr.horizontal-row-item td:nth-child(8) {
        margin-top: 8px !important;
    }
    .list-horizontal-table .bh-btn-action-view {
        width: 100% !important;
        height: 36px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 13px !important;
    }
}

/* =========================================================================
   📋 ĐÈ MẠNH LAYOUT TỐI CAO: PHẲNG HÀNG NGANG MÁY TÍNH (CẤU TRÚC 7 CỘT MỚI)
   ========================================================================= */

/* A. ĐỒNG BỘ TRÊN CẢ PC VÀ MOBILE: KHÔNG CHO PHÉP XUỐNG DÒNG */
div#view-hang-ngang table.list-horizontal-table th,
div#view-hang-ngang table.list-horizontal-table td {
    white-space: nowrap !important; /* Cấm tuyệt đối gãy dòng dữ liệu trên mọi thiết bị */
}

/* =========================================================================
   💎 TỐI ƯU BORDER & HIỆU ỨNG HOVER NỔI MÀU HIỆN ĐẠI CHO BẢNG CHI TIẾT
   ========================================================================= */

/* 1. Thiết lập lại Border tinh tế và màu nền mặc định cho bảng */
div#view-hang-ngang table.list-horizontal-table {
    border-collapse: collapse !important; /* Bắt buộc để border giữa các hàng không bị tách đôi */
    background: #ffffff;
}

/* Định cấu hình border nhẹ nhàng cho tất cả các ô dữ liệu */
div#view-hang-ngang table.list-horizontal-table th,
div#view-hang-ngang table.list-horizontal-table td {
    border-bottom: 1px solid #e2e8f0 !important; /* Border ngang siêu mảnh, hiện đại */
    border-top: 1px solid #e2e8f0 !important;
}

/* 3. HIỆU ỨNG HOVER NỔI MÀU ĐỒNG BỘ TOÀN HÀNG (TR) */
/* Đổi màu nền của dòng tr sang màu xám mờ xanh nhẹ nhàng khi chuột rê vào */
div#view-hang-ngang table.list-horizontal-table tbody tr.horizontal-row-item:hover {
    background-color: #f1f5f9 !important; /* Màu hover phong cách tối giản hiện đại */
}

/* 🔥 LÕI ÉP CÁC CỘT CÓ MÀU CỐ ĐỊNH PHẢI ĐỔI MÀU THEO HÀNG KHI HOVER */
div#view-hang-ngang table.list-horizontal-table tbody tr.horizontal-row-item:hover td {
    background-color: inherit !important; /* Buộc tất cả td thừa hưởng màu nền từ tr:hover */
}

/* Loại trừ các căn đã bán (background: #fff5f5) không cho đổi màu hover để giữ tính cảnh báo */
div#view-hang-ngang table.list-horizontal-table tbody tr.horizontal-row-item[style*="background: #fff5f5"]:hover td {
    background-color: #fff5f5 !important;
    opacity: 0.85;
}

/* =========================================================================
   ⚡ ĐỘC QUYỀN XỬ LÝ TOÀN DIỆN CHO DI ĐỘNG (MOBILE ĐÃ GOM GỌN BLOCK CHUẨN)
   ========================================================================= */
@media (max-width: 767px) {
    
    /* 1. Ép phân khu bọc ngoài cùng biến thành "Máng trượt" duy nhất */
    div#view-hang-ngang {
        display: block !important;
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: auto !important; /* Kích hoạt sinh làn cuộn ngang khi vuốt */
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important; /* Vuốt mượt trên iPhone */
    }

    /* 2. Ép các lớp bọc phụ trung gian nhả biên, không được chặn hành trình cuộn */
    div#view-hang-ngang .table-responsive-wrapper,
    div#view-hang-ngang .cms-bang-hang-wrapper {
        display: block !important;
        width: max-content !important; /* Nới rộng vô cực theo ruột bảng */
        max-width: none !important;
        overflow: visible !important;
        border: none !important;
    }

    /* 3. RUỘT BẢNG: Do bớt 1 cột giá nên thu gọn tổng chiều rộng xuống 1100px là tỷ lệ vàng, cực thoáng */
    div#view-hang-ngang table.list-horizontal-table {
        display: table !important;
        table-layout: fixed !important; /* Khóa chết tỷ lệ cột cố định, phá vỡ mọi flex/block đè dọc cũ */
        width: 1100px !important;       
        min-width: 1100px !important;
        max-width: none !important;
    }

    /* Khóa chết cơ chế nhóm dòng (Row Group) truyền thống */
    div#view-hang-ngang table.list-horizontal-table thead { display: table-header-group !important; }
    div#view-hang-ngang table.list-horizontal-table tbody { display: table-row-group !important; }
    
    /* 4. Ép mọi hàng tr và ô td biến thành các ô cờ độc lập, KHÔNG ĐÈ NHAU */
    div#view-hang-ngang table.list-horizontal-table tr.horizontal-row-item { 
        display: table-row !important; 
        float: none !important;
    }
    div#view-hang-ngang table.list-horizontal-table tr.horizontal-row-item td,
    div#view-hang-ngang table.list-horizontal-table thead tr th { 
        display: table-cell !important;
        float: none !important;
        padding: 12px 14px !important; /* Nới rộng padding đệm lót giữa các ô số */
        vertical-align: middle !important;
        position: relative !important;
    }

    /* 5. PHÂN BỔ LẠI DIỆN TÍCH ĐẤT CHO ĐỦ 7 CỘT MỚI - CHẤM DỨT TÌNH TRẠNG LỆCH CỘT */
    div#view-hang-ngang table.list-horizontal-table th:nth-child(1),
    div#view-hang-ngang table.list-horizontal-table td:nth-child(1) { width: 140px !important; } /* Cột 1: Mã căn (1PN+1) */
    div#view-hang-ngang table.list-horizontal-table th:nth-child(2),
    div#view-hang-ngang table.list-horizontal-table td:nth-child(2) { width: 240px !important; } /* Cột 2: Cấu hình căn hộ / DT */
    div#view-hang-ngang table.list-horizontal-table th:nth-child(3),
    div#view-hang-ngang table.list-horizontal-table td:nth-child(3) { width: 90px !important; }  /* Cột 3: Hướng */
    div#view-hang-ngang table.list-horizontal-table th:nth-child(4),
    div#view-hang-ngang table.list-horizontal-table td:nth-child(4) { width: 165px !important; } /* Cột 4: Giá tiến độ đ */
    div#view-hang-ngang table.list-horizontal-table th:nth-child(5),
    div#view-hang-ngang table.list-horizontal-table td:nth-child(5) { width: 165px !important; } /* Cột 5: Sớm chưa KPBT */
    div#view-hang-ngang table.list-horizontal-table th:nth-child(6),
    div#view-hang-ngang table.list-horizontal-table td:nth-child(6) { width: 115px !important; } /* Cột 6: Trạng thái (Đã đôn lên thay thế) */
    div#view-hang-ngang table.list-horizontal-table th:nth-child(7),
    div#view-hang-ngang table.list-horizontal-table td:nth-child(7) { width: 105px !important; } /* Cột 7: Nút chi tiết */

    /* 🛑 TRIỆT TIÊU HOÀN TOÀN CÁC NHÃN GIẢ (:BEFORE) CỦA CODE CŨ GÂY CHỒNG CHỮ TRẠNG THÁI */
    div#view-hang-ngang table.list-horizontal-table tr.horizontal-row-item td::before {
        display: none !important;
        content: "" !important;
    }

    /* ⚡ KHỬ TIỀN TỐ DÀI DÒNG CỦA RIÊNG CỘT GIÁ ĐÓNG SỚM (CỘT 5) ĐỂ SỐ TIỀN KHÔNG BỊ XUỐNG DÒNG */
    div#view-hang-ngang table.list-horizontal-table td.bg-light-green {
        font-size: 0 !important; /* Ẩn chữ thô "Sớm (Chưa KPBT):" */
        color: transparent !important;
    }
    div#view-hang-ngang table.list-horizontal-table td.bg-light-green .price-tts-medium {
        font-size: 13px !important; /* Trả lại cỡ chữ chuẩn riêng cho con số tiền tỷ */
        color: #166534 !important;  
        font-weight: 700 !important;
        display: inline-block !important;
        white-space: nowrap !important; /* Khóa chết chống nhảy dòng số tiền */
    }

    /* Khử triệt để lỗi dòng chữ kép (Tên căn hộ / Diện tích) bị bẻ chồng lên cột giá */
    div#view-hang-ngang .cell-double-row {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 3px !important;
        width: 100% !important;
    }

    /* Thu nhẹ cỡ chữ hệ thống trên Mobile giúp dải số thanh thoát */
    div#view-hang-ngang table.list-horizontal-table td { font-size: 12px !important; }
    div#view-hang-ngang .price-tiendo-bold,
    div#view-hang-ngang .price-tts-bold { font-size: 13px !important; }

    /* Định hình lại nút Chi tiết */
    div#view-hang-ngang .bh-btn-action-view {
        width: auto !important;
        padding: 5px 14px !important;
        font-size: 11px !important;
        height: 28px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}