/* Redesigned Pipeline (Phase 2). Layout glue on top of the design-system classes (ds/undrads-ui.css):
   pl-head, toolbar, views, board-wrap, lane-group, col, dcard, table, bulkbar. Tokens only. */

#boardView.pl-page { flex-direction: column; padding: 0; overflow: hidden; background: transparent; min-height: 0; }
#boardView .pl-head { flex: none; }
#boardView .pl-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-6); flex-wrap: wrap; }
#boardView .page-title { margin: 0; }
#boardView .pl-danger { color: var(--danger); }
#boardView [hidden] { display: none !important; }

/* Toolbar */
#boardView .tb-search { min-width: 220px; }
#boardView .filter-btn .pl-n { color: var(--brand-text); font-weight: 600; }
.pl-chips { display: contents; }
.pl-pop { top: calc(100% + 6px); left: 0; }
.pl-pop-right { left: auto; right: 0; }
.pl-pop-up { top: auto; bottom: calc(100% + 8px); }
.pl-quick { width: 280px; max-height: min(420px, 70vh); overflow: auto; }
.pl-quick-search { margin: 2px 2px 6px; width: calc(100% - 4px); }
.pl-quick-acts { display: flex; gap: var(--s-3); padding: 2px 10px 6px; font-size: var(--fs-12); }
.pl-cr-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
#plSortMenu, #plMoreMenu { min-width: 240px; }

/* "More filters": the field menu and the rule builder (built by sales.js) */
#addFilterMenu:not(.show), #filterBuilderPopover:not(.show) { display: none; }
#addFilterMenu { width: 260px; max-height: min(460px, 70vh); overflow: auto; }
#filterBuilderPopover { width: 300px; padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-3); }
#filterBuilderPopover.show { display: flex; }
.pl-fb-title { font-size: var(--fs-13); }
.pl-fb-foot { display: flex; justify-content: flex-end; gap: 6px; }
#filterBuilderBody select, #filterBuilderBody input[type="number"], #filterBuilderBody input[type="date"], #filterBuilderBody input[type="text"] {
    width: 100% !important; height: 36px; padding: 0 10px; border-radius: var(--r-md); background: var(--surface); color: var(--text);
    border: 1px solid var(--border-strong); font: inherit; font-size: var(--fs-13);
}
#filterBuilderBody select:focus, #filterBuilderBody input:focus { outline: 2px solid var(--brand-ring); outline-offset: 0; }
#filterBuilderBody .pf-multi { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; }
#filterBuilderBody .pf-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-sm); font-size: var(--fs-13); cursor: pointer; }
#filterBuilderBody .pf-opt:hover { background: var(--surface-3); }
#filterBuilderBody .pf-opt input { accent-color: var(--brand); }
#filterBuilderBody .pf-hint, #filterBuilderBody .pf-empty { font-size: var(--fs-12); color: var(--text-3); margin-top: 6px; }

/* Board */
#boardView .board-wrap { flex: 1 1 auto; min-height: 0; }
#boardView .col { position: relative; }
#boardView .col-body { min-height: 80px; }
#boardView .pl-drop { padding: 28px 8px; }
#boardView .dcard { cursor: pointer; }
#boardView .dcard.sortable-ghost { opacity: 0.35; }
#boardView .sortable-fallback { transform: rotate(2deg); box-shadow: var(--shadow-3); opacity: 0.96; }
#boardView .pl-skel { height: 112px; border-radius: var(--r-lg); }
#boardView .pl-prog { flex: 1; height: 4px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; display: inline-block; vertical-align: middle; min-width: 40px; }
#boardView .pl-prog i { display: block; height: 100%; background: var(--st-onboarding); border-radius: inherit; }
#boardView .pl-onb-churned { color: var(--danger); }
#boardView .pl-rev { color: var(--success); }
#boardView .pl-rev b { color: var(--text); }
#boardView .dcard-tags .chip { cursor: pointer; text-decoration: none; }
#boardView .meta.faint { color: var(--text-3); }

