* {
    user-select: none;
    box-sizing: border-box;
}

input, textarea {
    user-select: text !important;
    -webkit-user-select: text !important;
}

a {
    text-decoration: none;
}

body, main, div, span, label, button, input {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    line-height: 1.25;
    letter-spacing: normal;
    word-spacing: normal;
}

main {
    background-color: #FAFAFA;
    padding-top: 36px;
    scroll-padding-top: 36px;
}

/* Khi html lang="vi" thì ẩn tiếng Anh, hiện tiếng Việt */
html[lang="vi"] .lang-en { display: none !important; }
html[lang="vi"] .lang-vi { display: inline-block !important; }
/* Khi chuyển sang tiếng Anh thì ẩn tiếng Việt, hiện tiếng Anh */
html[lang="en"] .lang-vi { display: none !important; }
html[lang="en"] .lang-en { display: inline-block !important; }

/* ====================================================================
    MÀN HÌNH CHÀO KHI TẢI TRANG
   ==================================================================== */
#welcomescreen {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #FAFAFA;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 9999;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#welcomescreen.hide-welcome {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ====================================================================
    THANH CUỘN
   ==================================================================== */
.fieldgroup::-webkit-scrollbar, .tagzone::-webkit-scrollbar {
    height: 8px;
}
@media (max-width: 800px) {.fieldgroup::-webkit-scrollbar, .tagzone::-webkit-scrollbar {height: 5px;}}

[data-tile-panel]::-webkit-scrollbar, .optionbox-list::-webkit-scrollbar, .showlist::-webkit-scrollbar {
    width: 8px;
}
@media (max-width: 800px) {[data-tile-panel]::-webkit-scrollbar, .optionbox-list::-webkit-scrollbar, .showlist::-webkit-scrollbar {width: 5px;}}

[data-tile-panel]::-webkit-scrollbar-thumb,
.fieldgroup::-webkit-scrollbar-thumb,
.optionbox-list::-webkit-scrollbar-thumb,
.tagzone::-webkit-scrollbar-thumb,
.showlist::-webkit-scrollbar-thumb {
    background: lightgray;
    border-radius: 5px;
}

[data-tile-panel]::-webkit-scrollbar-thumb:hover,
.fieldgroup::-webkit-scrollbar-thumb:hover,
.optionbox-list::-webkit-scrollbar-thumb:hover,
.tagzone::-webkit-scrollbar-thumb:hover,
.showlist::-webkit-scrollbar-thumb:hover {
    background: gray;
}

/* ====================================================================
    CĂN CHỈNH BỐ CỤC CHÍNH
   ==================================================================== */
/* Khung làm việc phủ kín bên dưới Header */
#tiling-workspace {
    position: fixed;
    top: 38px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    display: flex;
    z-index: 2000;
    background-color: #DCDCDC;
}

/* Các nhánh chia đa tầng (Flexbox lồng nhau) */
.tile-split {
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}
.tile-split.dir-row { flex-direction: row; }
.tile-split.dir-col { flex-direction: column; }

.tile-branch {
    display: flex;
    min-width: 0;
    min-height: 0;
    position: relative;
}

/* Thanh ranh giới kéo giãn giữa 2 nhánh */
.tile-splitter {
    background-color: #D0D0D0;
    flex-shrink: 0;
    z-index: 50;
    touch-action: none;
    transition: background-color 0.15s;
}
.tile-splitter:hover, .tile-splitter.active { background-color: #777; }
.tile-split.dir-row > .tile-splitter { width: 5px; cursor: col-resize; }
.tile-split.dir-col > .tile-splitter { height: 5px; cursor: row-resize; }

/* ====================================================================
    KHỐI CỬA SỔ
   ==================================================================== */
[data-tile-panel] {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    min-width: 0;
    min-height: 0;
    border-radius: 5px;
    border: 1px solid #BDBDBD;
    background-color: #FAFAFA;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

[data-tile-panel]:not(#mysearch):not([open]) {
    display: none !important;
}

.tile-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
}

/* Lớp phủ chỉ báo vùng thả nổi bật nằm trên các cửa sổ */
.tile-drop-overlay {
    position: fixed;
    pointer-events: none;
    background: rgba(65, 105, 225, 0.16);
    border: 3px solid royalblue;
    box-shadow: inset 0 0 12px rgba(65, 105, 225, 0.35), 0 0 0 1px white;
    border-radius: 6px;
    z-index: 8500; /* Cao hơn #tiling-workspace (2000) và thấp hơn Header (9000) */
    transition: left 0.08s ease, top 0.08s ease, width 0.08s ease, height 0.08s ease;
}

/* Khi đưa vào vùng trung tâm (Hoán đổi 2 khối) -> Đổi sang viền nét đứt màu cam nổi bật */
.tile-drop-overlay.is-swap {
    background: rgba(255, 140, 0, 0.14);
    border: 3px dashed darkorange;
    box-shadow: inset 0 0 12px rgba(255, 140, 0, 0.3);
}

/* Làm mờ nhẹ khối đang được nắm kéo để dễ quan sát vị trí thả bên dưới */
.tile-is-dragging {
    opacity: 0.55;
    outline: 2px solid gray;
}

/* Đẩy nút đóng xuống dưới */
#mylist-close, .viewinfo-close, .mylist-edit { top: 4px !important; }

/* ====================================================================
    THANH HEADER
   ==================================================================== */
header {
    display: grid;
    grid-template-columns: 1fr 200px 1fr;
    height: 36px;
    align-items: center;
    padding: 0 1px;
    background-color: #F5F5F5;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9000;
    box-shadow: 0 1px 5px hsla(0, 0%, 0%, 0.1);
}

#header-left, #header-right {
    display: inline-flex;
    align-items: center;
    margin: auto 1px;
    gap: 4px
}
#header-right {justify-self: end;}

/* THANH CHỨA LOGO*/
#marqueebar {
    display: flex;
    margin: auto;
    width: 100%;
    overflow: hidden;
    container-type: inline-size;
}

/* LOGO */
#logoname {
    animation: marquee-run 60s linear infinite alternate;
}

@keyframes marquee-run {
    0% { transform: translateX(0); }
    100% { transform: translateX(calc(100cqw - 100%)); }
}

/* ====================================================================
    NÚT TRÊN HEADER BAR
   ==================================================================== */
.mysetting-button, .mylist-button, .mymap-button {
    display: inline-flex;
    color: dimgray;
    text-align: center;
    align-items: center;
    padding: 3px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    list-style: none;
}

.mylist-button:hover, .mysetting-button:hover, .mymap-button:hover {
    color: white;
    background-color: gray;
}

.mylist-button::-webkit-details-marker { display: none; }
.mysetting-button::-webkit-details-marker { display: none; }

