
:root {
  --bg:        #f8fafc;
  --surface:   #ffffff;
  --surface2:  #f1f5f9;
  --border:    #e2e8f0;
  --border2:   #cbd5e1;
  --text:      #0f172a;
  --muted:     #64748b;
  --accent:    #1a6b3c;
  --accent-bg: #edf6f1;
  --accent2:   #0f4a2a;
  --warn:      #b45309;
  --warn-bg:   #fef3e2;
  --err:       #b91c1c;
  --err-bg:    #fef2f2;
  --blue:      #1d4ed8;
  --blue-bg:   #eff6ff;
  --orange:    #f97316;
  --purple:    #7c3aed;
  --purple-bg: #f5f3ff;
  --sans:      'Be Vietnam Pro', sans-serif;
  --mono:      'IBM Plex Mono', monospace;
  --num:       'Inter', 'Be Vietnam Pro', sans-serif;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);

  /* ── Thang token gộp lại (trước đây rải rác ~12 giá trị radius, ~13 kiểu shadow riêng lẻ) ── */
  --radius-xs:   4px;   /* chip nhỏ, icon-button, control sát */
  --radius-sm:   6px;   /* nút, card nhỏ, dropdown */
  --radius-lg:   12px;  /* modal, panel lớn */
  --radius-full: 999px; /* pill, badge tròn, thanh progress */
  --shadow-xs:     0 1px 4px rgba(0,0,0,0.10);   /* thanh sticky, tab active */
  --shadow-float:  0 4px 20px rgba(0,0,0,0.14);  /* toast, phần tử nổi */
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.18);  /* popup nhỏ, preset modal */
  --shadow-xl:     0 20px 60px rgba(0,0,0,0.22); /* modal lớn giữa màn hình */
  --shadow-drawer: -6px 0 28px rgba(0,0,0,0.14); /* drawer trượt từ phải */
  --shadow-accent: 0 2px 4px rgba(26,107,60,0.2); /* shadow cho nút CTA màu accent */

  /* Overlay nền mờ — gộp về token để sau này Dark Mode chỉ cần đổi 2 dòng này */
  --overlay-dim:     rgba(15,15,15,0.45); /* nền tối mờ dùng chung cho mọi modal/drawer/dialog */
  --overlay-loading: rgba(248,250,252,0.6); /* nền sáng mờ riêng cho loading overlay (khớp slate-50 mới) */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; min-height: 100vh; }

/* ── Icon system: sprite SVG dùng chung thay cho emoji rải rác ── */
.ic {
  width: 1em; height: 1em; display: inline-block; flex-shrink: 0;
  vertical-align: -0.15em;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.ic-fill { fill: currentColor; stroke: none; }


/* ── TOP PANEL (luôn hiển thị, không collapse) ── */
#mothauTopPanel { display: block; }

/* ── ADVANCED FILTER DRAWER ── */
#advDrawerOverlay {
  display: none;
  position: fixed; inset: 0; z-index: 500;
  background: var(--overlay-dim);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
#advDrawerOverlay.open { display: block; }

#advDrawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 501;
  width: min(420px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--border2);
  box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
  will-change: transform;
}
#advDrawerOverlay.open #advDrawer { transform: translateX(0); }

.adv-drawer-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.adv-drawer-title {
  font-size: 13px; font-weight: 700; color: var(--text); flex: 1;
}
.adv-drawer-badge {
  display: none;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; font-family: var(--num); font-variant-numeric: tabular-nums;
  padding: 2px 7px; border-radius: var(--radius-lg);
}
.adv-drawer-badge.show { display: inline-block; }
.adv-drawer-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1;
  padding: 4px 6px; border-radius: var(--radius-xs); transition: all 0.12s;
}
.adv-drawer-close:hover { background: var(--surface2); color: var(--text); }

.adv-drawer-body {
  flex: 1; overflow-y: auto; padding: 14px 16px 24px;
  display: flex; flex-direction: column; gap: 10px;
}
.adv-drawer-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted); font-family: var(--sans);
  margin-bottom: 6px; margin-top: 4px;
}
.adv-drawer-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-shrink: 0;
}

/* nút mở drawer có badge đếm filter nâng cao đang bật */
#btnAdvancedFilter { position: relative; }
#btnAdvancedFilter .adv-count {
  display: none;
  position: absolute; top: -6px; right: -6px;
  background: var(--accent); color: #fff;
  font-size: 9px; font-weight: 700; font-family: var(--num); font-variant-numeric: tabular-nums;
  width: 16px; height: 16px; border-radius: 50%;
  align-items: center; justify-content: center;
}
#btnAdvancedFilter .adv-count.show { display: flex; }

/* ══════════════════════════════════════════════════════
   HỒ SƠ CHỦ ĐẦU TƯ — popup nhỏ
   ══════════════════════════════════════════════════════ */
#invPopup {
  position: fixed; z-index: 3000;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 340px; max-height: 480px; overflow-y: auto;
  display: none; flex-direction: column;
  animation: invPopIn 0.15s ease;
}
#invPopup.show { display: flex; }
@keyframes invPopIn { from { opacity:0; transform: translateY(6px) scale(0.97); } }
#invPopup .inv-hdr {
  padding: 12px 14px 10px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 10px; flex-shrink: 0;
}
#invPopup .inv-hdr-icon {
  width: 32px; height: 32px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--accent-bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
#invPopup .inv-hdr-name {
  flex: 1; min-width: 0; font-size: 12px; font-weight: 700;
  color: var(--text); line-height: 1.35; word-break: break-word;
}
#invPopup .inv-hdr-close {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 14px; padding: 2px 4px; border-radius: var(--radius-xs); flex-shrink: 0;
  transition: all 0.1s;
}
#invPopup .inv-hdr-close:hover { background: var(--surface2); color: var(--text); }
#invPopup .inv-kpi-row {
  display: flex; gap: 0; flex-shrink: 0; border-bottom: 1px solid var(--border);
}
#invPopup .inv-kpi {
  flex: 1; padding: 9px 10px; text-align: center;
  border-right: 1px solid var(--border);
}
#invPopup .inv-kpi:last-child { border-right: none; }
#invPopup .inv-kpi-val { font-size: 15px; font-weight: 700; font-family: var(--num); color: var(--text); font-variant-numeric: tabular-nums lining-nums; }
#invPopup .inv-kpi-lbl { font-size: 9px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); font-family: var(--sans); margin-top: 2px; }
#invPopup .inv-section { padding: 10px 14px; border-bottom: 1px solid var(--border); }
#invPopup .inv-section:last-child { border-bottom: none; }
#invPopup .inv-section-title { font-size: 9px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); font-family: var(--sans); margin-bottom: 7px; }
#invPopup .inv-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 11px; }
#invPopup .inv-row:last-child { margin-bottom: 0; }
#invPopup .inv-row-num { font-family: var(--num); font-variant-numeric: tabular-nums lining-nums; font-weight: 700; min-width: 28px; text-align: right; flex-shrink: 0; }
#invPopup .inv-row-bar { flex: 1; height: 4px; background: var(--border); border-radius: var(--radius-xs); overflow: hidden; }
#invPopup .inv-row-bar-fill { height: 100%; border-radius: var(--radius-xs); background: var(--accent); }

/* Nút Briefing trong fpModal */
.fp-briefing-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1.5px solid var(--border2); background: var(--surface2);
  font-size: 11px; font-weight: 600; color: var(--text); font-family: var(--sans);
  transition: all 0.12s; white-space: nowrap;
}
.fp-briefing-btn:hover { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }

/* ══════════════════════════════════════════════════════
   TOAST NOTIFICATION SYSTEM
   ══════════════════════════════════════════════════════ */
#toast-container {
  position: fixed; top: 14px; right: 14px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 260px; max-width: 380px;
  padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  font-size: 13px; line-height: 1.45;
  pointer-events: auto;
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.34,1.26,0.64,1), opacity 0.2s ease;
  cursor: pointer;
}
.toast.show {
  transform: translateX(0);
  opacity: 1;
}
.toast.hide {
  transform: translateX(calc(100% + 20px));
  opacity: 0;
}
.toast-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.toast-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.toast-warn    { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.toast-info    { background: var(--blue-bg); border: 1px solid #93c5fd; color: #1e3a8a; }
.toast-icon    { font-size: 15px; flex-shrink: 0; line-height: 1.3; }
.toast-msg     { flex: 1; }

/* ── YCBG visited rows ── */
#yc_mainTbody tr.yc-visited > td { opacity: 0.55; }
#yc_mainTbody tr.yc-visited:hover > td { opacity: 0.8; }
a.yc-link-btn { transition: all .15s; }
a.yc-link-btn.yc-link-seen {
  color: var(--muted); border-color: var(--border2);
  background: var(--surface2);
}

/* ══════════════════════════════════════════════════════
   WATCHLIST
   ══════════════════════════════════════════════════════ */
/* Nút sao trong fpModal header */
.btn-watchlist {
  background: none; border: 1.5px solid var(--border2); cursor: pointer;
  border-radius: var(--radius-sm); padding: 4px 8px; font-size: 16px; line-height: 1;
  transition: all 0.15s; color: var(--muted); flex-shrink: 0;
}
.btn-watchlist:hover { background: var(--warn-bg); border-color: var(--warn); }
.btn-watchlist.wl-active { color: #f59e0b; border-color: #f59e0b; background: #fffbeb; }
/* Icon sao nhỏ trong cell hoạt chất */
.wl-star {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; line-height: 1; margin-left: 3px;
  vertical-align: middle; opacity: 0.85; cursor: default;
}
/* Row highlight khi có alert mới */
tbody tr.row-wl-alert > td {
  background: #fffbeb !important;
  box-shadow: inset 3px 0 0 #f59e0b;
}

/* Nút "Quản lý Watchlist" trong header */
#btnOpenWatchlist {
  display: none; height: 32px;
  align-items: center; gap: 4px;
  padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid #f59e0b;
  background: #fffbeb; color: #92400e;
  font-family: var(--sans); font-size: 12px; cursor: pointer;
  font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s;
}
#btnOpenWatchlist:hover { background: #fef3c7; }

#btnPriceDiscrepancy, #btnUtilMenu, #btnFeedback {
  display: inline-flex; height: 32px;
  align-items: center; gap: 4px;
  padding: 0 12px; border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  margin-left: 6px;
}
#btnFeedback { border-color: transparent; }
#btnFeedback:hover { border-color: var(--border2); }

#btnOpenWatchlist .wl-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: #f59e0b; color: #fff;
  font-size: 9px; font-weight: 700; font-family: var(--num); font-variant-numeric: tabular-nums;
  min-width: 16px; height: 16px; border-radius: var(--radius); padding: 0 4px;
  line-height: 1;
}

