@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;
    height: 100%;
    overflow: hidden;
}

/* =========================
   HEADER & NAVIGATION
========================= */
.app {
    height: 100vh;
    display: grid;
    grid-template-rows: minmax(90px, 10vh) 1fr;
}

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

.logo {
    height: 60px;
    cursor: pointer;
}

/* =========================
   MENUS
========================= */
.hazard-menu {
    display: flex;
    gap: 15px;
    padding: 0;
    background: transparent;
    flex: 1;
}

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

.hazard-item.disabled {
    cursor: pointer;
    opacity: 0.7;
}

.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);
}

.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;
    min-width: 45px;
}

.hazard:hover {
    background: #fffde7;
}

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

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

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

/* Tooltip & Compact style */
.hazard-item:not(.active-container) .hazard-text {
    display: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
    flex-shrink: 0;
}

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

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

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

/* =========================
   DASHBOARD MAIN (Layout)
========================= */
.dashboard-main {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

/* 1. Trigger Bar (3%) */
.sidebar-trigger-bar {
    width: 3%;
    min-width: 40px; 
    background: linear-gradient(180deg, #f7971e 0%, #ffd200 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 1005;
    box-shadow: 2px 0 10px rgba(247, 151, 30, 0.2);
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
    margin: 10px 0;
    height: calc(100% - 20px);
}

.sidebar-trigger-bar:hover {
    background: #ffffff;
    color: #9a7d0a;
}

/* 2. Side Panel (47%) */
.info-sidebar {
    width: 47%;
    min-width: 400px; 
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    padding: 15px;
    background: #fffde7;
    border-right: 1px solid #fff59d;
    transition: all 0.4s ease;
    z-index: 900;
}

/* 3. Map Area (50%) */
.map-container {
    width: 50%;
    flex: 0 0 50%;
    position: relative;
    background: white;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.4s ease;
}

/* Sidebar Collapsed State */
.sidebar-collapsed .info-sidebar {
    width: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: none;
    opacity: 0;
    pointer-events: none;
}

.sidebar-collapsed .map-container {
    width: 97%;
    flex: 0 0 97%;
}

.sidebar-collapsed .sidebar-trigger-bar i {
    transform: rotate(180deg);
}

.map-title-overlay {
    width: 100%;
    text-align: center;
    padding: 15px 0;
    font-weight: 800;
    font-size: 28px;
    color: #9a7d0a;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(6px);
    z-index: 800;
}

#map {
    width: 100%;
    flex: 1;
}

/* =========================
   SIDEBAR COMPONENTS
========================= */
.info-card {
    background: white;
    border-radius: 18px;
    padding: 15px;
    border: 1px solid rgba(247, 151, 30, 0.2);
    box-shadow: 0 4px 12px rgba(154, 125, 10, 0.03);
    height: auto;
    min-height: fit-content;
}

.card-title {
    font-weight: 800;
    color: #9a7d0a;
    font-size: 15px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    cursor: pointer;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-direction: column;
    padding: 15px 20px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(154, 125, 10, 0.04);
    margin-bottom: 15px;
    border: 1px solid rgba(247, 151, 30, 0.15);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed rgba(247, 151, 30, 0.2);
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-item label {
    font-size: 12.5px;
    font-weight: 700;
    color: #9a7d0a;
}

.filter-item select {
    border: 1px solid #fff59d;
    border-radius: 12px;
    padding: 0 14px;
    background: #fffde7;
    font-size: 14px;
    color: #9a7d0a;
    height: 44px;
    outline: none;
}

.btn-filter-process {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.btn-filter-process:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(247, 151, 30, 0.3);
}

/* Crop Risk Summary */
.crop-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid rgba(247, 151, 30, 0.2);
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.crop-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #fff9c4;
}

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

.crop-name {
    font-weight: 800;
    font-size: 16px;
    color: #9a7d0a;
}

.risk-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.risk-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 5px;
    border-radius: 12px;
    background: #fdfdfd;
    border: 1px solid #f0f0f0;
}

