/* Страница сделки (deals/detail.html, deals/form.html). Цвета только через var(--токен) из :root в app.css. */

.deal-page { display: block; }
.deal-h {
  display: grid; gap: 12px; padding-block: 16px 14px; padding-left: 20px; padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.deal-h .crumbs { color: var(--ink-3); font-size: 12.5px; }
.deal-h .crumbs a { color: inherit; }
.deal-h .line1 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.deal-h h2 { font: 600 22px/1.2 var(--body); margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.deal-h .money { font: 700 18px var(--body); }
.deal-h .acts { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.deal-h .next-form { margin: 0; }

/* «Отказ»: выпадающая форма с причиной */
.lost-box { position: relative; }
.lost-box summary { list-style: none; }
.lost-box summary::-webkit-details-marker { display: none; }
.lost-form {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 280px; max-width: calc(100vw - 32px);
  display: grid; gap: 8px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop);
}
.lost-form label { margin: 0; }

/* полоса этапов: стрелки */
.stages { display: flex; gap: 3px; overflow-x: auto; }
.stage-form { display: flex; flex: 1 0 auto; margin: 0; }
.stages .stage {
  flex: 1; min-width: 92px; border: 0; margin: 0; padding: 7px 14px 7px 18px; text-align: left; white-space: nowrap;
  background: var(--paper-2); color: var(--ink-2); font-size: 12.5px; font-weight: 500;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%, 9px 50%);
}
.stages > .stage:first-child, .stages > .stage-form:first-child .stage {
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%); border-radius: 6px 0 0 6px;
}
.stages .stage.done { background: var(--green); color: var(--on-accent); }
.stages .stage.cur { background: var(--accent); color: var(--on-accent); }
.stages button.stage:hover { filter: brightness(.96); }
.stages .stage small { display: block; font-size: 10.5px; opacity: .85; font-weight: 400; }

/* тело: слева панели, справа лента */
.deal-b { padding-block: 16px 32px; padding-left: 20px; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.deal-b .side { display: grid; gap: 12px; min-width: 0; }
.deal-b .side .panel + .panel { margin-top: 0; }
.person { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.person b { display: block; }
.person small { display: block; color: var(--ink-3); }
.feed { display: grid; gap: 12px; min-width: 0; }

/* форма с вкладками */
.composer .tabs { margin: -4px -4px 12px; }
.composer .tab-panel[hidden] { display: none; }
.composer .tab-panel + .tab-panel { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.composer [role="tablist"]:not([hidden]) ~ .tab-panel { margin-top: 0; padding-top: 0; border-top: 0; }
.composer textarea { background: var(--paper); }
.composer .opts { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 10px; align-items: flex-end; }
.composer .opts > div { min-width: 0; }
.composer .opts .grow { flex: 1 1 200px; }
.composer .opts .btn-primary { margin-left: auto; }
.composer .opts select, .composer .opts input { min-height: 38px; }

.sec-t { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin: 6px 0 -2px; }

/* лента: «Запланировано» и «История» */
.ev { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; }
.ev .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); color: var(--ink-2); }
.ev .dot svg { width: 16px; height: 16px; }
.ev .dot.task { background: var(--accent-soft); color: var(--accent); }
.ev .dot.stage { background: var(--green-soft); color: var(--green); }
.ev .dot.done { background: var(--ok-soft); color: var(--ok); }
.ev .body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-width: 0; }
.ev .body.is-late { border-color: var(--bad); }
.ev .meta { color: var(--ink-3); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 3px; }
.ev .body p { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.ev .next { margin-top: 8px; font-size: 13px; background: var(--paper); border-radius: 6px; padding: 6px 8px; color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 10px; margin: 0; }
.check > span { min-width: 0; overflow-wrap: anywhere; }
.due-late { color: var(--bad); font-weight: 600; }
.tick {
  flex: none; width: 24px; height: 24px; min-height: 24px; padding: 0; border-radius: 6px;
  background: var(--surface); border: 2px solid var(--line-strong); color: var(--green); cursor: pointer;
}
.tick:hover { background: var(--green-soft); border-color: var(--green); }
.planned.is-late .tick { border-color: var(--bad); }

/* форма сделки (deals/form.html) */
.deal-form { max-width: 640px; }
.deal-form .form-actions { margin-top: 8px; }

@media (max-width: 760px) {
  .deal-h, .deal-b { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
  .deal-h .acts { margin-left: 0; width: 100%; }
  .deal-h .acts > .btn, .deal-h .acts .next-form, .deal-h .acts .lost-box { flex: 1; }
  .deal-h .acts .next-form .btn, .deal-h .acts .lost-box summary { width: 100%; }
  .lost-form { left: 0; right: auto; }
  .deal-b .feed { order: -1; }
  .stages .stage { min-width: 0; }
  .stages > .stage { flex: none; } /* текущий этап не сжимается на телефоне */
  .stage-form { flex: none; }
  .composer .opts .btn-primary { margin-left: 0; width: 100%; }
}
