/* Tasks and Churn — screen styles on top of app.css. Use the design tokens only (no literal colours). */

/* ============================== Tasks ============================== */
/* the screen lays out by its own width (the sidebar collapses at different widths) */
.tk-view{container:tk/inline-size}
.tk-view .tiles{grid-template-columns:repeat(auto-fit,minmax(160px,1fr))}
.tk-t-done{--tile-accent:var(--sky)}

/* add-a-task form */
.tk-add{display:grid;grid-template-columns:minmax(180px,2fr) minmax(170px,1.4fr) minmax(130px,1fr) minmax(140px,1fr) auto;gap:10px 12px;align-items:end;margin-bottom:16px;padding:14px 16px}
.tk-add .field{margin:0;min-width:0}
.tk-add .btn{height:36px}
@container tk (max-width:900px){
  .tk-add{grid-template-columns:repeat(2,minmax(0,1fr))}
  .tk-f-title{grid-column:1/-1}
}
@container tk (max-width:520px){
  .tk-f-client,.tk-f-btn{grid-column:1/-1}
  .tk-add:not(.open) .tk-more{display:none}
}

/* filters */
.tk-filters .seg{max-width:100%;overflow-x:auto;scrollbar-width:none}
.tk-filters select.inline-sel{height:36px;border-radius:10px;padding:0 10px;max-width:220px}
.tk-search{height:36px;width:240px;margin-left:auto}
.tk-search svg{width:15px;height:15px;flex:none}
.tk-search input::-webkit-search-cancel-button{cursor:pointer}
@container tk (max-width:640px){
  .tk-filters select.inline-sel{flex:1 1 130px;max-width:none;min-width:0}
  .tk-search{flex:1 1 170px;width:auto;margin-left:0}
}

/* the list, grouped by when each task is due */
.tk-list{padding:4px 0}
.tk-sec+.tk-sec{border-top:1px solid var(--line)}
.tk-sec-h{display:flex;align-items:center;gap:8px;margin:0;padding:14px 18px 6px;font:600 10.5px var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--ink2)}
.tk-sec-h::before{content:"";width:7px;height:7px;border-radius:99px;flex:none;background:var(--g-c,var(--ink3));box-shadow:0 0 10px var(--g-c,transparent)}
.tk-n{font:600 10.5px/1.7 var(--mono);letter-spacing:0;color:var(--ink2);background:var(--mut-bg);border-radius:99px;padding:0 7px}
.tk-g-late{--g-c:var(--crit)}
.tk-g-today{--g-c:var(--amber)}
.tk-g-week{--g-c:var(--aqua)}
.tk-g-later{--g-c:var(--brand)}
.tk-g-none{--g-c:var(--ink3)}
.tk-g-done{--g-c:var(--good)}
.tk-ul{list-style:none;margin:0;padding:0}

.tk-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;grid-template-areas:"chk title due del" "chk meta due del";align-items:center;gap:3px 12px;padding:11px 18px;border-top:1px solid var(--line2);transition:background-color .15s}
.tk-sec-h+.tk-ul .tk-row:first-child,.tk-sec:first-child .tk-ul .tk-row:first-child{border-top:0}
.tk-row:hover{background:color-mix(in srgb,var(--brand-tint) 55%,transparent)}
.tk-list.ro .tk-row{grid-template-columns:auto minmax(0,1fr) auto;grid-template-areas:"chk title due" "chk meta due"}

/* drawn checkbox */
.tk-check{grid-area:chk;align-self:start;width:20px;height:20px;padding:0;margin-top:1px;border-radius:6px;border:1.5px solid color-mix(in srgb,var(--ink) 28%,transparent);background:var(--solid);display:grid;place-items:center;transition:background-color .2s,border-color .2s,box-shadow .2s,transform .4s var(--spring)}
.tk-check:hover{border-color:var(--brand);box-shadow:0 0 0 4px var(--brand-tint)}
.tk-check:active{transform:scale(.84)}
.tk-check:disabled{cursor:progress}
.tk-check svg{width:14px;height:14px}
/* touch: a 40px hit area around the 20px box (it stays inside the row padding and the 12px column gap) */
@media (pointer:coarse){
  .tk-check{position:relative}
  .tk-check::after{content:"";position:absolute;inset:-10px}
}
.tk-check path,.tk-state path{fill:none;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}
.tk-check path{stroke:var(--solid);stroke-dasharray:16;stroke-dashoffset:16;transition:stroke-dashoffset .35s var(--ease) .05s}
.tk-check[aria-checked="true"]{background:var(--good);border-color:var(--good);box-shadow:0 0 12px -2px var(--good-bg)}
.tk-check[aria-checked="true"] path{stroke-dashoffset:0}
/* read-only status mark (no tasks.manage) */
.tk-state{grid-area:chk;align-self:start;width:18px;height:18px;margin-top:2px;border-radius:99px;border:1.5px solid var(--ink3);display:grid;place-items:center;color:var(--good)}
.tk-state.is-done{border-color:var(--good);background:var(--good-bg)}
.tk-state svg{width:11px;height:11px}
.tk-state path{stroke:currentColor}