/* Nút filter watchlist trong toolbar — inherit từ .btn .btn-outline .btn-sm */
#btnFilterWatchlist {
  white-space: nowrap;
}
#btnFilterWatchlist:hover { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
#btnFilterWatchlist.active {
  background: #fffbeb; border-color: #f59e0b; color: #92400e; font-weight: 700;
  box-shadow: 0 0 0 2px #fde68a;
}
#btnFilterWatchlist:disabled {
  opacity: 0.4; cursor: not-allowed; pointer-events: none;
  border-color: var(--border); color: var(--muted);
}

/* ══════════════════════════════════════════════════════
   WATCHLIST MODAL
   ══════════════════════════════════════════════════════ */
#watchlistModalOverlay {
  display: none; position: fixed; inset: 0; z-index: 2100;
  background: var(--overlay-dim); backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 16px;
}
#watchlistModalOverlay.show { display: flex; }

#watchlistModal {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  width: min(96vw, 560px); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: fpSlideIn 0.2s ease;
}
.wlm-header {
  padding: 15px 18px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.wlm-header-icon {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #f59e0b33;
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}
.wlm-title { font-size: 14px; font-weight: 700; color: var(--text); flex: 1; }
.wlm-sub   { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.wlm-close {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 4px; border-radius: var(--radius-xs);
  transition: all 0.1s; flex-shrink: 0;
}
.wlm-close:hover { background: var(--surface2); color: var(--text); }

.wlm-body { flex: 1; overflow-y: auto; }

.wlm-empty {
  padding: 40px 24px; text-align: center;
  color: var(--muted); font-size: 13px; line-height: 1.6;
}
.wlm-empty-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.4; }

/* Danh sách items */
.wlm-list { list-style: none; margin: 0; padding: 0; }
.wlm-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.wlm-item:last-child { border-bottom: none; }
.wlm-item:hover { background: var(--surface2); }

.wlm-drug-info { flex: 1; min-width: 0; }
.wlm-drug-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px; text-transform: capitalize;
}
.wlm-drug-meta {
  display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-top: 3px;
}
.wlm-badge {
  display: inline-block; padding: 1px 6px; border-radius: var(--radius);
  font-size: 9px; font-weight: 700; font-family: var(--num); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wlm-fp-str {
  font-family: var(--mono); font-size: 9px; color: var(--muted);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 1px 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.wlm-added-at { font-size: 9px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }

.wlm-actions { display: flex; gap: 5px; flex-shrink: 0; align-items: flex-start; padding-top: 1px; }
.wlm-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 4px 8px; border-radius: var(--radius-xs); border: 1px solid var(--border2);
  background: transparent; font-family: var(--sans); font-size: 10px;
  cursor: pointer; white-space: nowrap; transition: all 0.12s; color: var(--text);
}
.wlm-btn:hover { background: var(--surface2); }
.wlm-btn.danger { color: var(--err); border-color: var(--err); }
.wlm-btn.danger:hover { background: var(--err-bg); }
.wlm-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.wlm-footer {
  padding: 10px 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  font-size: 11px; color: var(--muted); font-family: var(--sans);
}
.wlm-footer-hint { flex: 1; }
.wlm-clear-all {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-xs); border: 1px solid var(--err);
  background: transparent; color: var(--err); font-family: var(--sans);
  font-size: 10px; font-weight: 500; cursor: pointer; transition: all 0.12s;
}
.wlm-clear-all:hover { background: var(--err-bg); }

/* ══════════════════════════════════════════════════════
   LOADING OVERLAY
   ══════════════════════════════════════════════════════ */
#loadingOverlay {
  display: none;
  position: fixed; inset: 0; z-index: 8000;
  background: var(--overlay-loading);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  align-items: center; justify-content: center;
  flex-direction: column; gap: 14px;
}
#loadingOverlay.active { display: flex; }
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-label {
  font-size: 12px; color: var(--muted);
  font-family: var(--sans); letter-spacing: 0.3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════
   DUAL FLOW — Flow A (ngày) + Flow C (mã TBMT) side-by-side
   ══════════════════════════════════════════════════════ */
.dual-flow-wrap {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.flow-block {
  padding: 12px 16px 24px;
  transition: opacity 0.25s ease, filter 0.25s ease;
}
.flow-block.dimmed {
  opacity: 0.5;
  filter: grayscale(80%);
  /* Không pointer-events: none — user vẫn click được */
}
.flow-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 0;
  width: 36px;
}
.flow-divider::before,
.flow-divider::after {
  content: '';
  flex: 1;
  width: 1px;
  background: var(--border);
}
.flow-divider-text {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-family: var(--sans);
  text-transform: uppercase;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
}
.flow-block-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  font-family: var(--sans);
}

/* ── FLOW C: tra cứu nhanh theo mã (trước đây toàn bộ style inline) ── */
#flowBlockCode { display: flex; flex-direction: column; }
.flow-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.flow-header-row .flow-block-label { margin-bottom: 0; }
.flowc-hint { font-size: 10px; color: var(--muted); font-family: var(--sans); }
.flowc-input-area { position: relative; flex: 1; display: flex; flex-direction: column; }
.flowc-input-row { display: flex; gap: 8px; align-items: stretch; flex: 1; }
.flowc-textarea {
  flex: 1; min-width: 0; height: 100%; min-height: 60px; resize: none;
  font-family: var(--mono); font-size: 11px; padding: 10px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); outline: none;
  box-sizing: border-box; line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.flowc-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.flowc-btn-col { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; justify-content: flex-start; }
.flowc-btn-search { min-width: 100px; justify-content: center; box-shadow: var(--shadow-accent); white-space: nowrap; }
.flowc-btn-clear { justify-content: center; color: var(--err); border-color: transparent; background: var(--err-bg); white-space: nowrap; }
.flowc-status-wrap { min-height: 18px; margin-top: 6px; }
.flowc-status-text { display: inline-block; line-height: 1.4; word-break: break-word; }

/* Responsive: stack vertically on small screens */
@media (max-width: 640px) {
  .dual-flow-wrap { grid-template-columns: 1fr; }
  .flow-divider {
    flex-direction: row; width: auto; height: 28px; padding: 0 12px;
  }
  .flow-divider::before, .flow-divider::after {
    width: auto; height: 1px; flex: 1;
  }
  .flow-divider-text { writing-mode: horizontal-tb; transform: none; }
}

/* ── HEADER ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
  height: 50px; position: relative; /*sticky; top: 0; z-index: 100;*/
}
.logo-mark {
  width: 28px; height: 28px; background: var(--accent); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700; font-family: var(--num); flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.logo-text { font-size: 13px; font-weight: 600; }
.logo-sub  { font-size: 10px; color: var(--muted); font-family: var(--mono); }
.header-sep { width: 1px; height: 20px; background: var(--border); }
.header-title { font-size: 12px; color: var(--muted); }
.header-spacer { flex: 1; }

@media (max-width: 768px) {
  .header { gap: 6px; padding: 0 8px; }
  .header .logo-text, .header .logo-sub, .header-sep,
  .header .btn-label, #userLabel { display: none; }
  .header-title { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
  #btnLogout, #btnUtilMenu, #btnOpenWatchlist, #btnPriceDiscrepancy, #btnFeedback {
    padding: 0; width: 44px; height: 44px; min-width: 44px; min-height: 44px;
    justify-content: center; flex-shrink: 0; font-size: 16px; gap: 2px;
  }
  #btnOpenWatchlist .ic, #btnLogout .ic, #btnUtilMenu .ic, #btnFeedback .ic { width: 1em; height: 1em; }
  #btnInstall .btn-label { display: inline; } /* Cài App vẫn hiện text vì ít khi cùng lúc với các nút khác */
}

/* ── LAYOUT ── */
:root { --main-max-width: 1920px; }
.main { max-width: var(--main-max-width); margin: 0 auto; padding: 14px 14px; }

/* ── FOOTER ── */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 24px;
}
.app-footer-inner {
  max-width: var(--main-max-width); margin: 0 auto;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: center;
}
.app-footer-copy { font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* ── TOOLBAR ── */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; flex-wrap: wrap;
}

/* ── FILTER ── */
.fg { display: flex; flex-direction: column; gap: 3px; min-width: 120px; flex: 1; }
.fg label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted); font-family: var(--sans);
}
.fg input, .fg select {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 8px; font-family: var(--sans);
  font-size: 12px; color: var(--text); outline: none;
  transition: border-color 0.15s; width: 100%;
}
.fg input:focus, .fg select:focus { border-color: var(--accent); background: #fff; }
.fg input::placeholder { color: var(--border2); }
.fg.date { min-width: 150px; flex: 0 0 150px; }
.fg.short { min-width: 80px; flex: 0 0 80px; }

/* ── FILTER CARD (grid layout) ── */
.filter-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}
.filter-row:last-child { margin-bottom: 0; }
.filter-row > .btn,
.filter-row > .fg[style*="flex:0"] {
  grid-column: auto;
}
.fg.date { min-width: unset; flex: unset; }
.fg.short { min-width: unset; flex: unset; }

.filter-card.toolbar-card .filter-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end;
  grid-template-columns: unset;
}
.filter-card.toolbar-card .fg.date { flex: 0 0 150px; min-width: 140px; }