/* NÚT CHUYỂN NGÔN NGỮ */
.language-switcher-zone {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.lang-btn, .newlang-btn {
    display: inline-flex;
    font-size: 18px;
    color: gray;
    text-align: center;
    align-items: center;
    background-color: white;
    padding: 3px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.lang-btn:hover, .newlang-btn:hover {
    color: white;
    background-color: lightgray;
}

.lang-btn.active,
.newlang-btn.active {
    color: white;
    background-color: gray;
}

/* ====================================================================
    SEARCH BAR
   ==================================================================== */
#searchbar {
    display: flex;
    align-items: center;
    max-width: 750px;
    width: 100%;
    margin: 8px auto;
    padding: 0 2px;
    overflow: auto;
    border-radius: 24px;
}

#searchinput {
    font-size: 16px;
    flex: 1;
    align-items: center;
    height: 36px;
    padding: 0 10px;
    border: 1px solid gray;
    border-top-left-radius: 24px;
    border-bottom-left-radius: 24px;
    outline: none;
}
@media (max-width: 800px) {#searchinput {font-size: 14px;}}

#searchbutton {
    color: white;
    text-align: center;
    height: 36px;
    width: 40px;
    background-color: gray;
    border: none;
    border-top-right-radius: 24px;
    border-bottom-right-radius: 24px;
    cursor: pointer;
}

#searchbutton:hover {
    background-color: black;
}

/* ====================================================================
    CHANGE BAR VÀ KIND BAR
   ==================================================================== */
#categorybar, .kindbar {
    display: flex;    
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    width: 100%;
    max-width: 100%;
    gap: 6px;
}
@media (max-width: 800px) {#categorybar, .kindbar {margin-bottom: 4px; gap: 3px;}}

#categorybar input[type="radio"], .kindbar input[type="radio"] {
    display: none;
}

#categorybar label, .kindbar label {
    display: inline-flex;
    font-size: 16px;
    color: black;
    padding: 3px 6px;
    justify-content: center;
    align-items: center;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #E5E5E5;
    white-space: nowrap;
}

#categorybar label:hover, .kindbar label:hover {
    background-color: lightgrey;
}

#categorybar label:has(input[type="radio"]:checked), .kindbar label:has(input[type="radio"]:checked) {
    color: white;
    background-color: gray;
}

#categorybar label {
    width: 38%;
    max-width: 180px;
    min-width: 115px;
}

/* Nhóm tab con bên trong .kindbar */
.kindgroup {
    display: none;
    align-items: center;
    gap: inherit;
    max-width: 100%;
    overflow: hidden;
}

.kindgroup.active {
    display: flex;
    justify-content: center;
}

/* Tab Tất cả (Z): Rộng mức tối thiểu vừa khít chữ */
.kindgroup .buttonall {
    flex: 0 0 auto !important;
    width: max-content !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 3px 8px;
}

/* Các Tab A, B, C... (không tính Z): Luôn rộng bằng nhau */
.kindgroup label:not(.buttonall) {
    flex: 1 1 0%;
    min-width: 0;
    width: 160px;
    max-width: 160px;
    overflow: hidden;
}

/* Đảm bảo text bên trong tab không bao giờ xuống dòng hoặc bị cắt dấu ba chấm */
.kindgroup label span {
    white-space: nowrap;
    display: inline-block;
}

/* Khi màn hình < 800px và có không quá 4 tab (tính cả Z): Rộng 100% cha bớt vào 2 bên 2px */
@media (max-width: 800px) {
    .kindgroup.active:not(:has(label:nth-child(5))) {
        width: calc(100% - 4px);
        margin: 0 2px;
    }

    .kindgroup:not(:has(label:nth-child(5))) label:not(.buttonall) {
        max-width: none;
        width: auto;
    }

    .kindgroup label {
        font-size: 14px;
        padding: 3px 4px;
    }
}

/* ====================================================================
    FIELD BAR THANH BẬT TẮT CÁC TRƯỜNG BỘ LỌC
   ==================================================================== */
.fieldbar {
    width: 100%;
    align-items: center;
    margin-bottom: 6px;
    position: relative;
}

.fieldbar-icon {
    display: inline-flex;
    flex-shrink: 0;
    position: absolute;
    left: 0;
}

.fieldgroup {
    display: none;
    align-items: center;
    max-width: calc(100% - 45px);
    margin-left: 25px;
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.fieldgroup input[type="checkbox"] {
    display: none;
}

.fieldgroup.active {
    display: inline-flex; 
}

.fieldbutton {
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 16px;
    color: black;
    text-align: center;
    align-items: center;
    padding: 3px;
    background-color: whitesmoke;
    border-left: 3px solid gray;
    cursor: pointer;
}
@media (max-width: 800px) {.fieldbutton {font-size: 14px;}}

.fieldbutton:hover {
    background-color: lightgray;
}

.fieldgroup .fieldbutton:has(input[type="checkbox"]:checked) {
    color: white;
    background-color: gray;
    border-left: 3px solid white;
}

/* Định dạng giao diện mũi tên chỉ báo cuộn */
.fieldbar-arrow {
    display: inline-flex;
    font-size: 14px;
    color: gray;
    align-items: center;
    padding: 2px;
    flex-shrink: 0;
    position: absolute;
    right: 0;
    cursor: pointer;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

/* Trạng thái khi kích hoạt hiển thị mũi tên */
.fieldbar-arrow.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Cho phép click vào mũi tên để tự cuộn nhanh */
}

/* Thao tác hover nhẹ lên mũi tên */
.fieldbar-arrow:hover {
    color: black;
}

/* ====================================================================
    VÙNG CHỨA TỪNG TRƯỜNG BỘ LỌC
   ==================================================================== */
#optionzone { 
    display: flex; 
    flex-direction: column; 
    align-items: flex-start; 
}
.optiongroup { 
    display: flex;
    position: relative;
    align-items: center;
    margin-bottom: 4px;
    width: 100%; 
}
.optionbox {  
    display: inline-block;
    position: relative;
    flex-shrink: 0; 
}
.optionbox-button {    
    font-size: 16px;
    color: black;
    text-align: left;
    background-color: whitesmoke;
    min-width: 160px;
    padding: 2px;
    padding-right: 15px; 
    border: 1px solid gray; 
    border-radius: 3px;     
    position: relative;
    flex-wrap: nowrap;
    cursor: pointer;
}
@media (max-width: 800px) {.optionbox-button {font-size: 14px; min-width: 80px;}}

/* Tạo mũi tên đi xuống */
.optionbox-button::after { 
    content: "▼";
    font-size: 10px;
    color: black;
    right: 3px; 
    top: 50%;
    transform: translateY(-50%);
    position: absolute; 
}
.optionbox-list { 
    display: none;
    position: absolute;
    width: 100%;
    top: 100%;
    padding: 4px 0; 
    max-height: 600px;
    background-color: whitesmoke;
    border: 1px solid gray; 
    border-radius: 3px;
    z-index: 100;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 1px 5px hsla(0, 0%, 0%, 0.1);
}
@media (max-width: 800px) {.optionbox-list {width: 150px;}}

.optionbox-item { 
    display: flex;
    font-size: 14px;
    padding: 2px; 
    align-items: center;
    gap: 2px;
    cursor: pointer;
}
@media (max-width: 800px) {.optionbox-item {font-size: 12px;}}

