@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&family=Noto+Sans+Math&display=swap');

/* Giao diện dùng chung (đi kèm static/js/theme.js: bảng màu Tailwind) — kiểu phần mềm thương mại,
   theo skill frontend-design của Anthropic.
   - Khung ứng dụng: điều hướng chung ở templates/_nav.html. Máy tính (>= 1024px): cột trái màu MỰC cố định,
     mục đang mở có vạch xanh tín hiệu bên trái (điểm nhấn DUY NHẤT). Điện thoại: thanh mực trên cùng, menu cuộn ngang.
   - Chữ: chỉ Be Vietnam Pro; số dùng tabular-nums (không dùng font mono). Tiêu đề viết hoa đầu câu.
   - Không emoji trong giao diện; không hiệu ứng xuất hiện cho từng thẻ.
   Phần này lo những gì class Tailwind không làm: font, khung, đổ bóng thẻ, tiêu điểm bàn phím,
   thanh cuộn, và các lớp riêng của /quanly (.card .inp .btn .btn2 .badge). */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --line: #dde3ec;
  --line-strong: #c9d5e4;
  --text: #0f2547;
  --ink: #0f2547;
  --signal: #1565c0;
  --muted: #64748b;
  --brand: #1565c0;
  --brand-hover: #0b3d91;
  --brand-soft: #e8f1fc;
  --th-bg: #f2f6fc;
  --nav-w: 232px;
  --shadow-sm: 0 1px 2px rgba(15, 40, 80, .05);
  --shadow: 0 1px 3px rgba(15, 40, 80, .06);
  --shadow-lg: 0 10px 24px -10px rgba(15, 40, 80, .22);
  color-scheme: light;
}

