:root {
  --brand: #0b5cad; --brand-dark: #08457f; --brand-soft: #e8f1fb;
  --ink: #1b2733; --ink-2: #4a5866; --ink-3: #6f7c89;
  --line: #dde3ea; --bg: #f5f7fa; --surface: #fff;
  --ok: #0a7d32; --ok-soft: #e6f4ea; --warn-soft: #fff6e0; --warn: #8a5a00;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,32,48,.06), 0 4px 16px rgba(16,32,48,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid #f2a600; outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand b { display: block; font-size: 16px; }
.brand small { display: block; color: var(--ink-3); font-size: 12px; }
.logo svg { width: 36px; height: 36px; fill: var(--brand); stroke: none; color: var(--brand); }
.logo svg path:last-child { stroke: var(--brand); stroke-width: 2; fill: none; }
.top-nav { display: flex; align-items: center; gap: 4px; }
.top-nav a { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.top-nav a:hover { background: var(--bg); color: var(--ink); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600;
  padding: 9px 16px; border-radius: 10px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-dark); }
.btn-ghost { background: var(--surface); color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn svg { width: 18px; height: 18px; }

/* Hero */
.hero { background: linear-gradient(180deg, var(--brand) 0%, #0d6cc7 100%); color: #fff; padding: 44px 0 56px; }
.hero h1 { font-size: 30px; }
.hero p { margin: 0 0 20px; opacity: .92; max-width: 680px; }
.search { display: flex; background: #fff; border-radius: 14px; padding: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: 760px; }
.search input { flex: 1; border: 0; font: inherit; font-size: 16px; padding: 10px 12px; color: var(--ink); min-width: 0; background: transparent; }
.search input:focus { outline: none; }
.search .btn { border-radius: 10px; }
.suggest { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.suggest span { font-size: 14px; opacity: .9; margin-right: 4px; }
.chip { border: 1px solid rgba(255,255,255,.45); background: rgba(255,255,255,.12); color: #fff; font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.chip:hover { background: rgba(255,255,255,.22); }

/* Lĩnh vực */
.section { padding: 28px 0; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-h h2 { font-size: 20px; margin: 0; }
.fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: -40px; }
.field { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-align: left; font: inherit; cursor: pointer; box-shadow: var(--shadow); color: var(--ink); }
.field b { display: block; }
.field small { color: var(--ink-3); }
.field:hover, .field.on { border-color: var(--brand); }
.field.on { background: var(--brand-soft); }

/* Bộ lọc + danh sách */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.filters label { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); }
.filters .count { margin-left: auto; color: var(--ink-3); font-size: 14px; }
.linkbtn { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 4px; text-decoration: underline; }
.list { display: grid; gap: 12px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.card h3 { font-size: 17px; margin: 0 0 4px; color: var(--brand-dark); }
.card .sub { color: var(--ink-3); font-size: 14px; }
.card .match { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; font-size: 14px; color: var(--ink-2); }
.facts span { display: inline-flex; gap: 6px; align-items: center; }
.facts svg { width: 16px; height: 16px; color: var(--ink-3); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--ink-2); }

/* Chi tiết */
.crumb { font-size: 14px; color: var(--ink-3); padding: 18px 0 6px; }
.crumb a { color: var(--ink-2); }
.detail-h { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.detail-h h1 { font-size: 26px; margin-bottom: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile small { display: flex; gap: 6px; align-items: center; color: var(--ink-3); font-size: 13px; margin-bottom: 4px; }
.tile small svg { width: 16px; height: 16px; }
.tile div { font-weight: 600; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.box h2 { font-size: 18px; }
.box ol, .box ul { margin: 0; padding-left: 22px; }
.box li + li { margin-top: 6px; }
.docs { width: 100%; border-collapse: collapse; font-size: 14px; }
.docs th, .docs td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.docs th { color: var(--ink-3); font-weight: 600; font-size: 13px; }
.docs td:first-child { width: 36px; color: var(--ink-3); }
.docs .note { display: block; color: var(--ink-3); font-size: 13px; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.fee label { display: block; font-size: 14px; color: var(--ink-2); margin: 10px 0 4px; }
.fee input, .fee select { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.fee .total { margin-top: 14px; padding: 12px; background: var(--brand-soft); border-radius: 10px; }
.fee .total b { font-size: 22px; color: var(--brand-dark); display: block; }
.fee p { font-size: 13px; color: var(--ink-3); margin: 8px 0 0; }

/* Footer */
.foot { border-top: 1px solid var(--line); background: var(--surface); margin-top: 40px; padding: 20px 0 90px; color: var(--ink-3); font-size: 13px; }
.loading { padding: 60px 20px; color: var(--ink-3); }

/* Nút nổi + khung chat */
.fab { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: inline-flex; gap: 8px; align-items: center; background: var(--brand); color: #fff; border: 0;
  border-radius: 999px; padding: 12px 18px; font: inherit; font-weight: 600; cursor: pointer; box-shadow: 0 6px 20px rgba(11,92,173,.35); }
.fab:hover { background: var(--brand-dark); }
.fab svg { fill: none; }
body.chat-open .fab { display: none; }
.chat { position: fixed; right: 20px; bottom: 20px; width: 400px; height: min(640px, calc(100vh - 100px)); z-index: 40; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgba(16,32,48,.22); display: flex; flex-direction: column; overflow: hidden; }
.chat[hidden] { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 12px 16px; background: var(--brand); color: #fff; }
.chat-head .mode { font-size: 11px; font-weight: 600; background: rgba(255,255,255,.2); padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.icon-btn { background: none; border: 0; color: inherit; padding: 6px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: rgba(255,255,255,.15); }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin: 0; }
.msg ul, .msg ol { margin: 4px 0 6px; padding-left: 20px; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .cite { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 6px; background: var(--brand-soft); text-decoration: none; }
.msg .src { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.msg .src a { display: block; text-decoration: none; padding: 2px 0; }
.msg .meta { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.msg.warn { align-self: stretch; max-width: none; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .25; } }
.chat-hello { color: var(--ink-2); font-size: 14px; }
.chat-hello .qs { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.chat-hello button { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
.chat-hello button:hover { border-color: var(--brand); }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; resize: none; font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; max-height: 120px; }
.send { background: var(--brand); color: #fff; border: 0; border-radius: 10px; width: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.send:disabled { opacity: .5; cursor: default; }
.chat-note { margin: 0; padding: 0 12px 10px; font-size: 12px; color: var(--ink-3); }

/* Máy tính bảng, điện thoại */
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .fields { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .top-nav a { display: none; }
  .brand small { display: none; }
  .hero { padding: 28px 0 52px; }
  .hero h1 { font-size: 24px; }
  .search .btn span { display: none; }
  .detail-h h1 { font-size: 22px; }
  .filters .count { margin-left: 0; width: 100%; }
  .chat { inset: 0; width: auto; height: auto; border-radius: 0; border: 0; }
  body.chat-open { overflow: hidden; }
  .fab span { display: none; }
  .fab { padding: 14px; }
  .docs th:nth-child(3), .docs td:nth-child(3) { display: none; }
}

/* In trang chi tiết */
@media print {
  .top, .fab, .chat, .foot, .actions, .crumb, .fee-box { display: none !important; }
  body { background: #fff; }
  .grid2 { grid-template-columns: 1fr; }
  .box, .tile { border-color: #999; break-inside: avoid; }
}
