/* OPS — operator views (queue, lead card, leads table, board, calls, phone, «Мои показатели»).
   Builds on app.css: tokens only (dark mode swaps them), phone-first, 44 px targets on touch. */

/* ───────────── shared ───────────── */
.ops-wrap { flex-wrap: wrap; }
.ops-warnmark { display: inline-flex; color: var(--warn); }
.ops-phone { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.ops-phone:hover { color: var(--brand-d); }
.ops-phone .ic { color: var(--muted); }
.ops-facts { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.ops-fact { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ops-fact .of-label { font-size: var(--fs-12); color: var(--muted); }
.ops-fact .of-value { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--ink); font-weight: 500; }
.ops-owner { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.ops-owner .ic { color: var(--faint); }
.ops-amount { align-items: flex-end; flex-wrap: wrap; }
.ops-amount > .field:first-child { flex: 1 1 160px; }
.ops-dup-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ops-dup { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink); }
.lt-filters .select, .board-tools .select, .calls-tools .select, .lt-dates .input { width: auto; max-width: 100%; }

/* qualification form */
.qf-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.qf-choice .qf-pick:first-child.is-on { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 45%, var(--bg)); color: var(--ok); }
.qf-choice .qf-pick:last-child.is-on { background: var(--panel-2); border-color: var(--faint); color: var(--ink); }
.qf-box { padding: 14px; border-radius: var(--r); background: var(--panel); }
.qf-box .chips-lg .chip { background: var(--bg); }

/* deal stepper */
.ops-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ops-steps button {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px 0 8px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-weight: 500; cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ops-steps button:hover:not(:disabled) { background: var(--panel); }
.ops-steps button:disabled { cursor: default; color: var(--ink); }
.ops-steps .st-dot { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--sc, var(--line-2)); color: var(--bg); flex: none; }
.ops-steps li.is-done .st-dot, .ops-steps li.is-current .st-dot { background: var(--sc, var(--brand)); }
.ops-steps li.is-current button { border-color: var(--sc, var(--brand)); background: color-mix(in srgb, var(--sc, var(--brand)) 12%, var(--bg)); }
.deal-close { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* post-call sheet */
.pc-call { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r); background: var(--panel); }
.pc-call .pc-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--bg); color: var(--muted); flex: none; }
.pc-call.tone-ok .pc-ic { color: var(--ok); }
.pc-call.tone-err .pc-ic { color: var(--err); }
.pc-call.tone-warn .pc-ic { color: var(--warn); }
.pc-call .pc-main { min-width: 0; }
.pc-result { display: grid; gap: 8px; }
.pc-line { font-size: var(--fs-13); color: var(--muted); }
.pc-extras { padding-top: 12px; border-top: 1px solid var(--line); }

/* ───────────── #/queue ───────────── */
/* one action per lead: the first lead of «Сейчас» is the big card, the rest are compact rows with a call button */
.q-today { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -6px 0 4px; color: var(--muted); font-size: var(--fs-13); }
.q-stat b { color: var(--ink); font-weight: 650; }
.q-attn { margin-bottom: 12px; }
.q-sections { margin-top: 18px; }
.q-sec { margin-top: 24px; }
.q-sec .section-head { margin-bottom: 6px; }
.q-sec .section-head h2 { font-size: var(--fs-14); color: var(--muted); font-weight: 600; }
.q-sec .section-head .aside { font-variant-numeric: tabular-nums; }
.q-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.q-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.q-row.q-later .q-title { color: var(--text); font-weight: 500; }
.q-row.is-hero {
  flex-wrap: wrap; gap: 14px; margin-bottom: 8px; padding: 18px;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); border-radius: var(--r-l);
  background: var(--brand-soft); box-shadow: var(--shadow-1);
}
.q-list:has(> .q-row.is-hero:first-child) { border-top: 0; }
.q-row.is-hero .q-main { flex: 1 1 100%; }
.q-row.is-hero .q-actions { flex: 1 1 100%; }
.q-row.is-hero .q-actions > .btn-block { flex: 1 1 auto; width: auto; }
.q-row.is-hero .q-title { font-size: 20px; font-weight: 700; }
.q-row.is-hero .q-meta { color: var(--text); }
.q-row.is-hero .src-tag { background: var(--bg); }
.q-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; color: inherit; text-decoration: none; }
.q-main:hover { text-decoration: none; }
.q-main:hover .q-title { color: var(--brand-d); }
.q-title { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--ink); font-weight: 600; font-size: var(--fs-16); }
.q-meta { color: var(--muted); font-size: var(--fs-13); overflow-wrap: anywhere; }
.q-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 3px; }
.q-tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-12); color: var(--muted); }
.q-tag.is-missed { color: var(--err); font-weight: 600; }
.q-tag.is-cb { color: var(--warm-d); font-weight: 600; }
.q-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.q-call { --h: 48px; border-radius: 50%; }
.q-dial, .q-actions .desk-only > .btn { background: var(--brand-soft); border-color: transparent; color: var(--brand-d); font-weight: 600; }
.q-dial:hover, .q-actions .desk-only > .btn:hover { background: var(--brand); color: var(--on-brand); }
.q-row.q-later .q-dial, .q-row.q-later .q-actions .desk-only > .btn { background: var(--panel); color: var(--text); }

