/* style.css — redesign-preserve: da theo nhận diện dulieucangbien.com (brand
   family "Dữ liệu ...", teal/gold trên nền tối), GIỮ nguyên cấu trúc/logic
   viewer (sidebar tab + bảng sort/filter/phân trang). Site tĩnh thuần —
   1 Google Fonts (Be Vietnam Pro), không CDN icon. Page Theme Lock: dark duy
   nhất, không toggle. */

:root {
  --bg: #07101e;
  --surface: #0d1a2c;
  --surface-2: #13243a;
  --surface-3: #1a3050;
  --border: #1e3251;
  --border-soft: #162844;
  --text: #e7eefc;
  --text-2: #9fb2cf;
  --text-3: #647da0;
  --accent: #34d3c2;
  --accent-2: #1aa596;
  --accent-deep: #0d6f66;
  --gold: #f5b942;
  --gold-deep: #caa137;
  --up: #34d399;
  --down: #fb7185;
  --grad-accent: linear-gradient(135deg, #34d3c2 0%, #1aa596 60%, #0d6f66 100%);
  --grad-hero: radial-gradient(1100px 480px at 6% -10%, rgba(52, 211, 194, 0.12), transparent 58%);
  --glow: 0 0 24px rgba(52, 211, 194, 0.28);
  --glow-gold: 0 0 22px rgba(245, 185, 66, 0.30);
  --shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
  --gutter: 22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg);
  background-image: var(--grad-hero);
  background-repeat: no-repeat;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* Mono font cho số KPI / bảng — JetBrains Mono weights 500, 700 */
.mono {
  font-family: "JetBrains Mono", "Be Vietnam Pro", monospace;
}

/* ===== Topbar — brand block theo dulieucangbien.com ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  border-bottom: 1px solid var(--border-soft);
}
.tb {
  display: flex;
  align-items: center;
  height: 66px;
  padding: 0 var(--gutter);
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand svg { width: 38px; height: 38px; filter: drop-shadow(var(--glow)); flex-shrink: 0; }
.bn { font-weight: 800; font-size: 18px; letter-spacing: -0.4px; line-height: 1.05; margin: 0; }
.bn .a { background: var(--grad-accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bt { font-size: 10.5px; color: var(--text-3); font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; margin-top: 2px; }

/* ===== Badge tên gói — pill nhỏ cạnh brand, KHÔNG chói (màu --text-2, border teal soft) ===== */
.pkg-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  white-space: nowrap;
}

/* Nav topbar — link pill style */
.tb-nav {
  display: flex;
  gap: 12px;
  margin-left: auto;
  align-items: center;
}
.tb-nav a {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  transition: 0.15s;
  white-space: nowrap;
}
.tb-nav a:hover {
  color: var(--accent);
  border-color: var(--accent-2);
}
.tb-nav a.active { color: var(--accent); border-color: var(--accent-2); }
.tb-nav a.tb-nav-pill {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  border-color: var(--accent-2);
  color: var(--accent);
  font-weight: 700;
  gap: 6px;
}
.tb-nav a.tb-nav-pill:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-2));
  border-color: var(--accent);
}

/* Auth box — login button + account dropdown */
.auth-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Login button (đăng nhập) */
.auth-box button, .auth-box a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.auth-box button:hover, .auth-box a:hover {
  color: var(--accent);
  border-color: var(--accent-2);
}

/* Acct chip (sau đăng nhập) — avatar + email + dropdown */
.acct-wrap {
  position: relative;
  display: inline-flex;
}

.acct-chip {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  transition: 0.15s;
}

.acct-chip:hover {
  border-color: var(--accent-2);
  background: var(--surface-3);
}

.acct-chip .car {
  font-size: 8.5px;
  opacity: 0.65;
  margin-left: 5px;
  display: inline-block;
  transition: transform 0.2s;
}

.acct-wrap.open .acct-chip .car {
  transform: rotate(180deg);
}

.acct-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 215px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  z-index: 90;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  display: none;
}

.acct-wrap.open .acct-menu {
  display: block;
}

.acct-menu .it {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  font-family: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.acct-menu .it:hover {
  background: var(--surface-3);
}

.acct-menu .meta {
  font-size: 11.5px;
  color: var(--text-3);
  padding: 4px 10px 8px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 6px;
  white-space: nowrap;
}

.acct-menu .out {
  color: #ff9d9d;
}

/* Login modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.mbox {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.mbox h3 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.mbox p {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}

.mbox .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s;
  font-family: inherit;
  white-space: nowrap;
  gap: 10px;
  margin-bottom: 10px;
}

.mbox .btn:hover {
  background: var(--accent);
  color: #04231f;
  border-color: var(--accent);
}

.mbox .row {
  display: flex;
  gap: 10px;
}

.mbox .row .btn {
  flex: 1;
}

.mbox .note {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
  margin-top: 12px;
}

.meta-bar { background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.meta {
  padding: 8px var(--gutter);
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.meta strong { color: var(--text-2); font-weight: 700; }

.layout { display: flex; min-height: calc(100vh - 140px); }

/* ===== Sidebar ===== */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  padding: 14px 0;
  display: flex;
  flex-direction: column;
}
.nav-item {
  text-align: left;
  border: none;
  background: none;
  font-family: inherit;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: 0.15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--surface-2);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 700;
}

