html, body {
    height: 100%;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
      width: 100%;
  overflow-x: hidden; /* QUAN TRỌNG */
}

/* ===== MAP ===== */
#map {
    position: absolute;
    top: 55px;      /* header */
    bottom: 32px;   /* footer */
    left: 0;
    right: 0;
}

/* ===== HEADER ===== */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;

    height: 55px;
    background: #2e7d32;
    color: #fff;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 18px;
    font-weight: bold;
    z-index: 3000; /* luôn cao nhất */
}


/* ===== FOOTER ===== */
#footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;

    height: 32px;
    background: #1b5e20;
    color: #e0e0e0;

    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 2000;
    width: 100%;
}



/* ===== LEGEND ===== */
.legend {
    background: white;
    padding: 10px;
    line-height: 20px;
    color: #333;
    font-size: 13px;
}
.legend i {
    width: 40px;
    height: 16px;
    float: left;
    margin-right: 8px;
    opacity: 0.9;
}
.legend h4 {
    margin: 0 0 6px;
    font-size: 14px;
}
/* ===== POPUP CHUYÊN NGHIỆP ===== */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 0;
}

.popup-box {
    width: 320px;
    font-size: 13px;
    color: #333;
}

.popup-header {
    background: #2e7d32;
    color: #fff;
    padding: 8px 10px;
    font-weight: bold;
    text-align: center;
    text-transform: uppercase;
}

.popup-body {
    padding: 10px;
}

.popup-section {
    margin-bottom: 8px;
}

.popup-section-title {
    font-weight: bold;
    color: #1b5e20;
    border-bottom: 1px solid #c8e6c9;
    margin-bottom: 4px;
    padding-bottom: 2px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    margin: 2px 0;
}

.popup-label {
    font-weight: 600;
    color: #555;
}

.popup-value {
    text-align: right;
    color: #000;
}

/* ===== BOTTOM SHEET – MOBILE COMPACT ===== */
.bottom-sheet {
    position: fixed;
    left: 50%;
    bottom: -100%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 420px;

    max-height: 45vh;           /* 👈 giảm mạnh */
    background: #fff;
    border-radius: 14px 14px 10px 10px;
    box-shadow: 0 -3px 12px rgba(0,0,0,0.25);
    z-index: 3000;

    transition: bottom 0.25s ease;
    overflow-y: auto;
}

.bottom-sheet.active {
    bottom: 10px;
}

.sheet-handle {
    width: 36px;
    height: 4px;
    background: #bbb;
    border-radius: 2px;
    margin: 8px auto 4px;
}
@media (max-width: 768px) {

  .popup-box {
      width: 100%;
      font-size: 12.5px;
  }

  .popup-header {
      padding: 6px 8px;
      font-size: 13px;
  }

  .popup-body {
      padding: 8px;
  }

  .popup-section {
      margin-bottom: 6px;
  }

  .popup-section-title {
      font-size: 12.5px;
  }

  .popup-row {
      margin: 1px 0;
  }
}

/* ===== POPUP FOOTER – NÚT ĐÓNG LUÔN THẤY ===== */
.popup-footer {
    position: sticky;
    bottom: 0;
    background: #ffffff;
    padding: 10px 0 12px;
    text-align: center;
    border-top: 1px solid #c8e6c9;
}

