* { box-sizing: border-box; margin: 0; }
:root {
  --bg: #f4f5f7; --panel: #ffffff; --line: #e3e6ea;
  --ink: #1c2733; --muted: #7a8794;
  --brand: #4f46e5; --brand-dark: #3c34c4;
  --in-bubble: #eef0f4; --out-bubble: #4f46e5;
}
body { font-family: "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--bg); height: 100vh; overflow: hidden; }
.muted { color: var(--muted); }
.placeholder { font-size: 13px; border: 1px dashed var(--line); border-radius: 8px; padding: 12px; }

/* ---- Đăng nhập ---- */
.login-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#4f46e5,#7c3aed); z-index: 10; }
.login-card { background: #fff; border-radius: 14px; padding: 36px 32px; width: 340px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { font-size: 26px; color: var(--brand); }
.login-card p { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.login-card button { width: 100%; padding: 11px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font-size: 15px; cursor: pointer; }
.login-card button:hover { background: var(--brand-dark); }
.login-err { color: #d33; font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---- Khung 3 cột ---- */
/* Thanh trên cùng (thương hiệu + 3 nút vai trò + người đăng nhập) */
.topbar { height: 46px; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .tb-brand { font-weight: 800; display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); letter-spacing: -.01em; }
.topbar .tb-logo { width: 24px; height: 24px; border-radius: 7px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.topbar .tb-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar #me-name { color: #0d7a84; font-weight: 600; font-size: 13px; }
.workspace { display: grid; grid-template-columns: 290px 1fr 480px; height: calc(100vh - 46px); } /* chừa 46px cho topbar */
/* Cột grid phải có min-height:0 + chặn max-height, nếu không nội dung dài đẩy cột
   vượt màn hình → phần dưới bị cắt và mất thanh cuộn */
.workspace > * { min-height: 0; max-height: calc(100vh - 46px); }
/* Điều khiển Mya trong đầu khung chat */
.chat-header { display: flex; align-items: center; gap: 8px; }
.chat-header .ch-who { flex: 1; min-width: 0; }
.mya-ctl { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.mya-btn { border: 1px solid var(--line); background: var(--panel); color: #0d7a84; border-radius: 8px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.mya-btn.stop { color: #b8433b; }
.mya-btn.lit { background: #dcfce7; color: #15803d; border-color: #15803d; }
.mya-btn-av { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; vertical-align: -3px; }
.mya-msg-av { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: -5px; margin-right: 5px; }
.mya-btn:hover { background: #eef5f5; }
.mya-chip { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.mya-chip.on { color: #15803d; background: #dcfce7; }
.mya-chip.stopped { color: #b8433b; background: #fee2e2; }
.mya-chip.off { color: #7a8794; background: #eef0f2; }
#ai-eval h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.ev-stars .ev-star { font-size: 19px; cursor: pointer; }

/* Cột 1 */
.col-list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.brand > div:first-of-type { flex: 1; min-width: 0; }
.logout-btn { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 7px; padding: 5px 10px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.logout-btn:hover { color: #d33; border-color: #d33; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.conv-list { overflow-y: auto; flex: 1; }
.conv-item { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv-item:hover { background: #f7f8fa; }
.conv-item.active { background: #eef0ff; border-left: 3px solid var(--brand); padding-left: 13px; }
.conv-item .name { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; }
.conv-item .name time { font-weight: 400; font-size: 11px; color: var(--muted); }
.conv-item .last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.badge { background: var(--brand); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }

/* Cột 2 */
.col-chat { display: flex; flex-direction: column; min-width: 0; }
.chat-header { padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line); font-weight: 600; }
.chat-header small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 62%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.msg.in  { background: var(--in-bubble); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--out-bubble); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg time { display: block; font-size: 10px; opacity: .65; margin-top: 4px; }
.composer { display: flex; gap: 10px; padding: 12px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 14px; }
.composer button { padding: 0 26px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-size: 14px; cursor: pointer; }
.composer button:disabled { opacity: .5; }

/* Cột 3 */
.col-panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; }
.panel-sec { margin-bottom: 22px; }
.panel-sec h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.kv { font-size: 13px; margin-bottom: 6px; }
.kv b { display: inline-block; min-width: 84px; color: var(--muted); font-weight: 500; }
.tag { display: inline-block; background: #eef0ff; color: var(--brand); border-radius: 6px; padding: 2px 8px; font-size: 12px; margin: 2px 4px 2px 0; }

/* Form thông tin khách (GĐ2) */
.cf-input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; margin-bottom: 8px; background: #fff; }
.cf-save { width: 100%; padding: 9px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font-size: 13px; cursor: pointer; }
.cf-save:disabled { opacity: .5; }
.cf-status { font-size: 12px; margin-top: 8px; min-height: 16px; }
.cf-status.ok { color: #15803d; }
.cf-status.err { color: #b91c1c; }

/* Trợ lý AI + Điện thoại (GĐ3/GĐ4) */
.ai-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.ai-btn { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; cursor: pointer; }
.ai-btn:hover { border-color: var(--brand); color: var(--brand); }
.ai-btn:disabled { opacity: .5; cursor: default; }
.ai-box { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.ai-suggestion { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; cursor: pointer; background: #fff; color: var(--ink); }
.ai-suggestion:hover { border-color: var(--brand); background: #f6f6ff; }
.ai-suggestion small { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; }
