:root {
  --bg: #faf3ea;
  --surface: #ffffff;
  --surface-soft: #fdf9f3;
  --sidebar: #fffdf9;
  --border: #ecdfd0;
  --border-soft: #f3eadd;
  --primary: #9a4b22;
  --primary-dark: #7d3b18;
  --primary-soft: #f6e7db;
  --text: #3d2b1f;
  --muted: #97826f;
  --success: #1f8a4c;
  --success-soft: #e4f4e6;
  --danger: #c2402a;
  --danger-soft: #fbe5de;
  --amber: #b45309;
  --amber-soft: #fdeed3;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 232px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-icon {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 19px; color: var(--primary-dark); }
.brand-sub { font-size: 11.5px; color: var(--muted); }

nav { display: flex; flex-direction: column; gap: 4px; }

.tab-btn {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  border-radius: 11px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.tab-btn svg { width: 19px; height: 19px; }
.tab-btn:hover { background: var(--surface-soft); color: var(--text); }
.tab-btn.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
#conn-status { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; padding: 0 6px; }
#conn-status .dot { display: flex; align-items: center; gap: 6px; }

/* ===== Main ===== */
main { flex: 1; padding: 28px 32px 48px; max-width: 1240px; }

.tab { display: none; }
.tab.active { display: block; }

.page-title {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

.columns { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.columns.inbox { grid-template-columns: 320px 1fr; }
.columns.settings { grid-template-columns: 1.5fr 1fr; }
@media (max-width: 980px) { .columns, .columns.inbox, .columns.settings { grid-template-columns: 1fr; } }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 18px;
}
.card h2 { font-size: 15.5px; font-weight: 700; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-head h2 { margin-bottom: 0; }

/* ===== Form ===== */
label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
form label:first-child { margin-top: 0; }

input[type="text"], input[type="datetime-local"], textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--sans);
  background: var(--surface-soft);
  color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; }
::placeholder { color: #b8a48f; }

.checks { display: flex; gap: 10px; }
.chip-check input { display: none; }
.chip-check span {
  display: inline-block;
  padding: 7px 16px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  background: var(--surface);
  transition: all 0.15s;
}
.chip-check input:checked + span {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: end; }
.aigc-wrap { padding-bottom: 2px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.outline:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn.big { flex: 1; padding: 12px 18px; }
.btn.block { width: 100%; }
.btn.mt { margin-top: 14px; }
.btn:disabled { opacity: 0.5; cursor: wait; }

.row { display: flex; gap: 10px; margin-top: 18px; }

/* ===== AI box ===== */
.ai-box {
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  padding: 14px;
  margin-top: 16px;
}
.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.ai-head strong { font-size: 13.5px; }
.ai-box .hint { margin: 2px 0 0; }

.idea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px;
  margin-top: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.idea:hover { border-color: var(--primary); }
.idea .tags { color: var(--primary); margin-top: 6px; font-weight: 500; }
.idea .script { color: var(--muted); margin-top: 6px; white-space: pre-wrap; }

/* ===== Dropzone ===== */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 16px;
  border: 1.6px dashed var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
  cursor: pointer;
  text-align: center;
  font-weight: 400;
  transition: border-color 0.15s;
}
.dropzone:hover { border-color: var(--primary); }
.dropzone svg { width: 30px; height: 30px; color: var(--primary); margin-bottom: 4px; }
.dz-title { font-weight: 600; font-size: 13.5px; }
.dz-sub { font-size: 12px; color: var(--muted); }
.dz-files { font-size: 12.5px; color: var(--primary-dark); font-weight: 600; }

/* ===== Switch ===== */
.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  font-weight: 600;
  font-size: 13px;
  margin: 0;
}
.switch-row small { font-weight: 400; color: var(--muted); }
.switch-row.mt { margin-top: 16px; }
.switch { position: relative; display: inline-block; flex-shrink: 0; }
.switch input { display: none; }
.switch i {
  display: block;
  width: 42px; height: 24px;
  background: #ddcfbe;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
}
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { left: 21px; }

/* ===== Messages / hints ===== */
.msg { margin-top: 10px; font-size: 13px; min-height: 18px; }
.msg.ok { color: var(--success); }
.msg.err { color: var(--danger); }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 10px; line-height: 1.55; }
code { background: var(--surface-soft); border: 1px solid var(--border-soft); border-radius: 5px; padding: 1px 5px; font-size: 12px; }

/* ===== Posts list ===== */
.post-item {
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 13px;
  margin-bottom: 11px;
  font-size: 13px;
  background: var(--surface);
  display: flex;
  gap: 12px;
}
.post-item .thumb {
  width: 56px; height: 56px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-soft);
}
.post-item .body { flex: 1; min-width: 0; }
.post-item .head { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }

