/* Tasks shell: view switcher, list, kanban, kanban dialogs, detail page.
   Everything is namespaced .tk-* so it can't collide with other modules. */

.tk-page { display: flex; flex-direction: column; min-height: 100%; }
.tk-vsw { display: inline-flex; align-items: center; gap: 2px; padding: 0 6px; margin: 0 4px; border-left: 1px solid var(--border-panel); border-right: 1px solid var(--border-panel); position: relative; }
.tk-vbtn { width: 26px; height: 26px; border-radius: 6px; border: none; background: transparent; color: #616e88; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; position: relative; }
.tk-vbtn:hover { background: var(--color-surface-alt); }
.tk-vbtn.active, .tk-vbtn.active:hover { color: #5464f2; background: #f0f1ff; }
.tk-vbtn svg { width: 16px; height: 16px; }
.tk-vbtn.tk-refresh { margin-left: 2px; }
.tk-menu-wrap { position: relative; display: inline-block; }
.tk-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 200px; background: #fff; border: 1px solid #c5c4d3; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.15); padding: 4px; }
.tk-menu.right { left: auto; right: 0; }
.tk-menu[hidden] { display: none; }
.tk-menu button, .tk-menu .tk-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; font-size: 14px; border: none; background: none; border-radius: 4px; color: var(--color-text); cursor: pointer; }
.tk-menu button:hover, .tk-menu .tk-menu-item:hover { background: #f0f4fc; }
.tk-menu hr { border: none; border-top: 1px solid var(--border-row); margin: 4px 0; }
.tk-menu .tk-check { width: 14px; color: #5464f2; font-weight: 700; }
.tk-menu button.tk-danger { color: var(--color-danger); }
.tk-disabled { opacity: .4; pointer-events: none; }
.tk-sort-wrap { position: relative; display: inline-block; }
.tk-sort-dot { position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: #5464f2; border: 1px solid #fff; }
.tk-split-btn { display: inline-flex; }
.tk-split-btn .btn:first-child { border-radius: 6px 0 0 6px; }
.tk-split-btn .btn:last-child { border-radius: 0 6px 6px 0; border-left: 1px solid rgba(255,255,255,.35); padding: 0 8px; }
.tk-tabs-row { display: flex; align-items: center; gap: 8px; background: var(--color-surface); border-bottom: 1px solid var(--border-row); padding-right: var(--space-5); }
.tk-tabs-row .view-tabs { border-bottom: none; flex: 1; }

/* Selection bar */
.tk-selbar { display: flex; align-items: center; gap: 10px; padding: 8px var(--space-5); background: #f0f1ff; border-bottom: 1px solid var(--color-border); font-size: 13px; flex-wrap: wrap; }
.tk-selbar .btn-link { color: #5464f2; background: none; border: none; cursor: pointer; }
.tk-canvas-btn { background: linear-gradient(90deg,#8c71fb,#5464f2); color: #fff; border: none; }

/* List */
.tk-table-wrap { flex: 1; overflow: auto; background: var(--color-surface); }
.tk-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tk-table th { text-align: left; font-weight: 500; color: var(--color-text-muted); padding: 9px 10px; border-bottom: 1px solid var(--border-row); white-space: nowrap; background: var(--color-surface); position: sticky; top: 0; z-index: 2; font-size: 13px; }
.tk-table th[data-sort] { cursor: pointer; }
.tk-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-row); height: 55px; vertical-align: middle; color: var(--color-text); }
.tk-table tbody tr:hover { background: #f5f7fc; }
.tk-table tbody tr:hover a { color: #5464f2; }
.tk-table a { color: inherit; text-decoration: none; }
.tk-table a:hover { text-decoration: underline; }
.tk-table .tk-col-qa { width: 92px; padding-right: 0; }
.tk-table .tk-col-cb { width: 32px; }
.tk-table .tk-related { display: inline-flex; align-items: flex-start; gap: 6px; max-width: 220px; }
.tk-table .tk-related span.tk-rel-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tk-mod-ico { width: 16px; height: 16px; flex-shrink: 0; color: #616e88; margin-top: 2px; }
.tk-qa { display: inline-flex; gap: 4px; visibility: hidden; }
.tk-table tbody tr:hover .tk-qa, .tk-table tbody tr:focus-within .tk-qa { visibility: visible; }
.tk-qa button { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-soft); background: #fff; color: #616e88; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.tk-qa button:hover { border-color: #5464f2; color: #5464f2; }
.tk-qa button.tk-complete { background: #12aa67; border-color: #12aa67; color: #fff; }
.tk-qa svg { width: 13px; height: 13px; }
.tk-table input[type=checkbox], .tk-kb-card input[type=checkbox] { accent-color: #5464f2; width: 15px; height: 15px; }
.tk-alpha-btn { margin-left: 6px; font-size: 12px; color: #5464f2; background: #f0f1ff; border: none; border-radius: 4px; padding: 1px 6px; cursor: pointer; }
.tk-alpha-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; min-width: 210px; }
.tk-alpha-grid button { justify-content: center; padding: 5px 0; }
.tk-alpha-grid button.active { background: #f0f1ff; color: #5464f2; font-weight: 600; }
.tk-cols-menu label { display: flex; gap: 8px; align-items: center; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.tk-footer { display: flex; align-items: center; justify-content: space-between; padding: 8px var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface); font-size: 13px; color: var(--color-text-muted); }
.tk-footer .tk-pager { display: inline-flex; align-items: center; gap: 10px; }
.tk-footer .tk-pager button { border: none; background: none; font-size: 18px; color: var(--color-text); cursor: pointer; padding: 0 6px; }
.tk-footer .tk-pager button:disabled { opacity: .35; cursor: default; }
.tk-overdue-dot { color: var(--color-danger); font-size: 12px; margin-left: 4px; }

/* Kanban */
.tk-kb-sub { display: flex; align-items: center; gap: 8px; padding: 8px var(--space-5); background: var(--color-bg); }
.tk-kb-select { min-width: 128px; height: 27px; padding: 5px 25px 5px 10px; background: #fff; border: 1px solid #c5c4d3; border-radius: 5px; font-size: 13px; text-align: left; cursor: pointer; position: relative; color: var(--color-text); }
.tk-kb-select::after { content: "\25BE"; position: absolute; right: 8px; top: 5px; font-size: 11px; color: #616e88; }
.tk-kb-edit { width: 27px; height: 27px; border-radius: 5px; border: 1px solid transparent; background: transparent; cursor: pointer; color: #616e88; display: inline-flex; align-items: center; justify-content: center; }
.tk-kb-edit:hover { background: #fff; border-color: #c5c4d3; }
.tk-kb { display: flex; gap: 20px; overflow-x: auto; padding: 4px var(--space-5) var(--space-4); flex: 1; align-items: flex-start; background: var(--color-bg); min-height: 300px; }
.tk-kb-col { flex: 0 0 305px; width: 305px; display: flex; flex-direction: column; max-height: calc(100vh - 260px); }
.tk-kb-head { height: 65px; padding: 10px 15px; border-radius: 3px 3px 0 0; background: #daf5f7; border: 1px solid #cfe9ea; border-top: 4px solid #99d1d3; border-bottom: none; display: flex; flex-direction: column; justify-content: center; gap: 2px; box-sizing: border-box; }
.tk-kb-head-row { display: flex; align-items: center; gap: 8px; }
.tk-kb-name { font-size: 14px; font-weight: 500; color: var(--color-text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-kb-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 20px; background: #99d1d3; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-strong); box-sizing: border-box; }
.tk-kb-agg { font-size: 12px; color: #616e88; }
.tk-kb-body { flex: 1; overflow-y: auto; padding: 10px 0 0; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.tk-kb-col.tk-empty .tk-kb-body { background: #dfe4ef; align-items: center; justify-content: center; padding: 0; border-radius: 0 0 3px 3px; }
.tk-kb-empty { color: #616e88; font-size: 14px; padding: 30px 10px; text-align: center; }
.tk-kb-col.drop-over .tk-kb-body { outline: 2px dashed #5464f2; outline-offset: -2px; }
.tk-kb-card { background: #fff; border-radius: 5px; box-shadow: 0 1px 2px rgba(0,0,0,.1); padding: 7px 36px 4px 15px; position: relative; cursor: grab; font-size: 14px; line-height: 1.55; }
.tk-kb-card:hover { box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.tk-kb-card.dragging { opacity: .45; }
.tk-kb-card .tk-kb-subject { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-strong); text-decoration: none; }
.tk-kb-card .tk-kb-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text); font-weight: 400; }
.tk-kb-card a.tk-kb-line, .tk-kb-card a.tk-kb-subject { text-decoration: none; }
.tk-kb-card:hover a.tk-kb-subject, .tk-kb-card:hover a.tk-kb-line { color: #5464f2; }
.tk-kb-card .tk-kb-cb { position: absolute; top: 8px; right: 10px; opacity: 0; }
.tk-kb-card:hover .tk-kb-cb, .tk-kb-card .tk-kb-cb:checked { opacity: 1; }

/* Dialogs (kanban view editor / manager) */
.tk-dlg-row { margin-bottom: 14px; }
.tk-dlg-row > label { display: block; font-size: 13px; color: var(--color-text-muted); margin-bottom: 4px; }
.tk-dlg-list { border: 1px solid var(--border-panel); border-radius: 6px; max-height: 190px; overflow-y: auto; }
.tk-dlg-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border-row); font-size: 13px; }
.tk-dlg-item:last-child { border-bottom: none; }
.tk-dlg-item .grow { flex: 1; }
.tk-dlg-item button.mv { border: none; background: none; cursor: pointer; color: #616e88; padding: 0 3px; }
.tk-dlg-item button.mv:disabled { opacity: .3; cursor: default; }
.tk-dlg-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.tk-dlg-err { color: var(--color-danger); font-size: 12px; margin-top: 4px; }
.tk-dlg-inline { display: flex; gap: 10px; }
.tk-dlg-inline > * { flex: 1; }
.tk-badge-default { font-size: 11px; background: #ddf8ec; color: #12aa67; border-radius: 10px; padding: 1px 8px; }

/* Detail page */
.tk-detail { min-height: 100%; background: var(--color-bg); }
.tk-d-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px var(--space-5) 8px; background: #fff; border-bottom: 1px solid var(--border-row); }
.tk-d-back { border: none; background: none; cursor: pointer; font-size: 20px; color: #616e88; padding: 4px 6px; border-radius: 6px; }
.tk-d-back:hover { background: var(--color-surface-alt); }
.tk-d-ico { width: 36px; height: 36px; border-radius: 8px; background: #daf5f7; color: #0e8f8f; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tk-d-title { flex: 1; min-width: 0; }
.tk-d-title h1 { font-size: 20px; font-weight: 600; color: var(--color-text-strong); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-d-tags { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; font-size: 13px; }
.tk-d-tags .tk-add-tags { border: none; background: none; color: #5464f2; cursor: pointer; padding: 0; font-size: 13px; }
.tk-d-actions { display: flex; align-items: center; gap: 8px; }
.tk-d-nav button { width: 28px; height: 28px; border: 1px solid #c5c4d3; background: #fff; border-radius: 6px; cursor: pointer; color: var(--color-text); }
.tk-d-nav button:disabled { opacity: .35; cursor: default; }
.tk-d-tabbar { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-5); background: #fff; border-bottom: 1px solid var(--border-panel); }
.tk-d-tabs { display: flex; gap: 22px; }
.tk-d-tab { padding: 10px 2px; border: none; background: none; font-size: 14px; color: var(--color-text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tk-d-tab.active { color: #5464f2; border-bottom-color: #5464f2; font-weight: 600; }
.tk-d-last { font-size: 13px; color: var(--color-text-muted); }
.tk-d-layout { display: flex; gap: var(--space-4); padding: var(--space-4) var(--space-5); align-items: flex-start; }
.tk-d-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.tk-d-side { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.tk-card { background: #fff; border-radius: 8px; border: 1px solid var(--border-row); padding: 16px 20px; }
.tk-summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.tk-summary .lbl { font-size: 12px; color: var(--color-text-muted); margin-bottom: 4px; }
.tk-summary .val { font-size: 14px; font-weight: 500; color: var(--color-text-strong); word-break: break-word; }
.tk-summary a { color: #5464f2; text-decoration: none; }
.tk-sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tk-sec-head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.tk-link-btn { border: none; background: none; color: #5464f2; cursor: pointer; font-size: 13px; padding: 0; }
.tk-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.tk-field-row { display: flex; padding: 9px 0; border-bottom: 1px solid var(--border-row); font-size: 14px; }
.tk-field-row .k { width: 42%; color: var(--color-text-muted); flex-shrink: 0; }
.tk-field-row .v { flex: 1; color: var(--color-text-strong); word-break: break-word; }
.tk-field-row a { color: #5464f2; text-decoration: none; }
.tk-note { padding: 10px 0; border-bottom: 1px solid var(--border-row); font-size: 14px; }
.tk-note:last-child { border-bottom: none; }
.tk-note .meta { font-size: 12px; color: var(--color-text-muted); margin-top: 3px; display: flex; gap: 10px; align-items: center; }
.tk-note .tk-note-title { font-weight: 600; }
.tk-tl { position: relative; padding-left: 26px; }
.tk-tl-ev { position: relative; padding: 0 0 18px; font-size: 14px; }
.tk-tl-ev::before { content: ""; position: absolute; left: -19px; top: 16px; bottom: -2px; width: 2px; background: var(--border-panel); }
.tk-tl-ev:last-child::before { display: none; }
.tk-tl-dot { position: absolute; left: -26px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid #5464f2; box-sizing: border-box; }
.tk-tl-ev.closed .tk-tl-dot { border-color: #12aa67; background: #12aa67; }
.tk-tl-ev.note .tk-tl-dot { border-color: #f9b21d; }
.tk-tl-ev .when { font-size: 12px; color: var(--color-text-muted); }
.tk-tl-ev .det { color: var(--color-text-muted); margin-top: 2px; white-space: pre-wrap; }
.tk-contact-sw { width: 100%; padding: 8px 10px; border: 1px solid #c5c4d3; border-radius: 6px; background: #fff; font-size: 14px; }
.tk-mini { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.tk-mini .av { width: 40px; height: 40px; border-radius: 50%; background: #5464f2; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.tk-mini .nm { font-weight: 600; }
.tk-mini .sub { font-size: 12px; color: var(--color-text-muted); }
.tk-rel-item { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border-row); font-size: 13px; }
.tk-rel-item:last-child { border-bottom: none; }
.tk-rel-item a { color: #5464f2; text-decoration: none; }
@media (max-width: 1000px) { .tk-d-layout { flex-direction: column; } .tk-d-side { width: 100%; } .tk-summary { grid-template-columns: repeat(2, 1fr); } .tk-fields { grid-template-columns: 1fr; } }