.optionbox-item:hover {
    background-color: lightgray;
}

.optionbox-item input { 
    margin-right: 2px; 
    vertical-align: middle; 
}

/* Thanh tìm kiếm thẻ lọc */
.optionbox-search {
    font-size: 12px;
    width: 95%;
    padding: 5px;
    margin: 5px auto 5px 2px;
    border: 1px solid gray;
    border-radius: 4px;
    outline: none;
}

/* Căn chỉnh danh sách nhiều dòng ngang của trường NEAR và AREA */
.near-area-rows-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.optiongroup:has(.near-area-rows-wrapper) {
    align-items: flex-start;
}

.near-area-action-row {
    display: flex;
    gap: 4px;
    padding: 2px 4px 4px 4px;
}

.near-area-action-row button {
    flex: 1;
    width: auto;
}

.near-area-action-row button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: transparent;
}

/* ====================================================================
    THẺ HIỆN NGOÀI CỦA TỪNG THUỘC TÍNH LỌC
   ==================================================================== */
/* VÙNG HIỆN RA CỦA TEXT, ONLY */
.tagzone { 
    display: flex; 
    align-items: center;
    flex-wrap: nowrap; 
    gap: 2px;
    margin-left: 5px;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.optiontag {
    display: flex;
    flex: 0 0 auto;
    font-size: 16px;
    color: black;
    border-radius: 8px; 
    padding: 1px;
    align-items: center;
    cursor: pointer;
}
@media (max-width: 800px) {.optiontag {font-size: 14px;}}

.optiontag-close {
    margin-left: 3px; 
    cursor: pointer;
    color: black;
    pointer-events: none; 
}

.optionbox-empty { 
    display: block;
    font-size: 14px;
    color: black; 
    padding: 2px; 
}

/* Các thẻ option Only hiện ra ngoài */
.optiontag.onlytag {
    color: white;
    background-color: gray;
}

.optiontag.onlytag .optiontag-close {
    color: white;
}

/* VÙNG HIỆN RA CỦA TRƯỜNG NUMBER, DATE, RANGE, TIME */
.inputzone {
    display: flex;
    font-size: 16px;
    color: black;
    align-items: center;
    justify-content: flex-start;
    padding: 0 2px;
    gap: 2px;
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;    
}
@media (max-width: 800px) {.inputzone {font-size: 14px;}}

/* Ô điền giá trị min max */
.inputbox {
    width: 120px;
    padding: 1px;
    border: 1px solid gray;
    border-radius: 4px;
    outline: none;
}
@media (max-width: 800px) {.inputbox {width: 80px;}}

/* Nơi hiện nhãn đơn vị giá trị */
.unitlabel {
    font-style: italic;
    padding: 1px;
}

/* ====================================================================
    GIAO DIỆN 3 NÚT CHUYỂN ĐỔI OR AND NOT
   ==================================================================== */
/* Khung bọc quanh 3 nút chuyển đổi ở dòng đầu tiên của danh sách thả xuống */
.condition-toggle-row {
    display: block;
    padding-left: 2px;
    gap: 2px;
}

/* Định dạng cơ bản chung cho cả 3 nút bấm chuyển đổi */
.condition-toggle-row button {
    display: inline-block;
    font-size: 12px;
    color: black;
    background-color: lightgray;
    width: 45px;
    padding: 4px 3px;
    border: 1px solid whitesmoke;
    border-radius: 5px;
    cursor: pointer;
}
@media (max-width: 800px) {.condition-toggle-row button {width: 40px; padding: 4px 1px;}}

.condition-toggle-row button:hover {
    border: 1px solid black;
    border-radius: 5px;
}

/* ĐỔI MÀU NỀN Ô VUÔNG CHECKBOX*/
.sub-checkbox {
    accent-color: gray !important;
}

/* 1. ĐỊNH DẠNG MÀU SẮC CHO BỘ 3 BUTTON LOGIC TOÁN TỬ (AND - OR - NOT) */
/* Thiết lập màu chữ trắng chung khi nút chuyển đổi ở trạng thái Active */
.condition-toggle-row button.active {
    color: white !important;
}

/* Nút "Hoặc có" (Toán tử OR) */
.condition-toggle-row label:nth-child(1) button.active {
    background-color: orange !important;
}

/* Nút "Phải có" (Toán tử AND) */
.condition-toggle-row label:nth-child(2) button.active {
    background-color: darkviolet !important;
}

/* Nút "Không có" (Toán tử NOT) */
.condition-toggle-row label:nth-child(3) button.active {
    background-color: black !important;
}

/* 2. ĐỔI MÀU NỀN CHO CÁC OPTION KHI ĐƯỢC TÍCH CHỌN */
/* Khi option được tích chọn: Ép hiển thị rõ ràng, đổi chữ thành màu trắng kể cả khi hover */
.optionbox-list .optionbox-item:has(.sub-checkbox:checked),
.optionbox-list .optionbox-item:has(.sub-checkbox:checked):hover {
    display: block !important;
    color: white !important;
}

.optionbox-list .optionbox-item:has(.sub-checkbox:checked) .item-text-label,
.optionbox-list .optionbox-item:has(.sub-checkbox:checked):hover .item-text-label {
    color: white !important;
}

/* Option gán Toán tử OR (kể cả khi đang hover chuột) */
.optionbox-list .optionbox-item:has(.sub-checkbox:checked[data-logic="OR"]),
.optionbox-list .optionbox-item:has(.sub-checkbox:checked[data-logic="OR"]):hover {
    background-color: orange !important;
}

/* Option gán Toán tử AND (kể cả khi đang hover chuột) */
.optionbox-list .optionbox-item:has(.sub-checkbox:checked[data-logic="AND"]),
.optionbox-list .optionbox-item:has(.sub-checkbox:checked[data-logic="AND"]):hover {
    background-color: darkviolet !important;
}

/* Option gán Toán tử NOT (kể cả khi đang hover chuột) */
.optionbox-list .optionbox-item:has(.sub-checkbox:checked[data-logic="NOT"]),
.optionbox-list .optionbox-item:has(.sub-checkbox:checked[data-logic="NOT"]):hover {
    background-color: black !important;
}

/* 3. ĐỔI MÀU ĐỒNG BỘ CHO CÁC THẺ TAG HIỂN THỊ BÊN NGOÀI */
/* Cấu hình màu chữ và màu nút xóa (x) thành trắng cho các thẻ Tag */
.optiontag.logic-and-tag,
.optiontag.logic-or-tag,
.optiontag.logic-not-tag {
    color: white !important;
    border-color: transparent !important;
}

.optiontag.logic-and-tag .optiontag-close,
.optiontag.logic-or-tag .optiontag-close,
.optiontag.logic-not-tag .optiontag-close {
    color: white !important;
}

/* Tag xử lý OR */
.optiontag.logic-or-tag {
    background-color: orange !important;
}

/* Tag xử lý AND */
.optiontag.logic-and-tag {
    background-color: darkviolet !important;
}

/* Tag xử lý NOT */
.optiontag.logic-not-tag {
    background-color: black !important;
}

/* ====================================================================
    GIỚI THIỆU KHI CHƯA CÓ KẾT QUẢ TÌM KIẾM
   ==================================================================== */
#summaryzone {
    font-size: 16px;
    padding: 5px 10px;
    margin-top: 2px;
    border-top: 1px solid gray;
}

