/* Шапка «Сделки» в духе Битрикс24: заголовок · Создать · воронка · поиск с плашками фильтров;
   ниже — вид и быстрые фильтры со счётчиками */
.hd { display: flex; flex-direction: column; gap: 10px; }
.hd-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hd .brand .mark { width: 36px; height: 36px; font-size: 11.5px; }
.hd-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0 4px 0 0; }

/* Создать */
.split-create { position: relative; display: flex; }
.split-create button { border: none; cursor: pointer; color: #fff; background: #178a46; font-weight: 700; font-size: 14px; min-height: 40px; }
.split-create button:hover { background: #12733a; }
.create-main { display: inline-flex; align-items: center; gap: 7px; padding: 0 16px 0 14px; border-radius: 20px 0 0 20px; }
.create-more { padding: 0 12px; border-radius: 0 20px 20px 0; border-left: 1px solid rgba(255,255,255,.35) !important; }

/* выпадающие меню */
.dd { position: absolute; top: calc(100% + 6px); left: 0; min-width: 230px; background: #fff; border-radius: 14px;
      box-shadow: 0 10px 34px rgba(20,30,50,.18); padding: 6px; z-index: 45; display: flex; flex-direction: column; }
.dd[hidden] { display: none; }
.dd a, .dd button { display: block; text-align: left; padding: 9px 12px; border-radius: 9px; text-decoration: none; color: var(--text);
                    background: none; border: none; cursor: pointer; font-size: 14px; }
.dd a:hover, .dd button:hover { background: var(--soft); color: var(--text); }
.dd a.on { font-weight: 700; color: var(--accent-dark); background: var(--accent-soft); }
.dd small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }

/* воронка */
.pipe-dd { position: relative; }
.pipe-btn { display: inline-flex; align-items: center; gap: 8px; border: none; background: #fff; border-radius: 20px; padding: 0 14px;
            min-height: 40px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--text); white-space: nowrap; }
.pipe-btn:hover { box-shadow: 0 0 0 2px var(--accent-ring); }
.pipe-btn svg:first-child { color: var(--accent); }

/* поиск с плашками фильтров */
.sbox { position: relative; flex: 1 1 360px; max-width: 720px; display: flex; align-items: center; gap: 6px; background: #fff;
        border-radius: 20px; padding: 4px 6px 4px 6px; min-height: 40px; flex-wrap: wrap; }
.sbox:focus-within { box-shadow: 0 0 0 2px var(--accent-ring); }
.fchip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent-dark); border-radius: 14px;
         padding: 5px 8px 5px 12px; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.fchip span[aria-hidden] { font-size: 16px; line-height: 1; opacity: .6; }
