:root {
  --bg: #f6f7f9; --card: #fff; --text: #1b1d22; --muted: #6b7280; --line: #e5e7eb;
  --accent: #e5484d; --accent-2: #c93a3f; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --chip: #f1f2f4; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111317; --card: #1a1d23; --text: #e8eaee; --muted: #9aa1ad; --line: #2a2e36;
          --chip: #242830; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: .5rem 0; }
main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
section { margin-bottom: 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.bad-text { color: var(--bad); font-weight: 600; }

/* thanh trên */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.brand.big { font-size: 1.4rem; justify-content: center; }
.logo { display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 8px; background: var(--accent); color: #fff; font-size: .8em; }
.topbar nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.topbar nav a { color: var(--muted); padding: .35rem .7rem; border-radius: 8px; white-space: nowrap; }
.topbar nav a.on, .topbar nav a:hover { color: var(--text); background: var(--chip); text-decoration: none; }
.pill { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 .45em; font-size: .75rem; font-weight: 700; }
.logout { margin-left: auto; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }

/* thẻ, lưới */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.grid2 > .card { margin: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.row-between h1, .row-between h2, .row-between h3 { margin-bottom: .5rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value, p.value { font-size: 1.5rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; margin: .1rem 0; }
p.value { font-size: 1.1rem; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.bad { background: var(--bad); }

/* form */
label { display: block; margin-bottom: .9rem; font-size: .9rem; color: var(--muted); }
input, select, textarea { display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
textarea { resize: vertical; }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); flex-wrap: wrap; }
label.check input { width: auto; margin: 0; }
form.inline { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
form.inline input { margin: 0; }
.form h2 { margin-top: 1.2rem; }
.form h2:first-of-type { margin-top: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .55rem 1rem; font: inherit; font-weight: 600;
  border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--chip); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn.wide { width: 100%; margin-top: .6rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { display: block; width: 100%; text-align: left; margin-top: .4rem; padding: .45rem .7rem; font: inherit; font-size: .9rem;
  background: var(--chip); color: var(--text); border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }

.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.flash.ok { background: color-mix(in srgb, var(--ok) 10%, var(--card)); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.flash.error { background: color-mix(in srgb, var(--bad) 10%, var(--card)); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.flash.warn { background: color-mix(in srgb, var(--warn) 10%, var(--card)); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

/* thẻ video */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.vcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: var(--shadow); transition: transform .12s; }
.vcard:hover { transform: translateY(-2px); text-decoration: none; border-color: var(--accent); }
.thumb { position: relative; aspect-ratio: 9/14; background: var(--chip); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 1.5rem; }
.thumb .badge { position: absolute; left: .5rem; top: .5rem; }
.vbody { padding: .6rem .75rem .75rem; }
.vtitle { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.step { color: var(--warn); margin-top: .2rem; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; color: #fff; background: #6b7280; white-space: nowrap; }
.badge.big { font-size: .85rem; padding: .3rem .8rem; }
.s-pending_review { background: #2563eb; }
.s-approved { background: #7c3aed; }
.s-uploaded { background: var(--ok); }
.s-failed, .s-stuck { background: var(--bad); }
.s-researching, .s-producing { background: var(--warn); }
.s-dropped { background: #9ca3af; }

.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .3rem .75rem; border-radius: 999px; background: var(--chip); color: var(--muted); font-size: .85rem; }
.tabs a.on { background: var(--text); color: var(--bg); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on:hover { color: var(--bg); }

/* chi tiết */
.detail { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 1.5rem; margin-bottom: 1.5rem; align-items: start; }
.detail .card { margin-bottom: 1rem; }
.player video { width: 100%; aspect-ratio: 9/16; background: #000; border-radius: var(--radius); display: block; }
.placeholder { aspect-ratio: 9/16; display: flex; align-items: center; justify-content: center; gap: .5rem; background: var(--chip); border-radius: var(--radius); color: var(--muted); }
.scenes li { margin-bottom: .7rem; }
.active-row { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.active-row:last-child { border-bottom: 0; }
.progress { color: var(--warn); display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; }
.spinner { width: .9em; height: .9em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .5rem .25rem; border-bottom: 1px solid var(--line); text-align: left; }
.table th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

.log { background: #0f1115; color: #d1d5db; padding: 1rem; border-radius: 10px; max-height: 520px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 ui-monospace, Consolas, monospace; margin: 0; }
details { padding: .4rem 0; border-bottom: 1px solid var(--line); }
details pre { margin-top: .5rem; }

.niches { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: .75rem; }
.niche { border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; display: flex; flex-direction: column; }
.niche form { margin-top: auto; }
.niche ul { padding-left: 1.1rem; margin: .4rem 0 .8rem; }

/* chung (mới) */
.plain { list-style: none; padding-left: 0; }
.plain li { margin-bottom: .3rem; }
.prose { white-space: pre-line; }
a.b { font-weight: 700; text-decoration: underline; }
.hot { color: var(--accent); font-weight: 700; }
.avatar-sm { width: 26px; height: 26px; border-radius: 50%; vertical-align: middle; }
.logout { display: flex; align-items: center; gap: .5rem; }
.who { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge.fmt { background: rgba(0,0,0,.65); }
.thumb .badge.fmt { left: auto; right: .5rem; }
.seg { display: flex; gap: .5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.seg label { display: flex; align-items: center; gap: .4rem; margin: 0; padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 8px; color: var(--text); cursor: pointer; }
.seg input { width: auto; margin: 0; }
.seg label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.days { display: flex; gap: .4rem 1rem; flex-wrap: wrap; margin: -.5rem 0 .9rem; }
.days label { margin: 0; }
.table-wrap { overflow-x: auto; }
.btn.google { background: #fff; color: #1f1f1f; border-color: #dadce0; gap: .6rem; }
.btn.google:hover { background: #f8f9fa; }
details.pw { margin-top: 1rem; text-align: left; }
details.pw summary { cursor: pointer; text-align: center; }

/* ý tưởng */
.igrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.idea { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .35rem; box-shadow: var(--shadow); }
.idea .actions { margin: auto 0 0; padding-top: .5rem; }
.actions.tight { gap: .35rem; }
.ititle { font-weight: 700; line-height: 1.3; }
.hook { font-style: italic; }
.score { font-weight: 800; font-size: 1.05rem; padding: .05rem .5rem; border-radius: 6px; background: var(--chip); }
.score.mid { background: color-mix(in srgb, var(--warn) 18%, var(--card)); color: var(--warn); }
.score.hi { background: color-mix(in srgb, var(--ok) 18%, var(--card)); color: var(--ok); }

/* video viral */
.trend-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: .75rem; }
.trend { display: grid; grid-template-columns: 140px 1fr; gap: .75rem; color: var(--text); padding: .5rem; border-radius: 10px; }
.trend:hover { background: var(--chip); text-decoration: none; }
.trend img { width: 140px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: var(--chip); }
.ttitle { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* kênh */
.chhead { display: flex; align-items: center; gap: 1rem; }
.chhead h2 { margin: 0; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.avatar.big { width: 160px; height: 160px; display: block; margin-bottom: .5rem; }
.brand-imgs { display: grid; grid-template-columns: 170px 1fr; gap: 1rem; margin-bottom: 1rem; align-items: start; }
.banner { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; margin-bottom: .5rem; display: block; }

/* video dài */
.vcard.wide .thumb { aspect-ratio: 9/14; }
.detail.long { grid-template-columns: minmax(320px, 640px) 1fr; }
.detail.long .player video, .detail.long .placeholder { aspect-ratio: 16/9; }
.thumbimg { width: 100%; border-radius: 10px; display: block; }
h3.chapter { margin: 1rem 0 .4rem -1rem; color: var(--accent); }

/* đăng nhập */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card.login { width: 100%; max-width: 360px; text-align: center; }
.card.login label { text-align: left; }

.trend-list { grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); }
.igrid { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
@media (max-width: 720px) {
  .detail, .detail.long { grid-template-columns: 1fr; }
  .brand-imgs { grid-template-columns: 1fr; }
  .trend { grid-template-columns: 110px 1fr; }
  .trend img { width: 110px; }
  .who { display: none; }
  .detail.long .player { max-width: none; }
  .player { max-width: 360px; margin: 0 auto; width: 100%; }
  .topbar { gap: .5rem; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .vgrid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  form.inline { flex-wrap: wrap; }
  h1 { font-size: 1.25rem; }
}