/* ====================================================================
    CHỨC NĂNG SẮP XẾP KẾT QUẢ TÌM KIẾM VÀ SỐ LƯỢNG KẾT QUẢ
   ==================================================================== */
/* Thanh chứa nút Sắp xếp, nhãn đang chọn và số lượng kết quả */
.result-headerbar {
    display: flex;
    font-size: 16px;
    align-items: center;
    flex-wrap: nowrap;
    gap: 3px;
    margin-top: 2px;
    padding-top: 4px;
    border-top: 1px solid gray;
    position: relative;
}

.sortzone {
    display: inline-flex;
    align-items: center;
}

.sortbox .optionbox-button {
    min-width: 0;
}

.sortbox .optionbox-list {
    width: max-content;
    min-width: 180px;
    max-width: 90vw;
    left: 0;
}

/* Nhãn hiển thị tiêu chí sắp xếp đang chọn nằm bên phải nút Sắp xếp */
.sortlabel-select {
    font-size: 16px;
    font-style: italic;
    padding: 2px;
    white-space: nowrap;
}
@media (max-width: 800px) {.sortlabel-select {font-size: 14px;}}

/* ====================================================================
    VÙNG KẾT QUẢ TÌM KIẾM
   ==================================================================== */
/* Dòng số lượng kết quả */
.resultnoti-yes, .resultnoti-no {
    font-size: 16px;
    text-align: center;
    padding: 5px;
}

@media (max-width: 800px) {.resultnoti-yes, .resultnoti-no {font-size: 14px;}}

/* VÙNG DANH SÁCH KẾT QUẢ*/
.resultgroup {
    display: flex;
    font-size: 16px;
    flex-direction: column;
    margin: 6px 0;
    border: 1px solid gray;
    border-radius: 5px;
    position: relative;
    contain: content;
}
@media (max-width: 800px) {.resultgroup {font-size: 14px;}}

/* Dòng kết quả cơ bản của đối tượng */
.resultitem {
    display: flex;
    align-items: center;
    padding: 4px 120px 4px 4px;
    background-color: ivory;
    border-radius: 5px;
    flex-wrap: wrap;
    cursor: pointer;
}

.resultitem:hover {
    background-color: lightgray;
}

/* Vùng nhãn thông tin đính kèm cạnh tên đối tượng kết quả */
.infobadgebar {
    display: inline-flex;
    align-items: center;
    margin-left: 5px;
}

/* Nhãn thông tin cạnh tên đối tượng kết quả*/
.infobadge {
    font-size: 14px;
    margin: auto 3px;
    padding: 2px;
    background: lightyellow;
    border: 1px solid black;
    border-radius: 5px;
}
@media (max-width: 800px) {.infobadge {font-size: 12px;}}

/* Vùng mở rộng để xem thêm thông tin*/
.infobox {
    display: none;
    position: relative;
    border-top: 1px dashed black;
}

/* Từng dòng dữ liệu trong vùng mở rộng thông tin */
.infobox-item {
    padding: 4px 10px;
    max-width: 100%;
    word-wrap: break-word;
    word-break: break-word;
}

/* Thông báo "không có dữ liệu" trong vùng mở rộng thông tin*/
.infobox-nodata {
    font-style: italic;
}

/* Nút thu gọn dưới phần thông tin mở rộng */
.infobox-close {
    font-size: 16px;
    font-weight: bold;
    color: gray;    
    text-align: center;
    margin-top: 10px;
    padding: 4px;
    border-top: 1px dotted gray;
    border-radius: 5px;
    cursor: pointer;
}
@media (max-width: 800px) {.infobox-close {font-size: 12px !important;}}

.infobox-close:hover {
    color: black !important;
    background-color: whitesmoke;
}

/* ====================================================================
    NÚT THAO TÁC NHANH Ở DANH SÁCH KẾT QUẢ
   ==================================================================== */
.infobox-buttongroup {
    display: inline-flex;
    align-self: flex-end;
    align-items: center;
    position: absolute;
    right: 3px;
    z-index: 10;
}

/* Cài đặt cho từng nút */
.infobox-button {
    display: inline-flex;
    align-items: center;
    margin: 2px 0;
    padding: 2px;
    border: none;
    background-color: transparent !important;
    cursor: pointer;
}

/* Thao tác hover chuột qua nút chưa chọn */
.infobox-buttongroup .infobox-button:hover svg {
    color: gray !important;
}

/* Đối tượng chưa được chọn -> Mặc định ép màu font chữ xám nhạt */
.infobox-buttongroup .infobox-button svg {
    color: lightgray !important;
    transition: color 0.2s ease;
}

/* Nút bấm tương ứng đã được kích chọn (data-active="true") */
.infobox-buttongroup .infobox-button.checknote[data-active="true"] svg {
    color: blue !important;
}

.infobox-buttongroup .infobox-button.checklove[data-active="true"] svg {
    color: red !important;
}

.infobox-buttongroup .infobox-button.checkhate[data-active="true"] svg {
    color: black !important;
}

.infobox-buttongroup .infobox-button.checkpin[data-active="true"] svg {
    color: darkmagenta !important;
}

.infobox-buttongroup .infobox-button.checkpin {
    margin-right: 1px;
    padding-right: 3px;
    border-right: 1px solid gray;
}

#resultpinzone {
    padding-bottom: 4px;
    border-bottom: 2px solid gray;
}

#resultpinzone:empty {
    display: none;
}

/* Nút Xem thêm kết quả */
.loadmore-wrap {
    display: flex;
    justify-content: center;
    margin: 10px 0 14px 0;
}

#result-loadmore-btn {
    font-size: 16px;
    background-color: #E5E5E5;
    border: none;
    border-radius: 5px;
    padding: 5px;
    cursor: pointer;
}
@media (max-width: 800px) {#result-loadmore-btn {font-size: 14px;}}

#result-loadmore-btn:hover {
    background-color: lightgray;
}

/* ====================================================================
    DANH SÁCH ĐÃ LƯU
   ==================================================================== */
/* NÚT BẬT TẮT CHỨC CHỈNH SỬA DANH SÁCH LƯU */
.mylist-edit {
    display: inline-flex;
    color: gray;
    padding: 2px;
    border-radius: 5px;
    position: absolute;
    top: 5px;
    left: 5px;
    cursor: pointer;
}

.mylist-edit:hover {
    color: white;
    background-color: lightgray;
}

.mylist-edit:has(#checkeditmylist:checked) {
    color: white;
    background-color: gray;
}

/* NÚT TẮT DANH SÁCH LƯU */
#mylist-close {
    position: absolute;
    top: -3px;
    right: 4px;
    font-size: 28px;
    font-weight: bold;
    color: gray;
    cursor: pointer;
}

