:root {
  --bg-dark: #121212;
  --glass-bg: rgba(20, 20, 20, 0.65);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-primary: #f0f0f0;
  --text-secondary: #aaaaaa;
  --accent: #00d2ff;
  --accent-glow: rgba(0, 210, 255, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

.hidden {
  display: none !important;
}

body, html, #app {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-dark);
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  color: var(--text-primary);
}

.ui-container {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 320px;
  pointer-events: none;
}

.search-box, .sidebar {
  pointer-events: auto;
}

.search-box {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  width: 260px;
  border-radius: 30px;
  transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  background: rgba(20, 20, 20, 0.85);
}

.search-box:focus-within {
  box-shadow: 0 0 20px var(--accent-glow), 0 4px 15px rgba(0, 0, 0, 0.6);
  border-color: var(--accent);
  background: rgba(10, 10, 10, 0.95);
  width: 400px;
}

#searchInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-size: 13px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

#searchInput::placeholder {
  color: var(--text-secondary);
}

#searchBtn {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 16px;
  padding: 0 5px;
  transition: transform 0.2s;
}
#searchBtn:hover {
  transform: scale(1.1);
}

.toggle-box {
  position: absolute;
  bottom: 20px;
  left: 60px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 15px;
  cursor: pointer;
  width: max-content;
  color: var(--text-primary);
  font-size: 0.85rem;
  user-select: none;
  pointer-events: auto;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}
.toggle-box input[type="checkbox"] {
  accent-color: #00d2ff;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.sidebar {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: top left;
}

.sidebar.hidden {
  opacity: 0;
  transform: scale(0.95) translateY(-10px);
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

#closeSidebar {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: color 0.2s;
}
#closeSidebar:hover {
  color: white;
}

.sidebar-content {
  padding: 20px;
  overflow-y: auto;
}

.sidebar-content::-webkit-scrollbar {
  width: 6px;
}
.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 3px;
}

.info-row {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
}
.info-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.info-value {
  font-size: 15px;
  font-weight: 400;
  word-break: break-word;
}
.info-value.highlight {
  color: var(--accent);
  font-weight: 600;
}

.legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  padding: 15px;
  width: 150px;
}
.legend h3 {
  font-size: 13px;
  margin-bottom: 10px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
}
.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  font-size: 13px;
}
.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  margin-right: 10px;
  border: 1px solid rgba(255,255,255,0.2);
}

.leaflet-tooltip {
  background: var(--glass-bg) !important;
  border: 1px solid var(--glass-border) !important;
  color: white !important;
  backdrop-filter: blur(5px);
  border-radius: 6px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
}
.leaflet-tooltip-top:before {
  border-top-color: var(--glass-bg) !important;
}
.leaflet-tooltip-bottom:before {
  border-bottom-color: var(--glass-bg) !important;
}
.leaflet-tooltip-left:before {
  border-left-color: var(--glass-bg) !important;
}
.leaflet-tooltip-right:before {
  border-right-color: var(--glass-bg) !important;
}

/* --- Auth & Modals --- */
.auth-box {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  width: max-content;
  padding: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 15px;
  pointer-events: auto;
}

#auth-btn {
  border: 2px solid #00d2ff;
  background: rgba(0, 210, 255, 0.1);
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}
#auth-btn:hover {
  background: rgba(0, 210, 255, 0.3);
  box-shadow: 0 0 15px rgba(0, 210, 255, 0.5);
}

.leaflet-top.leaflet-right {
    margin-top: 70px;
    margin-right: 10px;
  }
#user-info {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 600;
  color: #00d2ff;
  text-shadow: 0 0 5px rgba(0, 210, 255, 0.5);
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--glass-bg);
  border: 1px solid rgba(0, 210, 255, 0.3);
  backdrop-filter: blur(10px);
}

.parcel-label {
  color: white;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 
    -1px -1px 0 #000,  
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
  pointer-events: none;
}

.edge-length-label {
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 
    -1px -1px 0 #000,  
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
  background: transparent;
  border: none;
  box-shadow: none;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}
.glass-btn, .primary-btn, .secondary-btn, .text-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Custom Measure Tool */
.custom-measure-btn {
  font-size: 18px;
  text-align: center;
  line-height: 30px;
  background-color: #fff;
  color: #333;
  display: block;
  width: 34px;
  height: 34px;
  text-decoration: none;
}
.custom-measure-btn:hover {
  background-color: #f4f4f4;
}
.custom-measure-btn.active {
  background-color: #ff0000 !important;
  color: #fff !important;
  box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}