.tk-title{grid-area:title;min-width:0;font-size:13.5px;font-weight:550;line-height:1.45;overflow-wrap:anywhere;transition:color .25s}
.tk-row.is-done .tk-title{color:var(--ink3);text-decoration:line-through;text-decoration-color:color-mix(in srgb,var(--ink3) 70%,transparent)}
.tk-meta{grid-area:meta;min-width:0;display:flex;align-items:center;flex-wrap:wrap;gap:4px 14px;font-size:12px;color:var(--ink2)}
.tk-client{border:0;background:none;padding:0;font:inherit;font-weight:550;color:var(--ink2);text-align:left;text-decoration:underline;text-decoration-color:var(--line);text-underline-offset:3px;overflow-wrap:anywhere}
.tk-client:hover{color:var(--brand);text-decoration-color:currentColor}
.tk-owner{display:inline-flex;align-items:center;gap:6px;white-space:nowrap}
.tk-owner .mini-avatar{width:18px;height:18px;font-size:8px}
.tk-due{grid-area:due;justify-self:end;white-space:nowrap}
.tk-when{font:500 12px var(--mono);color:var(--ink2)}
.tk-del{grid-area:del;width:30px;height:30px;padding:0;border:0;border-radius:8px;background:none;color:var(--ink3);display:grid;place-items:center;opacity:0;transition:opacity .15s,background-color .15s,color .15s}
.tk-del svg{width:16px;height:16px}
.tk-row:hover .tk-del,.tk-row:focus-within .tk-del{opacity:1}
.tk-del:hover{background:var(--crit-bg);color:var(--crit)}
@media (hover:none){.tk-del{opacity:1}}
@container tk (max-width:560px){
  .tk-row{grid-template-areas:"chk title title del" "chk meta due del";padding:11px 14px}
  .tk-list.ro .tk-row{grid-template-areas:"chk title title" "chk meta due"}
  .tk-sec-h{padding-left:14px;padding-right:14px}
}
.tk-empty{display:flex;flex-direction:column;align-items:center;gap:10px;padding:34px 22px}
.tk-empty-t{font-size:14px;font-weight:600;color:var(--ink2)}

/* ============================== Churn ============================== */
.ch-view{container:ch/inline-size}
.ch-view .tiles{grid-template-columns:repeat(auto-fit,minmax(170px,1fr))}
.ch-t-pink{--tile-accent:var(--pink)}
.ch-t-sky{--tile-accent:var(--sky)}
.tile .t-sub.ch-ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ch-count{display:inline-block;margin-left:6px;font:600 11px/1.7 var(--mono);color:var(--ink2);background:var(--mut-bg);border-radius:99px;padding:0 7px;vertical-align:2px}
.ch-col{display:flex;flex-direction:column;gap:14px;min-width:0}
.ch-col>.card:last-child{flex:1}
.ch-empty{padding:16px 8px}

/* chart card: the summary sits at the bottom so the card fills its row */
.ch-chart{display:flex;flex-direction:column}
.ch-chart-foot{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:auto 0 0;padding-top:14px;border-top:1px solid var(--line2)}
.ch-chart .chart-wrap{margin-bottom:16px}
.ch-chart-foot dt{margin:0 0 3px}
.ch-chart-foot dd{margin:0;font-size:15px;font-weight:600;letter-spacing:-.01em}
.ch-chart-foot dd .faint{font-size:12.5px;font-weight:500;margin-left:4px}
/* "Full width" (ChartSize): the chart takes its own row and At risk + Rules sit side by side above it,
   so neither row is left half empty; the card is scrolled back into view, clear of the sticky top bar */