/* ───────────── #/lead/:id ───────────── */
.lead-stale { position: sticky; top: 0; z-index: 5; padding: 8px var(--gutter) 0; background: var(--bg); }
.lead-head { margin-bottom: 14px; }
.lead-head > .back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--fs-13); margin-bottom: 6px; }
/* the title block shrinks (its pills wrap inside .lead-pills), the actions keep their place on the right — on a phone the
   «…» button stays next to the name instead of dropping onto its own line */
.lead-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: nowrap; }
.lead-titles { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1 1 auto; }
.lead-titles h1 { overflow-wrap: anywhere; }
.lead-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.lead-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }
.lead-dups { margin-bottom: 12px; }
.lead-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 32px; align-items: start; }
.lead-sec { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.lead-main > .lead-sec:first-child { margin-top: 6px; }
.lead-slotline { margin-top: 10px; }
.lead-marks { margin-top: 12px; }
.lead-cb .lc-ic { display: inline-flex; color: var(--muted); }
.lead-cb .lc-text { flex: 1; min-width: 0; color: var(--ink); }
.lead-callbar { display: none; }
@media (min-width: 1100px) {
  .lead-grid { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); }
  .lead-side .lead-tl { margin-top: 6px; padding: 16px; border-top: 0; border-radius: var(--r-l); background: var(--panel); }
  .lead-side .tl-ic { background: var(--bg); }
}