.measure-temp-label {
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
}
.measure-permanent-label {
  background: #ff0000;
  color: #fff;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid #fff;
  text-align: center;
}
.glass-btn, .primary-btn, .secondary-btn, .text-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-color);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  font-weight: 600;
}
.glass-btn:hover { background: rgba(255, 255, 255, 0.2); }
.primary-btn { background: #00d2ff; color: #1a1a2e; border: none; }
.primary-btn:hover { background: #3aecff; }
.secondary-btn { background: rgba(255,255,255,0.05); }
.secondary-btn:hover { background: rgba(255,255,255,0.15); }
.text-btn { background: transparent; border: none; color: #aaa; }
.text-btn:hover { color: #fff; background: transparent; }

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  pointer-events: auto;
}
.modal {
  width: 90%;
  max-width: 400px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  animation: modalFadeIn 0.3s ease;
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal h3 {
  margin: 0 0 10px 0;
  font-size: 1.4rem;
  text-align: center;
}
.modal input, .modal textarea {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}
.modal input:focus, .modal textarea:focus {
  outline: none;
  border-color: #00d2ff;
}
.modal textarea {
  resize: vertical;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  justify-content: flex-end;
}
.error-text {
  color: #ff4d4d;
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
}
.success-text {
  color: #00fa9a;
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
}

/* Styling for User Location Marker */
.google-blue-dot {
  background-color: #4285F4;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 0 10px rgba(66, 133, 244, 0.8);
  position: relative;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.7); }
  70% { box-shadow: 0 0 0 15px rgba(66, 133, 244, 0); }
  100% { box-shadow: 0 0 0 0 rgba(66, 133, 244, 0); }
}

.brand-logo { display: flex; align-items: center; flex-shrink: 0; cursor: pointer; }
.logo-text { font-weight: 800; font-size: 15px; letter-spacing: 0.5px; background: linear-gradient(45deg, #00d2ff, #3a7bd5); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-transform: uppercase; }
.search-divider { width: 1px; height: 18px; background: rgba(255,255,255,0.3); margin: 0 10px; flex-shrink: 0; }
#searchBtn { display: flex; align-items: center; justify-content: center; padding: 4px; border-radius: 50%; transition: all 0.2s; }
#searchBtn:hover { background: rgba(0, 210, 255, 0.1); transform: scale(1.1); }

.dghc-tooltip { background: rgba(0,0,0,0.7); border: none; color: white; font-weight: bold; font-size: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }
.vungthon-tooltip { background: rgba(138,43,226,0.8); border: none; color: white; font-weight: bold; font-size: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }

.gia-dat-tooltip {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #FF0000;
  border-radius: 4px;
  font-weight: bold;
  color: #D32F2F;
  font-size: 11px;
  padding: 2px 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  white-space: nowrap;
}


/* Disclaimer */
.disclaimer-banner {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  background: rgba(0, 0, 0, 0.6);
  color: #ffeb3b;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 11.5px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  border: 1px solid rgba(255, 235, 59, 0.25);
}


/* ==========================================================================
   MOBILE RESPONSIVE DESIGN (Giao diện tối ưu cho điện thoại)
   ========================================================================== */

@media (max-width: 768px) {
  /* 1. Header & Top Bar: Tự động tránh tai thỏ / Dynamic Island (Safe Area) trên iPhone & Android */
  .auth-box {
    top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    right: 10px !important;
    gap: 6px !important;
    z-index: 1001 !important;
  }

  /* Nút hồ sơ trên mobile thu gọn thành icon 42x42 hình tròn cực gọn gàng, không lấn khung tìm kiếm */
  #btn-admin-records {
    height: 42px !important;
    width: 42px !important;
    min-width: 42px !important;
    padding: 0 !important;
    border-radius: 21px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    flex-shrink: 0 !important;
  }
  #btn-admin-records.hidden {
    display: none !important;
  }
  #btn-admin-records .admin-rec-text {
    display: none !important; /* Ẩn chữ trên mobile để chống che khung tìm kiếm */
  }
  #btn-admin-records .admin-rec-icon {
    font-size: 19px !important;
    margin: 0 !important;
  }
  #btn-admin-records .admin-rec-badge {
    position: absolute !important;
    top: -2px !important;
    right: -2px !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    padding: 1px 5px !important;
    min-width: 16px !important;
    height: 16px !important;
    border-radius: 8px !important;
    line-height: 14px !important;
    border: 1.5px solid #0b1118 !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5) !important;
    margin-left: 0 !important;
  }
  
  #auth-btn {
    height: 42px !important;
    padding: 0 12px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: 21px !important;
    white-space: nowrap !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  #user-info {
    display: none !important; /* Ẩn chuỗi email dài trên mobile để thanh trên luôn gọn gàng */
  }

  .ui-container {
    top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    left: 10px !important;
    right: 142px !important; /* Chừa 142px an toàn tuyệt đối cho nút 📂 (42px) + nút Đăng xuất (~75px) + gap */
    width: auto !important;
    max-width: none !important;
    z-index: 1000 !important;
  }

  .search-box {
    width: 100% !important;
    height: 42px !important;
    padding: 0 8px 0 12px !important;
    border-radius: 21px !important;
    box-sizing: border-box !important;
    border: 1.5px solid rgba(255, 255, 255, 0.65) !important;
    cursor: text !important;
  }

  .search-box:focus-within {
    width: 100% !important;
  }

  .brand-logo svg {
    width: 16px !important;
    height: 16px !important;
    margin-right: 4px !important;
  }

  .logo-text {
    font-size: 13px !important;
    white-space: nowrap !important;
  }

  .search-divider {
    margin: 0 6px !important;
    height: 16px !important;
  }

  #searchInput {
    font-size: 16px !important; /* Chuẩn 16px giúp iOS Safari/PWA mở bàn phím mượt mà, không bị lỗi zoom */
    height: 100% !important;
    padding: 0 4px !important;
    min-width: 0 !important; /* Cho phép co giãn mượt mà trên màn hình nhỏ */
    -webkit-user-select: text !important;
    user-select: text !important;
    touch-action: manipulation !important;
    pointer-events: auto !important;
  }

  #searchInput::placeholder {
    font-size: 12px !important;
  }

  /* Nút chuyển lớp bản đồ của Leaflet: xếp ngay dưới nút Đăng xuất */
  .leaflet-top.leaflet-right {
    margin-top: calc(env(safe-area-inset-top, 0px) + 62px) !important;
    margin-right: 10px !important;
  }

  /* 2. Footer & Bottom Area: Phân tầng khoa học, tách rời hoàn toàn các nút */
  
  /* Tầng 1 (Sát đáy): Dải cảnh báo pháp lý thanh mảnh, cố định mép dưới */
  .disclaimer-banner {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    width: 100% !important;
    border-radius: 0 !important;
    font-size: 10px !important;
    padding: 4px 8px !important;
    text-align: center !important;
    background: rgba(0, 0, 0, 0.8) !important;
    border: none !important;
    border-top: 1px solid rgba(255, 235, 59, 0.25) !important;
    white-space: normal !important;
    line-height: 1.25 !important;
    z-index: 998 !important;
    box-sizing: border-box !important;
  }

  /* Tầng 2: Nút Bật màu nền (trái) và Nút Chú giải (phải) cách mép dưới 28px */
  .toggle-box {
    bottom: 28px !important;
    left: 10px !important;
    padding: 6px 10px !important;
    font-size: 11.5px !important;
    height: 32px !important;
    border-radius: 16px !important;
    white-space: nowrap !important;
    gap: 6px !important;
    z-index: 1000 !important;
  }

  .toggle-box input[type="checkbox"] {
    width: 14px !important;
    height: 14px !important;
  }

  .legend {
    bottom: 28px !important;
    right: 10px !important;
    width: auto !important;
    padding: 6px 12px !important;
    height: 32px !important;
    border-radius: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    z-index: 1000 !important;
  }

  .legend h3 {
    font-size: 11.5px !important;
    margin-bottom: 0 !important;
  }

  #legend-items {
    position: absolute !important;
    bottom: 40px !important;
    right: 0 !important;
    width: 220px !important;
    max-height: 48vh !important;
    background: rgba(18, 18, 18, 0.96) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px !important;
    padding: 12px !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    z-index: 1002 !important;
  }

  /* Tầng 3: Các nút điều khiển Leaflet (Zoom +/-, Định vị GPS, Thước đo) nâng lên trên nút Bật màu nền */
  .leaflet-bottom.leaflet-left {
    margin-bottom: calc(36px + env(safe-area-inset-bottom, 0px)) !important;
    margin-left: 10px !important;
  }

  /* 3. Sidebar chi tiết thửa đất: Hiển thị dạng Bottom Sheet hiện đại từ đáy màn hình */
  .sidebar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-height: 65vh !important;
    border-radius: 20px 20px 0 0 !important;
    z-index: 10005 !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6) !important;
    background: rgba(18, 18, 18, 0.96) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-bottom: none !important;
    transition: transform 0.3s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.2s ease !important;
    transform: translateY(0) !important;
  }

  .sidebar.hidden {
    opacity: 0 !important;
    transform: translateY(100%) !important;
    pointer-events: none !important;
  }

  .sidebar-header {
    padding: 14px 18px !important;
  }

  .sidebar-header h2 {
    font-size: 15px !important;
  }

  .sidebar-content {
    padding: 14px 18px 24px 18px !important;
    max-height: calc(65vh - 55px) !important;
  }

  /* 4. Hộp thoại Đăng nhập / Phản ánh (Modals) */
  .modal {
    width: 92% !important;
    max-width: 360px !important;
    padding: 22px 18px !important;
    gap: 12px !important;
    border-radius: 16px !important;
  }

  .modal h3 {
    font-size: 1.2rem !important;
  }

  .modal input, .modal textarea {
    padding: 10px 12px !important;
    font-size: 13.5px !important;
  }
}

