/* Flyhub: lấy từ hệ thống thiết kế docs/giao-dien.html (v0.2, màu logo navy #211D6E, cam #EA7F0A).
   Đổi màu hay thành phần thì sửa ở docs/giao-dien.html trước, rồi chép sang đây. */
:root {
  --bg: #f7f7fb; --bg-subtle: #efeff6; --surface: #ffffff; --surface-hover: #f4f4fa;
  --border: #e3e2ee; --border-strong: #cdcbe0;
  --text: #17153b; --text-2: #4b4968; --text-3: #83819e;
  --accent: #211d6e; --accent-hover: #2e2992; --accent-active: #18154f; --accent-fg: #ffffff; --accent-soft: #ecebf8; --accent-text: #2f2a8f;
  --ring: rgba(46, 41, 146, .22);
  --highlight: #ea7f0a; --highlight-fg: #ffffff; --highlight-soft: #fdf0e1; --highlight-text: #a35400;
  --success: #16794a; --success-soft: #e6f4ec;
  --warning: #8f6400; --warning-soft: #fbf3d3;
  --danger: #c42b4b; --danger-soft: #fceaee;
  --neutral-soft: #eeedf4;
  --sb-bg: #1c1960; --sb-border: rgba(255,255,255,.08); --sb-text: #c9c7ea; --sb-text-strong: #ffffff; --sb-muted: #8f8cc4; --sb-hover: rgba(255,255,255,.07); --sb-active: rgba(255,255,255,.13);
  --shadow-sm: 0 1px 2px rgba(23,21,59,.06);
  --shadow-lg: 0 20px 48px rgba(23,21,59,.20), 0 2px 6px rgba(23,21,59,.08);
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0a1c; --bg-subtle: #11102a; --surface: #161532; --surface-hover: #1d1c3e;
    --border: #272552; --border-strong: #363466;
    --text: #eceaf7; --text-2: #aeacce; --text-3: #75739c;
    --accent: #7d77e8; --accent-hover: #928df0; --accent-active: #6a64d6; --accent-fg: #0b0a1c; --accent-soft: #1f1d4a; --accent-text: #aba7f6;
    --ring: rgba(125, 119, 232, .32);
    --highlight: #f2902a; --highlight-fg: #1a0e00; --highlight-soft: #33220f; --highlight-text: #f7ae5e;
    --success: #4cc38a; --success-soft: #12291f;
    --warning: #e3b341; --warning-soft: #2c2510;
    --danger: #f0697f; --danger-soft: #331a22;
    --neutral-soft: #1e1d3c;
    --sb-bg: #100f28; --sb-border: rgba(255,255,255,.06); --sb-text: #b4b2d6; --sb-muted: #75739c; --sb-hover: rgba(255,255,255,.05); --sb-active: rgba(255,255,255,.09);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 20px 48px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--ring); border-radius: 4px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

/* Khung */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sb-bg); color: var(--sb-text); border-right: 1px solid var(--sb-border); display: flex; flex-direction: column; padding: 12px 8px; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 8px 12px; font-weight: 600; font-size: 15px; color: var(--sb-text-strong); }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: #fff; padding: 3px; display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.nav-title { font-size: 11px; font-weight: 500; color: var(--sb-muted); text-transform: uppercase; letter-spacing: .06em; padding: 16px 8px 4px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: var(--r-sm); color: var(--sb-text); font-weight: 500; font-size: 13.5px; }
.nav-item:hover { background: var(--sb-hover); color: var(--sb-text-strong); text-decoration: none; }
.nav-item.active { background: var(--sb-active); color: var(--sb-text-strong); }
.nav-item.active::before { content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--highlight); }
.sidebar-foot { margin-top: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 1px solid var(--border); }
.topbar .spacer { flex: 1; }
.content { width: 100%; max-width: 1280px; padding: 24px 24px 40px; display: flex; flex-direction: column; gap: 24px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); font-size: 13.5px; }

/* Nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid transparent; font: 500 13px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:active:not([disabled]) { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--text-3); }
.btn-ghost { background: transparent; color: var(--sb-text); }
.btn-ghost:hover { background: var(--sb-hover); color: var(--sb-text-strong); }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* Thẻ, trạng thái trống, khung báo */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 16px; text-align: center; color: var(--text-2); }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--neutral-soft); color: var(--text-2); }
.badge.brand { background: var(--highlight-soft); color: var(--highlight-text); }

