/* Orbit — hệ thống thiết kế (tokens → thành phần). Be Vietnam Pro tự host qua /fonts/fonts.css. */
:root,
:root[data-theme="light"] {
  --bg: #f3f6f6;
  --surface: #ffffff;
  --surface-2: #eaf0f0;
  --line: #cfdadb;
  --ink: #13272b;
  --ink-2: #33474b;
  --muted: #54666a;
  --teal: #0b6a60;
  --teal-fill: #2c9081;
  --accent-soft: #dff1ee;
  --c-views: #1f8274;
  --c-sessions: #4a70c4;
  --c-conv: #cf6f21;
  --c-cvr: #7a58bd;
  --c-organic: #1f8274;
  --c-direct: #4a70c4;
  --c-referral: #cf6f21;
  --c-social: #7a58bd;
  --danger: #b3321f;
  --danger-bg: #fdebe7;
  --warn-ink: #7f4600;
  --warn-bg: #fff2dc;
  --warn-line: #e8c58a;
  --ok-ink: #0b6a52;
  --ok-bg: #e0f3ec;
  --focus: #1c5fd6;
  --shadow: 0 1px 2px rgba(19, 39, 43, 0.06), 0 4px 14px rgba(19, 39, 43, 0.05);
  --side-bg: #123e41;
  --side-ink: #cfe0df;
  --side-muted: #a4bfbe;
  --side-line: #3b6769;
  --hm0: #eef3f3; --hm1: #cfe9e4; --hm2: #8fcfc3; --hm3: #26796c; --hm4: #0f5c52;
  --hm0-ink: #54666a; --hm1-ink: #0e4a42; --hm2-ink: #0b3f38; --hm3-ink: #ffffff; --hm4-ink: #ffffff;
  --radius: 10px;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.875rem;
  --touch: 2.25rem;
}