#mylist-close:hover {
    color: black;
}

/* THANH DANH MỤC ĐÃ LƯU */
.mylisttab {
    display: flex;
    justify-content: center;
    margin-top: 2px;
    margin-bottom: 4px;
    gap: 3px;
}

.mylisttab input[type="radio"] {
    display: none;
}

.mylisttab label {
    display: inline-flex;
    align-items: center; 
    justify-content: center;   
    width: 60px;
    margin-bottom: 2px;
    padding: 1px;
    gap: 2px;
    border-radius: 5px;
    background-color: whitesmoke;
    cursor: pointer;
}

.mylisttab label:hover {
    background-color: lightgray;
}

.mylisttab label:has(input[type="radio"]:checked) {
    color: white;
    background-color: gray;
}

/* Dòng thống kê số lượng đối tượng được lưu trong My List */
.mylist-countbar {
    font-size: 16px;
    text-align: center;
    padding: 4px 5px;
    margin: 2px 5px 4px 5px;
    border-top: 1px solid lightgray;
    border-bottom: 1px solid lightgray;
}
@media (max-width: 800px) {.mylist-countbar {font-size: 14px;}}

/* VÙNG HIỆN CÁC ĐỐI TƯỢNG ĐƯỢC LƯU KÈM THÔNG TIN MỞ RỘNG */
.showlist {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 100%;
    padding: 0 5px;
    contain: content;
    overflow-y: auto;
}

/* VÙNG CHỨA TỪNG ĐỐI TƯỢNG ĐƯỢC LƯU */
.saved-item-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    margin: 4px auto;
}

/* Tên của đối tượng được lưu */
.saved-item-name {
    display: inline-flex;
    font-size: 16px;
    flex: 1;
    align-items: center;
    flex-wrap: wrap;
    background-color: ivory;
    border: 1px solid gray;
    border-radius: 5px;
    padding: 3px 5px;
    cursor: pointer;
}
.saved-item-name:hover {
    background-color: lightgray;
}

/* VÙNG CHỨA THÔNG TIN MỞ RỘNG TRONG MY LIST */
.mylist-infozone {
    display: flex;
    font-size: 16px;
    flex-direction: column;
    width: 100%;
    background: white;
    border: 1px dashed gray;
    border-top: none;
    border-radius: 5px;
}

/* Nội dung thông tin mở rộng trong Mylist */
.mylist-infoinzone {
    padding: 5px;
}

/* Nút thu gọn dưới phần thông tin mở rộng trong Mylist */
.mylist-closeinfozone {
    font-size: 16px;
    font-weight: bold;
    color: gray;    
    text-align: center;
    margin-top: 10px;
    padding: 4px;
    border-top: 1px dotted gray;
    cursor: pointer;
}
@media (max-width: 800px) {.mylist-closeinfozone {font-size: 12px !important;}}

.mylist-closeinfozone:hover {
    color: black !important;
    background-color: whitesmoke;
}

/* BẬT TẮT NÚT XÓA VÀ BIỂU TƯỢNG DI CHUYỂN KHI CHỌN EDIT */
#mylist .remove-button,
#mylist .drag-handle-button {
    display: none;
}

#mylist:has(#checkeditmylist:checked) .remove-button,
#mylist:has(#checkeditmylist:checked) .drag-handle-button {
    display: inline-flex;
    align-items: center;
}

/* Nút xóa đối tượng lưu */
.remove-button {
    color: gray;
    margin-right: 5px;
    padding: 1px;
    cursor: pointer;
}

.remove-button:hover {
    color: black;
    font-weight: bold;
}

.remove-button:hover + .saved-item-name {
    background-color: lightgray;
}

/* Định dạng biểu tượng thay đổi vị trí danh mục */
.drag-handle-button {
    color: gray;
}

.saved-item-name:hover .drag-handle-button {
    color: black;
}

/* Áp dụng riêng cho dòng đang được người dùng giữ và di chuyển */
.saved-item-row.is-moving .saved-item-name {
    background-color: lightgray !important;
}

/* Đổi con trỏ lúc chạm đối tượng khi đang bật Edit */
#mylist:has(#checkeditmylist:checked) .saved-item-name {
    cursor: grabbing;
    touch-action: none !important;
}

/* Ép con trỏ chuột toàn màn hình luôn giữ hình bàn tay nắm (grabbing), không bị nhảy hình */
body.saved-list-dragging-active {
    cursor: grabbing !important;
    overflow: hidden !important;
    overscroll-behavior-y: contain !important;
    touch-action: none !important;
}

/* Khóa toàn bộ sự kiện click mở popup chi tiết hoặc nút xóa để chuột tính tọa độ phẳng */
body.saved-list-dragging-active .showlist .saved-item-row * {
    pointer-events: none !important;
}

body.saved-list-dragging-active .showlist {
    overscroll-behavior-y: contain !important;
    touch-action: none !important;
}

/* =========================================
   CHỈNH MÀU 3 TAB NOTE, LOVE, HATE TRONG MYLIST
   ========================================= */

/* 1. Trạng thái MẶC ĐỊNH (Chưa chọn): Nền chung lightgray */
#mylist .mylisttab label:has(input[name="save"]) {
    background-color: lightgray;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Màu chữ & icon riêng khi chưa chọn: Note = blue, Love = red, Hate = black */
#mylist .mylisttab label:has(input[name="save"][value="note"]) {
    color: blue;
}

#mylist .mylisttab label:has(input[name="save"][value="love"]) {
    color: red;
}

#mylist .mylisttab label:has(input[name="save"][value="hate"]) {
    color: black;
}

/* 2. Trạng thái HOVER (Khi chưa chọn): Nền gray, giữ nguyên color */
#mylist .mylisttab label:has(input[name="save"]:not(:checked)):hover {
    background-color: gray;
}

/* 3. Trạng thái ĐANG CHỌN (Checked): Chữ & icon chung white, nền lần lượt blue, red, black */
#mylist .mylisttab label:has(input[name="save"][value="note"]:checked) {
    color: white;
    background-color: blue;    
}

#mylist .mylisttab label:has(input[name="save"][value="love"]:checked) {
    color: white;
    background-color: red;
}

#mylist .mylisttab label:has(input[name="save"][value="hate"]:checked) {
    color: white;
    background-color: black;
}

/* ====================================================================
    SETTING BOX
   ==================================================================== */
#mysetting {
    display: inline-flex;
}

/* Lớp nền mờ phủ kín màn hình khi mở Setting */
.outsidemysetting {
    position: fixed;
    top: 35px;
    right: 0;
    width: 100vw;
    height: 100vh;
    background-color: hsla(0, 0%, 0%, 0.5);
    z-index: 8000;
}