.ch-chart{scroll-margin-top:72px}
/* full screen pins the card to the window; browsers that still give a query container layout containment
   would pin it to the page instead, so the page stops being a container while it is open */
.ch-view:has(.cs-max){container-type:normal}
@media (min-width:1021px){
  .ch-view .grid-2:has(>.ch-chart.cs-wide)>.ch-col{grid-column:1/-1;flex-direction:row;align-items:stretch}
  .ch-view .grid-2:has(>.ch-chart.cs-wide)>.ch-col>.card{flex:7 1 0;min-width:0}
  .ch-view .grid-2:has(>.ch-chart.cs-wide)>.ch-col>.card:last-child{flex:5 1 0}
}

/* at risk */
.ch-risk{list-style:none;margin:0;padding:0}
.ch-risk-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;padding:12px 0;border-top:1px solid var(--line2)}
.ch-risk-row:first-child{border-top:0;padding-top:2px}
.ch-risk-main{flex:1 1 220px;min-width:0}
.ch-risk-name{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}
.ch-name{border:0;background:none;padding:0;font:inherit;font-size:13.5px;font-weight:650;color:var(--ink);text-align:left;overflow-wrap:anywhere}
.ch-name:hover{color:var(--brand)}
.ch-risk-meta{font-size:12.5px;color:var(--ink2);margin-top:3px}
.ch-risk-act{display:flex;gap:6px;flex-wrap:wrap}
.ch-out{flex:1 1 100%;display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:10px;border-radius:12px;background:var(--mut-bg)}
.ch-out[hidden]{display:none}
.ch-out .input{flex:1 1 220px;min-width:0;height:32px}

/* rule summary */
.ch-rules{margin:0;display:flex;flex-direction:column}
.ch-rule{display:grid;grid-template-columns:80px minmax(0,1fr);gap:10px;align-items:baseline;padding:10px 0;border-top:1px solid var(--line2);font-size:13px}
.ch-rule:first-child{border-top:0;padding-top:0}
.ch-rule dt,.ch-rule dd{margin:0}
.ch-rule dd{color:var(--ink2);line-height:1.5}
.ch-rule b{color:var(--ink);font:600 12.5px var(--mono)}

/* churned accounts table */
.ch-tbl-head{display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 12px;padding:16px 18px 8px}
.ch-tbl-head h3{margin:0;font-size:14.5px;font-weight:650;letter-spacing:-.01em}
.ch-tbl-head .sub{margin:0;font-size:12.5px;color:var(--ink2)}
.ch-tbl{min-width:620px}
.ch-tbl th:first-child,.ch-tbl td:first-child{padding-left:18px}
.ch-tbl th:last-child,.ch-tbl td:last-child{padding-right:18px}
.ch-tbl .ch-r{text-align:right}
.ch-nowrap{white-space:nowrap}
.ch-prods{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}
.ch-reason{display:flex;align-items:center;gap:8px;max-width:380px;font-size:12.5px;color:var(--ink2)}
.ch-reason .chip{flex:none}
.ch-reason-t{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}

/* lost before go-live */
.ch-lost-sum{text-align:right}
.ch-lost-sum .eyebrow{margin-bottom:2px}
.ch-lost-num{font-size:20px;font-weight:600;letter-spacing:-.02em;line-height:1.2}
.ch-lost-sum .faint{font-size:12px}
.ch-lost{list-style:none;margin:0 -8px;padding:0}
.ch-lost li+li{border-top:1px solid var(--line2)}
.ch-lost-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 12px;align-items:center;width:100%;border:0;background:none;text-align:left;padding:10px 8px;border-radius:10px;color:var(--ink);font:inherit;transition:background-color .15s}
.ch-lost-row:hover{background:var(--brand-tint)}
.ch-lost-name{display:flex;align-items:center;flex-wrap:wrap;gap:6px;font-size:13.5px;font-weight:600;min-width:0}
.ch-lost-amt{font-size:12.5px;color:var(--ink2);white-space:nowrap}
.ch-lost-why{grid-column:1/-1;font-size:12px;color:var(--ink3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@container ch (max-width:520px){
  .ch-lost-sum{text-align:left}
  .ch-rule{grid-template-columns:1fr;gap:6px}
}
