/* VietFina — design tokens & styles. See docs/design-guidelines.md.
   Phong cách "tài liệu tham khảo dữ liệu": trung lập, số liệu là trung tâm.
   Mọi màu/cỡ đi qua token trong :root; dark mode chỉ override token. */

:root {
	--fg: #1a1f29;
	--muted: #5b6573;
	--bg: #ffffff;
	--surface: #f7f9fb;
	--border: #e7eaee;
	--accent: #1f4e6b;
	--accent-dark: #163a50;
	--accent-weak: #eef3f7;
	--accent-contrast: #ffffff;
	--pos: #1f7a5a;
	--neg: #b04a3f;
	--row-alt: var(--surface);

	--max: 1040px;          /* trang dữ liệu / hồ sơ / bảng */
	--max-prose: 720px;     /* trang trust / tĩnh */
	--header-h: 58px;       /* cao header sticky — offset cho thead bảng & TOC dính dưới header */

	--font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	--font-serif: "Lora", "Source Serif 4", Georgia, "Times New Roman", serif;
	--font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, monospace;

	--shadow-sticky: 0 1px 2px rgba(15, 20, 25, .05);
}

/* Dark mode — theo hệ thống, trừ khi người dùng đã chọn thủ công ([data-theme]). */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--fg: #e6e9ee;
		--muted: #9aa4b2;
		--bg: #0f1419;
		--surface: #171d25;
		--border: #2a313c;
		--accent: #6fb3d6;
		--accent-dark: #9ccbe4;
		--accent-weak: #1a2733;
		--accent-contrast: #0f1419;
		--pos: #4cae8a;
		--neg: #d97b6f;
		--shadow-sticky: 0 1px 2px rgba(0, 0, 0, .4);
	}
}

[data-theme="dark"] {
	--fg: #e6e9ee;
	--muted: #9aa4b2;
	--bg: #0f1419;
	--surface: #171d25;
	--border: #2a313c;
	--accent: #6fb3d6;
	--accent-dark: #9ccbe4;
	--accent-weak: #1a2733;
	--accent-contrast: #0f1419;
	--pos: #4cae8a;
	--neg: #d97b6f;
	--shadow-sticky: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
	margin: 0;
	font-family: var(--font-sans);
	color: var(--fg);
	background: var(--bg);
	line-height: 1.6;
	-webkit-text-size-adjust: 100%;
}

.container { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* Tabular figures everywhere numbers are tabulated. */
.bctc-table, .data-table, .ratio-table, .bctc-long-table,
.info-table td, .metric-value, .listing-table, .peer-table, .hub-count {
	font-variant-numeric: tabular-nums;
}

/* Headings — serif editorial. */
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; }
h1 { font-size: 1.75rem; line-height: 1.25; margin: 0 0 8px; }
h2 { margin-top: 32px; font-size: 1.2rem; }

/* ── Header ── */
.site-header {
	position: sticky; top: 0; z-index: 20;
	background: color-mix(in srgb, var(--bg) 92%, transparent);
	backdrop-filter: saturate(150%) blur(6px);
	border-bottom: 1px solid var(--border);
	padding: 10px 0;
}
.site-header .container { display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-serif); font-weight: 700; font-size: 1.25rem; color: var(--accent-dark); }
.brand:hover { text-decoration: none; }
/* Logo mark inherits the brand link colour (currentColor) → adapts to dark mode. */
.brand-mark { height: 0.95em; width: auto; display: block; flex: none; }
.header-search { margin-left: auto; flex: 1; max-width: 360px; }
.header-search input {
	width: 100%; height: 38px; padding: 0 12px; font: inherit;
	color: var(--fg); background: var(--surface);
	border: 1px solid var(--border); border-radius: 8px;
}
.header-search input::placeholder { color: var(--muted); }
.header-search input:focus { outline: none; border-color: var(--accent); }

.theme-toggle {
	flex-shrink: 0; width: 38px; height: 38px;
	display: inline-flex; align-items: center; justify-content: center;
	font-size: 1.1rem; line-height: 1; cursor: pointer;
	color: var(--muted); background: transparent;
	border: 1px solid var(--border); border-radius: 8px;
}
.theme-toggle:hover { color: var(--fg); background: var(--surface); }