main { flex: 1; padding: var(--gutter); min-width: 0; }

/* ===== Stat cards (Tổng quan) — theo .spc gốc ===== */
.stat-cards { display: flex; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 14px 18px;
  min-width: 220px;
  flex: 1;
}
.stat-label { font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.stat-value.up { color: var(--up); }
.stat-value.down { color: var(--down); }
.stat-sub { margin-top: 6px; font-size: 12px; }

/* ===== Định nghĩa mart ===== */
.definition-box {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 13px;
}
.definition-box summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.definition-box p { margin: 8px 0 0; color: var(--text-2); line-height: 1.6; }

/* ===== Filter bar ===== */
.filter-bar { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filter-sub { display: contents; }
.filter-field {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  gap: 5px;
}
.filter-field select,
.filter-field input {
  font: 13px "Be Vietnam Pro", system-ui, sans-serif;
  text-transform: none;
  letter-spacing: normal;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  min-width: 150px;
}
.filter-field select:focus,
.filter-field input:focus { outline: none; border-color: var(--accent); }
.filter-field input::placeholder { color: var(--text-3); }

.row-count { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }

/* ===== Bảng — theo chuẩn .tbl brand ===== */
.table-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
}
table.data-table { border-collapse: collapse; width: 100%; font-size: 13.5px; white-space: nowrap; }
table.data-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-3);
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
table.data-table th:hover { color: var(--accent); background: var(--surface-3); }
.sort-ind { color: var(--accent); }
table.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); }
table.data-table tbody tr:hover td { background: var(--surface-2); }

td.col-usd, td.col-qty, td.col-percent, td.col-int,
th.col-usd, th.col-qty, th.col-percent, th.col-int {
  text-align: right;
}

.empty-row, .hint, .error-box { padding: 24px; text-align: center; color: var(--text-3); }
.error-box { color: var(--down); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-so_bo { background: color-mix(in srgb, var(--gold) 14%, var(--surface-2)); color: var(--gold); border-color: var(--gold-deep); }
.badge-dieu_chinh { background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); color: var(--accent); border-color: var(--accent-2); }
.badge-chinh_thuc { background: color-mix(in srgb, var(--up) 16%, var(--surface-2)); color: var(--up); border-color: var(--up); }
.badge-state-open { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.badge-state-settled { background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); color: var(--accent); border-color: var(--accent-2); }
.badge-state-frozen { background: var(--surface-2); color: var(--text-3); border-color: var(--border); }
.badge-state-error { background: color-mix(in srgb, var(--down) 16%, var(--surface-2)); color: var(--down); border-color: var(--down); }

/* ===== Pager ===== */
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 12px; font-size: 12px; }
.pager-btn {
  font: inherit;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: 0.15s;
}
.pager-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.pager-btn:disabled { opacity: 0.4; cursor: default; }
.pager-status { color: var(--text-3); }

footer.sitefoot {
  padding: 16px var(--gutter);
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--border-soft);
}
footer.sitefoot code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-2);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .meta { gap: 10px; }
}

/* ===== Topbar 2-row (≤860px) — logo + login hàng 1, nav pills hàng 2 trượt ngang =====
   Khi màn hẹp: nav "tan" vào .tb (display:contents), pills xuống hàng 2 full-width.
   Touch-target ≥44px theo Apple HIG. */
@media(max-width:860px){
  .tb{flex-wrap:wrap;height:auto;padding:10px 0;row-gap:9px;align-items:stretch}
  .brand{order:1}
  .auth-box{order:2;margin-left:auto;align-self:center;flex-shrink:0}
  .tb-nav{display:flex;order:3;width:100%;min-width:0;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding-bottom:2px;gap:0;margin-left:0;margin-right:0}
  .tb-nav a{padding:12px 15px;font-size:13px;flex-shrink:0;white-space:nowrap}
  .tb-nav::-webkit-scrollbar{display:none}
}

/* ===== Topbar mobile — chống wrap xấu (bug 375px, brand/nav vỡ dòng chồng lên nhau) =====
   Fix: .bt ẩn (đỡ rối dọc) + brand giữ 1 dòng (flex-shrink:0, nowrap) +
   .tb-nav co thành hàng cuộn ngang thay vì wrap. */
@media (max-width: 768px) {
  .bt { display: none; }
  .tb { flex-wrap: nowrap; gap: 10px; }
  .brand { flex-shrink: 0; min-width: 0; }
  .bn { font-size: 15px; white-space: nowrap; }
}

a{color:inherit;text-decoration:none}

/* ===== Tier label — bản xem trước, chưa khoá (nhãn thuần, không gate thật) =====
   .tag-paid bê nguyên từ longlivestock/web/vip.css:77. .tier-note là mới,
   dòng nhỏ dưới heading giải thích trạng thái "bản xem trước". */
.tag-paid { font-size: 10.5px; font-weight: 700; color: var(--gold); border: 1px solid var(--gold-deep); border-radius: 999px; padding: 2px 9px; margin-left: 8px; vertical-align: middle; white-space: nowrap; }
.tier-note { font-size: 11.5px; color: var(--text-3); font-style: italic; margin: 2px 0 10px; }
