/* --- RESET & CẤU HÌNH CƠ BẢN --- */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Đã sửa: Xóa overflow-x: hidden ở đây để không khóa cuộn dọc trên một số trình duyệt */
html {
  max-width: 100vw;
}

:root { 
  --bg-color: #f8fafc; 
  --header-old: #27282b; 
  --header-cyber: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); 
  --card-bg: #ffffff; 
  --primary-text: #1e293b; 
  --secondary-text: #64748b; 
  --up-color: #10b981; 
  --down-color: #ef4444; 
  --teal-color: #008b8b; 
  --border-color: #e2e8f0; 
  --accent-color: #3b82f6; 
}

/* Đã sửa: Chuyển overflow-x: hidden xuống chỉ áp dụng cho body */
body { 
  margin: 0; 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
  background: var(--bg-color) !important; 
  color: var(--primary-text); 
  overflow-x: hidden; 
  overscroll-behavior-y: none; /* Giữ nguyên để chặn pull-to-refresh mặc định của trình duyệt */
}

header { 
  padding: 8px 24px; 
  background: #434242; 
  color: white; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  position: fixed; 
  top: 0; left: 0; width: 100%; 
  box-sizing: border-box; 
  z-index: 1000; 
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  min-height: auto;
}

.brand { 
  font-size: 1.25rem; 
  font-weight: 700; 
  color: white; 
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand span { color: var(--accent-color); }

@media (max-width: 640px) {
  header { 
    padding: 0.8rem 1rem; 
    background: #434242; /* Cập nhật lại màu nền xám đen giống Desktop */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-height: 56px;
    border-bottom: none;
  }
  
  .menu-header-side {
    padding: 0.8rem 1rem;
    background: var(--header-cyber);
  }
  
  .container { 
    padding-top: 70px !important; 
    margin-top: 0; 
  } 
  .grid { grid-template-columns: 1fr; gap: 0.8rem; } 
  .card-value { font-size: 1.5rem; } 
}

.container { width: 100%; max-width: 1200px; margin: 0 auto; background: var(--bg-color); min-height: 100vh; padding: 80px 15px 3rem 15px; box-sizing: border-box; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }

.card { background: var(--card-bg); border-radius: 16px; padding: 1.5rem; border: 1px solid var(--border-color); transition: 0.3s; will-change: transform; transform: translateZ(0);}
.card.highlight { border-left: 4px solid var(--accent-color); }
.card-title { font-size: 0.75rem; color: var(--secondary-text); text-transform: uppercase; font-weight: 700; }
.card-value { font-size: 1.875rem; font-weight: 800; margin-top: 0.5rem; }
.sjc-sub { 
  font-size: 1.1rem; 
  margin-top: 0.25rem; 
  display: flex; 
  align-items: center; 
  gap: 4px; 
  font-weight: 800; 
}

@media (hover: hover) {
  .card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.05); }
}

.xau-up { color: var(--teal-color); } 
.xau-down { color: var(--down-color); }
.change-up { color: var(--up-color); } 
.change-down { color: var(--down-color); }

/* --- TABLE CẤU HÌNH --- */
.table-wrapper { 
  background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border-color); 
  overflow-x: auto; margin-bottom: 2rem; 
}

table { 
  width: 100%; 
  border-collapse: collapse; 
  font-size: 0.95rem; 
  min-width: 720px; 
  table-layout: fixed; 
}

th:nth-child(1), td:nth-child(1) { width: 18%; } /* Time */
th:nth-child(2), td:nth-child(2) { width: 20%; } /* XAU */
th:nth-child(3), td:nth-child(3) { width: 25%; } /* SJC */
th:nth-child(4), td:nth-child(4) { width: 25%; } /* Gap */
th:nth-child(5), td:nth-child(5) { width: 12%; } /* Diff */