.risk-item.risk-1 { border-top: 4px solid #4caf50; background: #f1f8e9; }
.risk-item.risk-2 { border-top: 4px solid #ffeb3b; background: #fffde7; }
.risk-item.risk-3 { border-top: 4px solid #f44336; background: #ffebee; }

.risk-label {
    font-size: 11px;
    font-weight: 700;
    color: #666;
    margin-bottom: 5px;
}

.risk-metrics {
    width: 100%;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    line-height: 1.4;
    padding: 2px 5px;
}

.metric-row span:first-child {
    color: #777;
    font-weight: 400;
}

.metric-row span:last-child {
    font-weight: 700;
    color: #333;
}

/* Area Summary Table */
.area-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.area-summary-table th {
    background: #f7971e;
    color: white;
    padding: 8px 4px;
    text-align: center;
    font-weight: 700;
}

.area-summary-table td {
    padding: 8px 4px;
    border-bottom: 1px solid #eee;
    text-align: right;
}

.area-summary-table td:first-child {
    text-align: left;
    font-weight: 700;
    color: #9a7d0a;
}

.area-summary-table tr:hover {
    background: #fffde7;
}

.stats-summary {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: stretch;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.contact-card {
    background: white;
    width: 800px;
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

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

.side-logo {
    width: 100%;
    max-height: 140px;
    object-fit: contain;
}

/* =========================
   MAP LABELS (Standardized)
========================= */
.label {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
    font-weight: 900;
    white-space: nowrap;
    line-height: 1;
    text-shadow: 
        2px 2px 0 #FFFFFF, 
        -2px 2px 0 #FFFFFF, 
        2px -2px 0 #FFFFFF, 
        -2px -2px 0 #FFFFFF, 
        0 0 5px #FFFFFF;
    pointer-events: none;
}

/* =========================
   CONTACT MODAL
========================= */
.contact-card {
    background: white;
    width: 800px;
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: swal-show 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-header {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 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: background 0.3s;
}

.contact-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

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

.dept-name {
    color: #9a7d0a;
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 25px;
}

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

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

.contact-map {
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #fff59d;
    height: 350px;
}

/* =========================
   PROCESSING CARD
========================= */
.processing-card {
    background: white;
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    text-align: center;
    animation: swal-show 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.spinner-box {
    padding: 10px;
}

.modern-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #fffde7;
    border-top: 4px solid #f7971e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.processing-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.proc-title {
    font-size: 22px;
    font-weight: 800;
    color: #9a7d0a;
    letter-spacing: -0.5px;
}

.proc-status {
    font-size: 14.5px;
    color: #f7971e;
    line-height: 1.5;
    font-weight: 500;
}

.btn-cancel-modal {
    width: 100%;
    padding: 12px;
    border: 1px solid #fff59d;
    background: #fffde7;
    color: #9a7d0a;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13.5px;
    margin-top: 10px;
}

.btn-cancel-modal:hover {
    background: #fff9c4;
    color: #e63946;
    border-color: #ffb3b3;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes swal-show { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }


.clickable-risk {
    cursor: pointer !important;
}

/* Arrow Rotation for Collapse */
.fa-chevron-down {
    transition: transform 0.3s ease;
}
.rotated {
    transform: rotate(180deg);
}

/* =========================
   MOBILE PORTRAIT (Responsive)
========================= */
@media (max-width: 768px) {
    html, body {
        height: auto !important;
        overflow: auto !important;
    }

    .app {
        min-width: 0 !important;
        width: 100% !important;
        height: auto !important;
        display: block !important;
        overflow-x: hidden;
    }

    .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: 15px;
        padding-top: 10px;
        border-top: 1px solid rgba(255,255,255,0.2);
    }

    .dashboard-main {
        flex-direction: column !important;
        height: auto !important;
        padding: 0 !important;
        gap: 0 !important;
        display: flex !important;
        overflow: visible !important;
    }

    .sidebar-trigger-bar {
        display: none !important;
    }

    .map-container {
        width: 100% !important;
        height: 450px !important;
        flex: none !important;
        order: -1; /* แผนที่อยู่บนสุด */
    }

    .map-title-overlay {
        font-size: 18px !important;
        padding: 10px 15px;
    }

    .info-sidebar {
        width: 100% !important;
        min-width: 0 !important;
        padding: 15px !important;
        overflow: visible !important;
        background: #fffde7 !important;
        border-right: none !important;
    }

    .info-card {
        width: 100% !important;
        margin-bottom: 15px;
    }

    .filter-bar {
        width: 100% !important;
        margin-bottom: 15px;
    }

    .crop-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .risk-grid {
        grid-template-columns: 1fr; /* Stack risk items on mobile */
    }

    .area-summary-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Modals */
    .contact-card, .processing-card {
        width: 95% !important;
        max-width: 100% !important;
        margin: 10px;
    }

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

    .contact-map {
        height: 200px;
    }

    /* Map labels on mobile portrait (Handled via JS scaling) */
}

/* =========================
   MOBILE LANDSCAPE (Responsive)
   ป้องกันวัตถุใน Header ล้นออกนอกหน้าจอ
   ไม่กระทบ Desktop และ Portrait
========================= */
@media (orientation: landscape) and (max-height: 600px) {

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

    .app {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;          /* บังคับให้ชิดขอบล่าง */
        right: 0 !important;           /* บังคับให้ชิดขอบขวา */
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        grid-template-rows: unset !important;
        grid-template-columns: unset !important;
    }

    .header {
        flex: none !important;
        height: 70px !important;
        min-height: 70px !important;
        padding: 0 12px !important;         /* ลด padding ขอบลงเหลือ 12px */
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;               /* ลด gap ระหว่าง Logo/Menu/Right เหลือ 12px */
        background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.25) !important;
        box-shadow: 0 8px 24px rgba(247, 151, 30, 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; 
        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;
    }

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

    .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;
    }

    .dashboard-main {
        flex: 1 1 0 !important;            /* กินพื้นที่ที่เหลือทั้งหมดหลัง Header */
        display: flex !important;
        flex-direction: row !important;
        min-height: 0 !important;          /* สำคัญ: ให้ flex item หดได้ใน column */
        overflow: hidden !important;
        width: 100% !important;
        position: relative !important;
    }

    /* === Trigger Bar === */
    .sidebar-trigger-bar {
        width: 28px !important;
        min-width: 28px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        font-size: 14px !important;
        z-index: 100 !important;
        border-radius: 0 10px 10px 0 !important;
        margin: 6px 0 !important;
        height: calc(100% - 12px) !important;
    }

    /* === Info Sidebar (ซ้าย 62%) === */
    .info-sidebar {
        width: 62% !important;
        min-width: 62% !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        padding: 6px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        background: #f8f9fa !important;
        box-sizing: border-box !important;
    }

    /* === Map Container (ขวา 58%) === */
    .map-container {
        flex: 1 !important;
        height: 100% !important;
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* === Map Title === */
    .map-title-overlay {
        position: static !important;
        font-size: 10px !important;
        padding: 3px 10px !important;
        margin: 4px auto !important;
        width: fit-content !important;
        max-width: 95% !important;
        border-radius: 6px !important;
        text-align: center !important;
        background: rgba(255, 255, 255, 0.9) !important;
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        color: #555 !important;
        font-weight: 600 !important;
        z-index: 10 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* === Map === */
    #map {
        flex: 1 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
    }

    /* === Filter Bar (compact) === */
    .filter-bar {
        padding: 6px 8px !important;
        border-radius: 8px !important;
        flex: 0 0 auto !important;
        font-size: 11px !important;
    }

    .filter-bar .card-title {
        font-size: 11px !important;
        padding: 2px 0 !important;
    }

    .filter-group {
        gap: 4px !important;
        padding-top: 4px !important;
    }

    .filter-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
    }

    .filter-item label {
        font-size: 10px !important;
        white-space: nowrap !important;
        min-width: 50px !important;
    }

    .filter-item select {
        flex: 1 !important;
        font-size: 10px !important;
        padding: 2px 4px !important;
        height: 24px !important;
    }

    .btn-filter-process {
        font-size: 11px !important;
        padding: 4px 10px !important;
        margin-top: 4px !important;
    }

    /* === Stats Card === */
    .info-card {
        padding: 6px 8px !important;
        border-radius: 8px !important;
        flex: 0 0 auto !important;
    }

    .stats-card {
        font-size: 11px !important;
    }

    .stats-card .stats-header-design {
        margin-bottom: 6px !important;
        padding-left: 8px !important;
    }

    .stats-card .stats-header-design div:first-child {
        font-size: 12px !important;
    }

    .stats-summary {
        font-size: 11px !important;
    }

    /* Sidebar collapsed state */
    .sidebar-collapsed .info-sidebar {
        width: 0 !important;
        min-width: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        opacity: 0 !important;
    }

    .sidebar-collapsed .map-container {
        flex: 1 !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;
    }

    /* Map labels on mobile landscape (Handled via JS scaling) */
}

    /* === Crop Insurance Specific Styles === */
    .filter-card-title {
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .stats-header-design {
        margin-bottom: 15px !important;
        border-left: 4px solid #f7971e;
        padding-left: 12px !important;
        padding-top: 2px;
        padding-bottom: 2px;
    }
    .stats-title {
        font-weight: 800;
        color: #9a7d0a;
        font-size: 16px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .stats-subtitle {
        font-size: 12.5px;
        font-weight: 500;
        color: #7a6e4d;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .loading-text {
        text-align: center;
        padding: 20px;
        color: #9a7d0a;
    }
    .detailed-stats-container {
        margin-top: 5px;
        border-top: 1px solid #eee;
        padding-top: 8px;
    }
    .detailed-area-stats {
        max-height: 400px;
        overflow-y: auto;
        border-radius: 12px;
    }
    .empty-state-text {
        text-align: center;
        padding: 10px;
        font-size: 12px;
        color: #999;
    }
    .info-footer-text {
        margin-top: 20px;
        font-size: 13px;
        color: #666;
        line-height: 1.6;
        text-align: center;
    }
    
    /* Map Tooltip */
    .custom-map-tooltip {
        background: rgba(255, 255, 255, 0.95);
        border: none;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        padding: 8px 12px;
    }
    .custom-map-tooltip::before {
        display: none;
    }
    
    /* Table specific overrides */
    .area-summary-table {
        width: 100%;
        border-collapse: collapse;
        text-align: right;
        font-size: 10px;
        margin-top: 5px;
    }
    .area-summary-table th, .area-summary-table td {
        border: 1px solid #eee;
        padding: 4px;
    }
    .area-summary-table th {
        color: white;
        text-align: center;
        font-weight: 600;
    }
