:root {
  --bg: #f6f7f5; --surface: #ffffff; --surface-2: #f0f2ef; --text: #1b1f1d; --muted: #5d6661; --border: #dde2de;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e2f3f1;
  --good: #15803d; --good-bg: #e7f6ec; --mid: #a16207; --mid-bg: #fdf4dc; --weak: #b42318; --weak-bg: #fdecea;
  --unk: #52525b; --unk-bg: #ececef; --info-bg: #eaf1fb; --info: #1d4f91;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413; --surface: #1a1e1c; --surface-2: #222725; --text: #e8ece9; --muted: #9aa39e; --border: #2f3532;
    --accent: #2dd4bf; --accent-ink: #062a26; --accent-soft: #123430;
    --good: #4ade80; --good-bg: #12301d; --mid: #facc15; --mid-bg: #33290b; --weak: #f87171; --weak-bg: #3a1616;
    --unk: #a1a1aa; --unk-bg: #27272a; --info-bg: #152338; --info: #93c5fd;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 10; }
.top { border-bottom: 1px solid var(--border); background: var(--surface); }
.top-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-weight: 650; display: flex; gap: 8px; align-items: center; }
.logo { color: var(--accent); font-size: 20px; }
.mode { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--mid-bg); color: var(--mid); }
main.wrap { padding-top: 24px; padding-bottom: 32px; display: grid; gap: 20px; }
h1 { font-size: 24px; margin: 0 0 4px; } h2 { font-size: 18px; margin: 0; } h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.lead, .muted { color: var(--muted); } .lead { margin: 0 0 18px; max-width: 760px; }
.search-card, .panel, .product, .table-wrap, .sources, .summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.search-card { padding: 22px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.req { color: var(--weak); }
input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
input:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input[aria-invalid="true"] { border-color: var(--weak); }
.hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.err { margin: 4px 0 0; font-size: 13px; color: var(--weak); min-height: 0; } .err:empty { display: none; }
.actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.form-msg { color: var(--muted); font-size: 14px; }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); min-width: 140px; }
.btn.primary:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; font-weight: 500; }
.recent { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.chip-btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 99px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.panel { padding: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { display: flex; align-items: center; gap: 10px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.progress-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; margin-top: 12px; }
@media (max-width: 760px) { .progress-grid { grid-template-columns: 1fr; } }
.log { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; font-size: 14px; }
.log li { padding: 5px 0 5px 22px; position: relative; border-bottom: 1px dashed var(--border); }
.log li::before { content: "●"; position: absolute; left: 4px; font-size: 10px; top: 9px; color: var(--muted); }
.log li.ok::before { color: var(--good); } .log li.limited::before, .log li.partial::before { color: var(--mid); } .log li.running::before { color: var(--accent); }
.live-sources { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; font-size: 13px; }
.live-sources li { padding: 4px 0; border-bottom: 1px dashed var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel.error { border-color: var(--weak); background: var(--weak-bg); }
.panel.error h2 { color: var(--weak); margin-bottom: 6px; }
#results { display: grid; gap: 16px; }
.banner { padding: 12px 14px; border-radius: 10px; font-size: 14px; background: var(--info-bg); color: var(--info); }
.banner.warn { background: var(--mid-bg); color: var(--mid); }
.banner strong { font-weight: 650; }
.summary { padding: 16px 18px; display: grid; gap: 10px; }
.summary-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.summary-meta { font-size: 13px; color: var(--muted); }
.src-status { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.src-status .st { padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }
.summary ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
td a { font-weight: 600; text-decoration: none; }
.sig { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.sig.manh, .verdict.strong { background: var(--good-bg); color: var(--good); }
.sig.trung_binh, .verdict.medium { background: var(--mid-bg); color: var(--mid); }
.sig.yeu, .verdict.weak { background: var(--weak-bg); color: var(--weak); }
.sig.khong_du_du_lieu, .verdict.unknown { background: var(--unk-bg); color: var(--unk); }
.conf { font-size: 12px; color: var(--muted); white-space: nowrap; }
.verdict { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 650; }
.product { padding: 18px; scroll-margin-top: 12px; }
.product-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.product h3 { font-size: 18px; color: var(--text); text-transform: none; letter-spacing: 0; margin: 0 0 4px; font-weight: 650; }
.product .meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px 14px; flex-wrap: wrap; }
.product .desc { margin: 8px 0 12px; }
.dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 860px) { .dims { grid-template-columns: 1fr; } }
.dim { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-2); }
.dim-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.dim-title { font-weight: 650; font-size: 14px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; margin-right: 4px; }
.tag.fact { background: var(--info-bg); color: var(--info); } .tag.inf { background: var(--mid-bg); color: var(--mid); } .tag.conf { background: var(--unk-bg); color: var(--unk); }
.facts { list-style: none; margin: 0 0 8px; padding: 0; font-size: 14px; }
.facts li { padding: 4px 0; }
.cite { font-size: 12px; font-weight: 600; text-decoration: none; background: var(--accent-soft); padding: 0 5px; border-radius: 4px; margin-left: 3px; white-space: nowrap; }
.date { font-size: 12px; color: var(--muted); }
.inference { font-size: 14px; margin: 0; }
.conflict { font-size: 13px; color: var(--mid); margin: 6px 0 0; }
.nodata { font-size: 14px; color: var(--unk); font-style: italic; margin: 0 0 6px; }
.extra { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; font-size: 14px; }
@media (max-width: 700px) { .extra { grid-template-columns: 1fr; } }
.extra ul { margin: 4px 0 0; padding-left: 18px; }
.extra h4 { margin: 0; font-size: 13px; color: var(--muted); }
.rep-warn { margin-top: 10px; font-size: 13px; color: var(--muted); border-left: 3px solid var(--mid); padding-left: 10px; }
.product-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.feedback { display: flex; gap: 6px; align-items: center; }
.feedback .on { background: var(--accent-soft); border-color: var(--accent); }
.sources { padding: 16px 18px; }
.sources ol { margin: 0; padding-left: 0; list-style: none; font-size: 14px; }
.sources li { padding: 8px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 44px 1fr; gap: 8px; scroll-margin-top: 12px; }
.sources li:target { background: var(--accent-soft); }
.sid { font-weight: 700; color: var(--accent); }
.sources .sub { font-size: 12px; color: var(--muted); }
.rel { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.rel.cao { background: var(--good-bg); color: var(--good); } .rel.trung_binh { background: var(--mid-bg); color: var(--mid); } .rel.thap { background: var(--weak-bg); color: var(--weak); } .rel.chua_danh_gia { background: var(--unk-bg); color: var(--unk); }
.empty { text-align: center; padding: 32px 20px; }
.empty h2 { margin-bottom: 8px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.method { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; }
.method summary { cursor: pointer; font-weight: 600; }
.method-body { font-size: 14px; color: var(--muted); }
.disclaimer { color: var(--weak); font-weight: 600; }
.foot { color: var(--muted); font-size: 12px; padding-bottom: 24px; }

/* ---------- Tài khoản, thanh người dùng ---------- */
.userbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.uname { font-weight: 600; font-size: 14px; }
.quota { font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 3px 10px; border-radius: 99px; }
a.btn { text-decoration: none; display: inline-block; white-space: nowrap; }
@media (max-width: 640px) { .top-inner { height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; gap: 8px; } .quota { display: none; } }
.auth-page { display: grid; place-items: center; min-height: 100vh; }
.auth-wrap { width: 100%; max-width: 400px; padding: 24px 16px; display: grid; gap: 16px; }
.auth-brand { font-weight: 700; font-size: 18px; text-align: center; display: flex; gap: 8px; justify-content: center; align-items: center; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 20px; }
.auth-card .muted { margin: 0; font-size: 14px; }
.btn.wide { width: 100%; }
select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }

/* ---------- Quản trị ---------- */
.admin { gap: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
[data-panel] { display: grid; gap: 16px; }
[data-panel][hidden] { display: none; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 860px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-val { font-size: 26px; font-weight: 700; margin: 2px 0; }
.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.meter span { display: block; height: 100%; background: var(--accent); }
.meter span.hot { background: var(--weak); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.panel h2 { margin-bottom: 10px; }
ul.plain { list-style: none; margin: 0; padding: 0; font-size: 14px; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.row-actions { display: inline-flex; gap: 6px; margin-left: 8px; }
.small { font-size: 12px; }
.sev { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.sev.alert { background: var(--weak-bg); color: var(--weak); } .sev.warn { background: var(--mid-bg); color: var(--mid); }
.sev.info { background: var(--unk-bg); color: var(--unk); } .sev.ok { background: var(--good-bg); color: var(--good); }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form .field { min-width: 160px; flex: 1; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: auto; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 760px; }
.settings-grid h2, .settings-grid .hint, .settings-grid .check, .settings-grid > div:last-child { grid-column: 1 / -1; }
@media (max-width: 640px) { .settings-grid { grid-template-columns: 1fr; } }
.dlg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 22px; width: min(520px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg form { display: grid; gap: 12px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr; } }
.danger-zone { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--border); }
.secret { background: var(--surface-2); border-radius: 8px; padding: 12px; font-size: 15px; display: grid; gap: 4px; }
.secret code { font-size: 16px; font-weight: 700; letter-spacing: .03em; }
