@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    font-family: 'Sarabun', sans-serif;
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden; /* ป้องกันล้นข้างในระดับ Global */
}

.header,
.legend,
th {
    font-weight: 600;
}

/* =========================
   ROOT GRID
========================= */

.app {
    height: 100vh;
    display: grid;
    grid-template-rows:
        minmax(90px, 10vh) 1fr;
    min-height: 0;
}

.fire-content {
    display: grid;
    grid-template-rows: minmax(50px, 5vh) minmax(60px, 6vh) 1fr;
    height: 100%;
    min-height: 0;
}

.btn-toggle-panels {
    display: none; /* ซ่อนโดยค่าเริ่มต้น (Desktop/Portrait) */
}

/* =========================
   HEADER
========================= */

.header {
    display: flex;
    align-items: center;
    padding: 0 30px;
    background: linear-gradient(135deg, #faaf78 0%, #df8549 50%, #c86932 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 24px rgba(200, 105, 50, 0.2);
    position: relative;
    gap: 40px;
    z-index: 1000;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto; /* Push to right */
    padding-right: 10px;
}

#user_display {
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    font-size: 14px;
}

.btn-manual {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    color: #b08900;
}

.btn-manual:hover {
    background: #fff8e1;
    transform: scale(1.1) rotate(5deg);
    color: #ffc107;
}

.btn-header-contact {
    background: white;
    border: none;
    border-radius: 999px;
    padding: 8px 18px;
    font-weight: 600;
    font-size: 13px;
    color: #2d6a4f;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-header-contact:hover {
    background: #f3e7d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}



.logo {
    height: 60px;
    cursor: pointer;
    transition: all 0.3s ease;
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.1));
}

.logo:hover {
    transform: scale(1.02);
    filter: drop-shadow(0 0 12px rgba(255,255,255,0.3)) brightness(1.1);
}

/* =========================
   MENUS
========================= */

.hazard-menu {
    display: flex;
    gap: 15px;
    padding: 0;
    background: transparent;
    flex: 1;
    max-width: 900px;
}

.hazard-item {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: auto; 
}

/* Watermark สำหรับเมนูที่ยังไม่เสร็จ */
.hazard-item.disabled {
    cursor: pointer;
    opacity: 0.8;
}

.hazard-item.disabled::after {
    content: "อยู่ระหว่างพัฒนา";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-10deg);
    font-size: 10px;
    font-weight: 800;
    color: rgba(239, 68, 68, 0.4);
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
    text-transform: uppercase;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.6);
}

.sub-menu,
.view-menu {
    display: flex;
    gap: 10px;
    padding: 8px 20px;
    background: #fff;
}

.hazard {
    flex: 1;
    text-align: center;
    padding: 8px 15px;
    border-radius: 12px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    transition: .2s;
    font-size: 12px;
    white-space: nowrap;
}

.sub {
    flex: 1;
    text-align: center;
    padding: 8px 15px;
    border-radius: 12px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    transition: .2s;
    font-size: 12px;
    white-space: nowrap;
}

.hazard:hover,
.sub:hover {
    background: #ddd;
}

.active {
    background: #f3e7d8 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15) !important;
    font-weight: 800 !important;
    color: #c86932 !important;
}

.hazard-item:not(.active-container) .hazard-text {
    display: none;
}

.hazard-item:not(.active-container) {
    flex: none;
    min-width: auto;
}

.hazard-item:not(.active-container) .hazard {
    min-width: 45px;
    padding: 8px;
    flex: 0 0 auto;
}

.hazard-icon {
    font-size: 18px;
    vertical-align: middle;
}

.hazard-text {
    vertical-align: middle;
    margin-left: 5px;
}

/* =========================
   FILTER BAR
========================= */

.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap; /* หนึ่งแถวเท่านั้น */
    gap: 8px; /* ลดระยะห่างเพื่อให้เบียดได้มากขึ้น */
    padding: 10px 15px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* ไม่ให้มี Scrollbar */
}

.filter-bar label {
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.filter-bar select,
.filter-bar .date-box select,
.filter-bar .date-box input {
    flex: 1; /* ให้กางออกเท่าๆ กัน */
    min-width: 0; /* สำคัญ: เพื่อให้ย่อขนาดได้ต่ำกว่าเนื้อหาภายใน */
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 6px 8px;
    background: #f5f5f5;
    font-size: 12px;
    height: 38px;
    box-sizing: border-box;
}

.filter-bar button {
    white-space: nowrap;
    flex-shrink: 0; /* ปุ่มไม่ต้องย่อ */
    background: linear-gradient(135deg, #d28b5c 0%, #b8754b 100%);
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 0 15px;
    height: 38px;
    border-radius: 8px;
    border: none;
    transition: all 0.2s ease;
}

/* เฉพาะปุ่ม Excel ปรับให้ดูพรีเมียมและเข้าธีมมากขึ้น */
.filter-bar button[onclick*="exportTableToExcel"] {
    background: linear-gradient(135deg, #2d6a4f 0%, #1b4332 100%) !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(45, 106, 79, 0.2) !important;
}

.filter-bar button[onclick*="exportTableToExcel"]:hover {
    background: linear-gradient(135deg, #40916c 0%, #2d6a4f 100%) !important;
    box-shadow: 0 6px 15px rgba(45, 106, 79, 0.3) !important;
    transform: translateY(-1px);
}

.filter-bar .date-box {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 2;
}

.filter-bar button:hover {
    background: linear-gradient(135deg, #e39a6a 0%, #d28b5c 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(210, 139, 92, 0.4);
}

.filter-bar button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(210, 139, 92, 0.3);
}

.date-box {
    display: flex;
    gap: 5px;
    padding: 3px 7px;
    background: #eee;
    border-radius: 12px;
}

.flatpickr-day.viirs-hotspot_viirs {
    background: #ffe066 !important;
    color: #000;
    font-weight: bold;
    border-radius: 50%;
}

.viirs-hotspot_viirs {
    background: #ffe066 !important;
    color: #000;
    font-weight: bold;
    border-radius: 50%;
}

/* Multi-select Dropdown for Moo */
.dropdown-checkbox {
    position: relative;
    width: 100%;
}

.dropdown-checkbox-btn {
    width: 100%;
    padding: 8px 12px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #444;
    height: 38px;
}

.dropdown-checkbox-content {
    display: none;
    position: absolute;
    background-color: #fff;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    z-index: 2000;
    border-radius: 8px;
    margin-top: 5px;
    border: 1px solid #e0e0e0;
}

.dropdown-checkbox-content.show {
    display: block;
}

.dropdown-checkbox-item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-checkbox-item:hover {
    background-color: #f8f9fa;
}

.dropdown-checkbox-item input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    margin: 0;
}

.dropdown-checkbox-item label {
    cursor: pointer;
    font-size: 13px;
    margin: 0;
    flex: 1;
    color: #444;
}

/* =========================
   LEGEND
========================= */

.legend {
    display: flex;
    gap: 15px;
    background: white;
    padding: 9px 15px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.hotspot_viirs {
    background: #FFD84D;
}

.burn {
    background: #FF8C42;
}


/* =========================
   MAIN AREA
========================= */

.view-dashboard {
    display: flex;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* =========================
   SIDE PANEL GRID
========================= */

.side-panel {
    width: 70%;
    height: 100%;
    display: grid;
    grid-template-columns: 22% 78%;
    gap: 12px;
    padding: 12px; /* ลด padding เพื่อกันล้น */
    min-height: 0;
    overflow: hidden;
}

/* LEFT COLUMN */

.left-column {
    display: grid;
    grid-template-rows: repeat(2, min-content) 1fr;
    gap: 12px;
    min-height: 0;
}

/* RIGHT COLUMN */

.right-column {
    display: grid;
    grid-template-rows: min-content 1fr;
    gap: 12px;
    height: 100%;
    min-height: 0; /* เพิ่มเพื่อให้ 1fr ทำงานได้ถูกต้องใน container ที่มีจำกัด */
}

/* =========================
   CARD COMMON STYLE
========================= */

.metric-card,
.big-table {
    background: white;
    border-radius: 22px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* ตัวแม่ไม่ต้อง Scroll */
}

#hotspot_viirs_count_table_content {
    width: 100%;
    max-height: 80vh; /* ให้ JS จัดการความสูงเองเป็นหลัก */
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    background: white;
    position: relative;
    flex: 1;
}

#hotspot_viirs_count_table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
}

#hotspot_viirs_count_table thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: linear-gradient(135deg, #faaf78 0%, #d28b5c 100%);
    color: white;
    font-weight: 600;
    font-size: 11px;
    padding: 12px 8px;
    border-bottom: 1px solid #d28b5c;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
}

#hotspot_viirs_count_table td {
    padding: 10px 8px;
    font-size: 13px;
    border-bottom: 1px solid #eee;
    border-right: 1px solid #eee;
    text-align: center;
    background: white;
}

#hotspot_viirs_count_table th:last-child,
#hotspot_viirs_count_table td:last-child {
    border-right: none;
}