/* Tinh chỉnh đặc biệt cho điện thoại cỡ nhỏ (màn hình hẹp < 400px như iPhone SE, 8, v.v.) */
@media (max-width: 400px) {
  .logo-text {
    display: none !important; /* Ẩn chữ TÂN HỘI, giữ lại logo biểu tượng vị trí màu xanh cực kỳ gọn gàng */
  }
  .brand-logo {
    margin-right: 0 !important;
  }
  .search-divider {
    margin: 0 4px !important;
  }
  .ui-container {
    right: 135px !important;
  }
  #auth-btn {
    padding: 0 8px !important;
    font-size: 11.5px !important;
  }
}




/* PWA Install Button */
.pwa-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 210, 255, 0.15) !important;
  border: 1.5px solid #00d2ff !important;
  color: #fff !important;
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.35) !important;
  cursor: pointer;
  transition: all 0.25s ease;
}
.pwa-install-btn:hover {
  background: rgba(0, 210, 255, 0.3) !important;
  box-shadow: 0 0 18px rgba(0, 210, 255, 0.6) !important;
  transform: translateY(-1px);
}
.pwa-install-btn .pwa-icon {
  font-size: 14px;
  line-height: 1;
}
.pwa-install-btn .pwa-label {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
}


/* Ẩn dấu X mặc định không nhạy của trình duyệt trên WebKit / Chrome */
#searchInput::-webkit-search-cancel-button,
#searchInput::-webkit-search-decoration,
#searchInput::-webkit-search-results-button,
#searchInput::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

