/* ==============================
   QLN - Quản lý nước
   Main Stylesheet
   ============================== */

/* ---- Full-page background image (desktop only) ---- */
body {
    background: url("../image/kinhthanh.jpeg") no-repeat center top / cover fixed;
    min-height: 100vh;
}

@media (max-width: 640px) {
    html, body {
        background: #ddeef8 !important;
        background-image: none !important;
        overflow-x: hidden;
    }
    #pagebody {
        background: #ddeef8;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
}

/* ---- Header blur (QLN page override) ---- */
header #web-head {
    background: rgba(255, 255, 255, 0.55) !important;
    backdrop-filter: blur(14px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(14px) saturate(180%) !important;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.15);
}

/* ---- Footer blur ---- */
#footer {
    background: rgba(255, 255, 255, 0.55) !important;
    backdrop-filter: blur(14px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(14px) saturate(180%) !important;
}

#footer .footer-top,
#footer .footer-bottom {
    background: transparent !important;
}

/* ---- Pagebody: bù cho header position:absolute, giữ footer luôn dưới ---- */
#pagebody {
    padding-top: 120px;
    min-height: 100vh;          /* giữ footer luôn ở cười trang */
    display: flex;
    flex-direction: column;
}

/* ---- Section ---- */
.qln-section {
    background: transparent;
    padding: 28px 20px 40px;
    flex: 1;                    /* đẩy footer xuống đáy */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ---- Default: cards grid ---- */
.qln-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
    max-width: 1200px;
    margin: 0 auto;
    transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.32s ease;
    transform-origin: top center;
    max-height: 2000px;
    opacity: 1;
    overflow: hidden;
}

/* Khi đang expand: grid thu nhỏ rồi ẩn */
.qln-section.expanding .qln-cards-grid {
    opacity: 0;
    transform: scale(0.94) translateY(-10px);
    max-height: 0;
    pointer-events: none;
}

.qln-section.expanded .qln-cards-grid {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ---- Horizontal nav tabs ---- */
.qln-navbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 10px 14px;
    margin-bottom: 18px;
    /* Trạng thái ẩn mặc định */
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    overflow: hidden;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.25s ease 0.16s,
                max-height 0.3s ease 0.13s,
                transform 0.25s ease 0.16s,
                padding 0.2s ease 0.13s,
                margin-bottom 0.2s ease 0.13s;
}

/* Navbar xuất hiện sau khi grid ẩn đi */
.qln-section.expanded .qln-navbar {
    opacity: 1;
    max-height: 200px;
    padding: 10px 14px;
    margin-bottom: 18px;
    transform: translateY(0);
    pointer-events: auto;
}

.qln-navtab {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 30px;
    padding: 6px 14px 6px 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 160px;
}

.qln-navtab:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
}

.qln-navtab[data-category="cap-nuoc"].active  { border-color: #1565c0; background: #fff; }
.qln-navtab[data-category="khi-tuong"].active  { border-color: #00838f; background: #fff; }
.qln-navtab[data-category="chat-luong"].active { border-color: #2e7d32; background: #fff; }
.qln-navtab[data-category="ung-pho"].active    { border-color: #bf360c; background: #fff; }

.qln-navtab-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    color: #fff;
    flex-shrink: 0;
}

.qln-navtab span {
    font-size: 0.72rem;
    font-weight: 600;
    color: #1a2a3a;
    line-height: 1.3;
}

/* ---- Content area ---- */
.qln-content-area {
    display: block;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 28px 32px;
    min-height: 480px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.13);
    /* Trạng thái ẩn mặc định */
    opacity: 0;
    max-height: 0;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    transform: translateY(14px);
    pointer-events: none;
    transition: opacity 0.28s ease 0.28s,
                max-height 0.35s ease 0.25s,
                min-height 0.35s ease 0.25s,
                padding 0.2s ease 0.25s,
                transform 0.28s ease 0.28s;
}

/* Content area hiện ra sau navbar */
.qln-section.expanded .qln-content-area {
    opacity: 1;
    max-height: 9999px;
    min-height: 480px;
    padding: 28px 32px;
    transform: translateY(0);
    pointer-events: auto;
}

.qln-content-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0a4d8c;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid #e9ecef;
    line-height: 1.4;
}

/* Back button (inside navbar) */
.qln-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1.5px solid rgba(0,0,0,0.5);
    color: #1a1a1a;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    margin-right: auto;
    order: -1;
}