/* Collapsed churn rails: the rail button sits inside the drop list */
#boardView .col.collapsed .col-head { display: none; }
#boardView .col.collapsed { cursor: pointer; }
#boardView .col.collapsed .col-body { min-height: 240px; align-self: stretch; width: 100%; }
#boardView .col.collapsed .col-body { padding: 0; height: 100%; overflow: hidden; }
#boardView .pl-rail { pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; height: 100%; min-height: 240px; padding: 12px 0; background: none; border: 0; color: inherit; cursor: pointer; }
#boardView .pl-rail .n { font-size: var(--fs-12); color: var(--text-3); }
#boardView .pl-rail .vlabel { writing-mode: vertical-rl; transform: rotate(180deg); font-size: var(--fs-12); font-weight: 600; color: var(--text-2); white-space: nowrap; }
#boardView .col-name .pl-rail-close { margin-left: auto; width: 24px; height: 24px; }

/* List view */
#plList { flex: 1 1 auto; min-height: 0; overflow: auto; margin: var(--s-4) var(--s-8); }
#plList .table tbody tr { cursor: pointer; }
#plList td[data-tick] { cursor: pointer; }

/* Bulk bar over the list */
#bulkActionBar.bulkbar { z-index: 1800; }

@media (max-width: 767px) {
    #boardView .pl-head { padding: var(--s-4); }
    #boardView .pl-stats { width: 100%; justify-content: space-between; }
    #boardView .board-wrap { padding: var(--s-3); }
    #plList { margin: var(--s-3); }
    #boardView .tb-search { min-width: 0; flex: 1 1 100%; }
}