/* Nút xóa nhanh nội dung tìm kiếm (Custom Clear Button) */
.clear-search-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #ddd;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin: 0 4px;
  flex-shrink: 0;
  transition: all 0.2s ease;
  padding: 0;
}
.clear-search-btn:hover {
  background: rgba(255, 255, 255, 0.4);
  color: #fff;
  transform: scale(1.1);
}
.clear-search-btn:active {
  transform: scale(0.9);
}


/* Fullscreen Control Button */
.fullscreen-btn {
  background-color: #fff !important;
  color: #333 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important;
  height: 34px !important;
  text-decoration: none !important;
  transition: background-color 0.2s ease, transform 0.1s ease !important;
}
.fullscreen-btn:hover {
  background-color: #f0f0f0 !important;
}
.fullscreen-btn:active {
  background-color: #e0e0e0 !important;
  transform: scale(0.92);
}

/* Locate Control Button */
.locate-btn {
  background-color: #fff !important;
  color: #333 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important;
  height: 34px !important;
  text-decoration: none !important;
  transition: background-color 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease !important;
}
.locate-btn:hover {
  background-color: #f0f0f0 !important;
}
.locate-btn:active {
  transform: scale(0.92);
}
.locate-btn svg {
  transition: fill 0.25s ease, transform 0.25s ease;
}

/* Khi đang bật định vị theo thời gian thực nhưng người dùng đã lướt bản đồ sang chỗ khác */
.locate-btn.active-tracking {
  background-color: #e8f0fe !important;
}
.locate-btn.active-tracking svg {
  fill: #1a73e8 !important;
}

/* Khi đang bật định vị theo thời gian thực VÀ đang theo dõi (căn giữa) */
.locate-btn.active-tracking.following {
  background-color: #1a73e8 !important;
  box-shadow: 0 0 10px rgba(26, 115, 232, 0.6) !important;
}
.locate-btn.active-tracking.following svg {
  fill: #ffffff !important;
  animation: pulse-locate 1.8s infinite;
}

@keyframes pulse-locate {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}


/* Tinh chỉnh chuyên biệt cho iOS (iPhone có Dynamic Island / Tai thỏ) */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 768px) {
    .ui-container {
      top: max(calc(env(safe-area-inset-top, 0px) + 10px), 56px) !important;
    }
    .auth-box {
      top: max(calc(env(safe-area-inset-top, 0px) + 10px), 56px) !important;
    }
    .leaflet-top.leaflet-right {
      margin-top: max(calc(env(safe-area-inset-top, 0px) + 60px), 106px) !important;
    }
    .disclaimer-banner {
      padding-bottom: max(4px, env(safe-area-inset-bottom, 4px)) !important;
    }
    .toggle-box, .legend {
      bottom: calc(28px + env(safe-area-inset-bottom, 0px)) !important;
    }
    .leaflet-bottom.leaflet-left {
      margin-bottom: calc(36px + env(safe-area-inset-bottom, 0px)) !important;
    }
    .sidebar-content {
      padding-bottom: calc(24px + env(safe-area-inset-bottom, 12px)) !important;
    }
  }
}


/* ==========================================================================
   PRO UPGRADE: DARK GLASSMORPHISM CONTROLS, LAYER DRAWER, AUTOCOMPLETE,
   CADASTRAL CARD, MEASURE TOOLBAR, GPS BANNER & SLIP MODAL
   ========================================================================== */