/* Khối nội dung cài đặt hiện ra */
#mysetting[open] .mysettingbox {
    display: grid;
    font-size: 16px;
    color: black;
    grid-template-columns: 1fr;
    align-content: start;
    position: fixed;
    top: 36px;
    left: 0;
    max-width: 400px;
    width: 90vw;
    height: calc(100vh - 36px);
    background-color: floralwhite;
    padding: 10px;
    z-index: 8500;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 1px 1px 5px hsla(0, 0%, 0%, 0.1);
}
@media (max-width: 800px) {#mysetting[open] .mysettingbox {font-size: 14px;}}

/* ====================================================================
    POPUP HƯỚNG DẪN SỬ DỤNG
   ==================================================================== */
.instruction-button,
.otherlanguage-button,
.whereyouare-button {
    display: flex;
    font-size: inherit;
    color: inherit;
    align-items: center;
    padding: 8px 15px;
    background-color: floralwhite;
    border: none;
    border-top: 1px solid gray;
    cursor: pointer;
}

.instruction-button:hover,
.otherlanguage-button:hover,
.whereyouare-button:hover {
    background-color: lightgray;
}

.instruction-box,
.otherlanguage-box,
.whereyouare-box {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 36px;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #FAFAFA;
    padding: 12px;
    z-index: 8600;
    font-size: 16px;
    color: black;
}

.instruction-box[open],
.otherlanguage-box[open],
.whereyouare-box[open] {
    display: flex;
}

@media (max-width: 800px) {
    .instruction-box,
    .otherlanguage-box,
    .whereyouare-box {
        font-size: 14px;
    }
}

.instruction-close,
.otherlanguage-close,
.whereyouare-close {
    position: absolute;
    top: 4px;
    right: 10px;
    font-size: 28px;
    font-weight: bold;
    color: gray;
    cursor: pointer;
    line-height: 1;
}

.instruction-close:hover,
.otherlanguage-close:hover,
.whereyouare-close:hover {
    color: black;
}

.instruction-title,
.otherlanguage-title,
.whereyouare-title {
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    padding: 0 28px 8px 28px;
    border-bottom: 1px dashed gray;
    margin-bottom: 8px;
    flex-shrink: 0;
}

@media (max-width: 800px) {
    .instruction-title,
    .otherlanguage-title,
    .whereyouare-title {
        font-size: 16px;
    }
}

.instruction-content,
.otherlanguage-content,
.whereyouare-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}

.instruction-content::-webkit-scrollbar,
.otherlanguage-content::-webkit-scrollbar,
.whereyouare-content::-webkit-scrollbar {
    width: 8px;
}
@media (max-width: 800px) {
    .instruction-content::-webkit-scrollbar,
    .otherlanguage-content::-webkit-scrollbar,
    .whereyouare-content::-webkit-scrollbar {
        width: 5px;
    }
}
.instruction-content::-webkit-scrollbar-thumb,
.otherlanguage-content::-webkit-scrollbar-thumb,
.whereyouare-content::-webkit-scrollbar-thumb {
    background: lightgray;
    border-radius: 5px;
}
.instruction-content::-webkit-scrollbar-thumb:hover,
.otherlanguage-content::-webkit-scrollbar-thumb:hover,
.whereyouare-content::-webkit-scrollbar-thumb:hover {
    background: gray;
}

/* ====================================================================
    DANH SÁCH CHỌN NGÔN NGỮ MỞ RỘNG
   ==================================================================== */
.otherlanguage-search {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 8px auto;
    flex-shrink: 0;
}

.otherlanguage-search input {
    width: 100%;
    font-size: inherit;
    padding: 5px 8px;
    border: 1px solid gray;
    border-radius: 4px;
    outline: none;
}

.otherlanguage-content label:has(input[type="radio"]:checked) {
    display: flex !important;
}

.otherlanguage-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    align-content: start;
    gap: 8px;
}

@media (max-width: 800px) {
    .otherlanguage-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
}

.otherlanguage-content label {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px 6px;
    background-color: #F5F5F5;
    border: 1px solid lightgray;
    border-radius: 5px;
    cursor: pointer;
    font-size: inherit;
    color: black;
}

.otherlanguage-content label input[type="radio"] {
    display: none;
}

.otherlanguage-content label:hover {
    background-color: #E6E6E6;
    border-color: #999;
}

.otherlanguage-content label:active {
    transform: scale(0.97);
    background-color: #D8D8D8;
}

.otherlanguage-content label:has(input[type="radio"]:checked) {
    color: white;
    background-color: #555555;
    border-color: #333333;
    font-weight: bold;
}

/* ====================================================================
    HỖ TRỢ VÀ LIÊN HỆ TRONG MY SETTING
   ==================================================================== */
.supportcontact {
    display: flex;
    flex-direction: column;
}

.supportcontact-button {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    border-top: 1px solid gray;
    cursor: pointer;
}
.supportcontact-button::-webkit-details-marker { display: none; }
.supportcontact-button:hover { background-color: lightgray; }

/* 3 dòng nội dung xếp dọc bên dưới */
.supportcontact > a,
.supportcontact > span {
    display: block;
    color: black;
    padding: 6px 8px;
    margin-top: 2px;
    background-color: #F5F5F5;
    border: 1px solid lightgray;
    border-radius: 5px;
    cursor: pointer;
}

.supportcontact > a:hover,
.supportcontact > span:hover {
    background-color: #E6E6E6;
    border-color: #999;
}

/* ====================================================================
    ĐỔI ĐƠN VỊ KHOẢNG CÁCH TRONG MY SETTING
   ==================================================================== */
.distancemeasure {
    display: flex;
    flex-direction: column;
}

.distancemeasure-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 15px;
    border-top: 1px solid gray;
    cursor: pointer;
}
.distancemeasure-button::-webkit-details-marker {
    display: none;
}
.distancemeasure-button:hover {
    background-color: lightgray;
}

/* Nhãn hiển thị đơn vị đang chọn (dùng chung cho My Setting, Search Engine và Map) */
.distancemeasure-status {
    font-size: 16px;
    font-weight: bold;
    font-style: normal;
    background-color: white;
    border: 1px solid lightgray;
    border-radius: 4px;
    padding: 1px 5px;    
}

.distancemeasure-row {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.distancemeasure-row label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #F5F5F5;
    width: 110px;
    padding: 4px 1px;
    border: 1px solid lightgray;
    border-radius: 5px;
    cursor: pointer;
}

/* Ẩn chấm tròn radio mặc định để biến cả thẻ thành nút bấm gọn đẹp */
.distancemeasure-row label input[type="radio"] {
    display: none;
}

/* Hiệu ứng khi di chuột vào ô */
.distancemeasure-row label:hover {
    background-color: #E6E6E6;
    border-color: #999;
}

/* Hiệu ứng ngay khoảnh khắc nhấn giữ (active) */
.distancemeasure-row label:active {
    transform: scale(0.97);
    background-color: #D8D8D8;
}

/* Ô đang được chọn (checked): Đậm màu nền, viền rõ nét và chữ trắng nổi bật */
.distancemeasure-row label:has(input[type="radio"]:checked) {
    color: white;
    background-color: #555555;
    border-color: #333333;
}