@media (max-width: 600px) {
  .filter-card { padding: 10px 12px; }
  .filter-row { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .fg.date { min-width: unset; }
  .filter-row > .btn.btn-outline.btn-sm:last-child {
    grid-column: 1 / -1; justify-self: start;
  }
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: var(--radius-sm); font-family: var(--sans);
  font-size: 12px; font-weight: 500; cursor: pointer; border: none;
  transition: all 0.15s; white-space: nowrap; flex-shrink: 0;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-primary:disabled { background: var(--border2); cursor: not-allowed; }
.btn-outline { background: transparent; border: 1px solid var(--border2); color: var(--text); }
.btn-outline:hover { background: var(--surface2); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon { width: 30px; height: 30px; padding: 0; justify-content: center; }

.status-text { font-family: var(--sans); font-size: 11px; color: var(--muted); }
.status-text.ok  { color: var(--accent); }
.status-text.err { color: var(--err); }
.status-text.warn { color: var(--warn); }

/* ── STATS ── */
.stats-bar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 8px; flex-wrap: wrap;
  font-family: var(--sans); font-size: 11px; color: var(--muted);
}
.stats-bar strong { color: var(--text); font-weight: 600; }

/* ── ACTION BAR (fetch toolbar row 2) ── */
.action-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 14px 8px;
  font-family: var(--sans); font-size: 11px;
}
.action-bar-cache {
  color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 6px;
}
.action-bar-cache .cache-dot { flex-shrink: 0; }
.action-bar-btns { display: flex; gap: 6px; margin-left: auto; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* ── DROPDOWN MENU (⋮) ── */
.dropdown-wrap { position: relative; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  min-width: 180px; z-index: 999; padding: 4px 0;
  font-family: var(--font); font-size: 12px;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 14px; background: none; border: none;
  cursor: pointer; color: var(--text); white-space: nowrap;
  transition: background 0.1s;
}
.dropdown-item:hover { background: var(--surface2); }
.dropdown-item.danger { color: var(--err); }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ── CACHE STATUS BAR ── */
.cache-bar {
  display: none !important;
}
.cache-bar-top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.cache-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.cache-dot.ok     { background: var(--accent); }
.cache-dot.miss   { background: var(--border2); }
.cache-dot.loading{ background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.cache-ranges { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.cache-month-group { display: flex; flex-direction: column; gap: 3px; }
.cache-month-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted);
}
.cache-month-body { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.cache-range-badge {
  padding: 2px 8px; border-radius: var(--radius-lg); font-size: 10px;
  background: var(--accent-bg); color: var(--accent);
  cursor: pointer; border: 1px solid transparent; transition: border-color 0.1s;
}
.cache-range-badge:hover { border-color: var(--accent); }
.cache-gap-badge {
  padding: 2px 7px; border-radius: var(--radius-lg); font-size: 10px;
  background: var(--err-bg); color: var(--err); cursor: default;
}
.cache-day-badge { padding: 1px 6px; border-radius: var(--radius-lg); font-size: 10px; }
.cache-day-badge.loading { background: var(--warn-bg); color: var(--warn); }

/* ── TABLE WRAP ── */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.table-scroll {
  overflow: auto; -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 260px); border-radius: var(--radius);
}

table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }

thead th {
  background: var(--surface2); padding: 8px 10px;
  text-align: left; font-size: 9px; font-weight: 700;
  letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--muted); font-family: var(--sans);
  border-bottom: 2px solid var(--border2);
  border-right: 1px solid var(--border2);
  white-space: nowrap; cursor: pointer; user-select: none;
  position: sticky; top: 0; z-index: 10; overflow: visible;
}
thead th:last-child { border-right: none; }
thead th:hover { color: var(--text); }
thead th.sort-asc::after  { content: ' ▲'; color: var(--accent); font-size: 8px; }
thead th.sort-desc::after { content: ' ▼'; color: var(--accent); font-size: 8px; }
thead th.no-sort { cursor: default; }

.th-wrap { position: relative; display: block; }
.col-resizer {
  position: absolute; right: -8px; top: -8px; bottom: -8px;
  width: 12px; cursor: col-resize; z-index: 1; background: transparent;
}
.col-resizer:hover, .col-resizer.resizing {
  background: var(--accent); opacity: 0.35; border-radius: var(--radius-xs);
}

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

tbody tr.sub-row td { border-bottom: 1px solid rgba(0,0,0,0.03); }
tbody tr.sub-row:last-of-type td { border-bottom: 1px solid var(--border); }
tbody tr.sub-row td.fill { background: transparent; }

/* ── GROUP BORDER: master row (đầu nhóm) — chỉ áp dụng cho #mainTable ── */
#mainTable tbody tr.group-master > td:first-child {
  border-left: 3px solid #7c3aed;
}
#mainTable tbody tr.group-master > td {
  background: transparent;
}
#mainTable tbody tr.group-master:hover > td {
  background: var(--surface2);
}

/* ── GROUP BORDER: sub-rows (cùng nhóm) ── */
#mainTable tbody tr.group-sub > td:first-child {
  border-left: 3px solid #c4b5fd;
}
#mainTable tbody tr.group-sub > td {
  background: transparent;
}
#mainTable tbody tr.group-sub:hover > td {
  background: var(--surface2);
}

/* td đầu tiên của group-master / group-sub không bị border-right che border-left */
#mainTable tbody tr.group-master > td:first-child,
#mainTable tbody tr.group-sub > td:first-child {
  border-right: 1px solid var(--border);
}

td { padding: 7px 10px; vertical-align: top; border-right: 1px solid var(--border); overflow: hidden; }
.fp-table td { overflow: visible; }
td:last-child { border-right: none; }
td.mono { font-family: var(--num); font-size: 11px; font-variant-numeric: tabular-nums lining-nums; }
td.center { text-align: center; }
td.nowrap { white-space: nowrap; }


}

