@font-face {
  font-family: "Be Vietnam Pro";
  src: url("/static/fonts/be-vietnam-pro-v12-latin_vietnamese-regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("/static/fonts/be-vietnam-pro-v12-latin_vietnamese-500.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("/static/fonts/be-vietnam-pro-v12-latin_vietnamese-600.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("/static/fonts/be-vietnam-pro-v12-latin_vietnamese-700.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Be Vietnam Pro", Inter, Roboto, sans-serif;
  background: #F7F9F6;
  color: #25312B;
  font-size: 15px;
  line-height: 1.5;
}
a { color: #26734D; }

/* ---------- Khung chính: menu trái cố định, thanh trên, vùng nội dung ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: #26734D; color: #fff;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px;
}
.sidebar .brand-name { font-size: 24px; font-weight: 700; letter-spacing: 0.5px; padding: 2px 10px 4px; }
.sidebar .brand-sub { font-size: 12px; opacity: 0.85; padding: 0 10px 16px; }
.sidebar a {
  display: block; color: #fff; text-decoration: none; font-weight: 500;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px; font-size: 15px;
}
.sidebar a:hover { background: rgba(255, 255, 255, 0.16); }
.sidebar a.active { background: rgba(255, 255, 255, 0.24); font-weight: 700; }
.nav-group { margin: 0 0 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.18); padding-bottom: 6px; }
.nav-group > summary { cursor: pointer; list-style: none; padding: 10px 10px 6px; display: flex; align-items: baseline; gap: 8px; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after { content: "▸"; margin-left: auto; font-size: 12px; opacity: 0.8; }
.nav-group[open] > summary::after { content: "▾"; }
.nav-group-title { font-size: 15px; font-weight: 800; letter-spacing: 0.4px; }
.nav-group-sub { font-size: 11.5px; opacity: 0.85; }
.nav-sub a { margin-left: 10px; }
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; padding: 10px 20px; display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; box-shadow: 0 1px 4px rgba(37, 49, 43, 0.08); position: sticky; top: 0; z-index: 50;
}
.topbar .search-form { flex: 1; min-width: 200px; display: flex; gap: 8px; }
.topbar .search-form input { margin: 0; }
.topbar .search-form .btn { margin: 0; white-space: nowrap; }
.work-state { font-size: 13px; font-weight: 600; }
.work-state.on { color: #26734D; }
.work-state.off { color: #8a6d00; }
.bell { position: relative; text-decoration: none; font-size: 20px; }
.bell-badge {
  position: absolute; top: -8px; right: -10px; background: #E45252; color: #fff;
  font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; line-height: 20px;
  border-radius: 999px; text-align: center; padding: 0 5px;
}
.quick-create { position: relative; }
.quick-create summary { list-style: none; cursor: pointer; }
.quick-create summary::-webkit-details-marker { display: none; }
.quick-menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(37, 49, 43, 0.22); padding: 8px; min-width: 220px; z-index: 80;
}
.quick-menu a { display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: #25312B; font-weight: 500; }
.quick-menu a:hover { background: #F7F9F6; }
.userinfo { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 20px 18px 48px; }
.guest-wrap { max-width: 520px; margin: 40px auto; padding: 0 16px; }
.guest-brand { text-align: center; margin-bottom: 18px; }
.guest-brand .brand-name { font-size: 30px; font-weight: 700; color: #26734D; }
.guest-brand .brand-sub { color: #5c6f64; font-size: 14px; }

/* ---------- Thành phần chung ---------- */
.card { background: #fff; border-radius: 12px; padding: 20px 22px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(37, 49, 43, 0.06); }
.subcard { border: 1px solid #DDE7DE; border-radius: 12px; padding: 16px; margin-top: 18px; }
h1 { font-size: 26px; font-weight: 700; margin: 6px 0 16px; }
h2 { font-size: 19px; font-weight: 600; margin-top: 4px; }
h3 { font-size: 16px; font-weight: 600; }
label { display: block; margin: 12px 0; font-weight: 600; font-size: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid #B9CDBD; border-radius: 10px; font-size: 15px; font-weight: 400;
  background: #fff; color: #25312B; font-family: inherit;
}
.btn {
  display: inline-block; border: none; cursor: pointer; text-decoration: none;
  padding: 10px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  margin: 4px 6px 4px 0; min-height: 40px; line-height: 1.25; font-family: inherit;
}
.btn-big { padding: 13px 26px; font-size: 16px; }
.btn-small { padding: 6px 12px; font-size: 13px; min-height: 32px; }
.btn-primary { background: #26734D; color: #fff; }
.btn-primary:hover { background: #1E5C3E; }
.btn-secondary { background: #F28C45; color: #fff; }
.btn-secondary:hover { background: #D97735; }
.btn-light { background: #EAF1EA; color: #25312B; }
.btn-light:hover { background: #DDE7DE; }
.btn-info { background: #3887D6; color: #fff; }
.btn-danger { background: #E45252; color: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid #E4EBE4; vertical-align: top; }
table.info th { width: 200px; color: #5c6f64; }
.badge { display: inline-block; background: #EAF1EA; color: #25312B; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; margin: 1px 2px 1px 0; }
.badge-danger { background: #FBE3E3; color: #A92F2F; }
.badge-warn { background: #FDF0CD; color: #7A5B00; }
.badge-ok { background: #DFF2E3; color: #1E5C3E; }
.badge-group { background: #E0EDFA; color: #1F5FA8; }
.badge-info { background: #E0EDFA; color: #1F5FA8; }
.badge-orange { background: #FDE7D7; color: #9A4E0D; }
.badge-hot { background: #FDE7D7; color: #9A4E0D; border: 1px solid #F28C45; }
.badge-urgent { background: #E45252; color: #fff; }
.badge-score-high { background: #5DAE74; color: #fff; }
.badge-score-mid { background: #F5C451; color: #5C4300; }
.badge-score-low { background: #E4EBE4; color: #5c6f64; }
td.hot-cell { border-left: 6px solid #F28C45; background: #FFF7F0; }
.check-list { margin: 8px 0 4px; }
.check-item { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 6px 0; }
.check-item input[type="checkbox"] { width: auto; margin: 0; }
.dual-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 24px; }
.team-goal-row { border-bottom: 1px solid #E4EBE4; padding: 12px 0; }
.team-goal-row:last-child { border-bottom: none; }
.stat-label { font-weight: 600; color: #5c6f64; }
.quick-form { display: inline-block; margin: 2px 4px 2px 0; }
.quick-form .btn { margin: 0; padding: 7px 12px; font-size: 13px; min-height: 32px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { text-align: center; margin-bottom: 0; }
.stat-num { font-size: 32px; font-weight: 700; color: #26734D; }
a.stat { text-decoration: none; color: #25312B; display: block; }
a.stat:hover { box-shadow: 0 4px 14px rgba(37, 49, 43, 0.14); }
.stat-num.warn { color: #9A4E0D; }
.stat-num.danger { color: #E45252; }
.stat-num.info { color: #3887D6; }
.muted { color: #5c6f64; }
.alert { background: #FBE3E3; color: #A92F2F; padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; }
.alert-warn { background: #FDF0CD; color: #7A5B00; padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; }
.hint { background: #EFF5EF; border-radius: 10px; padding: 10px 14px; margin-top: 16px; font-size: 13px; }
.login-card { max-width: 480px; margin: 0 auto; }
.filter-form { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
.filter-form label { flex: 1; min-width: 180px; margin: 0; }
.inline-form { margin-top: 12px; }
.actions form { display: inline-block; margin-right: 8px; vertical-align: top; }
.actions .inline-form { display: block; }
.timer-cell { min-width: 170px; }
.timer-total { font-size: 13px; margin-bottom: 4px; }
.timer-running { color: #9A4E0D; font-weight: 700; font-size: 13px; margin-bottom: 4px; }

/* ---------- Tab, biểu đồ thanh, thẻ KPI ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
  text-decoration: none; padding: 8px 16px; border-radius: 999px; background: #EAF1EA;
  color: #25312B; font-weight: 600; font-size: 14px;
}
.tabs a.active { background: #26734D; color: #fff; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 14px; }
.bar-label { width: 130px; font-weight: 600; }
.bar-track { flex: 1; background: #EAF1EA; border-radius: 999px; height: 18px; overflow: hidden; }
.bar-fill { background: #26734D; height: 100%; border-radius: 999px; }
.bar-fill.blue { background: #3887D6; }
.bar-value { width: 48px; text-align: right; font-weight: 700; }

/* ---------- Hộp thư ba cột ---------- */
.inbox-layout { display: grid; grid-template-columns: 300px 1fr 300px; gap: 16px; align-items: start; }
.inbox-list { max-height: 78vh; overflow-y: auto; }
.conv-item { display: block; text-decoration: none; color: #25312B; padding: 10px 12px; border-radius: 10px; margin-bottom: 6px; border: 1px solid #E4EBE4; background: #fff; }
.conv-item:hover { background: #F7F9F6; }
.conv-item.active { border-color: #26734D; background: #EFF5EF; }
.conv-item .conv-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.conv-unread { background: #E45252; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.inbox-thread { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.msg { max-width: 82%; padding: 9px 13px; border-radius: 12px; font-size: 14px; word-break: break-word; }
.msg-in { align-self: flex-start; background: #EAF1EA; }
.msg-out { align-self: flex-end; background: #E0EDFA; }
.msg-note { align-self: center; background: #FDF0CD; max-width: 92%; }
.msg-product { align-self: flex-end; background: #DFF2E3; border: 1px solid #5DAE74; }
.msg-meta { font-size: 11px; color: #5c6f64; margin-top: 3px; }

/* ---------- Kanban cơ hội ---------- */
.kanban { display: grid; grid-template-columns: repeat(8, minmax(215px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.kanban-col { background: #EFF5EF; border-radius: 12px; padding: 10px; min-height: 120px; }
.kanban-col h3 { margin: 2px 0 10px; font-size: 15px; }
.deal-card { background: #fff; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(37, 49, 43, 0.1); font-size: 13px; }
.deal-card .deal-title { font-weight: 700; font-size: 14px; }
.deal-card .deal-nav { display: flex; gap: 6px; margin-top: 8px; }
.deal-card .deal-nav form { margin: 0; }

/* ---------- Thanh điều hướng dưới cho điện thoại ---------- */
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .inbox-layout { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(8, minmax(200px, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 200; transform: translateX(-105%);
    transition: transform 0.2s ease; box-shadow: 0 0 30px rgba(0, 0, 0, 0.3); height: auto;
  }
  body.menu-open .sidebar { transform: translateX(0); }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    background: #fff; border-top: 1px solid #DDE7DE; box-shadow: 0 -2px 10px rgba(37, 49, 43, 0.08);
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; text-align: center; padding: 10px 4px 12px; font-size: 13px; font-weight: 600;
    color: #25312B; text-decoration: none; background: none; border: none; cursor: pointer; font-family: inherit;
  }
  .bottom-nav a.active { color: #26734D; }
  .container { padding-bottom: 92px; }
  #chat-root { bottom: 76px; }
  #chat-panel { bottom: 140px; }
}

/* ---------- Khung chat nội bộ nhân viên (đợt 3, giữ nguyên cấu trúc) ---------- */
#chat-root { position: fixed; right: 20px; bottom: 20px; z-index: 1000; font-family: inherit; }
#chat-toggle { position: relative; border: none; cursor: pointer; background: #26734D; color: #fff; font-size: 16px; font-weight: 700; padding: 14px 22px; border-radius: 999px; box-shadow: 0 4px 14px rgba(37, 49, 43, 0.35); }
#chat-toggle:hover { background: #1E5C3E; }
.chat-badge { position: absolute; top: -6px; right: -6px; background: #E45252; color: #fff; font-size: 12px; font-weight: 700; min-width: 22px; height: 22px; line-height: 22px; border-radius: 999px; text-align: center; padding: 0 5px; }
#chat-panel { position: fixed; right: 20px; bottom: 84px; width: 680px; max-width: 94vw; height: 520px; max-height: 78vh; background: #fff; border-radius: 14px; box-shadow: 0 10px 34px rgba(37, 49, 43, 0.3); display: flex; flex-direction: column; overflow: hidden; }
#chat-panel[hidden] { display: none; }
.chat-head { background: #26734D; color: #fff; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
#chat-close { background: transparent; border: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
.chat-body { display: flex; flex: 1; min-height: 0; }
.chat-contacts { width: 210px; border-right: 1px solid #E4EBE4; overflow-y: auto; padding: 8px; }
.chat-contact { display: block; width: 100%; text-align: left; background: transparent; border: none; cursor: pointer; padding: 10px 10px; border-radius: 10px; font-size: 14px; font-weight: 600; color: #25312B; font-family: inherit; }
.chat-contact:hover { background: #EFF5EF; }
.chat-contact.active { background: #DFF2E3; }
.chat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; background: #E45252; vertical-align: middle; }
.chat-unread-count { background: #E45252; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-title { padding: 10px 14px; font-weight: 700; border-bottom: 1px solid #E4EBE4; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; background: #F7F9F6; }
.chat-msg { max-width: 78%; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-msg.theirs { align-self: flex-start; }
.chat-bubble { display: inline-block; padding: 9px 13px; border-radius: 14px; font-size: 14px; text-align: left; word-break: break-word; }
.chat-msg.mine .chat-bubble { background: #26734D; color: #fff; }
.chat-msg.theirs .chat-bubble { background: #EAF1EA; color: #25312B; }
.chat-time { font-size: 11px; color: #5c6f64; margin-top: 2px; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #E4EBE4; align-items: center; }
.chat-form input { flex: 1; margin: 0; }
.chat-form .btn { margin: 0; }
.chat-tabs { display: flex; gap: 6px; padding: 8px 12px 0; background: #fff; }
.chat-tab { flex: 1; border: 1px solid #CFDCD2; background: #EFF5EF; color: #25312B; font-family: inherit; font-size: 14px; font-weight: 700; padding: 8px 10px; border-radius: 10px 10px 0 0; cursor: pointer; }
.chat-tab.active { background: #26734D; color: #fff; border-color: #26734D; }
#chat-group-pane, #chat-private-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#chat-group-pane[hidden], #chat-private-pane[hidden] { display: none; }
.chat-group-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-sender { font-size: 12px; font-weight: 700; color: #26734D; margin-bottom: 2px; }
.bot-test-result { margin-top: 14px; background: #EFF7F0; border: 1px solid #CFE3D2; border-radius: 10px; padding: 12px 14px; }
.preview-box { background: #F7F9F6; border: 1px solid #E4EBE4; border-radius: 10px; padding: 14px; white-space: pre-wrap; }
.chat-img { max-width: 180px; max-height: 180px; border-radius: 8px; display: block; }
.chat-attach-box { margin-top: 4px; }
.chat-attach-name { padding: 6px 12px; font-size: 12px; color: #1E5C3E; background: #EFF5EF; border-top: 1px solid #E4EBE4; }
.msg-img { max-width: 320px; max-height: 320px; border-radius: 8px; display: block; }
.msg-attach { margin-top: 6px; }
.signature-img { max-width: 320px; max-height: 160px; border: 1px solid #E4EBE4; border-radius: 8px; background: #fff; }
.inline-edit { display: inline-block; vertical-align: top; }
.inline-edit > summary { cursor: pointer; list-style: none; }
.inline-edit .form-grid { min-width: 280px; margin-top: 8px; }

/* ---------- Đợt 7: Chat AI giao việc, chi nhánh, tối ưu điện thoại ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 560px; }
.ai-messages {
  display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow-y: auto;
  padding: 14px; background: #F7F9F6; border: 1px solid #E4EBE4; border-radius: 12px;
}
.ai-plan {
  background: #fff; border: 1px solid #CFE3D2; border-radius: 10px;
  padding: 12px 14px; margin-top: 10px; text-align: left; color: #25312B;
}
.ai-plan p { margin: 4px 0; }
.ai-input-row { display: flex; gap: 8px; align-items: stretch; margin-top: 6px; }
.ai-input-row input { flex: 1; margin: 0; min-height: 48px; }
.ai-input-row .btn { margin: 0; min-height: 48px; white-space: nowrap; }
.menu-toggle { display: none; }

/* Điện thoại: menu hamburger, vùng chạm tối thiểu 44px, bảng cuộn ngang trong thẻ */
@media (max-width: 860px) {
  .menu-toggle { display: inline-block; min-height: 44px; margin: 0; }
  .btn { min-height: 44px; }
  .btn-small { min-height: 38px; padding: 9px 12px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  .tabs a { padding: 11px 16px; }
  .card { overflow-x: auto; padding: 16px 14px; }
  table { min-width: 620px; }
  table.info { min-width: 0; }
  th, td { padding: 10px 8px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .topbar .search-form { min-width: 0; flex: 1 1 100%; order: 5; }
  .userinfo { font-size: 13px; }
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }
  .ai-messages { max-height: 55vh; padding: 10px; }
  .ai-input-row { flex-wrap: wrap; }
  .ai-input-row input { flex: 1 1 100%; }
  .ai-input-row .btn { flex: 1; }
  .chat-contacts { width: 148px; }
  .chat-msg { max-width: 92%; }
  .bottom-nav a, .bottom-nav button { min-height: 48px; }
  .stat-num { font-size: 26px; }
}
@media (max-width: 860px) {
  main.container { overflow-x: clip; }
  .subcard { overflow-x: auto; }
}
