* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; }
body { background: #f4f6fb; color: #1f2430; }

/* ---------- Đăng nhập ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f6ef7, #8a5cf6); padding: 20px;
}
.login-box {
  background: #fff; padding: 40px 36px; border-radius: 14px; width: 380px; max-width: 100%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.login-box h2 { margin-bottom: 6px; text-align: center; }
.login-box p.sub { text-align: center; color: #888; font-size: 13px; margin-bottom: 22px; }
.login-box label { display: block; font-size: 13px; margin: 14px 0 6px; color: #555; }
.login-box input {
  width: 100%; padding: 10px 12px; border: 1px solid #dcdfe6; border-radius: 8px; font-size: 14px;
}
.login-box input:focus { outline: none; border-color: #4f6ef7; }
.login-box button {
  width: 100%; margin-top: 22px; padding: 11px; border: none; border-radius: 8px;
  background: #4f6ef7; color: #fff; font-size: 15px; cursor: pointer;
}
.login-box button:hover { background: #3d59d6; }
.error { color: #e5484d; font-size: 13px; margin-top: 10px; min-height: 16px; }
.hint { font-size: 12px; color: #999; margin-top: 14px; text-align: center; line-height: 1.6; }

/* ---------- Layout chung ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #1f2430; color: #fff; padding: 24px 18px;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.brand h2 { margin-bottom: 6px; }
.role-badge {
  display: inline-block; font-size: 11px; background: #4f6ef7; color: #fff;
  padding: 3px 9px; border-radius: 20px; margin-bottom: 24px;
}
.role-badge.iep { background: #e5484d; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a {
  color: #cfd3e0; text-decoration: none; padding: 10px 12px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.sidebar nav a.active, .sidebar nav a:hover { background: #343b4d; color: #fff; }
.sidebar button.logout {
  padding: 10px; border: none; border-radius: 8px; background: #e5484d; color: #fff; cursor: pointer; margin-top: 10px;
}

.content { flex: 1; padding: 28px 36px; min-width: 0; }
.content header { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.content header h1 { font-size: 22px; margin-bottom: 4px; }
.content header p { color: #777; font-size: 13px; }

/* ---------- Chuông thông báo ---------- */
.notif-wrap { position: relative; }
.notif-bell {
  background: #fff; border: 1px solid #dcdfe6; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; position: relative;
}
.notif-badge {
  position: absolute; top: -4px; right: -4px; background: #e5484d; color: #fff; font-size: 10px;
  min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.notif-dropdown {
  position: absolute; right: 0; top: 48px; width: 340px; max-height: 420px; overflow-y: auto;
  background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); z-index: 200; display: none;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header { padding: 12px 16px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; }
.notif-dropdown-header a { font-size: 12px; font-weight: 400; color: #4f6ef7; cursor: pointer; }
.notif-item { padding: 11px 16px; border-bottom: 1px solid #f5f5f5; cursor: pointer; font-size: 13px; }
.notif-item:hover { background: #fafbff; }
.notif-item.unread { background: #f5f7ff; }
.notif-item .n-msg { color: #333; margin-bottom: 3px; }
.notif-item .n-time { color: #999; font-size: 11px; }
.notif-empty { padding: 24px 16px; text-align: center; color: #999; font-size: 13px; }

/* ---------- Bộ lọc ---------- */
.filter-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }

.page-section { display: none; }
.page-section.active-section { display: block; }

.panel { background: #fff; padding: 22px; border-radius: 12px; box-shadow: 0 6px 16px rgba(0,0,0,0.06); margin-bottom: 20px; }
.panel h3 { margin-bottom: 14px; font-size: 16px; }
.muted { color: #888; font-size: 13px; }

.cards { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.card { background: #fff; flex: 1; min-width: 140px; padding: 18px; border-radius: 12px; box-shadow: 0 6px 16px rgba(0,0,0,0.06); }
.card h3 { font-size: 24px; color: #4f6ef7; }
.card p { color: #777; margin-top: 4px; font-size: 13px; }

/* ---------- Nút ---------- */
.btn { padding: 9px 16px; border: none; border-radius: 8px; background: #4f6ef7; color: #fff; font-size: 13px; cursor: pointer; }
.btn:hover { background: #3d59d6; }
.btn-outline { background: #fff; color: #4f6ef7; border: 1px solid #4f6ef7; }
.btn-danger { background: #e5484d; }
.btn-mini { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ---------- Bảng ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px; border-bottom: 2px solid #eee; color: #777; }
.table td { padding: 10px; border-bottom: 1px solid #f2f2f2; }
.table tr:hover { background: #fafbff; cursor: pointer; }

/* ---------- Tag trạng thái / ưu tiên ---------- */
.tag { padding: 3px 10px; border-radius: 20px; font-size: 12px; display: inline-block; }
.tag-new { background: #e8ecfd; color: #4f6ef7; }
.tag-progress { background: #fff4d6; color: #b8860b; }
.tag-resolved { background: #e3f9e5; color: #1f9d55; }
.tag-closed { background: #eee; color: #888; }
.tag-urgent { background: #fde3e3; color: #e5484d; }
.tag-high { background: #fff0e0; color: #d17a1f; }
.tag-normal { background: #eee; color: #777; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.hidden { display: none; }
.modal-content { background: #fff; width: 640px; max-width: 100%; max-height: 88vh; overflow-y: auto; border-radius: 14px; padding: 28px; }
.modal-content h3 { margin-bottom: 16px; }
.modal-content .close-btn { float: right; cursor: pointer; font-size: 20px; color: #999; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; margin-bottom: 6px; color: #555; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; padding: 9px 11px; border: 1px solid #dcdfe6; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.form-row textarea { min-height: 90px; resize: vertical; }

/* ---------- Ticket detail ---------- */
.ticket-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin-bottom: 18px; font-size: 13px; }
.ticket-meta .label { color: #888; }
.ticket-desc { background: #f7f8fc; padding: 14px; border-radius: 8px; font-size: 14px; margin-bottom: 18px; white-space: pre-wrap; }
.comments { border-top: 1px solid #eee; padding-top: 14px; }
.comment { padding: 10px 0; border-bottom: 1px solid #f5f5f5; }
.comment .meta { font-size: 12px; color: #999; margin-bottom: 4px; }
.comment .meta .role-tag { padding: 1px 8px; border-radius: 10px; font-size: 11px; margin-left: 6px; }
.comment .meta .role-tag.iep { background: #fde3e3; color: #e5484d; }
.comment .meta .role-tag.cust { background: #e8ecfd; color: #4f6ef7; }
.comment-input { display: flex; gap: 8px; margin-top: 14px; }
.comment-input textarea { flex: 1; min-height: 50px; }
.attach-img { max-width: 220px; max-height: 160px; border-radius: 8px; margin-top: 8px; display: block; cursor: pointer; border: 1px solid #eee; }
.attach-preview { font-size: 12px; color: #4f6ef7; margin-top: 6px; }

/* ---------- FAQ ---------- */
.faq-cat { margin-bottom: 24px; }
.faq-cat h3 { margin-bottom: 10px; }
.faq-item { border: 1px solid #eee; border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.faq-q { padding: 12px 16px; cursor: pointer; font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.faq-q:hover { background: #fafbff; }
.faq-a { padding: 0 16px; max-height: 0; overflow: hidden; transition: all .2s; font-size: 13px; color: #555; line-height: 1.6; }
.faq-item.open .faq-a { padding: 0 16px 14px; max-height: 400px; }
.faq-item.open .faq-q .arrow { transform: rotate(180deg); }
.arrow { transition: transform .2s; }

/* ---------- Chat ---------- */
.chat-box { display: flex; flex-direction: column; height: 60vh; background: #fff; border-radius: 12px; box-shadow: 0 6px 16px rgba(0,0,0,0.06); overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 70%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.chat-msg .meta { font-size: 11px; opacity: 0.7; margin-bottom: 3px; }
.chat-msg.mine { align-self: flex-end; background: #4f6ef7; color: #fff; }
.chat-msg.theirs { align-self: flex-start; background: #f0f1f5; color: #333; }
.chat-input { display: flex; gap: 8px; padding: 14px; border-top: 1px solid #eee; }
.chat-input input { flex: 1; padding: 10px 12px; border: 1px solid #dcdfe6; border-radius: 8px; }
.chat-company-select { margin-bottom: 14px; }

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
  .ticket-meta { grid-template-columns: 1fr; }
}