/* ====================================================================
    CHẾ ĐỘ ĐỔI BỐ CỤC (CHANGE LAYOUT MODE)
   ==================================================================== */
.changelayout, .resetlayout {
    display: flex;
    font-size: inherit;
    color: inherit;
    align-items: center;
    padding: 8px 15px;
    background-color: floralwhite;
    border: none;
    border-top: 1px solid gray;
    cursor: pointer;
}

.changelayout:hover, .resetlayout:hover {
    background-color: lightgray;
}

.changelayout:active, .resetlayout:active {
    transform: scale(0.98);
}

/* Thanh nổi góc trên bên phải (cao 36px bằng Header) chứa nút Hủy & Xác nhận */
.changelayout-toolbar {
    position: fixed;
    top: 0;
    right: 4px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    background-color: #F5F5F5;
    border-left: 1px solid #D0D0D0;
    z-index: 9500; /* Cao hơn Header (9000) */
}

.changelayout-toolbar button {
    font-size: 14px;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    padding: 4px 10px;
    cursor: pointer;
    white-space: nowrap;
}

.changelayout-cancel-btn {
    color: #333;
    background-color: #E0E0E0;
}
.changelayout-cancel-btn:hover {
    background-color: #CCCCCC;
}

.changelayout-confirm-btn {
    color: white;
    background-color: #2563EB;
}
.changelayout-confirm-btn:hover {
    background-color: #1D4ED8;
}

/* Khi bật chế độ Đổi bố cục: Toàn bộ khối lá biến thành vùng nắm kéo */
body.is-changing-layout [data-tile-panel] {
    cursor: grab !important;
    outline: 2px dashed royalblue;
    outline-offset: -2px;
    touch-action: none !important;
}

body.is-changing-layout [data-tile-panel]:active {
    cursor: grabbing !important;
}

/* Khóa tương tác các phần tử con bên trong lá để bấm chỗ nào cũng kéo được lá */
body.is-changing-layout [data-tile-panel] * {
    pointer-events: none !important;
}

/* ====================================================================
    NÚT XEM THÔNG TIN ĐỐI TƯỢNG VÀ NÚT XEM VỊ TRÍ ĐỊA ĐIỂM
   ==================================================================== */
.viewinfo-button, .placeonmap-button {
    display: inline-flex;
    color: black;
    background-color: transparent;
    align-items: center;
    justify-content: center;
    margin: auto 2px;
    padding: 0;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;    
}

.viewinfo-button:hover, .placeonmap-button:hover {
    color: white;
    background-color: gray;
}

#mylist:has(#checkeditmylist:checked) .viewinfo-button,
#mylist:has(#checkeditmylist:checked) .placeonmap-button {
    display: none;
    pointer-events: none;
}

/* ====================================================================
    POPUP XEM CHI TIẾT ĐỐI TƯỢNG (VIEW INFO)
   ==================================================================== */
.viewinfo-close {
    position: absolute;
    top: 4px;
    right: 10px;
    font-size: 28px;
    font-weight: bold;
    color: gray;
    cursor: pointer;
    line-height: 1;
}

.viewinfo-close:hover {
    color: black;
}

.viewinfo-title {
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    padding: 0 24px 8px 24px;
    border-bottom: 1px dashed gray;
    margin-bottom: 6px;
}
@media (max-width: 800px) {.viewinfo-title {font-size: 16px;}}

.viewinfo-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ====================================================================
    POPUP CHỌN VỊ TRÍ TÂM LỌC PHẠM VI
   ==================================================================== */
.range-location-details {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
}

.range-location-btn {
    display: inline-flex;
    align-items: center;
    color: black;
    background-color: lightgray;
    padding: 3px 4px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    list-style: none;
}
@media (max-width: 800px) {.range-location-btn {font-size: 12px; padding: 1px 2px;}}

.range-location-btn::-webkit-details-marker {
    display: none;
}

.range-location-btn:hover {
    color: white;
    background-color: gray;
}

.range-location-details[open] .range-location-btn {
    color: white;
    background-color: gray;
}

/* Nhãn trạng thái "Hiện tại" / "Tùy chọn" bên phải nút Vị trí */
.range-location-mode-status {
    font-size: 16px;
    font-style: italic;
    color: gray;
    margin: auto 2px;
    white-space: nowrap;
}
@media (max-width: 800px) {.range-location-mode-status {font-size: 14px;}}

/* Lớp nền mờ ngoài popup */
.outside-range-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: hsla(0, 0%, 0%, 0.4);
    z-index: 8000;
}

/* Hộp nội dung popup chính giữa màn hình */
.range-popup-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92vw;
    max-width: 380px;
    background-color: white;
    border: 1px solid gray;
    border-radius: 10px;
    padding: 16px;
    z-index: 8100;
    box-shadow: 0 4px 12px hsla(0, 0%, 0%, 0.2);
    font-size: 15px;
    color: black;
}

/* Nút X góc trên bên phải */
.range-popup-close {
    position: absolute;
    top: 4px;
    right: 10px;
    font-size: 28px;
    font-weight: bold;
    color: gray;
    cursor: pointer;
    line-height: 1;
}

.range-popup-close:hover {
    color: black;
}

.range-popup-title {
    font-weight: bold;
    font-size: 16px;
    text-align: center;
    margin-bottom: 12px;
    padding-right: 18px;
}

.range-popup-section {
    padding: 10px 0;
    border-top: 1px dashed lightgray;
}

.gps-popup-status {
    display: inline-flex;
    font-size: 14px;
    font-style: italic;
    white-space: nowrap;
}

.range-popup-coord-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.range-popup-coord-row label {
    min-width: 65px;
}

.range-popup-coord-row .inputbox {
    flex: 1;
    width: auto;
}

