/* ===== Note bubble vướng mắc — sticky notes ===== */
.kcv-note-bubble {
	position: fixed;
	bottom: 24px;
	right: 18px;
	z-index: 100160;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media screen and (max-width: 782px) {
	.kcv-note-bubble { bottom: 16px; right: 10px; }
}

.kcv-note-bubble-toggle {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: 2px solid rgba(255,255,255,.95);
	background: linear-gradient(135deg, #ffe066, #fab005 55%, #e67700);
	box-shadow: 0 6px 22px rgba(250, 176, 5, .45);
	cursor: pointer;
	padding: 0;
	transition: filter .2s, box-shadow .2s;
}
.kcv-note-bubble-toggle:hover {
	filter: brightness(1.06);
	box-shadow: 0 8px 28px rgba(250, 176, 5, .55);
}
.kcv-note-bubble[data-unread="0"] .kcv-note-bubble-toggle {
	background: linear-gradient(135deg, #e9ecef, #ced4da);
	box-shadow: 0 4px 14px rgba(0,0,0,.15);
}
.kcv-note-bubble-icon { font-size: 22px; line-height: 1; }
.kcv-note-bubble-count {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: #d63638;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 22px;
	text-align: center;
	box-shadow: 0 2px 6px rgba(214,54,56,.4);
}
.kcv-note-bubble[data-unread="0"] .kcv-note-bubble-count { display: none; }

.kcv-note-panel {
	position: absolute;
	bottom: 68px;
	right: 0;
	width: 360px;
	max-width: calc(100vw - 24px);
	max-height: 70vh;
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 12px 40px rgba(0,0,0,.22);
	overflow: hidden;
	border: 1px solid #e2e4e7;
}
.kcv-note-panel[hidden] { display: none !important; }
.kcv-note-panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	background: linear-gradient(135deg, #fff3bf, #ffe066);
	border-bottom: 1px solid #f0c000;
}
.kcv-note-panel-head strong { font-size: 14px; }
.kcv-note-panel-close {
	border: 0; background: transparent; font-size: 22px;
	line-height: 1; cursor: pointer; color: #664d03; padding: 0 4px;
}
.kcv-note-panel-filter { padding: 10px 12px 0; }
.kcv-note-panel-filter input {
	width: 100%; box-sizing: border-box;
	border: 1px solid #c3c4c7; border-radius: 8px;
	padding: 8px 10px; font-size: 13px;
}
.kcv-note-list {
	flex: 1; overflow-y: auto; padding: 12px;
	display: flex; flex-direction: column; gap: 10px;
	min-height: 120px; max-height: 48vh;
}
.kcv-note-panel-foot {
	padding: 8px 12px 12px; text-align: center;
	border-top: 1px solid #f0f0f1;
}

/* Sticky note cards */
.kcv-sticky {
	position: relative;
	background: linear-gradient(180deg, #fff9db 0%, #ffe066 100%);
	border-radius: 4px 4px 8px 8px;
	padding: 12px 14px 14px;
	box-shadow: 2px 3px 0 rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.1);
	transform: rotate(-0.6deg);
	transition: transform .15s, box-shadow .15s;
}
.kcv-sticky:nth-child(even) {
	background: linear-gradient(180deg, #fff3bf 0%, #ffd43b 100%);
	transform: rotate(0.5deg);
}
.kcv-sticky:hover {
	transform: rotate(0) scale(1.02);
	box-shadow: 0 6px 18px rgba(0,0,0,.14);
	z-index: 2;
}
.kcv-sticky.is-read {
	opacity: .72;
	background: linear-gradient(180deg, #f1f3f5 0%, #dee2e6 100%);
}
.kcv-sticky-meta {
	font-size: 11px; color: #664d03; margin-bottom: 6px;
	display: flex; flex-wrap: wrap; gap: 4px 10px;
}
.kcv-sticky-title { font-weight: 700; font-size: 13px; color: #212529; margin-bottom: 4px; }
.kcv-sticky-body { font-size: 13px; color: #343a40; white-space: pre-wrap; line-height: 1.4; }
.kcv-sticky-actions { margin-top: 8px; }
.kcv-sticky-actions .button { font-size: 11px !important; height: auto !important; line-height: 1.4 !important; padding: 2px 8px !important; }
.kcv-sticky-empty { text-align: center; color: #646970; font-size: 13px; padding: 24px 8px; }

/* Modal gửi gỡ rối */
.kcv-issue-modal {
	position: fixed; inset: 0; z-index: 100200;
	display: none; align-items: center; justify-content: center;
}
.kcv-issue-modal[hidden] { display: none !important; }
.kcv-issue-modal.is-open,
.kcv-issue-modal:not([hidden]) {
	display: flex !important;
}
.kcv-issue-modal-backdrop {
	position: absolute; inset: 0; background: rgba(0,0,0,.45);
}
.kcv-issue-modal-box {
	position: relative; z-index: 1;
	background: #fff; border-radius: 12px;
	padding: 20px 22px; width: 420px; max-width: calc(100vw - 32px);
	box-shadow: 0 16px 48px rgba(0,0,0,.28);
}
.kcv-issue-modal-box h3 { margin: 0 0 8px; font-size: 16px; }
.kcv-issue-modal-box label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13px; }
.kcv-issue-modal-box textarea {
	width: 100%; box-sizing: border-box;
	border: 1px solid #c3c4c7; border-radius: 8px;
	padding: 10px; font-size: 13px; resize: vertical;
}
.kcv-issue-modal-actions { margin: 16px 0 0; display: flex; gap: 8px; }
.kcv-issue-recipients { font-size: 12px; color: #50575e; margin-top: 4px; }

/* Tag vướng mắc đỏ + quản lý đã đọc */
.kcv-tag-blocked {
	display: inline-block;
	background: #d63638; color: #fff;
	font-size: 11px; font-weight: 700;
	padding: 2px 8px; border-radius: 10px;
	margin-left: 4px; vertical-align: middle;
}
.kcv-tag-mgr-read {
	display: inline-block;
	background: #00a32a; color: #fff;
	font-size: 10px; font-weight: 600;
	padding: 2px 7px; border-radius: 10px;
	margin-left: 4px; vertical-align: middle;
}
.kcv-btn-issue {
	margin-left: 4px !important;
	background: #d63638 !important;
	border-color: #b32d2e !important;
	color: #fff !important;
}
.kcv-btn-issue:hover {
	background: #b32d2e !important;
	border-color: #8a2424 !important;
	color: #fff !important;
}

/* Cột giải trình thất bại */
.kcv-fail-explain {
	min-width: 180px; max-width: 280px;
}
.kcv-fail-explain textarea {
	width: 100%; box-sizing: border-box;
	font-size: 12px; border-radius: 6px;
	border: 1px solid #c3c4c7; padding: 6px 8px;
	resize: vertical; min-height: 52px;
}
.kcv-fail-explain .kcv-explain-saved {
	font-size: 11px; color: #00a32a; margin-top: 2px;
}
.kcv-fail-explain .button { margin-top: 4px; font-size: 11px !important; height: auto !important; line-height: 1.4 !important; padding: 2px 8px !important; }

/* ===== Polish note panels (standalone CRM) ===== */
.kcv-note-bubble { z-index: 1100; }
.lkh-note-bubble { z-index: 1099; }

.kcv-note-panel {
  border: none;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.04);
  animation: kcv-note-in .22s ease;
}
@keyframes kcv-note-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.kcv-note-panel-head {
  background: linear-gradient(135deg, #fff8e1 0%, #ffe066 55%, #ffd43b 100%);
  padding: 14px 16px;
}
.kcv-note-panel-head strong {
  font-size: 14px;
  font-weight: 700;
  color: #5c4800;
  letter-spacing: -.01em;
}
.kcv-note-panel-close {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #664d03; background: rgba(255,255,255,.45);
  font-size: 18px;
}
.kcv-note-panel-close:hover { background: rgba(255,255,255,.85); }
.kcv-note-panel-filter { padding: 12px 14px 4px; }
.kcv-note-panel-filter input {
  width: 100%; box-sizing: border-box;
  border: 1.5px solid #e9d8a6;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  background: #fffdf5;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.kcv-note-panel-filter input:focus {
  border-color: #fab005;
  box-shadow: 0 0 0 3px rgba(250,176,5,.18);
}
.kcv-note-list { padding: 12px 14px; gap: 12px; }
.kcv-note-empty {
  text-align: center;
  color: #8e8e93;
  font-size: 13px;
  padding: 28px 12px;
}
.kcv-note-panel-foot { padding: 10px 14px 14px; }
.kcv-note-loadmore-btn,
.kcv-note-panel-foot .button {
  width: 100%;
  border: 1.5px solid #e9d8a6 !important;
  background: #fff9db !important;
  color: #5c4800 !important;
  border-radius: 10px !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer;
}
.kcv-note-loadmore-btn:hover,
.kcv-note-panel-foot .button:hover {
  background: #ffe066 !important;
}

.kcv-sticky {
  border-radius: 10px;
  border: 1px solid rgba(250,176,5,.25);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  padding: 12px 14px 14px;
}
.kcv-sticky-meta {
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  font-size: 11px; color: #7a6510; margin-bottom: 6px;
}
.kcv-sticky-title {
  font-size: 13px; font-weight: 700; color: #3d3200; margin-bottom: 4px;
}
.kcv-sticky-body {
  font-size: 13px; color: #4a3f0f; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.kcv-sticky-actions { margin-top: 10px; }
.kcv-sticky-actions .button,
.kcv-mark-read {
  border: 0 !important;
  background: #5c4800 !important;
  color: #fff !important;
  border-radius: 8px !important;
  padding: 5px 10px !important;
  font-size: 12px !important;
  cursor: pointer;
}
.kcv-sticky.is-read {
  opacity: .7;
  filter: grayscale(.15);
}

@media (max-width: 768px) {
  .kcv-note-bubble { right: 12px; }
  #kcv-note-bubble { bottom: 140px !important; }
  #lkh-note-bubble { bottom: 76px !important; }
  .kcv-note-panel { width: min(340px, calc(100vw - 20px)); }
}


/* Phân biệt icon: KPI công việc vs KPI doanh số */
.kcv-note-bubble:not(.lkh-note-bubble) .kcv-note-bubble-toggle {
  background: linear-gradient(135deg, #ffe066, #fab005 55%, #e67700);
  box-shadow: 0 4px 14px rgba(230, 119, 0, 0.35);
}
.lkh-note-bubble .kcv-note-bubble-toggle {
  background: linear-gradient(135deg, #69db7c, #2f9e44 55%, #2b8a3e);
  box-shadow: 0 4px 14px rgba(47, 158, 68, 0.35);
}
.lkh-note-bubble[data-unread="0"] .kcv-note-bubble-toggle {
  background: linear-gradient(135deg, #b2f2bb, #8ce99a 55%, #69db7c);
  box-shadow: 0 4px 12px rgba(47, 158, 68, 0.2);
}
.lkh-note-bubble .kcv-note-panel-head {
  background: linear-gradient(90deg, #d3f9d8, #b2f2bb);
  border-bottom-color: #8ce99a;
}
