/* Dashboard: "Sales pipeline: weekly trend" chart + records drawer.
   The four measure colors are used for these four measures only. */
.pipe-card, .pipe-backdrop {
  --pipe-new: #2F6FDB; --pipe-waiting: #E3A008; --pipe-completed: #12A594; --pipe-notsecured: #D9453D;
  --pipe-navy: #14213D; --pipe-ink: #0F172A; --pipe-muted: #64748B; --pipe-grid: #E8EDF3;
}
.pipe-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 24px 22px; box-shadow: var(--shadow-sm); margin-bottom: 24px; min-width: 0;
}
.pipe-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.pipe-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--pipe-ink); letter-spacing: -.01em; }
.pipe-sub { margin: 4px 0 0; font-size: 13px; color: var(--pipe-muted); }
.pipe-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pipe-field { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #334155; }
.pipe-field select { min-width: 130px; }
.pipe-seg { display: inline-flex; border: 1px solid #CBD5E1; border-radius: 10px; overflow: hidden; background: #fff; }
.pipe-seg button { border: 0; background: #fff; color: #334155; font: inherit; font-size: 13px; font-weight: 600; padding: 7px 16px; cursor: pointer; min-height: 36px; }
.pipe-seg button[aria-pressed="true"] { background: var(--pipe-navy); color: #fff; }
.pipe-seg button:focus-visible, .pipe-leg:focus-visible, .pipe-link:focus-visible, .pipe-num:focus-visible,
.pipe-plot:focus-visible, .pipe-d-btn:focus-visible, .pipe-d-th:focus-visible { outline: 3px solid #1D4ED8; outline-offset: 2px; }

.pipe-legendrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 16px 0 6px; }
.pipe-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.pipe-leg { display: inline-flex; align-items: center; gap: 8px; text-align: left; border: 0; background: none; font: inherit; font-size: 13px; color: var(--pipe-ink); cursor: pointer; padding: 6px 4px; border-radius: 8px; }
.pipe-leg:hover { background: #F1F5F9; }
.pipe-leg[aria-pressed="false"] { color: #94A3B8; text-decoration: line-through; }
.pipe-sw { width: 12px; height: 12px; border-radius: 2px; flex: 0 0 12px; background: var(--c); }
.pipe-leg[aria-pressed="false"] .pipe-sw { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }
.pipe-link { border: 0; background: none; color: #1D4ED8; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: underline; padding: 6px 4px; }

.pipe-stage { position: relative; min-width: 0; }
.pipe-plot { position: relative; border-radius: 10px; min-width: 0; }
.pipe-svg { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: crosshair; overflow: visible; }
.pipe-svg .grid { stroke: var(--pipe-grid); stroke-width: 1; }
.pipe-svg .axis-label { fill: var(--pipe-muted); font-size: 11px; }
.pipe-svg .x-label { fill: #334155; font-size: 11px; }
.pipe-svg .x-live { fill: #1D4ED8; font-size: 11px; font-weight: 700; }
.pipe-svg .band { fill: #EEF1F5; }
.pipe-svg .guide { stroke: #94A3B8; stroke-width: 1; stroke-dasharray: 2 3; }
.pipe-svg .sel { fill: rgba(47,111,219,.10); stroke: #2F6FDB; stroke-width: 1.5; stroke-dasharray: 5 4; pointer-events: none; }
.pipe-svg .ser { transition: opacity .12s; }
.pipe-svg .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pipe-svg .line.live { stroke-dasharray: 5 4; }
.pipe-svg .mk { stroke: #fff; stroke-width: 2; paint-order: stroke; }
.pipe-svg .mk.live { fill: #fff !important; stroke-width: 2; }
.pipe-svg .bar.live { opacity: .45; }
.pipe-svg .hit { fill: transparent; stroke: none; }
.pipe-svg .clickable { cursor: pointer; }
.pipe-svg .zero { cursor: default; }
.pipe-svg.has-active .wk:not(.active) .ser { opacity: .45; }
.pipe-svg.has-active .wk:not(.active) .bar.live { opacity: .25; }
.pipe-svg[data-hl] .ser:not(.hl) { opacity: .15 !important; }
.pipe-svg .mk:hover, .pipe-svg .bar:hover { filter: brightness(1.08); }

.pipe-tip { position: absolute; z-index: 5; width: 270px; max-width: calc(100% - 8px); background: #fff; border: 1px solid #D5DCE6; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15,23,42,.16); padding: 12px 14px 8px; }
.pipe-tip[hidden] { display: none; }
.pipe-tip h3 { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--pipe-ink); }
.pipe-tip ul { list-style: none; margin: 0; padding: 0; }
.pipe-tip li { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 13px; color: #334155; border-top: 1px solid #F1F5F9; }
.pipe-tip li:first-child { border-top: 0; }
.pipe-tip .pipe-key { width: 16px; height: 4px; border-radius: 2px; background: var(--c); flex: 0 0 16px; }
.pipe-tip .pipe-name { flex: 1; }
.pipe-num { border: 0; background: none; font: inherit; font-size: 18px; font-weight: 800; color: var(--pipe-ink); padding: 4px 8px; margin: -4px -8px -4px 0; border-radius: 8px; min-width: 36px; min-height: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.pipe-num.clickable { cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.pipe-num.clickable:hover { text-decoration-color: currentColor; background: #F1F5F9; }
.pipe-num.zero { cursor: default; color: #64748B; }

.pipe-summary { margin-top: 14px; border: 1px solid #E2E8F0; border-radius: 12px; padding: 14px 16px; background: #FAFBFD; }
.pipe-sum-empty { margin: 0; color: var(--pipe-muted); font-size: 13px; }
.pipe-sum-line { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--pipe-ink); }
.pipe-sum-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.pipe-sum-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pipe-sum-label { font-size: 11px; color: var(--pipe-muted); line-height: 1.25; }
.pipe-sum-num { align-self: flex-start; margin: 0; padding: 2px 6px 2px 0; font-size: 28px; font-weight: 800; line-height: 1.1; min-height: 40px; color: var(--pipe-ink); background: none; border: 0; font-family: inherit; font-variant-numeric: tabular-nums; border-radius: 8px; }
.pipe-sum-num.clickable { cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; }
.pipe-sum-num.clickable:hover { text-decoration-color: currentColor; }
.pipe-sum-num.zero { cursor: default; }
.pipe-sum-num.c-new { color: var(--pipe-new); }
.pipe-sum-num.c-completed { color: #0B7F72; }
.pipe-sum-num.c-notsecured { color: #C0352E; }

.pipe-tablewrap { overflow-x: auto; max-width: 100%; }
.pipe-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pipe-table caption { text-align: left; font-size: 12px; color: var(--pipe-muted); padding: 4px 0 8px; }
.pipe-table th, .pipe-table td { padding: 8px 10px; border-bottom: 1px solid #EEF2F7; text-align: right; }
.pipe-table th:first-child, .pipe-table td:first-child { text-align: left; }
.pipe-table thead th { font-size: 12px; font-weight: 700; color: #334155; }
.pipe-table tr.is-selected td, .pipe-table tr.is-selected th { background: rgba(47,111,219,.08); }
.pipe-table .pipe-num { margin: 0; font-size: 15px; }
.pipe-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pipe-empty { padding: 40px 0; text-align: center; color: var(--pipe-muted); font-size: 14px; }

/* ── drawer ── */
body.pipe-lock { overflow: hidden; }
.pipe-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 900; display: flex; justify-content: flex-end; }
.pipe-drawer { background: #fff; width: min(1220px, 96vw); height: 100%; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(15,23,42,.25); }
.pipe-d-head { padding: 18px 22px 12px; border-bottom: 1px solid #E2E8F0; display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.pipe-d-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--pipe-ink); line-height: 1.35; }
.pipe-d-title:focus { outline: none; }
.pipe-badge { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; color: #7A4B00; background: #FFF3D6; border: 1px solid #F3D18A; border-radius: 999px; padding: 3px 10px; }
.pipe-asof { margin: 6px 0 0; font-size: 12px; color: var(--pipe-muted); }
.pipe-foot { margin: 4px 0 6px; font-size: 11.5px; color: var(--pipe-muted); }
.pipe-warn { margin: 12px 0 0; padding: 10px 14px; border: 1px solid #F3C97A; background: #FFF6E0; color: #6B4A00; border-radius: 10px; font-size: 13px; font-weight: 600; }
.pipe-warn[hidden] { display: none; }
.pipe-sum-note { margin: 12px 0 0; font-size: 11.5px; color: var(--pipe-muted); }
.pipe-math { margin: 8px 0 0; font-size: 14px; font-weight: 600; color: var(--pipe-ink); }
.pipe-d-btn { border: 1px solid #CBD5E1; background: #fff; color: #0F172A; font: inherit; font-size: 13px; font-weight: 600; border-radius: 10px; padding: 8px 14px; cursor: pointer; min-height: 38px; white-space: nowrap; }
.pipe-d-btn:hover { background: #F1F5F9; }
.pipe-d-btn[disabled] { opacity: .5; cursor: default; }
.pipe-d-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 22px; border-bottom: 1px solid #EEF2F7; }
.pipe-d-bar input[type="search"] { flex: 1 1 220px; min-width: 0; }
.pipe-d-sortsel { display: none; }
.pipe-d-body { flex: 1; overflow: auto; padding: 0 22px 12px; }
.pipe-d-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pipe-d-table th { position: sticky; top: 0; background: #F8FAFC; text-align: left; padding: 0; border-bottom: 1px solid #E2E8F0; z-index: 1; }
.pipe-d-th { width: 100%; text-align: left; border: 0; background: none; font: inherit; font-size: 12px; font-weight: 700; color: #334155; padding: 10px 10px; cursor: pointer; white-space: nowrap; }
.pipe-d-table td { padding: 8px 8px; border-bottom: 1px solid #F1F5F9; vertical-align: top; }
.pipe-d-table tr.pipe-grouprow td { background: #F1F5F9; font-weight: 700; color: var(--pipe-ink); }
.pipe-d-table a { color: #1D4ED8; font-weight: 600; }
.pipe-d-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 22px; border-top: 1px solid #E2E8F0; font-size: 13px; color: #334155; flex-wrap: wrap; }
.pipe-d-foot .pipe-pager { display: flex; gap: 8px; align-items: center; }

@media (max-width: 900px) {
  .pipe-sum-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .pipe-card { padding: 16px 14px 18px; }
  .pipe-title { font-size: 16px; }
  .pipe-controls { width: 100%; justify-content: space-between; }
  .pipe-field select { min-width: 0; flex: 1; }
  .pipe-field { flex: 1 1 100%; }
  .pipe-tip { width: 230px; }
  .pipe-sum-num { font-size: 24px; }
  .pipe-drawer { width: 100vw; height: 100dvh; box-shadow: none; }
  .pipe-d-head, .pipe-d-bar, .pipe-d-foot { padding-left: 14px; padding-right: 14px; }
  .pipe-d-body { padding: 0 14px 10px; }
  .pipe-d-title { font-size: 16px; }
  .pipe-d-sortsel { display: inline-block; }
  /* rows become stacked cards: no sideways scrolling on phones */
  .pipe-d-table, .pipe-d-table tbody, .pipe-d-table tr, .pipe-d-table td { display: block; width: 100%; }
  .pipe-d-table thead { display: none; }
  .pipe-d-table tr { border: 1px solid #E2E8F0; border-radius: 12px; margin: 10px 0; padding: 6px 4px; }
  .pipe-d-table tr.pipe-grouprow { border: 0; margin: 14px 0 4px; padding: 0; }
  .pipe-d-table td { border: 0; padding: 4px 10px; display: flex; gap: 10px; justify-content: space-between; text-align: right; }
  .pipe-d-table td::before { content: attr(data-label); color: var(--pipe-muted); font-weight: 500; font-size: 12px; text-align: left; flex: 0 0 38%; }
  .pipe-d-table td.pipe-name-cell { font-size: 15px; }
  .pipe-legend { gap: 0 14px; }
  .pipe-leg { font-size: 12px; padding: 4px 2px; }
}
@media (prefers-reduced-motion: reduce) { .pipe-svg .ser { transition: none; } }
@media print { .pipe-tip, .pipe-controls { display: none; } }