.cell-goi-thau { max-width: 160px; }
.cell-goi-thau .tbmt-no { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.cell-goi-thau .bv-name { font-size: 12px; font-weight: 500; line-height: 1.3; }

.cell-hc { font-weight: 600; font-size: 12px; }
.cell-hc .hc-detail { font-size: 11px; font-weight: 400; color: var(--muted); }

.cell-nongdo  { min-width: 180px; max-width: 320px; white-space: normal; word-break: break-word; font-family: var(--mono); font-size: 11px; }
.cell-duongdung { max-width: 160px; white-space: normal; word-break: break-word; font-size: 11px; }

.cell-qty { text-align: right; }
.cell-qty .qty-num { font-family: var(--num); font-size: 12px; font-weight: 600; display: block; font-variant-numeric: tabular-nums lining-nums; }
.cell-qty .qty-uom { font-family: var(--sans); font-size: 10px; color: var(--muted); display: block; }

.mo-thau-cell { min-width: 240px; }
.bidder-line {
  display: flex; align-items: baseline; gap: 6px;
  padding: 1px 0; font-size: 11px; line-height: 1.5;
}
.bidder-line.winner { color: var(--accent); font-weight: 600; }
.bidder-line .b-rank { font-family: var(--mono); font-size: 10px; color: var(--muted); width: 14px; flex-shrink: 0; }
.bidder-line.winner .b-rank { color: var(--accent); }
.bidder-line .b-name { flex: 1; min-width: 0; }
.bidder-line .b-price { font-family: var(--num); font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--accent); flex-shrink: 0; font-variant-numeric: tabular-nums lining-nums; }
.bidder-line:not(.winner) .b-price { color: var(--text); font-weight: 400; }
.no-bidder { font-size: 11px; color: var(--muted); font-style: italic; }
.btn-refetch-open {
  display: inline-flex; align-items: center; gap: 3px;
  margin-top: 4px; padding: 2px 7px; border-radius: var(--radius-xs);
  font-size: 10px; font-family: var(--sans); font-weight: 500;
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--muted); cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.btn-refetch-open:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.btn-refetch-open:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-refetch-open.loading { color: var(--warn); border-color: var(--warn); }
.btn-refetch-open.done    { color: var(--accent); border-color: var(--accent); }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: var(--radius-full);
  font-size: 10px; font-weight: 600; font-family: var(--sans); white-space: nowrap;
}
.badge-green  { background: var(--accent-bg); color: var(--accent); }
.badge-orange { background: var(--warn-bg);   color: var(--warn); }
.badge-red    { background: var(--err-bg);    color: var(--err); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-gray   { background: var(--surface2);  color: var(--muted); }

.spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid var(--border); border-top-color: currentColor;
  border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .icon { font-size: 32px; margin-bottom: 8px; opacity: 0.4; }
.empty-state p { font-size: 13px; }
.empty-state .btn-clear-filter {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: var(--sans);
  font-size: 12px; font-weight: 500; cursor: pointer; transition: border-color .15s, background .15s;
}
.empty-state .btn-clear-filter:hover { border-color: var(--accent); background: var(--surface2); }

/* ── Skeleton loader ── */
.skeleton-row td { padding: 10px 12px !important; }
.skeleton-bar {
  height: 12px; border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--border) 25%, var(--surface2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk-w-40  { width: 40%; }
.sk-w-60  { width: 60%; }
.sk-w-80  { width: 80%; }
.sk-w-100 { width: 100%; }
.sk-w-30  { width: 30%; }
.sk-w-50  { width: 50%; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-top: 1px solid var(--border);
  background: var(--surface2); font-size: 11px; flex-wrap: wrap; gap: 6px;
}
.pg-info { color: var(--muted); font-family: var(--num); font-variant-numeric: tabular-nums lining-nums; }
.pg-btns { display: flex; gap: 3px; }
.pg-btn {
  padding: 3px 8px; border: 1px solid var(--border2); border-radius: var(--radius-xs);
  background: var(--surface); cursor: pointer; font-size: 11px;
  font-family: var(--num); color: var(--text); transition: all 0.1s; font-variant-numeric: tabular-nums;
}
.pg-btn:hover:not(:disabled) { background: var(--surface2); }
.pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── BACKFILL PANEL ── */
.backfill-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.backfill-header {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none; font-size: 12px; font-weight: 600;
}
.backfill-header .bf-toggle {
  font-size: 10px; color: var(--muted); font-family: var(--sans); margin-left: auto;
}
.backfill-body { margin-top: 12px; }
.backfill-body.hidden { display: none; }

.bf-progress-wrap {
  margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface2); display: none;
}
.bf-progress-bar { height: 4px; background: var(--accent); transition: width 0.3s; width: 0%; }
.bf-log {
  max-height: 160px; overflow-y: auto; font-family: var(--mono); font-size: 10px;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 2px;
}
.bf-log-line { line-height: 1.5; }
.bf-log-line.ok   { color: var(--accent); }
.bf-log-line.live { color: var(--blue); }
.bf-log-line.err  { color: var(--err); }
.bf-log-line.info { color: var(--muted); }

/* ── CONFIRM DIALOG ── */
.confirm-overlay {
  position: fixed; inset: 0; background: var(--overlay-dim);
  z-index: 999; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.confirm-overlay.show { opacity: 1; pointer-events: all; }

/* ── MODAL CHỌN GÓI ── */
.goi-modal-overlay {
  position: fixed; inset: 0; background: var(--overlay-dim);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.goi-modal-overlay.show { opacity: 1; pointer-events: all; }
.goi-modal-box {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); width: min(820px, 96vw); max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-md);
}
.goi-modal-header {
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.goi-modal-header h3 { margin: 0; font-size: 14px; font-weight: 700; flex: 1; }
.goi-modal-search {
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  padding: 5px 9px; font-size: 12px; width: 180px; outline: none;
  background: var(--surface2);
}
.goi-modal-search:focus { border-color: var(--accent); }
.goi-modal-body { overflow-y: auto; overflow-x: auto; flex: 1; padding: 8px 0; }
.goi-modal-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.goi-modal-table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface2);
  padding: 6px 10px; text-align: left; font-weight: 600;
  border-bottom: 1px solid var(--border); color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.goi-modal-table th:nth-child(1), .goi-modal-table td:nth-child(1) { width: 28px; }
.goi-modal-table th:nth-child(2), .goi-modal-table td:nth-child(2) { width: 100px; }
.goi-modal-table th:nth-child(3), .goi-modal-table td:nth-child(3) { width: auto; }
.goi-modal-table th:nth-child(4), .goi-modal-table td:nth-child(4) { width: 80px; }
.goi-modal-table th:nth-child(5), .goi-modal-table td:nth-child(5) { width: 38px; text-align: right; }
.goi-modal-table th:nth-child(6), .goi-modal-table td:nth-child(6) { width: 78px; }
.goi-modal-table th:nth-child(7), .goi-modal-table td:nth-child(7) { width: 88px; }
.goi-modal-table th:nth-child(8), .goi-modal-table td:nth-child(8) { width: 88px; }
.goi-modal-table tbody tr { cursor: pointer; transition: background 0.1s; }
.goi-modal-table tbody tr:hover td { background: var(--surface2); }
.goi-modal-table tbody tr.gm-selected td { background: #f0f7ff; }
.goi-modal-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle;
  overflow: hidden;
}
.goi-modal-table td:first-child { text-align: center; }
.gm-badge {
  display: inline-block; padding: 2px 6px; border-radius: var(--radius-xs);
  font-size: 10px; font-weight: 600; white-space: nowrap;
}
.gm-badge.mo   { background: #e6f4ea; color: #1a7f3c; }
.gm-badge.chua { background: #fff3e0; color: #b45309; }
.gm-badge.ko   { background: #fce8e8; color: #c0392b; }
.goi-modal-footer {
  padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.goi-modal-footer .gm-count { font-size: 12px; color: var(--muted); flex: 1; }
.gm-sel-all  { font-size: 12px; color: var(--accent); cursor: pointer; text-decoration: underline; background: none; border: none; padding: 0; }
.gm-sel-none { font-size: 12px; color: var(--muted);  cursor: pointer; text-decoration: underline; background: none; border: none; padding: 0; }
.confirm-box {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); padding: 20px 22px; max-width: 320px; width: 90%;
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 14px;
}
.confirm-icon { font-size: 24px; text-align: center; }
.confirm-msg  { font-size: 13px; line-height: 1.5; color: var(--text); text-align: center; }
.confirm-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* ── TABS NAV ── */
.tabs-nav {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 8px 12px; display: flex; align-items: center; gap: 6px;
  position: sticky; top: 0px; z-index: 101; box-shadow: var(--shadow-xs); /* top: 50px; z-index: 99; box-shadow: var(--shadow-xs); */
  max-width: var(--main-max-width); margin: 0 auto;
}
.tabs-pill-track {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 3px; flex: 1;
}
.tab-btn {
  flex: 1; padding: 8px 14px; font-family: var(--sans); font-size: 13px;
  font-weight: 600; cursor: pointer; border: none; background: transparent;
  color: var(--muted); border-radius: var(--radius-sm);
  transition: all 0.18s; white-space: nowrap;
  letter-spacing: 0.2px; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tab-btn:hover { color: var(--text); background: rgba(0,0,0,0.04); }
.tab-btn.active { color: var(--accent); background: var(--surface); box-shadow: var(--shadow-xs); }
@media (max-width: 480px) { .tabs-nav { padding: 6px 10px; } .tab-btn { font-size: 11px; padding: 7px 8px; gap: 4px; } }

/* ── TABS NAV: dropdown trên mobile thay cho dải pill ── */
.tabs-select {
  display: none; /* mặc định ẩn, chỉ hiện trên mobile */
  width: 100%; flex: 1;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  color: var(--text); outline: none;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M0 0l5 6 5-6z' fill='%23888'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
.tabs-select:focus { border-color: var(--accent); }
@media (max-width: 640px) {
  .tabs-pill-track { display: none; }
  .tabs-select { display: block; }
}

/* ── YCBG: chỉ báo cột đang sort ── */
#yc_mainTable th[id^="yc_th_"] { cursor: pointer; }
#yc_mainTable th[id^="yc_th_"].yc-sort-asc  .th-wrap::after { content: " ▲"; font-size: 9px; color: var(--accent); }
#yc_mainTable th[id^="yc_th_"].yc-sort-desc .th-wrap::after { content: " ▼"; font-size: 9px; color: var(--accent); }

/* ── TBMT RÚT GỌN: hàng có thể bấm để mở child-row chi tiết ── */
#rg_mainTable th[onclick] { cursor: pointer; }
.rg-row { cursor: pointer; }
.rg-row:hover > td { background: #eff6ff; }
.rg-ico-cell { text-align: center; }
.rg-ico { display: inline-block; font-size: 9px; color: var(--muted); }
.rg-bidname { white-space: normal; word-break: break-word; line-height: 1.4; }
/* ── KQLCNT TAB ── */
.kq-filter-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.kq-filter-card.toolbar-card .filter-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end;
}
.kq-filter-card.toolbar-card .filter-row > .fg {
  flex: 0 0 auto; min-width: 0; max-width: 100%;
}

/* Search card radio row */
.kq-search-radios {
  display: flex; gap: 16px; font-size: 11px;
  margin-bottom: 8px; flex-wrap: wrap; align-items: center;
}
.kq-search-radios span { font-weight: 500; color: var(--muted); white-space: nowrap; }
.kq-search-radios label { display: flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }

/* Search card input grid: desktop — text inputs tự co giãn, date-pair tối thiểu 310px */
.kq-search-grid {
  display: grid;
  grid-template-columns: 2fr 1.5fr minmax(310px, 1fr); 
  gap: 12px; 
  align-items: flex-end;
}

/* date-pair: 2 input ngày cùng 1 hàng */
.kq-date-pair {
  display: flex; gap: 6px;
}
.kq-date-pair input[type="date"] {
  flex: 1; min-width: 130px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 8px; font-family: var(--sans);
  font-size: 12px; color: var(--text); outline: none;
  transition: border-color 0.15s; width: 100%;
}
.kq-date-pair input[type="date"]:focus { border-color: var(--accent); background: #fff; }

/* Quan trọng: Ép Số quyết định chiếm 2 cột đầu để đẩy ô ngày sang cột 3 */
.kq-search-grid .kq-sg-soqd { 
  grid-column: 1 / span 2; 
}

/* --- TABLET (max-width: 1024px) --- */
@media (max-width: 1024px) {
  .kq-search-grid {
    grid-template-columns: 1fr 1fr;
  }
  .kq-search-grid .kq-sg-keyword  { grid-column: 1 / span 2; }
  .kq-search-grid .kq-sg-notmatch { grid-column: 1 / span 2; }
  .kq-search-grid .kq-sg-datepair { grid-column: 1 / span 2; }
}

/* --- MOBILE (max-width: 600px): 1 cột, date-pair vẫn 2 cạnh nhau --- */
@media (max-width: 600px) {
  .kq-search-radios { gap: 10px; }
  .kq-search-grid { grid-template-columns: 1fr; }
  .kq-search-grid > div { grid-column: 1 / span 1; }
  /* date-pair: 2 input luôn cùng 1 hàng ngay cả trên mobile */
  .kq-date-pair { flex-direction: row; }
  .kq-date-pair input[type="date"] { flex: 1; }
}
/* Inputs bên trong panel LỌC DỮ LIỆU (nền vàng) vẫn giữ màu trắng */
.kq-filter-card[style*="warn-bg"] .fg input,
.kq-filter-card[style*="warn-bg"] .fg select,
.kq-filter-card[style*="warn-bg"] .kq-date-pair input {
  background: var(--surface);
}
.kq-stats-bar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 8px; flex-wrap: wrap;
  font-family: var(--sans); font-size: 11px; color: var(--muted);
}
.kq-stats-bar strong { color: var(--text); font-weight: 600; }
.kq-table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.kq-table-scroll {
  overflow: auto; -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 260px); border-radius: var(--radius);
}
.kq-table-scroll table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kq-table-scroll thead th {
  background: var(--surface2); padding: 9px 12px;
  text-align: left; font-size: 10px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--muted); font-family: var(--sans);
  border-bottom: 2px solid var(--border2);
  border-right: 1px solid var(--border2);
  white-space: nowrap; cursor: pointer; user-select: none;
  position: sticky; top: 0; z-index: 10;
}
.kq-table-scroll thead th:last-child { border-right: none; }
.kq-table-scroll thead th:hover { color: var(--text); }
.kq-table-scroll thead th.kq-sort-asc::after  { content: ' ▲'; color: var(--accent); font-size: 8px; }
.kq-table-scroll thead th.kq-sort-desc::after { content: ' ▼'; color: var(--accent); font-size: 8px; }
.kq-table-scroll tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
.kq-table-scroll tbody tr:hover td { background: var(--surface2); }
.kq-table-scroll td {
  padding: 9px 12px; vertical-align: middle;
  border-right: 1px solid var(--border); overflow: hidden;
  font-size: 13px; line-height: 1.45;
}
.kq-table-scroll td:last-child { border-right: none; }
.kq-empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.kq-empty-state .icon { font-size: 32px; margin-bottom: 8px; opacity: 0.4; }
.kq-empty-state p { font-size: 13px; }
.kq-empty-state .btn-clear-filter {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: var(--sans);
  font-size: 12px; font-weight: 500; cursor: pointer; transition: border-color .15s, background .15s;
}
.kq-empty-state .btn-clear-filter:hover { border-color: var(--accent); background: var(--surface2); }

/* ── CANCEL TBMT ── */
td.goi-td.cancelled-row { background: var(--err-bg) !important; }
td.goi-td.cancelled-row .tbmt-no { text-decoration: line-through; color: var(--err); }
td.goi-td.cancelled-row .bv-name { color: var(--err); opacity: 0.6; }

.cancel-panel {
  background: var(--err-bg); border: 1px solid var(--err);
  border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 8px; font-size: 11px;
  opacity: 0.55;
}
.cancel-panel-header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; user-select: none;
}
.cancel-panel-toggle { font-family: var(--sans); font-size: 10px; color: var(--err); margin-left: auto; opacity: 0.7; }
.cancel-panel-body { margin-top: 8px; }
.cancel-panel-body.hidden { display: none; }
.cancel-panel-codes { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.cancel-code-badge {
  background: #fff; border: 1px solid var(--err); border-radius: var(--radius-lg); padding: 1px 8px;
  font-size: 10px; font-family: var(--sans); color: var(--err); display: flex; align-items: center; gap: 4px;
}
.cancel-code-badge button {
  background: none; border: none; cursor: pointer; color: var(--err); font-size: 11px; padding: 0; line-height: 1;
}

/* ══════════════════════════════════════
   FINGERPRINT PRICE HISTORY MODAL
══════════════════════════════════════ */
#fpModalOverlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: var(--overlay-dim); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
#fpModalOverlay.show { display: flex; }

#rgModalOverlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: var(--overlay-dim); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
#rgModalOverlay.show { display: flex; }
#rgModal {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  width: 1180px; height: 90vh; max-width: 98vw; max-height: 96vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: fpSlideIn 0.2s ease;
}
.rg-modal-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  background: var(--surface2);
}
.rg-modal-title { font-size: 13px; font-weight: 700; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rg-modal-header a { font-size: 11px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.rg-modal-header a:hover { text-decoration: underline; }
.rg-modal-close {
  width: 26px; height: 26px; border: none; background: transparent; cursor: pointer;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); flex-shrink: 0;
}
.rg-modal-close:hover { background: var(--border); color: var(--text); }
.rg-modal-body { position: relative; flex: 1; min-height: 0; }
.rg-modal-body iframe { width: 100%; height: 100%; border: none; display: block; background: #fff; }
.rg-modal-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  gap: 8px; font-size: 12px; color: var(--muted); background: var(--surface); z-index: 1;
}

#fpModal {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  width: 1180px; height: 800px; max-width: 98vw; max-height: 94vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: fpSlideIn 0.2s ease;
}
@keyframes fpSlideIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } }

.fp-header {
  padding: 16px 20px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px; flex-shrink: 0;
}
.fp-header-icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-bg), #d4eddc);
  border: 1px solid var(--border); display: flex; align-items: center;
  justify-content: center; font-size: 18px; flex-shrink: 0;
}
.fp-header-info { flex: 1; min-width: 0; }
.fp-drug-name {
  font-size: 14px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.fp-fingerprint-str {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 2px 7px; display: inline-block;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fp-close-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 4px; border-radius: var(--radius-xs);
  transition: all 0.1s; flex-shrink: 0;
}
.fp-close-btn:hover { background: var(--surface2); color: var(--text); }

.fp-body { flex: 1; min-height: 0; padding: 14px 20px 16px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }

/* Chart area */
.fp-chart-wrap {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.fp-chart-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted); font-family: var(--sans);
  margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.fp-legend {
  display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px;
}
.fp-legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; font-family: var(--sans); color: var(--muted);
}
.fp-legend-dot {
  width: 10px; height: 3px; border-radius: var(--radius-xs); flex-shrink: 0;
}
.fp-legend-dot.circle {
  width: 8px; height: 8px; border-radius: 50%; border: 2px solid currentColor;
  background: transparent;
}
#fpSvgChart { width: 100%; display: block; }
@media (max-height: 700px) {
  #fpSvgChart { height: 140px !important; }
}

/* Stats row */
.fp-stats-row {
  display: flex; gap: 10px; flex-wrap: wrap; flex-shrink: 0;
}
.fp-stat-card {
  flex: 1; min-width: 100px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.fp-stat-label { font-size: 9px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); font-family: var(--sans); margin-bottom: 4px; }
.fp-stat-value { font-size: 16px; font-weight: 700; color: var(--text); font-family: var(--num); font-variant-numeric: tabular-nums lining-nums; }
.fp-stat-sub { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* History table */
.fp-history-wrap {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}
.fp-history-scroll {
  overflow-x: auto; overflow-y: auto;
  flex: 1; min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.fp-history-header {
  background: var(--surface2); padding: 9px 14px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--muted); font-family: var(--sans);
  border-bottom: 1px solid var(--border);
}
.fp-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.fp-table thead th {
  background: var(--surface2); padding: 7px 10px;
  text-align: left; font-size: 9px; font-weight: 700; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--muted); font-family: var(--sans);
  border-bottom: 1px solid var(--border2); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.fp-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.fp-table tr:last-child td { border-bottom: none; }
.fp-table tr:hover td { background: var(--surface2); }
.fp-table td.fp-price-cell {
  font-family: var(--num); font-weight: 700; font-size: 12px;
  text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums lining-nums;
}
.fp-price-plan   { color: var(--warn); }
.fp-price-bid    { color: var(--blue); }
.fp-price-win    { color: var(--accent); }
.fp-badge-type {
  display: inline-block; padding: 1px 6px; border-radius: var(--radius-lg);
  font-size: 9px; font-weight: 700; font-family: var(--sans); white-space: nowrap;
}
.fp-badge-plan { background: var(--warn-bg); color: var(--warn); }
.fp-badge-bid  { background: var(--blue-bg); color: var(--blue); }
.fp-badge-win  { background: var(--accent-bg); color: var(--accent); }

/* Button in table cell */
.fp-trigger-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px; border-radius: var(--radius-xs); border: 1px solid var(--border2);
  background: var(--surface2); color: var(--muted); cursor: pointer;
  font-size: 10px; font-family: var(--sans); transition: all 0.12s;
  white-space: nowrap;
}
.fp-trigger-btn:hover {
  background: var(--accent-bg); border-color: var(--accent); color: var(--accent);
}
.fp-no-history {
  text-align: center; padding: 32px 20px; color: var(--muted);
  font-size: 12px;
}