#hotspot_viirs_count_table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

#hotspot_viirs_count_table tbody tr:hover {
    background-color: #fff3e0;
    transition: background-color 0.2s ease;
}

#hotspot_viirs_count_table td:nth-child(n+3) {
    text-align: right;
    font-weight: 500;
}

/* Column Widths */
.col-1 { width: 5%; }
.col-2 { width: 18%; }
.col-3 { width: 12%; }
.col-4 { width: 12%; }
.col-5 { width: 12%; }
.col-6 { width: 10%; }
.col-7 { width: 10%; }
.col-8 { width: 21%; }

#hotspot_viirs_count_table th {
    cursor: pointer;
    user-select: none;
}

#hotspot_viirs_count_table th::after {
    content: " ⇅";
    font-size: 11px;
    color: rgba(255,255,255,0.6);
}

.big-graph {
    background: white;
    border-radius: 22px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* =========================
   MOCK STYLES (เอาออกได้ภายหลัง)
========================= */

/* =========================
   METRIC CARDS (NEW STYLE)
========================= */

.metric-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}

.metric-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.metric-icon {
    font-size: 1.6rem;
    width: 42px;
    height: 42px;
    background: #f8f9fa;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-title {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.metric-title span {
    font-size: 14px;
    font-weight: 700;
    color: #333;
}

.metric-title small {
    font-size: 11px;
    color: #777;
}

.metric-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
}

.metric-card .value {
    font-size: 2.4rem;
    font-weight: 800;
    color: #d32f2f;
    line-height: 1;
}

.hotspot-agri .value {
    color: #ef6c00;
}

.metric-footer {
    font-size: 11px;
    color: #999;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.03);
    text-align: right;
}

/* Activity Grid Specifics */
.agri-activity .metric-header {
    margin-top: -15px; /* เลื่อนเนื้อหาข้างในขึ้นรวม 15px */
}

.activity-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px; /* ลดช่องว่างลง */
    margin: 5px 0; /* ลด margin ของ grid */
}

.activity-item {
    background: #fafafa;
    border-radius: 10px;
    padding: 6px 4px; /* ลด padding จาก 10px เหลือ 6px */
    text-align: center;
    border: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.activity-item:nth-child(3) {
    grid-column: span 2;
    background: linear-gradient(135deg, #fff8e1 0%, #fffde7 100%);
    border-color: #ffe082;
}

.activity-item.wide {
    grid-column: span 2;
    background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e9 100%);
    border-color: #c8e6c9;
    padding: 10px 5px;
}

.activity-item label {
    display: block;
    font-size: 10px; /* ลดขนาด font label ลงเล็กน้อย */
    color: #666;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.value-small {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2e7d32;
    line-height: 1;
}

.value-small.highlight {
    font-size: 1.6rem;
    color: #1b5e20;
}

.activity-item sub {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

.mt-auto {
    margin-top: auto;
}

.big-table {
    background: #ffffff;
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
    overflow: hidden;
    padding: 0;
    margin: 0;
    height: 100%;
}

/* Table Styles Cleaned and Moved to line 449 */

/* =========================
   SUMMARY TABLE (BS MODAL)
========================= */

.sum-bs-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    background: white;
}

.sum-bs-table thead th {
    background: linear-gradient(135deg, #faaf78 0%, #d28b5c 100%);
    color: white;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    padding: 12px 8px;
    border-bottom: 2px solid #b8754b;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.sum-bs-table td {
    padding: 10px 12px;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    border-right: 1px solid #eee;
    color: #444;
}

.sum-bs-table tr:last-child td {
    border-bottom: none;
}

.sum-bs-table tr:hover {
    background-color: #fdf5ef;
    transition: background 0.2s;
}

/* =========================
   MAP EXPANSION
========================= */

.map-area.expanded-map {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    width: 80vw !important;
    height: 80vh !important;
    transform: translate(-50%, -50%) !important; /* จัดกึ่งกลางที่แน่นอน */
    zoom: 1 !important;                         /* ยกเลิกการขยายจาก Parent */
    z-index: 9999 !important;
    border-radius: 24px !important;
    box-shadow: 0 30px 100px rgba(0,0,0,0.6) !important;
    border: 5px solid white !important;
    overflow: hidden !important;
}

.btn-expand-map {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    width: 32px;
    height: 32px;
    background: white;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: all 0.2s;
    color: #444;
}

.btn-expand-map:hover {
    background: #f4f4f4;
    color: #000;
    transform: scale(1.05);
}

.map-area.expanded-map .btn-expand-map {
    position: fixed !important; /* เปลี่ยนเป็น fixed เพื่อให้ลอยเหนือทุกอย่างจริงๆ */
    top: 20px !important;
    right: 20px !important;
    background: #fff !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4) !important;
    z-index: 999999 !important; /* สูงสุดๆ */
    border: 2px solid #c86932 !important;
    width: 45px !important; /* ขยายขนาดปุ่มให้กดง่ายขึ้นในมือถือ */
    height: 45px !important;
    font-size: 20px !important;
}

/* Moved to line 449 */

.btn-expand-table {
    position: absolute;
    top: 6px;
    right: 10px;
    z-index: 50;
    width: 28px;
    height: 28px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    color: #d28b5c;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.btn-expand-table:hover {
    background: #fff3e0;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(210, 139, 92, 0.2);
    border-color: #d28b5c;
}

/* Fullscreen Modal Specifics */
.fullscreen-modal {
    width: 95vw;
    height: 90vh;
    max-width: 1800px;
    background: white;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: swal-show 0.3s ease-out;
}

.fullscreen-table-container {
    flex: 1;
    overflow: auto;
    padding: 0 20px 20px 20px;
}

.fullscreen-table-container table {
    width: 100%;
    border-collapse: collapse !important;
    background: white;
}

.fullscreen-table-container th,
.fullscreen-table-container td {
    border: 1px solid #e0e0e0 !important;
    padding: 12px 10px;
    text-align: center; /* Default เป็นตรงกลางสำหรับตัวเลข */
    vertical-align: middle;
}

/* เฉพาะคอลัมน์ที่ 2 (พื้นที่) ให้ชิดซ้าย */
.fullscreen-table-container td:nth-child(2) {
    text-align: left;
}

/* =========================
   LEGEND MINIMIZE
========================= */

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
}

.btn-minimize-legend {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: opacity 0.2;
}

.btn-minimize-legend:hover {
    opacity: 0.7;
}

#map-legend-floating.collapsed .legend-body {
    display: none;
}

