/* NIPI-130: форма договора (поиск заказчика, этапы, оплата) и диаграмма Ганта */
.cf-form { display: grid; gap: 16px; }
.cf-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 0; }
.cf-section legend { padding: 0 6px; font-weight: 700; }
.cf-suggest { position: fixed; z-index: 2000; max-height: 280px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(16, 24, 40, .14); }
.cf-option { display: block; width: 100%; padding: 8px 12px; text-align: left; background: none; border: 0; font: inherit; cursor: pointer; }
.cf-option small { display: block; color: var(--muted); font-size: 12px; }
.cf-option:hover, .cf-option.active { background: var(--primary-soft); }
.cf-extra { color: var(--primary); font-weight: 600; border-top: 1px solid var(--border); }
.cf-empty { padding: 10px 12px; color: var(--muted); }
input.cf-chosen { border-color: #86c39b; background: #f3fbf6; }
.cf-new { margin-top: 8px; padding: 12px; border: 1px dashed var(--border); border-radius: 8px; background: #fafbfd; }
.cf-amount { text-align: right; font-variant-numeric: tabular-nums; }
.cf-pct { width: 70px; text-align: right; }
.cf-toggle { display: flex !important; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; font-weight: 600; margin-bottom: 10px; text-align: left; }
.cf-toggle input { width: auto; margin: 0; flex: none; }
.cf-table { min-width: 860px; }
.cf-table td { vertical-align: top; padding: 6px; }
.cf-table input, .cf-table select { width: 100%; min-width: 0; }
.cf-table td:first-child { width: 32px; color: var(--muted); padding-top: 12px; }
.cf-staff { min-width: 220px; }
.cf-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.cf-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 9px; border-radius: 999px; background: var(--primary-soft); font-size: 12.5px; }
.cf-chip button { border: 0; background: none; cursor: pointer; font-size: 14px; line-height: 1; color: var(--muted); }
.cf-total { margin: 10px 0 0; font-weight: 600; }
.cf-total-ok { color: #15803d; }
.cf-total-warn { color: #b45309; }
.cf-total-bad { color: #b91c1c; }

.gantt { --gantt-label: 300px; position: relative; font-size: 13px; overflow-x: auto; }
.gantt-row { display: grid; grid-template-columns: var(--gantt-label) 1fr; min-width: 760px; border-bottom: 1px solid var(--border); }
.gantt-head { position: sticky; top: 0; background: var(--surface); z-index: 2; border-bottom: 2px solid var(--border); }
.gantt-label { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 0; min-width: 0; }
.gantt-name { min-width: 0; overflow: hidden; }
.gantt-name a, .gantt-name { white-space: nowrap; text-overflow: ellipsis; }
.gantt-name small { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-row-stage .gantt-label { padding-left: 22px; }
.gantt-row-stage { background: #fbfcfe; }
.gantt-toggle { width: 18px; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; }
.gantt-toggle-space { width: 18px; flex: none; }
.gantt-track { position: relative; min-height: 36px; background-image: linear-gradient(to right, transparent calc(100% - 1px), var(--border) 1px); }
.gantt-scale { min-height: 28px; background: none; }
.gantt-month { position: absolute; top: 0; bottom: 0; padding: 6px 4px; border-left: 1px solid var(--border); color: var(--muted); font-size: 11.5px; overflow: hidden; white-space: nowrap; }
.gantt-year { border-left: 2px solid #9aa6b8; color: var(--text); font-weight: 600; }
.gantt-bar { position: absolute; top: 9px; height: 18px; border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); }
.gantt-stage { top: 11px; height: 14px; border-radius: 4px; }
.gantt-progress { position: absolute; inset: 0 auto 0 0; background: rgba(0, 0, 0, .18); }
.gantt-bar-text { position: relative; display: block; padding: 0 6px; font-size: 11px; line-height: 18px; font-weight: 700; color: #fff; white-space: nowrap; text-align: center; text-shadow: 0 0 2px rgba(0, 0, 0, .45); }
.gantt-planned .gantt-bar-text { color: #1c2430; text-shadow: none; }
.gantt-done { background: #22a05a; }
.gantt-active { background: #2f6fd6; }
.gantt-planned { background: #a9b4c6; }
.gantt-overdue { background: #dc2626; }
.gantt-pay { position: absolute; top: 12px; width: 11px; height: 11px; margin-left: -5px; transform: rotate(45deg); background: #f59e0b; border: 1px solid #fff; z-index: 1; }
.gantt-paid { background: #22a05a; }
.gantt-pay-late { background: #dc2626; }
.gantt-body { position: relative; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed #dc2626; pointer-events: none; z-index: 1; }
.gantt-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-top: 10px; color: var(--muted); font-size: 12px; }
.gantt-key { display: inline-block; width: 14px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.gantt-key-pay { width: 9px; height: 9px; transform: rotate(45deg); background: #f59e0b; border-radius: 0; }
.gantt-key-today { width: 0; height: 12px; border-left: 2px dashed #dc2626; border-radius: 0; }
.dir-gantt .gantt { max-height: 520px; overflow-y: auto; }
@media (max-width: 760px) { .gantt { --gantt-label: 170px; } }

/* NIPI-132: номер этапа и подэтапы */
.cf-code { width: 64px !important; text-align: center; }
.cf-table td:first-child { width: 72px; padding-top: 6px; }
.cf-row-actions { white-space: nowrap; }
.cf-row-actions .btn + .btn { margin-left: 4px; }
tr.cf-substage td:nth-child(2) { padding-left: 24px; }

/* NIPI-134: недопустимый процент или сумма платежа */
.cf-table input.cf-invalid { border-color: #dc2626; background: #fff5f5; }