.qln-back-btn:hover {
    background: rgba(0,0,0,0.08);
}

/* ---- Card ---- */
.qln-card {
    position: relative;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.14);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.35s cubic-bezier(0.4,0,0.2,1),
                box-shadow 0.35s ease,
                opacity 0.35s ease,
                scale 0.35s cubic-bezier(0.4,0,0.2,1);
    display: flex;
    flex-direction: column;
    transform-origin: top center;
}

.qln-card:hover:not(.qln-card--selected) {
    transform: translateY(-6px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.13);
}

/* Card được chọn: zoom nhẹ rồi sẽ biến mất */
.qln-card--selected {
    transform: scale(0.96) translateY(-4px);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
    z-index: 2;
}

/* Các card khác khi đang expanding: mờ dần */
.qln-section.expanding .qln-card:not(.qln-card--selected) {
    opacity: 0.3;
    transform: scale(0.95);
    transition-delay: 0.03s;
}

/* Card được chọn đang expanding: thu nhỏ nhanh lên phía trên */
.qln-section.expanding .qln-card--selected {
    opacity: 0;
    transform: scale(0.62) translateY(-36px);
    transition-duration: 0.26s;
}

.qln-card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 28px 28px 20px;
}

/* Accent stripe at top */
.qln-card-accent {
    height: 5px;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 16px 16px 0 0;
}