html { -webkit-text-size-adjust: 100%; font-size: 13.5px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Be Vietnam Pro", "Segoe UI", Roboto, Arial, "Noto Sans Math", sans-serif;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* ---- Khung ứng dụng ---- */
/* Header dính trên cùng: hàng đầu chứa _nav.html (thương hiệu + menu); các hàng sau (bộ lọc, tab) là dải trắng. */
header.sticky { background: #fff !important; backdrop-filter: none !important; border-bottom: 1px solid var(--line) !important;
                box-shadow: 0 1px 2px rgba(15, 37, 71, .05); }
header.sticky > div { max-width: none !important; }
header.sticky > div:first-child ~ div { padding-top: .55rem; padding-bottom: .55rem; }

/* Điện thoại / máy tính bảng: thanh mực trên cùng, menu một hàng cuộn ngang */
header.sticky > div:first-child {
  background: var(--ink); color: #fff; flex-wrap: nowrap !important; gap: .25rem 1rem !important;
  padding-top: .5rem !important; padding-bottom: .5rem !important; overflow-x: auto; scrollbar-width: none;
}
header.sticky > div:first-child::-webkit-scrollbar { display: none; }
.app-brand { display: flex; flex-direction: column; flex: none; line-height: 1.15; color: #fff; text-decoration: none; }
.app-brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.app-brand-sub { font-size: 11.5px; color: rgba(255, 255, 255, .6); }
.app-nav { display: flex; gap: .15rem; flex: none; }
.app-nav a { display: flex; align-items: center; gap: .55rem; white-space: nowrap; padding: .45rem .7rem; border-radius: 6px;
  font-size: 13.5px; font-weight: 500; color: rgba(255, 255, 255, .72); text-decoration: none; }
.app-nav a svg { flex: none; opacity: .85; }
.app-nav a:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.app-nav a.active { color: #fff; font-weight: 600; background: rgba(255, 255, 255, .1); }
.app-nav a:focus-visible { outline: 2px solid #7fb0ff; outline-offset: -2px; }
.app-nav-foot { margin-left: auto; }

/* Máy tính: hàng đầu thành cột trái cố định; nội dung lùi sang phải */
@media (min-width: 1024px) {
  body { padding-left: var(--nav-w); }
  header.sticky > div:first-child {
    position: fixed; top: 0; bottom: 0; left: 0; width: var(--nav-w); z-index: 40;
    flex-direction: column; align-items: stretch !important; justify-content: flex-start;
    padding: 1.25rem .75rem 1rem !important; gap: 0 !important; overflow-y: auto;
  }
  .app-brand { padding: 0 .6rem 1.1rem; margin-bottom: .75rem; border-bottom: 1px solid rgba(255, 255, 255, .1); }
  .app-brand-name { font-size: 19px; }
  .app-nav { flex-direction: column; gap: .125rem; }
  .app-nav a { padding: .55rem .7rem; font-size: 14px; position: relative; }
  .app-nav a.active { background: rgba(255, 255, 255, .08); }
  .app-nav a.active::before { content: ""; position: absolute; left: -.75rem; top: .4rem; bottom: .4rem; width: 3px;
    border-radius: 0 3px 3px 0; background: #4f95ff; }
  .app-nav-foot { margin: auto 0 0; padding-top: .75rem; border-top: 1px solid rgba(255, 255, 255, .1); }
  /* Trang không có hàng bộ lọc: header chỉ còn cột trái -> bỏ dải trắng rỗng */
  header.sticky:not(:has(> div + div)) { border: 0 !important; box-shadow: none; height: 0; }
}

/* Tiêu đề khối: viết hoa đầu câu, chữ đậm màu mực (không chữ hoa toàn bộ, không tô màu nhấn) */
main h2:not(.ad-card h2) { color: var(--ink) !important; font-size: 16px !important; font-weight: 700 !important;
  letter-spacing: -.015em; }
main h1 { letter-spacing: -.02em; }

/* Ô chỉ số lớn ở trang báo cáo */
.text-2xl.font-bold { font-weight: 700 !important; letter-spacing: -.025em; }

/* Thẻ / khối nội dung: nền trắng có viền thì thêm bóng nhẹ cho nổi khỏi nền */
.rounded-2xl.bg-gray-900, .rounded-xl.bg-gray-900.border, .card { box-shadow: var(--shadow); }

/* Thẻ quảng cáo ở thư viện / trang Fanpage */
.ad-card { box-shadow: var(--shadow); transition: box-shadow .18s ease, border-color .18s ease; }
.ad-card:hover { box-shadow: var(--shadow-lg); border-color: var(--signal) !important; }
.ad-card .media-box { background: #e9edf3 !important; }

/* Ô nhập, chọn: nền trắng, viền rõ, vòng sáng khi chọn */
input[type="search"], input[type="text"], input[type="password"], input:not([type]), select, textarea {
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 2px rgba(21, 101, 192, .15); border-color: var(--brand) !important; }
input::placeholder, textarea::placeholder { color: #98a2b3; }

/* Tiêu điểm bàn phím rõ ràng cho mọi phần tử bấm được */
a:focus-visible, button:focus-visible, summary:focus-visible, [role="tab"]:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px;
}

/* Tab ở /baocao */
.tab-btn { font-weight: 500; }
.tab-btn[aria-selected="true"] { color: var(--brand) !important; border-color: var(--brand) !important; font-weight: 600; }

/* Dòng bấm được trong danh sách Top 500 */
.bar-row:hover { background: var(--brand-soft); }

/* Bảng: chữ tiêu đề nhạt, dòng kẻ mảnh */
/* Bảng kiểu HRM: tiêu đề nền xanh nhạt đậm chữ, dòng kẻ mảnh, rê chuột tô xanh nhạt */
table thead th { background: var(--th-bg); color: #334155; font-weight: 600; border-bottom: 1px solid var(--line); }
tbody td { border-color: #e9eef6; }
tbody tr:hover > td { background: #f5f9ff; }

/* Thanh cuộn mảnh, sáng */
* { scrollbar-width: thin; scrollbar-color: #c4cbd7 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c4cbd7; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---- Trang /quanly ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem; margin-bottom: 1.25rem; }
.inp { width: 100%; min-height: 32px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line);
       padding: .3rem .7rem; font-size: 13px; color: var(--text); }
.inp:focus { outline: none; border-color: var(--brand); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; height: 32px; padding: 0 .9rem; border-radius: 6px;
       font-size: 13px; font-weight: 600; background: var(--brand); color: #fff; border: 1px solid var(--brand); box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--brand-hover); }
.btn:disabled { opacity: .5; }
.btn2 { display: inline-flex; align-items: center; gap: .35rem; height: 28px; padding: 0 .65rem; border-radius: 6px; font-size: 12.5px;
        border: 1px solid var(--line); background: var(--surface); color: #334155; box-shadow: var(--shadow-sm); }
.btn2:hover { background: #f5f9ff; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: 12px; font-weight: 500; }
.b-ok { background: #ecfdf3; color: #067647; }
.b-bad { background: #fef3f2; color: #b42318; }
.b-unknown { background: #f2f4f7; color: #475467; }
.page-quanly th { text-align: left; font-weight: 600; color: #334155; background: var(--th-bg); font-size: 12.5px; padding: .45rem .5rem; white-space: nowrap; border-bottom: 1px solid var(--line); }
.page-quanly td { padding: .35rem .5rem; font-size: 13px; border-top: 1px solid #e9eef6; vertical-align: top; }
.page-quanly nav a { padding: .4rem .75rem; border-radius: 6px; }
.page-quanly nav a:hover { background: var(--brand-soft); }
.page-quanly nav a.active { background: var(--brand); color: #fff; font-weight: 600; }

/* /quanly: tiêu đề trang thường (điểm nhấn màu mực đã nằm ở cột điều hướng) */
.page-quanly main > header h1 { font-size: 22px !important; letter-spacing: -.02em; }

/* Tôn trọng chế độ giảm chuyển động của hệ điều hành */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Điện thoại: hàng bộ lọc dưới thanh mực không xuống dòng mà cuộn ngang, để mẫu quảng cáo hiện ngay màn hình đầu */
@media (max-width: 639px) {
  header.sticky > div:first-child ~ div > div { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
  header.sticky > div:first-child ~ div > div::-webkit-scrollbar { display: none; }
  header.sticky > div:first-child ~ div > div > * { flex-shrink: 0; }
  header.sticky > div:first-child ~ div input[type="search"] { min-width: 220px !important; }
}

/* ---- Thẻ quảng cáo (static/js/common.js buildCard) ---- */
.run-chip { position: absolute; top: .55rem; left: .55rem; display: inline-flex; align-items: center; gap: .4rem;
  padding: .2rem .55rem; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4;
  background: rgba(255, 255, 255, .94); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 37, 71, .2); pointer-events: auto; }
.run-chip.run-live { color: #0b6b4c; }
.run-chip.run-off { color: #64748b; }
.run-chip.run-stale { color: #9a5b00; }
.run-dot { width: 7px; height: 7px; border-radius: 999px; background: #12a36f; box-shadow: 0 0 0 3px rgba(18, 163, 111, .18); }
.ad-body { padding: .8rem .9rem .7rem; display: flex; flex-direction: column; gap: .45rem; }
.ad-page { font-size: 14.5px !important; font-weight: 700; line-height: 1.3; color: var(--ink); word-break: break-word; }
.ad-page a { color: inherit; text-decoration: none; }
.ad-page a:hover { color: var(--signal); text-decoration: underline; }
.ad-meta { display: flex; flex-wrap: wrap; gap: .15rem .75rem; font-size: 12px; color: var(--muted); }
.ad-domain { color: var(--signal); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-domain:hover { text-decoration: underline; }
.ad-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.ad-tag { display: inline-flex; align-items: center; padding: .05rem .5rem; border-radius: 4px; font-size: 11.5px; font-weight: 500;
  background: #eef1f5; color: #334155; white-space: nowrap; }
a.ad-tag:hover { background: #e2e8f0; }
.ad-tag-cat { background: var(--brand-soft); color: var(--brand-hover); font-weight: 600; }
a.ad-tag-cat:hover { background: #d6e8fd; }
.ad-text { font-size: 13.5px; line-height: 1.5; color: #334155; }
.ad-more { align-self: flex-start; font-size: 12.5px; color: var(--signal); margin-top: -.2rem; }
.ad-more:hover { text-decoration: underline; }
.ad-actions { display: flex; border-top: 1px solid var(--line); }
.ad-actions a { flex: 1 1 0; text-align: center; padding: .55rem .5rem; font-size: 12.5px; font-weight: 600; color: var(--signal);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-actions a + a { border-left: 1px solid var(--line); }
.ad-actions a:hover { background: #f5f9ff; }

/* ---- Đầu trang (tiêu đề + 1 dòng số liệu) ---- */
.page-head { margin-bottom: 1.1rem; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); line-height: 1.25; }
.page-sub { margin-top: .2rem; font-size: 13.5px; color: var(--muted); }

/* ---- Nút "Bộ lọc" (chỉ hiện trên điện thoại) ---- */
.filter-toggle { display: none; align-items: center; gap: .4rem; height: 38px; padding: 0 .8rem; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.filter-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--signal); color: #fff; font-size: 11px; font-weight: 700; }
.filter-count[hidden] { display: none; }
@media (max-width: 639px) {
  .filter-toggle { display: inline-flex; }
  #search { flex: 1 1 auto !important; min-width: 0 !important; }
  /* Hàng đầu (ô tìm + bộ lọc): đóng thì chỉ còn ô tìm + nút; mở thì các ô chọn xuống dòng đầy đủ */
  body:not(.filters-open) header.sticky > div:first-child ~ div > div:first-child select { display: none; }
  body.filters-open header.sticky > div:first-child ~ div > div:first-child { flex-wrap: wrap !important; overflow: visible; }
  body.filters-open header.sticky > div:first-child ~ div > div:first-child select { flex: 1 1 45%; width: auto !important; }
  .page-head h1 { font-size: 19px; }
}
