/* =====================================================================
   Pipeline page, the Deal section on a lead's panel, and the "Why was it lost?" box
   (colours come from the tokens in app.css)
   ===================================================================== */

/* ---------- the numbers at the top ---------- */
.pl-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 0.8rem; margin-bottom: 1.1rem; }
.pl-summary .stat-value { font-size: 1.6rem; }
.pl-summary .pl-money { font-size: 1.15rem; line-height: 1.3; margin-top: 0.35rem; overflow-wrap: anywhere; }
.pl-summary .pl-money small { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.stat.hero .pl-money small { color: rgba(255, 255, 255, 0.8); }
.pl-reasons { list-style: none; margin: 0.35rem 0 0; padding: 0; }
.pl-reasons li { display: flex; justify-content: space-between; gap: 0.6rem; font-size: 0.8rem; color: var(--text-soft);
                 padding: 0.12rem 0; border-bottom: 1px dashed var(--border); }
.pl-reasons li:last-child { border-bottom: none; }
.pl-reasons b { font-variant-numeric: tabular-nums; color: var(--text); }
.pl-lost-tile .stat-sub { margin-top: 0.35rem; }

/* ---------- the board: one column per stage (scrolls sideways inside itself if it must) ---------- */
.pl-tabs { display: none; }
.pl-board { display: flex; gap: 0.6rem; align-items: flex-start; overflow-x: auto; padding-bottom: 0.4rem; }
.pl-col { flex: 1 0 178px; min-width: 0; display: flex; flex-direction: column; border-radius: var(--radius);
          background: var(--panel); border: 1px solid var(--border); }
.pl-col-head { padding: 0.7rem 0.8rem 0.55rem; border-bottom: 1px solid var(--border); }
.pl-col-title { display: flex; align-items: center; gap: 0.4rem; }
.pl-col-title h2 { margin: 0; font-size: 0.88rem; font-weight: 700; white-space: nowrap; }
.pl-col-title .dot { margin: 0; flex: none; }
.pl-count { min-width: 1.4rem; padding: 0 0.4rem; border-radius: 999px; background: rgba(255, 255, 255, 0.07);
            font-size: 0.72rem; text-align: center; color: var(--text-soft); }
.pl-collapse { margin-left: auto; padding: 0.15rem 0.45rem; font-size: 0.72rem; }
.pl-col-total { margin-top: 0.2rem; font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pl-cards { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.6rem; }
.pl-none, .pl-more { margin: 0.2rem 0.2rem 0.3rem; font-size: 0.78rem; }
.pl-col.stage-won, .pl-col.stage-lost { flex-basis: 165px; }
.pl-col.stage-won { border-color: rgba(47, 214, 123, 0.28); }
.pl-col.stage-lost { border-color: rgba(255, 95, 120, 0.22); }

/* Won / Lost folded away: a slim strip with the name and count */
.pl-col.collapsed { flex: 0 0 3.3rem; }
.pl-col.collapsed .pl-cards, .pl-col.collapsed .pl-col-total { display: none; }
.pl-col.collapsed .pl-col-head { border-bottom: none; padding: 0.6rem 0.3rem; }
.pl-col.collapsed .pl-col-title { flex-direction: column; gap: 0.5rem; }
.pl-col.collapsed .pl-col-title h2 { writing-mode: vertical-rl; }
.pl-col.collapsed .pl-collapse { margin: 0; }

/* ---------- a card ---------- */
.pl-card { position: relative; padding: 0.6rem 0.7rem 0.65rem; border-radius: var(--radius-sm);
           background: rgba(5, 10, 28, 0.45); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.15rem; }
.pl-card:hover { border-color: var(--border-strong); }
.pl-card.due-overdue { box-shadow: inset 3px 0 0 var(--red); }
.pl-card.due-today { box-shadow: inset 3px 0 0 var(--amber); }
.pl-name { padding: 0; border: none; background: none; color: var(--text); font: inherit; font-weight: 700; font-size: 0.88rem;
           text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.pl-name:hover { color: var(--accent-bright); text-decoration: underline; }
.pl-sub { font-size: 0.74rem; color: var(--muted); }
.pl-value { margin-top: 0.15rem; font-size: 0.84rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pl-meta { font-size: 0.74rem; color: var(--muted); }
.pl-lost-why { font-size: 0.76rem; color: var(--red); }
.pl-move-label { margin-top: 0.35rem; }
.pl-move { width: 100%; padding: 0.3rem 0.5rem; font-size: 0.78rem; cursor: pointer; }
.pl-move option { background: var(--panel-solid); }

/* "Send proposal – Thu 16 Oct": amber when due today, red when overdue */
.dl-next { display: block; font-size: 0.78rem; color: var(--text-soft); }
.dl-next b { font-weight: 700; }
.dl-next.due-today { color: var(--amber); }
.dl-next.due-overdue { color: var(--red); }

.pl-empty { max-width: 640px; }
.pl-empty .btn { margin-top: 0.6rem; }

/* ---------- phones: the stages become tabs, one list at a time ---------- */
@media (max-width: 860px) {
  .pl-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .pl-summary .stat { padding: 0.8rem 0.85rem; }
  .pl-summary .stat-value { font-size: 1.35rem; }
  .pl-summary .pl-money { font-size: 1rem; }
  .pl-tabs { display: flex; margin-bottom: 0.7rem; }
  .pl-tabs .chip { flex: 1 1 auto; }
  .pl-board { display: block; overflow: visible; }
  .pl-col, .pl-col.collapsed { display: none; }
  .pl-col.is-tab { display: flex; }
  .pl-col.is-tab .pl-cards, .pl-col.is-tab .pl-col-total { display: flex; }
  .pl-col.is-tab .pl-col-total { display: block; }
  .pl-col.is-tab .pl-col-title { flex-direction: row; }
  .pl-col.is-tab .pl-col-title h2 { writing-mode: horizontal-tb; }
  .pl-collapse { display: none; }
}

/* =====================================================================
   The Deal section on a lead's panel (app/static/js/lead-deal.js)
   ===================================================================== */
/* opened from the Pipeline: the section lands below the panel's sticky header */
.drawer-body section[data-section="deal"] { scroll-margin-top: 9rem; }
.dl-card { padding: 0.75rem 0.85rem; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border); }
.dl-card.stage-won { border-color: rgba(47, 214, 123, 0.4); }
.dl-card.stage-lost { border-color: rgba(255, 95, 120, 0.35); }
.dl-top { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.dl-money { margin-top: 0.5rem; }
.dl-money b { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; }
.dl-money small { display: block; color: var(--muted); font-size: 0.76rem; }
.dl-card p { margin: 0.45rem 0 0; font-size: 0.84rem; }
.dl-lost { color: var(--red); }
.dl-notes { color: var(--text-soft); white-space: pre-wrap; }
.dl-hint { color: var(--muted); font-size: 0.78rem !important; }
.dl-stages { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.7rem 0 0.2rem; }
.dl-stage-btn { padding: 0.3rem 0.65rem; font-size: 0.76rem; }
.dl-stage-btn.on { box-shadow: inset 0 0 0 2px currentColor; }
.dl-stage-btn:disabled { cursor: default; }
.dl-stage-btn:disabled:not(.on) { opacity: 0.35; }
.dl-edit, .dl-history { margin-top: 0.6rem; }
.dl-edit summary, .dl-history summary { cursor: pointer; font-size: 0.82rem; font-weight: 600; color: var(--accent-bright); }
.dl-form { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.6rem; }
.dl-row { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.dl-row .dl-field { flex: 1 1 8rem; }
.dl-row .dl-grow { flex: 2 1 12rem; }
.dl-field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.dl-field small { font-weight: 400; color: var(--muted); }
.dl-field > span { display: block; }
.dl-field input, .dl-field textarea { width: 100%; padding: 0.45rem 0.6rem; font-size: 0.86rem; }
.dl-field input[type="date"] { color-scheme: dark; }
.dl-field textarea { resize: vertical; }
.dl-quote-btn { align-self: flex-start; white-space: normal; text-align: left; }
.dl-form-foot { display: flex; justify-content: flex-end; }
.dl-history .history { margin-top: 0.3rem; }
.dl-history li.dl-undone .pill { opacity: 0.6; }
.dl-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.75rem; }
.dl-foot .dl-delete { display: inline; width: auto; margin-left: auto; font-size: 0.76rem; }
.dl-add { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.dl-add-at { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 500; color: var(--muted); }
.dl-add-at select { padding: 0.3rem 0.5rem; font-size: 0.8rem; }

/* ---------- "Why was it lost?" ---------- */
.dl-dialog { width: min(420px, calc(100vw - 2rem)); padding: 1.2rem 1.3rem; border-radius: var(--radius);
             border: 1px solid var(--border-strong); background: var(--panel-solid); color: var(--text); box-shadow: var(--shadow); }
.dl-dialog::backdrop { background: rgba(2, 6, 18, 0.6); backdrop-filter: blur(2px); }
.dl-dialog h2 { margin: 0 0 0.2rem; font-size: 1.1rem; }
.dl-lost-form { display: flex; flex-direction: column; gap: 0.7rem; }
.dl-lost-form > p { margin: 0; }
.dl-reasons { display: grid; gap: 0.25rem; }
.dl-reason { display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.55rem; border-radius: var(--radius-sm);
             border: 1px solid var(--border); font-weight: 500; color: var(--text); cursor: pointer; }
.dl-reason:hover { border-color: var(--border-strong); }
.dl-reason:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.dl-reason input { accent-color: var(--red); margin: 0; }
.dl-dialog-foot { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ---------- Commission on a client's deal (app/static/js/commission.js) ---------- */
.lead-commission:empty { display: none; }
.cm { margin-top: 0.75rem; padding: 0.7rem 0.85rem; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.cm-title { margin: 0 0 0.35rem; font-size: 0.86rem; }
.cm-totals li { padding: 0.2rem 0; font-size: 0.82rem; }
.cm-owed { color: var(--amber); }
.cm-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.cm-entry { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.45rem 0.55rem;
            border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border); }
.cm-entry.paid { opacity: 0.75; }
.cm-entry-main { min-width: 0; font-size: 0.84rem; }
.cm-entry-main small { display: block; color: var(--muted); font-size: 0.76rem; overflow-wrap: anywhere; }
.cm-amount { font-variant-numeric: tabular-nums; font-weight: 600; margin-left: 0.3rem; }
.cm-entry-acts { display: flex; align-items: center; gap: 0.45rem; flex-shrink: 0; }
.cm-entry-acts .cm-del { display: inline; width: auto; font-size: 0.74rem; }
.cm .dl-field select { width: 100%; padding: 0.45rem 0.6rem; font-size: 0.86rem; }
.cm .dl-field input[type="month"] { color-scheme: dark; }
.cm-foot { align-items: center; justify-content: space-between; gap: 0.5rem; }
.cm-entry-acts .pill-btn { padding: 0.25rem 0.6rem; font-size: 0.74rem; border-width: 1px; border-style: solid; }
