/* ==========================================================================
   Projects: list, form, workspace. Module stylesheet: tokens only, shared parts live in components.css.
   ========================================================================== */

/* ---- Project form: the form is the page; a live summary + tips sit beside it (stacked below on tablets / phones) ---------------------- */
.pj-new { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
.pj-new__main { min-width: 0; }
.pj-new__side { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.pj-sum { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); }
.pj-sum dt { color: var(--text-muted); font-weight: var(--fw-regular); } .pj-sum dd { margin: 0; text-align: end; font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.pj-sum dd.is-empty { color: var(--text-faint); font-weight: var(--fw-regular); }
.pj-sum__tpl { margin-block-start: var(--sp-3); padding-block-start: var(--sp-2); border-block-start: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-muted); }
.pj-tips { font-size: var(--fs-xs); color: var(--text-muted); padding-inline: var(--sp-1); }
.pj-tips__title { font-weight: var(--fw-semibold); color: var(--text); margin-block-end: var(--sp-1); display: flex; gap: var(--sp-1); align-items: center; }
.pj-tips ul { margin: 0; padding-inline-start: var(--sp-4); display: grid; gap: var(--sp-1); }
@media (min-width: 1100px) { .pj-new { grid-template-columns: minmax(0, 1fr) 320px; } .pj-new__side { position: sticky; inset-block-start: var(--sp-3); } }
@media (max-width: 767.98px) { .pj-new__side { display: none; } }   /* phones: the form is the page */

/* Project workspace Tasks tab: the board uses the full width, only the board scrolls sideways. */
.pj-tasks__head { display: flex; align-items: center; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap; margin-block-end: var(--sp-2); }
.pj-tasks__title { font-size: var(--fs-md); margin: 0; }

@keyframes bk-pulse { 50% { opacity: .45; } }

/* the whole card opens the task: the title link stretches over it; the menu stays above */

/* subtle help: shows on hover or keyboard focus, no permanent paragraph */
.bk-help, .m-tip { position: relative; color: var(--text-faint); cursor: help; display: inline-flex; border-radius: var(--r-sm); }
.bk-help:hover, .bk-help:focus-visible, .m-tip:hover, .m-tip:focus-visible { color: var(--text); }
.bk-help::after, .m-tip::after { content: attr(data-tip); position: absolute; inset-block-start: calc(100% + 6px); inset-inline-start: 0; width: max-content; max-width: min(280px, 80vw); background: var(--text); color: var(--bg); padding: 6px 8px; border-radius: var(--r-sm); font-size: var(--fs-xs); line-height: 1.35; opacity: 0; pointer-events: none; transition: opacity var(--t-fast); z-index: 20; }
.bk-help:hover::after, .bk-help:focus-visible::after, .m-tip:hover::after, .m-tip:focus-visible::after { opacity: 1; }
.pj-tasks__head { position: relative; }
@media (max-width: 767.98px) {   /* anchor the tip to the toolbar so it can never push the page wider */
  .bk-help, .m-tip { position: static; }
  .bk-help::after, .m-tip::after { inset-inline: 0; inset-block-start: 100%; width: auto; max-width: none; }
}

/* ---- Projects: cards view -------------------------------------------------------------------------------------------- */
.pj-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.pj-card { position: relative; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); min-width: 0; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.pj-card:hover { border-color: var(--border-strong); box-shadow: 0 3px 10px rgb(0 0 0 / .08); }
.pj-card:focus-within { border-color: var(--accent); }
.pj-card.is-muted { opacity: .75; }
.pj-card__top { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.pj-card__id { flex: 1; display: flex; flex-direction: column; }
.pj-card__id small { color: var(--text-faint); font-size: var(--fs-xs); }
.pj-card__name { font-weight: var(--fw-semibold); color: var(--text); line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
a.pj-card__name:hover { color: var(--accent-text); text-decoration: none; }
a.pj-card__name::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }   /* the whole card opens the project */
a.pj-card__name:focus-visible { outline: none; }
.pj-card:has(a.pj-card__name:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.pj-card__menu { position: relative; z-index: 2; flex: none; }
.pj-card__menu .icon-btn { width: 26px; height: 26px; }
.pj-card .m-avatar { width: 30px; height: 30px; font-size: var(--fs-sm); }
.pj-card__mid { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px var(--sp-2); min-width: 0; }
.pj-card__mid > .pj-card__chips { grid-column: 1 / -1; grid-row: 2; }
.pj-card__customer { color: var(--text-muted); font-size: var(--fs-sm); display: flex; align-items: center; gap: 6px; }
.pj-card__customer .bi, .pj-card__deadline .bi { color: var(--text-faint); font-size: .8rem; flex: none; }
.pj-card__chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.pj-card__stage { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text); font-weight: var(--fw-medium); }
.pj-card__deadline { font-size: var(--fs-xs); color: var(--text-muted); display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.pj-card__deadline.is-overdue, .pj-card__deadline.is-overdue .bi { color: var(--danger); }
.pj-card__foot { margin-block-start: auto; display: flex; align-items: center; gap: var(--sp-3); padding-block-start: 6px; border-block-start: 1px solid var(--border); }
.pj-card__foot .m-progress { flex: 1 1 auto; min-width: 0; }
.pj-card__foot:empty { display: none; }
.pj-card__tasks { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-xs); color: var(--text-muted); position: relative; z-index: 1; }
.pj-card__tasklink { color: inherit; } .pj-card__tasklink:hover { color: var(--accent-text); }
.pj-card__late { color: var(--danger); font-weight: var(--fw-medium); }

/* ---- Projects: the new-project form in the drawer (single column, no setup sidebar) ---------------------------------- */
.pj-tpl { display: grid; gap: var(--sp-2); margin-block-end: var(--sp-1); }
.pj-tpl__label { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-medium); }
.pj-tpl__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pj-tpl .pj-chip { height: 32px; padding-inline: 12px; font-size: var(--fs-sm); max-width: 100%; white-space: nowrap; }
.pj-tpl .pj-chip[aria-checked="true"] { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.pj-tpl__summary { margin: 0; font-size: var(--fs-xs); color: var(--text-muted); padding: 6px 10px; background: var(--surface-2); border-radius: var(--r-md); }
.pj-tpl__summary[hidden] { display: none; }
.pj-new--drawer { display: block; }
.pj-new--drawer .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pj-new--drawer .m-card__body { padding: 0; }
@media (max-width: 575.98px) { .pj-new--drawer .form-grid { grid-template-columns: minmax(0, 1fr); } .pj-new--drawer .form-grid > * { grid-column: 1 / -1; } }
.pj-new--drawer .m-lookup, .pj-new--drawer .m-select, .pj-new--drawer .m-input { min-width: 0; width: 100%; }

.fx-basis { display: inline-block; margin-inline-start: 4px; padding: 0 6px; border-radius: var(--r-pill); background: var(--neutral-soft); color: var(--text-muted); font-size: var(--fs-2xs, .6875rem); font-weight: var(--fw-regular, 400); }

.cur-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--sp-4) var(--sp-5); }
.cur-block { display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-start; min-width: 0; }
.cur-block__title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); margin: 0; text-transform: none; }
.cur-note { margin: 0; font-size: var(--fs-xs); color: var(--text-muted); max-width: 60ch; }
.cur-note--warn { color: var(--text); background: var(--warning-soft); border-radius: var(--r-md); padding: 6px 10px; }
.cur-hist { margin: 0; padding: 0; list-style: none; font-size: var(--fs-xs); color: var(--text-muted); }
.cur-impact { margin: 0; padding-inline-start: var(--sp-4); font-size: var(--fs-xs); color: var(--text-muted); display: grid; gap: 4px; }
.cur-block .cur-mainform { width: 100%; }