.qln-accent-blue   { background: linear-gradient(90deg, #0a4d8c, #2196f3); }
.qln-accent-teal   { background: linear-gradient(90deg, #007c8a, #00bcd4); }
.qln-accent-green  { background: linear-gradient(90deg, #1b5e20, #43a047); }
.qln-accent-orange { background: linear-gradient(90deg, #bf360c, #ff7043); }

/* Icon circle */
.qln-card-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    margin-bottom: 18px;
    flex-shrink: 0;
}

.qln-icon-blue   { background: linear-gradient(135deg, #0a4d8c, #2196f3); }
.qln-icon-teal   { background: linear-gradient(135deg, #007c8a, #00bcd4); }
.qln-icon-green  { background: linear-gradient(135deg, #1b5e20, #43a047); }
.qln-icon-orange { background: linear-gradient(135deg, #bf360c, #ff7043); }

/* Card body */
.qln-card-body {
    flex: 1;
}

.qln-card-body h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a2a3a;
    margin-bottom: 10px;
    line-height: 1.4;
}

.qln-card-body p {
    color: #6c757d;
    font-size: 0.88rem;
    line-height: 1.6;
    margin-bottom: 18px;
}

/* Stat chips */
.qln-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f0f4f8;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.78rem;
    color: #495057;
    font-weight: 500;
}

.stat-item i {
    font-size: 0.72rem;
    color: #0d7db5;
}

/* Card footer / button */
.qln-card-footer {
    border-top: 1px solid #f0f0f0;
    padding-top: 16px;
    margin-top: auto;
}

.qln-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    color: #0d7db5;
    transition: gap 0.2s ease, color 0.2s ease;
}

.qln-btn:hover {
    color: #0a4d8c;
    gap: 12px;
}

/* Color variants for btn */
.qln-card[data-category="cap-nuoc"]  .qln-btn { color: #1565c0; }
.qln-card[data-category="khi-tuong"] .qln-btn { color: #00838f; }
.qln-card[data-category="chat-luong"].qln-btn { color: #2e7d32; }
.qln-card[data-category="ung-pho"]   .qln-btn { color: #bf360c; }

.qln-card[data-category="cap-nuoc"]:hover  .qln-btn { color: #0d47a1; }
.qln-card[data-category="khi-tuong"]:hover .qln-btn { color: #006064; }
.qln-card[data-category="chat-luong"]:hover .qln-btn { color: #1b5e20; }
.qln-card[data-category="ung-pho"]:hover   .qln-btn { color: #870000; }

/* ---- Responsive – Desktop/Tablet ---- */
@media (min-width: 768px) {
    #pagebody { padding-top: 100px; }
}
@media (min-width: 1200px) {
    #pagebody { padding-top: 80px; }
}
@media (max-width: 900px) {
    .qln-navtab {
        min-width: 140px;
        flex: 1 1 calc(50% - 10px);
    }
    .qln-section       { padding: 20px 12px 32px; }
    .qln-content-area  { padding: 20px 18px; }
}

/* ════════════════════════════════════════════
   MOBILE OPTIMIZATION  (≤ 640px)
   ════════════════════════════════════════════ */
@media (max-width: 640px) {

    /* ── Pagebody ── */
    #pagebody { padding-top: 170px; }

    /* ── Section + grid ── */
    .qln-section { padding: 8px 0 16px; justify-content: flex-start; }

    /* ── Content area full-width ── */
    .qln-section.expanded .qln-content-area {
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .qln-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 8px;
    }

    /* ── Cards ── */
    .qln-card { border-radius: 12px; }
    .qln-card-inner { padding: 14px 12px 10px; }
    .qln-card-icon {
        width: 40px; height: 40px;
        border-radius: 10px; font-size: 1.1rem;
        margin-bottom: 10px;
    }
    .qln-card-body h3 { font-size: 0.72rem; line-height: 1.3; margin-bottom: 6px; }
    .qln-card-body p  { font-size: 0.72rem; line-height: 1.4; margin-bottom: 8px; display: none; }
    .qln-card-stats   { gap: 4px; margin-bottom: 8px; }
    .stat-item        { font-size: 0.65rem; padding: 3px 7px; gap: 4px; }
    .stat-item i      { font-size: 0.6rem; }
    .qln-card-accent  { height: 4px; }

    /* ── Navbar: scrollable pills ── */
    .qln-section.expanded .qln-navbar {
        max-height: 80px;
        padding: 7px 8px;
        margin-bottom: 10px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
        border-radius: 0;
    }
    .qln-section.expanded .qln-navbar::-webkit-scrollbar { display: none; }

    .qln-navtab {
        flex: 0 0 auto;
        min-width: 0;
        padding: 5px 10px 5px 6px;
        border-radius: 20px;
    }
    .qln-navtab-icon { width: 24px; height: 24px; font-size: 0.65rem; }
    .qln-navtab span  { font-size: 0.65rem; white-space: nowrap; }

    .qln-back-btn {
        flex: 0 0 auto;
        font-size: 0.72rem;
        padding: 5px 10px;
        order: -1;
    }

    /* ── Content area ── */
    .qln-section.expanded .qln-content-area {
        padding: 12px 10px;
        min-height: 320px;
        border-radius: 0;
        box-shadow: none;
    }
    .qln-content-title { font-size: 0.95rem; margin-bottom: 12px; padding-bottom: 8px; }

    /* ── Sub-tabs (Lượng mưa / Mực nước) ── */
    .kt-subtabs {
        width: 100% !important;
        display: flex;
        margin-bottom: 12px;
        border-radius: 8px;
        padding: 4px;
    }
    .kt-subtab {
        flex: 1;
        text-align: center;
        padding: 8px 6px;
        font-size: 0.8rem;
        border-radius: 6px;
    }
    .kt-subtab i { display: block; font-size: 1rem; margin: 0 0 3px 0; }

    /* ── Rainfall filter (.lm-filter) ── */
    .lm-filter {
        padding: 10px 10px;
        gap: 8px;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .lm-filter .fg             { margin: 0; }
    .lm-filter label           { font-size: 0.72rem; }
    .lm-filter select,
    .lm-filter input[type=number] { font-size: 0.8rem; padding: 5px 7px; min-width: 0; width: 100%; }
    /* Nút Tải dữ liệu – span full row */
    .lm-fg-load      { grid-column: 1 / -1; display: flex; align-items: flex-end; }
    /* Toggle view – ô 1 */
    .lm-fg-toggle    { margin-left: 0 !important; align-self: stretch; display: flex; align-items: center; }
    /* Nhập CSV – ô 2 */
    .lm-fg-upload    { display: flex; align-items: flex-end; }
    .lm-btn-load   { font-size: 0.8rem; padding: 7px 12px; width: 100%; justify-content: center; }
    .lm-btn-upload { font-size: 0.8rem; padding: 7px 10px; width: 100%; }
    .lm-btn-tog    { font-size: 0.75rem; padding: 5px 10px; }

    /* ── Rainfall cards ── */
    .lm-card { padding: 12px 10px; margin-bottom: 12px; }
    .lm-card-head h3 { font-size: 0.85rem; }
    .lm-btn-export { font-size: 0.75rem; padding: 4px 10px; }

    /* ── Rainfall table ── */
    .lm-tbl { font-size: 0.7rem; min-width: 500px; }
    .lm-tbl th { padding: 5px 3px; }
    .lm-tbl td { padding: 4px 2px; }

    /* Chart heights */
    #lm-chart-box         { height: 260px; }
    .lm-overview-chart    { height: 220px !important; }
    .lm-overview-grid     { grid-template-columns: 1fr !important; }

    /* Overview filter */
    .lm-overview-filter {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .lm-overview-filter label { font-size: 0.72rem; }
    .lm-overview-filter input[type=number],
    .lm-overview-filter select { font-size: 0.8rem; min-width: 0; width: 100%; }
    .lm-overview-filter .fg:last-child { grid-column: 1 / -1; }
    .lm-overview-filter button { width: 100%; }

    /* ── WL Toolbar ── */
    .lm-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .lm-toolbar-left,
    .lm-toolbar-right { justify-content: space-between; width: 100%; }
    .lm-toolbar-right { gap: 6px !important; }
    .lm-toolbar-right .lm-btn-load {
        flex: 1;
        font-size: 0.8rem;
        padding: 7px 8px;
        justify-content: center;
    }

    /* ── WL Export Panel ── */
    .wl-export-panel { padding: 12px 10px; }
    .wl-export-row   { flex-direction: column; gap: 10px; }
    .wl-export-card  { min-width: 0; padding: 10px 12px; }
    .wl-export-fields { gap: 6px; }
    .wl-select       { font-size: 0.8rem; padding: 5px 7px; }
    .wl-select-wide  { min-width: 0; width: 100%; }
    .wl-btn-export   { font-size: 0.8rem; padding: 6px 12px; width: 100%; justify-content: center; }

    /* ── WL Chart ── */
    #wl-chart        { height: 260px !important; margin-bottom: 12px !important; }

    /* ── WL Table ── */
    .wl-table-wrap   { border-radius: 4px; }
    .wl-table        { font-size: 0.75em; }
    .wl-td-no,  .wl-th-no-fixed  { width: 28px; min-width: 28px; max-width: 28px; padding: 5px 2px; }
    .wl-td-name,.wl-th-name-fixed { width: 120px; min-width: 100px; max-width: 120px; left: 28px; padding: 5px 6px; font-size: 0.8em; }
    .wl-td-val  { padding: 6px 2px; min-width: 34px; font-size: 0.88em; }
    .wl-th-time { min-width: 34px; padding: 5px 2px; font-size: 0.8em; }
    .wl-th-date-row { padding: 5px 4px; font-size: 0.85em; }
    .wl-th-fixed-rowspan { padding: 5px 4px; font-size: 0.8em; }

    /* ── WL Section blocks ── */
    .wl-section-block { padding: 12px 10px; }
    .wl-section-title { font-size: 0.88em; margin-bottom: 10px; }
    #wl-yearly-chart  { height: 240px !important; }
    .wl-yearly-toolbar { gap: 6px; }

    /* ── WL Records table ── */
    .wl-rtable-wrap  { }
    .wl-rtable       { font-size: 0.78em; }
    .wl-rtable th    { padding: 6px 6px; }
    .wl-rtable td    { padding: 6px 6px; }

    /* ── WL Stat boxes ── */
    .wl-stat-grid        { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
    .wl-stat-box         { padding: 8px 10px; }
    .wl-stat-box .wl-stat-value { font-size: 1.2em; }
    .wl-detail-chart     { height: 200px; }
    .wl-detail-card      { padding: 12px 10px; }

    /* ── Yearly comparison table ── */
    .wl-ytable-wrap  { }
    .wl-ytable       { font-size: 0.8em; }
}

/* ═══════════════════════════════════════════
   Mực nước – Water Level (chat-luong tab)
   ═══════════════════════════════════════════ */

/* Badge trạng thái */
.wl-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.wl-badge.wl-badge-ok      { background: #d4f5e2; color: #1a7a42; }
.wl-badge.wl-badge-loading { background: #fff3cd; color: #856404; }
.wl-badge.wl-badge-err     { background: #fde8e8; color: #c0392b; }
.wl-badge.wl-badge-new     { background: #e8f4fd; color: #1565c0; animation: wl-pulse 1s ease-in-out 3; }
.wl-badge.wl-badge-ok    i { color: #2ecc71; }
.wl-badge.wl-badge-loading i { color: #f39c12; animation: spin 1.2s linear infinite; }
.wl-badge.wl-badge-err   i { color: #c0392b; }
.wl-badge.wl-badge-new   i { color: #1565c0; }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes wl-pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* Thanh ngày – ẩn vì đã tích hợp vào header bảng */
.wl-date-bar { display: none; }

/* ═══════════════════════════════════════════════════════════
   BẢNG MỰC NƯỚC – phong cách báo cáo chuyên nghiệp
   ═══════════════════════════════════════════════════════════ */

/* Wrapper */
.wl-table-wrap {
    overflow-x: auto;
    border-radius: 6px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.13);
    background: #fff;
    border: 2px solid #2c5f8a;
}

/* Bảng */
.wl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    font-family: 'Times New Roman', Times, serif;
    table-layout: fixed;
}

/* ── HEADER ── */
.wl-table thead {
    position: sticky;
    top: 0;
    z-index: 3;
}

/* Hàng 1: nhãn ngày span qua tất cả cột thời gian */
.wl-th-date-row {
    background: #1a4f80;
    color: #fff;
    text-align: center;
    font-weight: 700;
    font-size: 1em;
    padding: 7px 8px;
    border: 1px solid #2d6ca0;
    white-space: nowrap;
    letter-spacing: 0.04em;
}
/* 2 ô cố định (# và Tên trạm) ở hàng 1 span 2 hàng */
.wl-th-fixed-rowspan {
    background: #1a4f80;
    color: #fff;
    font-weight: 700;
    font-size: 0.95em;
    padding: 7px 10px;
    border: 1px solid #2d6ca0;
    vertical-align: middle;
    text-align: center;
}

/* Hàng 2: nhãn giờ */
.wl-th-time {
    padding: 7px 3px;
    text-align: center;
    white-space: nowrap;
    font-weight: 600;
    font-size: 1em;
    background: #1a4f80;
    color: #fff;
    border: 1px solid #2d6ca0;
    overflow: hidden;
}

/* Cột giờ chẵn (18h, 19h…) – highlight vàng đậm */
.wl-th-hour {
    background: #c9920a !important;
    color: #fff !important;
    font-weight: 800;
    font-size: 1.05em;
    border: 1px solid #a07208 !important;
}

/* Cột mới nhất */
.wl-th-latest {
    background: #e6a800 !important;
    color: #fff !important;
    font-weight: 800;
}

/* ── STICKY CỘT TRÁI ── */
.wl-td-no, .wl-th-no-fixed {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #f0f4f8;
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    text-align: center;
}
.wl-td-name, .wl-th-name-fixed {
    position: sticky;
    left: 36px;
    z-index: 2;
    background: #f0f4f8;
    width: 200px;
    min-width: 160px;
    max-width: 200px;
    text-align: left;
    box-shadow: 3px 0 5px rgba(0,0,0,0.08);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
thead .wl-th-no-fixed   { background: #1a4f80; z-index: 4; }
thead .wl-th-name-fixed { background: #1a4f80; z-index: 4; box-shadow: 3px 0 6px rgba(0,0,0,0.25); left: 36px; }

/* ── ROWS ── */
.wl-table tbody tr {
    transition: background 0.1s;
}
.wl-table tbody tr:nth-child(odd)  { background: #fff; }
.wl-table tbody tr:nth-child(even) { background: #f5f8fc; }
.wl-table tbody tr:hover { background: #e8f3ff !important; }
.wl-table tbody tr:hover .wl-td-no,
.wl-table tbody tr:hover .wl-td-name { background: #d8ecff !important; }

.wl-td-no {
    padding: 7px 5px;
    color: #555;
    font-size: 0.88em;
    font-weight: 500;
    border: 1px solid #c0ccd8;
}
.wl-td-name {
    padding: 7px 13px;
    font-weight: 600;
    color: #1a2a3a;
    white-space: nowrap;
    border: 1px solid #c0ccd8;
    font-size: 0.97em;
}

/* ── CELL GIÁ TRỊ ── */
.wl-td-val {
    text-align: center;
    padding: 9px 3px;
    font-variant-numeric: tabular-nums;
    font-weight: 1000;
    font-size: 1.05em;
    border: 1px solid #c0ccd8;
    color: #333;
    overflow: hidden;
}

/* Cột mới nhất */
.wl-td-latest {
    background: rgba(230, 168, 0, 0.18) !important;
    font-weight: 800;
    border-left: 2px solid #c9920a !important;
    border-right: 2px solid #c9920a !important;
}
/* Cột giờ chẵn */
.wl-td-hour-col {
    background: rgba(201, 146, 10, 0.09) !important;
}
/* Kết hợp cả 2 */
.wl-td-latest.wl-td-hour-col {
    background: rgba(230, 168, 0, 0.28) !important;
}

/* ── MÀU THEO NGƯỠNG ── */
.wl-val-high { color: #c0392b; font-weight: 800; }
.wl-val-mid  { color: #1565c0; font-weight: 700; }
.wl-val-low  { color: #1e8449; font-weight: 600; }

/* ── XU HƯỚNG ── */
.wl-rising::after  { content: ' ▲'; font-size: 0.65em; color: #c0392b; vertical-align: middle; }
.wl-falling::after { content: ' ▼'; font-size: 0.65em; color: #1e8449; vertical-align: middle; }

/* ── End WL table ── */

/* ═══════════════════════════════════════════════════════════
   SECTION BLOCK chung (export, yearly, records)
   ═══════════════════════════════════════════════════════════ */
.wl-section-block {
    background: rgba(255,255,255,0.95);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid #d4dce8;
    padding: 20px 24px;
}
.wl-section-title {
    font-size: 1em;
    font-weight: 700;
    color: #1a4f80;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e8f4;
    display: flex;
    align-items: center;
    gap: 8px;
}
.wl-placeholder {
    color: #aaa;
    text-align: center;
    padding: 28px;
    font-size: 0.9em;
}
.wl-btn-sm {
    background: none;
    border: 1px solid #2c5f8a;
    color: #2c5f8a;
    font-size: 0.78em;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.wl-btn-sm:hover { background: #2c5f8a; color: #fff; }

/* ── EXPORT PANEL (fold-down dưới toolbar) ── */
.wl-export-panel {
    background: rgba(255,255,255,0.98);
    border: 1px solid #c0d0e4;
    border-radius: 10px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.12);
    padding: 18px 20px;
    margin-bottom: 16px;
    animation: wlPanelSlide 0.18s ease;
}
@keyframes wlPanelSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── EXPORT PANEL ── */
.wl-export-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.wl-export-card {
    flex: 1;
    min-width: 280px;
    background: #f5f8fd;
    border: 1px solid #d0dcea;
    border-radius: 8px;
    padding: 14px 18px;
}
.wl-export-card-title {
    font-size: 0.88em;
    font-weight: 700;
    color: #1a4f80;
    margin-bottom: 12px;
}
.wl-export-fields {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.wl-select {
    padding: 6px 10px;
    border: 1px solid #c0ccd8;
    border-radius: 6px;
    font-size: 0.86em;
    color: #333;
    background: #fff;
    cursor: pointer;
    outline: none;
}
.wl-select:focus { border-color: #2c5f8a; }
.wl-select-wide { min-width: 160px; flex: 1; }
.wl-btn-export {
    background: #1a4f80;
    color: #fff;
    border: none;
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 0.86em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
    white-space: nowrap;
}
.wl-btn-export:hover { background: #0d3460; }
.wl-btn-export:disabled { background: #9ab0c9; cursor: wait; }

/* Active state cho nút Xuất Excel khi panel đang mở */
.lm-btn-load.active {
    background: #1a4f80;
    color: #fff;
}

/* ── YEARLY COMPARISON TABLE ── */
.wl-yearly-toolbar { margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wl-ytable-wrap { overflow-x: auto; border-radius: 6px; border: 2px solid #2c5f8a; }
.wl-ytable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92em;
    font-family: 'Times New Roman', Times, serif;
    table-layout: fixed;
}
.wl-ytable th, .wl-ytable td {
    border: 1px solid #c0ccd8;
    text-align: center;
    padding: 7px 5px;
}
.wl-ytable thead th {
    background: #1a4f80;
    color: #fff;
    font-weight: 700;
}
.wl-ytable thead th.wl-yth-month {
    background: #c9920a;
    color: #fff;
}
.wl-ytable tbody tr:nth-child(odd)  { background: #fff; }
.wl-ytable tbody tr:nth-child(even) { background: #f5f8fc; }
.wl-ytable tbody tr:hover { background: #e8f0ff !important; }
.wl-ytable td:first-child { font-weight: 600; color: #1a4f80; background: #f0f4f8; }

/* ── RECORDS TABLE ── */
.wl-rtable-wrap { overflow-x: auto; border-radius: 6px; border: 2px solid #2c5f8a; }
.wl-rtable {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
    font-family: 'Times New Roman', Times, serif;
}
.wl-rtable th {
    background: #1a4f80;
    color: #fff;
    font-weight: 700;
    padding: 10px 12px;
    border: 1px solid #2d6ca0;
    text-align: center;
    white-space: nowrap;
    font-size: 0.95em;
}
.wl-rtable th.wl-rth-max { background: #9b2335; }
.wl-rtable th.wl-rth-min { background: #1a6b3c; }
.wl-rtable th.wl-rth-bd  { background: #7b4fa6; }
.wl-rtable td {
    border: 1px solid #c0ccd8;
    padding: 9px 12px;
    vertical-align: middle;
    font-size: 0.97em;
}
.wl-rtable tbody tr:nth-child(odd)  { background: #fff; }
.wl-rtable tbody tr:nth-child(even) { background: #f5f8fc; }
.wl-rtable tbody tr:hover { background: #e8f0ff !important; }
.wl-rtable .wl-r-name { font-weight: 600; color: #1a2a3a; white-space: nowrap; font-size: 1em; }
.wl-rtable .wl-r-max  { color: #c0392b; font-weight: 800; text-align: center; font-size: 1.05em; }
.wl-rtable .wl-r-min  { color: #1e8449; font-weight: 800; text-align: center; font-size: 1.05em; }
.wl-rtable .wl-r-time { font-size: 0.88em; color: #666; display: block; }
.wl-rtable .wl-r-bd   { text-align: center; color: #7b4fa6; font-weight: 700; font-size: 1.05em; }
.wl-rtable .wl-r-none { text-align: center; color: #bbb; font-style: italic; font-size: 0.9em; }

/* ═══════════════════════════════════════════════════════════
   ROW MỞ RỘNG – thống kê chi tiết trạm
   ═══════════════════════════════════════════════════════════ */

/* Hàng được chọn → highlight */
.wl-table tbody tr.wl-row-selected {
    background: #e0edff !important;
    cursor: pointer;
}
.wl-table tbody tr.wl-row-selected .wl-td-no,
.wl-table tbody tr.wl-row-selected .wl-td-name {
    background: #cfe3ff !important;
}
/* Con trỏ tay cho cột tên */
.wl-table tbody tr .wl-td-name { cursor: pointer; }

/* Hàng chi tiết */
.wl-detail-row td {
    padding: 0 !important;
    border: none !important;
    background: #f4f8fd !important;
}
.wl-detail-card {
    padding: 18px 24px 20px;
    border-top: 2px solid #4a90d9;
    border-bottom: 2px solid #4a90d9;
    background: linear-gradient(135deg, #f0f6ff 0%, #fafcff 100%);
    animation: wl-slide-down 0.22s ease;
}
@keyframes wl-slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Tiêu đề tên trạm trong card */
.wl-detail-title {
    font-size: 1em;
    font-weight: 700;
    color: #1a4f80;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.wl-detail-title .wl-detail-close {
    margin-left: auto;
    cursor: pointer;
    color: #888;
    font-size: 1.1em;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.wl-detail-title .wl-detail-close:hover { background: #e0e8f0; color: #333; }

/* Grid 4 stat boxes */
.wl-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
@media (max-width: 900px) { .wl-stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .wl-stat-grid { grid-template-columns: 1fr; } }

.wl-stat-box {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #d0dcea;
    padding: 12px 16px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.wl-stat-box .wl-stat-label {
    font-size: 0.74em;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 5px;
}
.wl-stat-box .wl-stat-value {
    font-size: 1.45em;
    font-weight: 800;
    line-height: 1.1;
    font-family: 'Times New Roman', Times, serif;
}
.wl-stat-box .wl-stat-time {
    font-size: 0.72em;
    color: #888;
    margin-top: 3px;
}
.wl-stat-max  .wl-stat-value { color: #c0392b; }
.wl-stat-min  .wl-stat-value { color: #1e8449; }
.wl-stat-tavg .wl-stat-value { color: #1565c0; }
.wl-stat-mavg .wl-stat-value { color: #7b4fa6; }

/* Biểu đồ trong card */
.wl-detail-chart {
    width: 100%;
    height: 260px;
    border-radius: 8px;
    overflow: hidden;
}

/* Loading spinner trong card */
.wl-detail-loading {
    text-align: center;
    padding: 30px;
    color: #888;
    font-size: 0.9em;
}
