/* Màn "Công việc & lịch": mọi class có tiền tố tk- để không đụng màn khác. */

.tk-head-tools,
.tk-nav,
.tk-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.tk-nav[hidden] {
  display: none;
}
.tk-chips {
  margin-left: auto;
}
.tk-range {
  min-width: 112px;
  text-align: center;
  font-weight: 600;
}

/* Việc kế tiếp (đếm ngược) */
.tk-next {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(420px, 100%);
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
  transition:
    transform var(--duration-fast) var(--ease-out),
    border-color var(--duration-base);
}
.tk-next:active:not([disabled]) {
  transform: scale(0.98);
}
.tk-next[disabled] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}
.tk-next-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (hover: hover) {
  .tk-next:hover:not([disabled]) {
    border-color: var(--accent);
  }
}

/* Lịch tuần */
.tk-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}
.tk-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 220px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    border-color var(--duration-base),
    background var(--duration-base),
    box-shadow var(--duration-base);
}
.tk-col.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.tk-col.is-drop {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tk-col-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.tk-dow {
  font-weight: 700;
}
.tk-dom {
  color: var(--muted);
}
.tk-add {
  margin-left: auto;
}
.tk-col-list {
  display: grid;
  gap: 8px;
}
.tk-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 56px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-size: 13px;
  transition:
    border-color var(--duration-base),
    color var(--duration-base),
    transform var(--duration-fast);
}
.tk-slot:active {
  transform: scale(0.97);
}
@media (hover: hover) {
  .tk-slot:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}
.tk-hint {
  margin-top: 12px;
  font-size: 13px;
}

/* Thẻ việc */
.tk-card {
  --tk-tone: var(--accent);
  position: relative;
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 32px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-color: color-mix(in srgb, var(--tk-tone) 45%, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--tk-tone) 10%, var(--surface));
  text-align: left;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
  transition:
    transform var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base);
}
.tk-t-call {
  --tk-tone: var(--accent);
}
.tk-t-meeting {
  --tk-tone: var(--warn);
}
.tk-t-email {
  --tk-tone: var(--ok);
}
.tk-card.is-overdue {
  --tk-tone: var(--danger);
  border-color: var(--danger);
}
.tk-card.is-done {
  opacity: 0.6;
}
.tk-card.is-done .tk-card-title {
  text-decoration: line-through;
}
.tk-card:active {
  transform: scale(0.98);
}
.tk-card.is-dragging {
  z-index: 50;
  box-shadow: var(--shadow-lg);
  cursor: grabbing;
  transition: none;
  will-change: transform;
}
@media (hover: hover) {
  .tk-card:hover:not(.is-dragging) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}
.tk-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--tk-tone);
  font-size: 12px;
  font-weight: 600;
}
.tk-card-top .i {
  width: 14px;
  height: 14px;
}
.tk-grip {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -6px -8px -6px auto;
  color: var(--muted);
  touch-action: none;
}
.tk-card-title {
  color: var(--text);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.tk-card-contact {
  color: var(--muted);
  font-size: 12px;
}
.tk-dragging,
.tk-dragging * {
  cursor: grabbing;
}
.tk-new {
  animation: tk-pop var(--duration-slide) var(--ease-out) backwards;
  animation-delay: calc(var(--tk-i, 0) * var(--stagger-step));
}
/* Huy hiệu việc của kịch bản bám khách (thẻ lịch tuần và dòng danh sách) */
.tk-seq {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 4px;
  max-width: 100%;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tk-seq .i {
  width: 12px;
  height: 12px;
  flex: none;
}
@keyframes tk-pop {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-6px);
  }
}

/* Danh sách */
.tk-group {
  margin-bottom: 20px;
}
.tk-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tk-g-overdue .tk-group-title {
  color: var(--danger);
}
.tk-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
}
.tk-group-toggle .i {
  transition: transform var(--duration-base) var(--ease-out);
  transform: rotate(-90deg);
}
.tk-group-toggle[aria-expanded='true'] .i {
  transform: none;
}
.tk-group .empty {
  padding: 18px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.tk-group .empty .i {
  width: 24px;
  height: 24px;
}
.tk-rows {
  display: grid;
  gap: 6px;
}
.tk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--line);
  border-color: color-mix(in srgb, var(--tk-tone, var(--accent)) 45%, var(--line));
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition:
    transform var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base),
    opacity var(--duration-base);
}
.tk-row.is-overdue {
  --tk-tone: var(--danger);
}
.tk-row.is-done {
  opacity: 0.65;
}
@media (hover: hover) {
  .tk-row:hover {
    transform: translateX(2px);
    box-shadow: var(--shadow-sm);
  }
}
.tk-row .check {
  padding: 6px;
}
.tk-row-main {
  flex: 1;
  min-width: 0;
}
.tk-row-title {
  display: block;
  max-width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font-weight: 500;
}
.tk-title-text {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--duration-slide) var(--ease-out);
}
.tk-title-text::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentcolor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-slide) var(--ease-out);
}
.tk-row.is-done .tk-title-text {
  color: var(--muted);
}
.tk-row.is-done .tk-title-text::after {
  transform: scaleX(1);
}
.tk-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 12px;
}
.tk-type,
.tk-repeat-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tk-type {
  color: var(--tk-tone, var(--accent));
  font-weight: 600;
}
.tk-type .i,
.tk-repeat-tag .i {
  width: 14px;
  height: 14px;
}
.tk-link {
  min-height: 24px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tk-remove {
  margin-right: auto;
}

@media (max-width: 720px) {
  .tk-head-tools {
    width: 100%;
    min-width: 0;
  }
  .tk-next {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
  }
  .tk-head-tools .btn-primary {
    flex: 1 1 auto;
    justify-content: center;
  }
  .tk-toolbar .seg {
    display: flex;
    width: 100%;
  }
  .tk-toolbar .seg-btn {
    flex: 1;
  }
  .tk-nav {
    flex: 1 1 100%;
  }
  .tk-chips {
    margin-left: 0;
  }
}

@media (max-width: 900px) {
  .tk-week {
    grid-template-columns: 1fr;
  }
  .tk-col {
    min-height: 0;
  }
  .tk-col-head {
    flex-wrap: nowrap;
  }
  .tk-chips {
    margin-left: 0;
  }
  .tk-grip {
    width: 40px;
    height: 40px;
    margin: -10px -10px -10px auto;
  }
}