/* ── Insight nav (sidebar card) + content switcher ── */
.fp-insight-wrap { display: flex; gap: 14px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.fp-nav { display: flex; flex-direction: column; gap: 8px; width: 176px; flex-shrink: 0; overflow-y: visible; }
.fp-nav-card {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 11px; cursor: pointer; transition: all 0.15s; text-align: left;
}
.fp-nav-card:hover { border-color: var(--accent); background: var(--accent-bg); }
.fp-nav-card.active { border-color: var(--accent); background: var(--accent-bg); box-shadow: 0 0 0 1px var(--accent) inset; }
.fp-nav-icon {
  width: 28px; height: 28px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.fp-nav-card.active .fp-nav-icon { background: var(--accent); border-color: var(--accent); }
.fp-nav-text { min-width: 0; }
.fp-nav-title { font-size: 11.5px; font-weight: 700; color: var(--text); line-height: 1.3; }
.fp-nav-sub { font-size: 9.5px; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.fp-content { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
/* Mỗi view fill toàn bộ fp-content */
.fp-view { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }
/* Trend: scroll bên trong vì nội dung có thể dài */
#fpViewTrend { overflow-y: auto; }
/* History: scroll được handle bởi .fp-history-scroll bên trong */
#fpViewHistory { overflow: hidden; }
/* Province: scroll được handle bởi .fp-prov-list bên trong */
#fpViewProvince { overflow: hidden; }
@media (max-width: 680px) {
  .fp-insight-wrap { flex-direction: column; overflow-y: auto; }
  .fp-nav { flex-direction: row; width: auto; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .fp-nav-card { flex: 0 0 auto; min-width: 148px; }
}

/* ── Phân bố đơn giá (histogram) ── */
.fp-dist-chart { position: relative; height: 130px; margin-bottom: 46px; }
.fp-dist-gridline { position: absolute; left: 0; right: 0; height: 1px; background: var(--border); }
.fp-dist-gridline.fp-dist-axis { background: var(--border2); height: 1.5px; }
.fp-dist-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 10px; padding: 0 2px; }
.fp-dist-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; }
.fp-dist-count { font-size: 10px; font-weight: 700; color: var(--accent); font-family: var(--num); margin-bottom: 2px; }
.fp-dist-bar { width: 100%; max-width: 44px; background: var(--accent); border-radius: 4px 4px 2px 2px; min-height: 2px; transition: height 0.25s ease; }
.fp-dist-label {
  font-size: 9px; color: var(--muted); white-space: nowrap; font-family: var(--num);
  position: absolute; top: 100%; left: 50%; margin-top: 6px;
  text-align: left; transform-origin: top left;
  transform: rotate(-40deg) translateX(-50%);
}

/* ── Theo tỉnh/TP (ranked bar list) ── */
.fp-prov-layout { display: flex; gap: 22px; align-items: flex-start; flex: 1; min-height: 0; overflow: hidden; }
.fp-prov-mapwrap { flex: 0 0 560px; width: 560px; overflow: visible; align-self: flex-start; }
.fp-prov-mapwrap svg { width: 100%; height: auto; display: block; }
.fp-prov-path { transition: opacity 0.15s; cursor: default; }
.fp-prov-path:hover { opacity: 0.72; }
.fp-prov-legend { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 8px; font-size: 9.5px; color: var(--muted); }
.fp-prov-legend-swatch { width: 70px; height: 8px; border-radius: var(--radius-xs); background: linear-gradient(to right, #edf6f1, var(--accent)); border: 1px solid var(--border); }
.fp-prov-listwrap { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#fpProvinceWrap { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; gap: 0; }
@media (max-width: 760px) {
  .fp-prov-layout { flex-direction: column; overflow-y: auto; }
  .fp-prov-mapwrap { width: 100%; flex: 0 0 auto; max-width: 320px; margin: 0 auto; max-height: none; }
}
.fp-prov-list { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.fp-prov-header {
  display: grid; grid-template-columns: 1fr 96px 52px 64px 32px;
  gap: 0 8px; align-items: center;
  padding: 0 0 6px; border-bottom: 1px solid var(--border2);
  font-size: 9px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--muted); font-family: var(--sans); flex-shrink: 0; margin-bottom: 2px;
}
.fp-prov-header span:nth-child(n+2) { text-align: right; }
.fp-prov-row   { display: grid; grid-template-columns: 1fr 96px 52px 64px 32px; gap: 0 8px; align-items: center; min-width: 0; }
.fp-prov-name  { font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fp-prov-val   { font-size: 10.5px; font-family: var(--num); font-weight: 700; color: var(--accent); white-space: nowrap; text-align: right; }
.fp-prov-qty   { font-size: 10px; font-family: var(--num); color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.fp-prov-value { font-size: 10px; font-family: var(--num); font-weight: 600; color: var(--blue); white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.fp-prov-cnt   { font-size: 10px; color: var(--muted); white-space: nowrap; text-align: right; }

/* ══════════════════════════════════════
   GỢI Ý DỰ THẦU STYLES
══════════════════════════════════════ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.card-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--muted); font-family: var(--sans); margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.step-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
@media (max-width: 800px) { .step-grid { grid-template-columns: 1fr; } }
@media (min-width: 800px) and (max-width: 1100px) { .step-grid { grid-template-columns: 1fr 1fr; } }

.step-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.step-card-header {
  display: flex; align-items: center; gap: 8px; padding: 11px 16px;
  cursor: pointer; user-select: none;
  border-bottom: 1px solid transparent; transition: border-color 0.15s;
}
.step-card-header:hover { background: var(--surface2); }
.step-card.expanded > .step-card-header { border-bottom-color: var(--border); }
.step-card-body {
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.step-card-body.hidden { display: none; }
/* ── Wizard step states ── */
.step-active {
  box-shadow: 0 0 0 2px var(--accent);
  opacity: 1;
  transition: box-shadow 0.2s, opacity 0.3s;
}
.step-dimmed {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.3s;
}
.step-toggle { margin-left: auto; font-size: 10px; color: var(--muted); font-family: var(--sans); }
.step-label {
  display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); font-family: var(--sans);
  pointer-events: none;
}
.step-num {
  width: 20px; height: 20px; border-radius: 50%; background: var(--purple); color: #fff;
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.step-num.done { background: var(--accent); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent2); }
.btn-accent:disabled { background: var(--border2); cursor: not-allowed; }

.upload-zone {
  border: 2px dashed var(--border2); border-radius: var(--radius-sm); padding: 12px 10px; text-align: center;
  cursor: pointer; transition: all 0.15s; color: var(--muted); font-size: 12px;
}
.upload-zone:hover { border-color: var(--purple); background: var(--purple-bg); color: var(--purple); }
.upload-zone.loaded { border-color: var(--accent); border-style: solid; background: var(--accent-bg); color: var(--accent); }
.upload-zone input { display: none; }

.status-line {
  font-family: var(--sans); font-size: 11px; color: var(--muted);
  padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface2);
  border: 1px solid var(--border); display: flex; align-items: center; gap: 8px;
}
.status-line.ok   { background: var(--accent-bg); color: var(--accent); border-color: #a7d9b8; }
.status-line.err  { background: var(--err-bg); color: var(--err); border-color: #fca5a5; }
.status-line.warn { background: var(--warn-bg); color: var(--warn); border-color: #fcd34d; }
.status-line.run  { background: var(--blue-bg); color: var(--blue); border-color: #bfdbfe; }

.progress-bar-bg { height: 4px; background: var(--border); border-radius: var(--radius-xs); overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--purple); border-radius: var(--radius-xs); transition: width 0.2s; width: 0%; }

.result-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.result-header {
  background: var(--surface2); border-bottom: 2px solid var(--border2); padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.result-title { font-weight: 700; font-size: 12px; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600; font-family: var(--num); font-variant-numeric: tabular-nums;
}
.chip-total  { background: var(--blue-bg);   color: var(--blue); }
.chip-exact  { background: var(--accent-bg); color: var(--accent); }
.chip-fuzzy  { background: var(--warn-bg);   color: var(--warn); }
.chip-none   { background: var(--surface2);  color: var(--muted); }
.chip-pvcc   { background: var(--purple-bg); color: var(--purple); }

.filter-input {
  width: 100%;
  padding: 5px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px; font-family: var(--sans); outline: none; background: var(--surface);
  color: var(--text); transition: border 0.15s;
}
.filter-input:focus { border-color: var(--purple); }

tr.row-dm { background: #fff; }
tr.row-dm td:first-child { border-left: 3px solid var(--purple); }
tr.row-pvcc-exact { background: #f0fdf4; }
tr.row-pvcc-exact td:first-child { border-left: 3px solid var(--accent); }
tr.row-pvcc-fuzzy { background: #fffbeb; }
tr.row-pvcc-fuzzy td:first-child { border-left: 3px solid var(--warn); }
tr.row-pvcc-none  { background: #fef2f2; }
tr.row-pvcc-none  td:first-child { border-left: 3px solid var(--border2); }

.score-badge {
  display: inline-block; padding: 1px 6px; border-radius: var(--radius-xs); font-family: var(--num);
  font-size: 10px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.score-high { background: var(--accent-bg); color: var(--accent); }
.score-mid  { background: var(--warn-bg);   color: var(--warn); }
.score-low  { background: var(--surface2);  color: var(--muted); }

.match-badge {
  display: inline-block; padding: 1px 7px; border-radius: var(--radius-full); font-size: 10px; font-weight: 600; font-family: var(--num); font-variant-numeric: tabular-nums;
}
.match-exact  { background: var(--accent-bg); color: var(--accent); }
.match-fuzzy  { background: var(--warn-bg);   color: var(--warn); }
.match-none   { background: var(--surface2);  color: var(--muted); }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.summary-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; text-align: center; }
.summary-val { font-size: 22px; font-weight: 700; font-family: var(--num); color: var(--text); font-variant-numeric: tabular-nums lining-nums; }
.summary-val.accent { color: var(--accent); }
.summary-val.warn   { color: var(--warn); }
.summary-val.purple { color: var(--purple); }
.summary-lbl { font-size: 10px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.7px; }

.lot-no {
  font-family: var(--sans); font-size: 11px; font-weight: 700; color: var(--purple); background: var(--purple-bg);
  padding: 1px 7px; border-radius: var(--radius-xs); white-space: nowrap;
}
.hc-main { font-weight: 600; font-size: 12px; color: var(--text); }
.hc-sub  { font-size: 10px; color: var(--muted); margin-top: 1px; }
.price-plan { font-family: var(--num); font-size: 11px; color: var(--warn); font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }
.qty-num    { font-family: var(--num); font-size: 11px; font-variant-numeric: tabular-nums lining-nums; }

.breakdown { display: flex; flex-direction: column; gap: 2px; font-family: var(--num); font-size: 10px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.breakdown span.ok  { color: var(--accent); }
.breakdown span.mid { color: var(--warn); }
.breakdown span.bad { color: var(--err); }

.tbmt-chip {
  display: inline-flex; align-items: center; gap: 4px; font-family: var(--sans); font-size: 10px; color: var(--blue);
  background: var(--blue-bg); padding: 1px 8px; border-radius: var(--radius-full);
}

#tab-goiy .pg-btn.active { background: var(--purple); color: #fff; border-color: var(--purple); }
.tbmt-found-row { display:flex; align-items:center; gap:6px; padding:5px 8px; background:var(--surface2); border-radius: var(--radius-sm); border:1px solid var(--border); font-size:11px; min-width:0; width:100%; box-sizing:border-box; }
.tbmt-found-row input[type=checkbox] { flex-shrink:0; }
.tbmt-found-no  { font-family:var(--mono); font-weight:700; color:var(--blue); flex-shrink:0; white-space:nowrap; }
.tbmt-found-bv  { color:var(--text); flex:1 1 0; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tbmt-found-cnt { font-family:var(--num); font-size:10px; color:var(--muted); flex-shrink:0; white-space:nowrap; font-variant-numeric:tabular-nums; }
.spinner-on-accent { width:12px; height:12px; border:2px solid rgba(255,255,255,0.4); border-top-color:#fff; border-radius:50%; animation:spin 0.7s linear infinite; display:inline-block; }
@keyframes spin { to { transform:rotate(360deg); } }
tr.master-row > td { background:#ede9fe; border-top:2px solid #c4b5fd; border-bottom:1px solid #c4b5fd; padding:5px 10px; cursor:pointer; }
tr.master-row:hover > td { background:#ddd6fe; }
tr.master-row.collapsed > td { border-bottom:2px solid #c4b5fd; }
.master-inner { display:flex; align-items:center; gap:10px; min-width:0; }
.master-toggle { font-size:11px; color:var(--purple); font-family:var(--mono); font-weight:700; flex-shrink:0; }
.master-no     { font-family:var(--mono); font-size:11px; font-weight:700; color:var(--purple); flex-shrink:0; }
.master-bv     { font-size:12px; font-weight:600; color:var(--text); flex-shrink:0; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:220px; }
.master-mid    { display:flex; align-items:center; gap:8px; flex:1; min-width:0; justify-content:center; flex-wrap:wrap; }
.master-bidname{ font-size:11px; color:var(--muted); font-style:italic; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:260px; }
.master-close  { font-family:var(--sans); font-size:10px; color:var(--muted); white-space:nowrap; flex-shrink:0; }
.master-days   { font-family:var(--sans); font-size:10px; font-weight:600; flex-shrink:0; white-space:nowrap; }
.master-locs   { font-family:var(--sans); font-size:10px; color:var(--blue); flex-shrink:0; white-space:nowrap; max-width:160px; overflow:hidden; text-overflow:ellipsis; }
.master-bd-star{ display:none; }
.badge-bd { display:inline-block; font-size:9px; font-weight:700; font-family:var(--num); background:var(--purple); color:#fff; padding:1px 4px; border-radius: var(--radius-xs); margin-right:3px; vertical-align:middle; flex-shrink:0; letter-spacing:0.3px; }
.badge-bd-row { background:var(--warn); }
.master-cnt    { font-family:var(--num); font-size:10px; background:var(--purple); color:#fff; padding:1px 8px; border-radius: var(--radius-lg); flex-shrink:0; font-variant-numeric:tabular-nums; }
.cell-hc   { font-weight:600; word-break:break-word; font-size:12px; }
.cell-nongdo { font-family:var(--mono); font-size:11px; color:var(--muted); }
.cell-sm   { font-size:11px; line-height:1.5; word-break:break-word; }
.cell-uom  { font-size:10px; color:var(--muted); font-family:var(--sans); }
.bv-filter-tag { display:inline-flex; align-items:center; font-family:var(--sans); font-size:10px; color:var(--purple); background:var(--purple-bg); padding:1px 8px; border-radius: var(--radius-full); }
td.fill { background:var(--surface2); border-bottom:1px solid var(--border); }
tr.sub-row td { background:rgba(0,0,0,0.015); }

/* ── KẾT QUẢ TRÚNG THẦU CELL ── */
.trung-cell { min-width: 560px; }
.trung-line {
  display: flex; flex-direction: column; gap: 1px;
  padding: 3px 0; border-bottom: 1px solid var(--border);
  font-size: 11px; line-height: 1.4;
}
.trung-line:last-child { border-bottom: none; padding-bottom: 0; }
.trung-ten { font-weight: 600; font-size: 11px; color: var(--primary, #2563eb); }
.trung-cty { font-size: 10px; color: var(--text); }
.trung-qd  { font-family: var(--mono); font-size: 9px; color: var(--muted); margin-top: 1px; }
.no-trung  { font-size: 11px; color: var(--muted); font-style: italic; }
.detail-cell { white-space: normal; word-break: break-word; color: var(--text); }
.detail-cell[data-field="hoatChatTrung"] { font-family: var(--sans); font-weight: 600; font-size: 12px; }
.detail-cell[data-field="nongDoTrung"],
.detail-cell[data-field="gdklh"] { font-family: var(--mono); font-size: 11px; }
.trung-loading { font-size: 10px; color: var(--border2); font-family: var(--sans); }

/* ── PHÂN TÍCH TAB ── */
.pt-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase;
  color: var(--muted); font-family: var(--sans); margin-bottom: 6px; padding-left: 2px;
}
.pt-kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px; margin-bottom: 10px;
}
@media (max-width: 1100px) { .pt-kpi-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 700px)  { .pt-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.pt-kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 13px; box-shadow: var(--shadow);
}
.pt-kpi-card.accent  { border-left: 3px solid var(--accent); }
.pt-kpi-card.blue    { border-left: 3px solid var(--blue); }
.pt-kpi-card.warn    { border-left: 3px solid var(--warn); }
.pt-kpi-card.purple  { border-left: 3px solid var(--purple); }
.pt-kpi-card.err     { border-left: 3px solid var(--err); }
.pt-kpi-label { font-size: 9px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); font-family: var(--sans); margin-bottom: 4px; }
.pt-kpi-value { font-size: 20px; font-weight: 700; font-family: var(--num); color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums lining-nums; }
.pt-kpi-sub   { font-size: 10px; color: var(--muted); margin-top: 3px; line-height: 1.3; }
.pt-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.pt-card-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--muted); font-family: var(--sans); margin-bottom: 10px;
}
.pt-chart-wrap { width: 100%; overflow: hidden; }
.pt-rank-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.pt-rank-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
.pt-rank-table th { font-size: 9px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); font-family: var(--sans); padding: 5px 8px; border-bottom: 2px solid var(--border2); text-align: left; white-space: nowrap; }
.pt-rank-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pt-rank-table tr:last-child td { border-bottom: none; }
.pt-rank-table tr:hover td { background: var(--surface2); }
.pt-rank-num { font-family: var(--num); font-size: 10px; color: var(--muted); width: 16px; min-width: 16px; text-align: center; padding-left: 2px !important; padding-right: 4px !important; font-variant-numeric: tabular-nums; }
.pt-bar-inline { display: inline-block; height: 6px; border-radius: var(--radius-xs); background: var(--accent); opacity: 0.65; vertical-align: middle; min-width: 2px; }
.pt-bar-cell { width: 80px; min-width: 40px; }
.pt-bar-cell .pt-bar-inline { width: calc(var(--bpct, 50) * 1%); max-width: 100%; }
.pt-bar-win { background: var(--warn); opacity: 0.85; }
.pt-hint { font-size: 10px; color: var(--muted); padding: 6px 8px; font-family: var(--sans); }
@media (max-width: 750px) {
  #tab-phantich [style*="grid-template-columns:3fr 2fr"],
  #tab-phantich [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
}

/* ── LOGIN OVERLAY ── */
#loginOverlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
#loginOverlay.hidden { display: none; }

/* ── LANDING NAV ── */
#loginOverlay .lo-nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 40px;
  background: rgba(245,244,240,0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#loginOverlay .lo-nav-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--sans); font-size: 16px; font-weight: 700; color: var(--text);
}
#loginOverlay .lo-nav-mark {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
#loginOverlay .lo-nav-cta {
  padding: 8px 20px; border-radius: var(--radius);
  background: var(--text); color: #fff;
  font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; font-family: var(--sans);
  transition: background .15s;
}
#loginOverlay .lo-nav-cta:hover { background: var(--accent); }

/* ── HERO SPLIT ── */
#loginOverlay .lo-hero {
  display: grid;
  grid-template-columns: 1fr 420px;
  min-height: calc(100vh - 57px);
  align-items: center;
  position: relative;
}
@media (max-width: 820px) {
  #loginOverlay .lo-hero { grid-template-columns: 1fr; min-height: unset; }
  #loginOverlay .lo-right { order: -1; border-left: none !important; border-bottom: 1px solid var(--border); min-height: unset; padding: 32px 24px; }
  #loginOverlay .lo-left { padding: 40px 24px; }
  #loginOverlay .lo-h1 { font-size: 32px; }
  #loginOverlay .lo-features { padding: 40px 24px; }
}

/* Grid nền */
#loginOverlay .lo-left {
  padding: 80px 64px;
  position: relative;
  overflow: hidden;
}
#loginOverlay .lo-left::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.45;
  mask-image: radial-gradient(ellipse 90% 80% at 40% 50%, black 20%, transparent 100%);
}
#loginOverlay .lo-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 14px; border-radius: var(--radius-full);
  background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--warn);
  margin-bottom: 28px; position: relative;
}
#loginOverlay .lo-eyebrow::before {
  content: ''; width: 5px; height: 5px;
  background: var(--warn); border-radius: 50%;
}
#loginOverlay .lo-h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1.1; letter-spacing: -1px;
  color: var(--text); position: relative;
  margin-bottom: 24px;
}
#loginOverlay .lo-h1 em { font-style: italic; color: var(--accent); }
#loginOverlay .lo-sub {
  font-size: 16px; line-height: 1.75;
  color: var(--text); max-width: 460px;
  position: relative; margin-bottom: 48px; opacity: 0.82;
}

/* Stats */
#loginOverlay .lo-stats {
  display: flex; gap: 40px; position: relative; flex-wrap: wrap;
}
#loginOverlay .lo-stat-num {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 36px; font-weight: 700;
  color: var(--text); line-height: 1; letter-spacing: -1px;
}
#loginOverlay .lo-stat-num span { color: var(--accent); }
#loginOverlay .lo-stat-label {
  font-size: 12px; color: var(--muted); margin-top: 4px;
}

/* ── RIGHT: LOGIN FORM ── */
#loginOverlay .lo-right {
  border-left: 1px solid var(--border);
  background: var(--surface);
  min-height: calc(100vh - 57px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 40px;
}
#loginOverlay .lo-form-wrap {
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 20px;
}
#loginOverlay .lo-form-title {
  font-size: 20px; font-weight: 700; color: var(--text);
  letter-spacing: -0.3px;
}
#loginOverlay .lo-form-sub {
  font-size: 13px; color: var(--muted); margin-top: -12px;
}
#loginOverlay .lo-field { display: flex; flex-direction: column; gap: 5px; }
#loginOverlay .lo-field label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
#loginOverlay .lo-field input {
  padding: 10px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  font-family: var(--sans); font-size: 14px; color: var(--text); outline: none;
  transition: border-color .15s, background .15s;
}
#loginOverlay .lo-field input:focus { border-color: var(--accent); background: var(--surface); }
#loginOverlay .lo-btn-login {
  padding: 12px; border-radius: var(--radius); border: none;
  background: var(--accent); color: #fff;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
  letter-spacing: 0.1px;
}
#loginOverlay .lo-btn-login:hover { background: var(--accent2); }
#loginOverlay .lo-btn-login:disabled { opacity: .6; cursor: default; }

/* ── FEATURES STRIP ── */
#loginOverlay .lo-features {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 56px 64px;
}
#loginOverlay .lo-features-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.8px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 32px;
}
#loginOverlay .lo-feat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}
#loginOverlay .lo-feat {
  display: flex; flex-direction: column; gap: 8px;
}
#loginOverlay .lo-feat-icon { font-size: 22px; }
#loginOverlay .lo-feat-name { font-size: 14px; font-weight: 700; color: var(--text); font-family: 'Playfair Display', Georgia, serif; }
#loginOverlay .lo-feat-desc { font-size: 13px; line-height: 1.65; color: var(--muted); }