:root[data-theme="dark"] {
  --bg: #0b181b;
  --surface: #11252a;
  --surface-2: #17313a;
  --line: #2a4750;
  --ink: #e7f1f1;
  --ink-2: #c3d4d6;
  --muted: #9db3b6;
  --teal: #62e0cd;
  --teal-fill: #35b7a4;
  --accent-soft: #123d3d;
  --c-views: #4fd1bd;
  --c-sessions: #86a8ee;
  --c-conv: #f2a15f;
  --c-cvr: #b79af0;
  --c-organic: #4fd1bd;
  --c-direct: #86a8ee;
  --c-referral: #f2a15f;
  --c-social: #b79af0;
  --danger: #ff9a88;
  --danger-bg: #3a1c19;
  --warn-ink: #f3c27a;
  --warn-bg: #3a2c12;
  --warn-line: #6d5321;
  --ok-ink: #6fe3bf;
  --ok-bg: #11382f;
  --focus: #8db6ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
  --side-bg: #0a2326;
  --side-ink: #cfe0df;
  --side-muted: #a4bfbe;
  --side-line: #2f5658;
  --hm0: #15292e; --hm1: #17433f; --hm2: #1d6a60; --hm3: #2c9a89; --hm4: #62e0cd;
  --hm0-ink: #9db3b6; --hm1-ink: #d6efea; --hm2-ink: #f0fbf9; --hm3-ink: #05211d; --hm4-ink: #05211d;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal); }
small { font-size: var(--fs-xs); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8125rem; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; word-break: break-word; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0 0 0.5rem; }
ul, ol { margin: 0; padding-left: 1.2rem; }
ul.plain, ol.plain { list-style: none; padding: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.icon { display: block; flex-shrink: 0; }

.hidden { display: none !important; }
.sr-only, .sr-offscreen { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.pos { color: var(--ok-ink); }
.neg { color: var(--danger); }
.block { display: block; }
.small-print { font-size: var(--fs-xs); color: var(--muted); margin-top: 0.75rem; }
.print-only { display: none; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); color: var(--ink); padding: 8px 12px; border-radius: 6px; border: 2px solid var(--focus); }
.skip-link:focus { top: 8px; }

/* ------------------------------------------------------------ Khung */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--side-bg); color: var(--side-ink); padding: 24px 16px;
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 40; overflow-y: auto;
}
.brand { font-size: 1.6rem; font-weight: 700; color: #fff; display: flex; gap: 10px; align-items: center; padding: 0 8px 24px; letter-spacing: -0.04em; }
.brandmark { width: 26px; height: 26px; border: 2px solid #d9f291; border-radius: 50%; position: relative; transform: rotate(-30deg); }
.brandmark::before { content: ''; position: absolute; inset: 5px -6px; border: 2px solid #d9f291; border-radius: 50%; }
.brandmark::after { content: ''; width: 6px; height: 6px; background: #d9f291; border-radius: 50%; position: absolute; right: 0; top: 0; }
.workspace { border: 1px solid var(--side-line); border-radius: 8px; padding: 10px; display: flex; gap: 10px; align-items: center; margin-bottom: 20px; font-size: var(--fs-sm); color: #fff; }
.workspace small { display: block; color: var(--side-muted); font-size: var(--fs-xs); margin-top: 2px; }
.avatar { background: #ffffff1f; border-radius: 7px; width: 30px; height: 30px; display: grid; place-items: center; font-weight: 600; flex-shrink: 0; font-size: var(--fs-xs); }
.navlabel { font-size: var(--fs-xs); color: var(--side-muted); padding: 0 8px; margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.navbutton, .site-nav {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; min-height: var(--touch);
  border-radius: 7px; border: 0; background: none; text-align: left; font-size: var(--fs-sm); color: var(--side-ink); margin-bottom: 2px;
}
.navbutton:hover, .site-nav:hover { background: #ffffff14; }
.navbutton.active { background: #ffffff22; color: #fff; font-weight: 600; }
.site-nav[aria-current="true"] { background: #ffffff22; color: #fff; font-weight: 600; }
.site-nav.add { color: #dcefb4; }
.site-nav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-demo { margin-left: auto; font-size: var(--fs-xs); background: var(--warn-bg); color: var(--warn-ink); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.navdivider { height: 1px; background: var(--side-line); margin: 14px 0; }
.sidebottom { margin-top: auto; padding-top: 18px; }
.privacy { font-size: var(--fs-xs); line-height: 1.6; color: var(--side-muted); border: 1px solid var(--side-line); border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.privacy b { display: block; color: #fff; margin-bottom: 4px; font-weight: 600; }
.user { display: flex; gap: 10px; align-items: center; font-size: var(--fs-sm); color: #fff; }
.user small { display: block; color: var(--side-muted); font-size: var(--fs-xs); }
.scrim { position: fixed; inset: 0; background: rgba(5, 15, 17, 0.55); z-index: 35; }

.main { grid-column: 2; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); min-height: 56px;
}
.breadcrumb { font-size: var(--fs-sm); color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb strong { color: var(--ink); }
.topactions { margin-left: auto; display: flex; align-items: center; gap: 8px; position: relative; }
.top-secondary { display: flex; align-items: center; gap: 8px; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.lang-btn { border: 0; background: none; padding: 6px 12px; min-height: 32px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.lang-btn[aria-pressed="true"] { background: var(--teal); color: #fff; }
:root[data-theme="dark"] .lang-btn[aria-pressed="true"] { color: #04211d; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: var(--touch); height: var(--touch); display: grid; place-items: center; color: var(--ink); }
.menu-btn, .more-btn { display: none; }
.alert-btn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.alert-btn .count { font-weight: 700; }

.content { padding: 24px; max-width: 1360px; margin: 0 auto; }
.main.is-atlas .content { max-width: none; }
.heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
h1:focus, .main:focus { outline: none; }
.subtitle { color: var(--muted); margin: 4px 0 0; max-width: 70ch; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.selector { position: relative; }
.dropdown { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 260px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.dd-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px; font-size: var(--fs-sm); width: 100%; border: 0; background: none; text-align: left; min-height: var(--touch); cursor: pointer; }
.dd-item:hover { background: var(--surface-2); }
.dd-item.disabled { opacity: 0.6; }
.dd-all { border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 4px; }
.dd-label { font-size: var(--fs-xs); color: var(--muted); padding: 6px 8px 2px; margin: 0; }

/* ------------------------------------------------------------ Điều khiển */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--touch); padding: 6px 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; font-size: var(--fs-sm); font-weight: 500; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .btn.primary { color: #04211d; }
.btn.primary:hover { filter: brightness(1.08); background: var(--teal); }
.btn.primary-outline { border-color: var(--teal); color: var(--teal); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 32px; padding: 4px 10px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
select.btn { padding-right: 28px; }
.link-btn { border: 0; background: none; color: var(--teal); text-decoration: underline; padding: 0; font: inherit; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-row.tight { margin-top: 0; }
.view-actions { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg.wrap { flex-wrap: wrap; border: 0; background: none; gap: 6px; overflow: visible; }
.seg-btn { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; min-height: 32px; font-size: var(--fs-sm); color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.seg:not(.wrap) .seg-btn { border: 0; border-radius: 0; }
.seg.wrap .seg-btn { border-radius: 8px; }
.seg-btn[aria-pressed="true"], .seg-btn[aria-selected="true"] { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .seg-btn[aria-pressed="true"], :root[data-theme="dark"] .seg-btn[aria-selected="true"] { color: #04211d; }
.switch { display: inline-flex; gap: 8px; align-items: center; font-size: var(--fs-sm); min-height: var(--touch); cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--teal); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.badge.blocker { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
#dataModeBadge[data-mode="real"] { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
#dataModeBadge[data-mode="mixed"], #dataModeBadge[data-mode="demo"] { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--line); margin-bottom: 14px; font-size: var(--fs-sm); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.notice > div, .notice > span { flex: 1; min-width: 0; }
.notice ul { margin: 4px 0 0; }
.notice .btn { align-self: center; }

/* ------------------------------------------------------------ Thẻ & bố cục */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 16px 20px 0; }
.card-head h2 { font-size: 1rem; font-weight: 600; }
.card-head p { margin: 4px 0 0; font-size: var(--fs-sm); max-width: 75ch; }
.card-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 14px 20px 18px; }
.empty-card { padding: 32px 24px; text-align: center; }
.empty-card h2 { font-size: 1.125rem; margin-bottom: 8px; }
.empty-card .btn-row { justify-content: center; }
.demo-card { border-style: dashed; border-color: var(--warn-line); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-seo { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; align-items: start; }
.grid-seo > .card { margin-bottom: 0; padding: 18px; }
.grid-seo > .card h2 { font-size: 1rem; margin-bottom: 10px; }
.sub { font-size: var(--fs-md); font-weight: 600; margin: 18px 0 8px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpis.kpis-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi-label { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.kpi-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0; word-break: break-word; }
.kpi-foot { font-size: var(--fs-xs); min-height: 1.2em; }
.spark { width: 100%; height: 34px; margin-top: 8px; }
.spark-line { fill: none; stroke: var(--c-views); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--c-views); opacity: 0.12; }
.spark.sessions .spark-line { stroke: var(--c-sessions); } .spark.sessions .spark-area { fill: var(--c-sessions); }
.spark.conv .spark-line { stroke: var(--c-conv); } .spark.conv .spark-area { fill: var(--c-conv); }
.spark.cvr .spark-line { stroke: var(--c-cvr); } .spark.cvr .spark-area { fill: var(--c-cvr); }

.loading { display: flex; gap: 10px; align-items: center; padding: 40px 0; justify-content: center; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ Biểu đồ */
.ts-readout { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: var(--fs-sm); margin-bottom: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--c-views); }
.dot.sessions { background: var(--c-sessions); } .dot.conv { background: var(--c-conv); }
.ts-focus { overflow-x: auto; }
.ts-svg { width: 100%; height: auto; display: block; }
.ts-svg .grid { stroke: var(--line); stroke-dasharray: 3 3; }
.ts-svg .axis { fill: var(--muted); font-size: 11px; }
.ts-svg .line { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.ts-svg .line.views { stroke: var(--c-views); } .ts-svg .line.sessions { stroke: var(--c-sessions); }
.ts-svg .line.conv { stroke: var(--c-conv); }
.ts-svg .line.forecast { stroke: var(--muted); stroke-dasharray: 5 4; }
.ts-svg .area { opacity: 0.1; } .ts-svg .area.views { fill: var(--c-views); } .ts-svg .area.conv { fill: var(--c-conv); }
.ts-svg .forecast-band { fill: var(--muted); opacity: 0.14; }
.ts-svg .cursor { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
@media (prefers-reduced-motion: no-preference) { .ts-svg .line { stroke-dasharray: none; } }
.ts-table { margin-top: 10px; font-size: var(--fs-sm); }
.ts-table summary { cursor: pointer; padding: 6px 0; color: var(--teal); min-height: 28px; }
.table-scroll { overflow-x: auto; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 4px; min-width: 60px; }
.bar-fill { height: 100%; width: var(--w, 0%); background: var(--teal-fill); border-radius: 3px; }
.bar-fill.blue { background: var(--c-sessions); } .bar-fill.purple { background: var(--c-cvr); }
.bar-fill.orange { background: var(--c-conv); } .bar-fill.gray { background: var(--muted); }

.funnel { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.funnel-step { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--surface-2); }
.funnel-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.funnel-index { font-weight: 700; color: var(--teal); }
.funnel-name { flex: 1 1 120px; min-width: 0; font-size: var(--fs-sm); font-weight: 600; }
.funnel-count { font-size: 1.25rem; font-weight: 700; white-space: nowrap; margin-left: auto; }
.funnel-meta { font-size: var(--fs-xs); margin-top: 6px; }

.insights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.insight { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--surface-2); }
.insight h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px; }
.insight-title { font-weight: 600; font-size: 1rem; }
.ci { color: var(--muted); font-size: var(--fs-xs); }
.n { font-size: var(--fs-xs); }

.table-scroll { max-width: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table thead th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.data-table tbody th { font-weight: 600; }
.data-table .bar { max-width: 140px; }
.sitename { display: flex; align-items: center; gap: 10px; }
.sitename small { display: block; }
.site-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot, var(--teal-fill)); flex-shrink: 0; display: inline-block; }
.site-c2c9081 { --dot: #2c9081; } .site-c7b9dd8 { --dot: #7b9dd8; } .site-ce58a43 { --dot: #e58a43; }
.site-cb59cd3 { --dot: #b59cd3; } .site-ce5ad77 { --dot: #e5ad77; } .site-c5f997f { --dot: #5f997f; }
code.wrap { white-space: normal; word-break: break-all; }

.heatmap { border-collapse: separate; border-spacing: 3px; width: 100%; font-size: var(--fs-xs); }
.heatmap th { font-weight: 600; color: var(--muted); padding: 4px; text-align: center; white-space: nowrap; }
.heatmap tbody th { text-align: left; }
.hm { text-align: center; padding: 8px 2px; border-radius: 4px; font-weight: 600; min-width: 34px; }
.hm-0 { background: var(--hm0); color: var(--hm0-ink); } .hm-1 { background: var(--hm1); color: var(--hm1-ink); }
.hm-2 { background: var(--hm2); color: var(--hm2-ink); } .hm-3 { background: var(--hm3); color: var(--hm3-ink); }
.hm-4 { background: var(--hm4); color: var(--hm4-ink); }
.heat-readout { min-height: 1.4em; margin-top: 8px; font-size: var(--fs-sm); }
.stat-row { display: flex; gap: 24px; flex-wrap: wrap; margin: 0 0 12px; }
.stat-row dt { font-size: var(--fs-xs); color: var(--muted); } .stat-row dd { margin: 0; font-size: 1.125rem; font-weight: 700; }
.depth-row, .device-row, .rank-list li { display: grid; grid-template-columns: 90px minmax(60px, 1fr) auto auto; gap: 10px; align-items: center; padding: 5px 0; font-size: var(--fs-sm); }
.device-row { grid-template-columns: 120px minmax(60px, 1fr) auto; }
.rank-list li { grid-template-columns: minmax(80px, 1.4fr) minmax(60px, 1fr) auto; }
.rank-list code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.depth-cvr { min-width: 90px; text-align: right; font-size: var(--fs-xs); }
.badge.q-star { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.badge.q-gem, .badge.q-optimize { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.recent-list li { display: grid; grid-template-columns: 72px minmax(110px, 1fr) minmax(0, 1.2fr) auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); align-items: baseline; }
.recent-list code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.journey-wrap { overflow-x: auto; }
.journey { width: 100%; height: auto; min-width: 640px; display: block; }
.journey .edge { fill: none; stroke: var(--c-sessions); opacity: 0.35; }
.journey .edge.hot { opacity: 0.9; } .journey .edge.dim { opacity: 0.08; }
.journey .fnode rect:first-child { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.2; }
.journey .fnode:focus-visible rect:first-child, .journey .fnode:hover rect:first-child { stroke: var(--teal); stroke-width: 2; }
.journey .fnode-bar { fill: var(--teal-fill); }
.journey text { fill: var(--ink); font-size: 11px; }
.journey .fnode-n { fill: var(--muted); } .journey .fhead { fill: var(--muted); font-size: 11px; font-weight: 600; }
@media (prefers-reduced-motion: no-preference) { .journey .edge { transition: opacity 0.15s ease; } }

/* ------------------------------------------------------------ SEO */
.readiness { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.big-num { font-size: 2.25rem; font-weight: 700; } .big-na { font-size: 1.125rem; font-weight: 600; color: var(--muted); }
.pillars { margin: 12px 0; display: grid; gap: 10px; }
.pillar-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: var(--fs-sm); }
.finding { padding: 14px 0; border-bottom: 1px solid var(--line); }
.finding:last-child { border-bottom: 0; }
.finding-head { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.finding-evidence, .finding-remedy { margin: 6px 0 0; font-size: var(--fs-sm); word-break: break-word; }
.finding-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-xs); margin: 8px 0 0; }
.link-ext { display: inline-flex; gap: 4px; align-items: center; min-height: 28px; }
.integrations { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.integration { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--surface-2); }
.integration header { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.integration h3 { font-size: var(--fs-md); }
.steps-small { margin: 8px 0; padding-left: 1.1rem; font-size: var(--fs-sm); }

/* ------------------------------------------------------------ Kết nối / cài đặt */
.codeblock { position: relative; margin: 8px 0 14px; }
.codeblock pre { margin: 0; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 420px; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; }
.codeblock code { background: none; padding: 0; word-break: normal; }
.copy-btn { position: absolute; top: 6px; right: 6px; }
.codeblock pre { padding-right: 96px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; align-items: start; }
.field { display: grid; gap: 4px; font-size: var(--fs-sm); border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, fieldset.field > legend { font-weight: 600; padding: 0; }
.field input[type="text"], .field input[type="url"], .field input[type="number"], .field input[type="password"] {
  min-height: var(--touch); padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); width: 100%;
}
.radio { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; padding: 4px 0; min-height: 28px; }
.radio input { margin-top: 4px; accent-color: var(--teal); }
.tester { margin: 10px 0; max-width: 520px; }
.bullets { padding-left: 1.2rem; display: grid; gap: 4px; font-size: var(--fs-sm); }
.steps { padding-left: 1.4rem; display: grid; gap: 8px; font-size: var(--fs-sm); margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; }
.checklist { display: grid; gap: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-sm); min-height: 28px; }
.check label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--teal); margin-top: 1px; }
.check-mark { width: 18px; text-align: center; color: var(--muted); }
.check.done .check-mark { color: var(--ok-ink); }
.conn-status { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.conn-status p { margin: 0; }
.kv { margin: 0; display: grid; gap: 8px; }
.kv > div { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.kv dt { font-size: var(--fs-sm); color: var(--muted); } .kv dd { margin: 0; font-size: var(--fs-sm); }
.setting-sites { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.setting-site { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--surface-2); }
.setting-site .kv > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
.setting-site header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; align-items: flex-start; }
.setting-site h3 { font-size: 1rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.alert-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.alert-item { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); }
.tabpanel { margin-top: 12px; }

/* ------------------------------------------------------------ Hộp thoại, toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 15, 17, 0.6); display: grid; place-items: center; z-index: 80; padding: 16px; overflow-y: auto; }
.modal { background: var(--surface); color: var(--ink); border-radius: 12px; border: 1px solid var(--line); width: min(480px, 100%); padding: 20px; box-shadow: var(--shadow); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.modal h2 { font-size: 1.125rem; }
.modal-body { display: grid; gap: 14px; margin: 14px 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.form-error { color: var(--danger); font-size: var(--fs-sm); margin: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-size: var(--fs-sm); z-index: 90; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; font-size: var(--fs-xs); color: var(--muted); border-top: 1px solid var(--line); margin-top: 28px; padding-top: 14px; }
.atlas-host { min-width: 0; }

/* ------------------------------------------------------------ Responsive */
@media (max-width: 1279px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights, .integrations { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .main { grid-column: 1; }
  .sidebar { transform: translateX(-100%); box-shadow: none; visibility: hidden; }
  .sidebar.open { transform: translateX(0); visibility: visible; box-shadow: 8px 0 30px rgba(0, 0, 0, 0.35); }
  .menu-btn { display: grid; }
  .grid-seo { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 8px 16px; }
  .content { padding: 20px 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  .sidebar { transition: transform 0.2s ease, visibility 0.2s; }
}
@media (max-width: 767px) {
  .grid-2, .insights, .integrations { grid-template-columns: minmax(0, 1fr); }
  .kv > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .recent-list li { grid-template-columns: 64px minmax(0, 1fr); }
  .recent-list li code, .recent-list li span { grid-column: 2; }
}
@media (max-width: 599px) {
  :root[data-theme] { --touch: 2.75rem; }
  .btn.small, .seg-btn, .lang-btn, .link-ext, .ts-table summary { min-height: 44px; }
  .check, .radio { min-height: 44px; align-items: center; }
  .content { padding: 16px; }
  .topbar { gap: 8px; }
  .breadcrumb { flex: 1; }
  .more-btn { display: grid; }
  .top-secondary { display: none; position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; flex-direction: column; align-items: stretch; box-shadow: var(--shadow); min-width: 200px; z-index: 50; }
  .top-secondary.open { display: flex; }
  .top-secondary .lang-switch { align-self: flex-start; }
  .heading .filters { width: 100%; }
  .heading .filters .btn { flex: 1; }
  .toolbar .filters { width: 100%; }
  .toolbar .filters > * { flex: 1 1 100%; }
  .selector .btn { width: 100%; justify-content: space-between; }
  .kpis, .kpis.kpis-2 { grid-template-columns: minmax(0, 1fr); }
  .card-head { padding: 14px 14px 0; } .card-body { padding: 12px 14px 16px; }
  .ts-svg { min-width: 560px; }
  .copy-btn { position: static; margin-top: 6px; }
  .codeblock pre { padding-right: 14px; }
  .depth-row { grid-template-columns: 70px minmax(40px, 1fr) auto; } .depth-row .depth-cvr { grid-column: 1 / -1; text-align: left; }
  /* Bảng thành thẻ dưới 600px */
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td, .table-cards th { display: block; width: 100%; }
  .table-cards tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 6px 10px; background: var(--surface); }
  .table-cards td, .table-cards tbody th { border: 0; padding: 6px 0; display: flex; justify-content: space-between; gap: 14px; align-items: baseline; text-align: right; }
  .table-cards td::before, .table-cards tbody th::before { content: attr(data-label); color: var(--muted); font-weight: 600; font-size: var(--fs-xs); text-align: left; flex-shrink: 0; }
  .table-cards td > .bar { display: none; }
  .table-cards td > div { text-align: right; }
}

/* ------------------------------------------------------------ Giảm chuyển động */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .spinner { animation: none; border-top-color: var(--line); }
}

/* ------------------------------------------------------------ In / Lưu PDF */
@media print {
  :root, :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --line: #bbb; --ink: #000; --ink-2: #222; --muted: #444; --teal: #064e46;
    --warn-bg: #fff; --warn-ink: #5a3200; --ok-bg: #fff; --ok-ink: #064e3b; --shadow: none;
  }
  body { background: #fff; color: #000; font-size: 11pt; }
  .sidebar, .scrim, .topbar, .toolbar, .heading .filters, .skip-link, .footer, .btn, .view-actions, .no-print, #toast, #modalRoot, .copy-btn, details.ts-table { display: none !important; }
  .shell { display: block; }
  .main { grid-column: auto; }
  .content { padding: 0; max-width: none; }
  .print-only { display: block; }
  .card, .kpi, .finding, .print-keep { break-inside: avoid; box-shadow: none; }
  .card { border: 1px solid #999; }
  a { color: #000; text-decoration: none; }
  .badge { border: 1px solid #666; background: #fff; color: #000; }
  .grid-seo { grid-template-columns: 220px 1fr; }
  .bar-fill, .hm, .spark-line { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