.range-popup-confirm-wrap {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.range-btn-gps, .range-btn-paste-map {
    display: inline-flex;
    color: white;
    background-color: gray;
    align-items: center;
    padding: 2px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    flex-shrink: 0;
}

.range-btn-gps:hover, .range-btn-paste-map:hover {
    background-color: black;
}

.range-popup-gps-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.range-gps-hint {
    font-size: 14px;
    color: black;
}

.range-btn-gps:disabled {
    background-color: lightgray;
    color: gray;
    cursor: not-allowed;
}

.range-btn-confirm {
    font-size: 14px;
    color: white;
    background-color: gray;
    padding: 5px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    flex-shrink: 0;
}

.range-btn-confirm:hover {
    background-color: black;
}

.range-popup-saved-wrap {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 10px;
}

/* Khung luôn giãn sẵn cố định bằng kích thước 5 đối tượng */
.range-saved-coords-list {
    height: 145px;
    overflow-y: auto;
    border: 1px solid lightgray;
    border-radius: 5px;
    background-color: #FAFAFA;
}

.range-saved-coords-list::-webkit-scrollbar {
    width: 5px;
}

.range-saved-coords-list::-webkit-scrollbar-thumb {
    background: lightgray;
    border-radius: 4px;
}

.range-saved-empty {
    font-size: 13px;
    font-style: italic;
    color: gray;
    padding: 6px 8px;
    text-align: center;
}

.range-saved-item {
    display: flex;
    align-items: center;
    height: 29px;
    padding: 0 8px;
    font-size: 14px;
    color: black;
    border-bottom: 1px solid #EEEEEE;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.range-saved-item:last-child {
    border-bottom: none;
}

.range-saved-item:hover {
    background-color: lightgray;
}

.range-saved-item.active {
    background-color: gray;
    color: white;
    font-weight: bold;
}

/* Hàng nhập tên gợi ý & nút Lưu / Xóa nằm phía trên Vĩ độ */
.range-popup-save-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.range-save-name-input {
    flex: 1;
    width: auto !important;
    font-size: 14px;
    padding: 4px 8px;
}

.range-btn-save-coord {
    font-size: 14px;
    color: white;
    background-color: gray;
    padding: 4px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    flex-shrink: 0;
}

.range-btn-save-coord:hover:not(:disabled) {
    background-color: black;
}

.range-btn-save-coord:disabled {
    background-color: lightgray;
    color: gray;
    cursor: not-allowed;
}

.range-btn-save-coord.is-delete-mode {
    background-color: #B91C1C;
}

.range-btn-save-coord.is-delete-mode:hover {
    background-color: #7F1D1D;
}

/* ====================================================================
    CỬA SỔ BẢN ĐỒ THUẦN WEB MERCATOR (#mymap)
   ==================================================================== */
#mymap .tile-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 4px;
    gap: 4px;
}

#mymap-close {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 28px;
    font-weight: bold;
    color: gray;
    cursor: pointer;
    z-index: 20;
    line-height: 1;
}
#mymap-close:hover { color: black; }

.mymap-toolbar {
    position: relative;
    padding-right: 26px;
    flex-shrink: 0;
}

.mymap-search-row {
    display: flex;
    gap: 4px;
}

#mymap-search-input {
    flex: 1;
    font-size: 14px;
    padding: 4px 8px;
    border: 1px solid gray;
    border-radius: 4px;
    outline: none;
    min-width: 0;
}

.mymap-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 13px;
    padding: 2px 4px;
    flex-shrink: 0;
    position: relative;
    z-index: 40; /* Cao hơn bản đồ và thanh tìm kiếm */
}

.mymap-footer-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

#mymap-coord-text {
    font-family: monospace;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#mymap-search-btn, #mymap-gps-btn, #mymap-apply-btn, #mymap-route-btn {
    font-size: 13px;
    color: white;
    background-color: gray;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    white-space: nowrap;
}

#mymap-search-btn:hover, #mymap-gps-btn:hover, #mymap-apply-btn:hover, #mymap-route-btn:hover {
    background-color: black;
}

#mymap-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 26px;
    max-height: 180px;
    overflow-y: auto;
    background: white;
    border: 1px solid gray;
    border-radius: 4px;
    z-index: 30;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.mymap-result-item {
    font-size: 13px;
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}
.mymap-result-item:hover { background-color: lightgray; }

#mymap-viewport {
    position: relative;
    flex: 1;
    width: 100%;
    overflow: hidden;
    background-color: #E5E3DF;
    border: 1px solid #BDBDBD;
    border-radius: 4px;
    cursor: grab;
    touch-action: none;
}
#mymap-viewport:active { cursor: grabbing; }

/* Nút Sao chép tọa độ đồng bộ giao diện với các nút footer */
#mymap-copy-btn {
    font-size: 13px;
    color: white;
    background-color: gray;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    white-space: nowrap;
}

#mymap-copy-btn:hover {
    background-color: black;
}

/* Dropdown chọn Tâm lọc (N+1 lựa chọn) mở hướng lên trên */
.mymap-apply-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    min-width: 210px;
    max-height: 220px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid gray;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    z-index: 999;
}

.mymap-apply-item {
    font-size: 13px;
    color: black;
    padding: 6px 10px;
    border-bottom: 1px solid #EEEEEE;
    cursor: pointer;
    white-space: nowrap;
}

.mymap-apply-item:last-child {
    border-bottom: none;
}

.mymap-apply-item:hover {
    background-color: lightgray;
}

/* Thanh chỉnh sửa bán kính & xóa nhanh tâm lọc dưới footer bản đồ */
.mymap-center-editor {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background-color: #EFEFEF;
    border-top: 1px solid #CCCCCC;
    border-radius: 4px;
    font-size: 13px;
    flex-shrink: 0;
}

#mymap-center-label {
    font-weight: bold;
    white-space: nowrap;
}

#mymap-center-radius {
    width: 100px;
    padding: 3px 6px;
    font-size: 13px;
    border: 1px solid gray;
    border-radius: 4px;
    outline: none;
}

#mymap-center-delete {
    margin-left: auto;
    font-size: 12px;
    color: white;
    background-color: #B91C1C;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    white-space: nowrap;
}

#mymap-center-delete:hover {
    background-color: #7F1D1D;
}

#mymap-center-close {
    background: transparent;
    border: none;
    font-size: 18px;
    font-weight: bold;
    color: gray;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}

#mymap-center-close:hover {
    color: black;
}

/* ====================================================================
    THANH LỌC ĐA LỚP TRÊN BẢN ĐỒ (.mymap-filterbar)
   ==================================================================== */
.mymap-filterbar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0;
}

.mymap-filterbar::-webkit-scrollbar {
    height: 4px;
}

.mymap-filterbar::-webkit-scrollbar-thumb {
    background: lightgray;
    border-radius: 4px;
}

.mymap-filtertab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 13px;
    color: black;
    background-color: #E5E5E5;
    border: none;
    border-radius: 5px;
    padding: 3px 8px;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.mymap-filtertab:hover {
    background-color: lightgray;
}

/* Ẩn hoàn toàn ô vuông checkbox mặc định */
.mymap-filtertab input[type="checkbox"] {
    display: none;
}

.mymap-filtertab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Màu icon khi chưa tích chọn */
.mymap-filtertab:has(input[value="note"]) svg { color: blue; }
.mymap-filtertab:has(input[value="love"]) svg { color: red; }
.mymap-filtertab:has(input[value="hate"]) svg { color: black; }

/* Trạng thái khi được tích chọn: Tô đặc toàn bộ nền nút và chuyển chữ/icon sang màu trắng */
.mymap-filtertab:has(input[type="checkbox"]:checked),
.mymap-filtertab:has(input[type="checkbox"]:checked) svg {
    color: white !important;
}

.mymap-filtertab:has(input[value="note"]:checked) {
    background-color: blue;
}

.mymap-filtertab:has(input[value="love"]:checked) {
    background-color: red;
}

.mymap-filtertab:has(input[value="hate"]:checked) {
    background-color: black;
}

.mymap-filtertab:has(input[value="search"]:checked) {
    background-color: green;
}

.mymap-filtertab:has(input[value="other"]:checked) {
    background-color: gray;
}

.mymap-filtertab:has(input[name="kindonmap"]:checked) {
    background-color: gray;
}