/* Ẩn toàn bộ app shell khi chưa đăng nhập */
body:not(.authed) header,
body:not(.authed) .tabs-nav,
body:not(.authed) [id^="tab-"],
body:not(.authed) #mothauTopPanel,
body:not(.authed) #initProgress {
  visibility: hidden;
  pointer-events: none;
}

/* Giữ lại các class cũ phòng JS vẫn reference */
#loginError {
  display: none; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--err-bg); border: 1px solid #fca5a5;
  color: var(--err); font-size: 12px;
}
#loginError.show { display: block; }
#btnGetOtp, #btnGetForgotOtp {
  padding: 0 14px; height: 42px;
  background: var(--surface); border: 1.5px solid var(--accent);
  color: var(--accent); border-radius: var(--radius);
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s;
  white-space: nowrap; flex-shrink: 0;
}
#btnGetOtp:hover, #btnGetForgotOtp:hover { background: var(--accent); color: #fff; }
#btnGetOtp:disabled, #btnGetForgotOtp:disabled { opacity: .6; cursor: default; }

#btnLogin, #btnRegister, #btnForgot {
  padding: 12px; border-radius: var(--radius); border: none;
  background: var(--accent); color: #fff;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
#btnLogin:hover, #btnRegister:hover, #btnForgot:hover { background: var(--accent2); }
#btnLogin:disabled, #btnRegister:disabled, #btnForgot:disabled { opacity: .6; cursor: default; }