/* Ẩn bảng layer mặc định cũ của Leaflet vì đã có Layer Drawer chuyên nghiệp */
.leaflet-control-layers {
  display: none !important;
}

/* Đồng bộ cụm nút công cụ góc dưới trái theo phong cách Dark Glassmorphism */
.leaflet-bottom.leaflet-left .leaflet-bar {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  margin-bottom: 10px !important;
}

.custom-measure-btn,
.locate-btn,
.fullscreen-btn {
  width: 40px !important;
  height: 40px !important;
  border-radius: 12px !important;
  background: rgba(16, 22, 32, 0.86) !important;
  color: #f0f6fc !important;
  border: 1px solid rgba(0, 210, 255, 0.32) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.22s ease !important;
}

.custom-measure-btn:hover,
.locate-btn:hover,
.fullscreen-btn:hover {
  background: rgba(0, 210, 255, 0.2) !important;
  border-color: #00d2ff !important;
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0, 210, 255, 0.3) !important;
}

.custom-measure-btn svg,
.locate-btn svg,
.fullscreen-btn svg {
  fill: #e6f1ff !important;
  transition: all 0.22s ease;
}

.custom-measure-btn.active {
  background: linear-gradient(135deg, #ff416c, #ff4b2b) !important;
  border-color: #ff758c !important;
  color: #fff !important;
  box-shadow: 0 0 16px rgba(255, 65, 108, 0.65) !important;
}

.locate-btn.active-tracking {
  background: rgba(0, 210, 255, 0.22) !important;
  border-color: #00d2ff !important;
}
.locate-btn.active-tracking svg {
  fill: #00d2ff !important;
}

.locate-btn.active-tracking.following {
  background: linear-gradient(135deg, #00d2ff, #0072ff) !important;
  border-color: #80e5ff !important;
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.65) !important;
}
.locate-btn.active-tracking.following svg {
  fill: #ffffff !important;
}

/* Nút mở Quản lý Lớp bản đồ */
.layer-manager-btn {
  position: absolute;
  top: 72px;
  right: 20px;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 20px;
  background: rgba(16, 22, 32, 0.88) !important;
  border: 1.5px solid rgba(0, 210, 255, 0.45) !important;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transition: all 0.22s ease;
}
.layer-manager-btn:hover {
  background: rgba(0, 210, 255, 0.22) !important;
  border-color: #00d2ff !important;
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.4);
}
.layer-badge {
  background: #00d2ff;
  color: #0a1018;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Bảng Quản lý Lớp Bản Đồ (Layer Drawer) */
.layer-drawer {
  position: absolute;
  top: 120px;
  right: 20px;
  width: 320px;
  max-height: calc(100vh - 160px);
  z-index: 10002;
  display: flex;
  flex-direction: column;
  background: rgba(15, 20, 28, 0.95) !important;
  border: 1px solid rgba(0, 210, 255, 0.35) !important;
  border-radius: 16px !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65) !important;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.layer-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 210, 255, 0.08);
}
.layer-drawer-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}
.drawer-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ccc;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s;
}
.drawer-close-btn:hover {
  background: rgba(255, 70, 70, 0.8);
  color: #fff;
}

.layer-drawer-body {
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.layer-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 10px 12px;
}
.layer-section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #00d2ff;
  margin-bottom: 8px;
}

.opacity-section {
  background: rgba(0, 210, 255, 0.07);
  border-color: rgba(0, 210, 255, 0.25);
}
.opacity-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #ddd;
  margin-bottom: 6px;
}
.opacity-header strong {
  color: #00d2ff;
}
#overlay-opacity-slider {
  width: 100%;
  accent-color: #00d2ff;
  cursor: pointer;
  height: 5px;
}

.basemap-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.basemap-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ccc;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.basemap-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.basemap-pill.active {
  background: rgba(0, 210, 255, 0.22);
  border-color: #00d2ff;
  color: #00d2ff;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.25);
}

.layer-toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 4px;
  cursor: pointer;
  font-size: 12.5px;
  color: #e6edf3;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  user-select: none;
}
.layer-toggle-row:last-child {
  border-bottom: none;
}
.layer-toggle-row input[type="checkbox"] {
  accent-color: #00d2ff;
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.layer-row-name {
  flex: 1;
}
.layer-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
}