.m-segment.is-saving { opacity: .75; }
.m-segment.is-saving a { pointer-events: none; }

/* Shared form modal: compact by default, wider for the few forms that ask for it (data-size="lg"). */
#m-overlay-modal .modal-dialog { --bs-modal-width: 560px; }
#m-overlay-modal[data-size="lg"] .modal-dialog { --bs-modal-width: 760px; }
#m-overlay-modal .m-modal__body { padding-block-end: var(--sp-3); }

/* Project logo */
/* a picture is shown whole, centred in its square (never cropped), whatever its shape */
.m-avatar:has(> img) { background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.m-avatar > img { width: 100%; height: 100%; object-fit: contain; padding: 2px; border-radius: inherit; display: block; }
.pj-logo { position: relative; display: inline-block; padding: 0; border: 0; background: none; border-radius: var(--r-lg); cursor: pointer; }
.pj-logo__edit { position: absolute; inset-inline-end: -4px; inset-block-end: -4px; display: grid; place-items: center; width: 18px; height: 18px; font-size: 10px; color: var(--accent-contrast); background: var(--accent); border-radius: 50%; opacity: 0; transition: opacity var(--t-fast); }
.pj-logo:hover .pj-logo__edit, .pj-logo:focus-visible .pj-logo__edit { opacity: 1; }
@media (hover: none) { .pj-logo__edit { opacity: 1; } }
.pj-logo__preview { display: flex; justify-content: center; }
.pj-logo__preview .m-avatar { width: 96px; height: 96px; }

/* Logo backgrounds: chosen from the picture (white behind dark / transparent-dark logos, black behind light ones) */
.m-avatar.m-avatar--bg-white { background: #fff; border-color: #e4e7ec; }
.m-avatar.m-avatar--bg-black { background: #0b0f17; border-color: #2a3140; }

/* ---- Project workspace: one-row header, quiet tabs, one toolbar row, then the board ----------------------------------------- */
.pj-ws .ct-header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--sp-3); min-height: 38px; margin-block-end: 6px; }
.pj-ws .ct-header__id, .pj-ws .ct-header__id > .min-w-0, .pj-ws .ct-header__meta { display: contents; }   /* logo, name, customer, stage, status, progress share one flex row */
.pj-ws .ct-header__id .m-avatar { width: 32px; height: 32px; font-size: var(--fs-sm); border-radius: var(--r-md); }
.pj-ws .ct-header h1 { margin: 0; font-size: var(--fs-xl); line-height: 1.2; letter-spacing: var(--ls-title); overflow-wrap: anywhere; }
.pj-ws .ct-header h1 small { margin-inline-start: 6px; font-size: var(--fs-xs); font-weight: var(--fw-regular); }
.pj-ws .ct-header__meta > a { display: inline-flex; align-items: center; gap: 6px; max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: var(--fs-sm); }
.pj-ws .ct-header__meta > a:hover { color: var(--text); }
.pj-ws .pj-chip { height: 26px; gap: 6px; padding-inline: 10px; background: var(--surface); border-color: var(--border-strong); font-weight: var(--fw-medium); }
.pj-ws .pj-chip .bk-dot { width: 8px; height: 8px; }
.pj-ws [data-project-progress] .m-progress { min-width: 0; width: 130px; }
.pj-ws .ct-header .page-header__actions { margin-inline-start: auto; flex-wrap: nowrap; gap: var(--sp-2); }
.pj-back { display: inline-grid; place-items: center; width: 24px; height: 28px; flex: none; margin-inline-end: -6px; border-radius: var(--r-md); color: var(--text-faint); }
.pj-back:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }

.pj-ws .m-tabs { gap: 0; margin-block-end: 8px; }
.pj-ws .m-tab { padding-inline: var(--sp-3); font-size: var(--fs-sm); }
.pj-ws .m-tab.active { font-weight: var(--fw-medium); }

.pj-ws .pj-tasks__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); min-height: var(--ctl-h); margin-block-end: 8px; }
.pj-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: 0; }
.pj-search { position: relative; display: flex; align-items: center; margin: 0; }
.pj-search .bi { position: absolute; inset-inline-start: 10px; color: var(--text-faint); pointer-events: none; }
.pj-search input { width: clamp(180px, 20vw, 260px); height: var(--ctl-h); padding-inline: 30px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: inherit; }
.pj-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.pj-ws .pj-tasks__head .m-btn, .pj-ws .pj-tasks__head .m-segment { height: var(--ctl-h); }
.pj-filterbtn.is-on { border-color: var(--accent); color: var(--accent-text); }
.pj-filterbtn__n { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-contrast); font-size: var(--fs-2xs); }
.pj-filtermenu { min-width: 220px; }
.pj-filtermenu .m-input { width: 100%; }
.pj-tasks__counts { white-space: nowrap; }

@media (max-width: 900px) {   /* not enough room for one row: identity row, then the facts */
  .pj-ws .ct-header__id { display: flex; align-items: flex-start; gap: var(--sp-2); min-width: 0; flex: 1 1 60%; }
  .pj-ws .ct-header__id > .min-w-0 { display: block; min-width: 0; }
  .pj-ws .ct-header__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--sp-2); margin-block-start: 4px; }
  .pj-ws .ct-header .page-header__actions { margin-inline-start: 0; }
}
@media (max-width: 600px) {   /* logo | name | actions, facts under them (a direction-agnostic grid) */
  .pj-back { display: none; }
  .pj-ws .ct-header { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; column-gap: var(--sp-2); }
  .pj-ws .ct-header__id, .pj-ws .ct-header__id > .min-w-0 { display: contents; }
  .pj-ws .ct-header__id > :first-child { grid-row: 1; grid-column: 1; }
  .pj-ws .ct-header h1 { grid-row: 1; grid-column: 2; }
  .pj-ws .ct-header .page-header__actions { grid-row: 1; grid-column: 3; margin-inline-start: 0; }
  .pj-ws .ct-header__meta { display: flex; grid-row: 2; grid-column: 1 / -1; flex-wrap: wrap; margin-block-start: 0; }
  .pj-ws .m-tab { padding-inline: 12px; }
  .pj-search input { width: 100%; }
  .pj-tools { flex: 1 1 100%; }
  .pj-search { flex: 1 1 140px; }
}