/* ── LOGOUT BUTTON ── */
#btnLogout {
  display: none;
  align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent; color: var(--muted);
  font-family: var(--sans); font-size: 11px; cursor: pointer;
  transition: background .15s, color .15s;
}
#btnLogout:hover { background: var(--err-bg); color: var(--err); border-color: var(--err); }
#userLabel { font-size:11px; color: var(--muted); white-space:nowrap; }

#initProgress {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 9999; width: 280px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 20px 24px; display: flex; flex-direction: column; gap: 12px;
  transition: opacity 0.3s ease;
}
#initProgress.hidden { opacity: 0; pointer-events: none; }
#initProgress .init-label {
  font-size: 12px; color: var(--muted); font-family: var(--sans);
  min-height: 16px; transition: opacity 0.2s;
}
#initProgress .init-bar-wrap {
  width: 100%; height: 4px;
  background: var(--border); border-radius: var(--radius-full); overflow: hidden;
}
#initProgress .init-bar {
  height: 4px; background: var(--accent);
  border-radius: var(--radius-full); width: 0%;
  transition: width 0.35s ease;
}
#initProgress .init-footer {
  display: flex; justify-content: space-between; align-items: center;
}
#initProgress .init-pct {
  font-size: 11px; color: var(--accent); font-family: var(--sans); font-weight: 600;
}
#initProgress .init-dots span {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--border); margin: 0 2px;
  animation: initDot 1.2s infinite ease-in-out;
}
#initProgress .init-dots span:nth-child(2) { animation-delay: 0.2s; }
#initProgress .init-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes initDot {
  0%, 80%, 100% { background: var(--border); transform: scale(1); }
  40% { background: var(--accent); transform: scale(1.3); }
}

/* ── PRICE DISCREPANCY MODAL ── */
#pdModalOverlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: var(--overlay-dim); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
#pdModalOverlay.show { display: flex; }

/* ── COMPETITOR PROFILE MODAL ── */
#cpModalOverlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: var(--overlay-dim); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
#cpModalOverlay.show { display: flex; }
#cpModal, .cpModal {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  width: 1180px; height: 800px; max-width: 98vw; max-height: 94vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: fpSlideIn 0.2s ease;
}
.cp-link { cursor: pointer !important; transition: color 0.12s; }
.cp-link:hover { color: var(--accent) !important; text-decoration: underline; }
.cp-bar-label { font-size: 10px; fill: var(--muted); font-family: var(--sans); }
.cp-bar-val { font-size: 10px; fill: var(--text); font-family: var(--num); font-weight: 600; }
.cp-nhom-bar {
  display: flex; align-items: center; gap: 8px; padding: 5px 0;
  font-size: 11px; font-family: var(--sans);
}
.cp-nhom-bar .cp-nhom-name { width: 70px; flex-shrink: 0; font-weight: 600; text-align: right; }
.cp-nhom-bar .cp-nhom-track { flex: 1; height: 18px; background: var(--surface2); border-radius: 4px; position: relative; overflow: hidden; }
.cp-nhom-bar .cp-nhom-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; }
.cp-nhom-bar .cp-nhom-stat { width: 100px; flex-shrink: 0; font-size: 10px; color: var(--muted); font-family: var(--num); font-variant-numeric: tabular-nums; }

/* ── FILTER PRESET ── */
.preset-modal-overlay {
  display:none; position:fixed; inset:0; background:var(--overlay-dim);
  z-index:3000; align-items:center; justify-content:center;
}
.preset-modal-overlay.open { display:flex; }
.preset-modal {
  background:var(--surface); border-radius:var(--radius-lg); box-shadow:var(--shadow-lg);
  width:min(420px,92vw); max-height:80vh; display:flex; flex-direction:column;
  overflow:hidden;
}
.preset-modal-header {
  padding:14px 16px 10px; border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:8px;
}
.preset-modal-title { font-size:14px; font-weight:700; flex:1; }
.preset-modal-close { background:none; border:none; font-size:18px; cursor:pointer; color:var(--muted); padding:0 4px; }
.preset-modal-body { padding:12px 16px; overflow-y:auto; flex:1; }
.preset-list { display:flex; flex-direction:column; gap:6px; margin-bottom:12px; min-height:32px; }
.preset-item {
  display:flex; align-items:center; gap:6px; padding:8px 10px;
  border:1px solid var(--border); border-radius: var(--radius); cursor:pointer;
  background:var(--surface2); transition:background .12s;
}
.preset-item:hover { background:var(--accent-bg); border-color:var(--accent); }
.preset-item-name { flex:1; font-size:12px; font-weight:600; }
.preset-item-meta { font-size:10px; color:var(--muted); }
.preset-item-del { background:none; border:none; color:var(--muted); cursor:pointer; font-size:13px; padding:0; border-radius: var(--radius-xs); min-width:44px; min-height:44px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.preset-item-del:hover { color:var(--err); background:var(--err-bg,#fee2e2); }
.preset-save-row { display:flex; gap:6px; margin-top:4px; }
.preset-save-row input { flex:1; padding:6px 10px; border:1px solid var(--border); border-radius: var(--radius-sm); font-size:12px; background:var(--surface); color:var(--text); outline:none; font-family:var(--sans); }
.preset-save-row input:focus { border-color:var(--accent); }
.preset-empty { font-size:12px; color:var(--muted); text-align:center; padding:12px 0; }
/* ══════════════════════════════════════════════
   MOBILE: font-size tối thiểu + touch targets
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Font tối thiểu: không cho phép dưới 12px trên mobile */
  body, td, th, input, select, button, label, p, span, div {
    -webkit-text-size-adjust: 100%;
  }

  /* Nâng các label phụ lên tối thiểu 12px */
  .badge, .cache-day-badge,
  .wlm-added-at, .logo-sub,
  .cell-goi-thau .tbmt-no,
  .cell-qty .qty-uom,
  .bidder-line .b-rank,
  .no-bidder,
  .kq-stats-bar,
  .status-text,
  .tab-date-hint,
  .preset-item-meta {
    font-size: 12px !important;
  }

  /* Nâng text table lên tối thiểu 12px */
  td, th { font-size: 12px !important; }
  .cell-nongdo, .cell-duongdung,
  .cell-hc .hc-detail,
  td.mono, .bidder-line .b-price,
  .no-bidder { font-size: 12px !important; }

  /* Label section header giữ tối thiểu 10px (uppercase có letter-spacing) */
  .section-label-sm, .tab-section-label,
  .kq-table-scroll thead th,
  .wlm-del-btn { font-size: 10px !important; }

  /* Touch targets tối thiểu 44×44px */
  .btn-sm, .btn {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  /* Nút chỉ có icon (⋮, ✕...): giữ đúng 44×44, không cộng thêm padding của nút chữ
     — nếu không sẽ thành hộp to trống rỗng quanh 1 icon nhỏ, nhìn như dư khoảng trống */
  .btn-icon {
    width: 44px; height: 44px;
    min-height: 44px;
    padding: 0; padding-top: 0; padding-bottom: 0;
  }
  .preset-item-del,
  .wlm-del-btn,
  .tab-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Nút xóa lọc trong empty state */
  .btn-clear-filter {
    min-height: 44px;
    padding: 10px 20px;
    font-size: 13px !important;
  }
}

/* --- Extracted Style --- */

      /* ── Riêng cho tab Tra Kết Quả VSS: ô filter rộng hơn, bảng rộng + wrap text ── */
      #tab-d1result .filter-row {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 6px 8px;
      }
      #tab-d1result .fg input,
      #tab-d1result .fg select {
        padding: 5px 8px;
        font-size: 11px;
      }
      #tab-d1result .fg label { font-size: 10px; margin-bottom: 2px; }
      #tab-d1result .fg.date,
      #tab-d1result .fg.short { min-width: unset; flex: unset; }
      @media (max-width: 600px) {
        #tab-d1result .filter-row { grid-template-columns: repeat(2, 1fr); gap: 6px; }
      }

      #tab-d1result .table-wrap { width: 100%; }
      #tab-d1result .table-scroll { width: 100%; max-height: 65vh; overflow: auto; }
      #tab-d1result table#d1_table {
        table-layout: fixed;
      }
      #tab-d1result table#d1_table thead {
        position: sticky;
        top: 0;
        z-index: 11;
        background: var(--surface2);
      }
      #tab-d1result table#d1_table thead th {
        position: static;
        white-space: normal;
        word-break: break-word;
        vertical-align: bottom;
        background: var(--surface2);
      }
      #tab-d1result table#d1_table td {
        white-space: normal;
        word-break: break-word;
        overflow: visible;
        text-overflow: unset;
        line-height: 1.4;
      }
      #tab-d1result thead tr.d1-filter-row th {
        padding: 4px 6px;
        background: var(--surface2);
        cursor: default;
        vertical-align: middle;
      }
      #tab-d1result thead tr.d1-filter-row th input {
        width: 100%; box-sizing: border-box; font-size: 11px; padding: 3px 5px;
        border: 1px solid var(--border); border-radius: 4px; font-family: var(--sans);
      }
    

/* ── MODAL FEEDBACK ── */
.fb-modal-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: var(--overlay-dim); display: flex;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  backdrop-filter: blur(2px);
}
.fb-modal-overlay.show { opacity: 1; pointer-events: all; }
.fb-modal-box {
  background: var(--surface); width: 90%; max-width: 460px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(10px) scale(0.98); transition: all 0.2s;
}
.fb-modal-overlay.show .fb-modal-box { transform: translateY(0) scale(1); }
.fb-modal-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.fb-modal-header h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.fb-modal-body { padding: 16px; flex: 1; overflow-y: auto; }
.fb-modal-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.fb-textarea {
  width: 100%; border: 1px solid var(--border2); border-radius: var(--radius-sm);
  padding: 10px; font-family: var(--sans); font-size: 13px; color: var(--text);
  resize: vertical; min-height: 120px; outline: none; transition: border-color 0.15s; margin-top: 8px;
}
.fb-textarea:focus { border-color: var(--accent); }

\n#mainTable { min-width: 1400px; }\n
@keyframes btnPulseNeedsFetch {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); transform: scale(1); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); transform: scale(1.02); background-color: #ef4444; border-color: #dc2626; }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); transform: scale(1); }
}
.btn.needs-fetch {
  animation: btnPulseNeedsFetch 1.5s infinite;
  background-color: #f87171 !important;
  color: white !important;
  border-color: #ef4444 !important;
}