.fchip:hover { color: var(--accent-dark); background: #d3ece8; }
.fchip:hover span[aria-hidden] { opacity: 1; }
.sbox input#searchQ { flex: 1 1 160px; border: none; outline: none; font-size: 14px; padding: 6px 8px; min-width: 120px; background: transparent; }
.sbtn { width: 32px; height: 32px; border-radius: 50%; border: none; background: none; display: grid; place-items: center; color: var(--muted);
        cursor: pointer; text-decoration: none; flex: none; }
.sbtn:hover { background: var(--soft); color: var(--text); }

/* строка 2: вид и быстрые фильтры */
.hd-row2 { gap: 10px; }
.views { display: flex; background: #dde3ea; border-radius: 12px; padding: 3px; }
.views a { font-size: 13px; text-decoration: none; color: #3d4350; padding: 6px 14px; border-radius: 9px; }
.views a:hover { color: var(--text); }
.views a.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.quick { display: flex; background: #dde3ea; border-radius: 12px; padding: 3px; flex-wrap: wrap; }
.quick a { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; text-decoration: none; color: #3d4350; padding: 5px 12px 5px 6px; border-radius: 9px; }
.quick a:hover { color: var(--text); background: rgba(255,255,255,.5); }
.quick a.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.quick .n { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: #c9d2dc; color: #3d4350; font-size: 12px;
            display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.quick .n.blue { background: #2a78d6; color: #fff; }
.quick .n.red { background: #c62f2e; color: #fff; }
.hd-today { margin-left: auto; font-size: 13px; color: var(--muted); }
.unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2a78d6; margin-right: 6px; vertical-align: 1px; }
.qi.on .unread-dot { background: #fff; }

/* фильтры раскрываются под строкой поиска */
.sbox .filter-pop { top: calc(100% + 8px); left: 0; right: 0; }

@media (max-width: 900px) {
  .hd-title { font-size: 22px; }
  .sbox { order: 5; flex-basis: 100%; max-width: none; }
  .hd-today { display: none; }
}
.split-create .dd button { color: var(--text); background: none; font-weight: 400; min-height: 0; border-radius: 9px; }
.split-create .dd button:hover { background: var(--soft); }
.board.staged { grid-template-columns: repeat(var(--n, 8), minmax(250px, 1fr)); }

/* чат: системные строки, вкладки этапов */
.sysline { align-self: center; max-width: 85%; text-align: center; font-size: 12px; color: var(--muted); background: #e9edf2; border-radius: 12px; padding: 6px 12px; line-height: 1.4; }
.sysline span { opacity: .8; }
.stage-tabs { display: flex; gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; background: #fff; }
.stage-tabs button { border: none; background: var(--soft); border-radius: 14px; padding: 6px 12px; font-size: 12px; cursor: pointer; white-space: nowrap; color: #3d4350; }
.stage-tabs button.on { background: var(--accent); color: #fff; font-weight: 600; }
.stage-tabs button.cur:not(.on) { box-shadow: inset 0 0 0 1.5px var(--accent); }
.stage-tag { display: inline-block; background: rgba(15,118,110,.12); color: var(--accent-dark); border-radius: 8px; padding: 0 6px; font-size: 10.5px; font-weight: 600; margin-right: 4px; }
.row.out .stage-tag { background: rgba(255,255,255,.22); color: #fff; }

/* правая панель: поля обращения/случая */
.meta { display: flex; flex-direction: column; gap: 8px; }
.meta-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.meta-title .muted { font-weight: 500; font-size: 12px; }
.meta-h { font-weight: 700; font-size: 13px; margin-top: 4px; }
.mf { display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 13px; }
.mf > span { color: var(--muted); }
.mf select, .mf input { width: 100%; font-size: 13px; border: none; background: var(--soft); border-radius: 12px; padding: 8px 10px; }
.mf select.auto { background: #fff3d6; }
.auto-tag { font-style: normal; font-size: 10px; font-weight: 700; background: #fff3d6; color: #6b4a00; border-radius: 6px; padding: 0 5px; margin-left: 4px; }
.meta-cases { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.case-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-decoration: none; color: var(--text); background: var(--soft); border-radius: 12px; padding: 8px 10px; font-size: 13px; }
.case-link:hover { background: #e6ebf0; color: var(--text); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.owner-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 6px; border-radius: 10px; }
.owner-row.cur { background: var(--accent-soft); font-weight: 600; }
.owner-row select { font-size: 12px; border: none; background: var(--soft); border-radius: 10px; padding: 6px 8px; }
.side-person { display: flex; flex-direction: column; gap: 14px; }
#sideMeta { display: flex; flex-direction: column; gap: 14px; }
.w-sum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
details.more summary { cursor: pointer; font-size: 13px; color: var(--accent); margin-top: 8px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { margin-bottom: 8px; }

/* правая панель чата: этапы статуса и чипы полей обращения */
.steps { display: flex; margin: 4px 0 2px; }
.step { flex: 1; position: relative; border: none; background: none; padding: 20px 2px 2px; font-family: inherit; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; }
.step::before { content: ''; position: absolute; top: 5px; left: 50%; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: #cfd6de; z-index: 1; }
.step::after { content: ''; position: absolute; top: 9px; left: -50%; width: 100%; height: 2px; background: #cfd6de; }
.step:first-child::after { display: none; }
.step.done::before, .step.done::after, .step.on::after { background: var(--accent); }
.step.on::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring, #d5ece9); }
.step.on { color: var(--text); cursor: default; }
.step:not(.on):not(:disabled):hover { color: var(--accent); }
.steps.ro .step { cursor: default; }
.av.xs { width: 18px; height: 18px; font-size: 8.5px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-ring, #d5ece9); color: var(--accent-dark, #0b5a54); font-weight: 700; }

/* карточка исполнителя: контракт, плитки, детализация */
.ct-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.ct-sub { font-size: 12px; margin-top: 2px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tile { background: var(--soft); border-radius: 12px; padding: 9px 10px; min-width: 0; }
.tile > span { font-size: 11.5px; color: var(--muted); }
.tile b { display: block; font-size: 18px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.bal { background: #e6f4f2; }
.tile.ud { background: #fde8e8; }
.tbar { display: block; height: 5px; border-radius: 3px; background: rgba(0,0,0,.08); overflow: hidden; margin-top: 4px; }
.tbar i { display: block; height: 100%; background: var(--accent); }
.fold > summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; }
.fold > summary::-webkit-details-marker, .pc > summary::-webkit-details-marker { display: none; }
.fold .arr, .pc .arr { color: var(--muted); transition: transform .15s; display: inline-block; }
.fold[open] > summary .arr, .pc[open] > summary .arr { transform: rotate(90deg); }
.fold[open] > summary { margin-bottom: 6px; }
.stmt { font-size: 12.5px; }
.stmt .kv.sub { padding-left: 10px; }
.stmt .kv.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; font-weight: 700; }
.stmt .kv.total span:first-child { color: var(--text); }
.stmt .neg { color: #b3261e; }
.ded { display: grid; grid-template-columns: 38px 1fr auto; gap: 6px; font-size: 12px; padding: 2px 0 2px 4px; }
.pc { border-top: 1px solid var(--line); padding: 8px 0 6px; }
.pc:first-of-type { border-top: none; }
.pc > summary { display: grid; grid-template-columns: 1fr auto 10px; gap: 8px; align-items: center; cursor: pointer; list-style: none; font-size: 12.5px; }
.pc > summary .muted { font-size: 11.5px; }
.pc-body { background: var(--soft); border-radius: 12px; padding: 8px 10px; margin-top: 8px; }

/* поля обращения под этапами: сетка 2×2 без плашек */
.mgrid { display: grid; grid-template-columns: 1fr 1fr; margin-top: 8px; border-top: 1px solid var(--line); }
.mcell { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 7px 8px; border-radius: 10px; min-width: 0; cursor: pointer; }
.mcell:hover:not(.ro) { background: var(--soft); }
.mcell.ro { cursor: default; }
.mcell small { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mcell > span, .mcell input { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcell select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.mcell input { border: none; background: none; padding: 0; font-family: inherit; color: var(--text); outline: none; width: 100%; display: block; }
.auto-dot { font-style: normal; text-transform: none; letter-spacing: 0; background: #fff3d6; color: #8a5a00; border-radius: 6px; padding: 0 5px; margin-left: 3px; }
.stmt .kv.sec { font-weight: 700; padding-top: 6px; }
.stmt .kv.sec span:first-child { color: var(--text); }
.dlist > div { font-size: 12px; padding: 6px 0 6px 10px; border-bottom: 1px solid var(--line); }

/* выбор объекта с поиском */
#objCell { position: relative; }
#objCell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.opick { position: absolute; z-index: 30; top: 2px; left: 0; width: max(100%, 260px); background: #fff; border-radius: 12px; box-shadow: 0 8px 28px rgba(16,24,40,.18); padding: 6px; cursor: default; }
.opick input { width: 100%; border: none; background: var(--soft); border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 13px; outline: none; }
.opick-list { max-height: 260px; overflow: auto; margin-top: 4px; display: flex; flex-direction: column; }
.opick-list button { text-align: left; border: none; background: none; border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text); }
.opick-list button:hover, .opick-list button.hl { background: var(--soft); }
.opick-list button.hl { box-shadow: inset 3px 0 0 var(--accent); }
.opick-none { padding: 8px 10px; color: var(--muted); font-size: 12.5px; }

/* детализация: строки «Начислено» / «Удержания» раскрываются */
.sline { border-bottom: 1px solid var(--line); }
.sline > summary { display: grid; grid-template-columns: 1fr auto 12px; gap: 8px; align-items: center; padding: 8px 0; cursor: pointer; list-style: none; font-weight: 600; }
.sline > summary::-webkit-details-marker { display: none; }
.sline > summary .arr { color: var(--muted); transition: transform .15s; display: inline-block; text-align: center; }
.sline[open] > summary .arr { transform: rotate(90deg); }
.sline > summary:hover { color: var(--accent); }
.sbody { padding: 0 0 8px 10px; }
.sbody .dlist > div { padding-left: 0; }
.stmt .kv.total { border-top: none; }

/* кнопка «Скопировать» расшифровку */
.fold-r { display: inline-flex; align-items: center; gap: 8px; }
.copy-btn { border: none; background: var(--soft); color: var(--text); border-radius: 9px; padding: 4px 9px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.copy-btn:hover { background: #e2e8ee; color: var(--accent); }
.copy-btn.ok { background: #e3f1df; color: #1c7a3c; }
.pc-copy { margin-top: 8px; text-align: right; }

/* объект сверху — только при расхождении с 1С или если 1С не знает человека */
.mcell.wide { grid-column: 1 / -1; }
.mcell.diff { background: #fff8e6; }
.mcell.diff:hover { background: #fff1cc; }
.ct-sub { position: relative; }
.obj-edit { border: none; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 12px; border-radius: 6px; }
.obj-edit:hover, .obj-edit:focus-visible { color: var(--accent); background: var(--soft); }
.ct-sub .opick { top: 18px; }

/* календарь смен */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal-nav { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.cal-nav span { min-width: 104px; text-align: center; }
.cal-nav button { border: none; background: var(--soft); border-radius: 8px; width: 26px; height: 26px; cursor: pointer; font-size: 15px; color: var(--text); }
.cal-nav button:disabled { opacity: .35; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { font-size: 10.5px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cal-d { aspect-ratio: 1; display: grid; place-items: center; border-radius: 9px; font-size: 12px; color: var(--muted); background: var(--soft); }
.cal-d.w { background: var(--accent); color: #fff; font-weight: 700; cursor: help; }
.cal-d.n { background: #134e4a; }
.cal-d.i { background: #fff3d6; color: #8a5a00; font-weight: 700; cursor: help; }
.cal-d.today { box-shadow: 0 0 0 2px var(--text) inset; }
.cal-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 11.5px; color: var(--muted); align-items: center; }
.cal-foot .lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.lg.w { background: var(--accent); } .lg.n { background: #134e4a; } .lg.i { background: #fff3d6; border: 1px solid #e8cf8f; }
.cal-cnt { margin-left: auto; font-weight: 600; color: var(--text); }

/* календарь смен — компактный */
#shiftCal { padding: 16px; }   /* поля как у остальных карточек */
.cal-head { margin-bottom: 4px; }
.cal-nav { gap: 4px; font-size: 12px; }
.cal-nav span { min-width: 92px; }
.cal-nav button { width: 22px; height: 22px; font-size: 13px; }
.cal-grid { gap: 2px; }
.cal-wd { font-size: 9.5px; padding-bottom: 0; }
.cal-d { aspect-ratio: auto; height: 20px; border-radius: 5px; font-size: 10.5px; background: none; }
.cal-foot { margin-top: 4px; font-size: 10.5px; gap: 2px 10px; }
.cal-head b { font-size: 14px; }
.cal-d { color: var(--text); }
.cal-foot { margin-top: 8px; }

/* правая колонка: карточки не сжимаются (иначе содержимое вылезает за скругления),
   всё плотнее — в обычном виде помещается без прокрутки; прокрутка появляется, когда раскрыли детализацию или прошлые контракты */
.side > *, .side-person > * { flex-shrink: 0; }
.side, .side-person { gap: 10px; }
.side .card, #shiftCal { padding: 12px 14px; }
.side .card .ttl { margin: 2px 0 2px; font-size: 15px; }
.side .meta { gap: 4px; }
.side .meta-title { margin-bottom: 0; }
.steps { margin: 0; }
.step { padding-top: 18px; }
.mgrid { margin-top: 4px; }
.mcell { padding: 5px 8px; }
.ct-head { margin-top: 6px; }
.tiles { gap: 6px; margin-top: 8px; }
.tile { padding: 6px 9px; }
.tile b { font-size: 16px; }
.fold > summary { min-height: 24px; }
.cal-d { height: 18px; }
.cal-foot { margin-top: 6px; }
.side { scrollbar-width: thin; }


/* обёртка содержимого страницы — для обновления без перезагрузки; на раскладку не влияет */
.page-body { display: contents; }
body.loading #pageBody > *, body.loading #queue { opacity: .55; transition: opacity .15s; }
.schips { display: contents; }
#sClear { display: contents; }