.badge {
  padding: 2.5px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.badge.facebook { background: var(--primary-soft); color: var(--primary-dark); }
.badge.tiktok { background: #2d2620; color: #fff; }
.badge.draft { background: #f1ece4; color: #6b5c4c; }
.badge.scheduled { background: var(--amber-soft); color: var(--amber); }
.badge.publishing { background: #e8e3f7; color: #5b4aa8; }
.badge.published { background: var(--success-soft); color: var(--success); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }

.post-item .content { white-space: pre-wrap; word-break: break-word; }
.post-item .meta { color: var(--muted); margin-top: 6px; font-size: 12px; }
.post-item .error { color: var(--danger); margin-top: 6px; }
.post-item .actions { margin-top: 9px; display: flex; gap: 6px; }
.post-item .actions button {
  padding: 4px 11px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--sans);
  color: var(--text);
}
.post-item .actions button:hover { border-color: var(--primary); color: var(--primary-dark); }

/* ===== Inbox ===== */
.convo {
  display: flex;
  gap: 10px;
  padding: 11px 10px;
  cursor: pointer;
  border-radius: 11px;
  align-items: center;
}
.convo:hover, .convo.active { background: var(--primary-soft); }
.convo .avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.convo .info { flex: 1; min-width: 0; }
.convo .name { font-weight: 600; font-size: 13.5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.convo .preview { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.flag {
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.thread-head { gap: 14px; }
#thread-messages {
  max-height: 430px;
  min-height: 220px;
  overflow-y: auto;
  margin: 6px 0 14px;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 15px;
  margin-bottom: 9px;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.bubble.in {
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}
.bubble.out {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.reply-row { display: flex; gap: 8px; }
.reply-row input { flex: 1; border-radius: 999px; padding-left: 16px; }
.btn.send { border-radius: 50%; width: 42px; height: 42px; padding: 0; font-size: 15px; }

/* ===== Settings — connections ===== */
.conn-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  padding: 10px 13px;
  margin-bottom: 9px;
  font-weight: 600;
  font-size: 13.5px;
}
.conn-chip {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}
.conn-chip.ok { background: var(--success-soft); color: var(--success); }
.conn-chip.off { background: var(--danger-soft); color: var(--danger); }

/* ===== Chiến dịch ===== */
.campaign-item {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 14px;
  margin-bottom: 9px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.campaign-item:hover { border-color: var(--primary); }
.ci-name { font-weight: 600; font-size: 14px; }
.ci-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.campaign-head { margin-top: 12px; }
.campaign-head h2 { font-family: var(--serif); font-size: 20px; }
.cp-message { font-size: 14px; color: var(--text); margin: 8px 0; line-height: 1.6; }
.cp-hashtag { display: inline-block; background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; padding: 3px 12px; border-radius: 999px; font-size: 13px; }

.week-card { border-left: 5px solid var(--border); border-radius: 0 12px 12px 0; }
.week-card.st-aware { border-left-color: #639922; }
.week-card.st-consider { border-left-color: #ba7517; }
.week-card.st-proof { border-left-color: #534ab7; }
.week-card.st-convert { border-left-color: #c2402a; }
.week-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stage-badge { font-weight: 700; font-size: 14px; color: var(--primary-dark); }
.week-goal { color: var(--muted); font-size: 13px; margin: 8px 0 12px; line-height: 1.5; }
.week-posts { display: flex; flex-direction: column; gap: 8px; }
.wp { background: var(--surface-soft); border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.wp .badge { margin-right: 6px; }
.wp-type { font-weight: 600; }
.wp-time { color: var(--muted); font-size: 12px; margin-left: 8px; }
.wp-caption { margin-top: 6px; white-space: pre-wrap; line-height: 1.5; }
.wp-cta { margin-top: 5px; color: var(--primary); font-size: 12.5px; }

.week-tasks { margin-top: 14px; background: #fff8ef; border: 1px solid var(--amber-soft); border-radius: 10px; padding: 12px; }
.wt-title { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.wt-item { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; font-weight: 400; margin: 0 0 7px; cursor: pointer; line-height: 1.45; }
.wt-item input { margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.wt-item.done { color: var(--muted); text-decoration: line-through; }

.lead-item { border-bottom: 1px solid var(--border-soft); padding: 9px 2px; font-size: 13px; }
.lead-name { font-weight: 600; }
.lead-text { color: var(--muted); font-size: 12.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Xưởng video ===== */
.vid-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.vid-thumb { position: relative; }
.vid-thumb img { width: 60px; height: 80px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.vid-thumb span {
  position: absolute; top: -6px; left: -6px;
  background: var(--primary); color: #fff;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.scene-row {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  padding: 10px;
  margin-bottom: 9px;
}
.scene-row > img { width: 54px; height: 72px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.scene-fields { flex: 1; min-width: 0; }
.scene-sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.scene-dur { width: 64px; padding: 5px 8px; }
.scene-vo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-preview { width: 100%; max-width: 320px; border-radius: 12px; background: #000; display: block; margin: 0 auto 12px; }

/* ===== Kế hoạch nội dung ===== */
.plan-controls { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.plan-controls > div { flex-shrink: 0; }
.plan-controls label { margin-top: 0; }
.plan-controls input[type="number"] { width: 90px; }
.plan-occasion { flex: 1; min-width: 220px; }
.plan-occasion input { width: 100%; }

.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 16px 16px 44px;
  margin-bottom: 12px;
  position: relative;
}
.plan-check { position: absolute; left: 16px; top: 16px; margin: 0; }
.plan-check input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.plan-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.plan-day { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.plan-type {
  font-size: 11.5px;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 2px 10px;
  color: var(--primary-dark);
  font-weight: 600;
}
.plan-hook { font-weight: 600; font-size: 14.5px; margin-bottom: 6px; }
.plan-caption { font-size: 13.5px; white-space: pre-wrap; line-height: 1.55; }
.plan-tags { color: var(--primary); font-size: 13px; margin-top: 6px; font-weight: 500; }
.plan-video, .plan-note {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 8px;
  padding: 8px 11px;
  background: var(--surface-soft);
  border-radius: 9px;
  white-space: pre-wrap;
  line-height: 1.5;
}
#plan-actions { margin-top: 6px; }
#plan-actions .btn { width: 100%; }

/* ===== Tab kết nối Facebook ===== */
.fb-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.fb-tab {
  flex: 1;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.fb-tab.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }

/* ===== FAQ ===== */
.faq-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  padding: 10px 13px;
  margin-bottom: 9px;
  font-size: 13px;
}
.faq-body { flex: 1; min-width: 0; }
.faq-q { font-weight: 600; }
.faq-a { color: var(--muted); margin-top: 3px; white-space: pre-wrap; }
.faq-item button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
}

.bubble.typing { opacity: 0.65; font-style: italic; }

.quote-card {
  background: linear-gradient(135deg, #a3522a, #7d3b18);
  border-radius: 16px;
  padding: 26px 22px;
  color: #fff;
  margin-bottom: 18px;
}
.quote-card p { font-family: var(--serif); font-style: italic; font-size: 17px; line-height: 1.5; }
.quote-card span { display: block; margin-top: 10px; font-size: 12px; opacity: 0.85; }