th { background: #f1f5f9; padding: 8px 16px; text-align: left !important; color: var(--secondary-text); }
td { padding: 8px 16px; border-bottom: 1px solid var(--border-color); text-align: left !important; }

/* CỘT TIME */
.col-time {
  position: relative;
  padding-left: 36px !important;
}

/* CHECKBOX: Ép cứng viền, không cho trình duyệt tự can thiệp kích thước */
.check-action {
  position: absolute;
  left: 12px; 
  top: 52%; 
  transform: translateY(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.2s ease;
  cursor: pointer;
  
  /* Các thuộc tính ép kích thước tuyệt đối */
  margin: 0 !important;
  padding: 0 !important;
  width: 13px !important; 
  height: 13px !important; 
  box-sizing: border-box !important;
}

.table-wrapper.select-mode .check-action {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

th:nth-child(2), td:nth-child(2),
th:nth-child(3), td:nth-child(3),
th:nth-child(4), td:nth-child(4) {
  padding-left: 36px !important;
}

td:nth-child(5) { padding-left: 16px !important; }
th:nth-child(5) { padding-left: 24px !important; }

/* --- FILTER BOX GIAO DIỆN --- */
.filter-box { 
  position: absolute;
  left: 120px; 
  display: flex;
  gap: 10px; 
  align-items: center; 
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.2s ease;
  background: var(--bg-color); 
  z-index: 20; 
}
.filter-box.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Ép thanh Filter thành Menu Dropdown Nổi trên Mobile để chống tràn */
@media (max-width: 768px) {
  .filter-box {
    left: 0;
    top: 45px; 
    width: 100%;
    max-width: none;
    background: var(--card-bg); 
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15); 
    flex-wrap: wrap; 
    border: 1px solid var(--border-color);
    box-sizing: border-box; /* Đã thêm box-sizing để sửa lỗi tràn layout sinh ra khoảng trắng bên phải */
  }
}

input[type="date"] { 
  padding: 8px; 
  border-radius: 8px; 
  border: 1px solid var(--border-color); 
  outline: none; 
}

/* Đoạn đã sửa cho các button */
.btn-filter, .btn-delete-multi, .btn-reset, .btn-select {
  padding: 6px 12px; 
  border-radius: 6px; 
  cursor: pointer; 
  font-weight: 600; 
  font-size: 0.8rem; 
  
  /* Màu nền trong suốt */
  background:  rgba(255,255,255,0.1); 
  /* Viền màu đen */
  border: 1px solid var(--border-color); 
  /* Màu chữ (nên để đen để dễ nhìn trên nền trong suốt) */
  color: rgb(74, 74, 74);
  transition: all 0.3s ease; /* Thêm hiệu ứng mượt mà khi hover */
}

/* Hiệu ứng khi di chuột qua (hover) */
.btn-filter:hover, .btn-delete-multi:hover, .btn-reset:hover, .btn-select:hover {
  /* Bạn có thể cho nền tối nhẹ hoặc đổi màu chữ để người dùng biết là đã chạm vào nút */
  background: rgba(0, 0, 0, 0.1); 
  color: #000;
}

.badge { padding: 4px 8px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; display: inline-block; }
.badge-up { background: rgba(251, 252, 251, 0.1); color: #000408; }
.badge-down { background: rgba(255, 255, 255, 0.1); color: #000408; }

.pagination { display: flex; justify-content: center; gap: 8px; padding: 15px; border-top: 1px solid var(--border-color); }
.page-btn { padding: 6px 12px; border: 1px solid var(--border-color); background: var(--card-bg); border-radius: 6px; cursor: pointer; color: var(--primary-text); font-weight: 600; transition: 0.2s;}
.page-btn.active { background: var(--accent-color); color: white; border-color: var(--accent-color); }
.page-btn:hover:not(:disabled):not(.active) { background: #f1f5f9; }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chart-card { 
  padding: 1.5rem; background: white; border-radius: 12px; border: 1px solid var(--border-color); 
}
.chart-scroll-container { width: 100%; overflow-x: auto; margin-top: 1rem; }

@media (max-width: 640px) {
  .usd-card { display: none; }
  .container { padding-top: 70px !important; }
  #lastTime { margin-top: 5px; margin-bottom: 0.6rem; }
  .grid { grid-template-columns: 1fr; gap: 0.8rem; } 
  .card-value { font-size: 1.5rem; } 
  .xau-wrapper { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .xau-wrapper .sjc-sub { margin-top: 0; }
  .table-wrapper {
    transition: margin-top 0.25s ease;
  }
  .table-wrapper.is-expanded {
    margin-top: 130px; 
  }
}

.chart-inner-wrapper { height: 320px; position: relative; }
.chart-scroll-container::-webkit-scrollbar { height: 8px; }
.chart-scroll-container::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.chart-scroll-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.chart-scroll-container::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- NÚT FORCE SYNC --- */
.sync-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  outline: none;
}

.sync-btn:hover { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.3); }
.sync-btn:active { transform: scale(0.9); } /* Hơi lún xuống khi bấm */

/* Chấm xám mặc định */
.sync-dot {
  width: 10px;
  height: 10px;
  background-color: #64748b; 
  border-radius: 50%;
  transition: background-color 0.3s, box-shadow 0.3s;
}

/* Chấm vàng nhấp nháy khi đang tải */
.sync-dot.loading {
  background-color: #fbbf24; 
  animation: syncPulse 0.8s infinite;
}

/* Chấm xanh phát sáng khi thành công */
.sync-dot.success {
  background-color: #10b981; 
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.8);
}

@keyframes syncPulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0.6; }
}
.diff-sub {
  color: #595959 !important;
}