#map-legend-floating.collapsed {
    width: 120px !important; /* ย่อความกว้างลงเมื่อพับ */
}


.fullscreen-table-container thead th {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #faaf78 0%, #d28b5c 100%);
    color: white;
    border-bottom: 2px solid #b8754b !important;
}

.sum-bs-table td:nth-child(n+3) {
    text-align: right;
    font-weight: 500;
}


.big-graph {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    background: #ffffff;
    /* พื้นหลังขาวเหมือนการ์ดอื่น */
    border-radius: 22px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
    padding: 12px;
    margin: 0;
    /* height: 100%; */
    overflow: hidden;
}

.big-graph canvas {
    flex: 1;
    width: 100% !important;
    height: 100% !important;
}

#hotspot_viirs_chart {
    width: 100% !important;
    height: 100% !important;
}

/* =========================
   MAP AREA
========================= */

.map-area {
    width: 30%;
    height: calc(100% - 24px); /* หักลบ margin บน-ล่าง */
    min-height: 0;
    margin: 12px 12px 12px 0; /* เว้นระยะให้เหมือน card */
    background: white;
    border-radius: 22px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#map {
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* overlay ดำโปร่ง */
#on_progres {
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;

    /* จัดกรอบขาวให้อยู่กลางจอ */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* กล่องสีขาว */
#on_progres_content {
    width: 30%;
    min-width: 300px;
    height: 120px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);

    display: flex;
    justify-content: center;
    align-items: center;
}

/* ข้อความโหลด */
.progress-text {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
}

#span_process {
    margin-top: 6px;
    font-size: 14px;
    color: #555;
}

.progress-text::after {
    content: " ...";
    animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
    0% {
        content: "";
    }

    33% {
        content: ".";
    }

    66% {
        content: "..";
    }

    100% {
        content: "...";
    }
}

/* =========================
   CONTACT MODAL
========================= */

.contact-card {
    background: white;
    width: 800px;
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: swal-show 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.contact-header {
    background: linear-gradient(135deg, #faaf78 0%, #d28b5c 100%);
    padding: 20px 25px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-title {
    font-size: 20px;
    font-weight: 700;
}

.contact-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.contact-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.contact-body {
    padding: 30px;
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 30px;
    background: #fcfaf8;
}

.dept-name {
    color: #2d6a4f;
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 25px;
    line-height: 1.4;
}

.info-item {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    font-size: 15px;
    color: #444;
    line-height: 1.5;
}

.info-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.contact-map {
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    height: 350px;
}

.map-area {
    position: relative;
}

#map-legend-floating {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 180px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .3);
    font-size: 13px;
    z-index: 999;
    user-select: none;
}

.legend-header {
    padding: 8px;
    font-weight: bold;
    cursor: move;
    background: #f3f3f3;
    border-radius: 12px 12px 0 0;
    text-align: center;
}

.legend-body {
    height: auto;
    max-height: 80vh;
    overflow-y: auto;
    padding: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.legend-line.thick {
    height: 5px;
    width: 26px;
    background: #000;
    margin-right: 6px;
}

.legend-line.mid {
    height: 4px;
    width: 26px;
    background: #000;
    margin-right: 6px;
}

.legend-line.thin {
    height: 3px;
    width: 26px;
    background: #000;
    margin-right: 6px;
}

.legend-line.thinner {
    height: 2px;
    width: 26px;
    background: #000;
    margin-right: 6px;
}

.legend-box {
    width: 18px;
    height: 12px;
    background: #a0e674;
    border: 1px solid #000;
    margin-right: 6px;
}

.legend-box-bs {
    width: 18px;
    height: 12px;
    background: #ff9500;
    border: 1px solid #000;
    margin-right: 6px;
}

.legend-star {
    color: red;
    font-size: 16px;
    margin-right: 6px;
}



/* =========================
   SOFT UI SHADOW SYSTEM
========================= */

.shadow-soft {
    box-shadow:
        0 8px 18px rgba(0, 0, 0, .08),
        0 2px 6px rgba(0, 0, 0, .05),
        inset 0 1px 0 rgba(255, 255, 255, .7);
}

/* hover ลอยนิดๆ */
.shadow-soft:hover {
    transform: translateY(-2px);
    box-shadow:
        0 14px 28px rgba(0, 0, 0, .12),
        0 6px 12px rgba(0, 0, 0, .08);
    transition: .25s ease;
}



/* =========================
   TABLE DEPTH
========================= */

/* Table Glow Moved to line 449 */

/* =========================
   GRAPH CARD DEPTH
========================= */

.big-graph {
    box-shadow:
        0 12px 26px rgba(0, 0, 0, .14),
        inset 0 1px 0 rgba(255, 255, 255, .8);
}

/* =========================
   FILTER + MENU GLOW
========================= */

.filter-bar,
.sub-menu {
    box-shadow:
        0 6px 16px rgba(0, 0, 0, .12),
        inset 0 1px 0 rgba(255, 255, 255, .9);
}

/* active ปุ่มดูนูน */
.active {
    box-shadow:
        0 6px 14px rgba(0, 0, 0, .25),
        inset 0 1px 0 rgba(255, 255, 255, .7);
}

/* =========================
   MAP CARD DEPTH
========================= */

.map-area {
    border-radius: 22px;
    overflow: hidden;
    box-shadow:
        0 14px 30px rgba(0, 0, 0, .18),
        inset 0 1px 0 rgba(255, 255, 255, .7);
}

/* =========================
   LEGEND GLASS EFFECT
========================= */

.legend {
    backdrop-filter: blur(6px);
    box-shadow:
        0 8px 20px rgba(0, 0, 0, .18),
        inset 0 1px 0 rgba(255, 255, 255, .9);
}

/* =========================
   BUTTON DEPTH
========================= */

.filter-bar button {
    box-shadow:
        0 6px 14px rgba(0, 0, 0, .25),
        inset 0 1px 0 rgba(255, 255, 255, .5);
}

.filter-bar button:hover {
    transform: translateY(-1px);
    box-shadow:
        0 10px 22px rgba(0, 0, 0, .35);
}

.label {
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
    text-shadow:
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white;
}

.hotspot_viirs-star {
    color: red;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 0 3px white;
}

.leaflet-pane.pane-hotspot_viirs {
    pointer-events: none;
}

/* =========================
   RESPONSIVE (Scaling Mode)
========================= */
/* เราจะใช้ JS ในการสเกลสัดส่วนแทนการจัด Layout ใหม่ตามความต้องการของ USER */
body {
    overflow-x: hidden;
}

.app {
    min-width: 1440px; /* ยืนพื้นขนาด Desktop เป็นมาตรฐาน */
    transition: transform 0.3s ease;
}

/* =========================
   LOGIN MODAL
========================= */

#login_overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.55);

    display: none;
    /* เริ่มต้นซ่อน */
    justify-content: center;
    align-items: center;
}

.login-box {
    width: 360px;
    background: white;
    border-radius: 22px;
    padding: 24px 26px;

    box-shadow:
        0 18px 40px rgba(0, 0, 0, .35),
        inset 0 1px 0 rgba(255, 255, 255, .8);
}

.login-title {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 18px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.login-field label {
    font-size: 13px;
    font-weight: 600;
}

.login-field input {
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    background: #eef0f4;
    font-size: 14px;
}

.login-field input:focus {
    outline: none;
    background: #e4e7ec;
}

.login-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.login-actions button {
    flex: 1;
    border: none;
    border-radius: 999px;
    padding: 10px;
    cursor: pointer;
    font-weight: 600;
}

.btn-cancel {
    background: #ccc;
}

.btn-login {
    background: #d28b5c;
    color: white;
}

.btn-login:hover {
    background: #bf7a4e;
}

/* =========================
   PRINT SELECT MODAL
========================= */

#print_select_overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(0, 0, 0, 0.55);

    display: none;
    justify-content: center;
    align-items: center;
}

.print-select-box {
    width: 380px;
    background: white;
    border-radius: 22px;
    padding: 28px 30px;

    box-shadow:
        0 18px 40px rgba(0, 0, 0, .35),
        inset 0 1px 0 rgba(255, 255, 255, .8);

    animation: printModalIn .25s ease;
}

@keyframes printModalIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.print-select-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 22px;
    color: #333;
}

.print-select-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.print-select-field label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

.print-select-field select,
.print-select-field input {
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    background: #eef0f4;
    font-size: 14px;
    font-family: 'Sarabun', sans-serif;
}

.print-select-field select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.print-select-field select:focus,
.print-select-field input:focus {
    outline: none;
    background-color: #e4e7ec;
    box-shadow: 0 0 0 2px rgba(210, 139, 92, 0.3);
}

.print-select-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.print-select-actions button {
    flex: 1;
    border: none;
    border-radius: 999px;
    padding: 11px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    font-family: 'Sarabun', sans-serif;
    transition: all .2s ease;
}

.btn-print {
    background: #d28b5c;
    color: white;
}

.btn-print:hover {
    background: #bf7a4e;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(210, 139, 92, .35);
}



/* ===== BURN SCAR SUMMARY MODAL ===== */
#sum_report_bs_overlay {
    position: fixed;
    inset: 0;
    z-index: 3500;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
}