/* Trang đăng nhập và trang báo */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth { width: 100%; max-width: 400px; padding: 32px 28px; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.auth .brand { justify-content: center; color: var(--text); font-size: 18px; padding: 0; }
.auth .brand-mark { width: 36px; height: 36px; border: 1px solid var(--border); }
.auth h1 { margin: 0; font-size: 18px; font-weight: 600; }
.auth p { margin: 0; color: var(--text-2); }
.auth .tg-pin { margin: 0; font-size: 40px; font-weight: 700; letter-spacing: 4px; color: var(--text); font-variant-numeric: tabular-nums; }
.auth form { display: flex; flex-direction: column; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .nav-title, .sidebar-foot { display: none; }
  .content { padding: 20px 16px 40px; }
}

/* ---------- Giai đoạn 1: bảng, form, nhãn, khung báo (theo docs/giao-dien.html) ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-hover); }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t1 { font-weight: 500; }
.t2 { font-size: 12.5px; color: var(--text-3); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 13px; font-weight: 500; }
.hint { font-size: 12.5px; color: var(--text-3); }
.err-text { font-size: 12.5px; color: var(--danger); }
.input, .select, .textarea { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: 14px var(--font); }
.textarea { height: auto; min-height: 120px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.is-error { border-color: var(--danger) !important; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info, .badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.callout { padding: 12px 14px; border-radius: var(--r-md); font-size: 13.5px; border: 1px solid var(--border); background: var(--surface); }
.callout.ok { background: var(--success-soft); border-color: transparent; }
.callout.warning { background: var(--warning-soft); border-color: transparent; }
.callout.danger { background: var(--danger-soft); border-color: transparent; }
.callout.info { background: var(--accent-soft); border-color: transparent; }
.inline { display: inline; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent-text); font: inherit; cursor: pointer; }
.main .btn-ghost { color: var(--text-2); }
.main .btn-ghost:hover { background: var(--neutral-soft); color: var(--text); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat .k { font-size: 12.5px; color: var(--text-2); }
.stat .v { font-size: 24px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.nav-item .count { margin-left: auto; font-size: 11.5px; color: var(--sb-muted); }
.nav-item .count.alert { color: var(--highlight-fg); background: var(--highlight); font-weight: 600; border-radius: 999px; padding: 0 6px; line-height: 18px; }
@media (max-width: 860px) {
  .form-grid, .stats { grid-template-columns: minmax(0, 1fr); }
}
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.row-form .input { flex: 1; min-width: 160px; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* Lớp tiện ích thay cho thuộc tính style="" (CSP style-src 'self' chặn style viết thẳng trong thẻ). */
.w-56 { width: 56px; min-width: 0; flex: none; }
.w-110 { width: 110px; }
.w-130 { width: 130px; }
.w-160 { width: 160px; }
.w-170 { width: 170px; }
.w-240 { width: 240px; }
.minw-0 { min-width: 0; }
.mh-160 { min-height: 160px; }
.mh-200 { min-height: 200px; }
.mh-240 { min-height: 240px; }
.pre-wrap { white-space: pre-wrap; }
.file-input { height: auto; padding: 6px; }
.self-end { align-self: flex-end; }
.items-start { align-items: flex-start; }
.gap-6 { gap: 6px; }
.gap-10 { gap: 10px; }
.my-8 { margin: 8px 0; }
.mt-6 { margin-top: 6px; }
.break-all { word-break: break-all; }
.clip-520 { max-width: 520px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb { border-radius: 6px; object-fit: cover; flex: none; }
.img-preview { max-width: 320px; max-height: 320px; border-radius: 8px; object-fit: contain; }

/* Kho viral */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.story { position: relative; display: flex; flex-direction: column; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.story:hover { border-color: var(--border-strong); }
.story:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.story .story-img { width: 100%; height: 160px; object-fit: cover; display: block; background: var(--border); }
.story .pick { position: absolute; top: 10px; left: 10px; }
.story .pick input { width: 18px; height: 18px; }
.story .score { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.55); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.story .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.story .cap { font-size: 13.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.story .meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }

/* Nhập nhanh (lưới như Google Sheets, theo docs/giao-dien.html) */
.qe-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; }
.qe-bar .sum { font-size: 13px; color: var(--text-2); margin-right: auto; }
.qe-bar .sum .bad { color: var(--danger); font-weight: 500; }
.qe-wrap { overflow: auto; max-height: 62vh; }
table.qe { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 1180px; width: 100%; }
.qe th { position: sticky; top: 0; z-index: 2; text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 8px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; }
.qe th .req { color: var(--danger); }
.qe td { padding: 0; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); vertical-align: top; background: var(--surface); }
.qe td.n { width: 40px; text-align: center; color: var(--text-3); font-size: 12px; padding-top: 9px; background: var(--bg-subtle); }
.qe td.st { width: 150px; padding: 8px; font-size: 12px; line-height: 1.35; }
.qe td.st.ok { color: var(--success); } .qe td.st.bad { color: var(--danger); } .qe td.st.warn { color: var(--warning); } .qe td.st.blank { color: var(--text-3); }
.qe-cell { display: block; width: 100%; min-height: 34px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; line-height: 1.4; padding: 8px; resize: none; outline: 0; }
textarea.qe-cell { height: 34px; overflow: hidden; }
textarea.qe-cell:focus { height: 96px; overflow: auto; position: relative; z-index: 1; background: var(--surface); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
select.qe-cell { cursor: pointer; }
.qe td:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.qe td.bad { background: var(--danger-soft); }
.qe td.bad:focus-within { box-shadow: inset 0 0 0 2px var(--danger); }
.qe-help { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.qe-help .card { padding: 12px 16px; font-size: 13px; color: var(--text-2); }
.qe-help b { color: var(--text); display: block; margin-bottom: 2px; }
@media (max-width: 1280px) { .qe-help { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .qe-help { grid-template-columns: minmax(0, 1fr); } }
.mw-150 { min-width: 150px; } .mw-160 { min-width: 160px; } .mw-190 { min-width: 190px; } .mw-200 { min-width: 200px; } .mw-260 { min-width: 260px; }
.vid-thumb { width: 44px; height: 44px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-size: 16px; }
.mw-90 { min-width: 90px; }
.gap-12 { gap: 12px; }
/* Web viết sẵn: tab lọc theo trạng thái, ô câu CTA để chép */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs .tab { padding: 8px 12px; color: var(--text-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .tab .count { font-size: 12px; color: var(--text-3); margin-left: 4px; }
.cta-box { min-height: 72px; }