/* Gợi ý tìm kiếm thông minh (Autocomplete Dropdown) */
.search-suggestions {
  pointer-events: auto;
  width: 100%;
  max-height: 310px;
  overflow-y: auto;
  background: rgba(15, 20, 28, 0.96) !important;
  border: 1px solid rgba(0, 210, 255, 0.45) !important;
  border-radius: 14px !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65) !important;
  padding: 6px 0;
  margin-top: -6px;
  z-index: 10005;
}
.suggestion-header {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  color: #00d2ff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
}
.suggestion-item {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s;
}
.suggestion-item:last-child {
  border-bottom: none;
}
.suggestion-item:hover,
.suggestion-item:active {
  background: rgba(0, 210, 255, 0.16);
}
.sug-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sug-owner {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sug-sub {
  font-size: 11px;
  color: #aaa;
}
.sug-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}
.sug-badge {
  background: rgba(0, 210, 255, 0.18);
  border: 1px solid rgba(0, 210, 255, 0.45);
  color: #00d2ff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}
.sug-land {
  font-size: 10.5px;
  color: #ddd;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Thiết kế Thẻ Địa Chính Hiện Đại (Cadastral Card) */
.sidebar-drag-handle {
  display: none;
  width: 100%;
  padding: 8px 0 2px 0;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.drag-pill {
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.3);
}
.sidebar-collapse-btn {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ddd;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.cadastral-owner-card {
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.14), rgba(58, 123, 213, 0.12));
  border: 1px solid rgba(0, 210, 255, 0.35);
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 10px;
}
.cadastral-owner-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #8ab4f8;
  margin-bottom: 3px;
}
.cadastral-owner-name {
  font-size: 15.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
}

.cadastral-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.cadastral-metric {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}
.cadastral-metric .m-label {
  font-size: 10.5px;
  color: #aaa;
  text-transform: uppercase;
  display: block;
  margin-bottom: 3px;
}
.cadastral-metric .m-val {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}
.cadastral-metric .m-val.accent {
  color: #00d2ff;
}

.land-type-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 10px;
}
.land-swatch {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.land-type-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.land-type-code {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.land-type-desc {
  font-size: 11.5px;
  color: #bbb;
  line-height: 1.3;
}

.legacy-ref-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 105, 180, 0.08);
  border: 1px dashed rgba(255, 105, 180, 0.35);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12px;
  color: #ffb6c1;
  margin-bottom: 12px;
}

.parcel-action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.parcel-act-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  transition: all 0.2s;
}
.parcel-act-btn:hover {
  background: rgba(0, 210, 255, 0.2);
  border-color: #00d2ff;
}
.parcel-act-btn.primary {
  background: linear-gradient(135deg, #00d2ff, #3a7bd5);
  color: #fff;
  border: none;
}
.parcel-act-btn.warn {
  background: rgba(255, 152, 0, 0.16);
  border-color: rgba(255, 152, 0, 0.45);
  color: #ffd54f;
}

/* Thanh trạng thái Đo đạc (Khoảng cách & Diện tích) */
.measure-toolbar {
  position: absolute;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10003;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 24px;
  background: rgba(15, 20, 28, 0.94) !important;
  border: 1.5px solid #00d2ff !important;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}
.measure-metrics {
  font-size: 12.5px;
  color: #eee;
  display: flex;
  align-items: center;
  gap: 8px;
}
.measure-metrics strong {
  color: #00d2ff;
  font-size: 13.5px;
}
.measure-sep {
  opacity: 0.35;
}
.measure-actions {
  display: flex;
  gap: 6px;
}
.measure-action-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.measure-action-btn.danger {
  background: rgba(244, 67, 54, 0.25);
  border-color: #f44336;
  color: #ffcdd2;
}

/* Banner GPS báo thửa đất đang đứng ngoài thực địa */
.gps-parcel-banner {
  position: absolute;
  top: 72px;
  left: 20px;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 20px;
  background: rgba(16, 28, 42, 0.92) !important;
  border: 1.5px solid #00e676 !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  font-size: 12px;
  color: #fff;
}
.gps-banner-btn {
  background: #00e676;
  color: #051b11;
  border: none;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* Toast Notification */
.app-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200000;
  background: rgba(15, 22, 32, 0.95);
  border: 1.5px solid #00d2ff;
  color: #fff;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  text-align: center;
}

/* Modal Phiếu Thông Tin Thửa Đất */
.parcel-slip-box {
  width: 94% !important;
  max-width: 420px !important;
  background: rgba(16, 22, 30, 0.98) !important;
  border: 1.5px solid rgba(0, 210, 255, 0.45) !important;
}
.slip-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 10px;
}
.slip-agency {
  font-size: 10px;
  font-weight: 700;
  color: #00d2ff;
  letter-spacing: 0.7px;
}
.slip-header h3 {
  font-size: 15px !important;
  margin-top: 3px;
  color: #fff;
}
.slip-body {
  font-size: 12.5px;
  color: #e6edf3;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slip-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}
.slip-row span {
  color: #999;
}
.slip-row strong {
  color: #fff;
  text-align: right;
}
.slip-canvas-wrap {
  background: #0b1118;
  border: 1px solid rgba(0, 210, 255, 0.3);
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px;
}
.slip-footer-note {
  font-size: 10.5px;
  color: #aaa;
  font-style: italic;
  text-align: center;
}

/* Responsive trên điện thoại cho các thành phần mới */
@media (max-width: 768px) {
  .layer-manager-btn {
    top: calc(env(safe-area-inset-top, 0px) + 60px) !important;
    right: 10px !important;
    padding: 8px 11px !important;
    font-size: 12px !important;
  }
  .layer-btn-label {
    display: none;
  }
  .layer-drawer {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 75vh !important;
    border-radius: 20px 20px 0 0 !important;
  }
  .sidebar-drag-handle {
    display: flex !important;
  }
  .sidebar-collapse-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
  /* Khi thu gọn Bottom Sheet để quan sát bản đồ */
  .sidebar.collapsed-sheet {
    transform: translateY(calc(100% - 88px)) !important;
  }
  .gps-parcel-banner {
    top: calc(env(safe-area-inset-top, 0px) + 60px) !important;
    left: 10px !important;
    right: 76px !important;
    font-size: 11px !important;
    padding: 6px 10px !important;
  }
  .gps-banner-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
  }
  .measure-toolbar {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
    width: 94% !important;
    justify-content: space-between;
    padding: 7px 11px !important;
  }
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 768px) {
    .layer-manager-btn {
      top: max(calc(env(safe-area-inset-top, 0px) + 58px), 104px) !important;
    }
    .gps-parcel-banner {
      top: max(calc(env(safe-area-inset-top, 0px) + 58px), 104px) !important;
    }
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  #parcel-slip-modal, #parcel-slip-modal * {
    visibility: visible;
  }
  #parcel-slip-modal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: #fff !important;
  }
}