/* ---- "Task lists" view of the Projects page: one list per project, tasks underneath (stage = label) ---- */
.pj-lists .pj-list .bk-col__head h2 a { color: inherit; text-decoration: none; }
.pj-lists .pj-list .bk-col__head h2 a:hover { text-decoration: underline; }
.pj-lists .pj-task .bk-labels { padding-inline-end: 0; margin-block-end: 4px; }
.pj-lists .pj-task .bk-card__facts { margin-block-start: 6px; }
.pj-list__empty { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }
.pj-list__more { display: block; padding: 6px var(--sp-3); font-size: var(--fs-sm); color: var(--text-muted); }
.pj-lists .pj-task .bk-card__title { text-align: start; padding-inline-end: 0; }
@media (max-width: 575.98px) { .pj-lists { --bk-col-w: min(86vw, 320px); } }   /* phones: one list nearly fills the screen, the next one peeks */

/* ---- Project popup: description + Vault credentials ---- */
.pq__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-block-end: var(--sp-3); font-size: var(--fs-sm); }
.pq__sec { margin-block-end: var(--sp-4); }
.pq__h { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-2); font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.pq__h .bi { color: var(--text-muted); }
.pq-cred { padding: var(--sp-2) 0; border-block-start: 1px solid var(--border); }
.pq-cred:first-of-type { border-block-start: 0; }
.pq-cred__name { display: flex; align-items: center; gap: var(--sp-2); margin-block-end: 4px; }
.pq-cred__fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px var(--sp-4); margin: 0; }
.pq-field { min-width: 0; padding: 2px 0; }
.pq-field dt { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.pq-field dd { display: flex; align-items: center; gap: 4px; margin: 0; min-width: 0; font-size: var(--fs-sm); }
.pq-field dd > a, .pq-field dd > span { min-width: 0; overflow-wrap: anywhere; }
.pq-field .icon-btn { flex: none; margin-inline-start: auto; }
.pq-field .icon-btn + .icon-btn { margin-inline-start: 0; }
.pq-secret { font-family: var(--font-mono, ui-monospace, monospace); letter-spacing: .08em; }
.pq-secret.is-open { letter-spacing: 0; user-select: all; }
.pj-lists-bar { display: flex; justify-content: flex-end; margin-block-end: var(--sp-2); }
.pj-switch { display: inline-flex; align-items: center; gap: var(--sp-2); margin: 0; font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer; }
.pj-lists--hide-done .pj-task.tk-row-done { display: none; }
.pj-lists { min-height: 240px; align-items: flex-start; padding-block-end: var(--sp-6); }   /* empty space below the lists to grab and drag the board sideways */
.pq-notes { margin-block-start: 6px; }
.pq-notes__k { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.pq-notes__v { white-space: pre-line; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.pj-add { padding: 4px 4px 6px; }
.pj-add__open { display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: none; color: var(--text-muted); font-size: var(--fs-sm); text-align: start; cursor: pointer; }
.pj-add__open:hover { background: var(--surface-hover); color: var(--text); }
.pj-add__open[hidden], .pj-add__form[hidden] { display: none; }
.pj-add__form { display: grid; gap: 6px; }

.pq__facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--sp-2) var(--sp-4); margin: 0 0 var(--sp-3); }
.pq__facts dt { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.pq__facts dd { margin: 0; font-size: var(--fs-sm); }
.pq-task { display: flex; align-items: center; gap: var(--sp-2); padding: 6px 0; border-block-start: 1px solid var(--border); font-size: var(--fs-sm); }
.pq-task:first-of-type { border-block-start: 0; }
.pq-task__title { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.pq-task__title:hover { text-decoration: underline; }
.pq-task.is-done .pq-task__title { text-decoration: line-through; color: var(--text-muted); }

/* Project card on the board: logo + name, tasks done / total, deadline, progress */
.pj-pc__head { display: flex; align-items: center; gap: 10px; padding-inline-end: 22px; }
.pj-pc__head .m-avatar { width: 32px; height: 32px; flex: none; }
.pj-pc__title { min-width: 0; flex: 1; }
.pj-pc__title .bk-card__title { display: block; font-weight: var(--fw-semibold); line-height: 1.25; padding: 0; text-align: start; }
.pj-pc__title .bk-card__sub { font-size: var(--fs-xs); }
.pj-pc__facts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0; }
.pj-pc__tasks { font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); }
.pj-pc__tasks.is-complete { color: var(--success, #16a34a); }


/* ---- Project cards: logo leads the card, name and customer beside it ---- */
.pj-card { gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); min-height: 132px; }
.pj-card__top { align-items: flex-start; gap: var(--sp-3); }
.pj-card__id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pj-card__bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); }
.pj-team { display: flex; align-items: center; flex-wrap: wrap; min-width: 0; }
.pj-team .bk-ava { margin-inline-end: -6px; border: 2px solid var(--surface); }
.pj-team__more { margin-inline-start: 10px; font-size: var(--fs-xs); color: var(--text-muted); }
.pj-card .pj-card__logo { width: 72px; height: 72px; margin-inline-start: auto; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); }
.pj-card .pj-card__logo img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.pj-card__code { color: var(--text-faint); font-size: var(--fs-xs); }
.pj-card__name { font-size: var(--fs-md, 1rem); }
.pj-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--sp-3); }
