/* ==========================================================================
   Team planner (tp-*)
   ========================================================================== */
.tp-layout { display: flex; gap: 12px; align-items: flex-start; }
.tp { flex: 1 1 auto; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: auto; max-height: calc(100vh - 210px); user-select: none; -webkit-user-select: none; }
.pl-fullscreen .tp-layout { flex: 1 1 auto; min-height: 0; }
.pl-fullscreen .tp { max-height: none; }
.tp-grid { position: relative; min-width: 100%; }
.tp-head { display: flex; position: sticky; top: 0; z-index: 5; background: var(--bg-subtle); border-bottom: 1px solid var(--border); height: 62px; }
.tp-corner {
  position: sticky; left: 0; z-index: 2; flex: 0 0 var(--tp-name-w); width: var(--tp-name-w); background: var(--bg-subtle); border-right: 1px solid var(--border);
  display: flex; align-items: flex-end; padding: 0 12px 8px; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .35px; color: var(--text-muted);
}
.tp-head-days { position: relative; flex: 0 0 auto; }
.tp-hday { position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 6px; border-left: 1px solid color-mix(in srgb, var(--border) 60%, transparent); font-size: .78rem; color: var(--text-muted); }
.tp-hday:first-child { border-left: 0; }
.tp-hday.is-week-start { border-left-color: var(--border-strong); }
.tp-hday.is-off { background: color-mix(in srgb, var(--text-faint) 9%, transparent); color: var(--text-faint); }
.tp-hday-name { font-size: .68rem; text-transform: uppercase; letter-spacing: .3px; }
.tp-hday-num { font-weight: 700; font-size: .95rem; color: var(--text); min-width: 24px; height: 22px; display: grid; place-items: center; border-radius: 11px; line-height: 1; }
.tp-hday.is-off .tp-hday-num { color: var(--text-muted); }
.tp-hday.is-today .tp-hday-num { background: var(--primary); color: var(--primary-text); }
.tp-hday.is-today .tp-hday-name { color: var(--primary); font-weight: 700; }
.tp-hday-month { position: absolute; top: 4px; left: 6px; line-height: 1.2; font-size: .72rem; font-weight: 600; color: var(--text); white-space: nowrap; }

.tp-row { display: flex; border-bottom: 1px solid var(--border); position: relative; }
.tp-row:hover .tp-name { background: color-mix(in srgb, var(--bg-hover) 70%, var(--surface)); }
.tp-name {
  position: sticky; left: 0; z-index: 3; flex: 0 0 var(--tp-name-w); width: var(--tp-name-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 12px; min-width: 0;
}
.tp-name-inner { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.tp-name-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.tp-name-text a { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-remove { opacity: 0; transition: opacity .1s; }
.tp-row:hover .tp-remove, .tp-remove:focus-visible { opacity: 1; }
.tp-lane { position: relative; flex: 0 0 auto; }
.tp-cell { position: absolute; top: 0; bottom: 0; border-left: 1px solid color-mix(in srgb, var(--border) 55%, transparent); }
.tp-cell:first-child { border-left: 0; }
.tp-cell.is-week-start { border-left-color: var(--border-strong); }
.tp-cell.is-off { background: color-mix(in srgb, var(--text-faint) 9%, transparent); }
.tp-cell.is-holiday { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--text-faint) 14%, transparent) 0 5px, transparent 5px 10px); }
.tp-cell.is-today { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.tp-row.is-drop-target .tp-lane { background: color-mix(in srgb, var(--primary) 6%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 55%, transparent); }
.tp-row.is-drop-target .tp-name { box-shadow: inset 3px 0 0 var(--primary); }
.tp-row.is-drop-invalid .tp-lane { background: color-mix(in srgb, var(--danger) 7%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--danger) 50%, transparent); }
.tp-row.is-drop-invalid .tp-bar.is-dragging { opacity: .6; }
.tp-cell.is-drop { background: color-mix(in srgb, var(--primary) 20%, transparent); box-shadow: inset 0 0 0 2px var(--primary); }