/* Ẩn nút Bật màu nền thửa đất ngoài màn hình chính (đã tích hợp trong Bảng Lớp Bản Đồ) */
.toggle-box {
  display: none !important;
}

@media (max-width: 768px) {
  .leaflet-bottom.leaflet-left {
    margin-bottom: calc(34px + env(safe-area-inset-bottom, 0px)) !important;
    margin-left: 10px !important;
  }
}

/* CSS cho Chức năng Đối soát Dân cư & Kê khai Đất đai */
.parcel-act-btn.doi-soat {
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.25), rgba(58, 123, 213, 0.4));
  border: 1.5px solid #00d2ff;
  color: #00e5ff;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}
.parcel-act-btn.doi-soat:hover {
  background: linear-gradient(135deg, #00d2ff, #3a7bd5);
  color: #0b1118;
  box-shadow: 0 0 15px rgba(0, 210, 255, 0.5);
}

.doi-soat-status-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 12px;
}
.doi-soat-status-box.success {
  border-left: 4px solid #00e676;
  background: rgba(0, 230, 118, 0.08);
}
.doi-soat-status-box.warning {
  border-left: 4px solid #ff9100;
  background: rgba(255, 145, 0, 0.08);
}
.doi-soat-status-box.danger {
  border-left: 4px solid #ff5252;
  background: rgba(255, 82, 82, 0.08);
}

.ds-tab-btn {
  background: transparent;
  border: none;
  color: #9aa4b2;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.ds-tab-btn.active {
  background: rgba(0, 210, 255, 0.18);
  color: #00d2ff;
  font-weight: 700;
}
.preview-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid #00d2ff;
}

.ds-preview-container {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.preview-card {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid #00d2ff;
  background: #111a24;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.preview-card:hover {
  transform: translateY(-2px);
}
.preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.preview-card .btn-del-img {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  background: rgba(239, 68, 68, 0.95);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
  transition: all 0.15s;
}
.preview-card .btn-del-img:hover {
  background: #ff1744;
  transform: scale(1.15);
}
.preview-card .img-order {
  position: absolute;
  bottom: 3px;
  left: 3px;
  background: rgba(11, 17, 24, 0.85);
  color: #00d2ff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(0, 210, 255, 0.3);
}

/* --- ADMIN RECORDS MODAL & TABLE & LIGHTBOX --- */
.admin-records-box {
  max-width: 1180px !important;
  width: 95% !important;
  max-height: 92vh !important;
  padding: 20px 24px !important;
  border-radius: 16px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  background: rgba(11, 18, 28, 0.97) !important;
  border: 1.5px solid rgba(0, 210, 255, 0.4) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(0, 210, 255, 0.15) !important;
}

.admin-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 12px;
}

.admin-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(90vh - 210px);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: #e0e6ed;
  text-align: left;
  white-space: nowrap;
}

.admin-table th {
  background: #131c28;
  color: #00d2ff;
  padding: 11px 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 700;
  border-bottom: 2px solid rgba(0, 210, 255, 0.5);
}

.admin-table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(0, 210, 255, 0.08);
}

.admin-img-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1.5px solid #00d2ff;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: inline-block;
  margin-right: 4px;
  background: #000;
}

.admin-img-thumb:hover {
  transform: scale(1.18);
  box-shadow: 0 4px 12px rgba(0, 210, 255, 0.6);
  z-index: 5;
}