.sum-report-modal {
    width: 90vw;
    height: 90vh;
    background: #f8f9fa;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .8);
    animation: modalScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}


/* ===== FLOAT TABLE OVERLAY ===== */
#table_overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(5px);
    
    display: none;
    /* เริ่มต้นไม่แสดง */
    justify-content: center;
    align-items: center;
}

/* กล่องหลัก */
.table-modal {
    width: 95vw;    /* ปรับให้เล็กลงนิดนึงเพื่อให้เห็นพื้นหลัง */
    height: 90vh;
    background: #f8f9fa; /* สีพื้นโปร่ง ๆ นิดนึง */
    border-radius: 24px;

    display: flex;
    flex-direction: column;
    overflow: hidden;

    box-shadow:
        0 24px 60px rgba(0, 0, 0, .3),
        inset 0 1px 0 rgba(255, 255, 255, .8);
        
    animation: modalScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* header */
.table-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(135deg, #faaf78 0%, #d28b5c 100%);
    color: white;
    border-bottom: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10;
}

.table-modal-title {
    font-size: 20px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ปุ่มปิด */
.table-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.table-modal-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1) rotate(90deg);
}

/* BODY */
.table-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

/* รูปแบบ Filter Bar ด้านใน */
.modal-filter {
    background: #ffffff;
    border-radius: 18px;
    padding: 10px 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    flex-wrap: nowrap; /* แถวเดียวเท่านั้น */
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.modal-filter .btn-filter {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 8px 18px; /* เพิ่มพื้นที่ด้านข้างให้พอดีตัวหนังสือ */
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 0 0 auto; /* ไม่บังคับขยาย/ย่อ ให้พอดีเนื้อหา */
    width: auto;
    white-space: nowrap;
    overflow: visible;
}

/* แสดงทั้งหมด - สีเทาสุภาพ */
.modal-filter .btn-filter[onclick*="(0)"] {
    background: #f1f3f5;
    color: #495057;
}

/* รายงานแล้ว - สีเขียวธีมกรม */
.modal-filter .btn-filter[onclick*="(1)"] {
    background: #e9f5ec;
    color: #2d6a4f;
    border-color: #c2e7cc;
}

/* ยังไม่รายงาน - สีส้มธีมไฟป่า */
.modal-filter .btn-filter[onclick*="(2)"] {
    background: #fff4ec;
    color: #d28b5c;
    border-color: #fce1cc;
}

.modal-filter .btn-filter:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.modal-filter .btn-filter.active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    font-weight: 700;
}

.btn-excel {
    background: linear-gradient(135deg, #2d6a4f 0%, #1b4332 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 12px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(45, 106, 79, 0.2) !important;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-excel:hover {
    background: linear-gradient(135deg, #40916c 0%, #2d6a4f 100%) !important;
    box-shadow: 0 6px 18px rgba(45, 106, 79, 0.3) !important;
    transform: translateY(-1px);
}


/* Container ของตารางด้านในให้มีสีขาวบังหลัง */
.modal-table-container {
    flex: 1;
    background: white;
    border-radius: 16px;
    padding: 4px; /* เผื่อพื้นที่ให้ DataTables */
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* DataTables wrapper ด้านในสุด ให้ใช้ความสูงเต็มที่ */
.modal-table-container .dataTables_wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* โครงสร้างพื้นฐานของตารางใน Modal */
#modal_data_table,
.dataTables_scrollHeadInner table,
.dataTables_scrollBody table {
    width: 100% !important;
    border-collapse: collapse !important;
    border: none !important; /* ลบเส้นขอบนอกสุดออก */
    margin: 0 !important;
}

/* บังคับ Box-sizing ให้เป็น border-box ทั้งหมด เพื่อการคำนวณขนาดที่แม่นยำ */
#modal_data_table th,
#modal_data_table td,
.dataTables_scrollHead thead th {
    box-sizing: border-box !important;
}

/* เฉพาะหัวตารางที่ใช้แสดงผลค้างไว้ (Sticky Head) */
.dataTables_scrollHead {
    border-bottom: 2px solid rgba(0, 0, 0, 0.1) !important; /* เส้นแบ่งหัวกับตัวแบบชัดเจนเส้นเดียว */
}

.dataTables_scrollHead thead th {
    background-color: #f8f9fa !important;
    background: #f8f9fa !important;
    color: #444 !important;
    font-weight: 700 !important;
    padding: 14px 15px !important;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05) !important;
    border-right: 1px solid rgba(0, 0, 0, 0.04) !important;
    white-space: nowrap !important;
    text-align: center !important;
    text-shadow: none !important;
}

/* ล้างสไตล์ของหัวตารางตัวจริงที่ซ่อนอยู่ใน Body เพื่อไม่ให้เกิดภาพซ้อน */
.dataTables_scrollBody table {
    border-top: none !important;
    margin-top: -1px !important; /* ยกระดับขึ้นไปทับเส้นขอบเดิมเพื่อไม่ให้เห็นกรอบสองชั้น */
}

.dataTables_scrollBody thead th {
    border: none !important;
    padding: 0 !important;
    height: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    background: none !important;
    visibility: hidden !important;
}

#modal_data_table tbody td {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f1f1;
    border-right: 1px solid #f9f9f9;
    font-size: 14px;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#modal_data_table tbody tr:hover {
    background-color: #fff8f3 !important; /* ส้มอ่อนเวลา hover ให้เข้ากับตีม */
    transition: background-color 0.2s ease;
}

#modal_data_table tbody tr:nth-child(even) {
    background-color: #fdfdfd;
}

.modal-table-container .dataTables_scrollBody {
    flex: 1;
    overflow-y: auto !important; /* รองรับการ scroll เฉพาะ Body ของ DataTables */
}

/* DataTables Specific UI improvements */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 999px;
    border: 1px solid #ddd;
    padding: 6px 15px;
    margin-left: 10px;
    outline: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 999px !important;
    border: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #5b8c5a !important;
    color: white !important;
}