.btn-close-popup {
    background: #2e7d32 !important;
    color: #ffffff !important;
    border: none;
    padding: 8px 22px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.leaflet-top.leaflet-right .legend {
    margin-top: 25px; /* tránh header */
}

/* ===== NÚT MỞ PANEL ===== */
.btn-toggle-rubber {
    position: absolute;
    top: 130px;
    right: 12px;
    z-index: 1500;
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

/* ===== PANEL DESKTOP ===== */
.rubber-panel {
    position: absolute;
    top: 120px;
    right: -360px;
    width: 340px;
    max-height: 70vh;
    background: #fff;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 10px rgba(0,0,0,0.25);
    z-index: 1600;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.rubber-panel.active {
    right: 0;
}

.rubber-panel-header {
    background: #2e7d32;
    color: #fff;
    padding: 10px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rubber-panel-header span {
    cursor: pointer;
}

.rubber-panel-content {
    padding: 10px;
    overflow-y: auto;
    font-size: 13px;
}

/* ===== CARD ĐỘI ===== */
.team-card {
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 10px;
}

.team-title {
    font-weight: bold;
    margin-bottom: 4px;
    color: #1b5e20;
}

.team-total {
    font-size: 13px;
    margin-bottom: 6px;
}

.team-row {
    display: flex;
    justify-content: space-between;
    margin: 2px 0;
}

/* ===== MOBILE: panel dùng bottom sheet ===== */
@media (max-width: 768px) {
    .rubber-panel {
        display: none;
    }
    .btn-toggle-rubber {
        top: auto;
        bottom: 90px;
        right: 12px;
    }
}

/* ===== RUBBER STAT BOTTOM SHEET – MOBILE (FIX) ===== */
.rubber-sheet {
    position: fixed;
    left: 50%;
    bottom: -100%;
    transform: translateX(-50%);
    width: 94%;
    max-width: 480px;

    height: 55vh;              /* 👈 CỐ ĐỊNH CHIỀU CAO */
    background: #ffffff;
    border-radius: 14px 14px 10px 10px;
    box-shadow: 0 -3px 12px rgba(0,0,0,0.25);
    z-index: 2600;

    transition: bottom 0.25s ease;
    display: flex;
    flex-direction: column;   /* 👈 RẤT QUAN TRỌNG */
}

.rubber-sheet.active {
    bottom: 12px;
}


.rubber-sheet-handle {
    width: 36px;
    height: 4px;
    background: #bbb;
    border-radius: 2px;
    margin: 8px auto 6px;
}

.rubber-sheet-header {
    background: #2e7d32;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rubber-sheet-header span {
    cursor: pointer;
    font-size: 16px;
}

.rubber-sheet-content {
    flex: 1;                  /* 👈 CHIẾM PHẦN CÒN LẠI */
    padding: 8px 10px 12px;
    overflow-y: auto;         /* 👈 CHO PHÉP CUỘN */
    font-size: 13px;
}


/* card đội trong mobile */
.rubber-team-card {
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
}

.rubber-team-title {
    font-weight: bold;
    color: #1b5e20;
    margin-bottom: 4px;
}

.rubber-team-total {
    font-size: 13px;
    margin-bottom: 6px;
}

.rubber-team-row {
    display: flex;
    justify-content: space-between;
    margin: 2px 0;
}

/* desktop không hiển thị */
@media (min-width: 769px) {
    .rubber-sheet {
        display: none;
    }
}

.rubber-sheet-header span {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
}

.rubber-sheet-header span:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== FIX: tránh nút thống kê đè legend (DESKTOP) ===== */
@media (min-width: 769px) {
    .btn-toggle-rubber {
        top: 380px;   /* 👈 đẩy xuống dưới legend */
        right: 12px;
    }
}

.header-left img {
  height: 36px;
  width: auto;
}
.header-left {
  position: absolute;
  left: 12px;
  display: flex;
  align-items: center;
}
/* Mobile tối ưu */
@media (max-width: 768px) {
  .header-left img {
    height: 30px;
  }

  .header-title {
    font-size: 13px;
    padding: 0 40px;
  }
}


.search-item {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 13px;
}

.search-item:hover {
    background: #e8f5e9;
}

.search-item b {
    color: #2e7d32;
}



.search-container input {
    width: 260px;
    padding: 7px 10px;
    font-size: 14px;
    border: 1px solid #c8e6c9;
    border-radius: 4px;
}

.search-container button {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 4px;
    cursor: pointer;
}

@media (max-width: 768px) {


  .search-container input {
      flex: 1;
      width: auto;
      font-size: 14px;
  }

  .search-container button {
      padding: 8px 16px;
      font-size: 14px;
  }
}
.search-results {
    position: absolute;
    top: 100%;
    left: 12px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    max-height: 240px;
    overflow-y: auto;
    z-index: 3500;
    width: 300px;
}
.search-results,
.search-item {
    pointer-events: auto;
}
@media (max-width: 768px) {

  .search-container input {
      flex: 1;
      width: auto;
      font-size: 14px;
  }

  .search-container button {
      padding: 7px 14px;
      font-size: 14px;
  }
}

/* ===== LEAFLET CONTROL – LOCATE ===== */
.leaflet-control-locate {
    background: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;
}

.leaflet-control-locate:hover {
    background: #f1f8f4;
}

.leaflet-control-locate.active {
    background: #e8f5e9;
}

.leaflet-control-locate svg {
    width: 20px;
    height: 20px;
    fill: #2e7d32;
}


/* ===== LABEL LÔ ===== */
.parcel-tooltip {
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
    font-size: 12px;
    font-weight: 600;
    color: #6a1b9a;
    text-align: center;
    /* 👇 VIỀN TRẮNG */
    text-shadow:
        -1px -1px 0 #fff,
         1px -1px 0 #fff,
        -1px  1px 0 #fff,
         1px  1px 0 #fff,
         0px  0px 2px #fff;
}

.parcel-label {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #1b5e20;
    line-height: 1.2;
    white-space: nowrap;
}

.parcel-label span {
    font-size: 12px;
    font-weight: normal;
    color: #555;
}

/* ===== DÒNG THỐNG KÊ ĐANG ĐƯỢC CHỌN ===== */
.stat-row {
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.stat-row.active {
    background: #e8f5e9;                 /* nền xanh nhạt */
    box-shadow: inset 4px 0 0 #2e7d32;   /* vạch xanh bên trái */
    font-weight: bold;
}

/* thêm icon nhận biết */
.stat-row.active span:first-child::before {
    content: "▶ ";
    color: #2e7d32;
    font-weight: bold;
}
.stat-row:hover {
    background: #f1f8f4;
}
@media (max-width: 768px) {
  .stat-row.active {
      background: #dcedc8;
      box-shadow: inset 6px 0 0 #1b5e20;
  }
}

/* ===== MAP NOTE ===== */
#map-note {
  position: fixed;
  bottom: 12px;
  left: 12px;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.95);
  border-left: 4px solid #2e7d32;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 999;
}

#map-note ul {
  padding-left: 18px;
  margin: 6px 0 0;
}

#map-note li {
  margin-bottom: 4px;
}

/* ===== TOGGLE NOTE BUTTON (MOBILE) ===== */
#toggle-note {
  position: fixed;
  bottom: 12px;
  left: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #2e7d32;
  color: white;
  font-size: 18px;
  cursor: pointer;
  z-index: 1000;
  display: none; /* desktop ẩn */
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  #map-note {
    display: none; /* mobile mặc định ẩn */
    max-width: 90%;
  }

  #toggle-note {
    display: block;
  }
}
/* ===== MAP NOTE ===== */
#map-note {
  position: fixed;
  bottom: 52px; /* 👈 32px footer + 20px đệm */
  left: 12px;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.95);
  border-left: 4px solid #2e7d32;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 1100; /* 👈 cao hơn footer */
}