/* Redesigned dialogs inside the old modal overlay (churn reason; more in Phases 3-4) */
.modal-content.ui-dialog { width: min(480px, calc(100vw - 32px)); margin: 12vh auto 0; padding: 0; background: var(--surface); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--r-2xl); box-shadow: var(--shadow-3); overflow: hidden; }
.ui-dialog .modal-head { display: flex; align-items: center; gap: var(--s-3); }
.ui-dialog .modal-head h2 { margin: 0; }
.ui-dialog-ic { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--brand-text); }
.ui-dialog-ic.danger { background: var(--danger-soft); color: var(--danger); }
.ui-pills { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.ui-dialog .form-error-banner { margin: 0 0 var(--s-3); padding: 8px 12px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font-size: var(--fs-13); }

/* ===== More filters: the shared rule builder (marketing.js renderConditionsInto) in design tokens ===== */
#boardView .pl-adv { width: min(640px, calc(100vw - 32px)); padding: 0; display: flex; flex-direction: column; max-height: 70vh; overflow: visible; }
#boardView .pl-adv[hidden] { display: none; }
#boardView .pl-adv-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px 4px; }
#boardView .pl-adv-head b { font-size: var(--fs-14); }
#boardView .pl-adv-match { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 14px 10px; font-size: var(--fs-13); color: var(--text-2); }
#boardView .pl-adv-match .select { width: auto; height: 30px; }
#boardView .pl-adv .al-conds { display: flex; flex-direction: column; gap: 6px; padding: 0 14px; max-height: 46vh; overflow: auto; }
#boardView .pl-adv-foot { display: flex; align-items: center; gap: 6px; padding: 10px 14px 12px; border-top: 1px solid var(--divider); margin-top: 10px; }
#boardView .pl-adv-foot .grow { flex: 1; }
[data-ui="v2"] .al-none { padding: 6px 0; font-size: var(--fs-13); color: var(--text-3); }
[data-ui="v2"] .al-cond { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 6px 8px; }
[data-ui="v2"] .al-cond select, [data-ui="v2"] .al-cond input { height: 30px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-13); padding: 0 8px; }
[data-ui="v2"] .al-cond > select { max-width: 220px; }
[data-ui="v2"] .al-cond input:focus, [data-ui="v2"] .al-cond select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft-2); }
[data-ui="v2"] .al-val { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
[data-ui="v2"] .al-val input { width: 130px; }
[data-ui="v2"] .al-cond .mkt-x { margin-left: auto; width: 26px; height: 26px; border: 0; background: transparent; color: var(--text-3); border-radius: var(--r-sm); cursor: pointer; font-size: 16px; }
[data-ui="v2"] .al-cond .mkt-x:hover { background: var(--surface-3); color: var(--danger); }
[data-ui="v2"] .al-connector { font-size: 10px; font-weight: 700; letter-spacing: 0.07em; color: var(--text-3); padding-left: 14px; }
[data-ui="v2"] .al-cond.al-incomplete { border-style: dashed; border-color: var(--warning); }
[data-ui="v2"] .al-cond.al-has-warn { border-color: var(--danger); }
[data-ui="v2"] .al-hint, [data-ui="v2"] .al-warn { flex-basis: 100%; font-size: var(--fs-12); }
[data-ui="v2"] .al-hint { color: var(--warning); }
[data-ui="v2"] .al-hint[hidden] { display: none; }
[data-ui="v2"] .al-warn { color: var(--danger); font-weight: 600; }
[data-ui="v2"] .mkt-muted { color: var(--text-3); font-size: var(--fs-12); }
[data-ui="v2"] .al-multi { position: relative; }
[data-ui="v2"] .al-multi summary { cursor: pointer; list-style: none; height: 30px; display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 0 10px; font-size: var(--fs-13); background: var(--surface); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-ui="v2"] .al-multi summary::-webkit-details-marker { display: none; }
[data-ui="v2"] .al-multi[open] summary { border-color: var(--brand); }
[data-ui="v2"] .al-multi-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 240px; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
[data-ui="v2"] .al-opt-search { width: 100% !important; margin-bottom: 4px; }
[data-ui="v2"] .al-opt-tools { display: flex; gap: 10px; padding: 2px 0 6px; border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
[data-ui="v2"] .al-link { background: none; border: 0; padding: 0; color: var(--brand-text); cursor: pointer; font-size: var(--fs-12); }
[data-ui="v2"] .al-opts { display: flex; flex-direction: column; gap: 2px; }
[data-ui="v2"] .al-opt { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: var(--r-sm); font-size: var(--fs-13); cursor: pointer; }
[data-ui="v2"] .al-opt:hover { background: var(--surface-hover); }
[data-ui="v2"] .al-opt input { accent-color: var(--brand); }
[data-ui="v2"] .al-opt[hidden], [data-ui="v2"] .al-opt-empty[hidden] { display: none !important; }

/* Sort menus: check marks, per-column sort button and its menu */
#boardView .pl-check { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--brand-text); font-size: var(--fs-12); }
#boardView .pl-col-sort { margin-left: auto; width: 24px; height: 24px; color: var(--text-3); opacity: 0; transition: opacity var(--t-fast); }
#boardView .col:hover .pl-col-sort, #boardView .pl-col-sort:focus-visible, #boardView .pl-col-sort.set { opacity: 1; }
#boardView .pl-col-sort.set { color: var(--brand-text); background: var(--brand-soft); }
#boardView .col.collapsed .pl-col-sort { display: none; }
#boardView .pl-colsort { position: fixed; z-index: 1400; width: 250px; }
#boardView .pl-colsort-note { padding: 6px 10px 4px; font-size: var(--fs-12); color: var(--text-3); border-top: 1px solid var(--divider); margin-top: 4px; }

/* Saved views */
#boardView .view-pill .ua-ic { flex: none; }
#boardView .pl-save-view { border-style: dashed; color: var(--text-2); }
.ui-dialog-form .pl-vm-sec { font-size: var(--fs-11); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); margin-top: 6px; }
.ui-dialog-form .pl-vm-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--divider); }
.ui-dialog-form .pl-vm-row .input { flex: 1; height: 32px; }
.ui-dialog-form .pl-vm-row .pl-vm-name { flex: 1; font-weight: 500; }
.ui-dialog-form .pl-vm-ic { color: var(--text-3); display: inline-flex; }
.ui-dialog-form .empty { padding: 12px; }