/* --- HIỆU ỨNG CHỚP NHÁY KHI CẬP NHẬT DỮ LIỆU --- */
@keyframes flashCard {
  0% { background-color: var(--card-bg); border-color: var(--border-color); }
  30% { background-color: rgba(16, 185, 129, 0.15); border-color: var(--up-color); box-shadow: 0 0 15px rgba(16, 185, 129, 0.2); }
  100% { background-color: var(--card-bg); border-color: var(--border-color); box-shadow: none; }
}

.flash-update {
  animation: flashCard 0.8s ease-out forwards;
}

/* ===== PULL TO REFRESH: RADAR SPINNER THEME ===== */
.cyber-pull-container {
  position: fixed; top: -80px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 15px;
  background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 10px 20px; border-radius: 40px;
  border: 1px solid rgba(59, 130, 246, 0.3); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 9999; pointer-events: none;
  transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s, box-shadow 0.3s;
}
.cyber-pull-container.ready {
  border-color: rgba(16, 185, 129, 0.8); box-shadow: 0 0 25px rgba(16, 185, 129, 0.2);
}
.cyber-text {
  color: #94a3b8; font-size: 14px; font-weight: 600; font-family: -apple-system, system-ui, sans-serif; transition: color 0.3s;
}
.cyber-pull-container.ready .cyber-text { color: #10b981; text-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }

/* Radar Spinner */
.radar-spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  transition: border-color 0.3s;
}
.cyber-pull-container.ready .radar-spinner {
  border-top-color: #10b981;
}
.cyber-pull-container.refreshing .radar-spinner {
  border-top-color: #10b981;
  border-right-color: rgba(16, 185, 129, 0.3);
  border-bottom-color: rgba(16, 185, 129, 0.3);
  border-left-color: rgba(16, 185, 129, 0.3);
  animation: radarSpin 0.7s linear infinite;
}
@keyframes radarSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.col-time {
  white-space: nowrap;      /* Ép chữ không được rớt dòng */
  min-width: 85px;          /* Cấp đủ không gian cho giờ + checkbox */
}

.col-time span, 
.col-time input[type="checkbox"] {
  display: inline-block;
  vertical-align: middle;   /* Căn giữa theo chiều dọc cho đẹp mắt */
}
/* 1. Mặc định ẩn thẻ ngắt dòng ở màn hình máy tính để các thành phần nằm trên 1 hàng ngang */
.mobile-break {
  display: none;
}