#map-note ul {
  padding-left: 18px;
  margin: 6px 0 0;
}

#map-note li {
  margin-bottom: 4px;
}

/* ===== TOGGLE NOTE BUTTON (MOBILE) ===== */
#toggle-note {
  position: fixed;
  bottom: 33px;   /* 👈 32px footer + 20px đệm */
  left: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #2e7d32;
  color: white;
  font-size: 18px;
  cursor: pointer;
  z-index: 2100;
  display: none;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  #map-note {
    display: none; /* mobile mặc định ẩn */
    max-width: 90%;
  }

  #toggle-note {
    display: block;
  }
}
@media (max-width: 768px) {
  #map-note {
    bottom: 33px; /* 👈 cao hơn nút ℹ️ */
    z-index: 1100;
  }
}
.search-container {
    position: fixed;
    top: 55px;              /* đúng bằng chiều cao header */
    left: 50%;
    transform: translateX(-50%);

    display: flex;
    gap: 6px;
    padding: 8px 12px;

    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);

    z-index: 2500;
    align-items: center;
}
/* ===== HEADER MOBILE CĂN ĐỀU ===== */
@media (max-width: 768px) {
  #header {
    height: auto;
    padding: 6px 8px;
  }

  .header-title {
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    padding: 0 32px;   /* chừa chỗ logo */
    white-space: normal;
  }
}

/* ===== FOOTER MOBILE GỌN ===== */
@media (max-width: 768px) {
  #footer {
    font-size: 11px;
    padding: 4px 6px;
    text-align: center;
    line-height: 1.2;
  }
}
@media (max-width: 768px) {
  .leaflet-top.leaflet-right .legend {
    margin-top: 90px;  /* 55px header + ~35px search */
  }
}
@media (max-width: 768px) {
  #map-note {
    bottom: 110px;   /* cao hơn nút 📊 */
    z-index: 2200;
  }
}
@media (max-width: 768px) {
  .btn-toggle-rubber {
    bottom: 50px;   /* cao hơn footer */
  }
}
/* ===== OPACITY CONTROL  ===== */
.opacity-control {
    background: #ffffff;
    padding: 6px 8px;
    margin-top: 8px;          /* 👈 cách nút zoom */
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 12px;
    width: 140px;
}

