:root {
  --navy: #292A68;
  --navy-dark: #1e1f4e;
  --cam: #F15A22;
  --kem: #FFFBF2;
  --line: #e6e2d8;
  --text: #2b2b3a;
  --muted: #7a7a90;
  --green: #27AE60;
  --red: #C0392B;
  --amber: #E6A700;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Be Vietnam Pro', system-ui, sans-serif; background: var(--kem); color: var(--text); font-size: 14px; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- LOGIN ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px 36px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h1 { color: var(--navy); font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-card label { display: block; font-weight: 600; font-size: 12px; margin: 12px 0 4px; color: var(--navy); }
.login-card input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; }
.login-card input:focus { outline: none; border-color: var(--cam); }
.btn-primary { background: var(--cam); color: #fff; border: none; border-radius: 8px; padding: 11px 18px; font-weight: 700; font-size: 14px; }
.btn-primary:hover { filter: brightness(1.06); }
.login-card .btn-primary { width: 100%; margin-top: 20px; }
.login-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.demo-accounts { margin-top: 18px; background: var(--kem); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ---------- LAYOUT ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--navy); color: #fff; padding: 20px 0; position: fixed; top: 0; bottom: 0; display: flex; flex-direction: column; }
.brand { padding: 0 20px 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand .logo { font-weight: 800; font-size: 17px; }
.brand .logo span { color: var(--cam); }
.demo-badge { display: inline-block; background: var(--cam); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; margin-top: 6px; letter-spacing: .5px; }
.nav { flex: 1; padding: 14px 10px; }
.nav a { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.85); text-decoration: none; padding: 10px 12px; border-radius: 8px; margin-bottom: 4px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: var(--cam); color: #fff; font-weight: 700; }
.nav .badge { background: #fff; color: var(--cam); border-radius: 10px; font-size: 11px; font-weight: 800; padding: 1px 7px; margin-left: auto; }
.user-box { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.user-box .name { font-weight: 700; }
.user-box .role { color: rgba(255,255,255,.6); font-size: 11px; }
.user-box button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; padding: 5px 10px; font-size: 12px; margin-top: 8px; }
.main { margin-left: 220px; flex: 1; padding: 24px 28px; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { color: var(--navy); font-size: 20px; margin-right: auto; }
.btn-outline { background: #fff; border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 14px; font-weight: 600; color: var(--navy); }
.btn-outline:hover { border-color: var(--cam); color: var(--cam); }
.btn-ghost { background: none; border: none; color: var(--muted); font-weight: 600; }

/* ---------- FILTERS ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filters select { padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; }
.seg { display: inline-flex; background: #fff; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: none; padding: 8px 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--navy); color: #fff; }

/* ---------- CALENDAR ---------- */
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav b { min-width: 130px; text-align: center; color: var(--navy); font-size: 15px; }
.cal-nav button { background: #fff; border: 1.5px solid var(--line); border-radius: 8px; width: 34px; height: 34px; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: uppercase; }
.cal-cell { background: #fff; border: 1px solid var(--line); border-radius: 10px; min-height: 108px; padding: 6px; position: relative; }
.cal-cell.other { opacity: .45; }
.cal-cell.today { border: 2px solid var(--cam); }
.cal-cell .dnum { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.cal-cell .add { visibility: hidden; border: none; background: var(--kem); color: var(--cam); border-radius: 6px; width: 20px; height: 20px; font-weight: 800; line-height: 1; }
.cal-cell:hover .add { visibility: visible; }
.chip { display: block; width: 100%; text-align: left; border: none; border-radius: 6px; padding: 4px 6px; margin-top: 4px; font-size: 11px; line-height: 1.35; color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chip small { opacity: .85; font-weight: 600; }

/* list view */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.table th { background: var(--navy); color: #fff; text-align: left; padding: 10px 12px; font-size: 12px; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:hover td { background: #fffaf3; }
.status-pill { display: inline-block; padding: 3px 10px; border-radius: 12px; color: #fff; font-size: 11px; font-weight: 700; white-space: nowrap; }
.cust-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.link-open { background: none; border: none; color: var(--cam); font-weight: 700; padding: 0; }

/* ---------- EDITOR MODAL ---------- */
.overlay { position: fixed; inset: 0; background: rgba(30,31,78,.55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 24px; overflow: auto; }
.editor { background: var(--kem); border-radius: 16px; width: 100%; max-width: 1100px; box-shadow: 0 24px 80px rgba(0,0,0,.4); }
.editor-head { display: flex; align-items: center; padding: 16px 22px; background: var(--navy); border-radius: 16px 16px 0 0; color: #fff; }
.editor-head h3 { font-size: 16px; margin-right: auto; }
.editor-head .x { background: none; border: none; color: #fff; font-size: 22px; }
.stepper { display: flex; gap: 4px; padding: 14px 22px 0; flex-wrap: wrap; }
.step { font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 12px; background: #eee9dd; color: var(--muted); }
.step.done { background: #d9f2e3; color: var(--green); }
.step.now { background: var(--cam); color: #fff; }
.editor-body { display: grid; grid-template-columns: 1fr 380px; gap: 20px; padding: 18px 22px 22px; }
@media (max-width: 900px) { .editor-body { grid-template-columns: 1fr; } }
.fgroup { margin-bottom: 12px; }
.fgroup label { display: block; font-size: 12px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.fgroup input, .fgroup select, .fgroup textarea { width: 100%; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; }
.fgroup textarea { resize: vertical; }
.fgroup input:focus, .fgroup textarea:focus, .fgroup select:focus { outline: none; border-color: var(--cam); }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.channels { display: flex; flex-wrap: wrap; gap: 8px; }
.ch { display: flex; align-items: center; gap: 5px; background: #fff; border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.ch input { accent-color: var(--cam); }
.ch.semi { border-style: dashed; }
.ai-row { display: flex; gap: 8px; margin: 4px 0 12px; }
.btn-ai { background: linear-gradient(135deg, #6a5acd, #4b3fa8); color: #fff; border: none; border-radius: 8px; padding: 8px 12px; font-weight: 700; font-size: 12px; }
.btn-ai:disabled { opacity: .6; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.btn-success { background: var(--green); color: #fff; border: none; border-radius: 8px; padding: 10px 16px; font-weight: 700; }
.btn-warn { background: var(--red); color: #fff; border: none; border-radius: 8px; padding: 10px 16px; font-weight: 700; }
.review-note { background: #fdeaea; border: 1px solid #f3c1c1; color: var(--red); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }

/* preview */
.preview-box { position: sticky; top: 10px; }
.ptabs { display: flex; gap: 6px; margin-bottom: 10px; }
.ptabs button { flex: 1; border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 0; font-weight: 700; font-size: 12px; color: var(--muted); }
.ptabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.pcard-head { display: flex; gap: 10px; padding: 12px; align-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.pcard-head .pname { font-weight: 700; font-size: 13px; }
.pcard-head .ptime { font-size: 11px; color: var(--muted); }
.pcard-text { padding: 0 12px 12px; font-size: 13px; white-space: pre-wrap; line-height: 1.5; }
.pimg { background: #e8e6f0; min-height: 160px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.pimg img { width: 100%; display: block; }
.pweb-title { font-size: 17px; font-weight: 800; color: #1a0dab; padding: 12px 12px 4px; }
.kw-chips { padding: 0 12px 8px; }
.kw-chip { display: inline-block; background: var(--kem); border: 1px solid var(--line); border-radius: 10px; font-size: 11px; padding: 2px 8px; margin: 2px 3px 0 0; color: var(--navy); font-weight: 600; }
.insight-mini { display: flex; gap: 14px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.insight-mini b { color: var(--navy); }
.pub-links { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12px; }
.pub-links a { color: var(--cam); font-weight: 700; }

/* ---------- DUYỆT ---------- */
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.rcard { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 12px; padding: 14px; }
.rcard h4 { color: var(--navy); font-size: 14px; margin-bottom: 4px; }
.rcard .meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.rcard .excerpt { font-size: 12px; background: var(--kem); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; max-height: 100px; overflow: hidden; white-space: pre-wrap; }
.rcard .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.rcard .acts button { font-size: 12px; padding: 7px 10px; }

/* ---------- REPORT ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .v { font-size: 24px; font-weight: 800; color: var(--navy); }
.kpi .v.orange { color: var(--cam); }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 1000px) { .charts { grid-template-columns: 1fr; } }
.chart-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.chart-card h4 { color: var(--navy); font-size: 14px; margin-bottom: 12px; }
.chart-card.wide { grid-column: 1 / -1; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }
.hbar-row { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.hbar-track { background: var(--kem); border-radius: 6px; height: 18px; display: flex; overflow: hidden; }
.hbar-track i { height: 100%; }
.section-title { color: var(--navy); font-size: 15px; font-weight: 800; margin: 22px 0 10px; }

/* ---------- LOGS ---------- */
.log-row { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; display: flex; gap: 12px; font-size: 13px; align-items: baseline; }
.log-row .t { color: var(--muted); font-size: 11px; white-space: nowrap; }
.log-row .a { font-weight: 700; color: var(--navy); white-space: nowrap; }
.tag { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 10px; background: var(--kem); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.dang { background: #d9f2e3; color: var(--green); border-color: #bfe8d0; }
.tag.tele { background: #e8f1fd; color: #2d6cdf; border-color: #cfe0f8; }

/* ---------- RICH TEXT EDITOR ---------- */
.rt-field { background: #fff; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.rt-field:focus-within { border-color: var(--cam); }
.rt-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 5px 6px; background: var(--kem); border-bottom: 1px solid var(--line); }
.rt-btn { border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 700; color: var(--navy); min-width: 28px; }
.rt-btn:hover { background: #fff; border-color: var(--line); }
.rt-btn.rt-fs { margin-left: auto; }
.rt-btn.rt-form { background: var(--navy); color: #fff; }
.rt-editor { min-height: 120px; max-height: 340px; overflow: auto; padding: 10px 12px; font-size: 14px; line-height: 1.55; outline: none; }
.rt-editor[contenteditable="false"] { background: #faf8f2; color: #555; }
.rt-editor h2 { font-size: 16px; color: var(--navy); margin: 10px 0 4px; }
.rt-editor h3 { font-size: 14px; color: var(--navy); margin: 8px 0 3px; }
.rt-editor p { margin: 4px 0; }
.rt-editor ul, .rt-editor ol { margin: 4px 0 4px 22px; }
.rt-editor mark[data-cid] { background: #ffe9a8; border-bottom: 2px solid var(--amber); border-radius: 2px; padding: 0 1px; }
.rt-field.fs { position: fixed; inset: 0; z-index: 300; border-radius: 0; display: flex; flex-direction: column; }
.rt-field.fs .rt-editor { flex: 1; max-height: none; font-size: 16px; padding: 24px clamp(16px, 15vw, 220px); }
.rt-field.fs .rt-toolbar { padding: 10px 16px; }

.pv-rich h2 { font-size: 15px; color: var(--navy); margin: 8px 0 3px; }
.pv-rich h3 { font-size: 13px; color: var(--navy); margin: 6px 0 2px; }
.pv-rich ul, .pv-rich ol { margin: 4px 0 4px 20px; }
.pv-note { font-size: 11px; color: var(--muted); background: var(--kem); border-top: 1px solid var(--line); padding: 8px 12px; }

/* ---------- NHẬN XÉT ---------- */
.cmt-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-top: 14px; padding: 12px; }
.cmt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.cmt-head b { font-size: 13px; color: var(--navy); margin-right: auto; }
.cmt-add { font-size: 11px; padding: 6px 9px; }
.cmt-add:disabled { opacity: .45; cursor: not-allowed; }
#cmt-toggle { font-size: 11px; padding: 0; }
.cmt { border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.cmt.done { border-left-color: var(--green); opacity: .72; }
.cmt-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cmt-quote { font-size: 12px; font-style: italic; background: #fff8e1; border-radius: 6px; padding: 5px 8px; margin-bottom: 4px; color: #6b5900; }
.cmt.done .cmt-quote { background: var(--kem); color: var(--muted); }
.cmt-text { font-size: 13px; margin-bottom: 6px; }
.cmt-resolve { font-size: 11px; padding: 5px 9px; }
.cmt-resolved { font-size: 11px; color: var(--green); font-weight: 600; }
.cmt-empty { font-size: 12px; color: var(--muted); padding: 8px 2px; }

/* ---------- MẪU DÀN Ý ---------- */
.tpl-hint { background: #fff; border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--muted); margin-bottom: 16px; max-width: 900px; }
.tpl-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 18px; max-width: 900px; }
.tpl-card input, .tpl-card select, .tpl-card textarea { width: 100%; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 8px; }
.tpl-card .rt-editor { max-height: 260px; }
.tpl-card .tpl-save { margin-top: 4px; }

/* ---------- KHÁCH HÀNG & KẾT NỐI ---------- */
.cust-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 18px; }
.cust-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cust-title .cc-name { font-size: 16px; font-weight: 800; color: var(--navy); border: 1.5px solid transparent; border-radius: 8px; padding: 6px 8px; flex: 0 1 320px; }
.cust-title .cc-name:hover, .cust-title .cc-name:focus { border-color: var(--line); outline: none; }
.live-switch { margin-left: auto; font-weight: 800; }
.live-switch.on { background: #d9f2e3; border-color: var(--green); color: var(--green); }
.cust-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .cust-grid { grid-template-columns: 1fr; } }
.cust-sec h5 { font-size: 13px; color: var(--navy); margin-bottom: 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.cust-sec input, .cust-sec textarea { width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px; }
.tok-ok { color: var(--green); font-weight: 700; font-size: 11px; }
.tok-no { color: var(--muted); font-weight: 600; font-size: 11px; }
.cust-actions { display: flex; gap: 8px; margin-top: 6px; }
.cc-result { margin-top: 10px; }
.chk { font-size: 12px; padding: 6px 9px; border-radius: 8px; margin-bottom: 5px; background: var(--kem); }
.chk.ok { background: #d9f2e3; }
.chk.no { background: #fdeaea; }

.toast { position: fixed; bottom: 22px; right: 22px; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.3); z-index: 99; }
.toast.err { background: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