.tp-bar {
  position: absolute; height: 26px; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 10px; border-radius: 5px; overflow: hidden; z-index: 1;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 45%, var(--border)); box-shadow: inset 3px 0 0 var(--c);
  color: var(--text); text-decoration: none; font-size: .84rem; line-height: 1.15;
}
.tp-bar:hover { text-decoration: none; color: var(--text); border-color: var(--c); background: color-mix(in srgb, var(--c) 22%, var(--surface)); }
.tp-bar.is-draggable { cursor: grab; touch-action: none; }
.tp-bar.is-dragging { box-shadow: inset 3px 0 0 var(--c), 0 0 0 2px var(--primary), 0 6px 14px rgba(0, 0, 0, .2); z-index: 4; }
.tp-bar.is-saving { opacity: .55; }
.tp-bar.is-closed { opacity: .55; }
.tp-bar.is-closed .tp-bar-title { text-decoration: line-through; }
.tp-bar.cut-l { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dashed; }
.tp-bar.cut-r { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-style: dashed; }
.tp-bar.tp-parent { border-style: dashed; }
.tp-bar-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.tp-bar-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.tp-bar-title .type-label { font-size: .7rem; }
.tp-bar-sub { font-size: .7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: none; }
.tp-milestone { box-shadow: none; padding-left: 6px; }
.tp-diamond { width: 10px; height: 10px; flex: 0 0 10px; background: var(--c); transform: rotate(45deg); border-radius: 1px; }
.tp-handle { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; z-index: 2; }
.tp-handle-l { left: 0; }
.tp-handle-r { right: 0; }
.tp-bar:hover .tp-handle-r::after { content: ""; position: absolute; right: 2px; top: 7px; bottom: 7px; width: 2px; border-radius: 2px; background: var(--c); }
.tp.is-dragging, .tp.is-dragging * { cursor: grabbing !important; }
.tp.is-dropping .tp-lane { cursor: copy; }

.tp-add-row { border-bottom: 0; min-height: 48px; }
.tp-add-row .tp-name { padding-left: 6px; }
.tp-add { width: 100%; }
.tp-add .btn { color: var(--primary); }
.tp-lane-empty { min-height: 48px; }
.tp-empty { position: sticky; left: 0; width: min(100%, 640px); }

/* Side panel */
.tp-side {
  flex: 0 0 300px; width: 300px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); display: flex; flex-direction: column;
  max-height: calc(100vh - 210px); position: sticky; top: calc(var(--header-h) + 8px);
}
.tp-side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tp-side-head h3 { margin: 0; font-size: 1rem; }
.tp-side-search { padding: 10px 12px 4px; }
.tp-side-hint { padding: 0 12px; margin: 4px 0 6px; }
.tp-side-list { flex: 1 1 auto; overflow-y: auto; padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.tp-side-empty { padding: 16px 4px; text-align: center; }
.tp-card {
  display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised);
  cursor: grab; box-shadow: var(--shadow-sm); touch-action: none;
}
.tp-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.tp-card-top { display: flex; align-items: center; gap: 6px; font-size: .8rem; }
.tp-card-status { margin-left: auto; color: var(--text-muted); font-size: .76rem; }
.tp-card-title { font-size: .9rem; font-weight: 500; line-height: 1.3; }
.tp-card-meta { display: flex; align-items: center; gap: 8px; font-size: .78rem; min-width: 0; }
.tp-chip { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--bg-muted); color: var(--text-muted); font-size: .72rem; white-space: nowrap; }
.tp-ghost { position: fixed; z-index: 600; pointer-events: none; width: 260px; padding: 8px 10px; border-radius: var(--radius); background: var(--surface-raised); border: 1px solid var(--primary); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 3px; opacity: .95; }
.tp-projects-menu { min-width: 280px; }
.tp-project-opt { display: flex !important; padding: 5px 10px; margin: 0; white-space: nowrap; }

@media (min-width: 1200px) { .tp-bar { height: 26px; } }
.tp.is-narrow .tp-name { padding-left: 8px; padding-right: 16px; }
.tp.is-narrow .tp-name-inner { gap: 6px; }
.tp.is-narrow .tp-name .avatar { width: 24px; height: 24px; font-size: .62rem; flex: 0 0 24px; }
.tp.is-narrow .tp-name-text a { font-size: .84rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.tp.is-narrow .tp-name-text .small { font-size: .7rem; }
.tp.is-narrow .tp-remove { position: absolute; right: 2px; top: 2px; }
@media (max-width: 900px) {
  .tp-layout { flex-direction: column; align-items: stretch; }
  .tp-side { width: auto; flex-basis: auto; position: static; max-height: 360px; }
  .tp { max-height: none; }
}
@media print {
  .tp { max-height: none; overflow: visible; border-color: #999; }
  .tp-side { display: none !important; }
  .tp-bar, .tp-cell.is-off, .tp-hday.is-today .tp-hday-num { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