/* 2. Xử lý hiển thị trên điện thoại */
@media (max-width: 768px) {
  .mobile-break {
    display: block;
    flex-basis: 100%; /* Chiếm trọn 100% chiều ngang Flexbox, buộc các thành phần phía sau phải xuống dòng */
    height: 0;
    margin: 0;
  }
  
  /* Căn chỉnh 2 ô chọn ngày kéo giãn đều nhau để lấp đầy dòng đầu tiên, mang lại cảm giác cân đối */
  #filterBox input[type="date"] {
    flex: 1;
  }
  
  /* (Tùy chọn) Cho phép 4 nút bấm kéo giãn dàn đều nhau ở dòng thứ hai */
  #filterBox button {
    flex: 1;
    padding: 8px 4px; /* Chỉnh lại đệm mỏng hơn một chút để các nút không bị chèn ép trên màn hình nhỏ */
  }
}
/* --- UI TÍCH CHỈ & MENU TRƯỢT --- */
.menu-btn { background: transparent; border: none; color: white; font-size: 1.5rem; cursor: pointer; padding: 0 5px; line-height: 1;}
/* --- UI TÍCH CHỈ & MENU TRƯỢT (BẢN NÂNG CẤP) --- */
.side-menu {
  position: fixed; top: 0; left: -280px; /* Đảm bảo menu trượt hẳn ra ngoài */
  width: 272.5px; 
  height: 100vh;
  background: var(--card-bg); 
  z-index: 2000; 
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 25px rgba(0,0,0,0.15); 
  display: flex; 
  flex-direction: column;
}
.side-menu.open { left: 0; }

.menu-header-side { 
  padding: 10px 24px; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  background: var(--header-cyber); 
  box-sizing: border-box; 
  min-height: 60px; 
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-header-side h3 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.close-btn { 
  background: rgba(255, 255, 255, 0.1); 
  border: none; 
  color: white; 
  font-size: 1.5rem; 
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; 
  transition: background 0.2s;
}
.close-btn:hover { background: rgba(239, 68, 68, 0.8); }

/* --- KHỐI DANH SÁCH MENU CHUNG --- */
.menu-list { 
  list-style: none; 
  padding: 20px 16px 10px 16px; /* Cố định lề trên là 20px cho mọi trường hợp */
  margin: 0; 
  flex-grow: 1; /* Chiếm hết chiều cao còn lại */
}

.menu-list li a {
  display: flex; 
  align-items: center;
  gap: 12px;
  padding: 14px 16px; 
  color: var(--secondary-text); 
  text-decoration: none; 
  font-weight: 600; 
  border-bottom: none; 
  border-radius: 10px; 
  margin-bottom: 6px;
  transition: all 0.25s ease;
}

.menu-list li a:hover { 
  background: #f1f5f9; 
  color: var(--primary-text);
  transform: translateX(6px); 
}
.menu-list li a span { font-size: 1.1rem; }

/* --- KHỐI PROFILE USER (KHI ĐÃ ĐĂNG NHẬP) --- */
.user-profile-card {
  margin: 20px 16px 0 16px; /* Tạo lề trên bằng đúng padding của danh sách menu */
  padding: 12px 16px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-profile-card .avatar {
  width: 42px; height: 42px; 
  background: var(--accent-color); 
  color: white; 
  border-radius: 50%; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-weight: bold; 
  font-size: 1.2rem;
}

/* Nút Đăng xuất ở cuối màn hình */
.logout-wrapper {
  padding: 0 16px 20px 16px;
  margin-top: auto; /* Tự động đẩy xuống đáy */
}

.logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px;
  background: rgba(239, 68, 68, 0.05);
  color: var(--down-color) !important;
  border: 1px solid rgba(239, 68, 68, 0.1);
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}
.logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  transform: translateY(-2px); 
}

/* =========================================================
   GIAO DIỆN SỔ VÀNG TRANG ĐỘC LẬP (KHÔNG CÒN LÀ POPUP)
   ========================================================= */
.sub-page {
  display: none; /* Mặc định ẩn khi ở Trang chủ */
  width: 100%;
  min-height: 100vh;
  background: var(--bg-color);
  /* Xóa hoàn toàn position: fixed và hiệu ứng trượt */
}