.admin-badge-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.admin-badge-status.waiting {
  background: rgba(255, 152, 0, 0.2);
  color: #ffb74d;
  border: 1px solid rgba(255, 152, 0, 0.4);
}

.admin-badge-status.done {
  background: rgba(76, 175, 80, 0.2);
  color: #81c784;
  border: 1px solid rgba(76, 175, 80, 0.4);
}

.btn-table-act {
  padding: 5px 8px;
  border-radius: 6px;
  border: none;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-table-act.locate {
  background: rgba(0, 210, 255, 0.18);
  color: #00d2ff;
  border: 1px solid rgba(0, 210, 255, 0.4);
}
.btn-table-act.locate:hover {
  background: #00d2ff;
  color: #0b1118;
}
.btn-table-act.del {
  background: rgba(255, 82, 82, 0.15);
  color: #ff5252;
  border: 1px solid rgba(255, 82, 82, 0.4);
}
.btn-table-act.del:hover {
  background: #ff5252;
  color: #fff;
}

/* Style chuẩn cho nút Quản lý hồ sơ */
#btn-admin-records {
  height: 42px;
  padding: 0 14px;
  border-radius: 21px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 210, 255, 0.18);
  border: 1.5px solid #00d2ff;
  color: #00d2ff;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
#btn-admin-records:hover {
  background: rgba(0, 210, 255, 0.32);
  box-shadow: 0 0 15px rgba(0, 210, 255, 0.4);
}
#btn-admin-records.hidden {
  display: none !important;
}
#btn-admin-records .admin-rec-badge {
  background: #ff5252;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 2px;
}

/* Badges for Data Source (Nguồn dữ liệu & Độ tin cậy) */
.admin-badge-source {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}
.admin-badge-source.guest {
  background: rgba(255, 193, 7, 0.16);
  color: #ffca28;
  border: 1px solid rgba(255, 193, 7, 0.45);
}
.admin-badge-source.reg {
  background: rgba(0, 230, 118, 0.16);
  color: #00e676;
  border: 1px solid rgba(0, 230, 118, 0.45);
}
.btn-table-act.zip {
  background: rgba(0, 210, 255, 0.18);
  color: #00d2ff;
  border: 1px solid rgba(0, 210, 255, 0.4);
}
.btn-table-act.zip:hover {
  background: #00d2ff;
  color: #0b1118;
}


/* --- STYLES NÂNG CẤP ĐĂNG NHẬP / ĐĂNG KÝ / GOOGLE SIGN-IN --- */
.auth-modal-box {
  background: rgba(15, 23, 42, 0.88) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
}
.auth-tab-btn {
  background: transparent;
  color: #94a3b8;
  border: none;
}
.auth-tab-btn.active {
  background: #00d2ff !important;
  color: #000 !important;
  box-shadow: 0 2px 10px rgba(0, 210, 255, 0.35) !important;
}
.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.auth-input-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  color: #94a3b8;
  pointer-events: none;
}
.auth-custom-input {
  width: 100% !important;
  padding: 10px 38px 10px 36px !important;
  background: rgba(0, 0, 0, 0.45) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: 9px !important;
  color: #fff !important;
  font-size: 13.5px !important;
  box-sizing: border-box !important;
  transition: all 0.2s ease !important;
}
.auth-custom-input:focus {
  border-color: #00d2ff !important;
  outline: none !important;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.3) !important;
}
.auth-pwd-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}
.auth-pwd-toggle:hover {
  color: #00d2ff;
}
.btn-auth-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4);
}
.btn-google-signin:hover {
  background: #f1f5f9 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.25) !important;
}


/* Reset tất cả span và label bên trong modal xác thực để không bị dính khung đen */
.auth-modal-box span {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  text-shadow: none !important;
  border-radius: 0 !important;
}
.auth-modal-box label span {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
}
.auth-input-wrap {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
}
.auth-input-icon {
  position: absolute !important;
  left: 12px !important;
  font-size: 15px !important;
  color: #94a3b8 !important;
  pointer-events: none !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
  z-index: 2 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.auth-custom-input {
  width: 100% !important;
  padding: 10px 42px 10px 40px !important;
  background: rgba(0, 0, 0, 0.45) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: 9px !important;
  color: #fff !important;
  font-size: 13.5px !important;
  box-sizing: border-box !important;
  line-height: normal !important;
}
.auth-custom-input:focus {
  border-color: #00d2ff !important;
  outline: none !important;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.3) !important;
}
.auth-pwd-toggle {
  position: absolute !important;
  right: 12px !important;
  background: transparent !important;
  border: none !important;
  color: #94a3b8 !important;
  font-size: 16px !important;
  cursor: pointer !important;
  padding: 0 !important;
  box-shadow: none !important;
  z-index: 2 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.btn-google-signin span {
  color: #1f2937 !important;
  font-weight: 600 !important;
}
