/* Giao diện Marketing SeJung.
   Nguyên tắc: bề mặt yên, viền mảnh, phân cấp bằng độ đậm chữ và khoảng cách; màu chỉ dành cho ý nghĩa (tăng/giảm, trạng thái, mục đang chọn).
   Gam SeJung (phongkhamsejung.vn): tím chàm #332688, tím #7a52db, nhấn hồng tím #e260f5 và cyan #11d2d6; gradient tím chỉ ở nút chính, ô chỉ số chính và trang đăng nhập.
   Bố cục: máy tính có thanh bên sáng 256px (thu gọn được thành dải biểu tượng 72px) + thanh trên mờ; điện thoại (≤ 900px) có menu trượt và thanh lối tắt nổi dưới đáy.
   Chủ đề: tokens trên :root (sáng), đổi theo [data-theme] hoặc prefers-color-scheme. */
@import url("/static/fonts/fonts.css");

:root {
  --bg: #f7f6fc; --panel: #ffffff; --panel-2: #f5f3fb; --side-bg: #f1eff9; --ink: #17133a; --ink-2: #3f3a66; --muted: #76719a; --line: #e6e3f1; --line-2: #efedf6; --hover: #efecf8;
  --accent: #4f35c8; --accent-ink: #ffffff; --accent-soft: #ede9fb; --accent-line: #cdc3f3;
  --series-1: #7a52db; --series-2: #16b0b8; --series-3: #d14ad9; --series-4: #f3a33b; --chart-muted: #ddd8f0;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #a15c00; --warn-soft: #fff4e0; --bad: #c2362c; --bad-soft: #fdeceb;
  --brand: #332688; --brand-2: #7a52db; --brand-pink: #e260f5; --brand-cyan: #11d2d6;
  --grad: linear-gradient(135deg, #4a35c4 0%, #7a52db 52%, #b84fdc 100%);
  --glow: radial-gradient(900px 480px at 85% -12%, rgba(122, 82, 219, .10), transparent 60%), radial-gradient(700px 420px at -5% 105%, rgba(17, 210, 214, .07), transparent 60%);
  --shadow-xs: 0 1px 2px rgba(23, 19, 58, .05); --shadow: 0 1px 2px rgba(23, 19, 58, .04), 0 3px 10px rgba(23, 19, 58, .05); --shadow-lg: 0 20px 50px rgba(23, 19, 58, .22);
  --radius: 16px; --radius-sm: 10px; --side: 256px; --rail: 72px;
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; --display: "Chakra Petch", var(--font);
  --logo-ink: block; --logo-white: none;
  color-scheme: light; accent-color: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0a1f; --panel: #15122e; --panel-2: #1b1738; --side-bg: #0e0c25; --ink: #efecfb; --ink-2: #c9c4e6; --muted: #8f89b8; --line: #2a2550; --line-2: #231f45; --hover: #1f1b40;
    --accent: #b8a4ff; --accent-ink: #160c3a; --accent-soft: #2a2160; --accent-line: #4a3c9c;
    --series-1: #9f7ef7; --series-2: #3cc8d0; --series-3: #e37bf0; --series-4: #f5b55c; --chart-muted: #352e63;
    --ok: #5fd39a; --ok-soft: #153626; --warn: #f0b458; --warn-soft: #3a2d12; --bad: #ff8a80; --bad-soft: #3f1f1d;
    --glow: radial-gradient(900px 480px at 85% -12%, rgba(122, 82, 219, .22), transparent 60%), radial-gradient(700px 420px at -5% 105%, rgba(17, 210, 214, .10), transparent 60%);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 10px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
    --logo-ink: none; --logo-white: block;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0a1f; --panel: #15122e; --panel-2: #1b1738; --side-bg: #0e0c25; --ink: #efecfb; --ink-2: #c9c4e6; --muted: #8f89b8; --line: #2a2550; --line-2: #231f45; --hover: #1f1b40;
  --accent: #b8a4ff; --accent-ink: #160c3a; --accent-soft: #2a2160; --accent-line: #4a3c9c;
  --series-1: #9f7ef7; --series-2: #3cc8d0; --series-3: #e37bf0; --series-4: #f5b55c; --chart-muted: #352e63;
  --ok: #5fd39a; --ok-soft: #153626; --warn: #f0b458; --warn-soft: #3a2d12; --bad: #ff8a80; --bad-soft: #3f1f1d;
  --glow: radial-gradient(900px 480px at 85% -12%, rgba(122, 82, 219, .22), transparent 60%), radial-gradient(700px 420px at -5% 105%, rgba(17, 210, 214, .10), transparent 60%);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 10px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
  --logo-ink: none; --logo-white: block;
  color-scheme: dark;
}

/* ---------- nền tảng ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--brand-2) 28%, transparent); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
kbd { display: inline-flex; align-items: center; font: 500 11px/1 var(--font); color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 3px 6px; background: var(--panel-2); white-space: nowrap; }
.logo-ink { display: var(--logo-ink); }
.logo-white { display: var(--logo-white); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- đăng nhập: tấm thương hiệu tím bên trái, thẻ đăng nhập bên phải ---------- */
.login { min-height: 100%; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--bg); }
.login-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 18px; padding: 48px 56px; color: #fff; background: radial-gradient(800px 500px at 15% 0%, rgba(122, 82, 219, .75), transparent 60%), radial-gradient(640px 480px at 100% 100%, rgba(226, 96, 245, .4), transparent 60%), radial-gradient(480px 320px at 80% 10%, rgba(17, 210, 214, .22), transparent 65%), linear-gradient(160deg, #1b1452, #332688 55%, #281b6e); }
.login-brand .logo { width: 220px; height: auto; display: block; }
.login-lead { font-size: 18px; line-height: 1.5; color: rgba(255, 255, 255, .82); max-width: 34ch; }
.login-orbs i { position: absolute; border-radius: 50%; pointer-events: none; }
.login-orbs i:nth-child(1) { width: 420px; height: 420px; right: -140px; top: -160px; background: radial-gradient(circle at 35% 35%, rgba(226, 96, 245, .45), transparent 62%); filter: blur(24px); }
.login-orbs i:nth-child(2) { width: 260px; height: 260px; right: 18%; top: 30%; background: radial-gradient(circle at 35% 35%, rgba(17, 210, 214, .4), transparent 62%); filter: blur(28px); }
.login-orbs i:nth-child(3) { width: 180px; height: 180px; left: 8%; top: 16%; background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, .22), transparent 62%); filter: blur(22px); }
.login-brand::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px); background-size: 48px 48px; mask-image: radial-gradient(70% 60% at 60% 40%, #000, transparent); pointer-events: none; }
.login-card { align-self: center; justify-self: center; width: min(100% - 48px, 400px); display: flex; flex-direction: column; gap: 8px; padding: 36px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.login-tag { font: 600 11px/1 var(--display); letter-spacing: .22em; text-transform: uppercase; color: var(--brand-2); margin-bottom: 10px; }
.login-card h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.login-card .sub { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-card label { margin-top: 6px; }
.login-card input { min-height: 44px; }
.login-card .btn { margin-top: 18px; min-height: 44px; justify-content: center; font-size: 14.5px; }

/* ---------- khung: thanh bên sáng + thanh trên mờ ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side-bg); border-right: 1px solid var(--line); padding: 12px 10px 10px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.side:focus { outline: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.brand { display: flex; align-items: center; padding: 4px 8px; border-radius: 10px; text-decoration: none; }
.logo-wrap { display: block; width: 132px; height: 36px; overflow: hidden; transition: width .18s; }
.logo-wrap .logo { height: 36px; width: auto; max-width: none; }
.btn.side-close, .btn.menu-btn, .scrim, .tabbar { display: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--muted); padding: 16px 10px 4px; white-space: nowrap; overflow: hidden; }
.nav a { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; border-radius: 10px; color: var(--ink-2); font-weight: 500; font-size: 13.5px; text-decoration: none; transition: background .12s, color .12s; }
.nav a svg.i { color: var(--muted); width: 18px; height: 18px; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--line); }
.nav a[aria-current="page"] svg.i { color: var(--accent); }
.nav a .nav-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a .chev { display: grid; place-items: center; width: 24px; height: 24px; margin-right: -6px; border-radius: 7px; color: var(--muted); font-size: 17px; line-height: 1; transition: transform .15s, background .12s, color .12s; }
.nav a .chev:hover { background: var(--accent-soft); color: var(--accent); }
.nav a.open .chev { transform: rotate(90deg); }
.nav a.sub { min-height: 32px; padding-left: 38px; font-size: 13px; color: var(--muted); animation: nav-in .15s ease-out; }
.nav a.sub svg.i { width: 15px; height: 15px; }
.nav a.sub[aria-current="page"] { color: var(--accent); background: transparent; box-shadow: none; }
@keyframes nav-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 4px 0 10px; font-size: 11.5px; color: var(--muted); }
.side-foot-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 8px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-xs); }
.side-user .avatar { width: 30px; height: 30px; font-size: 11px; background: var(--grad); }
.side-user .name { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* thanh bên thu gọn: chỉ còn biểu tượng, tên mục hiện qua tooltip */
@media screen and (min-width: 901px) {
  :root[data-side="rail"] .shell { grid-template-columns: var(--rail) minmax(0, 1fr); }
  :root[data-side="rail"] .side { padding-inline: 10px; }
  :root[data-side="rail"] .side-head { justify-content: center; }
  :root[data-side="rail"] .brand { padding: 4px; }
  :root[data-side="rail"] .logo-wrap { width: 38px; }
  :root[data-side="rail"] .nav a { justify-content: center; padding: 9px; }
  :root[data-side="rail"] .nav a .nav-text, :root[data-side="rail"] .nav a .chev, :root[data-side="rail"] .nav a.sub, :root[data-side="rail"] .nav-group, :root[data-side="rail"] .side-foot-text, :root[data-side="rail"] .side-user .name { display: none; }
  :root[data-side="rail"] .side-foot { justify-content: center; padding: 6px 0 0; }
  :root[data-side="rail"] .side-user { flex-direction: column; gap: 6px; padding: 8px 4px; }
}
.main { min-width: 0; display: flex; flex-direction: column; background: var(--glow); }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-height: 60px; padding: 10px 24px; position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent); }
.top-title { margin-right: auto; min-width: 0; }
.top h1 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
.top .desc { font-size: 12.5px; color: var(--muted); }
.period { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.period select { min-height: 32px; padding: 3px 8px; font-size: 13px; }
.search-btn { gap: 10px; color: var(--muted); font-weight: 500; min-width: 170px; justify-content: space-between; padding-right: 6px; }
.search-btn:hover { color: var(--ink); }
.view { padding: 22px 24px 56px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.view:focus { outline: none; }

/* ---------- nút, trường nhập ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); font-weight: 500; font-size: 13.5px; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow-xs); transition: background .12s, border-color .12s, box-shadow .12s, color .12s; }
.btn:hover { background: var(--hover); border-color: color-mix(in srgb, var(--line) 60%, var(--muted)); }
.btn svg.i { width: 16px; height: 16px; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(23, 19, 58, .12), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 6px 16px rgba(122, 82, 219, .35), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: transparent; box-shadow: none; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--hover); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 6px; width: 36px; justify-content: center; }
.btn.icon.small { width: 30px; padding: 3px; }
.btn[disabled] { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px; min-height: 36px; max-width: 100%; font-size: 13.5px; box-shadow: var(--shadow-xs); transition: border-color .12s, box-shadow .12s; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 16px; height: 16px; margin: 0; padding: 0; box-shadow: none; }
input[type="file"] { box-shadow: none; }
textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
select.inline { min-height: 28px; padding: 2px 6px; font-size: 12.5px; border-color: transparent; background: transparent; box-shadow: none; }
select.inline:hover { border-color: var(--line); background: var(--panel); }
label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row .grow { flex: 1 1 220px; min-width: 0; }
.spacer { margin-left: auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; font-size: 12.5px; }
code { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 6px; font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; font-size: 12.5px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* bộ chọn kiểu phân đoạn (tab) */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; }
.tab { border: 0; background: transparent; border-radius: 8px; padding: 5px 12px; font-size: 13px; font-weight: 500; color: var(--muted); transition: background .12s, color .12s; }
.tab:hover { color: var(--ink); }
.tab[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-xs), 0 0 0 1px var(--line); }
.tab svg.i { width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; color: var(--muted); }
.tab[aria-pressed="true"] svg.i { color: var(--accent); }
.tabs.page-tabs { align-self: flex-start; }
.page-tabs .tab { display: inline-flex; align-items: center; padding: 7px 14px; font-size: 13.5px; }

/* nhãn trạng thái, chip tăng giảm */
.pill { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; min-height: 22px; font-size: 11.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; background: var(--panel); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.pill.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pill.plain::before { display: none; }
.pill.xs { font-size: 10.5px; padding: 0 6px; min-height: 18px; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 7px 1px 5px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.chip svg.i { width: 13px; height: 13px; stroke-width: 2.4; }
.chip.good { color: var(--ok); background: var(--ok-soft); }
.chip.bad { color: var(--bad); background: var(--bad-soft); }
.chip.neutral { color: var(--ink-2); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.trend { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.trend .vs { font-size: 12px; color: var(--muted); }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 1.6; flex: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* thông báo, trống, khung xương */
.notice { padding: 10px 14px; border-radius: 12px; font-size: 13px; background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent); }
.notice.info { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.notice a { color: inherit; font-weight: 600; }
.notice svg.i { width: 16px; height: 16px; }
.pw-notice { display: flex; align-items: center; gap: 10px; margin: 14px 24px 0; }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 36px 20px; color: var(--muted); text-align: center; background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-weight: 600; font-size: 15px; }
.skeleton { display: flex; flex-direction: column; gap: 18px; }
.sk { border-radius: var(--radius); border: 1px solid var(--line-2); background: linear-gradient(100deg, var(--panel-2) 30%, var(--panel) 50%, var(--panel-2) 70%); background-size: 200% 100%; animation: sk 1.4s linear infinite; }
.sk-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.sk-tile { height: 116px; }
.sk-card { height: 320px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- thẻ, ô chỉ số, biểu đồ ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; box-shadow: var(--shadow); }
.card > h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card .sub { font-size: 12.5px; color: var(--muted); margin-top: -10px; line-height: 1.45; }
.card.flat { box-shadow: none; background: var(--panel-2); }
.card.flat > h2 { font-size: 13.5px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 14px; }
.tiles.kpi { grid-template-columns: repeat(auto-fit, minmax(min(100%, 236px), 1fr)); }
.tile { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; box-shadow: var(--shadow); }
.tile-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tile-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.tile-icon svg.i { width: 17px; height: 17px; }
.tile .name { font-size: 12.5px; font-weight: 500; color: var(--muted); min-width: 0; }
.tile-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-width: 0; }
.tile-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile .value { font-size: 26px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; overflow-wrap: anywhere; }
.tile .delta { font-size: 12px; color: var(--muted); min-height: 1.4em; }
.spark { width: 96px; height: 32px; flex: none; overflow: visible; }
.spark-area { fill: var(--series-1); opacity: .12; }
.spark-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-dot { fill: var(--series-1); stroke: var(--panel); stroke-width: 2; }
.tile.hero { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 12px 30px rgba(90, 60, 200, .3); overflow: hidden; }
.tile.hero::after { content: ""; position: absolute; right: -50px; top: -70px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .28), transparent 65%); pointer-events: none; }
.tile.hero .name, .tile.hero .delta, .tile.hero .vs { color: rgba(255, 255, 255, .82); }
.tile.hero .tile-icon { background: rgba(255, 255, 255, .2); color: #fff; }
.tile.hero .chip { background: rgba(255, 255, 255, .2); color: #fff; box-shadow: none; }
.tile.hero .spark-area { fill: #fff; opacity: .2; }
.tile.hero .spark-line { stroke: #fff; }
.tile.hero .spark-dot { fill: #fff; stroke: var(--brand-2); }
.tile.accent { background: var(--accent-soft); border-color: var(--accent-line); }
.tile.accent .value { color: var(--accent); }
.chart { position: relative; height: 260px; min-width: 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.crumbs button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.checklist { display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; list-style: none; }
.checklist li::before { content: "✓"; color: var(--ok); font-weight: 700; flex: none; }

/* bước quy trình, dòng thời gian */
.stepper { display: flex; flex-wrap: wrap; gap: 4px; }
.step { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); background: var(--panel); cursor: pointer; }
.step:hover { color: var(--ink); }
.step.done { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.step.current { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline li { list-style: none; padding: 8px 0 8px 26px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--series-1); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline li::after { content: ""; position: absolute; left: 4px; top: 27px; bottom: -8px; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 12px; color: var(--muted); }

/* ---------- bảng ---------- */
.tablebox { overflow: auto; max-height: 68vh; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.card > div > .tablebox:first-child { border-left: 0; border-right: 0; border-radius: 0; margin: 0 -20px; }
.card > div > .tablebox:first-child:last-child { border-bottom: 0; margin-bottom: -18px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line-2); vertical-align: middle; font-size: 13px; }
thead th { position: sticky; top: 0; z-index: 1; background: var(--panel); font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
thead th button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
thead th button:hover { color: var(--ink); }
thead th[aria-sort="ascending"] button::after { content: " ↑"; color: var(--accent); }
thead th[aria-sort="descending"] button::after { content: " ↓"; color: var(--accent); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; min-width: 220px; }
td.strong { font-weight: 500; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; background: var(--panel-2); }
.bar { display: inline-block; height: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--brand-2), var(--brand-pink)); opacity: .55; margin-right: 8px; vertical-align: middle; }
.neg { color: var(--bad); }

/* ---------- hộp thoại, thông báo nổi, tìm nhanh ---------- */
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink); padding: 0; width: min(94vw, 560px); box-shadow: var(--shadow-lg); max-height: 92vh; }
dialog.wide { width: min(94vw, 860px); }
dialog.xwide { width: min(96vw, 1100px); }
dialog::backdrop { background: rgba(10, 8, 40, .5); backdrop-filter: blur(4px); }
dialog[open] { animation: dlg-in .18s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.dlg { display: flex; flex-direction: column; gap: 16px; padding: 22px 24px; }
.dlg h2 { font-size: 17px; font-weight: 700; letter-spacing: -.015em; }
.dlg h3 { font-size: 13.5px; font-weight: 600; margin-top: 6px; }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; }
.dlg-head .spacer { margin-left: auto; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.form-error { color: var(--bad); font-size: 13px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dlg > .dlg-actions:last-child { margin: 2px -24px -22px; padding: 14px 24px; background: var(--panel-2); border-top: 1px solid var(--line-2); border-radius: 0 0 18px 18px; }
.dlg-actions .left { margin-right: auto; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow-lg); max-width: min(90vw, 420px); animation: dlg-in .18s ease-out; }
.toast.error { background: var(--bad); color: #fff; }
dialog.palette-dlg { margin-top: 12vh; width: min(94vw, 560px); }
.palette { display: flex; flex-direction: column; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-input input { flex: 1; min-width: 0; border: 0; box-shadow: none; background: transparent; font-size: 15px; padding: 4px 0; }
.palette-input input:focus-visible { box-shadow: none; }
.palette-list { padding: 8px; max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.palette-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: inherit; text-align: left; }
.palette-item svg.i { color: var(--muted); }
.palette-item.active, .palette-item:hover { background: var(--hover); }
.palette-item.active svg.i { color: var(--accent); }
.palette-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.palette-text > span { font-weight: 500; }
.palette-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-empty { padding: 12px; }

/* ---------- kịch bản và giọng đọc ---------- */
.script { display: flex; flex-direction: column; gap: 10px; }
.script .hook { font-size: 16px; font-weight: 600; padding: 12px 14px; border-left: 3px solid var(--series-1); background: var(--accent-soft); border-radius: 8px; }
.script table td { white-space: normal; vertical-align: top; }
.tagbar { display: flex; flex-wrap: wrap; gap: 6px; }
.audio { width: 100%; margin-top: 4px; }
.thumb-spec { display: grid; grid-template-columns: 180px 1fr; gap: 18px; align-items: start; }
.thumb-frame { aspect-ratio: 9 / 16; border: 2px dashed var(--accent-line); border-radius: 12px; position: relative; background: var(--panel-2); font-size: 11px; color: var(--muted); }
.thumb-frame .safe { position: absolute; inset: 14% 8% 22%; border: 1px dashed var(--line); border-radius: 6px; display: grid; place-items: center; text-align: center; padding: 6px; }
.thumb-frame .band { position: absolute; left: 8%; right: 8%; bottom: 8%; height: 12%; background: var(--accent-soft); border-radius: 4px; display: grid; place-items: center; }

/* ---------- sơ đồ nhân sự ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex: none; letter-spacing: .02em; background: var(--grad); text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.sm { width: 20px; height: 20px; font-size: 9px; }
.org { display: flex; flex-direction: column; align-items: center; gap: 0; }
.org-root { display: flex; justify-content: center; padding-bottom: 22px; position: relative; }
.org-root::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 2px; height: 22px; background: var(--line); }
.org-teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; width: 100%; border-top: 2px solid var(--line); padding-top: 14px; }
.org-team { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.org-team::before { content: ""; position: absolute; left: 14px; right: 14px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: var(--team); }
.org-team-head { display: flex; flex-direction: column; gap: 2px; }
.org-leads { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.org-members { display: flex; flex-direction: column; gap: 10px; }
.org-role { display: flex; flex-direction: column; gap: 4px; }
.org-role-name { font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--muted); padding: 4px 0 2px; }
.person { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 10px; padding: 6px 8px; cursor: pointer; color: inherit; min-width: 0; }
.person:hover { background: var(--hover); border-color: var(--line); }
.person.lead { background: var(--panel-2); border-color: var(--line); }
.person.root { background: var(--panel); border-color: var(--line); padding: 8px 14px; width: auto; cursor: default; box-shadow: var(--shadow); }
.person .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.person .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .role { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .badges { display: flex; gap: 4px; flex: none; }

/* ---------- bảng công việc: cột kéo thả, hôm nay, tuần, lịch tháng ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.lane { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; min-width: 0; }
.lane-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 4px; }
.lane-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; flex: 1; }
.lane.collapsed { opacity: .85; }
.task { position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; color: inherit; box-shadow: var(--shadow-xs); min-width: 0; transition: box-shadow .12s, border-color .12s; }
.task:hover { border-color: var(--accent-line); box-shadow: var(--shadow); }
.task.dragging { opacity: .45; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-title { font-weight: 500; line-height: 1.35; }
.task-meta, .task-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; }
.task-who { color: var(--ink-2); }
.labels { display: flex; flex-wrap: wrap; gap: 4px; }
.label { display: inline-block; font-size: 11px; line-height: 1.6; padding: 0 7px; border-radius: 999px; background: hsl(var(--h) 60% 90%); color: hsl(var(--h) 55% 28%); font-weight: 600; }
:root[data-theme="dark"] .label { background: hsl(var(--h) 40% 24%); color: hsl(var(--h) 70% 80%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .label { background: hsl(var(--h) 40% 24%); color: hsl(var(--h) 70% 80%); } }
.lane.over, .day.over, .mcell.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
input.quick { border-style: dashed; background: transparent; box-shadow: none; font-size: 13px; }
input.quick:focus { background: var(--panel); border-style: solid; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.check-item { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.check-item input { margin-top: 3px; }
.check-item.done { color: var(--muted); text-decoration: line-through; }
.today { display: flex; flex-direction: column; gap: 14px; }
.today .card.danger { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.today-person { display: flex; flex-direction: column; gap: 6px; }
.today-name { font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 6px; }
.today-row { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }
.today-row input { margin-top: 12px; }
.week-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 12px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 8px; overflow-x: auto; }
.day { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 260px; min-width: 0; }
.day.is-today { border-color: var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), var(--panel-2) 44px); }
.day.weekend { background: var(--bg); }
.day-head { display: flex; align-items: baseline; gap: 6px; }
.month-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 12px; color: var(--muted); text-align: center; padding: 6px 0 2px; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mcell { min-height: 96px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-width: 0; }
.mcell.other { opacity: .5; }
.mcell.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mcell .mday { font-size: 12px; color: var(--muted); font-weight: 600; }
.mtask { display: block; width: 100%; text-align: left; border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 1px 6px; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.mtask.done { background: var(--hover); color: var(--muted); text-decoration: line-through; }
.mtask.late { background: var(--bad-soft); color: var(--bad); }

/* ---------- hộp thư Fanpage ---------- */
.chat { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 12px; min-height: 60vh; }
.chat-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-y: auto; max-height: 72vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.conv { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-2); padding: 10px 12px; cursor: pointer; color: inherit; }
.conv:hover { background: var(--hover); }
.conv.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--series-1); }
.conv.unread .conv-name, .conv.unread .conv-snippet { font-weight: 600; color: var(--ink); }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-head { display: flex; justify-content: space-between; gap: 8px; }
.conv-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11.5px; color: var(--muted); flex: none; }
.conv-snippet { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-thread { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 72vh; min-width: 0; box-shadow: var(--shadow); }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: color-mix(in srgb, var(--panel-2) 50%, transparent); }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 72%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-xs); }
.msg.me .bubble { background: var(--accent-soft); border-color: var(--accent-line); border-radius: 16px 16px 4px 16px; }
.bubble img { max-width: 240px; border-radius: 8px; display: block; }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.reply { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.reply textarea { flex: 1; min-height: 44px; }
.page-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; align-items: center; }
.page-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 500; color: inherit; box-shadow: var(--shadow-xs); }
.page-chip:hover { background: var(--hover); }
.page-chip.active { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.page-chip .cnt { color: var(--muted); }
.page-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.track { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.track input[type="text"] { font-size: 12.5px; padding: 4px 8px; min-width: 140px; min-height: 30px; }
.track input.grow { flex: 1; }
.ad-src { padding: 6px 12px; font-size: 12.5px; background: var(--accent-soft); border-bottom: 1px solid var(--line-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* nút trông như liên kết (tên dòng bấm được trong bảng phễu) */
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.linkish:hover { text-decoration: underline; }
/* chọn nhiều tài khoản trong báo cáo */
.picker { position: relative; }
.picker .chev { margin-left: 6px; opacity: .7; }
.picker-menu { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 360px; max-width: 90vw; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px; }
.picker.open .picker-menu { display: block; }
.picker-menu .row { gap: 6px; margin-bottom: 8px; }
.picker-menu input[type="search"] { flex: 1; min-width: 0; }
.picker-items { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; }
.picker-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--line-2); cursor: pointer; font-size: 13px; }
.picker-item:hover { background: var(--hover); }

/* trang trả về sau khi đăng nhập Google (mở trong thẻ riêng) */
.oauth-page { max-width: 560px; margin: 12vh auto; padding: 32px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); font-family: inherit; color: var(--ink); box-shadow: var(--shadow); }
.oauth-page h1 { font-size: 20px; margin: 0 0 12px; }
.oauth-page.ok h1 { color: var(--accent); }
.oauth-page.bad h1 { color: var(--bad); }
.oauth-page p { color: var(--ink-2); line-height: 1.5; }

@media print {
  .side, .tabbar, .scrim, .top .period, .search-btn, .btn, .tabs, .toasts, .toolbar { display: none !important; }
  .shell { display: block; }
  .top { position: static; border: 0; background: none; }
  body, .main { background: #fff; }
  .tablebox { max-height: none; overflow: visible; }
  .card, .tile { break-inside: avoid; box-shadow: none; }
}

/* ---------- điện thoại và máy tính bảng dọc (≤ 900px): menu trượt, thanh lối tắt nổi dưới đáy ---------- */
@media screen and (max-width: 900px) {
  :root { --tabbar: 64px; --safe-b: env(safe-area-inset-bottom, 0px); }
  body { font-size: 15px; }
  body:has(.shell.nav-open) { overflow: hidden; }
  .shell { display: block; }

  /* menu trượt từ trái */
  .side { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(86vw, 320px); height: auto; padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + var(--safe-b)); background: var(--panel); box-shadow: var(--shadow-lg); overscroll-behavior: contain; visibility: hidden; transform: translateX(-103%); transition: transform .24s ease, visibility 0s .24s; }
  .shell.nav-open .side { visibility: visible; transform: none; transition: transform .24s ease; }
  .btn.side-close { display: inline-flex; }
  .side-toggle { display: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 39; width: 100%; border: 0; padding: 0; background: rgba(10, 8, 40, .5); backdrop-filter: blur(3px); }
  .nav a { min-height: 44px; padding: 10px 12px; font-size: 15px; }
  .nav a.sub { min-height: 40px; padding-left: 40px; font-size: 14px; }

  /* đầu trang gọn, kỳ xem thành hàng cuộn ngang riêng */
  .top { gap: 8px 6px; min-height: 56px; padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px; }
  .btn.menu-btn { display: inline-flex; }
  .top-title { flex: 1 1 0; margin-right: 0; }
  .top h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top .desc { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search-btn { min-width: 0; width: 42px; padding: 9px; justify-content: center; gap: 0; border-color: transparent; background: transparent; box-shadow: none; }
  .search-btn .search-text, .search-btn kbd { display: none; }
  .period { order: 9; flex: 0 0 100%; margin: 0 -10px -8px; padding: 6px 12px 8px; flex-wrap: nowrap; white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
  .period select, .period .btn { flex: none; }
  .pw-notice { margin: 12px 16px 0; }
  .view { padding: 16px 16px calc(var(--tabbar) + 32px + var(--safe-b)); gap: 14px; }

  /* thanh lối tắt nổi dưới đáy */
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); z-index: 30; padding: 6px; border-radius: 20px; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(18px); box-shadow: 0 12px 32px rgba(23, 19, 58, .18); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px; min-width: 0; padding: 4px 2px; border: 0; border-radius: 14px; background: none; color: var(--muted); font-size: 11px; font-weight: 500; text-decoration: none; cursor: pointer; transition: background .12s, color .12s; }
  .tabbar span { max-width: 100%; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tabbar svg.i { width: 21px; height: 21px; }
  .tabbar [aria-current="page"] { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--tabbar) + 14px + var(--safe-b)); align-items: center; }

  /* vùng chạm đủ lớn; chữ trong ô nhập 16px để iPhone không tự phóng to */
  .btn { min-height: 42px; padding: 9px 14px; }
  .btn.small { min-height: 34px; padding: 5px 11px; font-size: 13px; }
  .btn.icon { width: 42px; padding: 9px; justify-content: center; }
  .btn.icon.small { width: 34px; padding: 5px; }
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]), select, textarea { min-height: 44px; font-size: 16px; }
  select.inline { min-height: 36px; font-size: 16px; }
  .period select { min-height: 36px; font-size: 14px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .toolbar { gap: 8px; }
  .toolbar > select, .toolbar > input:not([type="checkbox"], [type="radio"]), .row > select:not(.inline), .row > input:not([type="checkbox"], [type="radio"]) { flex: 1 1 150px; min-width: 0; }
  .toolbar > input[type="search"] { flex-basis: 100%; }
  .toolbar > input[type="date"], .row > input[type="date"] { flex-basis: 120px; padding-inline: 8px; }
  .tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tab { flex: none; padding: 8px 14px; }

  /* thẻ, ô chỉ số, biểu đồ, bảng */
  .card { padding: 16px; }
  .card > div > .tablebox:first-child { margin-inline: -16px; }
  .card > div > .tablebox:first-child:last-child { margin-bottom: -16px; }
  .grid, .grid-2 { gap: 14px; }
  .chart { height: 230px; }
  .tile .pill { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
  .tile .pill::before { display: inline-block; margin-right: 5px; vertical-align: middle; }
  .thumb-spec { grid-template-columns: 1fr; }
  .thumb-frame { max-width: 200px; }
  .tablebox { max-height: none; overscroll-behavior-x: contain; }
  thead th { position: static; }
  td.wrap { min-width: 170px; }
  .tablebox tr > :first-child { position: sticky; left: 0; z-index: 1; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
  .tablebox thead tr > :first-child, .tablebox tfoot tr > :first-child { background: var(--panel-2); }

  /* hộp thoại thành tấm trượt từ đáy */
  dialog, dialog.wide, dialog.xwide { width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-width: 1px 0 0; border-radius: 22px 22px 0 0; overscroll-behavior: contain; }
  dialog.palette-dlg { margin: 8vh 0 auto; border-width: 0 0 1px; border-radius: 0 0 22px 22px; }
  dialog.palette-dlg .dlg::before, .palette-dlg .palette::before { display: none; }
  @keyframes dlg-in { from { transform: translateY(32px); opacity: .4; } to { transform: none; opacity: 1; } }
  .dlg { padding: 10px 16px calc(16px + var(--safe-b)); }
  .dlg::before { content: ""; flex: none; align-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--line); }
  .dlg > .dlg-actions:last-child { position: sticky; bottom: 0; margin: 0 -16px calc(-16px - var(--safe-b)); padding: 12px 16px calc(12px + var(--safe-b)); border-radius: 0; }
  .dlg-actions .btn { flex: 1 1 auto; justify-content: center; }
  .dlg-actions .left { flex-basis: 100%; margin: 0; }
  .picker-menu { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(var(--tabbar) + 14px + var(--safe-b)); min-width: 0; max-width: none; max-height: 70dvh; overflow-y: auto; }

  /* bảng việc: mỗi cột gần trọn màn hình, vuốt ngang bắt dính từng cột */
  .board { grid-auto-columns: min(84vw, 320px); scroll-snap-type: x mandatory; scroll-padding: 0 16px; margin: 0 -16px; padding: 0 16px 8px; }
  .lane, .day { scroll-snap-align: start; }
  .week-wrap { grid-template-columns: minmax(0, 1fr); }
  .week { grid-template-columns: repeat(7, min(78vw, 300px)); scroll-snap-type: x mandatory; }
  .day { min-height: 180px; }
  .month { gap: 2px; }
  .month-head { font-size: 11px; }
  .mcell { min-height: 58px; padding: 4px 3px; border-radius: 6px; }
  .mtask { height: 4px; padding: 0; font-size: 0; border-radius: 2px; }

  /* hộp thư: danh sách trước, bấm vào mới mở hội thoại trọn màn hình, có nút quay lại */
  .chat { display: block; min-height: 0; }
  .chat-list { max-height: none; }
  .chat-thread { display: none; }
  .chat.show-thread .chat-list { display: none; }
  .chat.show-thread .chat-thread { display: flex; max-height: none; height: calc(100dvh - var(--tabbar) - 28px - var(--safe-b)); scroll-margin-top: 8px; }
  .view:has(.chat.show-thread) > .toolbar, .view:has(.chat.show-thread) > .page-chips { display: none; }
  .chat-back { display: inline-flex; }
  .conv { padding: 12px; }
  .thread-head { flex-wrap: wrap; gap: 6px 8px; }
  .thread-head .spacer, .thread-head > .small.muted, .thread-head > .page-tag, .track > .muted { display: none; }
  .thread-head > strong { flex: 1 1 calc(100% - 60px); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ad-src { flex-wrap: nowrap; align-items: flex-start; font-size: 12px; }
  .ad-src > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .page-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; }
  .page-chip, .page-chips .btn { flex: none; }
  .page-chip > span:not(.dot, .cnt, .badge) { max-width: 56vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .msg { max-width: 86%; }
  .bubble img { max-width: 100%; }
  .track input[type="text"], .track select { flex: 1 1 140px; min-width: 0; min-height: 38px; font-size: 16px; }

  /* đăng nhập: tấm thương hiệu thu thành dải trên cùng */
  .login { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .login-brand { padding: calc(28px + env(safe-area-inset-top, 0px)) 24px 28px; justify-content: center; gap: 12px; min-height: 36vh; }
  .login-brand .logo { width: 180px; }
  .login-lead { font-size: 15px; }
  .login-card { margin: -28px 0 24px; padding: 26px 22px; box-shadow: var(--shadow-lg); }
  .oauth-page { margin: 6vh 16px; padding: 22px; }
}
@media screen and (max-width: 600px) {
  .tiles, .tiles.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tiles > .tile:only-child, .tiles.kpi > .tile.hero { grid-column: 1 / -1; }
  .tile { padding: 14px; gap: 8px; }
  .tile .value { font-size: 22px; white-space: normal; overflow-wrap: anywhere; }
  .tile-body { flex-wrap: wrap; }
  .spark { width: 72px; height: 26px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: 8px; }
}
@media screen and (max-width: 380px) {
  .tabbar { left: 8px; right: 8px; padding: 4px; }
  .tabbar a, .tabbar button { padding-inline: 0; font-size: 10.5px; }
  .tabbar span { padding: 0 2px; }
}