.sub-page.open {
  display: block; /* Hiển thị dàn trang như một website độc lập */
}
.sub-header {
  padding: 15px 20px; background: var(--header-cyber); color: white; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.back-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: white; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.tc-buy { color: var(--up-color); font-weight: bold; }
.tc-sell { color: var(--down-color); font-weight: bold; }
.btn-del-tc { background: transparent; color: var(--down-color); border: none; cursor: pointer; font-weight: bold; font-size: 1.2rem;}
/* --- AUTH MODAL (LOGIN / REGISTER) --- */
.auth-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 3000; display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.auth-overlay.show { opacity: 1; visibility: visible; }

.auth-modal {
  background: var(--card-bg); width: 90%; max-width: 360px; /* Đảm bảo 320-400px tùy màn hình */
  border-radius: 16px; padding: 25px 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  position: relative;
  transform: translateY(-20px) scale(0.95); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.auth-overlay.show .auth-modal { transform: translateY(0) scale(1); }

.auth-close {
  position: absolute; top: 10px; right: 15px;
  background: transparent; border: none; font-size: 1.5rem; color: var(--secondary-text); cursor: pointer;
}
.auth-close:hover { color: var(--down-color); }

.auth-input {
  width: 100%; padding: 12px 10px; margin-bottom: 15px;
  border: 1px solid #ccc; border-radius: 8px;
  font-size: 1rem; color: var(--primary-text); background: var(--bg-color);
  box-sizing: border-box; outline: none; transition: border-color 0.2s;
}
.auth-input:focus { border-color: var(--accent-color); }

.auth-btn {
  width: 100%; padding: 12px; background: #3b82f6; color: white;
  border: none; border-radius: 8px; font-size: 1rem; font-weight: bold;
  cursor: pointer; transition: background 0.2s;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.auth-btn:hover:not(:disabled) { background: #2563eb; } /* Đậm hơn khi hover */
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-switch { text-align: center; margin-top: 15px; font-size: 0.9rem; color: var(--secondary-text); }
.auth-switch a { color: var(--accent-color); text-decoration: none; font-weight: bold; }
.auth-switch a:hover { text-decoration: underline; }

.auth-error { background: #fee2e2; color: #ef4444; padding: 10px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 15px; display: none; font-weight: 500; }
.auth-success { background: #d1fae5; color: #10b981; padding: 10px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 15px; display: none; font-weight: 500; }

/* Spinner CSS thuần */
.auth-spinner {
  width: 20px; height: 20px; border: 3px solid rgba(255,255,255,0.3); border-top-color: white;
  border-radius: 50%; animation: authSpin 0.8s linear infinite; display: none; position: absolute;
}
.auth-btn.loading .btn-text { visibility: hidden; }
.auth-btn.loading .auth-spinner { display: block; }
@keyframes authSpin { to { transform: rotate(360deg); } }
#forceSyncBtn {
  display: none; /* Ẩn mặc định, JS sẽ cho hiện sau nếu đúng User */
}

/* ==========================================
   NÚT TOGGLE THAM CHIẾU CUSTOM (NATIVE SELECT REPLACEMENT)
   ========================================== */
.custom-ref-wrapper {
    position: relative;
    display: inline-block;
}

/* Dùng chung style định dạng cho cả 2 viên thuốc */
.ref-toggle-btn, .ref-dropdown-content {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    
    /* Ép nút tự động co hẹp/mở rộng bám sát theo độ dài của chữ */
    width: max-content;
    
    /* Căn giữa chữ và để lề phải rộng hơn (24px) nhường chỗ cho mũi tên */
    text-align: center; 
    padding: 4px 24px 4px 12px; 
    
    font-size: 0.85rem;
    font-weight: 700; 
    color: #64748b; 
    
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center; 
    background-size: 10px;
    transition: all 0.2s ease;
    user-select: none;
    box-sizing: border-box;
}

.ref-toggle-btn:hover, .ref-dropdown-content:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #334155;
    border-color: #94a3b8;
}

/* Viên thuốc lựa chọn còn lại (Làm Dropdown) */
.ref-dropdown-content {
    position: absolute;
    top: calc(100% + 6px); /* Đẩy xuống dưới 6px so với nút gốc */
    right: 0;
    background-color: #ffffff; /* Nền trắng đục để đè lên nội dung bên dưới */
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    z-index: 100;
    white-space: nowrap;
}

/* Hiệu ứng trượt thả xuống mượt mà */
.ref-dropdown-content.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* =========================================================
   SHORTCUT SỔ VÀNG TẠI TRANG CHỦ
   ========================================================= */

.btn-so-vang-fab {
    position: fixed;
    bottom: 30px;
    left: 30px; /* Góc dưới bên phải, bạn có thể đổi thành left: 30px nếu vướng */
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    
    /* Hiệu ứng Glassmorphism */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    
    border: 1px solid rgba(234, 179, 8, 0.5);
    border-radius: 50px;
    color: #1e293b;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(234, 179, 8, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Hiệu ứng ánh sáng Cyber Pulse chìm ở viền */
.btn-so-vang-fab::before {
    content: '';
    position: absolute;
    
    border-radius: 50px;
    background: transparent;
    z-index: -1;
    opacity: 0.4;
    
    transition: opacity 0.3s ease;
    animation: gold-pulse 2.5s infinite alternate;
}

/* Tương tác khi Hover */
.btn-so-vang-fab:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 35px -5px rgba(234, 179, 8, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border-color: rgba(234, 179, 8, 0.9);
    background: rgba(255, 255, 255, 0.95);
}

.btn-so-vang-fab:hover::before {
    opacity: 0.8;
}

/* Icon Animation */
.btn-so-vang-fab svg {
    color: #D97706;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-so-vang-fab:hover svg {
    transform: rotate(-10deg) scale(1.15);
}

/* Nhịp đập Pulse */
@keyframes gold-pulse {
    0% { filter: blur(8px); transform: scale(0.98); }
    100% { filter: blur(14px); transform: scale(1.02); }
}


/* Responsive cho Mobile: Căn giữa nút sát đáy */
@media (max-width: 600px) {
    .btn-so-vang-fab {
        /* 1. CĂN GIỮA HOÀN HẢO */
        left: 86% !important;
        right: auto !important; /* Xóa bỏ lệnh neo bên phải cũ */
        transform: translateX(-50%) !important; /* Dịch chuyển ngược lại 50% chiều rộng chính nó */
        box-shadow:none;
        /* 2. ĐƯA SÁT ĐÁY */
        bottom: 115px !important; 
        background:transparent;
        
        /* 3. CỐ ĐỊNH KÍCH THƯỚC (CHỐNG MÉO) */
        width: 56px !important;
        height: 56px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        
        /* 4. HIỆU ỨNG NỔI BẬT */
        z-index: 9999;
    }
    /* Icon Animation */
.btn-so-vang-fab svg {
    color: #D97706;
    transition: none;
}

.btn-so-vang-fab:hover svg {
    transform: none;
}

    /* Ẩn chữ để nút tròn trịa, tinh tế hơn trên mobile */
    .btn-so-vang-fab .sv-text {
        display: none !important;
    }
}
/* =========================================================
   PREMIUM HEADER ICONS & TEXT
   ========================================================= */

/* --- Hiệu ứng chữ XAU DASHBOARD mạ vàng --- */
.premium-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Be Vietnam Pro', sans-serif;
}

.brand-text {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    
    /* Đổ màu Gradient Vàng 3D cho chữ */
    background: linear-gradient(to right, #b16a0d 70%, #634b03 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% auto;
    
    }

.brand-text-gold {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    
    /* Đổ màu Gradient Vàng 3D cho chữ */
    background: linear-gradient(to right, #f2f2f2 0%, #eddfb5 30%, #efb97c 70%, #FDE047 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% auto;
    
    }

.brand-icon {
    filter: drop-shadow(0 2px 3px rgba(234, 179, 8, 0.3));
}

@keyframes goldShineText {
    to {
        background-position: 200% center;
    }
}

/* --- Hiệu ứng tương tác cho Nút Menu SVG --- */
.premium-menu-btn {
    background: transparent;
    border: none;
    color: #64748b; /* Màu xám thép công nghệ */
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

/* Từng nét (line) trong menu có hiệu ứng mượt */
.premium-menu-btn svg line {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Khi hover: nét giữa dài ra, đổi sang màu vàng */
.premium-menu-btn:hover {
    color: #D97706;
}

.premium-menu-btn:hover .menu-line-2 {
    x2: 21; /* Kéo dài nét giữa ra bằng nét 1 và 3 */
}

/* =========================================================
   PREMIUM SIDE MENU (LIGHT GOLD THEME - #ffe6b3)
   ========================================================= */

.premium-sidebar {
    background: #edebe5; /* Tone màu vàng nhạt chủ đạo theo yêu cầu */
    border-right: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 5px 0 25px rgba(120, 53, 15, 0.15); /* Bóng đổ màu nâu nhạt */
}

/* Header của Sidebar */
.premium-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    /* ĐÃ SỬA: Tăng khoảng cách ở trên (20px) để đẩy chữ MENU và nút X xuống. 
       Cấu trúc: padding: [Trên] [Phải] [Dưới] [Trái] */
    padding: 15px 19px 8px 19px; 
    
    border-bottom: 1px solid rgba(244, 237, 215, 0.1);
}

.menu-brand-side {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #eae3d5; /* Chữ Nâu đậm sang trọng */
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

.premium-close-btn {
    background: transparent;
    border: none;
    color: #92400E; /* Icon đóng màu nâu vàng */
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
}

.premium-close-btn:hover {
    color: #DC2626; /* Chuyển đỏ khi hover */
    background: rgba(220, 38, 38, 0.1);
    transform: rotate(90deg); /* Xoay nhẹ icon x */
}

/* Khối Danh sách Menu */
.premium-menu-list {
    list-style: none;
    padding: 15px 10px;
    margin: 0;
}

.premium-menu-list li a,
.premium-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: #78350F; /* Chữ menu màu Nâu Đất */
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.premium-menu-list li a .menu-icon,
.premium-logout .menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #B45309; /* Icon màu Cam/Nâu sáng */
    transition: all 0.3s ease;
}

/* Tương tác khi lướt chuột vào Menu Item: Hiệu ứng nút kính trắng nổi lên */
.premium-menu-list li a:hover {
    background: rgba(255, 255, 255, 0.7); /* Nền trắng mờ */
    color: #451A03; /* Chữ chuyển đậm hơn */
    transform: translateX(5px);
    box-shadow: 0 4px 10px rgba(120, 53, 15, 0.05);
}

.premium-menu-list li a:hover .menu-icon {
    color: #D97706; /* Icon rực rỡ hơn */
    transform: scale(1.1);
}

/* Nút Đăng xuất riêng biệt */
.premium-logout {
    color: #B91C1C !important; /* Đỏ đô */
}

.premium-logout .menu-icon {
    color: #EF4444 !important;
}

.premium-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #991B1B !important;
    transform: translateX(5px);
}

/* =========================================================
   USER PROFILE CARD (HIỆU ỨNG THẺ VIP TRÊN NỀN SÁNG)
   ========================================================= */

.premium-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    margin: 15px 10px;
    /* Nền thẻ trắng mờ Glassmorphism trên nền vàng */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(120, 53, 15, 0.08);
}

.premium-avatar {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 800;
    font-size: 1.4rem;
    color: #451A03;
    /* Huy hiệu vàng rực rỡ cho Avatar */
    background: linear-gradient(135deg, #FDE047 0%, #F59E0B 100%);
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
    text-transform: uppercase;
    border: 2px solid #FEF08A;
}

.premium-profile .user-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.premium-profile .user-name {
    color: #451A03; /* Tên người dùng Nâu đậm đen */
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.premium-profile .user-role {
    color: #B45309; /* Danh hiệu màu Cam/Nâu */
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}
/* Đường gạch ngang phân cách nét đứt */
.sv-divider-line {
  border: 0;
  border-top: 1px dashed #e69305;
  margin: 18px 0;
}

/* Đường gạch ngang phân cách nét đứt */
.sv-divider-linex {
  border: 0;
  border-top: 1px dashed #e69305;
  
  /* ĐÃ SỬA: margin: [Trên] [Phải] [Dưới] [Trái] */
  /* Chỉnh số 5px nhỏ lại nếu muốn kẻ sát hơn nữa, hoặc tăng lên nếu muốn xa ra */
  margin: 4px 0 18px 0; 
}
/* Chống chớp giật màn hình khi F5 vào thẳng Sổ Vàng */
html.hide-main-ui body > header,
html.hide-main-ui body > .container {
    display: none !important;
}

/* THÊM MỚI: Ép trang Sổ Vàng hiện ra ngay lập tức lấp vào chỗ trống */
html.hide-main-ui #tichChiPage {
    display: block !important;
}


.hide-main-ui header,
.hide-main-ui .container {
  display: none !important;
}

html:not(.hide-main-ui) header { display: flex; }
html:not(.hide-main-ui) .container { display: block; }