:root {
  --bg: #f5f7fb; --card: #fff; --ink: #1d2433; --muted: #667085; --line: #e3e8ef;
  --brand: #0068ff; --brand-soft: #e8f1ff; --ok: #12a150; --warn: #c98200; --bad: #d92d20;
  --thieu-bg: #fff4ce; --thieu: #b42318; --radius: 10px;
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 6px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #b8c4d6; text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; color: var(--ink); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
input:focus, textarea:focus, select:focus, [contenteditable]:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

header.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
header.top .logo { font-weight: 700; color: var(--brand); }
header.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--ink); }
header.top nav a.on { background: var(--brand-soft); color: var(--brand); }
header.top .me { margin-left: auto; color: var(--muted); display: flex; gap: 8px; align-items: center; }
main { max-width: 1400px; margin: 0 auto; padding: 20px; }
h1.page { font-size: 20px; margin: 0 0 4px; }
.sub { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: #eef2f6; color: var(--muted); }
.badge.team { background: var(--brand-soft); color: var(--brand); }
.badge.chot { background: #e7f6ec; color: var(--ok); }
.badge.moi { background: #fde8e7; color: var(--bad); }
.badge.tay { background: #fff4ce; color: #8a5a00; }
.badge.auto { background: #e7f6ec; color: var(--ok); }
.muted { color: var(--muted); }
.list { border-collapse: collapse; width: 100%; }
.list th, .list td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list th { color: var(--muted); font-weight: 600; font-size: 12px; }
.empty { color: var(--muted); padding: 20px; text-align: center; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 100; max-width: 90vw; }
.toast.err { background: var(--bad); }

/* editor layout */
.ed { display: grid; grid-template-columns: 220px minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1200px) { .ed { grid-template-columns: 200px minmax(0, 1fr); } .ed .side-r { grid-column: 1 / -1; } }
@media (max-width: 760px) { .ed { grid-template-columns: 1fr; } }
.side { position: sticky; top: 70px; }
.secnav a { display: flex; justify-content: space-between; gap: 6px; padding: 7px 10px; border-radius: 8px; color: var(--ink); }
.secnav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.secnav .dot { width: 8px; height: 8px; border-radius: 50%; background: #d0d5dd; margin-top: 7px; flex: none; }
.secnav .dot.half { background: var(--warn); } .secnav .dot.full { background: var(--ok); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; }
.tabs button.on { border-bottom-color: var(--brand); color: var(--brand); font-weight: 600; }
.q { margin-bottom: 14px; }
.q label { display: block; font-weight: 600; margin-bottom: 4px; }
.q .hint { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.guide { background: var(--brand-soft); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }
.rep { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 14px; }
.rep > .rep-h { font-weight: 700; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.rep > .rep-h input { flex: 1; font-weight: 600; }
.prev-ctx { white-space: pre-wrap; font-size: 12px; color: var(--muted); background: #fafbfc; border: 1px dashed var(--line); border-radius: 6px; padding: 6px 8px; margin-bottom: 8px; max-height: 160px; overflow: auto; }
.suggest { font-size: 12px; background: #fafbfc; border: 1px dashed var(--line); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; }
.suggest li { cursor: pointer; } .suggest li:hover { color: var(--brand); }

table.num { border-collapse: collapse; width: 100%; margin: 6px 0 16px; font-size: 13px; }
table.num th, table.num td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; }
table.num th { background: #f2f6fc; font-weight: 600; }
table.num td.v { text-align: right; white-space: nowrap; }
table.num input { width: 100%; min-width: 60px; padding: 3px 5px; border-radius: 6px; }
table.num td.v input { text-align: right; width: 90px; }
table.num .src { font-size: 11px; color: var(--muted); display: block; }
.tbl-h { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.tbl-h h4 { margin: 0; }
.note { font-size: 12px; color: #8a5a00; }

.doc { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px 22px; min-height: 300px; }
.doc h1 { font-size: 19px; margin: 0 0 10px; color: #0b3b8c; }
.doc h2 { font-size: 16px; margin: 16px 0 8px; color: #0b3b8c; }
.doc h3 { font-size: 14px; margin: 12px 0 6px; }
.doc p { margin: 0 0 8px; }
.doc table { border-collapse: collapse; width: 100%; margin: 6px 0 12px; font-size: 13px; }
.doc th, .doc td { border: 1px solid #c9d2df; padding: 4px 6px; vertical-align: top; }
.doc th { background: #e8f1fb; }
.doc .thieu, .thieu { background: var(--thieu-bg); color: var(--thieu); }
.doc .ghichu { font-size: 12px; color: var(--muted); font-style: italic; }
.doc [data-dong-gop] { border-left: 3px solid var(--brand); padding-left: 8px; margin: 8px 0; }
.doc [data-dong-gop]::before { content: "Đóng góp của " attr(data-tu); display: block; font-size: 11px; color: var(--brand); }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; position: sticky; top: 60px; background: var(--bg); padding: 4px 0; z-index: 5; }
.toolbar button { padding: 4px 8px; }
.savestate { font-size: 12px; color: var(--muted); }
.lib-sec { margin-bottom: 18px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .compare { grid-template-columns: 1fr; } }

dialog { border: none; border-radius: 12px; padding: 0; width: min(760px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16,24,40,.45); }
dialog .dh { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; }
dialog .db { padding: 16px 18px; max-height: 70vh; overflow: auto; }
dialog .df { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.code { font-family: Consolas, monospace; font-size: 12px; background: #f6f8fa; border: 1px solid var(--line); border-radius: 6px; padding: 8px; white-space: pre-wrap; max-height: 300px; overflow: auto; }
.login { max-width: 420px; margin: 60px auto; }
.big-code { font-family: Consolas, monospace; font-size: 22px; letter-spacing: 2px; background: #f6f8fa; padding: 8px 12px; border-radius: 8px; display: inline-block; }

/* gop y (binh luan) — 03/10/2026 */
.blc { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.rtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 10px; }
.rtabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 6px 10px; }
.rtabs button.on { border-bottom-color: var(--brand); color: var(--brand); font-weight: 600; }
.bl-new { margin-bottom: 12px; }
.bl-new textarea { min-height: 64px; }
.bl { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; background: #fff; }
.bl.done { background: #fafbfc; }
.bl.rep2 { border: none; border-left: 3px solid var(--brand-soft); border-radius: 0; margin: 6px 0 0 6px; padding: 4px 8px; }
.bl-h { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bl blockquote { margin: 4px 0; padding: 4px 8px; border-left: 3px solid #f0c36d; background: #fffaf0; color: var(--muted); font-size: 12px; max-height: 90px; overflow: auto; }
.bl-b { margin-top: 2px; white-space: normal; word-break: break-word; }
.bl-a { display: flex; gap: 10px; margin-top: 4px; font-size: 12px; }
.bl-a a.danger { color: var(--bad); }
.bl-reply:empty { display: none; }
.bl-reply { margin-top: 6px; }
/* AI soan nhap */
.sn-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.sn-ai { margin-top: 4px; padding: 6px 8px; background: #f7f9fc; border-radius: 6px; font-size: 13px; }