.opacity-control label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #1b5e20;
}

.opacity-control input {
    width: 100%;
}
.opacity-toggle {
    margin-top: 8px; /* cách nút zoom */
}

.opacity-btn {
    width: 34px;
    height: 34px;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 16px;
}

.opacity-btn:hover {
    background: #f1f8f4;
}

.opacity-panel {
    margin-top: 6px;
    background: #ffffff;
    padding: 6px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    width: 140px;
    font-size: 12px;
}

.opacity-panel label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #1b5e20;
}

.opacity-panel input {
    width: 100%;
}
/* ===== BASEMAP  ===== */
.basemap-toggle {
    margin-top: 6px; /* nằm ngay dưới opacity */
}

.basemap-btn {
    width: 34px;
    height: 34px;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 16px;
}

.basemap-btn:hover {
    background: #f1f8f4;
}

.basemap-panel {
    margin-top: 6px;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    overflow: hidden;
    font-size: 12px;
}

.basemap-item {
    padding: 6px 10px;
    cursor: pointer;
    white-space: nowrap;
}

.basemap-item:hover {
    background: #e8f5e9;
}

.basemap-item.active {
    font-weight: bold;
    color: #1b5e20;
    background: #f1f8f4;
}

/* ===== LEGEND ICON TOGGLE ===== */
.legend-toggle {
    margin-top: 6px;
}

.legend-btn {
    width: 34px;
    height: 34px;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.legend-btn:hover {
    background: #f1f8f4;
}

.legend-panel {
    margin-top: 6px;
    width: 220px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
    overflow: hidden;
    font-size: 12px;
}

.legend-header {
    background: #2e7d32;
    color: #ffffff;
    padding: 6px 8px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legend-close {
    cursor: pointer;
    font-size: 14px;
}

.legend-content {
    padding: 8px;
    line-height: 18px;
}

.legend-content i {
    width: 24px;
    height: 14px;
    float: left;
    margin-right: 6px;
    opacity: 0.9;
}

/* =========================
   ICON NĂNG SUẤT (YIELD)
   ========================= */
.yield-btn {
    font-size: 22px;            /* kích thước icon */
    cursor: pointer;
    color: #555;                /* trạng thái OFF */
    transition: all 0.2s ease;
    line-height: 1;
}

/* Hover nhẹ */
.yield-btn:hover {
    color: #2e7d32;
    transform: scale(1.12);
}

/* Đang bật năng suất */
.yield-btn.active {
    color: #2e7d32;
    background: rgba(46, 125, 50, 0.12);
    border-radius: 6px;
    box-shadow: 0 0 0 2px rgba(0, 255, 115, 0.25);
}

/* ===== ICON LEGEND ===== */
.legend-btn {
    font-size: 22px;   /* 👈 tăng tại đây */
    cursor: pointer;
    line-height: 1;
}
/* Hiệu ứng mượt cho polygon Leaflet */
.leaflet-interactive {
    transition: fill-opacity 0.25s linear;
}

.leaflet-control-locate {
  margin-top: 6px;
}


.header-right {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);

  display: flex;
  align-items: center;
  gap: 8px;
}

#userInfo {
  font-size: 13px;
  opacity: 0.9;
  white-space: nowrap;
}

#btnLogout {
  background: #1b5e20;
  color: #fff;
  border: none;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
@media (max-width: 768px) {
  #userInfo {
    display: none;   /* mobile ẩn tên, chỉ để nút đăng xuất */
  }
}
/* ===== UPDATE===== */
.update-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  background: rgba(0,0,0,0.4);
  z-index: 9999;
}

.update-popup.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.update-box {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  width: 300px;
  text-align: center;
}

.update-title {
  font-weight: bold;
  margin-bottom: 10px;
}

.update-text {
  font-size: 14px;
  margin-bottom: 15px;
}

#btnUpdateApp {
  background: #2e7d32;
  color: #fff;
  border: none;
  padding: 10px 15px;
  border-radius: 6px;
  cursor: pointer;
}