* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    overflow: hidden; /* vừa 1 màn hình, không cuộn dọc */
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    font-size: 13px;
    color: #1f2d3d;
    background: #eaf0f8;
}

/* Cột dọc full chiều cao: header + KPI giữ chiều cao tự nhiên, lưới 2x2 chiếm phần còn lại */
.dashboard-container { height: 100vh; padding: 8px; display: flex; flex-direction: column; }

/* Thanh tiêu đề + các tab */
.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    padding: 6px 14px;
    background: #fff;
    border-radius: 8px;
}
.dash-header h1 { margin: 0; font-size: 16px; letter-spacing: 0.3px; color: #0b5cad; }
.dash-tabs { display: flex; gap: 6px; }
.dash-tab {
    padding: 6px 14px;
    border: 1px solid #c5d3e4;
    border-radius: 6px;
    background: #f5f8fc;
    font: inherit;
    font-weight: 600;
    color: #3c4a5c;
    cursor: pointer;
}
.dash-tab:hover { background: #e6f0fb; }
.dash-tab.active { background: #0b5cad; border-color: #0b5cad; color: #fff; }
/* Nhãn năm hiện tại + icon lọc để chọn năm khác, đặt trước tab đầu tiên */
.dash-year-filter { position: relative; display: flex; align-items: center; gap: 6px; }
.dash-year-filter-btn {
    padding: 6px 10px;
    border: 1px solid #c5d3e4;
    border-radius: 6px;
    background: #f5f8fc;
    font: inherit;
    color: #3c4a5c;
    cursor: pointer;
}
.dash-year-filter-btn:hover, .dash-year-filter-btn.open { background: #e6f0fb; }
.dash-year {
    padding: 6px 14px;
    border: 1px solid #a9c6ea;
    border-radius: 6px;
    background: #eaf2fb;
    font-weight: 700;
    color: #0b5cad;
}
.dash-year-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 240px;
    max-height: 340px;
    overflow: auto;
    background: #fff;
    border: 1px solid #c5d3e4;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
    z-index: 50;
}
.dash-year-dropdown.open { display: block; }
/* Panel của icon phễu gồm 2 combobox xếp dọc: Năm, Chủ đầu tư; áp dụng cho toàn bộ các tab */
.dash-cdt-filter { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; font-weight: 600; color: #3c4a5c; }
.dash-cdt-filter + .dash-cdt-filter { border-top: 1px solid #e1e8f1; }
/* Nút Tìm kiếm: chỉ khi bấm mới áp dụng Năm + Chủ đầu tư đang chọn */
.dash-filter-actions { padding: 8px 10px 10px; border-top: 1px solid #e1e8f1; }
.dash-search-btn {
    width: 100%;
    padding: 7px 12px;
    border: 0;
    border-radius: 6px;
    background: #0b5cad;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.dash-search-btn:hover { background: #094a8c; }
.dash-cdt-filter select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #a9c6ea;
    border-radius: 6px;
    background: #eaf2fb;
    font: inherit;
    font-weight: 700;
    color: #0b5cad;
    cursor: pointer;
}

/* ===== Tab Tổng quan ===== */
.tq-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 8px; }
#ntKpis { grid-template-columns: repeat(4, 1fr); }
.tq-kpi { display: flex; gap: 10px; padding: 8px 12px; background: #fff; border-radius: 8px; border-left: 3px solid var(--c); }
.tq-kpi-icon {
    flex: none; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
    border-radius: 10px; background: color-mix(in srgb, var(--c) 14%, #fff); color: var(--c); font-size: 17px;
}
.tq-kpi-body { min-width: 0; }
.tq-kpi-label { font-size: 12px; font-weight: 700; color: #1f2d3d; }
.tq-kpi-note { font-size: 9px; color: #8a97a8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tq-kpi-value { margin-top: 4px; font-size: 22px; font-weight: 700; color: #111c2b; line-height: 1.1; }
.tq-kpi-value-text { font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tq-kpi-unit { font-size: 10px; color: #6b7a8e; }

.tq-charts { flex: 1.1; min-height: 0; display: grid; grid-template-columns: 1fr 1.2fr; gap: 8px; margin-bottom: 8px; }
.tq-card { min-height: 0; display: flex; flex-direction: column; padding: 8px 12px; background: #fff; border-radius: 8px; }
.tq-title { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: #111c2b; display: flex; align-items: center; gap: 8px; }
.tq-title i { color: #1a6fb5; }
.tq-subtitle { margin: 0 0 8px; font-size: 12px; color: #8a97a8; }
.tq-chip { margin-left: auto; padding: 1px 10px; border-radius: 10px; background: #eef2f7; font-size: 11px; color: #5a6a7e; }
.tq-chart { flex: 1; min-height: 0; min-width: 0; }
/* Chú giải bên trái biểu đồ pie: mỗi mục 1 dòng, rộng đúng bằng nội dung dài nhất (không ngắt từng chữ) */
.tq-pie-row { flex: 1; min-height: 0; display: flex; align-items: stretch; gap: 12px; }
.tq-legend { flex: none; align-self: center; margin: 0; padding: 0 0 0 4px; list-style: none; }
.tq-legend li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12px; color: #3c4a5c; white-space: nowrap; }
.tq-legend i { flex: none; width: 12px; height: 12px; border-radius: 3px; }
.tq-legend b { color: #111c2b; }
.tq-map-card { flex: 1; }
.tq-map-wrap { position: relative; flex: 1; min-height: 0; border-radius: 6px; overflow: hidden; }
#tqMap { position: absolute; inset: 0; }
.tq-map-stats {
    position: absolute; left: 10px; bottom: 10px; z-index: 500; padding: 6px 12px;
    background: rgba(255, 255, 255, 0.92); border-radius: 6px; font-size: 12px; color: #4a5a6e; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.tq-map-stats strong { margin-left: 4px; font-size: 16px; color: #2b7bff; }
/* Ghim đỏ kiểu Google Maps: giọt nước xoay 45°, số dự án trong vòng tròn trắng */
.tq-gpin-wrap { background: transparent; border: 0; }
.tq-gpin {
    position: relative; width: 30px; height: 30px; margin: 0 auto;
    background: #ea4335; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45); border: 1px solid #b3261e;
}
.tq-gpin span {
    position: absolute; inset: 5px; display: flex; align-items: center; justify-content: center;
    background: #fff; border-radius: 50%; transform: rotate(45deg);
    font-size: 12px; font-weight: 700; color: #b3261e;
}
/* Tên địa danh cạnh ghim: chữ đậm có viền trắng như nhãn địa danh của Google Maps */
.leaflet-tooltip.tq-place {
    display: none; padding: 0; background: transparent; border: 0; box-shadow: none;
    font-size: 11px; font-weight: 600; color: #3c4043;
    text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 0 0 3px #fff;
}
.leaflet-tooltip.tq-place::before { display: none; }
.tq-show-labels .leaflet-tooltip.tq-place { display: block; }

/* ===== Tab Tổng mức đầu tư ===== */
.tm-row { flex: 1; min-height: 0; display: grid; gap: 8px; margin-bottom: 8px; }
.tm-row-1 { grid-template-columns: 1fr 1fr; }
.tm-row-2 { grid-template-columns: 1fr 1fr; margin-bottom: 0; }
.tm-pies { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tm-pies.tm-pies-3 { grid-template-columns: repeat(3, 1fr); }
.tm-pie { min-height: 0; display: flex; flex-direction: column; }
.tm-pie h3 { margin: 0; text-align: center; font-size: 12px; font-weight: 700; color: #111c2b; }

/* ===== Tab KH vốn trung hạn ===== */
.kh-row-1 { grid-template-columns: 1fr 1fr; flex: 1.5; }
.kh-row-2 { flex: 1; margin-bottom: 0; }

/* ===== Tab Vốn đã giải ngân ===== */
.vgn-row-1 { grid-template-columns: 1fr 1fr; flex: 1; }
.vgn-row-2 { grid-template-columns: 1fr; flex: 1; margin-bottom: 0; }

/* ===== Tab Vốn đã cấp ===== */
.vdc-row-1 { grid-template-columns: 1fr 1fr; flex: 1; }
.vdc-row-2 { grid-template-columns: 1fr; flex: 1; margin-bottom: 0; }

/* ===== Tab Quyết toán ===== */
.nt-row-1 { grid-template-columns: 1fr 1fr; flex: 1; }
.nt-row-2 { grid-template-columns: 1fr 1fr; flex: 1; margin-bottom: 0; }
.qt-row-1 { grid-template-columns: 1fr 1fr; flex: 1; }
.qt-row-2 { grid-template-columns: 1fr 1fr; flex: 1; margin-bottom: 0; }
.kh-table-wrap { flex: 1; min-height: 0; overflow: auto; }
.kh-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kh-table th, .kh-table td { padding: 9px 14px; text-align: right; border-bottom: 1px solid #edf1f6; font-variant-numeric: tabular-nums; }
.kh-table th:first-child, .kh-table td:first-child { text-align: left; }
.kh-table thead th { background: #f3f5f8; color: #5a6a7e; font-weight: 600; }
.kh-table tbody tr:hover { background: #f8fafc; }
.kh-table tr.total td { font-weight: 700; color: #111c2b; border-top: 1px solid #d5dce6; border-bottom: 0; }
/* Bảng Top 5 (TMĐT, gói thầu): chỉ 5 dòng nên giãn đều theo chiều cao khung thay vì dồn lên trên, chừa khoảng trống dưới */
#tmTopTable, #lcntTopTable { height: 100%; }
#tmTopTable tbody tr, #lcntTopTable tbody tr { height: 20%; }

/* ===== Tab Lựa chọn nhà thầu ===== */
.lcnt-row-1 { grid-template-columns: 1fr 1fr; flex: 1; }
.lcnt-row-2 { grid-template-columns: 1fr 1fr; flex: 1; margin-bottom: 0; }
.lcnt-pie-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lcnt-pie-card .tq-chart { flex: 1 1 75%; min-width: 120px; }

/* Nút Tạm dừng / Tiếp tục tự động chuyển tab */
.auto-toggle {
    margin-left: 6px;
    padding: 6px 14px;
    border: 1px solid #e0594b;
    border-radius: 6px;
    background: #fff4f2;
    font: inherit;
    font-weight: 700;
    color: #d6402f;
    cursor: pointer;
}
.auto-toggle:hover { background: #ffe6e2; }
.auto-toggle.paused { border-color: #1f9d55; background: #effaf3; color: #1f9d55; }

/* Thanh tiến trình trên cùng: đầy dần trong 10 giây rồi chuyển tab */
.auto-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 900; background: transparent; }
#autoProgressBar { height: 100%; width: 0; background: #1f9d55; transition: width 0.1s linear; }

/* Mỗi tab là 1 pane chiếm phần còn lại của màn hình */
.tab-pane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tab-pane.active { display: flex; }
.tab-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 8px;
    font-size: 16px;
    color: #8a97a8;
}

/* Hàng thẻ KPI: 4 thẻ, mỗi giai đoạn 1 thẻ — style dùng chung .tq-kpi của tab Tổng quan */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
/* Tab Lựa chọn nhà thầu: 6 thẻ KPI thay vì 4 (thêm Nhà thầu trúng thầu, Tổng giá trị Hợp đồng) */
#lcntKpis { grid-template-columns: repeat(6, 1fr); }

/* Lưới 2x2 các vùng */
.zone-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 8px; }
.zone { min-height: 0; display: flex; flex-direction: column; padding: 8px 10px 4px; background: #fff; border-radius: 8px; }
.zone-title {
    margin: 0 0 2px;
    padding-left: 8px;
    border-left: 3px solid var(--zone-color);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    color: #1f2d3d;
}
.zone-charts { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.chart-card { min-height: 0; display: flex; flex-direction: column; }
.chart-card h3 { margin: 2px 0 0; text-align: center; font-size: 13px; font-weight: 700; color: #111c2b; }
.chart-box { flex: 1; min-height: 0; }
/* Thẻ KPI bấm được */
.kpi-card { cursor: pointer; transition: box-shadow 0.2s, transform 0.2s; }
.kpi-card:hover { box-shadow: 0 3px 10px rgba(11, 92, 173, 0.18); transform: translateY(-1px); }

/* Panel trượt từ phải: danh sách dự án chi tiết */
.project-panel { position: fixed; inset: 0; z-index: 1000; visibility: hidden; transition: visibility 0.3s; }
.project-panel.open { visibility: visible; }
.panel-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); opacity: 0; transition: opacity 0.3s; }
.project-panel.open .panel-overlay { opacity: 1; }
.panel-content {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: min(980px, 94vw);
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
.project-panel.open .panel-content { transform: translateX(0); }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #e3eaf3; }
.panel-header h3 { margin: 0; font-size: 15px; color: #0b5cad; }
.panel-close { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: #5a6a7e; }
.panel-close:hover { color: #111c2b; }
.panel-table-wrap { flex: 1; min-height: 0; overflow: auto; }
.panel-table { width: 100%; border-collapse: collapse; }
.panel-table th, .panel-table td { padding: 8px 10px; border-bottom: 1px solid #edf1f6; text-align: left; vertical-align: top; }
.panel-table th { position: sticky; top: 0; background: #f2f6fb; font-size: 12px; z-index: 1; }
.panel-table tbody tr:hover { background: #f7fbff; }
.panel-table .c { text-align: center; }
.panel-table .r { text-align: right; }
.panel-table .empty { text-align: center; color: #999; padding: 24px; }
.panel-footer { padding: 10px 16px; border-top: 1px solid #e3eaf3; background: #f7fafd; }

/* Bóng đổ rõ cho các biểu đồ 3D ở tab Tổng quan và Tổng mức đầu tư (cột/thanh đổ xuống phía dưới bên phải) */
.tq-chart .highcharts-series-group { filter: drop-shadow(2px 4px 4px rgba(0, 0, 0, 0.16)); }

/* Bóng đổ mềm dưới khối 3D như mẫu */
.chart-box .highcharts-series-group { filter: drop-shadow(0 14px 10px rgba(0, 0, 0, 0.28)); }

/* STT dạng vòng tròn cam, số trắng đậm (bảng Top 5) */
.stt-badge { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: #ffa91f; color: #fff; font-weight: 700; font-size: 13px; }