/* click-to-edit rows */
/* «Данные лида»: a two-column grid of label-over-value cells (the comment and a cell being edited span both) */
.inl-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 20px; }
.inl { display: flex; flex-direction: column; min-width: 0; padding: 4px 0 2px; }
.inl.is-wide, .inl.is-editing { grid-column: 1 / -1; }
.inl-label { color: var(--muted); font-size: var(--fs-12); }
.inl-value {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: calc(100% + 16px); min-height: 34px; margin: 0 -8px; padding: 4px 8px;
  border: 0; border-radius: var(--r-s); background: none; color: var(--ink); font-weight: 500; text-align: left; cursor: pointer;
}
.inl-add { color: var(--placeholder); font-weight: 400; }
.inl-value:hover { background: var(--panel); }
.inl-value .ic { color: var(--faint); opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.inl-value:hover .ic, .inl-value:focus-visible .ic { opacity: 1; }
.inl-text { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.inl-edit { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 8px; }

/* timeline */
.tl-compose { margin-top: 2px; }
.timeline { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; }
.tl-item { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding-bottom: 14px; }
.tl-item::before { content: ""; position: absolute; left: 14px; top: 32px; bottom: 2px; width: 2px; border-radius: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); color: var(--muted); }
.tl-item.tone-ok .tl-ic { background: var(--ok-soft); color: var(--ok); }
.tl-item.tone-err .tl-ic { background: var(--err-soft); color: var(--err); }
.tl-item.tone-warn .tl-ic { background: var(--warn-soft); color: var(--warn); }
.tl-body { min-width: 0; padding-top: 4px; }
.tl-title { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.tl-meta { margin-top: 2px; color: var(--muted); font-size: var(--fs-12); }
.tl-text { margin-top: 4px; color: var(--text); font-size: var(--fs-13); overflow-wrap: anywhere; }
.tl-note { padding: 8px 10px; border-radius: var(--r-s); background: var(--warm-soft); white-space: pre-wrap; }
.tl-audio { display: block; width: 100%; max-width: 360px; height: 36px; margin-top: 6px; }

/* ───────────── #/leads ───────────── */
.lt-filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.lt-dates { flex-wrap: wrap; }
.lt-table td { font-size: var(--fs-13); }
.lt-table .lt-name a { color: var(--ink); font-weight: 500; }
.lt-table .lt-comment .ellipsis, .lt-table .lt-reason .ellipsis { display: block; max-width: 240px; }
.lt-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.lt-card-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }

/* ───────────── #/board ───────────── */
.board-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.board-top { flex: none; padding: 24px var(--gutter) 14px; }
.board-top .page-head { margin-bottom: 12px; }
.board-fail { flex: 1; display: grid; place-items: center; }
.board-card { user-select: none; -webkit-user-select: none; }
.board-card .bc-link { position: absolute; inset: 0; z-index: 0; border-radius: inherit; }
.board-card .bc-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* the stretched link takes the clicks; only real controls inside the card stay clickable */
.board-card > :not(.bc-link) { position: relative; z-index: 1; pointer-events: none; }
.board-card button { pointer-events: auto; }
.board-card .bc-left { min-width: 0; overflow: hidden; }
.board-card .bc-move { margin-right: -6px; }
.board-card .bc-stale { display: inline-flex; align-items: center; gap: 3px; }
.board-more { display: block; padding: 6px; text-align: center; font-size: var(--fs-13); }
.board-col.is-drop-no { opacity: .5; }
.bc-ghost { position: fixed; left: 0; top: 0; z-index: var(--z-menu); margin: 0; pointer-events: none; box-shadow: var(--shadow-3); }
body.is-board-dragging, body.is-board-dragging * { cursor: grabbing !important; }

/* ───────────── #/calls ───────────── */
.calls-page .tabs { margin-bottom: 14px; }
.calls-tools { margin-bottom: 6px; }
.calls-intro { margin-bottom: 12px; max-width: 70ch; }
.calls-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--panel); color: var(--muted); flex: none; }
.calls-row.tone-ok .calls-ic, .calls-ic.tone-ok { background: var(--ok-soft); color: var(--ok); }
.calls-row.tone-err .calls-ic, .calls-ic.tone-err { background: var(--err-soft); color: var(--err); }
.calls-row.tone-warn .calls-ic, .calls-ic.tone-warn { background: var(--warn-soft); color: var(--warn); }
.calls-row .title a { color: var(--ink); }
.calls-more { margin-top: 12px; }
.calls-new { flex-wrap: wrap; }
.calls-new-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ───────────── #/phone ───────────── */
.phone-pair { display: flex; flex-direction: column; gap: 14px; }
.phone-pair-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); flex: none; }
.phone-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.phone-dot.is-ok { background: var(--ok); }
.phone-dot.is-bad { background: var(--err); }
.phone-restricted { margin-top: 10px; }
.phone-unpair { margin-top: 24px; }
.phone-install { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; align-items: start; margin-bottom: 16px; }
.phone-qr { display: flex; flex-direction: column; gap: 12px; width: 240px; max-width: 100%; }
.phone-qr .qr { align-self: center; }
.phone-server { margin-top: 8px; flex-wrap: wrap; }
.phone-server code { padding: 4px 8px; border-radius: 6px; background: var(--panel); color: var(--ink); overflow-wrap: anywhere; }

/* ───────────── #/me ───────────── */
.me-tools { margin-bottom: 4px; }
.me-chart { margin-top: 14px; min-height: 200px; }

/* ───────────── phones ───────────── */
@media (max-width: 899px) {
  .q-row { gap: 8px; }
  .q-row.is-hero { padding: 16px; }
  .lead-callbar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; bottom: 0; z-index: 4;
    margin: 20px calc(var(--gutter) * -1) -32px; padding: 10px var(--gutter);
    background: var(--bg); border-top: 1px solid var(--line);
  }
  .lead-callbar .lc-main { flex: 1; min-width: 0; }
  .board-top { padding: 16px var(--gutter) 10px; }
  .board-card .bc-move { margin-right: -4px; }
  .calls-new-actions { flex: 1 1 100%; padding-left: 48px; }
  .calls-row .end { flex-direction: column; align-items: flex-end; gap: 2px; }
  .lt-filters .toolbar > .select, .lt-filters .toolbar > .chip { flex: 1 1 calc(50% - 4px); }
}
@media (max-width: 699px) {
  .phone-install { grid-template-columns: minmax(0, 1fr); }
  .phone-qr { justify-self: center; }
}
@media (max-width: 599px) {
  .inl-list { gap: 2px 12px; }
  .deal-close, .qf-choice { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (pointer: coarse) {
  /* operator screens: every tap target at least 44 px, small buttons included */
  :is(.q-page, .lead-page, .lt-page, .board-top, .calls-page, .phone-page, .me-page, .pc) .btn-sm { --h: 44px; }
  .inl-value { min-height: 44px; }
  .inl-value .ic { opacity: .7; }
  .ops-steps button { height: 44px; }
}