.dt-buttons .dt-button {
    background: #d28b5c !important;
    color: white !important;
    border: none !important;
    border-radius: 999px !important;
    padding: 6px 18px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    margin-right: 10px !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) !important;
}

.dt-buttons .dt-button:hover {
    background: #bf7a4e !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, .15) !important;
}
/* ===== MAP MODAL OVERLAY ===== */
#map_overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);

    /* สำคัญ */
    display: none;
    /* ซ่อนตอนเริ่ม */
    align-items: center;
    justify-content: center;

    z-index: 9999;
}

/* ===== MAP MODAL BOX ===== */
.map-modal {
    width: 70%;
    height: 70%;
    background: #fff;
    border-radius: 12px;

    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== HEADER ===== */
.map-modal-header {
    height: 48px;
    padding: 0 16px;
    background: #1f2937;
    color: #fff;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ===== BODY ===== */
.map-modal-body {
    flex: 1;
}

#geojson_map {
    width: 100%;
    height: 100%;
}

/* ❌ ปิด hover effect ใต้ map modal */
#map_overlay {
    pointer-events: auto;
}

.shadow-static {
    box-shadow:
        0 8px 18px rgba(0, 0, 0, .08),
        0 2px 6px rgba(0, 0, 0, .05),
        inset 0 1px 0 rgba(255, 255, 255, .7);
}

/* ป้องกัน header/body เหลื่อม */
table.dataTable {
    width: 100% !important;
}

div.dataTables_scrollHeadInner,
div.dataTables_scrollHeadInner table {
    width: 100% !important;
}

.dataTables_scrollBody table {
    width: 100% !important;
}

.big-table .filter-bar {
    background: white;
    padding: 12px 15px;
    margin-bottom: 0;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    border-radius: 22px 22px 0 0;
}

