/* VimAI Ecom OS — phần thêm khi gộp thành một OS: màn đăng nhập, ô người dùng, phân quyền, kênh bán, bản đồ AI OS, log agent.
   Chỉ dùng biến màu của base.css nên tự có đủ sáng / tối và ba theme. Mã tự viết — mR47 — Phong Creator. */

/* ---------- nút đang chờ máy chủ ---------- */
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy > * { visibility: hidden; }
.btn.busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; border: 2px solid var(--text-2); border-top-color: transparent; animation: ec-spin .7s linear infinite; }
.btn.primary.busy::after { border-color: var(--accent-ink); border-top-color: transparent; }
@keyframes ec-spin { to { transform: rotate(360deg); } }

/* ---------- màn đăng nhập / quên mật khẩu / tạo tài khoản ---------- */
body.on-auth { overflow: auto; }
#app.auth { display: block; height: auto; width: auto; min-height: calc(100vh / var(--scale)); background: radial-gradient(1100px 520px at 50% -12%, var(--accent-soft), transparent 62%), var(--bg-2); }
.au-wrap { position: relative; min-height: calc(100vh / var(--scale)); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px 24px; }
.au-card { width: min(412px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px 28px 24px; box-shadow: 0 26px 80px rgba(0, 0, 0, .32); }
html[data-mode="light"] .au-card { box-shadow: 0 20px 60px rgba(20, 30, 60, .14); }
.au-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.au-logo { width: 36px; height: 36px; border-radius: 9px; }
.au-brand b { display: block; font-size: 16px; letter-spacing: -.005em; }
.au-brand small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.au-card h1 { font-size: 19px; margin: 0 0 4px; letter-spacing: -.01em; }
.au-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; line-height: 1.5; }
.au-field { display: block; margin-bottom: 13px; }
.au-field > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.au-field > small { display: block; color: var(--dim); font-size: 11px; margin-top: 5px; }
.au-field .input { width: 100%; padding: 10px 12px; font-size: 14px; border-radius: 9px; }
.au-pw { position: relative; }
.au-pw .input { width: 100%; padding-right: 42px; }
.au-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); padding: 7px; border-radius: 7px; display: inline-flex; }
.au-eye:hover { color: var(--text); background: rgba(var(--ov), .06); }
.au-code { letter-spacing: .26em; font-size: 18px !important; text-align: center; }
.au-check { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--text-2); margin: 2px 0 2px; cursor: pointer; line-height: 1.45; }
.au-check input { margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.au-submit { margin-top: 14px; padding: 11px; font-size: 14px; border-radius: 9px; }
.au-err, .au-ok { padding: 9px 11px; border-radius: 8px; font-size: 12.5px; line-height: 1.45; }
.au-err { margin: 12px 0 0; background: var(--red-soft); border: 1px solid rgba(255, 107, 107, .45); color: var(--red); }
.au-ok { margin: 0 0 14px; background: var(--green-soft); border: 1px solid rgba(61, 220, 151, .4); color: var(--green); }
.au-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 12.5px; }
.au-note { color: var(--dim); font-size: 11.5px; line-height: 1.55; margin: 14px 0 0; }
.au-note p { margin: 0 0 8px; color: var(--text-2); font-size: 12.5px; }
.au-note code { display: block; margin-top: 4px; font-family: var(--mono); font-size: 11px; background: rgba(var(--ov), .06); padding: 8px 10px; border-radius: 7px; color: var(--text-2); word-break: break-all; }
.au-foot { margin-top: 18px; display: flex; gap: 16px; font-size: 11.5px; color: var(--dim); flex-wrap: wrap; justify-content: center; }
.au-foot a { color: var(--muted); }
.au-mode { position: absolute; top: 14px; right: 16px; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.au-mode:hover { color: var(--text); background: rgba(var(--ov), .06); }
.au-meter { display: flex; align-items: center; gap: 9px; margin: -6px 0 12px; font-size: 11px; color: var(--dim); }
.au-meter > div { flex: none; width: 96px; height: 4px; border-radius: 4px; background: var(--track); overflow: hidden; }
.au-meter i { display: block; height: 100%; width: 0; background: var(--red); transition: width .2s, background .2s; }
.au-meter[data-s="1"] i { width: 25%; }
.au-meter[data-s="2"] i { width: 50%; background: var(--orange); }
.au-meter[data-s="3"] i { width: 75%; background: var(--yellow); }
.au-meter[data-s="4"] i { width: 100%; background: var(--green); }
.au-meter[data-s="3"] span, .au-meter[data-s="4"] span { color: var(--green); }

/* ---------- ô người dùng ở chân thanh bên ---------- */
.sb-foot { cursor: pointer; }
.sb-foot:hover { background: rgba(var(--ov), .04); }
.sb-foot.err .dot { background: var(--red); }
.sb-av { position: relative; width: 28px; height: 28px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #8088a4, #5d6480); letter-spacing: .02em; }
.sb-av.r-owner { background: linear-gradient(135deg, #f0b44c, #d9782a); }
.sb-av.r-admin { background: linear-gradient(135deg, #8f7df5, #5c48cc); }
.sb-av.r-manager { background: linear-gradient(135deg, #4bb4e6, #2a78b8); }
.sb-av.r-staff { background: linear-gradient(135deg, #3fc493, #23876a); }
.sb-av.r-finance { background: linear-gradient(135deg, #e07aa8, #a8457a); }
.sb-foot .sb-av .dot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border: 2px solid var(--sb); box-shadow: none; }
.sb-foot-txt b { max-width: 118px; }
.um { position: fixed; z-index: 90; width: 236px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 18px 50px rgba(0, 0, 0, .4); padding: 6px; }
.um-h { padding: 8px 10px 9px; border-bottom: 1px solid var(--line-2); margin-bottom: 5px; }
.um-h b { display: block; font-size: 13px; }
.um-h small { color: var(--dim); font-size: 11px; }
.um-it { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: transparent; color: var(--text-2); padding: 7px 10px; border-radius: 7px; font-size: 12.5px; text-align: left; }
.um-it:hover { background: rgba(var(--ov), .07); color: var(--text); }
.um-it.red { color: var(--red); }
.um-sep { height: 1px; background: var(--line-2); margin: 5px 0; }
.um-note { padding: 4px 10px 8px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }

/* ---------- vai trò, không có quyền, ô chép ---------- */
.chip.role { font-weight: 600; }
.chip.role.r-owner { background: var(--yellow-soft); color: var(--yellow); }
.chip.role.r-admin { background: var(--purple-soft); color: var(--purple); }
.chip.role.r-manager { background: var(--accent-soft); color: var(--accent); }
.chip.role.r-staff { background: var(--green-soft); color: var(--green); }
.chip.role.r-finance { background: var(--orange-soft); color: var(--orange); }
.chip.role.r-viewer { background: transparent; border-color: var(--line); color: var(--muted); }
.card.denied { max-width: 520px; margin: 9vh auto 0; padding: 30px 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.card.denied > .ic { color: var(--orange); }
.card.denied b { font-size: 15px; }
.card.denied p { margin: 0 0 6px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.card.denied code { font-family: var(--mono); font-size: 11.5px; background: rgba(var(--ov), .07); padding: 1px 6px; border-radius: 4px; color: var(--text-2); }
.copyf .input { flex: 1; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scroll-x { overflow-x: auto; }
.tbl tr.total td { border-top: 1px solid var(--line); background: rgba(var(--ov), .03); }
.hb-row.fin { grid-template-columns: 118px minmax(0, 1fr) 124px 46px; }
@media (min-width: 1181px) { .grid2.wide-left { grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); } }

/* ---------- phễu ---------- */
.fn-row { display: grid; grid-template-columns: 158px minmax(0, 1fr) 54px 46px; gap: 9px; align-items: center; font-size: 11.5px; padding: 3px 0; color: var(--text-2); }
.fn-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fn-row .bar { height: 7px; }
.fn-row b { text-align: right; font-variant-numeric: tabular-nums; }
.fn-row small { color: var(--dim); text-align: right; font-size: 10.5px; }
.fn-ch { padding: 9px 0 10px; border-bottom: 1px solid var(--line-2); }
.fn-ch:last-child { border-bottom: 0; }
.fn-h { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; font-size: 12.5px; }
.fn-h b { flex: 1; }

/* ---------- kênh bán ---------- */
.chn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(390px, 1fr)); gap: 12px; }
.chn { padding: 13px 14px 10px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.chn.off { opacity: .78; }
.chn-h { display: flex; align-items: center; gap: 10px; }
.chn-h b { display: block; font-size: 13.5px; }
.chn-h small { display: block; color: var(--dim); font-size: 10.5px; margin-top: 1px; }
.chn-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.chn-stats > div { background: rgba(var(--ov), .035); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; min-width: 0; }
.chn-stats small { display: block; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chn-stats b { display: block; font-size: 14.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chn-todo { display: flex; gap: 8px; align-items: flex-start; font-size: 11.5px; color: var(--text-2); background: var(--orange-soft); border-radius: 7px; padding: 7px 9px; line-height: 1.45; }
.chn-todo .ic { color: var(--orange); margin-top: 1px; }
.chn-f { display: flex; gap: 14px; align-items: center; font-size: 11px; color: var(--dim); margin-top: auto; padding-top: 2px; }
.chn-f a { cursor: pointer; }
.chn-sec { font-size: 9.5px; letter-spacing: .12em; color: var(--dim); font-weight: 600; margin-top: 4px; }
.chn-off { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; padding: 18px 4px; }
.tbl.led th, .tbl.led td { padding: 7px 8px; font-size: 11.5px; }

/* ---------- log lượt chạy agent ---------- */
pre.runlog { margin: 0; background: var(--editor); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; font-family: var(--mono); font-size: 11.5px; line-height: 1.55; min-height: 220px; max-height: 56vh; overflow: auto; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
code.runcmd { display: block; font-family: var(--mono); font-size: 11.5px; background: rgba(var(--ov), .05); border: 1px solid var(--line-2); border-radius: 7px; padding: 8px 10px; color: var(--text-2); word-break: break-word; line-height: 1.5; }
.mc-board.live .mc-col { width: 340px; }

/* ---------- người dùng & phân quyền ---------- */
.us-tbl td { padding-top: 8px; padding-bottom: 8px; }
.btn.icon.red:hover { color: var(--red); }
.rl-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rl-card { padding: 11px 13px; }
.rl-card p { margin: 7px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.rl-tbl td, .rl-tbl th { padding: 7px 10px; }
.rl-tbl td:first-child b { font-weight: 500; font-size: 12.5px; }
.rl-tbl td:first-child code { font-family: var(--mono); font-size: 10px; color: var(--dim); margin-left: 9px; }
.rl-tbl .rl-c { text-align: center; width: 104px; }
.rl-tbl tr.rl-g td { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 600; background: rgba(var(--ov), .03); padding: 6px 10px; }
.rl-lock { color: var(--yellow); margin-left: 7px; display: inline-flex; vertical-align: -2px; }
.rl-x { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--accent-ink); padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.rl-x:hover:not(:disabled) { border-color: var(--accent); }
.rl-x.on { background: var(--accent); border-color: var(--accent); }
.rl-x.fixed { cursor: default; opacity: .55; }
.rl-x.on.fixed { background: var(--muted); border-color: var(--muted); color: var(--bg); }
.pm-row { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 12.5px; color: var(--dim); }
.pm-row.on { color: var(--text); }
.pm-row.on .ic { color: var(--green); }
.pm-row code { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--dim); }
.ac-card .field { margin-bottom: 10px; }
.ac-card .input, .ac-card .au-pw { width: 100%; }
.ac-2 { gap: 14px; align-items: flex-start; }
.se .tbl td, .se .tbl th { font-size: 12px; }
.cfg-ta { width: 100%; height: 56vh; font-size: 11.5px; line-height: 1.5; white-space: pre; resize: vertical; }
code.path { font-size: 10.5px; max-width: 340px; word-break: break-all; text-align: right; color: var(--muted); }

/* ---------- bản đồ AI OS ---------- */
.ao-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 12px; flex-wrap: wrap; }
.ao-top h2 { margin: 0 0 3px; font-size: 16px; letter-spacing: -.005em; }
.ao-top p { margin: 0; color: var(--muted); font-size: 12px; max-width: 780px; line-height: 1.5; }
.ao-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.ao-lg { display: inline-flex; align-items: center; gap: 6px; }
.ao-lg b { color: var(--text); }
.ao-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); display: inline-block; flex: none; }
.ok > .ao-dot { background: var(--green); box-shadow: 0 0 7px var(--green); }
.part > .ao-dot { background: var(--yellow); }
.sim > .ao-dot { background: var(--accent); }
.off > .ao-dot { background: transparent; border: 1.5px dashed var(--dim); }
.ao-mc { border: 1px solid var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), transparent 130%); border-radius: 12px; padding: 10px 12px 12px; margin-bottom: 10px; }
.ao-mc-t { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .14em; font-weight: 700; color: var(--accent); margin-bottom: 9px; }
.ao-mc-t small { letter-spacing: 0; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.ao-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 8px; }
.ao-tile { position: relative; display: block; background: var(--card); border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 26px 9px 11px; min-height: 64px; color: var(--text); }
a.ao-tile:hover { border-color: var(--accent-line); background: var(--card-hi); text-decoration: none; }
.ao-tile .ao-ic { color: var(--muted); float: left; margin: 1px 8px 0 0; display: inline-flex; }
.ao-tile b { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.ao-tile small { display: block; clear: both; color: var(--dim); font-size: 10.5px; line-height: 1.35; padding-top: 4px; }
.ao-tile > .ao-dot { position: absolute; top: 12px; right: 10px; }
.ao-tile.off { background: transparent; border-style: dashed; }
.ao-tile.off b { color: var(--muted); }
.ao-body { display: grid; grid-template-columns: 128px minmax(0, 1fr) 128px; gap: 10px; align-items: stretch; }
.ao-side { border: 1px solid var(--line-2); border-radius: 12px; background: var(--card-2); padding: 12px 9px; display: flex; flex-direction: column; gap: 16px; justify-content: center; text-align: center; }
.ao-side > b { font-size: 10.5px; letter-spacing: .14em; color: var(--muted); }
.ao-side.in { border-color: var(--accent-line); }
.ao-side.out { border-color: rgba(61, 220, 151, .4); }
.ao-side > div { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; }
.ao-side small { color: var(--dim); font-weight: 400; font-size: 10.5px; line-height: 1.35; }
.ao-side .ao-ic { color: var(--accent); display: inline-flex; }
.ao-side.out .ao-ic { color: var(--green); }
.ao-layers { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ao-row { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 10px; background: var(--card-2); border: 1px solid var(--line-2); border-radius: 11px; padding: 9px 10px; align-items: center; }
.ao-lab { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ao-lab > i { font-style: normal; width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; background: var(--accent-soft); color: var(--accent); flex: none; }
.ao-lab small { display: block; color: var(--dim); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; }
.ao-lab b { display: block; font-size: 12.5px; line-height: 1.25; }
.ao-lab span { display: block; color: var(--dim); font-size: 10.5px; margin-top: 2px; line-height: 1.3; }
.ao-row.l5 .ao-lab > i { background: var(--purple-soft); color: var(--purple); }
.ao-row.l4 .ao-lab > i { background: var(--green-soft); color: var(--green); }
.ao-row.l3 .ao-lab > i { background: var(--orange-soft); color: var(--orange); }
.ao-row.l2 .ao-lab > i { background: var(--yellow-soft); color: var(--yellow); }
.ao-row.l1 .ao-lab > i { background: var(--red-soft); color: var(--red); }
.ao-loop { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 12px 0 14px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--card-2); }
.ao-step { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; color: var(--text-2); background: var(--card); }
.ao-step:hover { border-color: var(--accent-line); color: var(--text); text-decoration: none; }
.ao-arrow { color: var(--dim); display: inline-flex; }
.ao-arrow.back { color: var(--accent); margin-left: 4px; }

/* ---------- màn hẹp ---------- */
@media (max-width: 1180px) {
	.rl-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.ao-body { grid-template-columns: minmax(0, 1fr); }
	.ao-side { flex-direction: row; flex-wrap: wrap; justify-content: space-around; align-items: flex-start; gap: 10px; }
	.ao-side > b { flex-basis: 100%; }
}
@media (max-width: 760px) {
	.au-card { padding: 22px 20px 20px; }
	.chn-grid { grid-template-columns: minmax(0, 1fr); }
	.chn-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.fn-row { grid-template-columns: 112px minmax(0, 1fr) 46px 40px; }
	.ao-row { grid-template-columns: minmax(0, 1fr); }
	.ao-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.ao-loop { border-radius: 14px; }
	.rl-cards { grid-template-columns: minmax(0, 1fr); }
	.ac-2 { flex-direction: column; }
	.ac-2 > .grow { width: 100%; }
	.mc-board.live .mc-col { width: 86vw; }
	.um { left: 8px !important; }
}

/* ---------- tên “VimAI Ecom OS” vừa một dòng trên thanh bên ---------- */
.sb-head { padding: 13px 8px 8px 14px; gap: 6px; }
.sb-brand { gap: 8px; }
.sb-name { font-size: 14px; letter-spacing: 0; }
.chn-f { flex-wrap: wrap; row-gap: 4px; }
.chn-f a, .chn-f span { white-space: nowrap; }

/* hai link chân trang (bắt buộc ở mọi site của VimAI / Phong Creator) */
.sb-links { flex: none; display: flex; justify-content: center; gap: 10px; padding: 0 10px 8px; font-size: 10.5px; line-height: 1.4; }
.sb-links a { color: var(--muted); text-decoration: none; opacity: .75; }
.sb-links a:hover { color: var(--text); opacity: 1; text-decoration: underline; }
#app.sb-mini .sb-links { display: none; }
