/* Этап С2 — анализ сделки и ТКП: дополнения к style.css (те же цвета и размеры, docs/дизайн-сервиса.md) */
td .grp-sel { width: 150px !important; min-height: 34px !important; padding: 4px 6px !important; font-size: 13px; }
.deal-positions { min-width: 0; table-layout: fixed; }
@media (max-width: 800px) { .deal-positions { min-width: 0; table-layout: auto; } .deal-positions colgroup { display: none; } }
.ready { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 16px;
         background: var(--green-bg); border: 1px solid #BFE3CC; color: var(--green); border-radius: var(--r); padding: 12px 16px; }
.deal-steps .arr { color: var(--muted); align-self: center; }
.step.off { opacity: .5; }
.kp-card { display: block; color: var(--text); border-color: #C7D5F7; background: var(--blue-bg); }
.kp-card:hover { text-decoration: none; color: var(--text); border-color: var(--blue); }

.kpi.dec { border-width: 1px; }
.kpi.dec.ok { background: var(--green-bg); border-color: #BFE3CC; color: var(--green); }
.kpi.dec.head { background: var(--yellow-bg); border-color: #F1D9A6; color: var(--yellow); }
.kpi.dec.loss, .kpi.dec.none { background: var(--red-bg); border-color: #F4C7C2; color: var(--red); }
.kpi.dec .v { font-size: 18px; }
.kpi.dec.owner { background: var(--red-bg); border-color: #F4C7C2; color: var(--red); }
/* С2а, решение 99: ROIC — первым и крупнее остальных итогов */
.kpis-roic { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis-roic { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }
.kpi.roic { border-width: 2px; border-color: var(--blue); }
.kpi.roic .v { font-size: 24px; }
.kpi.roic .v .u { font-size: 16px; font-weight: 600; color: var(--muted); }
.kpi.roic.good .v { color: var(--green); } .kpi.roic.bad { border-color: var(--red); background: var(--red-bg); } .kpi.roic.bad .v { color: var(--red); }
.v.good { color: var(--green); } .v.bad { color: var(--red); }

.src-line { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cond-line { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
/* С2г: условия — по 3 колонки на компьютере, по 1 на телефоне; у каждого поля своя подпись, поле — на всю ширину колонки */
.cond-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; margin-top: 12px; align-items: end; }
.cond-grid > div { min-width: 0; }
.cond-grid input, .cond-grid select { width: 100%; }
.cond-grid [hidden] { display: none; }
.cond-grid .pay-line { grid-column: 1 / -1; background: var(--blue-bg); border-radius: 10px; padding: 10px 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.cond-grid .pay-line .f { margin: 0; }
.city-options { position: absolute; z-index: 10; background: white; border: 1px solid var(--line); box-shadow: 0 4px 10px #0002; }
.city-options button { display: block; width: 100%; border: 0; background: white; padding: 8px 12px; text-align: left; cursor: pointer; }
.city-options button:hover { background: var(--blue-bg); }
input.ro { background: var(--gray-bg); color: var(--muted); }
@media (max-width: 860px) { .cond-grid { grid-template-columns: 1fr; } }
.new-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; align-items: stretch; }
.new-card { display: flex; flex-direction: column; }
.new-cards .new-card { margin-top: 0; }
.new-card h2 { min-height: 28px; margin: 0; }
.new-card > p { min-height: 62px; }
.new-card > button:last-child { margin-top: auto; }
.new-card .job-list { height: 320px; }
.new-card.on { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-bg); }
.new-card .drop { padding: 20px 12px; }
.grid-2f { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-2f input { width: 100%; min-height: 44px; }
.job-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; }
.job-list label { padding: 8px 0; border-bottom: 1px solid var(--line); }
.job-list label[hidden] { display: none; }
@media (max-width: 1100px) { .new-cards { grid-template-columns: 1fr; } }
.tkp-bar { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-top: 16px; background: #fff;
           border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; }
.approve-box { margin-top: 16px; border: 2px solid var(--blue); background: var(--blue-bg); }
.approve-box .f { display: block; color: var(--muted); font-size: 13px; }
.approve-box b.big { font-size: 26px; display: block; line-height: 1.2; }
.btn.big-btn { min-height: 48px; padding: 12px 22px; font-size: 16px; }
.wait-box { margin: 12px 0 16px; border: 2px solid var(--yellow); }
.tkp-name { margin: 6px 0 0; }
.tkp-name input { width: 100%; min-height: 34px; padding: 4px 8px; font-size: 13px; }
.noweight { margin-top: 6px; }
.tkp-head { display: flex; gap: 20px; align-items: center; justify-content: space-between; border-bottom: 2px solid #1F3864; padding-bottom: 8px; }
.tkp-logo { font-size: 22px; letter-spacing: .08em; color: #1F3864; }
.tkp-head .req { text-align: center; font-size: 11px; }
.tkp-t thead th { background: #1F3864; color: #fff; font-size: 12px; }
.tkp-terms { padding-left: 18px; margin: 6px 0; }
.method .row { margin-top: 10px; }
.inline-num { width: 110px !important; min-height: 38px !important; padding: 6px 8px !important; text-align: right; }
.inline-num.wide { width: 150px !important; }
.lock { font-size: 15px; }
td.locked { background: #FFF8E6; }
.grp { display: inline-block; min-width: 26px; text-align: center; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.g-A { background: var(--green-bg); color: var(--green); } .g-B { background: var(--blue-bg); color: var(--blue); }
.g-C { background: var(--yellow-bg); color: var(--yellow); } .g-none { background: var(--red-bg); color: var(--red); }
.b-warn { background: var(--yellow-bg); color: var(--yellow); } .b-bad { background: var(--red-bg); color: var(--red); }
.b-gray { background: var(--gray-bg); color: var(--gray); }
tr.out td { color: var(--muted); background: #FAFBFC; }
tr.anchor { scroll-margin-top: calc(var(--top-h, 61px) + 12px); }
.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--gray-bg); margin: 8px 0 12px; }
.bar span { display: block; height: 100%; }
.legend { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.legend li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.legend li.sum { font-weight: 700; border-bottom: 2px solid var(--line); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-top: 16px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
.tkp-doc { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 28px; position: relative; }
.tkp-doc .draft-mark { display: block; width: fit-content; margin: 0 0 12px auto; color: var(--red); border: 2px solid var(--red); border-radius: 8px; padding: 4px 10px; font-weight: 700; }
.tkp-doc .req { color: var(--muted); font-size: 13px; }
.hist li { padding: 8px 0; border-bottom: 1px solid var(--line); list-style: none; }
.hist { padding: 0; margin: 0; }
.changed { background: #FFF8E6 !important; border-color: #E8B23A !important; }
.was { display: block; font-size: 12px; color: var(--yellow); margin-top: 2px; }
.savebar { position: sticky; bottom: 0; background: #fff; border-top: 2px solid var(--blue); padding: 14px 16px; margin: 16px -24px -24px;
           display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; box-shadow: 0 -4px 16px rgba(0,0,0,.08); z-index: 10; }
.savebar[hidden] { display: none; }
.consts-tbl input[type=text] { min-height: 38px; padding: 6px 8px; }
.kp-st-ok { color: var(--green); font-weight: 600; } .kp-st-check { color: var(--yellow); font-weight: 600; } .kp-st-none { color: var(--red); font-weight: 600; }
/* С2е: обновление не участвует в автоматической привязке прокрутки браузера. */
main { overflow-anchor: none; }
.deal-layout { display:flex; flex-direction:column; }
.deal-layout > * { min-width:0; }
.analytics-panel { order:0; margin:16px 0; }
.analytics-panel details { background:#fff; border:1px solid var(--line,#ddd); border-radius:10px; margin-bottom:8px; }
.analytics-panel summary { padding:14px; font-weight:600; cursor:pointer; }
.analytics-body { padding:0 14px 14px; font-size:13px; overflow-wrap:normal; }
.analytics-body .legend li { flex-wrap:wrap; gap:4px; }
.analytics-body h2 { font-size:16px; }
.position-card { padding:12px; background:#f4f7fc; white-space:normal; }
.position-card .kv { max-width:680px; }
.close-position { float:right; }
.position-detail[hidden] { display:none !important; }
.field-error { color:#b42318; font-size:12px; white-space:normal; }
[aria-invalid=true] { border:2px solid #b42318 !important; }
/* С3а: шапка общая, аналитика начинается вместе с ТКП. */
.deal-layout { display: block; }
.deal-columns { display: grid; grid-template-columns: minmax(0, 1fr) var(--sidebar); gap: var(--space-4); align-items: start; }
.deal-main { min-width: 0; }
.deal-columns > .analytics-panel { position: sticky; top: calc(var(--top-h, 56px) + var(--space-4)); max-height: calc(100vh - var(--top-h, 56px) - var(--space-6)); overflow: auto; margin: var(--space-4) 0 0; }
.deal-main .deal-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: stretch; }
.deal-kpis .kpi { min-width: 0; padding: var(--space-3); }
.deal-kpis .v { font-size: var(--font-card); white-space: nowrap; }
.deal-kpis .dec .v { white-space: normal; }
.deal-columns .tbl-wrap { max-width: 100%; }
.deal-main .cond-grid { align-items: stretch; }
.deal-main .cond-grid > div:not(.pay-line):not(.create-deal-row) { display: flex; flex-direction: column; justify-content: end; align-items: start; }
.deal-main .cond-grid input, .deal-main .cond-grid select { max-width: var(--field-text); }
.deal-main .cond-grid input[inputmode=numeric], .deal-main .cond-grid input[inputmode=decimal], .deal-main .cond-grid #sp, .deal-main .cond-grid #pd, .deal-main .cond-grid #avgMarkup { max-width: var(--field-short); }
.deal-main .cond-grid #agent, .deal-main .cond-grid #nmc, .deal-main .cond-grid #drfm { max-width: var(--field-money); }
.deal-main .cond-grid label.f { flex: 1; display: block; }
.deal-main .cond-grid .create-deal-row { grid-column: 1 / -1; display: flex; gap: var(--space-2); align-items: center; }
.deal-main .cond-grid [hidden] { display: none !important; }
.analytics-body { overflow-wrap: normal; word-break: normal; }
.analytics-body .legend li { flex-direction: column; align-items: start; }
.analytics-body .legend .num { white-space: nowrap; }
.job-changed form { margin-top: var(--space-2); }
@media(max-width:1279px) {
  .deal-columns { grid-template-columns: minmax(0, 1fr); }
  .deal-columns > .analytics-panel { position: static; max-height: none; }
}
@media(max-width:700px) {
  .deal-main .deal-kpis { grid-template-columns: repeat(5, var(--field-text)); overflow-x: auto; }
}
.deal-save-state { position: fixed; bottom: 12px; right: 16px; z-index: 30; padding: 6px 10px; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px #0002; font-size: 13px; }
.deal-save-state:empty { display: none; }
@media (min-width: 801px) {
  table.deal-positions th, table.tkp-t th { white-space: normal; overflow-wrap: normal; font-size: 11px; padding: 8px 4px; }
  table.deal-positions td, table.tkp-t td { padding: 8px 4px; font-size: 12px; }
  .deal-positions .note, .deal-positions .badge { font-size: 11px; white-space: normal; }
  .deal-positions td:nth-child(2) { overflow-wrap: normal; }
  .deal-positions td .grp-sel, .deal-positions .inline-num { width: 100% !important; min-width: 0; padding: 5px 3px !important; font-size: 12px; }
  .deal-positions .lock { padding: 4px; }
  table.tkp-t { table-layout: fixed; }
  .tkp-t td:nth-child(2), .tkp-t td:last-child { overflow-wrap: normal; }
  .tkp-t th:nth-child(1) { width: 3%; } .tkp-t th:nth-child(2) { width: 27%; }
  .tkp-t th:nth-child(3) { width: 4%; } .tkp-t th:nth-child(4) { width: 6%; }
  .tkp-t th:nth-child(5), .tkp-t th:nth-child(6), .tkp-t th:nth-child(7), .tkp-t th:nth-child(8) { width: 12%; }
  .tkp-t th:nth-child(9) { width: 12%; }
}
@media (max-width: 640px) {
  .inline-num { width: 100% !important; }
  .savebar { margin: 16px -16px -16px; }
  .tkp-doc { padding: 16px; }
}

.price-mode-row { display: flex; align-items: center; gap: var(--space-2); flex-basis: 100%; flex-wrap: wrap; }
@media(min-width:801px) { .deal-positions { min-width: calc(var(--sidebar) * 4); } }