/* =========================
   PROCESSING MODAL (NEW)
========================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.processing-card {
    background: white;
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: swal-show 0.3s ease-out;
}

.spinner-box {
    margin-bottom: 10px;
}

.modern-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #d28b5c; /* สีธีมหลัก */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.processing-info .proc-title {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.processing-info .proc-status {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.btn-cancel-modal {
    margin-top: 10px;
    background: #f8f8f8;
    color: #888;
    border: 1px solid #eee;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-cancel-modal:hover {
    background: #fff0f0;
    color: #e53935;
    border-color: #ffcdd2;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes swal-show {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* =========================
   CUSTOM SWEETALERT THEME
========================= */
.swal-modal {
    font-family: 'Sarabun', sans-serif !important;
    border-radius: 20px !important;
    padding: 24px !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2) !important;
}

.swal-title {
    font-size: 22px !important;
    color: #2c3e50 !important;
    font-weight: 700 !important;
    margin-bottom: 15px !important;
    padding: 0 !important;
}

.swal-text {
    font-size: 16px !important;
    color: #555 !important;
    text-align: center !important;
    line-height: 1.6 !important;
}

.swal-button {
    font-family: 'Sarabun', sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    padding: 10px 28px !important;
    border-radius: 10px !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Success / Confirm Button */
.swal-button--confirm {
    background-color: #d28b5c !important; /* Orange-Brown Tone */
    color: #fff !important;
}

.swal-button--confirm:hover {
    background-color: #b9764a !important;
    transform: translateY(-1px) !important;
}

/* Cancel Button */
.swal-button--cancel {
    background-color: #f5f5f5 !important;
    color: #666 !important;
}

.swal-button--cancel:hover {
    background-color: #eeeeee !important;
}

/* Error/Danger Style (if used by swal) */
.swal-button--danger {
    background-color: #d32f2f !important;
}

.swal-icon--success::before,
.swal-icon--success::after,
.swal-icon--success__hide-corners {
    background: transparent !important;
}

.swal-icon--success__line {
    background-color: #4caf50 !important;
}

.swal-icon--success__ring {
    border: 4px solid rgba(76, 175, 80, 0.2) !important;
}

.swal-footer {
    text-align: center !important;
    margin-top: 25px !important;
}
/* ====================================================
   MIGRATED FROM EJS (UTILITIES & COMPONENTS)
   ==================================================== */

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

.icon-lg {
    font-size: 24px;
}

.btn-process-sum {
    background: #2d6a4f;
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 12px;
    font-weight: 600;
}

.btn-excel-sum {
    background: #27ae60;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    margin-left: 10px;
}

.summary-content {
    flex: 1;
    overflow: auto;
    padding: 10px;
    background: white;
    border-radius: 16px;
}

.full-width {
    width: 100%;
}

.align-middle {
    vertical-align: middle;
}

.text-center-placeholder {
    text-align: center !important;
    color: #888;
    padding: 50px;
}

.modal-title-small {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.9;
}

.label-filter {
    font-weight: 600;
    color: #555;
    margin-right: 10px;
}

.spacer {
    flex: 1;
}

.icon-sm {
    font-size: 16px;
}

.small-unit {
    font-size: 0.5em;
    opacity: 0.7;
}

.bg-darkgreen {
    background: darkgreen;
    border-radius: 4px;
}

.contact-map iframe {
    border: 0;
}

/* =========================
   MOBILE PORTRAIT (Responsive)
========================= */
@media (max-width: 768px) {
    .app {
        min-width: 0 !important;
        width: 100% !important;
        height: auto !important;
        display: block !important;
        overflow-x: hidden;
    }

    #map-legend-floating {
        display: block !important;
        zoom: 0.5 !important;
        top: auto !important;
        left: auto !important;
        right: 10px !important;
        bottom: 10px !important;
        z-index: 1000 !important;
    }

    .header {
        padding: 15px !important;
        height: auto !important;
        min-height: 80px;
        flex-direction: column;
        gap: 15px;
    }

    .logo {
        height: 45px;
        margin-bottom: 5px;
    }

    .hazard-menu {
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 10px;
        width: 100%;
        justify-content: flex-start;
        display: flex;
        -webkit-overflow-scrolling: touch;
    }

    .hazard-item {
        flex: 0 0 auto;
    }

    .header-right {
        width: 100%;
        justify-content: center;
        margin-left: 0;
        gap: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(255,255,255,0.2);
    }

    .fire-content {
        display: block !important;
        height: auto !important;
        padding: 0 10px;
    }

    .sub-menu {
        overflow-x: auto;
        white-space: nowrap;
        padding: 10px;
        margin: 10px 0;
        border-radius: 12px;
        display: flex;
        -webkit-overflow-scrolling: touch;
    }

    .sub {
        flex: 0 0 auto;
    }

    .filter-bar {
        flex-wrap: wrap !important;
        height: auto !important;
        gap: 10px !important;
        padding: 15px !important;
        margin-bottom: 15px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .filter-bar label {
        width: 100%;
        margin-bottom: 0;
    }

    .filter-bar select, 
    .filter-bar .date-box,
    .filter-bar button {
        width: 100% !important;
        flex: none !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .filter-bar button {
        white-space: normal !important;
        height: auto !important;
        min-height: 44px;
        padding: 10px 15px !important;
        line-height: 1.4;
    }

    .filter-bar .date-box {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 8px;
    }

    .view-dashboard {
        flex-direction: column !important;
        height: auto !important;
        overflow: visible !important;
        display: block !important;
    }

    .side-panel {
        width: 100% !important;
        grid-template-columns: 1fr !important;
        height: auto !important;
        padding: 0 !important;
        gap: 15px !important;
        overflow: visible !important;
        display: block !important;
    }

    .left-column, .right-column {
        width: 100% !important;
        display: flex !important;
        flex-direction: column;
        gap: 15px;
        padding: 0 !important;
        margin-bottom: 15px;
    }

    .metric-card, .big-table, .big-graph {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 0 15px 0 !important;
    }

    .map-area {
        width: 100% !important;
        height: 450px !important;
        margin: 10px 0 20px 0 !important;
        order: -1; 
        box-sizing: border-box !important;
    }

    #hotspot_viirs_count_table_content {
        max-height: 200px !important; /* ลดความสูงลงเพื่อประหยัดพื้นที่ */
        width: 100% !important;
    }

    #hotspot_viirs_count_table_content table th,
    #hotspot_viirs_count_table_content table td {
        font-size: 9px !important;     /* ลดขนาดฟอนต์ลงอีกนิด */
        white-space: nowrap !important; /* ห้ามตัดบรรทัด */
        padding: 3px 5px !important;    /* ลด Padding */
        overflow: hidden !important;
        text-overflow: ellipsis !important; /* แสดง ... ถ้าข้อความยาวเกิน */
        max-width: 80px !important;     /* กำหนดความกว้างสูงสุดเพื่อบังคับ nowrap */
    }

    #hotspot_viirs_count_table_content table td {
        display: table-cell !important; /* มั่นใจว่าเป็น table-cell */
    }

    .big-graph {
        height: 350px !important;
    }

    /* Removed for testing at end of file */

    /* Modals adjustments */
    .contact-card, .login-box, .print-select-box {
        width: 95% !important;
        max-width: 100% !important;
        margin: 10px;
    }

    .contact-body {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .contact-map {
        height: 200px;
    }

    .fullscreen-modal {
        width: 98vw;
        height: 96vh;
        border-radius: 15px;
    }

    .table-modal {
        width: 96% !important;
        height: 96% !important;
    }

    .table-modal-body {
        display: block !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        height: calc(100% - 60px) !important; /* Adjust based on header height */
    }

    .modal-table-container {
        flex: none !important;
        height: auto !important;
        overflow: visible !important;
    }

    .dataTables_scrollBody {
        height: auto !important;
        max-height: 500px !important;
    }

    .metric-card .value {
        font-size: 2rem;
    }

    .activity-grid {
        grid-template-columns: 1fr;
    }

    .activity-item.wide {
        grid-column: span 1;
    }

    /* Modal Filter Specific for Mobile */
    .modal-filter {
        flex-wrap: wrap !important;
        height: auto !important;
        gap: 12px !important;
        padding: 15px !important;
    }

    .modal-filter span {
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: center !important;
        border-bottom: 1px solid #eee;
        padding-bottom: 10px;
    }

    .modal-filter span:last-of-type {
        border-bottom: none;
    }

    .modal-filter .btn-filter, 
    .modal-filter .input-filter,
    .modal-filter .btn-excel {
        width: 100% !important;
        flex: none !important;
        margin: 0 !important;
    }

    .modal-filter .input-filter {
        height: 44px !important;
        padding: 0 15px !important;
        border-radius: 12px !important;
        border: 1px solid #e0e0e0 !important;
        background: #f8f9fa !important;
        font-size: 14px !important;
    }

    .modal-filter .label-filter {
        width: 100% !important;
        text-align: center !important;
        margin: 0 0 5px 0 !important;
    }

    .flex-center-gap {
        gap: 8px !important;
    }

    /* ซ่อน Label บนแผนที่สำหรับมือถือแนวตั้ง */
    .leaflet-tooltip,
    .leaflet-label,
    .leaflet-tooltip-pane,
    .leaflet-static-label,
    .label-admin,
    .leaflet-marker-pane div,
    [class*="label-"],
    .leaflet-marker-icon.label-admin {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

/* =========================
   MOBILE LANDSCAPE (Responsive)
========================= */
@media (orientation: landscape) and (max-height: 900px) {

    html, body {
        width: 100vw !important;
        height: 100vh !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .app {
        height: 100vh !important;
        width: 100vw !important;
        max-width: 100vw !important;
        display: flex !important;
        flex-direction: column !important;
        background: #f4f6f9 !important;
        overflow: hidden !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        grid-template-rows: none !important; /* ยกเลิก Grid จาก Desktop */
    }

    #map-legend-floating {
        display: block !important;
        zoom: 0.5 !important;
        top: auto !important;
        left: auto !important;
        right: 10px !important;
        bottom: 10px !important;
        z-index: 1000 !important;
    }

    .header {
        flex: none !important;
        height: 70px !important;
        min-height: 70px !important;
        padding: 0 12px !important;         /* ลด padding ขอบลงเหลือ 12px */
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;               /* ลด gap ระหว่าง Logo/Menu/Right เหลือ 12px */
        background: linear-gradient(135deg, #faaf78 0%, #df8549 50%, #c86932 100%) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.25) !important;
        box-shadow: 0 8px 24px rgba(200, 105, 50, 0.2) !important;
        z-index: 1000 !important;
        position: relative !important;
        width: 100% !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .logo {
        height: 32px !important;            /* ลดความสูงโลโก้ลงอีก */
        width: auto !important;
        max-width: 150px !important;        /* จำกัดความกว้างไม่ให้เบียด */
        flex-shrink: 0 !important;
        margin: 0 !important;
        cursor: pointer !important;
    }

    .hazard-menu {
        display: flex !important;
        gap: 6px !important;                /* ลด gap ระหว่างปุ่มเมนูเหลือ 6px */
        padding: 0 5px !important;
        margin: 0 !important;
        background: transparent !important;
        flex: 1 1 0 !important;             /* กินพื้นที่ที่เหลือ */
        align-items: center !important;
        overflow-x: auto !important;        /* ให้เลื่อนแนวนอนได้ถ้าเมนูเยอะเกิน */
        overflow-y: hidden !important;
        min-width: 0 !important;            /* สำคัญ: ให้ flex item หดได้ */
        -webkit-overflow-scrolling: touch !important;
    }

    /* ซ่อน scrollbar สำหรับ hazard-menu */
    .hazard-menu::-webkit-scrollbar {
        display: none !important;
    }

    .hazard {
        flex: 0 0 auto !important;
        text-align: center !important;
        padding: 4px 10px !important;       /* ลด padding ลงเหลือ 4px 10px */
        border-radius: 8px !important;
        cursor: pointer !important;
        background: rgba(255, 255, 255, 0.7) !important;
        backdrop-filter: blur(4px) !important;
        transition: .2s !important;
        font-size: 10px !important;         /* ลดฟอนต์เหลือ 10px */
        white-space: nowrap !important;
        color: #333 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border: none !important;
        min-width: 32px !important;         /* ขนาดขั้นต่ำเล็กลง */
    }

    .hazard.active {
        background: #ffffff !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, .15) !important;
        font-weight: 800 !important;
        color: #9a7d0a !important;
    }

    .hazard-icon {
        font-size: 16px !important;         /* ลดขนาดไอคอนเหลือ 16px */
    }

    .hazard-text {
        margin-left: 5px !important; /* ระยะห่างข้อความแบบ cropins */
        font-weight: inherit !important;
    }

    /* ตรรกะแสดงเฉพาะ Active Text */
    .hazard:not(.active) .hazard-text {
        display: none !important;
    }

    .hazard.active .hazard-text {
        display: inline-block !important;
    }

    .header-right {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        flex-shrink: 0 !important;          /* ห้ามหด */
        margin-left: auto !important;
        min-width: fit-content !important;
    }

    .btn-header-contact {
        padding: 5px 10px !important;       /* ลด padding ปุ่มให้เล็กลง */
        font-size: 11px !important;         /* ลดขนาดฟอนต์ปุ่ม */
        white-space: nowrap !important;
        height: 32px !important;            /* กำหนดความสูงให้พอดีกับโลโก้ */
        display: flex !important;
        align-items: center !important;
    }

    #user_display {
        display: none !important;           /* ซ่อนชื่อผู้ใช้ใน landscape เพื่อเพิ่มพื้นที่ */
    }

    #user_display {
        font-weight: 800 !important;
        color: #ffffff !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
        font-size: 14px !important; /* ขนาดฟอนต์ชื่อแบบ cropins */
    }

    .btn-header-contact {
        background: white !important;
        border: none !important;
        border-radius: 999px !important;
        padding: 8px 18px !important; /* Padding ปุ่มแบบ cropins */
        font-weight: 600 !important;
        font-size: 13px !important;
        color: #9a7d0a !important;
        cursor: pointer !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
    }


    .fire-content {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;        /* เลื่อนได้ใน landscape */
        -webkit-overflow-scrolling: touch !important;
    }

    /* เพิ่มขนาดวัตถุด้านใน .fire-content ทั้งหมด 30% */
    .fire-content > * {
        zoom: 1.3 !important;
    }

    /* === ปุ่มซ่อน/แสดง Panels === */
    .btn-toggle-panels {
        display: flex !important;           /* แสดงเฉพาะ landscape */
        align-items: center !important;
        gap: 6px !important;
        margin: 4px 8px !important;
        padding: 5px 14px !important;
        background: linear-gradient(135deg, #faaf78, #c86932) !important;
        color: white !important;
        border: none !important;
        border-radius: 999px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        cursor: pointer !important;
        box-shadow: 0 2px 8px rgba(200, 105, 50, 0.3) !important;
        transition: all 0.2s !important;
        flex-shrink: 0 !important;
        zoom: 1 !important;                 /* ยกเว้นจาก zoom 1.3 ของ parent */
    }

    .btn-toggle-panels:active {
        opacity: 0.8 !important;
        transform: scale(0.97) !important;
    }

    /* === Collapsed State === */
    /* ซ่อนเฉพาะแถบเลือกพื้นที่ด้านบน และเมนูย่อย เมื่อกดซ่อนเมนู */
    .fire-content.panels-hidden .sub-menu,
    .fire-content.panels-hidden > .filter-bar {
        display: none !important;
    }
    /* แถบ .filter-bar ที่อยู่ใน .big-table จะไม่ได้รับผลกระทบเพราะไม่ใช่ลูกโดยตรงของ .fire-content */

    .fire-content.panels-hidden .btn-toggle-panels {
        background: rgba(255,255,255,0.9) !important;
        color: #c86932 !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.1) !important;
    }

    .filter-bar {
        display: flex !important; /* บังคับให้แสดงผลเป็น flex เสมอ */
        height: auto !important;
        padding: 8px 12px !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        visibility: visible !important;
        opacity: 1 !important;
        background: #ffffff !important;
        border-bottom: 1px solid #eee !important;
        z-index: 100 !important;
    }

    .filter-bar button {
        padding: 6px 12px !important;      /* ลด padding ปุ่มลง */
        font-size: 11px !important;        /* ลดขนาดฟอนต์ปุ่ม */
        height: auto !important;           /* ให้ความสูงปรับตามเนื้อหา */
        border-radius: 6px !important;
        margin-top: 5px !important;        /* เพิ่มระยะห่างด้านบนเมื่อมีการปัดลงบรรทัดใหม่ */
    }

    .filter-bar label {
        display: none !important;
    }

    /* บรรทัดที่ 1: Select พื้นที่ */
    .filter-bar select {
        height: 32px !important;
        font-size: 11px !important;
        flex: 1 1 23% !important; /* ให้แบ่งกัน 4 ตัวในแถวเดียว */
        min-width: 80px !important;
        padding: 0 5px !important;
    }

    /* บรรทัดที่ 2: เริ่มต้นที่ Date Box */
    .filter-bar .date-box {
        width: auto !important;
        height: 32px !important;
        flex: 0 0 auto !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 4px !important;
        margin-top: 4px !important;
        padding: 0 8px !important;
        border: 1px solid #ddd !important;
        border-radius: 6px !important;
    }

    .filter-bar .date-box input {
        width: 85px !important;
        font-size: 11px !important;
        border: none !important;
        background: transparent !important;
    }

    /* Legend และปุ่มในบรรทัดที่ 2 */
    .filter-bar .legend {
        margin: 4px 0 0 10px !important;
        padding: 0 !important;
        flex: 0 0 auto !important;
    }

    .filter-bar label {
        font-size: 10px !important;
        font-weight: 700 !important;
        margin-right: 2px !important;
        white-space: nowrap !important;
    }

    /* บังคับให้หัวข้อ "ช่วงเวลา" และสิ่งที่ตามมาขึ้นบรรทัดใหม่ */
    .filter-bar label:nth-of-type(5) { 
        flex-basis: 100% !important;
        width: 100% !important;
        margin-top: 8px !important;
        padding-top: 8px !important;
        border-top: 1px dashed #eee !important; /* เพิ่มเส้นแบ่งจางๆ ให้ดูเป็นระเบียบ */
    }

    .filter-bar button {
        height: 32px !important;
        font-size: 11px !important;
        padding: 0 12px !important;
        margin-top: 4px !important;
        flex: 1 1 auto !important; /* ให้ปุ่มขยายตามพื้นที่ที่เหลือ */
        white-space: nowrap !important;
    }


    .view-dashboard {
        flex: 1 !important;
        display: flex !important;
        flex-direction: row !important;
        height: auto !important;
        overflow: hidden !important;
    }


    #view-dashboard {
        height: 150% !important;            /* เพิ่มความสูงขึ้น 50% เพื่อให้ scroll ได้ */
        min-height: 0 !important;
    }

    .side-panel {
        width: 68% !important;
        height: 100% !important;
        overflow-y: auto !important;
        padding: 8px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .map-area {
        width: calc(32% - 5px) !important;
        height: calc(90% + 15px) !important; /* เพิ่มขึ้นอีก 5px รวมเป็น +15px */
        margin: 0 !important;
        border-radius: 0 !important;
        align-self: center !important;
    }

    #map-title-overlay, 
    .map-label, 
    .map-title {
        display: none !important;
    }

    .btn-expand-map {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 10001 !important; /* สูงกว่าเลเยอร์อื่น */
        top: 5px !important;
        right: 5px !important;
        width: 32px !important;
        height: 32px !important;
        background: white !important;
        border: 1px solid rgba(0,0,0,0.3) !important;
    }

    /* ปรับความหนาของเส้นและป้ายชื่อในแผนที่: ซ่อนป้ายชื่อเสมอในมือถือ */
    .leaflet-pane path,
    .leaflet-interactive,
    .leaflet-vector-layers path {
        stroke-width: 0.5px !important; 
        stroke: #333 !important;
    }

    /* ซ่อนป้ายชื่อและ Label ทั้งหมดในโหมดแนวนอน */
    .leaflet-tooltip,
    .leaflet-label,
    .leaflet-tooltip-pane,
    .leaflet-static-label,
    .label-admin,
    .leaflet-marker-pane div,
    [class*="label-"],
    .leaflet-marker-icon.label-admin {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    #map {
        height: 100% !important;
        width: 100% !important;
    }


    .left-column {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
        margin-bottom: 10px !important; /* ลดระยะห่างด้านล่าง */
        min-height: auto !important; /* ปรับความสูงตามวัตถุ */
        align-content: start !important;
    }


    #table_area {
        width: 100% !important;
        height: auto !important;
        max-height: 350px !important; /* ปรับให้สูงขึ้นเป็น 350px เพื่อให้เห็นข้อมูล */
        min-height: 200px !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        overflow-y: auto !important;
    }



    .left-column .metric-card {
        margin-bottom: 0 !important;
        padding: 2px 4px !important; /* ลด Padding ภายในการ์ดเหลือขั้นต่ำ */
        min-height: 38px !important; /* ลดความสูงขั้นต่ำลงอีก */
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
        border-radius: 8px !important;
    }

    /* ลดความสูงเฉพาะ hotspot-total และ hotspot-agri ลงอีก 10% */
    .metric-card.hotspot-total,
    .metric-card.hotspot-agri {
        min-height: 19px !important; /* ลดจาก 21px เหลือ 19px */
        padding: 0px 4px !important;
        gap: 0 !important;
    }

    .metric-card.hotspot-total .metric-title,
    .metric-card.hotspot-agri .metric-title,
    .metric-card.hotspot-total .metric-title span,
    .metric-card.hotspot-agri .metric-title span,
    .metric-card.hotspot-total .metric-title small,
    .metric-card.hotspot-agri .metric-title small,
    .metric-card.agri-activity .metric-title span,
    .metric-card.agri-activity .metric-title small {
        font-size: 0.6rem !important; /* ปรับขนาดเป็น 0.6rem */
        line-height: 1.1 !important;
    }

    .metric-card.hotspot-total .metric-icon,
    .metric-card.hotspot-agri .metric-icon {
        font-size: 0.5rem !important; /* ลดไอคอนลงเหลือ 0.5rem */
    }


    .left-column .metric-card.agri-activity {
        grid-column: span 2 !important; 
        min-height: 100px !important; /* ปรับเป็น 100px ตามคำขอ */
        display: flex !important;
        flex-direction: column !important; /* กลับเป็นแนวตั้งเพื่อให้สมดุลกับความสูง */
        justify-content: center !important;
        align-items: center !important;
        padding: 10px !important;
        gap: 8px !important;
        overflow: hidden !important;
    }

    .metric-card.agri-activity .metric-header {
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
    }

    .metric-card.agri-activity .activity-grid {
        display: flex !important;
        flex-direction: row !important;
        gap: 10px !important; 
        align-items: center !important;
        margin: 0 !important;
        flex-wrap: nowrap !important;
    }

    .metric-card.agri-activity .activity-item {
        display: flex !important;
        flex-direction: row !important; 
        align-items: baseline !important;
        gap: 2px !important;
    }

    .metric-card.agri-activity .activity-item label {
        font-size: 0.32rem !important; /* ลดขนาดลงเล็กน้อย */
        font-weight: 600 !important;
        color: #666 !important;
        margin: 0 !important;
        white-space: nowrap !important;
    }

    .metric-card.agri-activity .activity-item .value-small {
        font-size: 0.55rem !important; /* ลดขนาดตัวเลขลงเพื่อไม่ให้ล้นขอบ */
        font-weight: 800 !important;
        color: #c86932 !important;
    }

    .metric-card.agri-activity .activity-item sub {
        font-size: 0.28rem !important;
        bottom: 0 !important;
        opacity: 0.6 !important;
    }


    .left-column .metric-card.agri-activity .metric-header {
        margin-bottom: 6px !important; /* เพิ่มระยะห่างด้านล่างหัวข้อด้วย */
    }



    .metric-card .metric-header {
        margin-bottom: 1px !important;
        justify-content: center !important;
        gap: 3px !important;
    }

    .metric-card .metric-icon {
        font-size: 0.7rem !important; /* ไอคอนเล็กลงที่สุด */
        margin-right: 0 !important;
    }

    .metric-card .metric-title {
        font-size: 0.42rem !important; /* ตัวหนังสือเล็กระดับ Micro */
        line-height: 1 !important;
        font-weight: 600 !important;
    }

    .metric-card .metric-title small {
        font-size: 0.38rem !important; /* เล็กที่สุดเท่าที่จะเป็นไปได้ */
        opacity: 0.7;
        display: block;
    }


    .metric-card .value {
        font-size: 0.95rem !important;
        font-weight: 800 !important;
        line-height: 1 !important;
    }

    #legend_mode_text {
        font-size: 10px !important; /* ลดขนาดฟอนต์ของคำอธิบาย Legend */
    }

    .metric-card .metric-footer {
        display: block !important; /* แสดงผลตามคำขอ */
        font-size: 0.35rem !important; /* เล็กที่สุดเพื่อให้ยังเห็นได้ */
        margin-top: 2px !important;
        opacity: 0.6;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }


    .activity-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        width: 100% !important;
    }

    .activity-item {
        display: flex !important;
        flex-direction: row !important; /* บังคับแถวเดียวกัน */
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        flex-wrap: nowrap !important; /* ห้ามขึ้นบรรทัดใหม่ */
        border-bottom: 1px dotted rgba(0,0,0,0.05);
        padding-bottom: 1px;
    }


    .activity-item label {
        font-size: 0.45rem !important;
        margin: 0 !important;
        white-space: nowrap;
    }

    .activity-item .value-small {
        font-size: 0.6rem !important;
        font-weight: 700 !important;
    }

    .activity-item sub {
        display: none !important;
    }

    .big-table {
        width: 100% !important;
        height: auto !important;
        min-height: auto !important; 
        margin-bottom: 10px !important;
        overflow: visible !important; /* เปลี่ยนเป็น visible เพื่อให้ปุ่มไม่หาย */
        display: flex !important;
        flex-direction: column !important;
    }

    #hotspot_viirs_count_table_content {
        width: 100% !important;
        height: auto !important;
        max-height: 250px !important;
    }

    /* ลดขนาดตัวหนังสือในตารางสำหรับแนวนอน (เล็กลงอีก) */
    #hotspot_viirs_count_table thead th {
        font-size: 7px !important;
        padding: 4px 1px !important;
    }
    #hotspot_viirs_count_table td {
        font-size: 8px !important;
        padding: 4px 2px !important;
    }

    /* ลดขนาดปุ่มใน table_area */
    #table_area .filter-bar button {
        font-size: 9px !important;
        height: 28px !important;
        padding: 0 8px !important;
        margin-top: 2px !important;
    }

    .big-graph {
        width: 100% !important;
        height: 300px !important;
        min-height: 200px !important;
    }

    .big-graph .btn-expand-table {
        font-size: 11px !important;
    }

    .table-modal-body {
        display: block !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        height: calc(100vh - 100px) !important;
        max-height: 85vh !important;
        padding: 10px !important;
    }

    .modal-table-container {
        width: 100% !important;
        overflow-x: auto !important;
    }

    .big-table .btn-expand-table {
        display: flex !important;
        position: absolute !important; 
        top: 60px !important;        /* เลื่อนลงมา 50px จากเดิม 10px */
        right: 10px !important;
        width: 26px !important;  
        height: 26px !important;
        background: white !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 6px !important;
        z-index: 10000 !important;
        color: #d28b5c !important;
        font-size: 11px !important;
        justify-content: center !important;
        align-items: center !important;
        transform: none !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
    }

    /* ปรับ Modal ติดต่อเราให้พอดีกับจอแนวตั้งในโหมดแนวนอน */
    .contact-card {
        max-height: 95vh !important;
        width: 90% !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        margin: auto !important;
    }
    .contact-header {
        padding: 10px 20px !important;
    }
    .contact-body {
        overflow-y: auto !important;
        padding: 15px !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
        flex: 1 !important;
    }
    .contact-map {
        height: 180px !important;
    }
    .dept-name {
        font-size: 14px !important;
        margin-bottom: 10px !important;
    }
    .info-item {
        font-size: 12px !important;
        margin-bottom: 8px !important;
        gap: 8px !important;
    }
}