/* ── Hero / search ── */
.hero { padding: 56px 0 28px; text-align: center; }
.hero h1 { font-size: 2rem; margin: 0 0 10px; }
.hero-sub { color: var(--muted); margin: 0 auto 26px; max-width: 620px; }
.search-box { position: relative; max-width: 580px; margin: 0 auto; }
.search-box > input {
	width: 100%; padding: 14px 16px; font-size: 1.05rem; font-family: inherit;
	color: var(--fg); background: var(--bg);
	border: 1px solid var(--border); border-radius: 10px;
}
.search-box > input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.search-results { position: relative; text-align: left; }

/* ── Result list ── */
.result-list { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.result-list li + li { border-top: 1px solid var(--border); }
.result-list a { display: flex; align-items: baseline; gap: 10px; padding: 11px 14px; color: var(--fg); }
.result-list a:hover { background: var(--surface); text-decoration: none; }
.result-ticker { font-family: var(--font-mono); font-weight: 700; color: var(--accent-dark); min-width: 64px; }
.result-name { flex: 1; }
.result-exchange { color: var(--muted); font-size: 0.85rem; }

/* ── Search results page (/tim-kiem?q=) ── */
.search-page { padding: 8px 0 40px; }
.search-head { margin: 4px 0 20px; }
.search-head h1 { margin: 0 0 6px; }
.search-summary { color: var(--muted); margin: 0; }
.search-summary strong { color: var(--fg); font-weight: 600; }
.search-term { color: var(--accent-dark); font-weight: 600; }
.search-refine { display: flex; gap: 8px; max-width: 580px; margin: 0 0 24px; }
.search-refine input {
	flex: 1; min-width: 0; padding: 12px 14px; font-size: 1rem; font-family: inherit;
	color: var(--fg); background: var(--bg);
	border: 1px solid var(--border); border-radius: 8px;
}
.search-refine input::placeholder { color: var(--muted); }
.search-refine input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.search-refine button {
	padding: 0 18px; font-family: inherit; font-size: 0.95rem; font-weight: 600; white-space: nowrap;
	color: var(--accent-contrast); background: var(--accent);
	border: 1px solid var(--accent); border-radius: 8px; cursor: pointer;
}
.search-refine button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
/* Fragment (HTMX autocomplete) và trạng thái rỗng full-page dùng chung .search-empty */
.search-empty { padding: 14px 0; color: var(--muted); }
.search-empty p { margin: 0; }
.search-hint { font-size: 0.9rem; margin-top: 6px !important; }
/* Full-page: khoảng cách trên danh sách kết quả rộng hơn dropdown (6px) */
.search-page .result-list { margin-top: 0; }

/* ── Breadcrumb / tags ── */
.breadcrumb { color: var(--muted); font-size: 0.9rem; margin: 16px 0; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
/* Masthead — tiêu đề trang ngăn cách nội dung bằng 1 đường kẻ mảnh (§4).
   Dùng chung cho trang hồ sơ (.company) và BCTC (.financial). */
.company-header, .financial-header { margin: 6px 0 0; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
/* Hồ sơ: tên (serif) + ticker badge cùng baseline, hàng tag bên dưới. */
.company-header h1 { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; }
.company-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.company-tags .tag { margin-right: 0; }
.tag {
	display: inline-block; background: var(--surface); border: 1px solid var(--border);
	border-radius: 6px; padding: 2px 9px; font-size: 0.85rem; margin-right: 6px; color: var(--fg);
}
a.tag:hover { background: var(--accent-weak); text-decoration: none; }
.ticker-badge {
	font-family: var(--font-mono); font-size: 0.95rem; font-weight: 600;
	background: var(--accent-weak); color: var(--accent-dark);
	padding: 2px 9px; border-radius: 6px; vertical-align: middle;
}

/* ── Profile intro narrative (rule-based, D7) — câu đầu là "standfirst" hơi to. */
.company-intro { margin: 20px 0 4px; max-width: 70ch; }
.company-intro p { margin: 0 0 12px; color: var(--fg); line-height: 1.75; }
.company-intro p:first-child { font-size: 1.08rem; }
.company-intro p:last-child { margin-bottom: 0; }

/* Section micro-intro caption (one line under a section heading). */
.section-intro { margin: 0 0 14px; color: var(--muted); font-size: 0.92rem; max-width: 72ch; }

/* ── Section rhythm — mỗi section cách ~40px; heading có đường kẻ mảnh + 1 vạch
   accent ngắn (design-guidelines §3–4). Dùng cho hồ sơ (.company) & BCTC (.financial). */
.company > section > h2,
.financial > section > h2 {
	position: relative; margin-top: 40px; padding-top: 18px;
	border-top: 1px solid var(--border);
}
.company > section > h2::before,
.financial > section > h2::before {
	content: ""; position: absolute; top: -1px; left: 0;
	width: 40px; height: 2px; background: var(--accent);
}
/* Anchor jump (hồ sơ) không bị header + TOC sticky (~54px) che mất tiêu đề. */
.company > section[id] { scroll-margin-top: calc(var(--header-h) + 54px); }

/* Consolidated data-source / freshness block (E-E-A-T, YMYL). */
.profile-source { margin: 40px 0 8px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.profile-source h2 { font-size: 1rem; margin: 0 0 6px; }
.profile-source p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.6; max-width: 80ch; }

/* ── Buttons / notices ── */
.btn { display: inline-block; background: var(--accent); color: var(--accent-contrast); padding: 10px 18px; border-radius: 8px; font-weight: 500; }
.btn:hover { background: var(--accent-dark); color: var(--accent-contrast); text-decoration: none; }
.cta { margin: 20px 0; }
.notice {
	background: var(--surface); border: 1px solid var(--border);
	border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 14px; color: var(--muted);
}

/* ── Tables ── */
.info-table, .bctc-table { width: 100%; border-collapse: collapse; }
.info-table th, .info-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.info-table th { width: 220px; color: var(--muted); font-weight: 500; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.bctc-table th, .bctc-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
/* Ma trận nhiều năm cuộn ngang trong .table-wrap (overflow:auto) → thead chỉ
   neo top:0 trong container (tránh "trôi" giữa bảng); cột chỉ tiêu đầu dính trái. */
.bctc-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; }
.bctc-table th[scope="row"] {
	text-align: left; font-weight: 500;
	position: sticky; left: 0; background: var(--bg); z-index: 1;
}
.bctc-table thead th:first-child { left: 0; z-index: 3; }
.bctc-table tbody tr:nth-child(even) th[scope="row"] { background: var(--surface); }
.bctc-table tbody tr:nth-child(even) { background: var(--surface); }
.bctc-table tbody tr:hover td, .bctc-table tbody tr:hover th[scope="row"] { background: var(--accent-weak); }
.unit-note, .source-note { color: var(--muted); font-size: 0.85rem; }

/* ── Year switch — DN có thể có 20+ năm BCTC nên dùng chip rời (pill có gap),
   wrap nhiều dòng gọn gàng thay vì 1 thanh segmented liền (tránh viền gãy khi
   xuống dòng). Năm đang chọn tô đặc accent. ── */
.year-switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.year {
	padding: 5px 12px; border: 1px solid var(--border); border-radius: 8px;
	color: var(--accent); background: var(--bg);
	font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.year:hover { background: var(--surface); text-decoration: none; }
.year.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: 600; }

/* ── Narrative ── */
.narrative p { margin: 0 0 12px; }

/* ── Static pages ── */
.static-page { max-width: var(--max-prose); }
.static-page h2 { border-top: 1px solid var(--border); padding-top: 18px; }
.static-page li { margin: 4px 0; }

/* ── P1 enrichment ── */

/* Mục lục — dính dưới header trang khi cuộn, đóng vai nav phụ. */
.profile-toc {
	position: sticky; top: var(--header-h); z-index: 10;
	margin: 22px 0; padding: 10px 14px;
	background: color-mix(in srgb, var(--bg) 92%, transparent);
	backdrop-filter: saturate(150%) blur(6px);
	border: 1px solid var(--border); border-radius: 10px;
}
.profile-toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.profile-toc a { font-size: 0.9rem; color: var(--muted); }
.profile-toc a:hover { color: var(--accent); }
/* Mobile: 12 mục wrap 4 dòng chiếm cả màn khi sticky → ép 1 hàng cuộn ngang. */
@media (max-width: 720px) {
	.profile-toc { padding: 8px 12px; }
	.profile-toc ul { flex-wrap: nowrap; overflow-x: auto; gap: 0 18px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
	.profile-toc ul::-webkit-scrollbar { display: none; }
	.profile-toc li { flex: none; }
	.profile-toc a { white-space: nowrap; }
}

.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.metric { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.metric-label { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.metric-value { font-weight: 600; font-size: 1.05rem; }
.data-asof { color: var(--muted); font-size: 0.85rem; margin-top: 10px; }
.data-caveat { color: var(--muted); font-size: 0.85rem; margin-top: 12px; padding: 8px 12px; border-left: 3px solid var(--border); background: var(--surface); border-radius: 6px; max-width: 80ch; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; vertical-align: top; }
.data-table thead th { background: var(--surface); }
.data-table th[scope="row"], .data-table thead th:first-child { text-align: left; white-space: normal; }
.data-table th[scope="row"] { font-weight: 500; }
.data-table tbody tr:nth-child(even) { background: var(--surface); }
.data-table tbody tr:hover { background: var(--accent-weak); }

.ratio-group { border: 1px solid var(--border); border-radius: 10px; margin: 8px 0; overflow: hidden; }
/* .ratio-group đã là khung bo góc → bảng bên trong bỏ viền/radius riêng (tránh
   2 khung lồng nhau lệch góc). */
.ratio-group .table-wrap { border: none; border-radius: 0; }
.ratio-group summary { cursor: pointer; padding: 11px 14px; font-weight: 500; }
.ratio-group[open] summary { border-bottom: 1px solid var(--border); }
.ratio-table { width: 100%; border-collapse: collapse; }
.ratio-table th, .ratio-table td { padding: 7px 14px; border-bottom: 1px solid var(--border); }
.ratio-table th { text-align: left; font-weight: 400; color: var(--muted); }
.ratio-table td { text-align: right; white-space: nowrap; }
.ratio-table tr:last-child th, .ratio-table tr:last-child td { border-bottom: none; }

/* Ranking breakdown */
.ranking-summary { margin: 8px 0 14px; }
.rank-up { color: var(--pos); margin-left: 8px; }
.rank-down { color: var(--neg); margin-left: 8px; }
.score-bars { list-style: none; margin: 0; padding: 0; }
.score-bars li { display: grid; grid-template-columns: minmax(160px, 220px) 1fr 44px; align-items: center; gap: 12px; padding: 6px 0; }
.score-label { color: var(--muted); }
.score-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.score-bar { width: 100%; height: 10px; -webkit-appearance: none; appearance: none; border: none; border-radius: 6px; background: var(--surface); overflow: hidden; }
/* <meter> semantics for a static score; keep a single accent fill (no good/warn/bad tint). */
.score-bar::-webkit-meter-bar { background: var(--surface); border: none; border-radius: 6px; height: 10px; }
.score-bar::-webkit-meter-optimum-value,
.score-bar::-webkit-meter-suboptimum-value,
.score-bar::-webkit-meter-even-less-good-value { background: var(--accent); border-radius: 6px; }
.score-bar::-moz-meter-bar { background: var(--accent); border-radius: 6px; }

/* Documents list */
.doc-list { list-style: none; margin: 12px 0 0; padding: 0; }
.doc-list li { padding: 9px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.doc-date { color: var(--muted); font-size: 0.85rem; min-width: 92px; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* History timeline */
.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.timeline li { padding: 9px 0 9px 14px; border-left: 2px solid var(--border); display: flex; gap: 12px; }
.timeline-date { color: var(--muted); font-size: 0.85rem; min-width: 92px; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ── Footer ── */
.site-footer { border-top: 1px solid var(--border); margin-top: 56px; padding: 32px 0; color: var(--muted); font-size: 0.9rem; }
.footer-cols { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 24px; }
.footer-col { display: flex; flex-direction: column; gap: 8px; }
.footer-col a { color: var(--muted); }
.footer-col a:hover { color: var(--accent); }
.footer-head { font-family: var(--font-sans); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg); font-weight: 600; margin: 0 0 2px; }
.footer-about { gap: 6px; }
.footer-brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-serif); font-weight: 700; font-size: 1.15rem; color: var(--accent-dark); }
.footer-brand:hover { color: var(--accent-dark); }
.footer-tagline { margin: 0; max-width: 30ch; }
.footer-note { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--border); }

@media (max-width: 640px) {
	.footer-cols { grid-template-columns: 1fr 1fr; }
	.footer-about { grid-column: 1 / -1; }
}

/* ── P2: long-form statement, report tabs ── */
.report-tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.report-tabs .detail-label { color: var(--muted); font-size: 0.9rem; margin-right: 4px; }
.report-tabs .tab { padding: 5px 14px; border: 1px solid var(--border); border-radius: 18px; font-size: 0.9rem; text-decoration: none; color: var(--accent); }
.report-tabs .tab:hover { background: var(--surface); }
.report-tabs .tab.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.bctc-long-table { width: 100%; border-collapse: collapse; }
.bctc-long-table th, .bctc-long-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
/* Bảng chi tiết chỉ 2 cột (không cần cuộn ngang) → wrap để overflow:visible nên
   thead sticky neo theo VIEWPORT, dính dưới header trang khi cuộn bảng dài. */
.statement-long .table-wrap { overflow: visible; }
.bctc-long-table thead th { position: sticky; top: var(--header-h); background: var(--surface); text-align: right; z-index: 2; }
.bctc-long-table th[scope="row"] { text-align: left; font-weight: 400; }
.bctc-long-table td { text-align: right; white-space: nowrap; }
.bctc-long-table tbody tr:nth-child(even) { background: var(--surface); }
.bctc-long-table tbody tr:hover { background: var(--accent-weak); }
.bctc-long-table tr.depth-0 th { font-weight: 700; }
.bctc-long-table tr.depth-1 th { padding-left: 1.2rem; }
.bctc-long-table tr.depth-2 th { padding-left: 2.4rem; }
.bctc-long-table tr.depth-3 th { padding-left: 3.6rem; color: var(--muted); }

/* ── P2: sector/exchange listing ── */
.listing-header { margin-bottom: 12px; }
.listing-count { color: var(--muted); }
.listing-table td, .listing-table th[scope="row"] { white-space: nowrap; }
.listing-table th[scope="row"] { text-align: left; font-weight: 400; white-space: normal; }
.pagination { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 20px 0; }
.page-current { color: var(--muted); }

/* ── P2: peer comparison ── */
.peer-intro { color: var(--muted); margin: 4px 0 12px; }
.peer-table td { text-align: right; white-space: nowrap; }

/* ── Home: hero stats ── */
.hero-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 0; margin: 28px auto 0; max-width: 560px; }
.hero-stat { flex: 1; min-width: 130px; padding: 0 18px; text-align: center; }
.hero-stat + .hero-stat { border-left: 1px solid var(--border); }
.hero-stat dt { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.hero-stat dd { margin: 4px 0 0; font-family: var(--font-serif); font-weight: 600; font-size: 1.5rem; color: var(--accent-dark); font-variant-numeric: tabular-nums; }
.hero-stat-note { display: block; font-family: var(--font-sans); font-weight: 400; font-size: 0.72rem; color: var(--muted); letter-spacing: 0; }

/* ── Home: feature cards ── */
.features { margin: 44px 0; }
.feature-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.feature { padding: 18px 18px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.feature-title { margin: 0 0 6px; font-size: 1.02rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.94rem; }
.features-note { margin: 16px 0 0; color: var(--muted); font-size: 0.9rem; }

/* ── Home: featured-companies leaderboard ── */
.rank-grid { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.rank-card { position: relative; }
.rank-card > a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--fg); }
.rank-card > a:hover { background: var(--surface); }
.rank-no { flex-shrink: 0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent-dark); background: var(--accent-weak); border-radius: 7px; }
.rank-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.rank-ticker { font-family: var(--font-mono); font-weight: 700; color: var(--accent-dark); }
.rank-name { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-cap { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.rank-cap-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-cap-unit { font-size: 0.72rem; color: var(--muted); }

/* ── Home: discover (sectors + exchanges, two columns) ── */
.discover { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; margin: 44px 0; align-items: start; }
.venue-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.venue-item > a { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; color: var(--fg); }
.venue-item > a:hover { background: var(--surface); }
.venue-code { font-family: var(--font-mono); font-weight: 700; color: var(--accent-dark); }
.venue-count { color: var(--muted); font-size: 0.85rem; }

@media (max-width: 760px) {
	.discover { grid-template-columns: 1fr; gap: 32px; }
}

/* ── Home: FAQ accordion ── */
.home-faq, .company-faq, .financial-faq { margin: 44px 0; }
.faq-list { margin: 14px 0 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.faq-item { border-top: 1px solid var(--border); }
.faq-item:first-child { border-top: none; }
.faq-item > summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 1.2rem; line-height: 1; }
.faq-item[open] > summary::after { content: "\2212"; }
.faq-item > summary:hover { background: var(--surface); }
.faq-item > p { margin: 0; padding: 0 16px 16px; color: var(--muted); max-width: 72ch; }

/* ── SEO interlinking: hubs + home blocks ── */
.hub-header { margin: 16px 0; }
.hub-header p { color: var(--muted); }
.hub-grid { list-style: none; margin: 12px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.hub-item { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 11px 13px; }
.hub-item:hover { background: var(--surface); }
.hub-count { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
/* Hub explanatory body: prose-width, dividers like .static-page (E-E-A-T). */
.hub-content { max-width: var(--max-prose); margin: 36px 0 0; }
.hub-content h2 { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 28px; }
.hub-content p { color: var(--muted); }
.hub-highlights { margin: 10px 0; padding-left: 20px; }
.hub-highlights li { margin: 5px 0; color: var(--muted); }
.hub-venues { margin: 12px 0; }
.hub-venues dt { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; margin-top: 14px; }
.hub-venues dd { margin: 4px 0 0; color: var(--muted); }
/* Listing page explanatory body (page 1 only). */
.listing-lead { color: var(--muted); max-width: var(--max-prose); margin: 8px 0 0; }
.listing-content { max-width: var(--max-prose); margin: 40px 0 0; }
.listing-content h2 { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 28px; }
.listing-content p { color: var(--muted); }
/* Sector aggregate stat strip (page 1). */
.listing-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.listing-stats .stat { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; min-width: 120px; }
.listing-stats .stat-wide { flex: 1 1 100%; }
.listing-stats .stat-label { color: var(--muted); font-size: 0.8rem; }
.listing-stats .stat-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.listing-stats .stat-sep { color: var(--border); margin: 0 6px; }
.home-block { margin: 44px 0; }
.home-block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.home-block-sub, .home-block-all { color: var(--muted); font-size: 0.9rem; }

/* ── SI-3: related companies ── */
.related-companies { margin: 28px 0; }
.related-grid { list-style: none; margin: 12px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.related-grid a { display: flex; align-items: baseline; gap: 8px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; color: var(--fg); }
.related-grid a:hover { background: var(--surface); text-decoration: none; }
.related-grid .top-ticker { font-family: var(--font-mono); font-weight: 700; color: var(--accent-dark); }

/* ── SI-3: pagination ── */
.pagination .page-link.current { background: var(--accent); color: var(--accent-contrast); border-radius: 6px; }
.pagination .page-num { display: flex; gap: 4px; align-items: baseline; }
.pagination .page-num a, .pagination .page-num span { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; }
.pagination .page-ellipsis { border: none; color: var(--muted); }
.peer-table td:last-child { text-align: left; color: var(--muted); }

/* ── Block-level clickability (stretched-link) ──
   Cả khối/hàng có link thì click ở đâu cũng điều hướng, không chỉ chữ link.
   Container đặt position:relative; link con phủ overlay inset:0.
   .result-list/.related-grid/.rank-card không cần vì <a> đã phủ kín khối. */
.hub-item > a::after {
	content: ""; position: absolute; inset: 0;
}
/* Listing table: click cả hàng → trang doanh nghiệp (overlay từ ô tên). */
.listing-table tbody tr { position: relative; }
.listing-table th[scope="row"] a::after {
	content: ""; position: absolute; inset: 0;
}
/* Con trỏ tay trên toàn hàng listing để báo hiệu khối click được. */
.listing-table tbody tr { cursor: pointer; }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; animation: none !important; }
}
